From b2c75b75b32a51cf9455913d9ec3e4e49d414bec Mon Sep 17 00:00:00 2001 From: James Chen Date: Thu, 21 Nov 2024 22:02:20 +0800 Subject: [PATCH] continue ... --- .github/workflows/gen_decorators.js | 4 - pal/env/minigame/env.ts | 3 +- pal/minigame/baidu.ts | 116 ---------------------------- 3 files changed, 1 insertion(+), 122 deletions(-) delete mode 100644 pal/minigame/baidu.ts diff --git a/.github/workflows/gen_decorators.js b/.github/workflows/gen_decorators.js index 49f8649a335..6c9b8139138 100644 --- a/.github/workflows/gen_decorators.js +++ b/.github/workflows/gen_decorators.js @@ -57,7 +57,6 @@ const BUILD_CONFIG = { HTML5: true, NATIVE: false, WECHAT: false, - BAIDU: false, XIAOMI: false, ALIPAY: false, TAOBAO: false, @@ -65,9 +64,6 @@ const BUILD_CONFIG = { OPPO: false, VIVO: false, HUAWEI: false, - COCOSPLAY: false, - QTT: false, - LINKSURE: false, EDITOR: false, PREVIEW: false, BUILD: true, diff --git a/pal/env/minigame/env.ts b/pal/env/minigame/env.ts index d3ad2879392..b84f1e0fbba 100644 --- a/pal/env/minigame/env.ts +++ b/pal/env/minigame/env.ts @@ -23,11 +23,10 @@ */ /* eslint-disable import/no-dynamic-require */ -import { BAIDU, TAOBAO, TAOBAO_MINIGAME, WECHAT, WECHAT_MINI_PROGRAM, XIAOMI } from 'internal:constants'; +import { TAOBAO, TAOBAO_MINIGAME, WECHAT, WECHAT_MINI_PROGRAM, XIAOMI } from 'internal:constants'; import { checkPalIntegrity, withImpl } from '../../integrity-check'; declare const require: (path: string) => any; -declare const __baiduRequire: (path: string) => any; declare const __wxRequire: (path: string) => any; declare const __taobaoRequire: (path: string) => any; diff --git a/pal/minigame/baidu.ts b/pal/minigame/baidu.ts deleted file mode 100644 index 2f0b86ea669..00000000000 --- a/pal/minigame/baidu.ts +++ /dev/null @@ -1,116 +0,0 @@ -/* - Copyright (c) 2022-2023 Xiamen Yaji Software Co., Ltd. - - https://www.cocos.com/ - - Permission is hereby granted, free of charge, to any person obtaining a copy - of this software and associated documentation files (the "Software"), to deal - in the Software without restriction, including without limitation the rights to - use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies - of the Software, and to permit persons to whom the Software is furnished to do so, - subject to the following conditions: - - The above copyright notice and this permission notice shall be included in - all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - THE SOFTWARE. -*/ - -import { IMiniGame } from 'pal/minigame'; -import { checkPalIntegrity, withImpl } from '../integrity-check'; -import { Orientation } from '../screen-adapter/enum-type'; -import { cloneObject, createInnerAudioContextPolyfill } from '../utils'; - -declare let swan: any; - -const minigame: IMiniGame = {} as IMiniGame; -cloneObject(minigame, swan); - -// #region SystemInfo -const systemInfo = minigame.getSystemInfoSync(); -minigame.isDevTool = systemInfo.platform === 'devtools'; - -minigame.isLandscape = systemInfo.screenWidth > systemInfo.screenHeight; -// init landscapeOrientation as LANDSCAPE_RIGHT -let landscapeOrientation = Orientation.LANDSCAPE_RIGHT; -swan.onDeviceOrientationChange((res) => { - if (res.value === 'landscape') { - landscapeOrientation = Orientation.LANDSCAPE_RIGHT; - } else if (res.value === 'landscapeReverse') { - landscapeOrientation = Orientation.LANDSCAPE_LEFT; - } -}); -Object.defineProperty(minigame, 'orientation', { - get () { - return minigame.isLandscape ? landscapeOrientation : Orientation.PORTRAIT; - }, -}); -// #endregion SystemInfo - -// #region Accelerometer -let _customAccelerometerCb: AccelerometerChangeCallback | undefined; -let _innerAccelerometerCb: AccelerometerChangeCallback | undefined; -minigame.onAccelerometerChange = function (cb: AccelerometerChangeCallback): void { - // swan.offAccelerometerChange() is not supported. - // so we can only register AccelerometerChange callback, but can't unregister. - if (!_innerAccelerometerCb) { - _innerAccelerometerCb = (res: any): void => { - let x = res.x; - let y = res.y; - if (minigame.isLandscape) { - const orientationFactor = (landscapeOrientation === Orientation.LANDSCAPE_RIGHT ? 1 : -1); - const tmp = x; - x = -y * orientationFactor; - y = tmp * orientationFactor; - } - - const resClone = { - x, - y, - z: res.z, - }; - _customAccelerometerCb?.(resClone); - }; - swan.onAccelerometerChange(_innerAccelerometerCb); - // onAccelerometerChange would start accelerometer, need to stop it mannually - swan.stopAccelerometer({}); - } - _customAccelerometerCb = cb; -}; -minigame.offAccelerometerChange = function (cb?: AccelerometerChangeCallback): void { - // swan.offAccelerometerChange() is not supported. - _customAccelerometerCb = undefined; -}; -// #endregion Accelerometer - -minigame.createInnerAudioContext = createInnerAudioContextPolyfill(swan, { - onPlay: true, - onPause: true, - onStop: true, - onSeek: false, -}); - -// #region SafeArea -minigame.getSafeArea = function (): SafeArea { - console.warn('getSafeArea is not supported on this platform'); - const systemInfo = minigame.getSystemInfoSync(); - return { - top: 0, - left: 0, - bottom: systemInfo.screenHeight, - right: systemInfo.screenWidth, - width: systemInfo.screenWidth, - height: systemInfo.screenHeight, - }; -}; -// #endregion SafeArea - -export { minigame }; - -checkPalIntegrity(withImpl());