listFile fix to listFileSync
mkdir fix to mkdirSync srcDir+'/'+fsl[i] remove '/' destDir+'/'+fsl[i] remove '/'
This commit is contained in:
parent
8b779ebf86
commit
cc770e9f40
@ -7,11 +7,11 @@
|
||||
"material": {
|
||||
"certpath": "C:\\Users\\JackLee\\.ohos\\config\\default_OpenCAX_IBQbNZG6W5V0zTmQxRPojupy-F1gTlaQ6msiMPu4JRM=.cer",
|
||||
"keyAlias": "debugKey",
|
||||
"keyPassword": "0000001B4A3BC55F1B1B4A2AB1329B9D5275AE0838B295831B2E32CD64C1907F81907CB4EEB31059EE899A",
|
||||
"keyPassword": "0000001B3A77593550E08B545C9DBACCC59B3C15B073167C67ECEF2B8B6B92A7FB893F9EF12C0B46F27F1D",
|
||||
"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": "0000001B09F6464CFF2E52CDE07A1789369BFA2D006BFD15F43C3B1ECF3FF0FAC6FE258C8B0539EB694CC1"
|
||||
"storePassword": "0000001BA261C4B798064E9B27EDF1ABE90DCBB63F196BE8922529410D84879CD4436A14ADCC49F3E6248D"
|
||||
}
|
||||
}
|
||||
],
|
||||
@ -19,8 +19,8 @@
|
||||
{
|
||||
"name": "default",
|
||||
"signingConfig": "default",
|
||||
"targetSdkVersion": "6.0.2(22)",
|
||||
"compatibleSdkVersion": "6.0.2(22)",
|
||||
"targetSdkVersion": "6.1.0(23)",
|
||||
"compatibleSdkVersion": "6.1.0(23)",
|
||||
"runtimeOS": "HarmonyOS",
|
||||
"buildOption": {
|
||||
"nativeCompiler": "BiSheng",
|
||||
|
||||
@ -23,22 +23,22 @@ 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();
|
||||
}
|
||||
//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;
|
||||
}
|
||||
|
||||
if(!InitHub(data,windowStage,this.context)){
|
||||
console.log("InitHub Failed!")
|
||||
}
|
||||
mdwInfo.win = data;
|
||||
mdwInfo.winId =data.getWindowProperties().id;
|
||||
//moveWindowTo
|
||||
data.moveWindowTo(50, 50)
|
||||
data?.moveWindowTo(50, 50)
|
||||
//resize mainWindow Size
|
||||
data.resize(mdwInfo.winWidth, mdwInfo.winHeight, (err) => {
|
||||
data?.resize(mdwInfo.winWidth, mdwInfo.winHeight, (err) => {
|
||||
if (err.code) {
|
||||
console.error(`Failed to resize the window. Code: ${err.code}, message: ${err.message}`);
|
||||
return;
|
||||
@ -47,20 +47,13 @@ export default class EntryAbility extends UIAbility {
|
||||
});
|
||||
|
||||
// windowSizeChangeListener to Change mainWindowWidth&&mainWindowHeight in AppStorage
|
||||
data.on('windowSizeChange', (ChangeData) => {
|
||||
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);
|
||||
});
|
||||
let color: string = '#00000000';
|
||||
try {
|
||||
data.setWindowBackgroundColor(color);
|
||||
data.setWindowShadowEnabled(true);
|
||||
} catch (exception) {
|
||||
console.error(`Failed to set the background color. Cause code: ${exception.code}, message: ${exception.message}`);
|
||||
};
|
||||
});
|
||||
//Load page
|
||||
windowStage.loadContent('pages/Index', (err) => {
|
||||
|
||||
63
entry/src/main/ets/init/InitOptions.ets
Normal file
63
entry/src/main/ets/init/InitOptions.ets
Normal file
@ -0,0 +1,63 @@
|
||||
import { AppStorageV2 } from "@kit.ArkUI";
|
||||
|
||||
|
||||
//子工具栏的保存设置
|
||||
@ObservedV2
|
||||
export class SubToolbar{
|
||||
//选择过滤项目
|
||||
@Trace select_type:number=0;
|
||||
//图层列表
|
||||
@Trace layouts:Array<number>=[0]
|
||||
//渲染显示模式
|
||||
@Trace displayMode:number=0;
|
||||
//浏览模式
|
||||
@Trace viewMode:number=0;
|
||||
//控制模式
|
||||
@Trace controlMode:number=0;
|
||||
}
|
||||
|
||||
//用户设置
|
||||
@ObservedV2
|
||||
export class UseOption{
|
||||
|
||||
}
|
||||
//基本设置
|
||||
@ObservedV2
|
||||
export class BaseOption{
|
||||
|
||||
}
|
||||
//对象设置
|
||||
@ObservedV2
|
||||
export class ObjectOption{
|
||||
|
||||
}
|
||||
//可视化设置
|
||||
@ObservedV2
|
||||
export class VizOption{
|
||||
|
||||
}
|
||||
//该类属于整个软件的设置类.可以在选项中进行修改
|
||||
//软件启动首先读取沙箱中的配置文件.该文档包含对软件设置的持久化
|
||||
@ObservedV2
|
||||
export class Options {
|
||||
//配置文件版本,该版本区别于软件.主要针对软件版本升级后,文档版本不同的情况下进行兼容升级
|
||||
@Trace private version: string='1.0.0';
|
||||
|
||||
}
|
||||
//初始化全局设置
|
||||
export function InitOptions(){
|
||||
|
||||
}
|
||||
//读取全局设置文件
|
||||
export function ReadOptions(){
|
||||
|
||||
}
|
||||
//写入全局设置文件
|
||||
export function WriteOptions(){
|
||||
|
||||
}
|
||||
//同步全局设置
|
||||
export function SyncOptions(){
|
||||
|
||||
}
|
||||
export let options: Options = AppStorageV2.connect<Options>(Options, () => new Options())!;
|
||||
@ -2,7 +2,7 @@
|
||||
功能:主要用于软件在首次启动,或者往次启动时候对设置,事件的初始化<br>
|
||||
InitEnv 初始化环境检测<br>
|
||||
InitFonts 初始化字体<br>
|
||||
InitOpts 初始化软件设置<br>
|
||||
InitOptions 初始化软件设置<br>
|
||||
InitSubAbility 初始化子窗口的Ability<br>
|
||||
InitEventHub 初始化事件总线<br>
|
||||
InitGlobalDWI 初始化设备分辨率,窗体尺寸<br>
|
||||
|
||||
@ -170,7 +170,6 @@ async function EventCreateWin(): Promise<boolean>{
|
||||
let options: StartOptions = {
|
||||
withAnimation:false,
|
||||
hideStartWindow:true
|
||||
|
||||
};
|
||||
// 发起启动 Ability 的请求
|
||||
console.info("Attempting to start SubWinAbility...");
|
||||
|
||||
@ -2,20 +2,26 @@ import fs from '@ohos.file.fs';
|
||||
|
||||
//列出资源管理器指定目录下的所有问题件
|
||||
export function HilogSadboxFontDirFile(ctx: Context,dirName:string){
|
||||
// 获取资源管理器
|
||||
const rm = ctx?.filesDir+'/'+dirName+'/';
|
||||
fs.listFile(rm).then((filenames: Array<string>) => {
|
||||
try {
|
||||
// 获取资源管理器
|
||||
const rm = ctx?.filesDir+'/'+dirName+'/';
|
||||
let fsl:Array<string>=fs.listFileSync(rm);
|
||||
console.info('沙箱文件信息'); // 打印成功日志
|
||||
console.info('目录路径:'+rm); // 打印成功日志
|
||||
console.log('指定目录文件数: ' + filenames.length) // 打印文件数量
|
||||
console.log('指定目录文件数: ' + fsl.length) // 打印文件数量
|
||||
// 遍历打印所有文件名到控制台
|
||||
for (let i = 0; i < filenames.length; i++) {
|
||||
console.log('文件名:', filenames[i]);
|
||||
for (let i = 0; i < fsl.length; i++) {
|
||||
console.log('文件名:', fsl[i]);
|
||||
}
|
||||
}).catch((err: BusinessError) => {
|
||||
// 捕获并打印文件列表获取失败的错误信息
|
||||
console.error('list file failed with error message: ' + err.message + ', error code: ' + err.code);
|
||||
});
|
||||
}catch (err) {
|
||||
let msg = 'Unknown error';
|
||||
if (err instanceof Error) {
|
||||
msg = err.message;
|
||||
} else if (typeof err === 'string') {
|
||||
msg = err;
|
||||
}
|
||||
console.error(`list file failed with error message: ${msg}, error code: ${err.code}`);
|
||||
}
|
||||
}
|
||||
export function CheckExistDir(ctx: Context,dir:string):boolean{
|
||||
if (!dir || typeof dir !== 'string') {
|
||||
@ -65,8 +71,10 @@ export function ExtractDir(ctx: Context,dirName:string):boolean{
|
||||
}
|
||||
//如果沙箱目录不存在则创建目录
|
||||
if(!destDirState){
|
||||
fs.mkdir(destDir);
|
||||
fs.mkdirSync(destDir);
|
||||
console.info('Created sandbox directory successfully:', destDir);
|
||||
}else{
|
||||
return true;
|
||||
}
|
||||
ExtractFile(ctx,srcDir,destDir);
|
||||
console.info('Copy dir to sandbox successfully.');
|
||||
@ -84,17 +92,14 @@ export function ExtractDir(ctx: Context,dirName:string):boolean{
|
||||
}
|
||||
export function ExtractFile(ctx: Context,srcDir:string,destDir:string){
|
||||
try {
|
||||
//获取srcDir目录下所有文件,并复制到destDir目录下
|
||||
fs.listFile(srcDir).then((filenames: Array<string>) => {
|
||||
for (let i = 0; i < filenames.length; i++) {
|
||||
console.log('文件名:', filenames[i]);
|
||||
let srcFile=srcDir+'/'+filenames[i];
|
||||
let destFile=destDir+'/'+filenames[i];
|
||||
fs.copyFileSync(srcFile, destFile);
|
||||
}
|
||||
}).catch((err: BusinessError) => {
|
||||
console.error('copy file error message: ' + err.message + ', error code: ' + err.code);
|
||||
});
|
||||
//获取srcDir目录下所有文件,
|
||||
let fsl:Array<string>=fs.listFileSync(srcDir);
|
||||
for (let i = 0; i < fsl.length; i++) {
|
||||
console.log('文件名:', fsl[i]);
|
||||
let srcFile=srcDir+fsl[i];
|
||||
let destFile=destDir+fsl[i];
|
||||
fs.copyFileSync(srcFile, destFile);
|
||||
}
|
||||
}catch (err) {
|
||||
let msg = 'Unknown error';
|
||||
if (err instanceof Error) {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user