新增沉浸式预览模式

This commit is contained in:
JackLee 2026-04-15 19:57:14 +08:00
parent deb0edcc0d
commit 5781a4dc9d
7 changed files with 52 additions and 27 deletions

View File

@ -1,15 +1,17 @@
import { AbilityConstant, ConfigurationConstant, UIAbility, Want } from '@kit.AbilityKit'; import { AbilityConstant, ConfigurationConstant, UIAbility, Want } from '@kit.AbilityKit';
import { hilog } from '@kit.PerformanceAnalysisKit'; import { hilog } from '@kit.PerformanceAnalysisKit';
import { window, display, AppStorageV2 } from '@kit.ArkUI'; import { window, display, AppStorageV2, ColorMetrics } from '@kit.ArkUI';
import { IBestInit } from "@ibestservices/ibest-ui-v2" import { IBestInit } from "@ibestservices/ibest-ui-v2"
import {ExtractDir,CheckExistDir,HilogSadboxFontDirFile} from "../pages/ExtractDir/ExtractDir" import {ExtractDir,CheckExistDir,HilogSadboxFontDirFile} from "../pages/ExtractDir/ExtractDir"
import {MainWindowStageInfo,InitGlobalDisplayWindowInfo,mwInfo}from '../pages/DispWinInfo/DispWinInfo' import {MainWindowStageInfo,InitGlobalDisplayWindowInfo,mwInfo, mwsInfo}from '../pages/DispWinInfo/DispWinInfo'
const DOMAIN = 0x0000; const DOMAIN = 0x0000;
export default class EntryAbility extends UIAbility { export default class EntryAbility extends UIAbility {
private mainWindow: window.Window | undefined; private mainWindow: window.Window | undefined;
private subWindow: window.Window | undefined = undefined;
onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void {
//InitFont->Copy Res/resfile/font to sandbox
let sbFontsDir=this.context?.filesDir + '/fonts/'; let sbFontsDir=this.context?.filesDir + '/fonts/';
let sbExampleDir=this.context?.filesDir + '/example/'; let sbExampleDir=this.context?.filesDir + '/example/';
try { try {
@ -45,9 +47,16 @@ export default class EntryAbility extends UIAbility {
} }
onWindowStageCreate(windowStage: window.WindowStage): void { onWindowStageCreate(windowStage: window.WindowStage): void {
//InitFont->Copy Res/resfile/font to sandbox
InitGlobalDisplayWindowInfo(windowStage); InitGlobalDisplayWindowInfo(windowStage);
//Load page
windowStage.loadContent('pages/Index', (err) => {
if (err.code) {
hilog.error(DOMAIN, 'Tag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err));
return;
}
IBestInit(windowStage, this.context);
hilog.info(DOMAIN, 'testTag', 'Succeeded in loading the content.');
});
//Get Main Window //Get Main Window
windowStage.getMainWindow((err, data) => { windowStage.getMainWindow((err, data) => {
@ -76,15 +85,13 @@ export default class EntryAbility extends UIAbility {
console.info('Succeeded in enabling the listener for window size changes. Data:' + ChangeData.width, console.info('Succeeded in enabling the listener for window size changes. Data:' + ChangeData.width,
ChangeData.height); ChangeData.height);
}); });
}); let color: string = '#00000000';
//Load page try {
windowStage.loadContent('pages/Index', (err) => { this.mainWindow.setWindowBackgroundColor(color);
if (err.code) { this.mainWindow.setWindowShadowEnabled(true);
hilog.error(DOMAIN, 'Tag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err)); } catch (exception) {
return; console.error(`Failed to set the background color. Cause code: ${exception.code}, message: ${exception.message}`);
} };
IBestInit(windowStage, this.context);
hilog.info(DOMAIN, 'testTag', 'Succeeded in loading the content.');
}); });
} }

View File

@ -34,7 +34,7 @@ export async function CreateAndShowSubWindow(winInfo:WinInfo) {
await mwsInfo.winStage.createSubWindowWithOptions('subWindow', options).then((data) => { await mwsInfo.winStage.createSubWindowWithOptions('subWindow', options).then((data) => {
subWindow = data; subWindow = data;
//子窗口创建成功后,设置子窗口的位置、大小及相关属性等。 //子窗口创建成功后,设置子窗口的位置、大小及相关属性等。
subWindow.moveWindowTo(50, 50) subWindow.moveWindowTo(200, 200)
//子窗口重置大小 //子窗口重置大小
console.info("页面路径:", winInfo.page); console.info("页面路径:", winInfo.page);
subWindow.resize(winInfo.width,winInfo.height); subWindow.resize(winInfo.width,winInfo.height);

View File

@ -16,20 +16,19 @@ struct Index {
@Local isDragging:boolean=false; @Local isDragging:boolean=false;
@Provider('LeftSideWidth') leftSideWidth:number=mwInfo.width * 0.1; @Provider('LeftSideWidth') leftSideWidth:number=mwInfo.width * 0.1;
@Provider('RightSideWidth') rightSideWidth:number=mwInfo.width * 0.1; @Provider('RightSideWidth') rightSideWidth:number=mwInfo.width * 0.1;
private uiContext: UIContext = this.getUIContext(); @Local overlayState:boolean=true;
private overlayManager: OverlayManager = this.uiContext.getOverlayManager();
private componentContent: ComponentContent | null = null;
build() { build() {
Stack({ alignContent: Alignment.Top }) {
//OpenCAX主界面整体布局,采用多行布局 //OpenCAX主界面整体布局,采用多行布局
Column() { Column() {
//头部导航功能区 //头部导航功能区
TitleTab().height('15%') Blank().height(this.overlayState?'15%':'0%')
//TitleTab().height('15%')
//分割线 //分割线
Divider().vertical(false).strokeWidth(1).lineCap(LineCapStyle.Round).width('100%').backgroundColor(Color.Grey) Divider().vertical(false).strokeWidth(1).lineCap(LineCapStyle.Round).width('100%').backgroundColor(Color.Grey)
//工具栏 //工具栏
Row() { Row() {
TitleColumnSub() TitleColumnSub({ subOverlayState:this.overlayState!! })
}.height('4%') }.height('4%')
.align(Alignment.Start) .align(Alignment.Start)
@ -37,7 +36,7 @@ struct Index {
Divider().vertical(false).strokeWidth(1).lineCap(LineCapStyle.Round).width('100%').backgroundColor(Color.Grey) Divider().vertical(false).strokeWidth(1).lineCap(LineCapStyle.Round).width('100%').backgroundColor(Color.Grey)
Row() { Row() {
//左侧边导航区 //左侧边导航区
LeftSideTab() LeftSideTab().width(this.overlayState?this.leftSideWidth:'0%')
// 左拖拽手柄 // 左拖拽手柄
Divider().vertical(true).strokeWidth(3).lineCap(LineCapStyle.Round).height('100%').backgroundColor(Color.Grey) Divider().vertical(true).strokeWidth(3).lineCap(LineCapStyle.Round).height('100%').backgroundColor(Color.Grey)
.onMouse((event) => { .onMouse((event) => {
@ -80,8 +79,8 @@ struct Index {
} }
}) })
//右侧边导航区 //右侧边导航区
RightSideTab() RightSideTab().width(this.overlayState?this.rightSideWidth:'0%')
}.height('77%') }.height(this.overlayState?'77%':'92%')
//分割线 //分割线
Divider().vertical(false).strokeWidth(1).lineCap(LineCapStyle.Round).width('100%').backgroundColor(Color.Grey) Divider().vertical(false).strokeWidth(1).lineCap(LineCapStyle.Round).width('100%').backgroundColor(Color.Grey)
///状态栏 ///状态栏
@ -92,7 +91,15 @@ struct Index {
.alignItems(HorizontalAlign.Start) .alignItems(HorizontalAlign.Start)
.justifyContent(FlexAlign.Center) .justifyContent(FlexAlign.Center)
.height('4%') .height('4%')
}.width('100%') }
.height('100%') TitleTab()
.height(this.overlayState?'15%':'0%')
.backgroundColor(Color.Transparent)
.backgroundBlurStyle(BlurStyle.Thin, { colorMode: ThemeColorMode.LIGHT, adaptiveColor: AdaptiveColor.DEFAULT, scale: 1.0 })
}.width('100%')
.height('100%')
.backgroundColor(Color.Transparent)
.backgroundBlurStyle(BlurStyle.Thin, { colorMode: ThemeColorMode.LIGHT, adaptiveColor: AdaptiveColor.DEFAULT, scale: 1.0 })
} }
} }

View File

@ -14,10 +14,12 @@ export struct RightSideTab {
Column({space:1}){ Column({space:1}){
Tabs({ barPosition: BarPosition.Start, controller: this.leftSideBarTabs }) { Tabs({ barPosition: BarPosition.Start, controller: this.leftSideBarTabs }) {
TabContent() { TabContent() {
} }
}.barHeight(0) }.barHeight(0)
Blank().layoutWeight(1)
}.width(this.isExpanded?this.rightSideWidth:0) }.width(this.isExpanded?this.rightSideWidth:0)
Column({space:1}){ Column({space:1}){
Button() Button()
.backgroundImagePosition({ x: '5%', y: '5%' }) .backgroundImagePosition({ x: '5%', y: '5%' })

View File

@ -17,6 +17,8 @@ export struct TitleColumnSub {
@Local dX:number=0; @Local dX:number=0;
@Local dY:number=0; @Local dY:number=0;
@Local viewDialog:CustomDialogController|undefined=undefined; @Local viewDialog:CustomDialogController|undefined=undefined;
@Param subOverlayState: boolean = true;
@Event $subOverlayState: (val: boolean) => void = (val: boolean) => {};
//文件操作目录数据初始化 //文件操作目录数据初始化
private ViewDialog(): CustomDialogController { private ViewDialog(): CustomDialogController {
@ -62,6 +64,10 @@ export struct TitleColumnSub {
height: '80%' // 图片高度占满按钮 height: '80%' // 图片高度占满按钮
}) })
SubColumnMenu({menus:DisplayMode}) SubColumnMenu({menus:DisplayMode})
Blank().layoutWeight(1)
Button('TabsBar显示/隐藏').onClick(()=>{
this.$subOverlayState(!this.subOverlayState);
})
}.width('100%') }.width('100%')
.height('100%') .height('100%')
.backgroundBlurStyle(BlurStyle.Thin, .backgroundBlurStyle(BlurStyle.Thin,

View File

@ -14,6 +14,9 @@
"requestPermissions": [ "requestPermissions": [
{ {
"name": "ohos.permission.INPUT_MONITORING", "name": "ohos.permission.INPUT_MONITORING",
},
{
"name": "ohos.permission.SET_WINDOW_TRANSPARENT",
} }
], ],
"abilities": [ "abilities": [

View File

@ -2,7 +2,7 @@
"color": [ "color": [
{ {
"name": "start_window_background", "name": "start_window_background",
"value": "#FFFFFF" "value": "#00000000"
} }
] ]
} }