From 93963f047320eaa8efb405c74b2d4cdfdf2eec5d Mon Sep 17 00:00:00 2001 From: fofolee Date: Mon, 23 May 2022 10:49:28 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=AD=A3=E6=8E=92=E5=BA=8F=E9=80=BB?= =?UTF-8?q?=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/pages/ShareCenterPage.vue | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/src/pages/ShareCenterPage.vue b/src/pages/ShareCenterPage.vue index bed717d..c079a2a 100644 --- a/src/pages/ShareCenterPage.vue +++ b/src/pages/ShareCenterPage.vue @@ -184,7 +184,9 @@ export default { this.errCommandsCount++; return; } - this.commands.push(command); + command.updated + ? this.commands.unshift(command.data) + : this.commands.push(command.data); }); }); }, @@ -216,7 +218,11 @@ export default { // 如果远端更新时间和本地相同则读取本地缓存,否则更新 async getCommand(id, updateTime, authorName, authorId) { let localCache = JSON.parse(localStorage.getItem(id)); - if (localCache?.updateTime === updateTime) return localCache; + if (localCache?.updateTime === updateTime) + return { + data: localCache, + updated: false, + }; let res = await window.yuQueClient( `repos/${this.releaseRepo}/docs/${id}?raw=1` ); @@ -231,7 +237,10 @@ export default { if (!command) return; Object.assign(command, { authorName, updateTime, authorId }); localStorage.setItem(id, JSON.stringify(command)); - return command; + return { + data: command, + updated: true, + }; }, fetchCommands() { window.yuQueClient(`repos/${this.releaseRepo}/docs`).then((res) => {