From 39167fb193e8bd5520495f22b092c8254c9a7c10 Mon Sep 17 00:00:00 2001
From: "xiaoqi.cxq"
Date: Thu, 19 Oct 2023 18:20:34 +0800
Subject: [PATCH] =?UTF-8?q?=E4=B8=BB=E6=96=87=E6=A1=A3=E7=A9=BA=E9=97=B4?=
=?UTF-8?q?=E6=94=AF=E6=8C=81GitHub=E7=99=BB=E5=BD=95?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
README.md | 4 +-
package-lock.json | 2 +-
package.json | 2 +-
server/index.js | 1 +
src/components/Modal.vue | 2 +
src/components/PreviewInPageButtons.vue | 17 +-
src/components/menus/HistoryMenu.vue | 13 +-
src/components/menus/MainMenu.vue | 19 ++
src/components/menus/WorkspacesMenu.vue | 3 +-
.../modals/PublishManagementModal.vue | 8 +-
.../modals/WorkspaceManagementModal.vue | 5 +-
src/data/defaults/defaultSettings.yml | 2 +
src/data/features.js | 14 +-
src/data/simpleModals.js | 27 +-
src/icons/Provider.vue | 3 +
src/services/optional/shortcuts.js | 18 +-
.../providers/githubAppDataProvider.js | 292 ++++++++++++++++++
src/services/providers/helpers/giteeHelper.js | 1 +
.../providers/helpers/githubHelper.js | 38 ++-
src/services/syncSvc.js | 16 +-
src/store/discussion.js | 10 +-
src/store/workspace.js | 12 +-
static/landing/gistshare.html | 165 ++++++++++
static/themes/preview-theme-activeblue.js | 2 +-
static/themes/preview-theme-caoyuangreen.js | 2 +-
25 files changed, 639 insertions(+), 39 deletions(-)
create mode 100644 src/services/providers/githubAppDataProvider.js
create mode 100644 static/landing/gistshare.html
diff --git a/README.md b/README.md
index ed2bffde..fac73cf7 100644
--- a/README.md
+++ b/README.md
@@ -78,10 +78,10 @@ StackEdit中文版
- 支持分享文档(2023-03-30)
- 支持ChatGPT生成内容(2023-04-10)
- GitLab授权接口调整(2023-08-26)
+- 主文档空间支持GitHub登录(2023-10-19)
## 国外开源版本弊端:
-- 作者已经不维护了
-- Github授权登录存在问题
+- 作者已经不维护了或很少维护了
- 不支持国内常用Gitee
- 强依赖GoogleDrive,而Google Drive在国内不能正常访问
diff --git a/package-lock.json b/package-lock.json
index d4101bda..18751698 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -1,6 +1,6 @@
{
"name": "stackedit",
- "version": "5.15.20",
+ "version": "5.15.21",
"lockfileVersion": 1,
"requires": true,
"dependencies": {
diff --git a/package.json b/package.json
index cfe4c778..9075587f 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
{
"name": "stackedit",
- "version": "5.15.20",
+ "version": "5.15.21",
"description": "免费, 开源, 功能齐全的 Markdown 编辑器",
"author": "Benoit Schweblin, 豆萁",
"license": "Apache-2.0",
diff --git a/server/index.js b/server/index.js
index 1be80049..2b604258 100644
--- a/server/index.js
+++ b/server/index.js
@@ -72,6 +72,7 @@ module.exports = (app) => {
}));
// Serve share.html
app.get('/share.html', (req, res) => res.sendFile(resolvePath('static/landing/share.html')));
+ app.get('/gistshare.html', (req, res) => res.sendFile(resolvePath('static/landing/gistshare.html')));
// Serve static resources
if (process.env.NODE_ENV === 'production') {
diff --git a/src/components/Modal.vue b/src/components/Modal.vue
index fc49df3b..6cd52883 100644
--- a/src/components/Modal.vue
+++ b/src/components/Modal.vue
@@ -10,6 +10,7 @@
+
@@ -187,6 +188,7 @@ export default {
// User has to sign in
await store.dispatch('modal/open', 'signInForSponsorship');
await giteeHelper.signin();
+ await syncSvc.afterSignIn();
syncSvc.requestSync();
}
if (!store.getters.isSponsor) {
diff --git a/src/components/PreviewInPageButtons.vue b/src/components/PreviewInPageButtons.vue
index 430b5922..aaec6bdd 100644
--- a/src/components/PreviewInPageButtons.vue
+++ b/src/components/PreviewInPageButtons.vue
@@ -26,6 +26,7 @@ import store from '../store';
import DropdownMenu from './common/DropdownMenu';
import publishSvc from '../services/publishSvc';
import giteeGistProvider from '../services/providers/giteeGistProvider';
+import gistProvider from '../services/providers/gistProvider';
export default {
components: {
@@ -107,12 +108,15 @@ export default {
store.dispatch('notification/info', '登录主文档空间之后才可使用分享功能!');
return;
}
- let giteeGistId = null;
- const filterLocations = this.publishLocations.filter(it => it.providerId === 'giteegist' && it.url && it.gistId);
+ let tempGistId = null;
+ const isGithub = mainToken.providerId === 'githubAppData';
+ const gistProviderId = isGithub ? 'gist' : 'giteegist';
+ const filterLocations = this.publishLocations.filter(it => it.providerId === gistProviderId
+ && it.url && it.gistId);
if (filterLocations.length > 0) {
- giteeGistId = filterLocations[0].gistId;
+ tempGistId = filterLocations[0].gistId;
}
- const location = giteeGistProvider.makeLocation(
+ const location = (isGithub ? gistProvider : giteeGistProvider).makeLocation(
mainToken,
`分享-${currentFile.name}`,
true,
@@ -120,9 +124,10 @@ export default {
);
location.templateId = 'styledHtmlWithTheme';
location.fileId = currentFile.id;
- location.gistId = giteeGistId;
+ location.gistId = tempGistId;
const { gistId } = await publishSvc.publishLocationAndStore(location);
- const url = `${window.location.protocol}//${window.location.host}/share.html?id=${gistId}`;
+ const sharePage = mainToken.providerId === 'githubAppData' ? 'gistshare.html' : 'share.html';
+ const url = `${window.location.protocol}//${window.location.host}/${sharePage}?id=${gistId}`;
await store.dispatch('modal/open', { type: 'shareHtml', name: currentFile.name, url });
} catch (err) {
if (err) {
diff --git a/src/components/menus/HistoryMenu.vue b/src/components/menus/HistoryMenu.vue
index 977bf339..90c13e9a 100644
--- a/src/components/menus/HistoryMenu.vue
+++ b/src/components/menus/HistoryMenu.vue
@@ -8,7 +8,7 @@
- 同步 {{currentFileName}} 以启用修订历史 或者 登录 Gitee 以同步您的主文档空间。
+ 同步 {{currentFileName}} 以启用修订历史 或者 登录 Gitee 或 登录 GitHub 以同步您的主文档空间。
历史版本加载中…
{{currentFileName}} 没有历史版本.