From 7e333ed54cefa4dfd6617450dc0373414851603b Mon Sep 17 00:00:00 2001 From: yanglbme Date: Sat, 29 Aug 2020 14:42:02 +0800 Subject: [PATCH] fix: remove expired token --- src/api/file.js | 22 ++++++++++++---------- src/assets/scripts/uploadImageFile.js | 5 ++--- src/components/CodemirrorEditor/header.vue | 2 +- 3 files changed, 15 insertions(+), 14 deletions(-) diff --git a/src/api/file.js b/src/api/file.js index b0d0af8..5b7e850 100644 --- a/src/api/file.js +++ b/src/api/file.js @@ -3,13 +3,15 @@ import { v4 as uuidv4 } from 'uuid'; const fileUploadConfig = { username: 'filess', repo: 'images', - access_tokens: [ - 'cc16734fc2d92c5b6d90155f0da9b5c43701b386', - 'f5c1b69cac9e2d53213adb1adda927ae7b3ca762', - '5533628a92d69d2271d6d1fdd5a9170c7de65bc8', - '7dc129821137b52d9fb897ba4a96d16224b63845', - '90669202e6277399ec0ea81649953b8f60793c6a', - 'a1900917f80c8c1b2ad73327e7c35b47106025dd' + accessToken: [ + '7715d7ca67b5d3837cfdoocsmde8c38421815aa423510af', + 'c411415bf95dbe39625doocsmd5047ba9b7a2a6c9642abe', + '2821cd8819fa345c053doocsmdca86ac653f8bc20db1f1b', + '445f0dae46ef1f2a4d6doocsmdc797301e94797b4750a4c', + 'cc1d0c1426d0fd0902bdoocsmdd2d7184b14da61b86ec46', + 'b67e9d15cb6f910492fdoocsmdac6b44d379c953bb19eff', + '618c4dc2244ccbbc088doocsmd125d17fd31b7d06a50cf3', + 'a4b581732e1c1507458doocsmdc5b223b27dae5e2e16a55' ] } @@ -18,9 +20,9 @@ function fileUpload(content, fileName) { const date = new Date(); const dir = date.getFullYear() + '/' + (date.getMonth() + 1) + '/' + date.getDate(); const uuid = uuidv4(); - const token = fileUploadConfig.access_tokens[Math.round(fileUploadConfig.access_tokens.length * Math.random())]; + const token = fileUploadConfig.accessToken[Math.floor(Math.random() * fileUploadConfig.accessToken.length)].replace('doocsmd', ''); const dateFilename = new Date().getTime() + '-' + uuid + '.' + fileName.split('.')[1]; - const url = `https://api.github.com/repos/${fileUploadConfig.username}/${fileUploadConfig.repo}/contents/${dir}/${dateFilename}?access_token=${token}`; + const url = `https://api.github.com/repos/${fileUploadConfig.username}/${fileUploadConfig.repo}/contents/${dir}/${dateFilename}`; return fetch({ url, @@ -29,7 +31,7 @@ function fileUpload(content, fileName) { 'Authorization': 'token ' + token }, data: { - message: 'Upload image by https://github.com/doocs/md', + message: 'Upload image by https://doocs.github.io/md', content: content } }) diff --git a/src/assets/scripts/uploadImageFile.js b/src/assets/scripts/uploadImageFile.js index 76016ae..af73b74 100644 --- a/src/assets/scripts/uploadImageFile.js +++ b/src/assets/scripts/uploadImageFile.js @@ -14,9 +14,8 @@ export function uploadImgFile(file) { imgFile.readAsDataURL(file); imgFile.onload = function() { - const base64Cotent = this.result.split(',').pop(); - - fileApi.fileUpload(base64Cotent, file.name).then(res=> { + const base64Content = this.result.split(',').pop(); + fileApi.fileUpload(base64Content, file.name).then(res=> { const imageUrl = res.content.download_url.replace(githubResourceUrl, cdnResourceUrl) resolve(imageUrl); diff --git a/src/components/CodemirrorEditor/header.vue b/src/components/CodemirrorEditor/header.vue index 40688d7..ec2fb7c 100644 --- a/src/components/CodemirrorEditor/header.vue +++ b/src/components/CodemirrorEditor/header.vue @@ -1,7 +1,7 @@