1-去掉启动页,增加自定义启动页
2-支持重复加载page功能 3-调整TitleBar栏.subBar栏,footBar栏采用Display尺寸进行设定,不再受窗体尺寸变化而缩放.目前只支持缩放的是中间的显示栏区域. 4-修复部分设定BUG. 5-首启动页暂时还未完工,临时加载页面. 6-字体释放不再强制要求自启动 7-页面组件部分没有设定
This commit is contained in:
parent
c737830f17
commit
50bcf7b678
@ -3,7 +3,7 @@ import { hilog } from '@kit.PerformanceAnalysisKit';
|
||||
import { window, display, AppStorageV2, ColorMetrics } from '@kit.ArkUI';
|
||||
import { IBestInit } from "@ibestservices/ibest-ui-v2"
|
||||
import { DisplayWindowInfo,mdwInfo}from '../pages/dispwininfo/DispWinInfo'
|
||||
import { InitHub } from '../init/InitHub';
|
||||
import { InitInfoWindow } from './InitWindow';
|
||||
|
||||
const DOMAIN = 0x0000;
|
||||
|
||||
@ -18,48 +18,7 @@ export default class EntryAbility extends UIAbility {
|
||||
}
|
||||
|
||||
onWindowStageCreate(windowStage: window.WindowStage): void {
|
||||
if(!InitHub(windowStage.getMainWindowSync(),windowStage,this.context)){
|
||||
console.log("InitHub Failed!")
|
||||
///this.context.getApplicationContext().killAllProcesses();
|
||||
}else{
|
||||
//Get Main Window
|
||||
windowStage.getMainWindow((err, data) => {
|
||||
if (err.code) {
|
||||
console.error(`Failed to obtain the main window. Code: ${err.code}, message: ${err.message}`);
|
||||
return;
|
||||
}
|
||||
mdwInfo.win = data;
|
||||
mdwInfo.winId =data.getWindowProperties().id;
|
||||
//moveWindowTo
|
||||
data?.moveWindowTo(50, 50)
|
||||
//resize mainWindow Size
|
||||
data?.resize(mdwInfo.winWidth, mdwInfo.winHeight, (err) => {
|
||||
if (err.code) {
|
||||
console.error(`Failed to resize the window. Code: ${err.code}, message: ${err.message}`);
|
||||
return;
|
||||
}
|
||||
console.info(`Succeeded in resizing the window to ${mdwInfo.winWidth}x${mdwInfo.winHeight}.`);
|
||||
});
|
||||
|
||||
// windowSizeChangeListener to Change mainWindowWidth&&mainWindowHeight in AppStorage
|
||||
data?.on('windowSizeChange', (ChangeData) => {
|
||||
// if Size Change save to AppStorage
|
||||
mdwInfo.winWidth = ChangeData.width;
|
||||
mdwInfo.winHeight = ChangeData.height;
|
||||
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.');
|
||||
});
|
||||
}
|
||||
InitInfoWindow(windowStage,this.context);
|
||||
}
|
||||
onWindowStageDestroy(): void {
|
||||
AppStorageV2.remove<DisplayWindowInfo>(DisplayWindowInfo);
|
||||
|
||||
122
entry/src/main/ets/entryability/InitWindow.ets
Normal file
122
entry/src/main/ets/entryability/InitWindow.ets
Normal file
@ -0,0 +1,122 @@
|
||||
import { window } from "@kit.ArkUI";
|
||||
import { hilog } from "@kit.PerformanceAnalysisKit";
|
||||
import { InfoWinMargin,MainWinMargin, InitGlobalDWI, mdwInfo } from "../pages/dispwininfo/DispWinInfo";
|
||||
import common from "@ohos.app.ability.common";
|
||||
|
||||
const DOMAIN = 0x0000;
|
||||
|
||||
export enum LoadPageType{
|
||||
STAGE,
|
||||
WIN
|
||||
}
|
||||
//设置窗口在屏幕上显示位置
|
||||
function SetDisplayPosition (x:number,y:number){
|
||||
//设置窗口显示位置
|
||||
if(mdwInfo.win){
|
||||
mdwInfo.win.moveWindowTo(x, y)
|
||||
console.info(`MainWindow SetDisplayPosition:x:${x}-y:${y} `);
|
||||
}else{
|
||||
console.error(`MainWindow SetDisplayPosition Error: win is nullptr!`);
|
||||
}
|
||||
}
|
||||
//设置窗口的大小尺寸
|
||||
function SetWinSize (width:number,height:number){
|
||||
//设置窗口大小
|
||||
if(mdwInfo.win){
|
||||
mdwInfo.win.resize(mdwInfo.winWidth, mdwInfo.winHeight, (err) => {
|
||||
if (err.code) {
|
||||
console.error(`Failed to resize the window. Code: ${err.code}, message: ${err.message}`);
|
||||
return;
|
||||
}
|
||||
console.info(`Succeeded in resizing the window to ${mdwInfo.winWidth}x${mdwInfo.winHeight}.`);
|
||||
});
|
||||
}else{
|
||||
console.error(`MainWindow SetWinSize Error: win is nullptr!`);
|
||||
}
|
||||
}
|
||||
//窗口的事件监听
|
||||
function InitWinEventHub(ctx:common.UIAbilityContext){
|
||||
if(mdwInfo.win==undefined||mdwInfo.winStage==undefined){
|
||||
return;
|
||||
}
|
||||
//当窗口大小改变事件触发
|
||||
mdwInfo.win.on('windowSizeChange', (ChangeData) => {
|
||||
// if Size Change save to AppStorage
|
||||
//mdwInfo.winWidth = ChangeData.width;
|
||||
//mdwInfo.winHeight = ChangeData.height;
|
||||
console.info('Succeeded in enabling the listener for window size changes. Data:' + ChangeData.width,
|
||||
ChangeData.height);
|
||||
});
|
||||
if(ctx){
|
||||
ctx.eventHub.on('EMIT_LOADMAINPAGE', (data: Object) => {
|
||||
let runType=data as LoadPageType;
|
||||
InitLoadMainPage(runType);
|
||||
});
|
||||
}
|
||||
}
|
||||
//初始化加载信息页面
|
||||
export function InitLoadInfoPage(){
|
||||
//加载页面
|
||||
if(mdwInfo.winStage){
|
||||
mdwInfo.winStage.loadContent('pages/Info', (err) => {
|
||||
if (err.code) {
|
||||
hilog.error(DOMAIN, 'Tag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err));
|
||||
return;
|
||||
}
|
||||
hilog.info(DOMAIN, 'testTag', 'Succeeded in loading the content.');
|
||||
});
|
||||
}else{
|
||||
console.error(`InitLoadInfoPage winStage Error: win is nullptr!`);
|
||||
}
|
||||
SetWinSize(mdwInfo.winWidth,mdwInfo.winHeight)
|
||||
SetDisplayPosition((mdwInfo.displayWidth-InfoWinMargin[0])/4.16,(mdwInfo.displayHeight-InfoWinMargin[1])/4.16);
|
||||
}
|
||||
//WinStage加载软件Info页面
|
||||
export function InitLoadMainPage(rType:LoadPageType){
|
||||
//加载页面
|
||||
if(rType==LoadPageType.STAGE){
|
||||
if(mdwInfo.winStage){
|
||||
mdwInfo.winStage.loadContent('pages/Index', (err) => {
|
||||
if (err.code) {
|
||||
hilog.error(DOMAIN, 'Tag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err));
|
||||
return;
|
||||
}
|
||||
hilog.info(DOMAIN, 'testTag', 'Succeeded in loading the content.');
|
||||
});
|
||||
}else{
|
||||
console.error(`InitLoadInfoPage winStage Error: win is nullptr!`);
|
||||
}
|
||||
}else if(rType==LoadPageType.WIN){
|
||||
if(mdwInfo.win){
|
||||
mdwInfo.win.setUIContent('pages/Index', (err) => {
|
||||
if (err.code) {
|
||||
hilog.error(DOMAIN, 'Tag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err));
|
||||
return;
|
||||
}
|
||||
hilog.info(DOMAIN, 'testTag', 'Succeeded in loading the content.');
|
||||
});
|
||||
mdwInfo.win.showWindow();
|
||||
}else{
|
||||
console.error(`InitLoadInfoPage winStage Error: win is nullptr!`);
|
||||
}
|
||||
}
|
||||
mdwInfo.winWidth=mdwInfo.displayWidth-MainWinMargin[0];
|
||||
mdwInfo.winHeight=mdwInfo.displayHeight-MainWinMargin[1]*2;
|
||||
SetWinSize(mdwInfo.winWidth,mdwInfo.winHeight)
|
||||
SetDisplayPosition(MainWinMargin[0]/2,MainWinMargin[1]/2);
|
||||
}
|
||||
|
||||
//初始化显示信息页面
|
||||
export function InitInfoWindow(winStage: window.WindowStage,ctx:common.UIAbilityContext){
|
||||
//通过WindowStage获取MainWindow
|
||||
winStage.getMainWindow((err, data) => {
|
||||
if (err.code) {
|
||||
console.error(`Failed to obtain the main window. Code: ${err.code}, message: ${err.message}`);
|
||||
return;
|
||||
}
|
||||
InitGlobalDWI(winStage);
|
||||
InitLoadInfoPage();
|
||||
//InitLoadMainPage(LoadPageType.STAGE)
|
||||
InitWinEventHub(ctx);
|
||||
});
|
||||
}
|
||||
@ -1,17 +0,0 @@
|
||||
import { display, window } from '@kit.ArkUI';
|
||||
import {MsgTips} from '../pages/subpages/MsgTips'
|
||||
export function InitEnv(win: window.Window):boolean {
|
||||
let resolve:boolean=true;
|
||||
//获取屏幕状态,仅仅支持横屏模式.LANDSCAPE(横屏) or LANDSCAPE_INVERTED(反向横屏)
|
||||
let orientation: number = display.getDefaultDisplaySync().orientation;
|
||||
if (orientation != 1 && orientation != 3) {
|
||||
MsgTips(win,'请切换到<横屏模式>后重试')
|
||||
return false;
|
||||
}
|
||||
let freeWinState = win.isInFreeWindowMode();
|
||||
if (!freeWinState) {
|
||||
MsgTips(win,'请开启<自由窗口模式>后重试')
|
||||
return false;
|
||||
}
|
||||
return resolve;
|
||||
}
|
||||
@ -1,32 +0,0 @@
|
||||
import { common } from "@kit.AbilityKit";
|
||||
import {
|
||||
CheckExistDir,
|
||||
ExtractDir,
|
||||
HilogSadboxFontDirFile
|
||||
} from "./ExtractDir";
|
||||
|
||||
export function InitFonts(uac:common.UIAbilityContext):boolean{
|
||||
try {
|
||||
let sbFontsDir=uac.filesDir + '/fonts/';
|
||||
let sbExampleDir=uac.filesDir + '/example/';
|
||||
if(!CheckExistDir(uac,sbFontsDir)||!CheckExistDir(uac,sbExampleDir)) {
|
||||
console.info(`first run app check dir exist`);
|
||||
console.info(`extract dir file to sandbox dir`);
|
||||
const fontsCopied = ExtractDir(uac, 'fonts');
|
||||
const exampleCopied = ExtractDir(uac, 'example');
|
||||
console.info(`ExtractResDir Done!`);
|
||||
}
|
||||
HilogSadboxFontDirFile(uac,'fonts');
|
||||
HilogSadboxFontDirFile(uac,'example');
|
||||
return true;
|
||||
} catch (err) {
|
||||
let msg = 'Unknown error';
|
||||
if (err instanceof Error) {
|
||||
msg = err.message;
|
||||
} else if (typeof err === 'string') {
|
||||
msg = err;
|
||||
}
|
||||
console.error(`Init Fonts Failed: ${msg}, error code: ${err.code}`);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@ -1,20 +0,0 @@
|
||||
import {display,window} from '@kit.ArkUI';
|
||||
import {mdwInfo} from '../pages/dispwininfo/DispWinInfo'
|
||||
export function InitGlobalDWI(windowStage: window.WindowStage):boolean{
|
||||
try{
|
||||
mdwInfo.displayId = display.getDefaultDisplaySync().id;
|
||||
mdwInfo.displayWidth = display.getDefaultDisplaySync().width;
|
||||
mdwInfo.displayHeight = display.getDefaultDisplaySync().height;
|
||||
|
||||
mdwInfo.winWidth = mdwInfo.displayWidth-100;
|
||||
mdwInfo.winHeight = mdwInfo.displayHeight-200;
|
||||
mdwInfo.winStage= windowStage;
|
||||
|
||||
console.error(`Display Size:`,mdwInfo.displayWidth,mdwInfo.displayHeight);
|
||||
console.error(`MainWindow Size:`,mdwInfo.winWidth,mdwInfo.winHeight);
|
||||
return true;
|
||||
}catch (err){
|
||||
console.error(`Failed to InitGlobalDWI. Code: ${err.code}, message: ${err.message}`);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@ -1,22 +0,0 @@
|
||||
import { window } from "@kit.ArkUI";
|
||||
import { InitFonts } from "./InitFonts";
|
||||
import { InitEnv } from "./InitEnv";
|
||||
import { InitGlobalDWI } from "./InitGlobalDWI";
|
||||
import { common } from "@kit.AbilityKit";
|
||||
|
||||
export function InitHub(win:window.Window,ws:window.WindowStage,uac:common.UIAbilityContext):boolean{
|
||||
if(!InitEnv(win)){
|
||||
console.log("InitEnv Failed!")
|
||||
return false;
|
||||
}
|
||||
if(!InitFonts(uac)){
|
||||
console.log("InitFonts Failed!")
|
||||
return false;
|
||||
}
|
||||
if(!InitGlobalDWI(ws)){
|
||||
console.log("InitGlobalDWI Failed!")
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -19,8 +19,8 @@ enum DividerType{
|
||||
struct Index {
|
||||
@Local startX:number=0;
|
||||
@Local isDragging:boolean=false;
|
||||
@Provider('LeftSideWidth') leftSideWidth:number=mdwInfo.winWidth * 0.1;
|
||||
@Provider('RightSideWidth') rightSideWidth:number=mdwInfo.winHeight * 0.1;
|
||||
@Provider('LeftSideWidth') leftSideWidth:number=mdwInfo.winWidth * 0.087;
|
||||
@Provider('RightSideWidth') rightSideWidth:number=mdwInfo.winWidth * 0.087;
|
||||
|
||||
//利用分割线拖动改变区域容器大小.鼠标和触控整合
|
||||
dividerChangeSize(event:MouseEvent|TouchEvent,dividerType:DividerType){
|
||||
@ -37,7 +37,7 @@ struct Index {
|
||||
// 计算新的宽度
|
||||
let newWidth = this.leftSideWidth + (mouseEvent.windowX - this.startX);
|
||||
// 添加最小宽度限制
|
||||
newWidth = Math.max(newWidth, 0);
|
||||
newWidth = Math.max(newWidth, mdwInfo.winWidth*0.013);
|
||||
this.leftSideWidth = newWidth;
|
||||
// 更新起始坐标,实现连续拖动
|
||||
this.startX = mouseEvent.windowX;
|
||||
@ -54,7 +54,7 @@ struct Index {
|
||||
// 计算新的宽度
|
||||
let newWidth = this.rightSideWidth - (mouseEvent.windowX - this.startX);
|
||||
// 添加最小宽度限制
|
||||
newWidth = Math.max(newWidth, 0);
|
||||
newWidth = Math.max(newWidth, mdwInfo.winWidth*0.013);
|
||||
this.rightSideWidth = newWidth;
|
||||
// 更新起始坐标,实现连续拖动
|
||||
this.startX = mouseEvent.windowX;
|
||||
@ -70,18 +70,17 @@ struct Index {
|
||||
//OpenCAX主界面整体布局,采用多行布局
|
||||
Column() {
|
||||
//头部导航功能区
|
||||
Blank().height(uiMode.state?'15%':'0%')
|
||||
//TitleTab().height('15%')
|
||||
//Blank().height(uiMode.state?'15%':'0%')
|
||||
TitleTab().height(uiMode.state?mdwInfo.displayHeight*0.07:0)
|
||||
//分割线
|
||||
Divider().vertical(false).strokeWidth(1).lineCap(LineCapStyle.Round).width('100%').backgroundColor(Color.Grey)
|
||||
//工具栏
|
||||
Row() {
|
||||
TitleColumnSub()
|
||||
}.height('4%')
|
||||
.align(Alignment.Start)
|
||||
|
||||
}.height(mdwInfo.displayHeight*0.02)
|
||||
.align(Alignment.Start)
|
||||
//分割线
|
||||
Divider().vertical(false).strokeWidth(1).lineCap(LineCapStyle.Round).width('100%').backgroundColor(Color.Grey)
|
||||
Divider().vertical(false).strokeWidth(2).lineCap(LineCapStyle.Round).width('100%').backgroundColor(Color.Grey)
|
||||
Row() {
|
||||
//左侧边导航区
|
||||
LeftSideTab().width(uiMode.state?this.leftSideWidth:'0%')
|
||||
@ -97,7 +96,7 @@ struct Index {
|
||||
Row() {
|
||||
View()
|
||||
}.layoutWeight(1)
|
||||
.align(Alignment.Center)
|
||||
.align(Alignment.Center)
|
||||
//右拖拽手柄
|
||||
Divider().vertical(true).strokeWidth(3).lineCap(LineCapStyle.Round).height('100%').backgroundColor(Color.Grey)
|
||||
.onMouse((event) => {
|
||||
@ -108,26 +107,22 @@ struct Index {
|
||||
})
|
||||
//右侧边导航区
|
||||
RightSideTab().width(uiMode.state?this.rightSideWidth:'0%')
|
||||
}.height(uiMode.state?'77%':'92%')
|
||||
}.layoutWeight(1)
|
||||
//分割线
|
||||
Divider().vertical(false).strokeWidth(1).lineCap(LineCapStyle.Round).width('100%').backgroundColor(Color.Grey)
|
||||
///状态栏
|
||||
Column() {
|
||||
Row() {
|
||||
Text('状态栏').fontSize(16)
|
||||
}.width('100%')
|
||||
.align(Alignment.End)
|
||||
.alignItems(HorizontalAlign.Start)
|
||||
.justifyContent(FlexAlign.Center)
|
||||
.height('4%')
|
||||
.justifyContent(FlexAlign.Start)
|
||||
.height(mdwInfo.displayHeight*0.02)
|
||||
}
|
||||
TitleTab()
|
||||
.height(uiMode.state?'15%':'0%')
|
||||
.backgroundColor(Color.Transparent)
|
||||
.backgroundBlurStyle(BlurStyle.Thin, { colorMode: ThemeColorMode.LIGHT, adaptiveColor: AdaptiveColor.DEFAULT, scale: 1.0 })
|
||||
// TitleTab()
|
||||
// .height(uiMode.state?'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 })
|
||||
}
|
||||
}
|
||||
|
||||
103
entry/src/main/ets/pages/Info.ets
Normal file
103
entry/src/main/ets/pages/Info.ets
Normal file
@ -0,0 +1,103 @@
|
||||
import { mdwInfo } from './dispwininfo/DispWinInfo';
|
||||
import { LoadPageType } from '../entryability/InitWindow';
|
||||
import { common } from '@kit.AbilityKit';
|
||||
import { SWInfo } from './subpages/info/SWInfo';
|
||||
import { SWSrc } from './subpages/info/SWSrc';
|
||||
import { SWEnv } from './subpages/info/SWEnv';
|
||||
|
||||
|
||||
const TabsBarStr:Array<string>=['运行检测','软件介绍','更新日志','开源信息','关于']
|
||||
@Entry
|
||||
@ComponentV2
|
||||
struct Info {
|
||||
//顶部导航组件
|
||||
private titleBarTabs: TabsController = new TabsController();
|
||||
//当前的顶部导航选择页
|
||||
@Local selectedIndex: number = 0; // 当前选中的索引
|
||||
build() {
|
||||
Flex({ direction: FlexDirection.Column }){
|
||||
Scroll() {
|
||||
Row({space:0}) {
|
||||
Blank().layoutWeight(1)
|
||||
ForEach(TabsBarStr, (item: string, index: number) => {
|
||||
Button(){
|
||||
Column(){
|
||||
Text(item)
|
||||
.height('95%')
|
||||
.fontSize(index === this.selectedIndex ? 20 : 16)
|
||||
.fontWeight(index === this.selectedIndex ? FontWeight.Bold : FontWeight.Normal)
|
||||
.backgroundColor(Color.Transparent)
|
||||
Divider()
|
||||
.height('5%')
|
||||
.vertical(false)
|
||||
.strokeWidth(2)
|
||||
.lineCap(LineCapStyle.Round)
|
||||
.color(Color.Grey)
|
||||
.align(Alignment.Top)
|
||||
.visibility(index === this.selectedIndex?Visibility.Visible:Visibility.Hidden)
|
||||
}.width('100%')
|
||||
.height('100%')
|
||||
}
|
||||
.width('7%')
|
||||
.backgroundColor(index === this.selectedIndex ? $r('sys.color.container_modal_button_normal_baseboard') : Color.Transparent)
|
||||
.type(ButtonType.Normal)
|
||||
.onClick(() => {
|
||||
this.titleBarTabs.changeIndex(index);
|
||||
this.selectedIndex = index;
|
||||
})
|
||||
})
|
||||
Blank().layoutWeight(1)
|
||||
}
|
||||
}
|
||||
.height('5%')
|
||||
.align(Alignment.Center)
|
||||
.scrollable(ScrollDirection.Horizontal)
|
||||
.scrollBar(BarState.Off)
|
||||
.margin({ top: 0,left:0,bottom:0,right:0})
|
||||
//分割线
|
||||
Divider()
|
||||
.vertical(false)
|
||||
.strokeWidth(1)
|
||||
.lineCap(LineCapStyle.Round)
|
||||
.width('100%')
|
||||
.backgroundColor(Color.Grey)
|
||||
|
||||
Tabs({barPosition: BarPosition.Start, index: this.selectedIndex,controller: this.titleBarTabs}){
|
||||
TabContent() {
|
||||
SWEnv();
|
||||
}
|
||||
TabContent() {
|
||||
SWInfo();
|
||||
}
|
||||
TabContent() {
|
||||
|
||||
}
|
||||
TabContent() {
|
||||
SWSrc()
|
||||
}
|
||||
TabContent() {
|
||||
|
||||
}
|
||||
}
|
||||
.height('90%')
|
||||
.scrollable(true)
|
||||
.barHeight(0)
|
||||
.barMode(BarMode.Fixed)
|
||||
Row(){
|
||||
Blank().layoutWeight(1)
|
||||
Checkbox({ name: 'checkbox1', group: 'checkboxGroup' })
|
||||
.onChange((value: boolean) => {
|
||||
console.info('Checkbox1 change is'+ value);
|
||||
})
|
||||
Text('下次启动不再显示').fontSize(18)
|
||||
Button('确定')
|
||||
.onClick(()=>{
|
||||
let ctx=this.getUIContext().getHostContext() as common.UIAbilityContext;
|
||||
ctx.eventHub.emit('EMIT_LOADMAINPAGE',LoadPageType.STAGE)
|
||||
})
|
||||
Blank().layoutWeight(1)
|
||||
}.height('5%')
|
||||
.justifyContent(FlexAlign.Center)
|
||||
}.margin({ top:'1%', left: 0, bottom: '1%', right:0 })
|
||||
}
|
||||
}
|
||||
@ -8,8 +8,8 @@ import {
|
||||
} from "../interface/Interface";
|
||||
|
||||
//按钮统一尺寸,该按钮为正方形,所以以主窗口宽为基准,长=高->正方形
|
||||
let ebWidth=mdwInfo.winWidth*0.02;
|
||||
let ebHeigth=mdwInfo.winWidth*0.02;
|
||||
let ebWidth=mdwInfo.winWidth*0.015;
|
||||
let ebHeigth=mdwInfo.winWidth*0.015;
|
||||
//占位符的高度
|
||||
let edHeigth=mdwInfo.winWidth*0.005
|
||||
|
||||
@ -124,7 +124,7 @@ export struct MenuBtn {
|
||||
.align(Alignment.Center)
|
||||
}
|
||||
.constraintSize({ minWidth: ebWidth })
|
||||
.height(mdwInfo.winWidth*0.01)
|
||||
.height(mdwInfo.winWidth*0.011)
|
||||
.backgroundColor(Color.Transparent)
|
||||
.bindMenu(this.BaseMenu)
|
||||
.type(ButtonType.Normal)
|
||||
|
||||
@ -7,7 +7,7 @@ import {
|
||||
} from "../interface/Interface";
|
||||
|
||||
//按钮统一尺寸,该按钮为正方形,所以以主窗口宽为基准,长=高->正方形
|
||||
let ebWidth=mdwInfo.winWidth*0.02;
|
||||
let ebWidth=mdwInfo.winWidth*0.015;
|
||||
|
||||
@Builder
|
||||
export function BaseMenu(indexMenu:BaseMenuData) {
|
||||
@ -65,8 +65,8 @@ export struct GroupTextEventMenu {
|
||||
.fontSize(16)
|
||||
Blank().width('auto')
|
||||
Button()
|
||||
.height(mdwInfo.winWidth*0.005)
|
||||
.width(mdwInfo.winWidth*0.005)
|
||||
.height(mdwInfo.winWidth*0.007)
|
||||
.width(mdwInfo.winWidth*0.007)
|
||||
.padding(1)
|
||||
.backgroundColor(Color.Transparent)
|
||||
.backgroundImage($r('app.media.base_seetings'))
|
||||
|
||||
@ -1,4 +1,8 @@
|
||||
import { AppStorageV2, display,window} from '@kit.ArkUI';
|
||||
|
||||
export const InfoWinMargin:Array<number>=[1200,800]
|
||||
export const MainWinMargin:Array<number>=[100,100]
|
||||
|
||||
//该文档主要储存屏幕信息,主窗口信息,窗口管理信息
|
||||
@ObservedV2
|
||||
export class DisplayWindowInfo {
|
||||
@ -11,7 +15,6 @@ export class DisplayWindowInfo {
|
||||
@Trace public winHeight: number;
|
||||
@Trace public winStage?: window.WindowStage;
|
||||
|
||||
|
||||
constructor(
|
||||
_displayId?:number,
|
||||
_displayWidth?: number,
|
||||
@ -30,6 +33,26 @@ export class DisplayWindowInfo {
|
||||
}
|
||||
}
|
||||
|
||||
export function InitGlobalDWI(windowStage: window.WindowStage):boolean{
|
||||
try{
|
||||
mdwInfo.displayId = display.getDefaultDisplaySync().id;
|
||||
mdwInfo.displayWidth = display.getDefaultDisplaySync().width;
|
||||
mdwInfo.displayHeight = display.getDefaultDisplaySync().height;
|
||||
|
||||
mdwInfo.winWidth = mdwInfo.displayWidth-InfoWinMargin[0];
|
||||
mdwInfo.winHeight = mdwInfo.displayHeight-InfoWinMargin[1];
|
||||
mdwInfo.winStage= windowStage;
|
||||
mdwInfo.win=windowStage.getMainWindowSync();
|
||||
mdwInfo.winId =mdwInfo.win.getWindowProperties().id;
|
||||
|
||||
console.error(`Display Size:`,mdwInfo.displayWidth,mdwInfo.displayHeight);
|
||||
console.error(`MainWindow Size:`,mdwInfo.winWidth,mdwInfo.winHeight);
|
||||
return true;
|
||||
}catch (err){
|
||||
console.error(`Failed to InitGlobalDWI. Code: ${err.code}, message: ${err.message}`);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
//全局保存主窗口信息,屏幕信息.窗口管理器信息
|
||||
export let mdwInfo: DisplayWindowInfo = AppStorageV2.connect<DisplayWindowInfo>(DisplayWindowInfo, () => new DisplayWindowInfo())!;
|
||||
|
||||
43
entry/src/main/ets/pages/initEvent/InitEnv.ets
Normal file
43
entry/src/main/ets/pages/initEvent/InitEnv.ets
Normal file
@ -0,0 +1,43 @@
|
||||
import { display } from '@kit.ArkUI';
|
||||
import { mdwInfo } from '../dispwininfo/DispWinInfo';
|
||||
import { common } from "@kit.AbilityKit";
|
||||
import {
|
||||
CheckExistDir,
|
||||
ExtractDir,
|
||||
HilogSadboxFontDirFile
|
||||
} from "./ExtractDir";
|
||||
|
||||
export function FreeWinMode():boolean {
|
||||
let freeWinState = mdwInfo.win?.isInFreeWindowMode();
|
||||
if (!freeWinState) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
export function ExtractFonts():boolean{
|
||||
try {
|
||||
let ctx=mdwInfo.win?.getUIContext().getHostContext() as common.UIAbilityContext;
|
||||
let sbFontsDir=ctx.filesDir + '/fonts/';
|
||||
let sbExampleDir=ctx.filesDir + '/example/';
|
||||
if(!CheckExistDir(ctx,sbFontsDir)||!CheckExistDir(ctx,sbExampleDir)) {
|
||||
console.info(`first run app check dir exist`);
|
||||
console.info(`extract dir file to sandbox dir`);
|
||||
const fontsCopied = ExtractDir(ctx, 'fonts');
|
||||
const exampleCopied = ExtractDir(ctx, 'example');
|
||||
console.info(`ExtractResDir Done!`);
|
||||
}
|
||||
HilogSadboxFontDirFile(ctx,'fonts');
|
||||
HilogSadboxFontDirFile(ctx,'example');
|
||||
return true;
|
||||
} catch (err) {
|
||||
let msg = 'Unknown error';
|
||||
if (err instanceof Error) {
|
||||
msg = err.message;
|
||||
} else if (typeof err === 'string') {
|
||||
msg = err;
|
||||
}
|
||||
console.error(`Init Fonts Failed: ${msg}, error code: ${err.code}`);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@ -7,7 +7,7 @@ export struct LeftSideTab {
|
||||
private leftSideBarTabs: TabsController = new TabsController();
|
||||
@Local leftSideBarFocusIndex: number = 0;
|
||||
@Local isExpanded:boolean=true;
|
||||
@Consumer('LeftSideWidth') leftSideWidth:number=mdwInfo.winWidth * 0.1;
|
||||
@Consumer('LeftSideWidth') leftSideWidth:number=mdwInfo.winWidth * 0.087;
|
||||
|
||||
build() {
|
||||
Row() {
|
||||
@ -25,7 +25,7 @@ export struct LeftSideTab {
|
||||
.height(mdwInfo.winWidth*0.013)
|
||||
.onClick(()=>{
|
||||
this.isExpanded = !this.isExpanded;
|
||||
this.leftSideWidth=this.isExpanded?mdwInfo.winWidth * 0.1:mdwInfo.winWidth*0.013
|
||||
this.leftSideWidth=this.isExpanded?mdwInfo.winWidth * 0.087:mdwInfo.winWidth*0.013
|
||||
}).margin({ top: 2,left:1,bottom:0,right:2})
|
||||
Scroll() {
|
||||
Flex({ direction: FlexDirection.Column}) {
|
||||
@ -67,7 +67,7 @@ export struct LeftSideTab {
|
||||
}
|
||||
})
|
||||
}.barHeight(0)
|
||||
}.width(this.isExpanded?this.leftSideWidth:0)
|
||||
}.width(this.isExpanded?mdwInfo.winWidth * 0.087:0)
|
||||
}.width('auto')
|
||||
}
|
||||
}
|
||||
|
||||
@ -7,7 +7,7 @@ export struct RightSideTab {
|
||||
private leftSideBarTabs: TabsController = new TabsController();
|
||||
@Local leftSideBarFocusIndex: number = 0;
|
||||
@Local isExpanded:boolean=true;
|
||||
@Consumer('RightSideWidth') rightSideWidth:number=mdwInfo.winWidth * 0.1;
|
||||
@Consumer('RightSideWidth') rightSideWidth:number=mdwInfo.winWidth * 0.087;
|
||||
|
||||
build() {
|
||||
Row() {
|
||||
@ -33,10 +33,11 @@ export struct RightSideTab {
|
||||
.height(mdwInfo.winWidth*0.013)
|
||||
.onClick(()=>{
|
||||
this.isExpanded = !this.isExpanded;
|
||||
this.rightSideWidth=this.isExpanded?mdwInfo.winWidth * 0.1:mdwInfo.winWidth*0.013;
|
||||
this.rightSideWidth=this.isExpanded?mdwInfo.winWidth * 0.087:mdwInfo.winWidth*0.013;
|
||||
}).margin({ top: 2,left:1,bottom:0,right:2})
|
||||
Blank().layoutWeight(1)
|
||||
}.borderWidth(1)
|
||||
.borderColor(Color.Grey)
|
||||
.width(mdwInfo.winWidth*0.013)
|
||||
}.width('auto')
|
||||
}
|
||||
|
||||
113
entry/src/main/ets/pages/subpages/info/SWEnv.ets
Normal file
113
entry/src/main/ets/pages/subpages/info/SWEnv.ets
Normal file
@ -0,0 +1,113 @@
|
||||
import {mdwInfo}from '../../dispwininfo/DispWinInfo'
|
||||
import { TextComboBox } from '../../customcontroller/ComboBox';
|
||||
import { deviceInfo } from '@kit.BasicServicesKit';
|
||||
import { display } from '@kit.ArkUI';
|
||||
import {
|
||||
TitleButton,
|
||||
ModelType,
|
||||
EventType
|
||||
} from "../../interface/Interface";
|
||||
import {
|
||||
FreeWinMode,
|
||||
ExtractFonts
|
||||
} from '../../initEvent/InitEnv';
|
||||
|
||||
export let DisplayMode:Array<TitleButton>=[
|
||||
{btnModel:[ModelType.BASE],btnName:"横屏",btnNamed:"",btnIcon:"",btnTips:"横屏",btnEvent:{uid:'',command:'',page:'',type:EventType.EVENT,args:[]}},
|
||||
{btnModel:[ModelType.BASE],btnName:"反向横屏",btnNamed:"",btnIcon:"",btnTips:"反向横屏",btnEvent:{uid:'',command:'',page:'',type:EventType.EVENT,args:[]}}
|
||||
]
|
||||
export let DrivceMode:Array<TitleButton>=[
|
||||
{btnModel:[ModelType.BASE],btnName:"2in1",btnNamed:"",btnIcon:"",btnTips:"2in1",btnEvent:{uid:'',command:'',page:'',type:EventType.EVENT,args:[]}},
|
||||
{btnModel:[ModelType.BASE],btnName:"tablet",btnNamed:"",btnIcon:"",btnTips:"tablet",btnEvent:{uid:'',command:'',page:'',type:EventType.EVENT,args:[]}}
|
||||
]
|
||||
|
||||
//软件介绍
|
||||
@ComponentV2
|
||||
export struct SWEnv {
|
||||
//所有检测状态
|
||||
@Local envState:boolean=false;
|
||||
//设备支持状态
|
||||
@Local drivceState:boolean=false;
|
||||
//字体释放状态
|
||||
@Local fontState:boolean=false;
|
||||
//设置初始化读取状态
|
||||
@Local optsState:boolean=false;
|
||||
//事件初始化状态
|
||||
@Local eventState:boolean=false;
|
||||
//自由窗口状态
|
||||
@Local freeWinState:boolean=false;
|
||||
//屏幕方向状态
|
||||
@Local winOriState:boolean=false;
|
||||
|
||||
//当前屏幕方向文本
|
||||
@Local currentDispOriStr?:string;
|
||||
//当前设备型号
|
||||
@Local currentDrivceStr?:string;
|
||||
aboutToAppear(): void {
|
||||
this.fontState=ExtractFonts();
|
||||
this.freeWinState=FreeWinMode();
|
||||
if(display.getDefaultDisplaySync().orientation===1){
|
||||
this.currentDispOriStr=DisplayMode[0].btnName
|
||||
this.winOriState=true;
|
||||
}else if(display.getDefaultDisplaySync().orientation===3){
|
||||
this.currentDispOriStr=DisplayMode[1].btnName
|
||||
this.winOriState=true;
|
||||
}else{
|
||||
this.currentDispOriStr='当前模式不支持'
|
||||
}
|
||||
this.currentDrivceStr=deviceInfo.deviceType;
|
||||
for(let i=0;i<=DrivceMode.length;i++){
|
||||
if(this.currentDrivceStr==DrivceMode[i].btnName){
|
||||
this.drivceState=true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
@Builder
|
||||
build(){
|
||||
Column(){
|
||||
Row(){
|
||||
Image($r('app.media.base_background'))
|
||||
.width(mdwInfo.winWidth*0.1)
|
||||
.height(mdwInfo.winWidth*0.08)
|
||||
.backgroundImageSize({
|
||||
width: '100%', // 图片宽度占满按钮
|
||||
height: '100%' // 图片高度占满按钮
|
||||
})
|
||||
}.justifyContent(FlexAlign.Center)
|
||||
.height('30%')
|
||||
Column(){
|
||||
Row(){
|
||||
TextComboBox({name:'支持设备型号:',menu:DrivceMode})
|
||||
Blank().layoutWeight(1)
|
||||
Text(`当前设备型号:${this.currentDrivceStr}`)
|
||||
Blank().width('10%')
|
||||
Text('状态:')
|
||||
Checkbox().select(this.drivceState);
|
||||
}.height('10%')
|
||||
Row(){
|
||||
TextComboBox({name:'屏幕支持方向:',menu:DisplayMode})
|
||||
Blank().layoutWeight(1)
|
||||
Text(`屏幕当前方向:${this.currentDispOriStr}`)
|
||||
Blank().width('10%')
|
||||
Text('状态:')
|
||||
Checkbox().select(this.winOriState);
|
||||
}.height('10%')
|
||||
Row(){
|
||||
Text('沙箱字体状态:')
|
||||
Blank().layoutWeight(1)
|
||||
Text('状态:')
|
||||
Checkbox().select(this.fontState);
|
||||
}.height('10%')
|
||||
Row(){
|
||||
Text('自由窗口状态:')
|
||||
Blank().layoutWeight(1)
|
||||
Text('状态:')
|
||||
Checkbox().select(this.freeWinState);
|
||||
}.height('10%')
|
||||
Blank().layoutWeight(1)
|
||||
}.height('70%')
|
||||
.margin({ top: 0,left:'25%',bottom:0,right:'25%'})
|
||||
}
|
||||
}
|
||||
}
|
||||
39
entry/src/main/ets/pages/subpages/info/SWInfo.ets
Normal file
39
entry/src/main/ets/pages/subpages/info/SWInfo.ets
Normal file
@ -0,0 +1,39 @@
|
||||
import {mdwInfo}from '../../dispwininfo/DispWinInfo'
|
||||
import { LengthMetrics } from '@kit.ArkUI'
|
||||
|
||||
//软件介绍
|
||||
@ComponentV2
|
||||
export struct SWInfo {
|
||||
|
||||
@Builder
|
||||
build(){
|
||||
Column(){
|
||||
Row(){
|
||||
Image($r('app.media.base_background'))
|
||||
.width(mdwInfo.winWidth*0.1)
|
||||
.height(mdwInfo.winWidth*0.08)
|
||||
.backgroundImageSize({
|
||||
width: '100%', // 图片宽度占满按钮
|
||||
height: '100%' // 图片高度占满按钮
|
||||
})
|
||||
}.justifyContent(FlexAlign.Center)
|
||||
.height('30%')
|
||||
Column(){
|
||||
TextArea({
|
||||
text: '本软件由JackLee基于OCCT独立开发.旨在基于鸿蒙平台和OCCT构建一套强参数建模软件',
|
||||
})
|
||||
.margin({ left:36, right:36 })
|
||||
.fontWeight(FontWeight.Regular)
|
||||
.fontSize($r('sys.float.Body_L'))
|
||||
.enterKeyType(EnterKeyType.Done)
|
||||
.borderRadius($r('sys.float.corner_radius_level8'))
|
||||
.backgroundColor($r('sys.color.comp_background_tertiary'))
|
||||
.maxLines(50)
|
||||
.lineSpacing(LengthMetrics.px(5))
|
||||
.textOverflow(TextOverflow.Clip)
|
||||
.textAlign(TextAlign.Center)
|
||||
}.height('70%')
|
||||
.margin({ top: 0,left:'25%',bottom:0,right:'25%'})
|
||||
}
|
||||
}
|
||||
}
|
||||
42
entry/src/main/ets/pages/subpages/info/SWSrc.ets
Normal file
42
entry/src/main/ets/pages/subpages/info/SWSrc.ets
Normal file
@ -0,0 +1,42 @@
|
||||
import {mdwInfo}from '../../dispwininfo/DispWinInfo'
|
||||
import { LengthMetrics } from '@kit.ArkUI'
|
||||
|
||||
//软件介绍
|
||||
@ComponentV2
|
||||
export struct SWSrc {
|
||||
|
||||
@Builder
|
||||
build(){
|
||||
Column(){
|
||||
Row(){
|
||||
Image($r('app.media.base_background'))
|
||||
.width(mdwInfo.winWidth*0.1)
|
||||
.height(mdwInfo.winWidth*0.08)
|
||||
.backgroundImageSize({
|
||||
width: '100%', // 图片宽度占满按钮
|
||||
height: '100%' // 图片高度占满按钮
|
||||
})
|
||||
}.justifyContent(FlexAlign.Center)
|
||||
.height('30%')
|
||||
Column(){
|
||||
TextArea({
|
||||
text: '源码开源地址:http://git.axibug.com/JackLee/OpenCAX.git \n ' +
|
||||
'开源麻本质就是一种抄所以大家一起抄.正所谓你不抄我不抄项目怎么交 \n' +
|
||||
'一杯茶,一包烟,一行代码写一天,上午写,中午改,晚上调又调 \n'+
|
||||
'东借借,西看看,月薪指定能过万 \n',
|
||||
})
|
||||
.margin({ left:36, right:36 })
|
||||
.fontWeight(FontWeight.Regular)
|
||||
.fontSize($r('sys.float.Body_L'))
|
||||
.enterKeyType(EnterKeyType.Done)
|
||||
.borderRadius($r('sys.float.corner_radius_level8'))
|
||||
.backgroundColor($r('sys.color.comp_background_tertiary'))
|
||||
.maxLines(50)
|
||||
.lineSpacing(LengthMetrics.px(5))
|
||||
.textOverflow(TextOverflow.Clip)
|
||||
.textAlign(TextAlign.Center)
|
||||
}.height('70%')
|
||||
.margin({ top: 0,left:'25%',bottom:0,right:'25%'})
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -33,7 +33,7 @@ export struct TitleTab {
|
||||
Column(){
|
||||
Text(item.cmName)
|
||||
.height('95%')
|
||||
.fontSize(index === this.selectedIndex ? 20 : 16)
|
||||
.fontSize(index === this.selectedIndex ? 18 : 16)
|
||||
.fontWeight(index === this.selectedIndex ? FontWeight.Bold : FontWeight.Normal)
|
||||
.backgroundColor(Color.Transparent)
|
||||
|
||||
@ -84,7 +84,6 @@ export struct TitleTab {
|
||||
.barHeight(0)
|
||||
.barMode(BarMode.Fixed)
|
||||
}.margin({ top:0, left: 0, bottom: 0, right: 0 })
|
||||
//.backgroundColor($r('sys.color.background_secondary'))
|
||||
.backgroundBlurStyle(BlurStyle.Thin,
|
||||
{ colorMode: ThemeColorMode.LIGHT, adaptiveColor: AdaptiveColor.DEFAULT, scale: 1.0 })
|
||||
}
|
||||
|
||||
@ -25,8 +25,8 @@ export struct TitleTabContent {
|
||||
}else if(row_item instanceof Array<TitleGroup>){ //Array<TitleGroup>
|
||||
//功能组,迭代多个功能组
|
||||
ForEach(row_item, (group_item: TitleGroup, index: number) =>{
|
||||
Column({ space:5 }){
|
||||
Row({ space: 5 }){
|
||||
Column({ space:2 }){
|
||||
Row({ space: 2 }){
|
||||
ForEach(group_item.grpBtn, (btn_item: TitleButton|Array<TitleButton>, index: number) =>{
|
||||
if(this.curtLayout?.cmName=='应用模块'){
|
||||
if(Array.isArray(btn_item)){
|
||||
|
||||
@ -33,6 +33,7 @@
|
||||
"minWindowHeight": 800, // 设置最小高度
|
||||
"exported": true,
|
||||
"launchType":"multiton",
|
||||
"startWindow": "$profile:start_sub_window",
|
||||
"skills": [
|
||||
{
|
||||
"entities": [
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
{
|
||||
"src": [
|
||||
"pages/Index",
|
||||
"pages/Info",
|
||||
"pages/subpages/SWLine",
|
||||
"pages/subpages/SWExtrude",
|
||||
"pages/subpages/Options",
|
||||
|
||||
Loading…
Reference in New Issue
Block a user