This commit is contained in:
cansnow
2026-02-09 07:29:02 +08:00
parent 2860c46ec1
commit 6720c15e30
19 changed files with 996 additions and 207 deletions
+18
View File
@@ -245,6 +245,23 @@ const get_absolute_path = (fn)=>{
return plus.io.convertLocalFileSystemURL(fn);
}
const pendingDownloads = new Map();
const getCachePath = (url,saveDir)=>{
if(!url || !url.startsWith('http')){
return url;
}
const key = md5(url);
var ext = "png"
if(url.toLowerCase().indexOf('.mp4')!==-1){
ext = "mp4";
}
let cacheDir = plus.io.convertLocalFileSystemURL(`_doc/{{dir}}/{{key}}.{{ext}}`);
if(uni.getSystemInfoSync().osName == 'android'){
cacheDir = cacheDir.replace('apps/'+plus.runtime.appid+'/doc','cache');
}
return cacheDir.replace('{{dir}}',saveDir)
.replace('{{key}}',key)
.replace('{{ext}}',ext);
}
const cacheFile = (url, saveDir,progressCallback) => {
//console.log(url);
// #ifndef APP
@@ -462,6 +479,7 @@ export default{
toMapAPP,
cacheFile,
fileExsit,
getCachePath,
get_absolute_path,
// #ifdef APP
downloadFile,