图片更新需重新下载

This commit is contained in:
CPPAlien 2019-11-26 12:04:26 +08:00
parent 6dc9e69fa1
commit f7d4bcc5d9
2 changed files with 32 additions and 7 deletions

View File

@ -40,6 +40,24 @@ export default class Dowloader {
resolve(url);
return;
}
if (!lru) {
// 无 lru 情况下直接判断 临时文件是否存在,不存在重新下载
wx.getFileInfo({
filePath: url,
success: () => {
resolve(url);
},
fail: () => {
downloadFile(url, lru).then((path) => {
resolve(path);
}, () => {
reject();
});
},
})
return
}
const file = getFile(url);
if (file) {
@ -79,7 +97,9 @@ function downloadFile(url, lru) {
reject();
return;
}
const { tempFilePath } = res;
const {
tempFilePath
} = res;
wx.getFileInfo({
filePath: tempFilePath,
success: (tmpRes) => {

View File

@ -234,11 +234,16 @@ Component({
downloader.download(newVal.url, this.properties.LRU).then((path) => {
doView.originUrl = doView.url
doView.url = path
this.reDraw(doView, callback, isMoving)
})
};
} else {
(newVal && newVal.text && doView.text && newVal.text !== doView.text) && (doView.text = newVal.text);
(newVal && newVal.content && doView.content && newVal.content !== doView.content) && (doView.content = newVal.content);
this.reDraw(doView, callback, isMoving)
}
},
reDraw(doView, callback, isMoving) {
const draw = {
width: this.currentPalette.width,
height: this.currentPalette.height,