From 0e02822adda361ba91b3783f9dbe92fb6962d0fe Mon Sep 17 00:00:00 2001 From: "xiaoqi.cxq" Date: Sun, 9 Apr 2023 21:35:55 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96share?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/PreviewInPageButtons.vue | 4 +++- static/landing/share.html | 16 +++++++--------- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/components/PreviewInPageButtons.vue b/src/components/PreviewInPageButtons.vue index 4d6ce2ff..430b5922 100644 --- a/src/components/PreviewInPageButtons.vue +++ b/src/components/PreviewInPageButtons.vue @@ -125,7 +125,9 @@ export default { const url = `${window.location.protocol}//${window.location.host}/share.html?id=${gistId}`; await store.dispatch('modal/open', { type: 'shareHtml', name: currentFile.name, url }); } catch (err) { - /* cancel */ + if (err) { + store.dispatch('notification/error', err); + } } finally { this.sharing = false; } diff --git a/static/landing/share.html b/static/landing/share.html index e9b2dd53..81e52e38 100644 --- a/static/landing/share.html +++ b/static/landing/share.html @@ -87,16 +87,14 @@ window.onload = function() { const xhr = new XMLHttpRequest(); const gistId = getQueryString('id'); - const workspaces = window.localStorage.getItem('data/workspaces'); let accessToken = null; - if (workspaces) { - const workspacesObj = JSON.parse(workspaces); - const sub = workspacesObj.data && workspacesObj.data.main && workspacesObj.data.main.sub; - if (sub) { - const tokens = window.localStorage.getItem('data/tokens'); - if (tokens) { - const tokensObj = JSON.parse(tokens); - accessToken = tokensObj.data && tokensObj.data.gitee && tokensObj.data.gitee[sub] && tokensObj.data.gitee[sub].accessToken; + const tokens = window.localStorage.getItem('data/tokens'); + if (tokens) { + const tokensObj = JSON.parse(tokens); + if (tokensObj.data && tokensObj.data.gitee) { + const tokenArr = Object.keys(tokensObj.data.gitee).map(it => tokensObj.data.gitee[it]).filter(it => it && it.isLogin); + if (tokenArr.length > 0) { + accessToken = tokenArr[0].accessToken; } } }