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}} 没有历史版本.