新增沉浸式预览模式

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 { 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 {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;
export default class EntryAbility extends UIAbility {
private mainWindow: window.Window | undefined;
private subWindow: window.Window | undefined = undefined;
onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void {
//InitFont->Copy Res/resfile/font to sandbox
let sbFontsDir=this.context?.filesDir + '/fonts/';
let sbExampleDir=this.context?.filesDir + '/example/';
try {
@ -45,9 +47,16 @@ export default class EntryAbility extends UIAbility {
}
onWindowStageCreate(windowStage: window.WindowStage): void {
//InitFont->Copy Res/resfile/font to sandbox
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
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,
ChangeData.height);
});
});
//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.');
let color: string = '#00000000';
try {
this.mainWindow.setWindowBackgroundColor(color);
this.mainWindow.setWindowShadowEnabled(true);
} catch (exception) {
console.error(`Failed to set the background color. Cause code: ${exception.code}, message: ${exception.message}`);
};
});
}

View File

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

View File

@ -16,20 +16,19 @@ struct Index {
@Local isDragging:boolean=false;
@Provider('LeftSideWidth') leftSideWidth:number=mwInfo.width * 0.1;
@Provider('RightSideWidth') rightSideWidth:number=mwInfo.width * 0.1;
private uiContext: UIContext = this.getUIContext();
private overlayManager: OverlayManager = this.uiContext.getOverlayManager();
private componentContent: ComponentContent | null = null;
@Local overlayState:boolean=true;
build() {
Stack({ alignContent: Alignment.Top }) {
//OpenCAX主界面整体布局,采用多行布局
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)
//工具栏
Row() {
TitleColumnSub()
TitleColumnSub({ subOverlayState:this.overlayState!! })
}.height('4%')
.align(Alignment.Start)
@ -37,7 +36,7 @@ struct Index {
Divider().vertical(false).strokeWidth(1).lineCap(LineCapStyle.Round).width('100%').backgroundColor(Color.Grey)
Row() {
//左侧边导航区
LeftSideTab()
LeftSideTab().width(this.overlayState?this.leftSideWidth:'0%')
// 左拖拽手柄
Divider().vertical(true).strokeWidth(3).lineCap(LineCapStyle.Round).height('100%').backgroundColor(Color.Grey)
.onMouse((event) => {
@ -80,8 +79,8 @@ struct Index {
}
})
//右侧边导航区
RightSideTab()
}.height('77%')
RightSideTab().width(this.overlayState?this.rightSideWidth:'0%')
}.height(this.overlayState?'77%':'92%')
//分割线
Divider().vertical(false).strokeWidth(1).lineCap(LineCapStyle.Round).width('100%').backgroundColor(Color.Grey)
///状态栏
@ -92,7 +91,15 @@ struct Index {
.alignItems(HorizontalAlign.Start)
.justifyContent(FlexAlign.Center)
.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}){
Tabs({ barPosition: BarPosition.Start, controller: this.leftSideBarTabs }) {
TabContent() {
}
}.barHeight(0)
Blank().layoutWeight(1)
}.width(this.isExpanded?this.rightSideWidth:0)
Column({space:1}){
Button()
.backgroundImagePosition({ x: '5%', y: '5%' })

View File

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

View File

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

View File

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