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

edit

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