document/脚本/冒泡/modules/mp-app.js
2024-10-02 00:36:43 +08:00

44 lines
1.5 KiB
JavaScript

const _App = {
version: '1.0.3',
};
let mp_app = {
version: _App.version,
userSaveFilePath: `/sdcard/脚本/冒泡社区/仙剑问情/`,
userSaveFile: `/sdcard/脚本/冒泡社区/仙剑问情/UserId.txt`,
// saveFilePath: `/sdcard/脚本/冒泡社区/仙剑问情/${_App.version}/`,
saveFilePath: `./assets/images/`,
isUpdate: false,
init() {
if (this.isUpdate) {
if (files.isDir(this.saveFilePath)) {
toastLog('无需更新资源')
return;
}
//活动包名
files.ensureDir(this.saveFilePath + "/temp/")
toast('正在更新资源')
files.ensureDir(this.saveFilePath)
const url = `https://cos.shhuanmeng.com/jiaoben/%E5%86%92%E6%B3%A1/${this.version}.tar`;
console.log('下载地址', url);
let res = http.get(url);
if (res.statusCode !== 200) {
toast("请求失败");
return;
}
let fileData = `${this.saveFilePath}${this.version}.tar`;
console.log(fileData);
files.writeBytes(fileData, res.body.bytes());
//tar -xvzf /sdcard/yourfile.tar.gz -C /sdcard/yourfolder/
//shell
var adbTar = `tar -xvzf ${fileData} -C ${this.saveFilePath}`;
console.log('解压文件夹', adbTar);
var result = shell(adbTar, true);
console.log(result);
toast('资源更新结束')
}
}
};
module.exports = mp_app;