From 450d70c954d0630d8d70e4b0cc483e4b50160230 Mon Sep 17 00:00:00 2001 From: fofolee Date: Mon, 23 May 2022 10:41:44 +0800 Subject: [PATCH] =?UTF-8?q?=E5=91=BD=E4=BB=A4=E8=A7=A3=E6=9E=90=E6=8A=A5?= =?UTF-8?q?=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));