From d52c677acdca218a0baa50f85a375b0942b07bb3 Mon Sep 17 00:00:00 2001 From: "xiaoqi.cxq" Date: Tue, 24 May 2022 03:13:23 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8DOpen=20On=20Gitee=20=E5=92=8C?= =?UTF-8?q?=20Save=20On=20Gitee=20=E7=9A=84bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- config/dev.env.js | 7 +++- package.json | 2 +- server/index.js | 2 -- src/components/menus/SyncMenu.vue | 34 +++++++++++++++++++ src/data/features.js | 22 +++++++++++- src/services/providers/helpers/giteeHelper.js | 2 +- 6 files changed, 63 insertions(+), 6 deletions(-) diff --git a/config/dev.env.js b/config/dev.env.js index ff2021b2..00822024 100644 --- a/config/dev.env.js +++ b/config/dev.env.js @@ -2,5 +2,10 @@ var merge = require('webpack-merge') var prodEnv = require('./prod.env') module.exports = merge(prodEnv, { - NODE_ENV: '"development"' + NODE_ENV: '"development"', + GITHUB_CLIENT_ID: '"845b8f75df48f2ee0563"', + GITHUB_CLIENT_SECRET: '"80df676597abded1450926861965cc3f9bead6a0"', + GITEE_CLIENT_ID: '"925ba7c78b85dec984f7877e4aca5cab10ae333c6d68e761bdb0b9dfb8f55672"', + GITEE_CLIENT_SECRET: '"f05731066e42d307339dc8ebbb037a103881dafc7207a359a393b87749f1c562"', + GITEE_CALLBACK: '"http://test.local.com/oauth2/callback"' }) \ No newline at end of file diff --git a/package.json b/package.json index c0517642..80ddac9b 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "stackedit", - "version": "5.15.1", + "version": "5.15.2", "description": "Free, open-source, full-featured Markdown editor", "author": "Benoit Schweblin", "license": "Apache-2.0", diff --git a/server/index.js b/server/index.js index 2bfb0e45..393f49e4 100644 --- a/server/index.js +++ b/server/index.js @@ -39,8 +39,6 @@ module.exports = (app) => { app.get('/', (req, res) => res.sendFile(resolvePath('static/landing/index.html'))); // Serve sitemap.xml app.get('/sitemap.xml', (req, res) => res.sendFile(resolvePath('static/sitemap.xml'))); - // Serve google-api.js - app.get('/google-api.js', (req, res) => res.sendFile(resolvePath('static/google-api.js'))); // Serve callback.html app.get('/oauth2/callback', (req, res) => res.sendFile(resolvePath('static/oauth2/callback.html'))); // Google Drive action receiver diff --git a/src/components/menus/SyncMenu.vue b/src/components/menus/SyncMenu.vue index 2c0c1c8d..d4bd0319 100644 --- a/src/components/menus/SyncMenu.vue +++ b/src/components/menus/SyncMenu.vue @@ -50,6 +50,18 @@ {{token.name}} +
+ + +
Open from Gitee
+ {{token.name}} +
+ + +
Save on Gitee
+ {{token.name}} +
+
@@ -110,6 +122,7 @@ import gitlabHelper from '../../services/providers/helpers/gitlabHelper'; import googleDriveProvider from '../../services/providers/googleDriveProvider'; import dropboxProvider from '../../services/providers/dropboxProvider'; import githubProvider from '../../services/providers/githubProvider'; +import giteeProvider from '../../services/providers/giteeProvider'; import gitlabProvider from '../../services/providers/gitlabProvider'; import syncSvc from '../../services/syncSvc'; import store from '../../store'; @@ -263,6 +276,27 @@ export default { badgeSvc.addBadge('saveOnGithub'); } catch (e) { /* cancel */ } }, + async openGitee(token) { + try { + const syncLocation = await store.dispatch('modal/open', { + type: 'giteeOpen', + token, + }); + store.dispatch( + 'queue/enqueue', + async () => { + await giteeProvider.openFile(token, syncLocation); + badgeSvc.addBadge('openFromGitee'); + }, + ); + } catch (e) { /* cancel */ } + }, + async saveGitee(token) { + try { + await openSyncModal(token, 'giteeSave'); + badgeSvc.addBadge('saveOnGitee'); + } catch (e) { /* cancel */ } + }, async saveGist(token) { try { await openSyncModal(token, 'gistSync'); diff --git a/src/data/features.js b/src/data/features.js index 7a9f67ba..7092b31c 100644 --- a/src/data/features.js +++ b/src/data/features.js @@ -174,7 +174,7 @@ export default [ ), new Feature( 'addGiteeWorkspace', - 'GitHub workspace creator', + 'Gitee workspace creator', 'Use the workspace menu to create a Gitee workspace.', ), new Feature( @@ -219,6 +219,11 @@ export default [ 'GitHub user', 'Link your GitHub account to StackEdit.', ), + new Feature( + 'addGiteeAccount', + 'Gitee user', + 'Link your Gitee account to StackEdit.', + ), new Feature( 'addGitLabAccount', 'GitLab user', @@ -276,6 +281,16 @@ export default [ 'GitHub writer', 'Use the "Synchronize" menu to save a file in a GitHub repository.', ), + new Feature( + 'openFromGitee', + 'Gitee reader', + 'Use the "Synchronize" menu to open a file from a Gitee repository.', + ), + new Feature( + 'saveOnGitee', + 'Gitee writer', + 'Use the "Synchronize" menu to save a file in a Gitee repository.', + ), new Feature( 'saveOnGist', 'Gist writer', @@ -348,6 +363,11 @@ export default [ 'Gist publisher', 'Use the "Publish" menu to publish a file to a Gist.', ), + new Feature( + 'publishToGitee', + 'Gitee publisher', + 'Use the "Publish" menu to publish a file to a Gitee repository.', + ), new Feature( 'publishToGitlab', 'GitLab publisher', diff --git a/src/services/providers/helpers/giteeHelper.js b/src/services/providers/helpers/giteeHelper.js index 5fc38666..b8df527b 100644 --- a/src/services/providers/helpers/giteeHelper.js +++ b/src/services/providers/helpers/giteeHelper.js @@ -8,11 +8,11 @@ const request = (token, options) => networkSvc.request({ ...options, headers: { ...options.headers || {}, - Authorization: `token ${token.accessToken}`, }, params: { ...options.params || {}, t: Date.now(), // Prevent from caching + access_token: token.accessToken, }, });