提交 089bc4bd authored 作者: zs's avatar zs

edit

上级 8c52db57
......@@ -88,7 +88,7 @@ export default {
*/
async init() {
initService.init();
return;
return
checkAndCreateDirectory(SYNCHRONIZE_DATA_PAD)
.then(() => {
return new Promise((resolve, reject) => {
......
......@@ -13,7 +13,6 @@ export default {
// app初始化
async init() {
const BASE_PATH = "_documents/data/asmzx/pad"; // 基础路径
// uni.showLoading({
// title: '正在初始化...',
// })
......@@ -25,11 +24,7 @@ export default {
await this.initSqlLite(sqllitedb); // 确保表被创建
console.log('Tables created.');
await ioUtil.createDir(BASE_PATH, '发送数据')
await ioUtil.createDir(BASE_PATH, '日志文件')
await ioUtil.createDir(BASE_PATH, '巡检数据')
await ioUtil.createDir(BASE_PATH, 'history')
await ioUtil.createDir(BASE_PATH, 'fssj')
await this.initDir()
let isInit = await SqlliteDbUtil.checkIfDataImported(sqllitedb); // 确保表存在后再查询
console.log('Data imported:', isInit);
if (!isInit) {
......@@ -97,44 +92,30 @@ export default {
// 初始化目录
async initDir() {
const BASE_PATH = "_documents/data/asmzx/pad"; // 基础路径
try {
const downloadEntry = await ioUtil.getFileEntry()
const _doc = _Path.getPrivateDOC()
const docEntry = await ioUtil.getFileEntry(_doc)
if(docEntry){
const parentPaths = [
'_documents',
'_documents/data',
'_documents/data/asmzx',
'_documents/data/asmzx/pad'
];
if (downloadEntry) {
await ioUtil.createDir(BASE_PATH, 'base')
await ioUtil.createDir(BASE_PATH, 'export')
await ioUtil.createDir(BASE_PATH, 'import')
await ioUtil.createDir(BASE_PATH, 'doc')
await ioUtil.createDir(BASE_PATH, 'error')
for (const path of parentPaths) {
const parts = path.split('/');
const parent = parts.slice(0, -1).join('/') || '/';
await ioUtil.createDir(parent, parts.pop());
}
// 获取设备名称
uni.getSystemInfo({
success: async function(e) {
const deviceData = {
deviceId: e.deviceId,
brand: e.deviceBrand,
deviceModel: e.deviceModel,
const subDirs = ['发送数据', '日志文件', '巡检数据', 'history', 'fssj'];
await Promise.all(
subDirs.map(dir => ioUtil.createDir(BASE_PATH, dir))
);
}
const deviceFilePath = BASE_PATH + 'name.txt'
await ioUtil.removeExistFile(deviceFilePath)
await ioUtil.writeFile('name.txt', downloadEntry, JSON.stringify(deviceData))
},
});
// 文件目录
if (docEntry) {
await ioUtil.createDir(docEntry.fullPath, 'file')
}
// 临时目录
let tempEntry = await ioUtil.getFileEntry(_temp)
if (!tempEntry) {
await ioUtil.createDir(_temp)
tempEntry = await ioUtil.createDir(_Path.getTempParent(), 'inspectTemp')
}
await ioUtil.createDir(tempEntry.fullPath, 'db')
} catch (e) {
console.log(e.message)
}
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论