fix: 补充初始化代码

This commit is contained in:
wangzhongjie 2025-06-25 13:38:13 +08:00
parent 84bf4184e3
commit 637e41248c
4 changed files with 21 additions and 8 deletions

View File

@ -47,3 +47,6 @@ export const HomeTag = '[Home]';
//judge
export const JudgeTag = '[Judge]';
//初始化表
export const InitTableTag = '[InitTable]';

View File

@ -1,7 +1,7 @@
import common from '@ohos.app.ability.common';
import router from '@ohos.router';
import { HomeTag, JudgeConfig } from '../config';
import { HomeTag, InitTableTag, JudgeConfig } from '../config';
import VoiceAnnounce from './judgeSDK/utils/voiceAnnouncements';
import { BaseInfoType } from '../model/Common';
import { CarInfoType, InitializeTheCentralTableType, MASYSSETTableType, TimeSynchronizationRspBody } from '../model';
@ -147,6 +147,7 @@ struct Index {
singlePlay: this.singlePlay
}
InitializeTheCentralTable(param).then((ret) => {
dConsole.log(InitTableTag, "初始化表成功", ret)
if (ret) {
GetSyncData<MASYSSETTableType>("MA_SYSSET").then(data => {
data.forEach(sys => {

View File

@ -279,9 +279,15 @@ export async function UseAuth(context: common.UIAbilityContext): Promise<boolean
if (grantStatus.every(status => status === 0)) {
return true;
} else {
Prompt.showToast({
message: "部分权限未授权,请全部授权,否则无法正常使用",
})
return false;
}
} catch (err) {
Prompt.showToast({
message: "授权出错,请联系开发者或检查权限设置",
})
return false;
}
}

View File

@ -5,8 +5,9 @@ import { BusinessError } from '@ohos.base';
import Prompt from '@system.prompt';
import { initialization } from '../../api';
import { GlobalConfig } from '../../config';
import { GlobalConfig, InitTableTag } from '../../config';
import FileUtils from '../FileUtils';
import { dConsole } from '../LogWorker';
// 建表操作
export async function InitTable() {
@ -137,7 +138,7 @@ export async function InitializeTheCentralTable(params: InitializeTheCentralTabl
// 后端传递的字段首字母小写了,需要转换下
let newKey = key.charAt(0).toUpperCase() + key.slice(1)
let isExit = CenterMap.has(newKey)
console.log("-------------------表名-----------------------", newKey, isExit)
console.log(InitTableTag, "-------------------表名-----------------------", newKey, isExit)
if (isExit) {
console.log("可以插入的表", newKey, CenterMap.get(newKey))
let arrList: Array<RecordType> | RecordType = []
@ -150,18 +151,20 @@ export async function InitializeTheCentralTable(params: InitializeTheCentralTabl
const folderPath = await fileUtil.initFolder(`/config/tableList`);
fileUtil.addFile(`${folderPath}/${RemappingTableName.get(newKey)}.txt`, JSON.stringify(arrList))
try {
console.log("插入表操作", newKey)
console.log("插入表别名", RemappingTableName.get(newKey))
console.log("插入表长度", arrList.length)
console.log(InitTableTag, "插入表操作", newKey)
console.log(InitTableTag, "插入表别名", RemappingTableName.get(newKey))
console.log(InitTableTag, "插入表长度", arrList.length)
const result = await SqlInsertTable(RemappingTableName.get(newKey)!, arrList);
console.log("插入表结果,表", newKey, "结果", result)
console.log(InitTableTag, "插入表结果,表", newKey, "结果", result)
if (!result) {
Prompt.showToast({
message: '初始化数据库失败'
})
}
console.log(InitTableTag, "~~~~~~~~~~~~~~~~~~~~~~初始化成功~~~~~~~~~~~~~~~~~~~~~~", newKey)
resolve(result)
} catch (e) {
dConsole.error(InitTableTag, "初始化表失败", JSON.stringify(e))
reject(e)
}
}