From 4a33fa9a29911f417475da70da459fe59d6e753b Mon Sep 17 00:00:00 2001 From: Daniel <845765@qq.com> Date: Sun, 27 Oct 2024 12:07:32 +0800 Subject: [PATCH] :art: The Publishing service no longer support export https://github.com/siyuan-note/siyuan/issues/12928 --- app/src/index.ts | 5 +++- app/src/menus/commonMenuItem.ts | 3 ++ app/src/mobile/index.ts | 1 + app/src/types/index.d.ts | 6 +++- app/src/window/index.ts | 9 ++++-- kernel/api/router.go | 52 ++++++++++++++++----------------- kernel/api/system.go | 8 +++-- 7 files changed, 51 insertions(+), 33 deletions(-) diff --git a/app/src/index.ts b/app/src/index.ts index 6285b443475..454f56bac76 100644 --- a/app/src/index.ts +++ b/app/src/index.ts @@ -17,7 +17,9 @@ import { progressBackgroundTask, progressLoading, progressStatus, - reloadSync, setDefRefCount, setRefDynamicText, + reloadSync, + setDefRefCount, + setRefDynamicText, setTitle, transactionError } from "./dialog/processSystem"; @@ -166,6 +168,7 @@ export class App { addScriptSync(`${Constants.PROTYLE_CDN}/js/lute/lute.min.js?v=${Constants.SIYUAN_VERSION}`, "protyleLuteScript"); addScript(`${Constants.PROTYLE_CDN}/js/protyle-html.js?v=${Constants.SIYUAN_VERSION}`, "protyleWcHtmlScript"); window.siyuan.config = response.data.conf; + window.siyuan.isPublish = response.data.isPublish; await loadPlugins(this); getLocalStorage(() => { fetchGet(`/appearance/langs/${window.siyuan.config.appearance.lang}.json?v=${Constants.SIYUAN_VERSION}`, (lauguages: IObject) => { diff --git a/app/src/menus/commonMenuItem.ts b/app/src/menus/commonMenuItem.ts index cc2468ae7da..0c767411463 100644 --- a/app/src/menus/commonMenuItem.ts +++ b/app/src/menus/commonMenuItem.ts @@ -446,6 +446,9 @@ export const copySubMenu = (id: string, accelerator = true, focusElement?: Eleme }; export const exportMd = (id: string) => { + if (window.siyuan.isPublish) { + return; + } return new MenuItem({ id: "export", label: window.siyuan.languages.export, diff --git a/app/src/mobile/index.ts b/app/src/mobile/index.ts index 0c46f3cfdeb..180ae733ade 100644 --- a/app/src/mobile/index.ts +++ b/app/src/mobile/index.ts @@ -97,6 +97,7 @@ class App { addScriptSync(`${Constants.PROTYLE_CDN}/js/lute/lute.min.js?v=${Constants.SIYUAN_VERSION}`, "protyleLuteScript"); addScript(`${Constants.PROTYLE_CDN}/js/protyle-html.js?v=${Constants.SIYUAN_VERSION}`, "protyleWcHtmlScript"); window.siyuan.config = confResponse.data.conf; + window.siyuan.isPublish = confResponse.data.isPublish; correctHotkey(siyuanApp); await loadPlugins(this); getLocalStorage(() => { diff --git a/app/src/types/index.d.ts b/app/src/types/index.d.ts index 044b10a3e05..e36aa83be70 100644 --- a/app/src/types/index.d.ts +++ b/app/src/types/index.d.ts @@ -432,7 +432,11 @@ interface ISiyuan { bookmarkLabel?: string[] blockPanels: import("../block/Panel").BlockPanel[], dialogs: import("../dialog").Dialog[], - viewer?: Viewer + viewer?: Viewer, + /** + * 是否在发布服务下访问 + */ + isPublish?: boolean; } interface IOperation { diff --git a/app/src/window/index.ts b/app/src/window/index.ts index 3f28f41b380..d8a6d876599 100644 --- a/app/src/window/index.ts +++ b/app/src/window/index.ts @@ -9,9 +9,13 @@ import {fetchGet, fetchPost} from "../util/fetch"; import {addBaseURL, setNoteBook} from "../util/pathName"; import {openFileById} from "../editor/util"; import { - processSync, progressBackgroundTask, + processSync, + progressBackgroundTask, progressLoading, - progressStatus, reloadSync, setDefRefCount, setRefDynamicText, + progressStatus, + reloadSync, + setDefRefCount, + setRefDynamicText, setTitle, transactionError } from "../dialog/processSystem"; @@ -151,6 +155,7 @@ class App { addScriptSync(`${Constants.PROTYLE_CDN}/js/lute/lute.min.js?v=${Constants.SIYUAN_VERSION}`, "protyleLuteScript"); addScript(`${Constants.PROTYLE_CDN}/js/protyle-html.js?v=${Constants.SIYUAN_VERSION}`, "protyleWcHtmlScript"); window.siyuan.config = response.data.conf; + window.siyuan.isPublish = response.data.isPublish; await loadPlugins(this); getLocalStorage(() => { fetchGet(`/appearance/langs/${window.siyuan.config.appearance.lang}.json?v=${Constants.SIYUAN_VERSION}`, (lauguages: IObject) => { diff --git a/kernel/api/router.go b/kernel/api/router.go index 8632aca4077..a315d529341 100644 --- a/kernel/api/router.go +++ b/kernel/api/router.go @@ -90,7 +90,7 @@ func ServeAPI(ginServer *gin.Engine) { ginServer.Handle("POST", "/api/notebook/renameNotebook", model.CheckAuth, model.CheckAdminRole, model.CheckReadonly, renameNotebook) ginServer.Handle("POST", "/api/notebook/changeSortNotebook", model.CheckAuth, model.CheckAdminRole, model.CheckReadonly, changeSortNotebook) ginServer.Handle("POST", "/api/notebook/setNotebookIcon", model.CheckAuth, model.CheckAdminRole, model.CheckReadonly, setNotebookIcon) - ginServer.Handle("POST", "/api/notebook/getNotebookInfo", model.CheckAuth, model.CheckAdminRole, model.CheckReadonly, getNotebookInfo) + ginServer.Handle("POST", "/api/notebook/getNotebookInfo", model.CheckAuth, model.CheckReadonly, getNotebookInfo) ginServer.Handle("POST", "/api/filetree/searchDocs", model.CheckAuth, searchDocs) ginServer.Handle("POST", "/api/filetree/listDocsByPath", model.CheckAuth, listDocsByPath) @@ -276,33 +276,33 @@ func ServeAPI(ginServer *gin.Engine) { ginServer.Handle("POST", "/api/asset/fullReindexAssetContent", model.CheckAuth, model.CheckAdminRole, model.CheckReadonly, fullReindexAssetContent) ginServer.Handle("POST", "/api/asset/statAsset", model.CheckAuth, model.CheckAdminRole, statAsset) - ginServer.Handle("POST", "/api/export/batchExportMd", model.CheckAuth, batchExportMd) - ginServer.Handle("POST", "/api/export/exportMd", model.CheckAuth, exportMd) - ginServer.Handle("POST", "/api/export/exportSY", model.CheckAuth, exportSY) - ginServer.Handle("POST", "/api/export/exportNotebookSY", model.CheckAuth, exportNotebookSY) - ginServer.Handle("POST", "/api/export/exportMdContent", model.CheckAuth, exportMdContent) - ginServer.Handle("POST", "/api/export/exportHTML", model.CheckAuth, exportHTML) - ginServer.Handle("POST", "/api/export/exportPreviewHTML", model.CheckAuth, exportPreviewHTML) - ginServer.Handle("POST", "/api/export/exportMdHTML", model.CheckAuth, exportMdHTML) - ginServer.Handle("POST", "/api/export/exportDocx", model.CheckAuth, exportDocx) - ginServer.Handle("POST", "/api/export/processPDF", model.CheckAuth, processPDF) + ginServer.Handle("POST", "/api/export/batchExportMd", model.CheckAuth, model.CheckAdminRole, batchExportMd) + ginServer.Handle("POST", "/api/export/exportMd", model.CheckAuth, model.CheckAdminRole, exportMd) + ginServer.Handle("POST", "/api/export/exportSY", model.CheckAuth, model.CheckAdminRole, exportSY) + ginServer.Handle("POST", "/api/export/exportNotebookSY", model.CheckAuth, model.CheckAdminRole, exportNotebookSY) + ginServer.Handle("POST", "/api/export/exportMdContent", model.CheckAuth, model.CheckAdminRole, exportMdContent) + ginServer.Handle("POST", "/api/export/exportHTML", model.CheckAuth, model.CheckAdminRole, exportHTML) + ginServer.Handle("POST", "/api/export/exportPreviewHTML", model.CheckAuth, model.CheckAdminRole, exportPreviewHTML) + ginServer.Handle("POST", "/api/export/exportMdHTML", model.CheckAuth, model.CheckAdminRole, exportMdHTML) + ginServer.Handle("POST", "/api/export/exportDocx", model.CheckAuth, model.CheckAdminRole, exportDocx) + ginServer.Handle("POST", "/api/export/processPDF", model.CheckAuth, model.CheckAdminRole, processPDF) ginServer.Handle("POST", "/api/export/preview", model.CheckAuth, exportPreview) - ginServer.Handle("POST", "/api/export/exportResources", model.CheckAuth, exportResources) - ginServer.Handle("POST", "/api/export/exportAsFile", model.CheckAuth, exportAsFile) - ginServer.Handle("POST", "/api/export/exportData", model.CheckAuth, exportData) - ginServer.Handle("POST", "/api/export/exportDataInFolder", model.CheckAuth, exportDataInFolder) - ginServer.Handle("POST", "/api/export/exportTempContent", model.CheckAuth, exportTempContent) + ginServer.Handle("POST", "/api/export/exportResources", model.CheckAuth, model.CheckAdminRole, exportResources) + ginServer.Handle("POST", "/api/export/exportAsFile", model.CheckAuth, model.CheckAdminRole, exportAsFile) + ginServer.Handle("POST", "/api/export/exportData", model.CheckAuth, model.CheckAdminRole, exportData) + ginServer.Handle("POST", "/api/export/exportDataInFolder", model.CheckAuth, model.CheckAdminRole, exportDataInFolder) + ginServer.Handle("POST", "/api/export/exportTempContent", model.CheckAuth, model.CheckAdminRole, exportTempContent) ginServer.Handle("POST", "/api/export/export2Liandi", model.CheckAuth, model.CheckAdminRole, model.CheckReadonly, export2Liandi) - ginServer.Handle("POST", "/api/export/exportReStructuredText", model.CheckAuth, exportReStructuredText) - ginServer.Handle("POST", "/api/export/exportAsciiDoc", model.CheckAuth, exportAsciiDoc) - ginServer.Handle("POST", "/api/export/exportTextile", model.CheckAuth, exportTextile) - ginServer.Handle("POST", "/api/export/exportOPML", model.CheckAuth, exportOPML) - ginServer.Handle("POST", "/api/export/exportOrgMode", model.CheckAuth, exportOrgMode) - ginServer.Handle("POST", "/api/export/exportMediaWiki", model.CheckAuth, exportMediaWiki) - ginServer.Handle("POST", "/api/export/exportODT", model.CheckAuth, exportODT) - ginServer.Handle("POST", "/api/export/exportRTF", model.CheckAuth, exportRTF) - ginServer.Handle("POST", "/api/export/exportEPUB", model.CheckAuth, exportEPUB) - ginServer.Handle("POST", "/api/export/exportAttributeView", model.CheckAuth, exportAttributeView) + ginServer.Handle("POST", "/api/export/exportReStructuredText", model.CheckAuth, model.CheckAdminRole, exportReStructuredText) + ginServer.Handle("POST", "/api/export/exportAsciiDoc", model.CheckAuth, model.CheckAdminRole, exportAsciiDoc) + ginServer.Handle("POST", "/api/export/exportTextile", model.CheckAuth, model.CheckAdminRole, exportTextile) + ginServer.Handle("POST", "/api/export/exportOPML", model.CheckAuth, model.CheckAdminRole, exportOPML) + ginServer.Handle("POST", "/api/export/exportOrgMode", model.CheckAuth, model.CheckAdminRole, exportOrgMode) + ginServer.Handle("POST", "/api/export/exportMediaWiki", model.CheckAuth, model.CheckAdminRole, exportMediaWiki) + ginServer.Handle("POST", "/api/export/exportODT", model.CheckAuth, model.CheckAdminRole, exportODT) + ginServer.Handle("POST", "/api/export/exportRTF", model.CheckAuth, model.CheckAdminRole, exportRTF) + ginServer.Handle("POST", "/api/export/exportEPUB", model.CheckAuth, model.CheckAdminRole, exportEPUB) + ginServer.Handle("POST", "/api/export/exportAttributeView", model.CheckAuth, model.CheckAdminRole, exportAttributeView) ginServer.Handle("POST", "/api/import/importStdMd", model.CheckAuth, model.CheckAdminRole, model.CheckReadonly, importStdMd) ginServer.Handle("POST", "/api/import/importData", model.CheckAuth, model.CheckAdminRole, model.CheckReadonly, importData) diff --git a/kernel/api/system.go b/kernel/api/system.go index c136085572a..5f1e66a342e 100644 --- a/kernel/api/system.go +++ b/kernel/api/system.go @@ -429,7 +429,8 @@ func getConf(c *gin.Context) { // REF: https://github.com/siyuan-note/siyuan/issues/11364 role := model.GetGinContextRole(c) - if model.IsReadOnlyRole(role) { + isPublish := model.IsReadOnlyRole(role) + if isPublish { maskedConf.ReadOnly = true } if !model.IsValidRole(role, []model.Role{ @@ -439,8 +440,9 @@ func getConf(c *gin.Context) { } ret.Data = map[string]interface{}{ - "conf": maskedConf, - "start": !util.IsUILoaded, + "conf": maskedConf, + "start": !util.IsUILoaded, + "isPublish": isPublish, } }