From 72b158ba5929d3e23c1443e0f0868d7bcbb56088 Mon Sep 17 00:00:00 2001 From: benb365 Date: Sat, 18 Sep 2021 01:38:05 +0000 Subject: [PATCH] fix js mediaquery in ace1.0 --- runtime/main/app/index.ts | 12 ++++++------ runtime/main/extend/mediaquery/pluginMediaQuery.ts | 6 ------ runtime/main/model/index.ts | 12 ++++++------ test/ut/app/bundle.ts | 8 ++++---- test/ut/manage/bridge.ts | 10 +++++----- 5 files changed, 21 insertions(+), 27 deletions(-) diff --git a/runtime/main/app/index.ts b/runtime/main/app/index.ts index bdc572cb..66c5a33a 100644 --- a/runtime/main/app/index.ts +++ b/runtime/main/app/index.ts @@ -34,16 +34,16 @@ import { requireModule } from '../page/register'; */ export interface MediaQueryInfo { 'orientation': string; - 'deviceType': string; - 'deviceWidth': string; - 'deviceHeight': string; - 'roundScreen': boolean; + 'device-type': string; + 'device-width': string; + 'device-height': string; + 'round-screen': boolean; 'width': string; 'height': string; 'isInit': boolean; 'resolution': string; - 'aspectRatio': string; - 'darkMode': string; + 'aspect-ratio': string; + 'dark-mode': string; } /** diff --git a/runtime/main/extend/mediaquery/pluginMediaQuery.ts b/runtime/main/extend/mediaquery/pluginMediaQuery.ts index a5b82729..b24381a3 100644 --- a/runtime/main/extend/mediaquery/pluginMediaQuery.ts +++ b/runtime/main/extend/mediaquery/pluginMediaQuery.ts @@ -90,12 +90,6 @@ export class MediaQueryApi { if (!this._mqlArray || this._mqlArray.length === 0) { return; } - data['device-type'] = data.deviceType; - data['aspect-ratio'] = data.aspectRatio; - data['device-width'] = data.deviceWidth; - data['device-height'] = data.deviceHeight; - data['round-screen'] = data.roundScreen; - data['dark-mode'] = data.darkMode; for (let i = 0; i < this._mqlArray.length; i++) { const mediaQueryList:MediaQueryList = this._mqlArray[i]; const result: boolean = matchMediaQueryCondition(mediaQueryList.condition, data, true); diff --git a/runtime/main/model/index.ts b/runtime/main/model/index.ts index 683c3d84..cb254205 100644 --- a/runtime/main/model/index.ts +++ b/runtime/main/model/index.ts @@ -189,12 +189,12 @@ export default class Vm { this.mediaStatus.width = this._app.options.width; this.mediaStatus.height = this._app.options.height; this.mediaStatus.resolution = this._app.options.resolution; - this.mediaStatus['device-type'] = this._app.options.deviceType; - this.mediaStatus['aspect-ratio'] = this._app.options.aspectRatio; - this.mediaStatus['device-width'] = this._app.options.deviceWidth; - this.mediaStatus['device-height'] = this._app.options.deviceHeight; - this.mediaStatus['round-screen'] = this._app.options.roundScreen; - this.mediaStatus['dark-mode'] = this._app.options.darkMode; + this.mediaStatus['device-type'] = this._app.options['device-type']; + this.mediaStatus['aspect-ratio'] = this._app.options['aspect-ratio']; + this.mediaStatus['device-width'] = this._app.options['device-width']; + this.mediaStatus['device-height'] = this._app.options['device-height']; + this.mediaStatus['round-screen'] = this._app.options['round-screen']; + this.mediaStatus['dark-mode'] = this._app.options['dark-mode']; // If there is no parentElement, specify the documentElement. this._parentEl = parentEl || this._app.doc.documentElement; diff --git a/test/ut/app/bundle.ts b/test/ut/app/bundle.ts index aa05e9a8..da26ab1f 100644 --- a/test/ut/app/bundle.ts +++ b/test/ut/app/bundle.ts @@ -41,11 +41,11 @@ describe('use defineFn/bootstrap', () => { let doc: Document; const options = { orientation: 'portrait', - deviceType: 'phone', + 'device-type': 'phone', resolution: '3.0', - aspectRatio: 'string', - deviceWidth: '1176', - deviceHeight: '2400', + 'aspect-ratio': 'string', + 'device-width': '1176', + 'device-height': '2400', width: '0', height: '0', isInit: true, diff --git a/test/ut/manage/bridge.ts b/test/ut/manage/bridge.ts index 8a1972ac..ef9f74fb 100644 --- a/test/ut/manage/bridge.ts +++ b/test/ut/manage/bridge.ts @@ -40,17 +40,17 @@ describe('receiveTasks', () => { const instanceId = Date.now() + ''; const options = { orientation: 'portrait', - deviceType: 'phone', + 'device-type': 'phone', resolution: '3.0', - aspectRatio: 'string', - deviceWidth: '1176', - deviceHeight: '2400', + 'aspect-ratio': 'string', + 'device-width': '1176', + 'device-height': '2400', roundScreen: false, width: '0', height: '0', isInit: true, pcPreview: 'disable', - darkMode: 'false', + 'dark-mode': 'false', appInstanceId: '10002', packageName: 'com.example.helloworld', resourcesConfiguration: [], -- Gitee