解耦事件,把事件类型分为Page和Event.

Page主要针对Arkui侧的子窗口事件
Event主要针对Native侧的事件.

后续考虑解耦为如下:
Arkui_Page(主要针对子窗口归一化调用)
Arkui_Event(主要针对arkui侧的归一化动态组件操作)
Native_Page(主要针对Native侧对Arkui侧的页面数据更新和回调)
Native_Event(主要针对单一从Aarkui侧调用Native指令)

本次更新后btnEvent中增加了page地址和args.可以在预置功能中预置命令和参数.
This commit is contained in:
JackLee 2026-04-15 16:14:15 +08:00
parent ba448cd637
commit deb0edcc0d
8 changed files with 76 additions and 72 deletions

View File

@ -48,6 +48,7 @@ export default class EntryAbility extends UIAbility {
//InitFont->Copy Res/resfile/font to sandbox
InitGlobalDisplayWindowInfo(windowStage);
//Get Main Window
windowStage.getMainWindow((err, data) => {
if (err.code) {
@ -76,7 +77,6 @@ export default class EntryAbility extends UIAbility {
ChangeData.height);
});
});
//Load page
windowStage.loadContent('pages/Index', (err) => {
if (err.code) {

View File

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

View File

@ -1,5 +1,5 @@
import { hilog } from '@kit.PerformanceAnalysisKit';
import { edgeColors, display, AppStorageV2 } from '@kit.ArkUI';
import { OverlayManager } from '@kit.ArkUI';
import { TitleTab } from './TitleLayout/TitleTab'
import { LeftSideTab } from './LeftSideLayout/LeftSideTab'
import { RightSideTab } from './RightSideLayout/RightSideTab'
@ -16,31 +16,35 @@ 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;
build() {
//OpenCAX主界面整体布局,采用多行布局
Column() {
//头部导航功能区
TitleTab().height('15%')
//分割线
Divider().vertical(false).strokeWidth(1).lineCap(LineCapStyle.Round).width('100%').backgroundColor(Color.Grey)
//工具栏
Row() {
TitleColumnSub()
}.height('4%')
.align(Alignment.Start)
Column() {
//头部导航功能区
TitleTab().height('15%')
//分割线
Divider().vertical(false).strokeWidth(1).lineCap(LineCapStyle.Round).width('100%').backgroundColor(Color.Grey)
//工具栏
Row() {
TitleColumnSub()
}.height('4%')
.align(Alignment.Start)
//分割线
Divider().vertical(false).strokeWidth(1).lineCap(LineCapStyle.Round).width('100%').backgroundColor(Color.Grey)
Row() {
//左侧边导航区
LeftSideTab()
// 左拖拽手柄
Divider().vertical(true).strokeWidth(3).lineCap(LineCapStyle.Round).height('100%').backgroundColor(Color.Grey)
.onMouse((event) => {
if(event.button==MouseButton.Left&&event.action==MouseAction.Press){
this.startX = event.screenX; // 记录起始坐标
this.isDragging = true;
}else if(event.action==MouseAction.Move&&this.isDragging){
//分割线
Divider().vertical(false).strokeWidth(1).lineCap(LineCapStyle.Round).width('100%').backgroundColor(Color.Grey)
Row() {
//左侧边导航区
LeftSideTab()
// 左拖拽手柄
Divider().vertical(true).strokeWidth(3).lineCap(LineCapStyle.Round).height('100%').backgroundColor(Color.Grey)
.onMouse((event) => {
if(event.button==MouseButton.Left&&event.action==MouseAction.Press){
this.startX = event.screenX; // 记录起始坐标
this.isDragging = true;
}else if(event.action==MouseAction.Move&&this.isDragging){
// 计算新的宽度
let newWidth = this.leftSideWidth + (event.screenX - this.startX);
// 添加最小宽度限制
@ -48,47 +52,47 @@ struct Index {
this.leftSideWidth = newWidth;
// 更新起始坐标,实现连续拖动
this.startX = event.screenX;
}else if(event.action==MouseAction.Release){
this.isDragging = false;
}
})
//中间操作区域
Row() {
ModelViewTab()
}.layoutWeight(1)
.align(Alignment.Center)
//右拖拽手柄
Divider().vertical(true).strokeWidth(3).lineCap(LineCapStyle.Round).height('100%').backgroundColor(Color.Grey)
.onMouse((event) => {
if(event.button==MouseButton.Left&&event.action==MouseAction.Press){
this.startX = event.screenX; // 记录起始坐标
this.isDragging = true;
}else if(event.action==MouseAction.Move&&this.isDragging){
// 计算新的宽度
let newWidth = this.rightSideWidth - (event.screenX - this.startX);
// 添加最小宽度限制
newWidth = Math.max(newWidth, 0);
this.rightSideWidth = newWidth;
// 更新起始坐标,实现连续拖动
this.startX = event.screenX;
}else if(event.action==MouseAction.Release){
this.isDragging = false;
}
})
//右侧边导航区
RightSideTab()
}.height('77%')
//分割线
Divider().vertical(false).strokeWidth(1).lineCap(LineCapStyle.Round).width('100%').backgroundColor(Color.Grey)
///状态栏
Column() {
Text('状态栏').fontSize(16)
}else if(event.action==MouseAction.Release){
this.isDragging = false;
}
})
//中间操作区域
Row() {
ModelViewTab()
}.layoutWeight(1)
.align(Alignment.Center)
//右拖拽手柄
Divider().vertical(true).strokeWidth(3).lineCap(LineCapStyle.Round).height('100%').backgroundColor(Color.Grey)
.onMouse((event) => {
if(event.button==MouseButton.Left&&event.action==MouseAction.Press){
this.startX = event.screenX; // 记录起始坐标
this.isDragging = true;
}else if(event.action==MouseAction.Move&&this.isDragging){
// 计算新的宽度
let newWidth = this.rightSideWidth - (event.screenX - this.startX);
// 添加最小宽度限制
newWidth = Math.max(newWidth, 0);
this.rightSideWidth = newWidth;
// 更新起始坐标,实现连续拖动
this.startX = event.screenX;
}else if(event.action==MouseAction.Release){
this.isDragging = false;
}
})
//右侧边导航区
RightSideTab()
}.height('77%')
//分割线
Divider().vertical(false).strokeWidth(1).lineCap(LineCapStyle.Round).width('100%').backgroundColor(Color.Grey)
///状态栏
Column() {
Text('状态栏').fontSize(16)
}.width('100%')
.align(Alignment.End)
.alignItems(HorizontalAlign.Start)
.justifyContent(FlexAlign.Center)
.height('4%')
}.width('100%')
.align(Alignment.End)
.alignItems(HorizontalAlign.Start)
.justifyContent(FlexAlign.Center)
.height('4%')
}.width('100%')
.height('100%')
.height('100%')
}
}

View File

@ -69,6 +69,5 @@ export struct LeftSideTab {
}.barHeight(0)
}.width(this.isExpanded?this.leftSideWidth:0)
}.width('auto')
.backgroundColor($r('sys.color.background_secondary'))
}
}

View File

@ -61,10 +61,8 @@ export struct ModelViewTab {
.height('auto')
.barMode(BarMode.Fixed)
.barPosition(BarPosition.Start)
.backgroundBlurStyle(BlurStyle.COMPONENT_THIN)
.fadingEdge(true)
.barMode(BarMode.Scrollable)
.backgroundColor($r('sys.color.comp_background_secondary'))
.divider({ strokeWidth: '1px', color: $r('sys.color.comp_divider') })
}else{
Image($r('app.media.base_background'))

View File

@ -36,8 +36,6 @@ export struct RightSideTab {
}).margin({ top: 2,left:1,bottom:0,right:2})
Blank().layoutWeight(1)
}.borderWidth(1)
.borderColor(Color.Grey)
}.width('auto')
.backgroundColor($r('sys.color.background_secondary'))
}
}

View File

@ -64,5 +64,7 @@ export struct TitleColumnSub {
SubColumnMenu({menus:DisplayMode})
}.width('100%')
.height('100%')
.backgroundBlurStyle(BlurStyle.Thin,
{ colorMode: ThemeColorMode.LIGHT, adaptiveColor: AdaptiveColor.DEFAULT, scale: 1.0 })
}
}

View File

@ -87,6 +87,9 @@ export struct TitleTab {
.barHeight(0)
.barMode(BarMode.Fixed)
}.margin({ top:0, left: 0, bottom: 0, right: 0 })
.backgroundColor($r('sys.color.background_secondary'))
//.backgroundColor($r('sys.color.background_secondary'))
.borderRadius(15)
.backgroundBlurStyle(BlurStyle.Thin,
{ colorMode: ThemeColorMode.LIGHT, adaptiveColor: AdaptiveColor.DEFAULT, scale: 1.0 })
}
}