From 22d82fccfc9b19fc1268e9ede619eb46efacb8e7 Mon Sep 17 00:00:00 2001 From: JackLee <809262979@qq.com> Date: Tue, 21 Apr 2026 16:19:30 +0800 Subject: [PATCH] =?UTF-8?q?1-=E5=A2=9E=E5=8A=A0=E5=AD=90=E7=AA=97=E5=8F=A3?= =?UTF-8?q?=E5=90=AF=E5=8A=A8=E7=AA=97=E5=8F=A3=E9=9A=90=E8=97=8F=202-?= =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E5=90=AF=E5=8A=A8=E8=AE=BE=E5=A4=87=E5=92=8C?= =?UTF-8?q?=E7=8A=B6=E6=80=81=E6=A3=80=E6=B5=8B(=E4=B8=8D=E9=80=82?= =?UTF-8?q?=E5=90=88=E7=9A=84=E8=AE=BE=E5=A4=87,=E6=88=96=E8=80=85?= =?UTF-8?q?=E6=9C=AA=E5=BC=80=E5=90=AF=E7=9A=84=E5=8A=9F=E8=83=BD=E4=BC=9A?= =?UTF-8?q?=E8=87=AA=E5=8A=A8=E5=85=B3=E9=97=AD,=E6=9A=82=E6=97=B6?= =?UTF-8?q?=E8=BF=98=E6=B2=A1=E5=8A=A0=E6=8F=90=E7=A4=BA)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- build-profile.json5 | 4 ++-- .../main/ets/entryability/EntryAbility.ets | 7 ++++++- .../src/main/ets/pages/eventhub/EventBase.ets | 11 ++++++---- .../src/main/ets/pages/runenvcheck/README.md | 2 ++ .../ets/pages/runenvcheck/RunEnvCheck.ets | 19 ++++++++++++++++++ .../main/ets/subwinability/SubWinAbility.ets | 5 ++++- entry/src/main/module.json5 | 11 ++-------- .../base/media/base_sub_background.png | Bin 0 -> 36445 bytes 8 files changed, 42 insertions(+), 17 deletions(-) create mode 100644 entry/src/main/ets/pages/runenvcheck/README.md create mode 100644 entry/src/main/ets/pages/runenvcheck/RunEnvCheck.ets create mode 100644 entry/src/main/resources/base/media/base_sub_background.png diff --git a/build-profile.json5 b/build-profile.json5 index 6eeae427..55306212 100644 --- a/build-profile.json5 +++ b/build-profile.json5 @@ -7,11 +7,11 @@ "material": { "certpath": "C:\\Users\\JackLee\\.ohos\\config\\default_OpenCAX_IBQbNZG6W5V0zTmQxRPojupy-F1gTlaQ6msiMPu4JRM=.cer", "keyAlias": "debugKey", - "keyPassword": "0000001B2CD38FF95C9F1C08458296E67652F4DBA4D84D03D4468A904DEDA5C7AA6ADF19C56C0E83DAFDFE", + "keyPassword": "0000001B21AB330D4506E54197E39D516254A107D6F69BEC6158A58DACD97A0661F51DB303F7F7C5E83CAA", "profile": "C:\\Users\\JackLee\\.ohos\\config\\default_OpenCAX_IBQbNZG6W5V0zTmQxRPojupy-F1gTlaQ6msiMPu4JRM=.p7b", "signAlg": "SHA256withECDSA", "storeFile": "C:\\Users\\JackLee\\.ohos\\config\\default_OpenCAX_IBQbNZG6W5V0zTmQxRPojupy-F1gTlaQ6msiMPu4JRM=.p12", - "storePassword": "0000001B34A8AD5BD79AC1BDC8894626A599B5CC3A217A7F911B96A0FDBF8C7411D838809EA9B939B34EEE" + "storePassword": "0000001B8207D7EF59E69E28EAE5FB4C9C38A1B6F70BCB0C224D0F17811D2053BFED6A612893BB9C7C0E1B" } } ], diff --git a/entry/src/main/ets/entryability/EntryAbility.ets b/entry/src/main/ets/entryability/EntryAbility.ets index f088cbd0..8731a3f9 100644 --- a/entry/src/main/ets/entryability/EntryAbility.ets +++ b/entry/src/main/ets/entryability/EntryAbility.ets @@ -4,7 +4,7 @@ import { window, display, AppStorageV2, ColorMetrics } from '@kit.ArkUI'; import { IBestInit } from "@ibestservices/ibest-ui-v2" import {ExtractDir,CheckExistDir,HilogSadboxFontDirFile} from "../pages/extractdir/ExtractDir" import { DisplayWindowInfo, InitGlobalDisplayWindowInfo,mdwInfo}from '../pages/displaywindowinfo/DispWinInfo' - +import {RunEnvCheck} from '../pages/runenvcheck/RunEnvCheck' const DOMAIN = 0x0000; export default class EntryAbility extends UIAbility { @@ -63,6 +63,9 @@ export default class EntryAbility extends UIAbility { console.error(`Failed to obtain the main window. Code: ${err.code}, message: ${err.message}`); return; } + if(!RunEnvCheck(data)){ + this.context.terminateSelf(); + } mdwInfo.win = data; mdwInfo.winId =data.getWindowProperties().id; //moveWindowTo @@ -99,6 +102,8 @@ export default class EntryAbility extends UIAbility { if (mdwInfo.win) { mdwInfo.win = undefined; } + let ctx =this.context.getApplicationContext() + ctx.eventHub.emit('MainWindowDestroy'); // Main window is destroyed, release UI related resources hilog.info(DOMAIN, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); } diff --git a/entry/src/main/ets/pages/eventhub/EventBase.ets b/entry/src/main/ets/pages/eventhub/EventBase.ets index b8297291..5d53d8e9 100644 --- a/entry/src/main/ets/pages/eventhub/EventBase.ets +++ b/entry/src/main/ets/pages/eventhub/EventBase.ets @@ -2,7 +2,7 @@ import { CloseSubWindow, CreateAndShowSubWindow } from './EventSubPage'; import { CreateXCompNode } from './XCompMgr'; import { mdwInfo } from '../displaywindowinfo/DispWinInfo'; import { window } from '@kit.ArkUI'; -import { common,Want } from "@kit.AbilityKit"; +import { common, StartOptions,Want } from "@kit.AbilityKit"; import NativeOpenCAX from 'libopencax.so'; import { @@ -150,7 +150,6 @@ export function EventWin(event:TitleButton){ async function EventCreateWin(): Promise{ let want: Want = { - deviceId: '', bundleName: 'com.example.opencax', abilityName: 'SubWinAbility' }; @@ -177,12 +176,16 @@ async function EventCreateWin(): Promise{ appCtx?.eventHub.off('SubWinInitialized'); }); }); + //启动参 + let options: StartOptions = { + withAnimation:false, + hideStartWindow:true + }; // 发起启动 Ability 的请求 console.info("Attempting to start SubWinAbility..."); - await ctx.startAbility(want); + await ctx.startAbility(want,options); console.info("StartAbility request sent."); - // --- 等待初始化完成事件 --- console.info("Waiting for SubWinInitialized event..."); const initResult = await initializationPromise; diff --git a/entry/src/main/ets/pages/runenvcheck/README.md b/entry/src/main/ets/pages/runenvcheck/README.md new file mode 100644 index 00000000..ffd5fa40 --- /dev/null +++ b/entry/src/main/ets/pages/runenvcheck/README.md @@ -0,0 +1,2 @@ +软件运行环境检查
+对于不支持或者未开启只有窗口的设备进行提示!
\ No newline at end of file diff --git a/entry/src/main/ets/pages/runenvcheck/RunEnvCheck.ets b/entry/src/main/ets/pages/runenvcheck/RunEnvCheck.ets new file mode 100644 index 00000000..0006f8c6 --- /dev/null +++ b/entry/src/main/ets/pages/runenvcheck/RunEnvCheck.ets @@ -0,0 +1,19 @@ +import { window} from '@kit.ArkUI'; +import { display } from '@kit.ArkUI'; +import { deviceInfo } from '@kit.BasicServicesKit'; + +export function RunEnvCheck(win:window.Window):boolean{ + let resolve:boolean=true; + //获取屏幕状态,仅仅支持横屏模式.LANDSCAPE(横屏) or LANDSCAPE_INVERTED(反向横屏) + let orientation:number = display.getDefaultDisplaySync().orientation; + if(orientation!=1 && orientation!=3){ + resolve=false; + //TIPS提示横屏 + } + let freeWinState=win.isInFreeWindowMode(); + if(!freeWinState){ + resolve=false; + //TIPS提示开启自由窗口 + } + return resolve; +} \ No newline at end of file diff --git a/entry/src/main/ets/subwinability/SubWinAbility.ets b/entry/src/main/ets/subwinability/SubWinAbility.ets index 90b923f7..50ab92fc 100644 --- a/entry/src/main/ets/subwinability/SubWinAbility.ets +++ b/entry/src/main/ets/subwinability/SubWinAbility.ets @@ -14,6 +14,9 @@ export default class SubWinAbility extends UIAbility { let winInfo=data as SubWinInfo; this.InitWindowParam(winInfo); }); + ctx.eventHub.on('MainWindowDestroy', (data: Object) => { + this.context.terminateSelf(); + }); } //执行窗口参数 InitWindowParam(winInfo:SubWinInfo){ @@ -58,7 +61,6 @@ export default class SubWinAbility extends UIAbility { } async onWindowStageCreate(windowStage: window.WindowStage): Promise { - windowStage.removeStartingWindow(); this.subWinStage=windowStage; this.subWin = await windowStage.getMainWindow(); let ctx =this.context.getApplicationContext() @@ -68,6 +70,7 @@ export default class SubWinAbility extends UIAbility { onWindowStageDestroy(): void { let ctx =this.context.getApplicationContext() ctx.eventHub.off('InitSubWindow'); + ctx.eventHub.off('MainWindowDestroy'); // Main window is destroyed, release UI related resources hilog.info(DOMAIN, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); } diff --git a/entry/src/main/module.json5 b/entry/src/main/module.json5 index ccc8a432..63d7eb4c 100644 --- a/entry/src/main/module.json5 +++ b/entry/src/main/module.json5 @@ -49,17 +49,10 @@ "description": "$string:EntryAbility_desc", "icon": "$media:base_opencax_logo", "label": "$string:EntryAbility_label", - "startWindowIcon": "$media:base_start_background", + "startWindowIcon": "$media:base_sub_background", "startWindowBackground": "$color:start_window_background", "exported": true, - "launchType":"standard", - "metadata": - [ - { - "name":"enable.remove.starting.window", - "value":"true" - } - ], + "launchType":"multiton", "skills": [ { "entities": [ diff --git a/entry/src/main/resources/base/media/base_sub_background.png b/entry/src/main/resources/base/media/base_sub_background.png new file mode 100644 index 0000000000000000000000000000000000000000..7ff5ae5121e54c9f3822e9427319f8b349090297 GIT binary patch literal 36445 zcmeI)!HbMx90%~<%a~!9a?xx`DIyZfNt@EF*=8oqwmWUfMT5hZlGU=7i&<^SK@c>m1ZU4)t!xhPOnSj?Pu$)X2i8! z5uMqH-)X9|5OKLbVzC`D@F1c*@%YW?k+hIMbG%lKzsuL$+xdHGX2V4N`ZR4ZfCr+$5zN$b&>TY6F6Gh1An-_+ONe%Hyo z_z99g0R7>3VK(;xBDkXyL$m7S(1A<$$JK+x_Iqfz-VcjiKS{%fa@Ie~XHd7ytkO literal 0 HcmV?d00001