message:Error: 非法的文件,错误信息:invalid file: wxcomponents/painter/lib/downloader.js, 1:65, SyntaxError: Unexpected token exportconst e=require("./util"),t=require("./sha1");let i=6291456,s={};export default class a{constructor(){getApp().PAINTER_MAX_LRU_SPACE&&(i=getApp().PAINTER_MAX_LRU_SPACE),wx.getStorage({key:"savedFiles",success:function(e){e.data&&(s=e.data)}})}download(i,a){return new Promise((n,l)=>{if(!i||!e.isValidUrl(i))return void n(i);const f=function(i){if(e.isDataUrl(i)){const[,e,s]=/data:image\/(\w+);base64,(.*)/.exec(i)||[];return`${t.hex_sha1(s)}.${e}`}return i}(i);if(!a)return void wx.getFileInfo({filePath:f,success:()=>{n(i)},fail:()=>{e.isOnlineUrl(i)?r(i,a).then(e=>{n(e)},()=>{l()}):e.isDataUrl(i)&&o(i,a).then(e=>{n(e)},()=>{l()})}});const c=function(e){if(!s[e])return;return s[e].time=(new Date).getTime(),wx.setStorage({key:"savedFiles",data:s}),s[e]}(f);c?-1!==c.path.indexOf("//usr/")?wx.getFileInfo({filePath:c.path,success(){n(c.path)},fail(e){console.error("base64 file broken, "+JSON.stringify(e)),o(i,a).then(e=>{n(e)},()=>{l()})}}):wx.getSavedFileInfo({filePath:c.path,success:e=>{n(c.path)},fail:e=>{console.error("the file is broken, redownload it, "+JSON.stringify(e)),r(i,a).then(e=>{n(e)},()=>{l()})}}):e.isOnlineUrl(i)?r(i,a).then(e=>{n(e)},()=>{l()}):e.isDataUrl(i)&&o(i,a).then(e=>{n(e)},()=>{l()})})}}function o(e,i){return new Promise((s,a)=>{const[,o,r]=/data:image\/(\w+);base64,(.*)/.exec(e)||[];if(!o)return console.error("base parse failed"),void a();const f=`${t.hex_sha1(r)}.${o}`,c=`${wx.env.USER_DATA_PATH}/${f}`,d=wx.base64ToArrayBuffer(r.replace(/[\r\n]/g,""));wx.getFileSystemManager().writeFile({filePath:c,data:d,encoding:"binary",success(){wx.getFileInfo({filePath:c,success:e=>{const t=e.size;i?l(t).then(()=>{n(f,t,c,!0).then(e=>{s(e)})},()=>{s(c)}):s(c)},fail:e=>{console.error(`getFileInfo ${c} failed, ${JSON.stringify(e)}`),s(c)}})},fail(e){console.log(e)}})})}function r(e,t){return new Promise((i,s)=>{wx.downloadFile({url:e,success:function(a){if(200!==a.statusCode)return console.error(`downloadFile ${e} failed res.statusCode is not 200`),void s();const{tempFilePath:o}=a;wx.getFileInfo({filePath:o,success:s=>{const a=s.size;t?l(a).then(()=>{n(e,a,o).then(e=>{i(e)})},()=>{i(o)}):i(o)},fail:e=>{console.error(`getFileInfo ${a.tempFilePath} failed, ${JSON.stringify(e)}`),i(a.tempFilePath)}})},fail:function(e){console.error(`downloadFile failed, ${JSON.stringify(e)} `),s()}})})}function n(e,t,i,a=!1){return new Promise((o,r)=>{if(a){const a=s.totalSize?s.totalSize:0;return s[e]={},s[e].path=i,s[e].time=(new Date).getTime(),s[e].size=t,s.totalSize=t+a,wx.setStorage({key:"savedFiles",data:s}),void o(i)}wx.saveFile({tempFilePath:i,success:i=>{const a=s.totalSize?s.totalSize:0;s[e]={},s[e].path=i.savedFilePath,s[e].time=(new Date).getTime(),s[e].size=t,s.totalSize=t+a,wx.setStorage({key:"savedFiles",data:s}),o(i.savedFilePath)},fail:t=>{console.error(`saveFile ${e} failed, then we delete all files, ${JSON.stringify(t)}`),o(i),wx.removeStorage({key:"savedFiles",success:()=>{wx.getSavedFileList({success:e=>{f(e.fileList)},fail:e=>{console.error("getSavedFileList failed, "+JSON.stringify(e))}})}})}})})}function l(e){return e>i?Promise.reject():new Promise((t,a)=>{let o=s.totalSize?s.totalSize:0;if(e+o<=i)return void t();const r=[],n=JSON.parse(JSON.stringify(s));delete n.totalSize;const l=Object.keys(n).sort((e,t)=>n[e].time-n[t].time);for(const t of l)if(o-=s[t].size,r.push(s[t].path),delete s[t],o+e<i)break;s.totalSize=o,wx.setStorage({key:"savedFiles",data:s,success:()=>{r.length>0&&f(r),t()},fail:e=>{console.error("doLru setStorage failed, "+JSON.stringify(e)),a()}})})}function f(e){for(const t of e){let e=t;"object"==typeof t&&(e=t.filePath),-1!==e.indexOf("//usr/")?wx.getFileSystemManager().unlink({filePath:e,fail(e){console.error(`removeSavedFile ${t} failed, ${JSON.stringify(e)}`)}}):wx.removeSavedFile({filePath:e,fail:e=>{console.error(`removeSavedFile ${t} failed, ${JSON.stringify(e)}`)}})}} [20230216 08:50:05][wx71cfac05a7971cb5]
appid: wx71cfac05a7971cb5
openid: o6zAJs29tKKIhaXuzgVXR0eRs0Mo
ideVersion: 1.06.2210310
osType: win32-x64
time: 2023-02-16 08:50:18