diff --git a/src/api/file.js b/src/api/file.js index 250ecd1..c68d946 100644 --- a/src/api/file.js +++ b/src/api/file.js @@ -19,10 +19,28 @@ const fileUploadConfig = { function fileUpload(content, filename) { const date = new Date(); const dir = date.getFullYear() + '/' + (date.getMonth() + 1).toString().padStart(2, '0') + '/' + date.getDate().toString().padStart(2, '0'); - const uuid = uuidv4(); - const token = fileUploadConfig.accessToken[Math.floor(Math.random() * fileUploadConfig.accessToken.length)].replace('doocsmd', ''); + const uuid = uuidv4(); const dateFilename = new Date().getTime() + '-' + uuid + '.' + filename.split('.')[1]; - const url = `https://api.github.com/repos/${fileUploadConfig.username}/${fileUploadConfig.repo}/contents/${dir}/${dateFilename}`; + const imgHost = localStorage.getItem("ImgHost") || 'default' + + let token = '' + let username = '' + let repo = '' + + if (imgHost === 'default') { + token = fileUploadConfig.accessToken[Math.floor(Math.random() * fileUploadConfig.accessToken.length)].replace('doocsmd', ''); + username = fileUploadConfig.username + repo = fileUploadConfig.repo + } + + if (imgHost === 'github' && localStorage.getItem("GitHubConfig")) { + const githubConfg = JSON.parse(localStorage.getItem("GitHubConfig")); + token = githubConfg.accessToken + username = githubConfg.username + repo = githubConfg.repo + } + + const url = `https://api.github.com/repos/${username}/${repo}/contents/${dir}/${dateFilename}`; return fetch({ url, diff --git a/src/components/CodemirrorEditor/aboutDialog.vue b/src/components/CodemirrorEditor/aboutDialog.vue index 007a812..c45b2fe 100644 --- a/src/components/CodemirrorEditor/aboutDialog.vue +++ b/src/components/CodemirrorEditor/aboutDialog.vue @@ -8,8 +8,8 @@ - GitHub 仓库 - Gitee 仓库 + GitHub 仓库 + Gitee 仓库 diff --git a/src/components/CodemirrorEditor/header.vue b/src/components/CodemirrorEditor/header.vue index bccd457..ec3513e 100644 --- a/src/components/CodemirrorEditor/header.vue +++ b/src/components/CodemirrorEditor/header.vue @@ -1,14 +1,9 @@