优化share

This commit is contained in:
xiaoqi.cxq 2023-04-09 21:35:55 +08:00
parent 1daa5afe39
commit 0e02822add
2 changed files with 10 additions and 10 deletions

View File

@ -125,7 +125,9 @@ export default {
const url = `${window.location.protocol}//${window.location.host}/share.html?id=${gistId}`; const url = `${window.location.protocol}//${window.location.host}/share.html?id=${gistId}`;
await store.dispatch('modal/open', { type: 'shareHtml', name: currentFile.name, url }); await store.dispatch('modal/open', { type: 'shareHtml', name: currentFile.name, url });
} catch (err) { } catch (err) {
/* cancel */ if (err) {
store.dispatch('notification/error', err);
}
} finally { } finally {
this.sharing = false; this.sharing = false;
} }

View File

@ -87,16 +87,14 @@
window.onload = function() { window.onload = function() {
const xhr = new XMLHttpRequest(); const xhr = new XMLHttpRequest();
const gistId = getQueryString('id'); const gistId = getQueryString('id');
const workspaces = window.localStorage.getItem('data/workspaces');
let accessToken = null; 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'); const tokens = window.localStorage.getItem('data/tokens');
if (tokens) { if (tokens) {
const tokensObj = JSON.parse(tokens); const tokensObj = JSON.parse(tokens);
accessToken = tokensObj.data && tokensObj.data.gitee && tokensObj.data.gitee[sub] && tokensObj.data.gitee[sub].accessToken; 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;
} }
} }
} }