From 450d70c954d0630d8d70e4b0cc483e4b50160230 Mon Sep 17 00:00:00 2001 From: fofolee Date: Mon, 23 May 2022 10:41:44 +0800 Subject: [PATCH 01/10] =?UTF-8?q?=E5=91=BD=E4=BB=A4=E8=A7=A3=E6=9E=90?= =?UTF-8?q?=E6=8A=A5=E9=94=99=E7=9A=84=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/pages/ShareCenterPage.vue | 25 +++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-) diff --git a/src/pages/ShareCenterPage.vue b/src/pages/ShareCenterPage.vue index 3d79023..bed717d 100644 --- a/src/pages/ShareCenterPage.vue +++ b/src/pages/ShareCenterPage.vue @@ -141,6 +141,7 @@ export default { releaseRepo: "fofolee/qcreleases", commandTypes: commandTypes, platform: window.processPlatform, + errCommandsCount: 0, }; }, computed: { @@ -151,9 +152,11 @@ export default { return this.commands.length === this.currentPageCounts ? false : true; }, currentPageCounts() { - return this.currentPage === this.maxPages - ? this.matchedCommands.length % this.perPage - : this.perPage; + return ( + (this.currentPage === this.maxPages + ? this.matchedCommands.length % this.perPage + : this.perPage) - this.errCommandsCount + ); }, }, mounted() { @@ -166,6 +169,7 @@ export default { }, methods: { fetchCommandDetails(page) { + this.errCommandsCount = 0; this.commands = []; this.matchedCommands .slice((page - 1) * this.perPage, page * this.perPage) @@ -176,6 +180,10 @@ export default { item.last_editor.name, item.last_editor.id ).then((command) => { + if (!command) { + this.errCommandsCount++; + return; + } this.commands.push(command); }); }); @@ -212,9 +220,14 @@ export default { let res = await window.yuQueClient( `repos/${this.releaseRepo}/docs/${id}?raw=1` ); - let command = JSON.parse( - res.data?.data.body.match(/```json([\s\S]*)```/)?.[1] - ); + let command; + try { + command = JSON.parse( + res.data?.data.body.match(/```json([\s\S]*)```/)?.[1] + ); + } catch (error) { + console.log("parseErr", command, error); + } if (!command) return; Object.assign(command, { authorName, updateTime, authorId }); localStorage.setItem(id, JSON.stringify(command)); From 93963f047320eaa8efb405c74b2d4cdfdf2eec5d Mon Sep 17 00:00:00 2001 From: fofolee Date: Mon, 23 May 2022 10:49:28 +0800 Subject: [PATCH 02/10] =?UTF-8?q?=E4=BF=AE=E6=AD=A3=E6=8E=92=E5=BA=8F?= =?UTF-8?q?=E9=80=BB=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) => { From 4fefe53ed948a494a4152f49bb3fb6240c875f3a Mon Sep 17 00:00:00 2001 From: fofolee Date: Tue, 24 May 2022 16:47:13 +0800 Subject: [PATCH 03/10] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E7=94=A8=E6=88=B7?= =?UTF-8?q?=E5=8F=98=E9=87=8F=E6=B2=A1=E6=9C=89=E5=8F=91=E9=80=81=E6=8C=89?= =?UTF-8?q?=E9=92=AE=E7=9A=84bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/CommandSideBar.vue | 2 +- src/components/popup/UserData.vue | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/components/CommandSideBar.vue b/src/components/CommandSideBar.vue index 1c0a1a8..7b0619d 100644 --- a/src/components/CommandSideBar.vue +++ b/src/components/CommandSideBar.vue @@ -270,7 +270,7 @@ /> - + diff --git a/src/components/popup/UserData.vue b/src/components/popup/UserData.vue index edbb7dc..e8c5437 100644 --- a/src/components/popup/UserData.vue +++ b/src/components/popup/UserData.vue @@ -18,7 +18,9 @@ :placeholder="item.value || '本机未设置'" >