fix(core): 非浏览器环境屏蔽相关代码
This commit is contained in:
@@ -68,7 +68,7 @@ class App extends EventEmitter {
|
|||||||
options.designWidth && (this.designWidth = options.designWidth);
|
options.designWidth && (this.designWidth = options.designWidth);
|
||||||
|
|
||||||
// 根据屏幕大小计算出跟节点的font-size,用于rem样式的适配
|
// 根据屏幕大小计算出跟节点的font-size,用于rem样式的适配
|
||||||
if (this.platform === 'mobile' || this.platform === 'editor') {
|
if (this.jsEngine === 'browser') {
|
||||||
const calcFontsize = () => {
|
const calcFontsize = () => {
|
||||||
const { width } = document.documentElement.getBoundingClientRect();
|
const { width } = document.documentElement.getBoundingClientRect();
|
||||||
const fontSize = width / (this.designWidth / 100);
|
const fontSize = width / (this.designWidth / 100);
|
||||||
|
|||||||
@@ -75,6 +75,8 @@ const commonClickEventHandler = (app: App, eventName: string, e: any) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
export const bindCommonEventListener = (app: App) => {
|
export const bindCommonEventListener = (app: App) => {
|
||||||
|
if (app.jsEngine !== 'browser') return;
|
||||||
|
|
||||||
window.document.body.addEventListener('click', (e: any) => {
|
window.document.body.addEventListener('click', (e: any) => {
|
||||||
commonClickEventHandler(app, 'click', e);
|
commonClickEventHandler(app, 'click', e);
|
||||||
});
|
});
|
||||||
@@ -91,6 +93,8 @@ export const bindCommonEventListener = (app: App) => {
|
|||||||
export const triggerCommonMethod = (methodName: string, node: Node) => {
|
export const triggerCommonMethod = (methodName: string, node: Node) => {
|
||||||
const { instance } = node;
|
const { instance } = node;
|
||||||
|
|
||||||
|
if (!instance) return;
|
||||||
|
|
||||||
switch (methodName.replace(COMMON_METHOD_PREFIX, '')) {
|
switch (methodName.replace(COMMON_METHOD_PREFIX, '')) {
|
||||||
case CommonMethod.SHOW:
|
case CommonMethod.SHOW:
|
||||||
instance.show();
|
instance.show();
|
||||||
@@ -101,7 +105,7 @@ export const triggerCommonMethod = (methodName: string, node: Node) => {
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case CommonMethod.SCROLL_TO_VIEW:
|
case CommonMethod.SCROLL_TO_VIEW:
|
||||||
instance.$el.scrollIntoView({ behavior: 'smooth' });
|
instance.$el?.scrollIntoView({ behavior: 'smooth' });
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case CommonMethod.SCROLL_TO_TOP:
|
case CommonMethod.SCROLL_TO_TOP:
|
||||||
|
|||||||
Reference in New Issue
Block a user