From 72f9fea42e7e1f2b780c1d14304828bfc1aea33e Mon Sep 17 00:00:00 2001 From: "xiaoqi.cxq" Date: Thu, 14 Jul 2022 22:48:46 +0800 Subject: [PATCH] =?UTF-8?q?gitee=20=E6=8E=A5=E5=8F=A3=E9=99=90=E5=88=B6?= =?UTF-8?q?=E5=85=BC=E5=AE=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server/conf.js | 1 - server/index.js | 6 +++- src/components/Modal.vue | 2 -- src/components/menus/PublishMenu.vue | 1 - .../modals/providers/GiteeAccountModal.vue | 31 ------------------- .../providers/giteeWorkspaceProvider.js | 1 - src/services/providers/helpers/giteeHelper.js | 6 ++-- 7 files changed, 9 insertions(+), 39 deletions(-) delete mode 100644 src/components/modals/providers/GiteeAccountModal.vue diff --git a/server/conf.js b/server/conf.js index 9b2d550b..f86e1f54 100644 --- a/server/conf.js +++ b/server/conf.js @@ -35,7 +35,6 @@ exports.publicValues = { dropboxAppKey, dropboxAppKeyFull, githubClientId, - giteeClientId, googleClientId, googleApiKey, wordpressClientId, diff --git a/server/index.js b/server/index.js index 70071717..16ac2f00 100644 --- a/server/index.js +++ b/server/index.js @@ -34,7 +34,11 @@ module.exports = (app) => { app.post('/paypalIpn', bodyParser.urlencoded({ extended: false, }), user.paypalIpn); - + app.get('/giteeClientId', (req, res) => { + const giteeClientIds = conf.values.giteeClientId.split(','); + const clientId = giteeClientIds[Math.floor((giteeClientIds.length * Math.random()))]; + res.send(clientId); + }); // Serve landing.html app.get('/', (req, res) => res.sendFile(resolvePath('static/landing/index.html'))); // Serve privacy_policy.html diff --git a/src/components/Modal.vue b/src/components/Modal.vue index 00d9a242..0574ba30 100644 --- a/src/components/Modal.vue +++ b/src/components/Modal.vue @@ -56,7 +56,6 @@ import GithubWorkspaceModal from './modals/providers/GithubWorkspaceModal'; import GithubPublishModal from './modals/providers/GithubPublishModal'; import GistSyncModal from './modals/providers/GistSyncModal'; import GistPublishModal from './modals/providers/GistPublishModal'; -import GiteeAccountModal from './modals/providers/GiteeAccountModal'; import GiteeOpenModal from './modals/providers/GiteeOpenModal'; import GiteeSaveModal from './modals/providers/GiteeSaveModal'; import GiteeWorkspaceModal from './modals/providers/GiteeWorkspaceModal'; @@ -120,7 +119,6 @@ export default { GithubPublishModal, GistSyncModal, GistPublishModal, - GiteeAccountModal, GiteeOpenModal, GiteeSaveModal, GiteeWorkspaceModal, diff --git a/src/components/menus/PublishMenu.vue b/src/components/menus/PublishMenu.vue index b17ca1f7..653c9f69 100644 --- a/src/components/menus/PublishMenu.vue +++ b/src/components/menus/PublishMenu.vue @@ -252,7 +252,6 @@ export default { }, async addGiteeAccount() { try { - await store.dispatch('modal/open', { type: 'giteeAccount' }); await giteeHelper.addAccount(); } catch (e) { /* cancel */ } }, diff --git a/src/components/modals/providers/GiteeAccountModal.vue b/src/components/modals/providers/GiteeAccountModal.vue deleted file mode 100644 index eabb3afb..00000000 --- a/src/components/modals/providers/GiteeAccountModal.vue +++ /dev/null @@ -1,31 +0,0 @@ - - - diff --git a/src/services/providers/giteeWorkspaceProvider.js b/src/services/providers/giteeWorkspaceProvider.js index 08a88d40..ab9c76fb 100644 --- a/src/services/providers/giteeWorkspaceProvider.js +++ b/src/services/providers/giteeWorkspaceProvider.js @@ -70,7 +70,6 @@ export default new Provider({ token = store.getters['data/giteeTokensBySub'][workspace.sub]; } if (!token) { - await store.dispatch('modal/open', { type: 'giteeAccount' }); token = await giteeHelper.addAccount(); } diff --git a/src/services/providers/helpers/giteeHelper.js b/src/services/providers/helpers/giteeHelper.js index 8b173dd0..70771f13 100644 --- a/src/services/providers/helpers/giteeHelper.js +++ b/src/services/providers/helpers/giteeHelper.js @@ -69,10 +69,12 @@ export default { * https://developer.gitee.com/apps/building-oauth-apps/authorization-options-for-oauth-apps/ */ async startOauth2(lastToken, silent = false, isMain) { - const giteeClientIds = store.getters['data/serverConf'].giteeClientId.split(','); - const clientId = giteeClientIds[Math.floor((giteeClientIds.length * Math.random()))]; let tokenBody; if (!silent) { + const clientId = (await networkSvc.request({ + method: 'GET', + url: 'giteeClientId', + })).body; // Get an OAuth2 code const { code } = await networkSvc.startOauth2( 'https://gitee.com/oauth/authorize',