提交 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 (downloadEntry) { if(docEntry){
await ioUtil.createDir(BASE_PATH, 'base') const parentPaths = [
await ioUtil.createDir(BASE_PATH, 'export') '_documents',
await ioUtil.createDir(BASE_PATH, 'import') '_documents/data',
await ioUtil.createDir(BASE_PATH, 'doc') '_documents/data/asmzx',
await ioUtil.createDir(BASE_PATH, 'error') '_documents/data/asmzx/pad'
} ];
// 获取设备名称 for (const path of parentPaths) {
uni.getSystemInfo({ const parts = path.split('/');
success: async function(e) { const parent = parts.slice(0, -1).join('/') || '/';
const deviceData = { await ioUtil.createDir(parent, parts.pop());
deviceId: e.deviceId, }
brand: e.deviceBrand,
deviceModel: e.deviceModel, const subDirs = ['发送数据', '日志文件', '巡检数据', 'history', 'fssj'];
} await Promise.all(
const deviceFilePath = BASE_PATH + 'name.txt' subDirs.map(dir => ioUtil.createDir(BASE_PATH, dir))
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 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论