From 904b9faf8cfae3eb0526403697f36d8dba2c6eae Mon Sep 17 00:00:00 2001 From: Vanessa Date: Thu, 4 Jul 2024 23:29:59 +0800 Subject: [PATCH 1/7] :art: fix https://github.com/siyuan-note/siyuan/issues/11843 --- app/src/layout/dock/Outline.ts | 9 ++++++--- app/src/util/Tree.ts | 3 ++- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/app/src/layout/dock/Outline.ts b/app/src/layout/dock/Outline.ts index 1555eac85c..35c3156d56 100644 --- a/app/src/layout/dock/Outline.ts +++ b/app/src/layout/dock/Outline.ts @@ -375,18 +375,21 @@ export class Outline extends Model { } let needReload = false; const ops = data.data.sources[0]; - ops.doOperations.forEach((item: IOperation) => { + ops.doOperations.find((item: IOperation) => { if ((item.action === "update" || item.action === "insert") && (item.data.indexOf('data-type="NodeHeading"') > -1 || item.data.indexOf(`
`) > -1)) { needReload = true; + return true } else if (item.action === "delete" || item.action === "move") { needReload = true; + return true; } }); - if (ops.undoOperations) { - ops.undoOperations.forEach((item: IOperation) => { + if (!needReload && ops.undoOperations) { + ops.undoOperations.find((item: IOperation) => { if (item.action === "update" && item.data.indexOf('data-type="NodeHeading"') > -1) { needReload = true; + return true; } }); } diff --git a/app/src/util/Tree.ts b/app/src/util/Tree.ts index f13d496dd3..f1b7c87bff 100644 --- a/app/src/util/Tree.ts +++ b/app/src/util/Tree.ts @@ -84,6 +84,7 @@ export class Tree { style = `padding-left: ${(item.depth - 1) * 18 + 22}px;margin-right: 2px`; } const showArrow = hasChild || (item.type === "backlink" && !isMobile()); + // data-id 需要添加 item.id,否则大纲更新时 name 不一致导致 https://github.com/siyuan-note/siyuan/issues/11843 html += `
  • - + ${iconHTML} ${item.name} From f25b36ff38d189a756333a7c5d0aabb15ba3d21d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yingyi=20/=20=E9=A2=96=E9=80=B8?= <49649786+Zuoqiu-Yingyi@users.noreply.github.com> Date: Fri, 5 Jul 2024 20:01:43 +0800 Subject: [PATCH 2/7] Disable some menu items in read-only mode (#11733) * :art: kernel supports read-only publishing services * :bug: Fix authentication vulnerabilities * :art: Protect secret information * :art: Adjust the permission control * :art: Adjust the permission control * :art: Fixed the vulnerability that `getFile` gets file `conf.json` * :art: Add API `/api/setting/setPublish` * :art: Add API `/api/setting/getPublish` * :bug: Fixed the issue that PWA-related files could not pass BasicAuth * :art: Add a settings panel for publishing features * :memo: Add guide for `Publish Service` * :memo: Update Japanese user guide * :art: Merge fixed static file services * :art: Disable some menu items in read-only mode * :art: Disable some menu items in read-only mode * Update router.go --- app/src/config/editor.ts | 10 ++-- app/src/index.ts | 46 +++++++++++----- app/src/layout/Wnd.ts | 2 +- app/src/layout/status.ts | 1 + app/src/layout/topBar.ts | 3 +- app/src/menus/commonMenuItem.ts | 4 +- app/src/menus/workspace.ts | 1 + app/src/mobile/index.ts | 73 ++++++++++++++++--------- app/src/protyle/gutter/index.ts | 2 + app/src/protyle/header/openTitleMenu.ts | 6 ++ app/src/protyle/scroll/saveScroll.ts | 10 ++-- app/src/util/assets.ts | 6 +- app/src/window/index.ts | 38 +++++++++---- kernel/api/router.go | 6 +- kernel/api/setting.go | 4 -- kernel/api/sync.go | 7 +-- kernel/api/workspace.go | 7 +++ kernel/model/role.go | 4 -- 18 files changed, 150 insertions(+), 80 deletions(-) diff --git a/app/src/config/editor.ts b/app/src/config/editor.ts index 851b2c65ec..102acc26f3 100644 --- a/app/src/config/editor.ts +++ b/app/src/config/editor.ts @@ -310,10 +310,12 @@ export const editor = { if (fontFamilyElement.tagName === "SELECT") { let fontFamilyHTML = ``; fetchPost("/api/system/getSysFonts", {}, (response) => { - response.data.forEach((item: string) => { - fontFamilyHTML += ``; - }); - fontFamilyElement.innerHTML = fontFamilyHTML; + if (response.code === 0) { + response.data.forEach((item: string) => { + fontFamilyHTML += ``; + }); + fontFamilyElement.innerHTML = fontFamilyHTML; + } }); } editor.element.querySelector("#clearHistory").addEventListener("click", () => { diff --git a/app/src/index.ts b/app/src/index.ts index 0bcd88cf56..c666a0cc1a 100644 --- a/app/src/index.ts +++ b/app/src/index.ts @@ -38,6 +38,8 @@ export class App { registerServiceWorker(`${Constants.SERVICE_WORKER_PATH}?v=${Constants.SIYUAN_VERSION}`); /// #endif addBaseURL(); + 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"), this.appId = Constants.SIYUAN_APPID; window.siyuan = { @@ -158,24 +160,40 @@ export class App { }; fetchPost("/api/system/getConf", {}, async (response) => { - 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; - await loadPlugins(this); - getLocalStorage(() => { - fetchGet(`/appearance/langs/${window.siyuan.config.appearance.lang}.json?v=${Constants.SIYUAN_VERSION}`, (lauguages: IObject) => { - window.siyuan.languages = lauguages; - window.siyuan.menus = new Menus(this); - bootSync(); + + const promises = [ + loadPlugins(this), + new Promise(resolve => getLocalStorage(resolve)), + new Promise(resolve => fetchGet( + `/appearance/langs/${window.siyuan.config.appearance.lang}.json?v=${Constants.SIYUAN_VERSION}`, + (lauguages: IObject) => { + window.siyuan.languages = lauguages; + resolve(); + }, + )), + ]; + + if (!window.siyuan.config.readonly) { + promises.push(new Promise(resolve => { fetchPost("/api/setting/getCloudUser", {}, userResponse => { window.siyuan.user = userResponse.data; - onGetConfig(response.data.start, this); - account.onSetaccount(); - setTitle(window.siyuan.languages.siyuanNote); - initMessage(); + resolve(); }); - }); - }); + })); + } + + await Promise.all(promises); + + if (!window.siyuan.config.readonly) { + bootSync(); + } + + window.siyuan.menus = new Menus(this); + onGetConfig(response.data.start, this); + account.onSetaccount(); + setTitle(window.siyuan.languages.siyuanNote); + initMessage(); }); setNoteBook(); initBlockPopover(this); diff --git a/app/src/layout/Wnd.ts b/app/src/layout/Wnd.ts index 1bee1396b1..a2fd122736 100644 --- a/app/src/layout/Wnd.ts +++ b/app/src/layout/Wnd.ts @@ -105,7 +105,7 @@ export class Wnd { this.headersElement.parentElement.addEventListener("click", (event) => { let target = event.target as HTMLElement; while (target && !target.isEqualNode(this.headersElement)) { - if (target.classList.contains("block__icon") && target.getAttribute("data-type") === "new") { + if (target.classList.contains("block__icon") && target.getAttribute("data-type") === "new" && !window.siyuan.config.readonly) { setPanelFocus(this.headersElement.parentElement.parentElement); newFile({ app, diff --git a/app/src/layout/status.ts b/app/src/layout/status.ts index 1cd7399b2a..bd7d048af4 100644 --- a/app/src/layout/status.ts +++ b/app/src/layout/status.ts @@ -68,6 +68,7 @@ export const initStatus = (isWindow = false) => { window.siyuan.menus.menu.append(new MenuItem({ label: window.siyuan.languages.userGuide, icon: "iconHelp", + disabled: window.siyuan.config.readonly, click: () => { mountHelp(); } diff --git a/app/src/layout/topBar.ts b/app/src/layout/topBar.ts index 64a01139e9..152e28d4f1 100644 --- a/app/src/layout/topBar.ts +++ b/app/src/layout/topBar.ts @@ -305,6 +305,7 @@ const openPlugin = (app: App, target: Element) => { menu.addItem({ icon: "iconSettings", label: window.siyuan.languages.manage, + disabled: window.siyuan.config.readonly, click() { openSetting(app).element.querySelector('.b3-tab-bar [data-name="bazaar"]').dispatchEvent(new CustomEvent("click")); } @@ -374,7 +375,7 @@ const openPlugin = (app: App, target: Element) => { } }); if (!hasPlugin) { - window.siyuan.menus.menu.element.querySelector(".b3-menu__separator").remove(); + window.siyuan.menus.menu.element.querySelector(".b3-menu__separator")?.remove(); } let rect = target.getBoundingClientRect(); if (rect.width === 0) { diff --git a/app/src/menus/commonMenuItem.ts b/app/src/menus/commonMenuItem.ts index 0c45f02721..e571f34988 100644 --- a/app/src/menus/commonMenuItem.ts +++ b/app/src/menus/commonMenuItem.ts @@ -448,6 +448,7 @@ export const exportMd = (id: string) => { label: window.siyuan.languages.template, iconClass: "ft__error", icon: "iconMarkdown", + disabled: window.siyuan.config.readonly, click: async () => { const result = await fetchSyncPost("/api/block/getRefText", {id: id}); @@ -507,8 +508,9 @@ export const exportMd = (id: string) => { }); }); return; + } else if (response.code === 0) { + showMessage(window.siyuan.languages.exportTplSucc); } - showMessage(window.siyuan.languages.exportTplSucc); }); dialog.destroy(); }); diff --git a/app/src/menus/workspace.ts b/app/src/menus/workspace.ts index 85796b2684..88f6d2017f 100644 --- a/app/src/menus/workspace.ts +++ b/app/src/menus/workspace.ts @@ -440,6 +440,7 @@ export const workspaceMenu = (app: App, rect: DOMRect) => { window.siyuan.menus.menu.append(new MenuItem({ label: window.siyuan.languages.userGuide, icon: "iconHelp", + disabled: window.siyuan.config.readonly, click: () => { mountHelp(); } diff --git a/app/src/mobile/index.ts b/app/src/mobile/index.ts index 1124a67777..f04daf7075 100644 --- a/app/src/mobile/index.ts +++ b/app/src/mobile/index.ts @@ -37,9 +37,10 @@ class App { if (!window.webkit?.messageHandlers && !window.JSAndroid) { registerServiceWorker(`${Constants.SERVICE_WORKER_PATH}?v=${Constants.SIYUAN_VERSION}`); } + addBaseURL(); 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"); - addBaseURL(); + this.appId = Constants.SIYUAN_APPID; window.siyuan = { zIndex: 10, @@ -89,30 +90,7 @@ class App { fetchPost("/api/system/getConf", {}, async (confResponse) => { window.siyuan.config = confResponse.data.conf; correctHotkey(siyuanApp); - await loadPlugins(this); - getLocalStorage(() => { - fetchGet(`/appearance/langs/${window.siyuan.config.appearance.lang}.json?v=${Constants.SIYUAN_VERSION}`, (lauguages: IObject) => { - window.siyuan.languages = lauguages; - window.siyuan.menus = new Menus(this); - document.title = window.siyuan.languages.siyuanNote; - bootSync(); - loadAssets(confResponse.data.conf.appearance); - initMessage(); - initAssets(); - fetchPost("/api/setting/getCloudUser", {}, userResponse => { - window.siyuan.user = userResponse.data; - fetchPost("/api/system/getEmojiConf", {}, emojiResponse => { - window.siyuan.emojis = emojiResponse.data as IEmoji[]; - setNoteBook(() => { - initFramework(this, confResponse.data.start); - initRightMenu(this); - openChangelog(); - }); - }); - }); - addGA(); - }); - }); + document.addEventListener("touchstart", handleTouchStart, false); document.addEventListener("touchmove", handleTouchMove, false); document.addEventListener("touchend", (event) => { @@ -140,6 +118,51 @@ class App { } } }); + + const promises = [ + loadPlugins(this), + new Promise(resolve => getLocalStorage(resolve)), + new Promise(resolve => fetchGet( + `/appearance/langs/${window.siyuan.config.appearance.lang}.json?v=${Constants.SIYUAN_VERSION}`, + (lauguages: IObject) => { + window.siyuan.languages = lauguages; + resolve(); + }, + )), + new Promise(resolve => { + fetchPost("/api/setting/getEmojiConf", {}, emojiResponse => { + window.siyuan.emojis = emojiResponse.data as IEmoji[]; + resolve(); + }); + }), + ]; + + if (!window.siyuan.config.readonly) { + promises.push(new Promise(resolve => { + fetchPost("/api/setting/getCloudUser", {}, userResponse => { + window.siyuan.user = userResponse.data; + resolve(); + }); + })); + } + + await Promise.all(promises); + + if (!window.siyuan.config.readonly) { + bootSync(); + } + + window.siyuan.menus = new Menus(this); + document.title = window.siyuan.languages.siyuanNote; + loadAssets(confResponse.data.conf.appearance); + initMessage(); + initAssets(); + setNoteBook(() => { + initFramework(this, confResponse.data.start); + initRightMenu(this); + openChangelog(); + }); + addGA(); }); } } diff --git a/app/src/protyle/gutter/index.ts b/app/src/protyle/gutter/index.ts index e1eb165182..464f45e471 100644 --- a/app/src/protyle/gutter/index.ts +++ b/app/src/protyle/gutter/index.ts @@ -1667,6 +1667,7 @@ export class Gutter { window.siyuan.menus.menu.append(new MenuItem({ label: window.siyuan.languages.wechatReminder, icon: "iconMp", + disabled: window.siyuan.config.readonly, click() { openWechatNotify(nodeElement); } @@ -1678,6 +1679,7 @@ export class Gutter { accelerator: window.siyuan.config.keymap.editor.general.quickMakeCard.custom, iconHTML: '', icon: "iconRiffCard", + disabled: window.siyuan.config.readonly, click() { quickMakeCard(protyle, [nodeElement]); } diff --git a/app/src/protyle/header/openTitleMenu.ts b/app/src/protyle/header/openTitleMenu.ts index 0af807957c..dd338bc082 100644 --- a/app/src/protyle/header/openTitleMenu.ts +++ b/app/src/protyle/header/openTitleMenu.ts @@ -112,6 +112,7 @@ export const openTitleMenu = (protyle: IProtyle, position: IPosition) => { window.siyuan.menus.menu.append(new MenuItem({ label: window.siyuan.languages.wechatReminder, icon: "iconMp", + disabled: window.siyuan.config.readonly, click() { openFileWechatNotify(protyle); } @@ -120,6 +121,7 @@ export const openTitleMenu = (protyle: IProtyle, position: IPosition) => { iconHTML: "", label: window.siyuan.languages.spaceRepetition, accelerator: window.siyuan.config.keymap.editor.general.spaceRepetition.custom, + disabled: window.siyuan.config.readonly, click: () => { fetchPost("/api/riff/getTreeRiffDueCards", {rootID: protyle.block.rootID}, (response) => { openCardByData(protyle.app, response.data, "doc", protyle.block.rootID, response.data.name); @@ -128,6 +130,7 @@ export const openTitleMenu = (protyle: IProtyle, position: IPosition) => { }, { iconHTML: "", label: window.siyuan.languages.manage, + disabled: window.siyuan.config.readonly, click: () => { fetchPost("/api/filetree/getHPathByID", { id: protyle.block.rootID @@ -139,6 +142,7 @@ export const openTitleMenu = (protyle: IProtyle, position: IPosition) => { iconHTML: "", label: window.siyuan.languages.quickMakeCard, accelerator: window.siyuan.config.keymap.editor.general.quickMakeCard.custom, + disabled: window.siyuan.config.readonly, click: () => { let titleElement = protyle.title?.element; if (!titleElement) { @@ -153,6 +157,7 @@ export const openTitleMenu = (protyle: IProtyle, position: IPosition) => { riffCardMenu.push({ iconHTML: "", label: window.siyuan.languages.addToDeck, + disabled: window.siyuan.config.readonly, click: () => { makeCard(protyle.app, [protyle.block.rootID]); } @@ -163,6 +168,7 @@ export const openTitleMenu = (protyle: IProtyle, position: IPosition) => { type: "submenu", icon: "iconRiffCard", submenu: riffCardMenu, + disabled: window.siyuan.config.readonly, }).element); window.siyuan.menus.menu.append(new MenuItem({ diff --git a/app/src/protyle/scroll/saveScroll.ts b/app/src/protyle/scroll/saveScroll.ts index 48dc2803a9..0ae19c1177 100644 --- a/app/src/protyle/scroll/saveScroll.ts +++ b/app/src/protyle/scroll/saveScroll.ts @@ -45,7 +45,7 @@ export const saveScroll = (protyle: IProtyle, getObject = false) => { export const getDocByScroll = (options: { protyle: IProtyle, - scrollAttr: IScrollAttr, + scrollAttr?: IScrollAttr, mergedOptions?: IOptions, cb?: () => void focus?: boolean, @@ -61,7 +61,7 @@ export const getDocByScroll = (options: { actions = [Constants.CB_GET_UNUNDO]; } } - if (options.scrollAttr.zoomInId) { + if (options.scrollAttr?.zoomInId) { fetchPost("/api/filetree/getDoc", { id: options.scrollAttr.zoomInId, size: Constants.SIZE_GET_MAX, @@ -100,9 +100,9 @@ export const getDocByScroll = (options: { return; } fetchPost("/api/filetree/getDoc", { - id: options.scrollAttr.rootId || options.mergedOptions?.blockId || options.protyle.block?.rootID || options.scrollAttr.startId, - startID: options.scrollAttr.startId, - endID: options.scrollAttr.endId, + id: options.scrollAttr?.rootId || options.mergedOptions?.blockId || options.protyle.block?.rootID || options.scrollAttr?.startId, + startID: options.scrollAttr?.startId, + endID: options.scrollAttr?.endId, query: options.protyle.query?.key, queryMethod: options.protyle.query?.method, queryTypes: options.protyle.query?.types, diff --git a/app/src/util/assets.ts b/app/src/util/assets.ts index d2ffad6943..314871829d 100644 --- a/app/src/util/assets.ts +++ b/app/src/util/assets.ts @@ -150,8 +150,10 @@ export const initAssets = () => { return; } } - window.siyuan.config.appearance = response.data.appearance; - loadAssets(response.data.appearance); + if (response.code === 0) { + window.siyuan.config.appearance = response.data.appearance; + loadAssets(response.data.appearance); + } }); }); }; diff --git a/app/src/window/index.ts b/app/src/window/index.ts index 24a51a7bcd..4dc48d3a1c 100644 --- a/app/src/window/index.ts +++ b/app/src/window/index.ts @@ -27,9 +27,10 @@ class App { public appId: string; constructor() { + addBaseURL(); 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"); - addBaseURL(); + this.appId = Constants.SIYUAN_APPID; window.siyuan = { zIndex: 10, @@ -146,19 +147,34 @@ class App { }; fetchPost("/api/system/getConf", {}, async (response) => { window.siyuan.config = response.data.conf; - await loadPlugins(this); - getLocalStorage(() => { - fetchGet(`/appearance/langs/${window.siyuan.config.appearance.lang}.json?v=${Constants.SIYUAN_VERSION}`, (lauguages: IObject) => { - window.siyuan.languages = lauguages; - window.siyuan.menus = new Menus(this); + + const promises = [ + loadPlugins(this), + new Promise(resolve => getLocalStorage(resolve)), + new Promise(resolve => fetchGet( + `/appearance/langs/${window.siyuan.config.appearance.lang}.json?v=${Constants.SIYUAN_VERSION}`, + (lauguages: IObject) => { + window.siyuan.languages = lauguages; + resolve(); + }, + )), + ]; + + if (!window.siyuan.config.readonly) { + promises.push(new Promise(resolve => { fetchPost("/api/setting/getCloudUser", {}, userResponse => { window.siyuan.user = userResponse.data; - init(this); - setTitle(window.siyuan.languages.siyuanNote); - initMessage(); + resolve(); }); - }); - }); + })); + } + + await Promise.all(promises); + + window.siyuan.menus = new Menus(this); + init(this); + setTitle(window.siyuan.languages.siyuanNote); + initMessage(); }); setNoteBook(); initBlockPopover(this); diff --git a/kernel/api/router.go b/kernel/api/router.go index 5d9b53f289..b200f01b08 100644 --- a/kernel/api/router.go +++ b/kernel/api/router.go @@ -47,7 +47,7 @@ func ServeAPI(ginServer *gin.Engine) { ginServer.Handle("POST", "/api/system/setDownloadInstallPkg", model.CheckAuth, model.CheckAdminRole, model.CheckReadonly, setDownloadInstallPkg) ginServer.Handle("POST", "/api/system/setNetworkProxy", model.CheckAuth, model.CheckAdminRole, model.CheckReadonly, setNetworkProxy) ginServer.Handle("POST", "/api/system/setWorkspaceDir", model.CheckAuth, model.CheckAdminRole, model.CheckReadonly, setWorkspaceDir) - ginServer.Handle("POST", "/api/system/getWorkspaces", model.CheckAuth, model.CheckAdminRole, getWorkspaces) + ginServer.Handle("POST", "/api/system/getWorkspaces", model.CheckAuth, getWorkspaces) ginServer.Handle("POST", "/api/system/getMobileWorkspaces", model.CheckAuth, model.CheckAdminRole, getMobileWorkspaces) ginServer.Handle("POST", "/api/system/checkWorkspaceDir", model.CheckAuth, model.CheckAdminRole, model.CheckReadonly, checkWorkspaceDir) ginServer.Handle("POST", "/api/system/createWorkspaceDir", model.CheckAuth, model.CheckAdminRole, model.CheckReadonly, createWorkspaceDir) @@ -238,7 +238,7 @@ func ServeAPI(ginServer *gin.Engine) { ginServer.Handle("POST", "/api/sync/listCloudSyncDir", model.CheckAuth, model.CheckAdminRole, listCloudSyncDir) ginServer.Handle("POST", "/api/sync/performSync", model.CheckAuth, model.CheckAdminRole, model.CheckReadonly, performSync) ginServer.Handle("POST", "/api/sync/performBootSync", model.CheckAuth, model.CheckAdminRole, model.CheckReadonly, performBootSync) - ginServer.Handle("POST", "/api/sync/getBootSync", model.CheckAuth, getBootSync) + ginServer.Handle("POST", "/api/sync/getBootSync", model.CheckAuth, model.CheckAdminRole, getBootSync) ginServer.Handle("POST", "/api/sync/getSyncInfo", model.CheckAuth, model.CheckAdminRole, getSyncInfo) ginServer.Handle("POST", "/api/sync/exportSyncProviderS3", model.CheckAuth, model.CheckAdminRole, exportSyncProviderS3) ginServer.Handle("POST", "/api/sync/importSyncProviderS3", model.CheckAuth, model.CheckAdminRole, model.CheckReadonly, importSyncProviderS3) @@ -318,7 +318,7 @@ func ServeAPI(ginServer *gin.Engine) { ginServer.Handle("POST", "/api/setting/setSearch", model.CheckAuth, model.CheckAdminRole, model.CheckReadonly, setSearch) ginServer.Handle("POST", "/api/setting/setKeymap", model.CheckAuth, model.CheckAdminRole, model.CheckReadonly, setKeymap) ginServer.Handle("POST", "/api/setting/setAppearance", model.CheckAuth, model.CheckAdminRole, model.CheckReadonly, setAppearance) - ginServer.Handle("POST", "/api/setting/getCloudUser", model.CheckAuth, getCloudUser) + ginServer.Handle("POST", "/api/setting/getCloudUser", model.CheckAuth, model.CheckAdminRole, getCloudUser) ginServer.Handle("POST", "/api/setting/logoutCloudUser", model.CheckAuth, model.CheckAdminRole, model.CheckReadonly, logoutCloudUser) ginServer.Handle("POST", "/api/setting/login2faCloudUser", model.CheckAuth, model.CheckAdminRole, model.CheckReadonly, login2faCloudUser) ginServer.Handle("POST", "/api/setting/setEmoji", model.CheckAuth, model.CheckAdminRole, model.CheckReadonly, setEmoji) diff --git a/kernel/api/setting.go b/kernel/api/setting.go index 9010350078..4a6322455a 100644 --- a/kernel/api/setting.go +++ b/kernel/api/setting.go @@ -590,10 +590,6 @@ func getCloudUser(c *gin.Context) { ret := gulu.Ret.NewResult() defer c.JSON(http.StatusOK, ret) - if !model.IsAdminRoleContext(c) { - return - } - arg, ok := util.JsonArg(c, ret) if !ok { return diff --git a/kernel/api/sync.go b/kernel/api/sync.go index 6f122846cc..f793cbf08d 100644 --- a/kernel/api/sync.go +++ b/kernel/api/sync.go @@ -18,13 +18,14 @@ package api import ( "encoding/hex" - "github.com/siyuan-note/logging" "io" "net/http" "os" "path/filepath" "time" + "github.com/siyuan-note/logging" + "github.com/88250/gulu" "github.com/gin-gonic/gin" "github.com/siyuan-note/siyuan/kernel/conf" @@ -381,10 +382,6 @@ func getBootSync(c *gin.Context) { ret := gulu.Ret.NewResult() defer c.JSON(http.StatusOK, ret) - if !model.IsAdminRoleContext(c) { - return - } - if model.Conf.Sync.Enabled && 1 == model.BootSyncSucc { ret.Code = 1 ret.Msg = model.Conf.Language(17) diff --git a/kernel/api/workspace.go b/kernel/api/workspace.go index 16975c1f99..c126c3c33d 100644 --- a/kernel/api/workspace.go +++ b/kernel/api/workspace.go @@ -235,6 +235,13 @@ func getWorkspaces(c *gin.Context) { return } + if role := model.GetGinContextRole(c); !model.IsValidRole(role, []model.Role{ + model.RoleAdministrator, + }) { + ret.Data = []*Workspace{} + return + } + var workspaces, openedWorkspaces, closedWorkspaces []*Workspace for _, p := range workspacePaths { closed := !util.IsWorkspaceLocked(p) diff --git a/kernel/model/role.go b/kernel/model/role.go index 79f6b0f18f..5f0fca3aa5 100644 --- a/kernel/model/role.go +++ b/kernel/model/role.go @@ -54,7 +54,3 @@ func GetGinContextRole(c *gin.Context) Role { return RoleVisitor } } - -func IsAdminRoleContext(c *gin.Context) bool { - return GetGinContextRole(c) == RoleAdministrator -} From 862fd5e993e2a07c6160aab93ec2860d635ed4a3 Mon Sep 17 00:00:00 2001 From: Daniel <845765@qq.com> Date: Fri, 5 Jul 2024 20:07:54 +0800 Subject: [PATCH 3/7] :memo: Update changelogs --- app/changelogs/v3.1.0/v3.1.0.md | 2 +- app/changelogs/v3.1.0/v3.1.0_zh_CHT.md | 68 +++++++++++++------------- app/changelogs/v3.1.0/v3.1.0_zh_CN.md | 68 +++++++++++++------------- 3 files changed, 69 insertions(+), 69 deletions(-) diff --git a/app/changelogs/v3.1.0/v3.1.0.md b/app/changelogs/v3.1.0/v3.1.0.md index 703c475daa..daad732e47 100644 --- a/app/changelogs/v3.1.0/v3.1.0.md +++ b/app/changelogs/v3.1.0/v3.1.0.md @@ -45,7 +45,6 @@ Below are the detailed changes in this version. * [No prompt when pressing the auxiliary key in the shortcut key setting](https://github.com/siyuan-note/siyuan/issues/11720) * [Improve embed blocks exporting](https://github.com/siyuan-note/siyuan/issues/11725) * [Improve use of `↓` in doc titles](https://github.com/siyuan-note/siyuan/issues/11729) -* [Kernel API OCR returns text coordinate information](https://github.com/siyuan-note/siyuan/pull/11738) * [Improve inline elements pasting](https://github.com/siyuan-note/siyuan/issues/11740) * [Improve HTML formula clipping](https://github.com/siyuan-note/siyuan/issues/11743) * [Custom Emoji folders no longer require manual refresh when they change](https://github.com/siyuan-note/siyuan/issues/11749) @@ -89,6 +88,7 @@ Below are the detailed changes in this version. ### Development +* [Kernel API OCR returns text coordinate information](https://github.com/siyuan-note/siyuan/pull/11738) * [Add internal kernel API `/api/attr/batchGetBlockAttrs`](https://github.com/siyuan-note/siyuan/issues/11786) ## Download diff --git a/app/changelogs/v3.1.0/v3.1.0_zh_CHT.md b/app/changelogs/v3.1.0/v3.1.0_zh_CHT.md index 3c634b647f..29b4af5dd0 100644 --- a/app/changelogs/v3.1.0/v3.1.0_zh_CHT.md +++ b/app/changelogs/v3.1.0/v3.1.0_zh_CHT.md @@ -15,67 +15,66 @@ * [在建立空白文件後改進互動指導](https://github.com/siyuan-note/siyuan/issues/10528) * [改進行級元素的選單互動](https://github.com/siyuan-note/siyuan/issues/10577) * [改進展開標題的效能](https://github.com/siyuan-note/siyuan/issues/10935) -* [改進PDF匯出](https://github.com/siyuan-note/siyuan/issues/11258) +* [改進 PDF 匯出](https://github.com/siyuan-note/siyuan/issues/11258) * [複製資料庫表格檢視欄位時保持寬度](https://github.com/siyuan-note/siyuan/issues/11552) -* [改進HTML實體剪輯](https://github.com/siyuan-note/siyuan/issues/11557) +* [改進 HTML 實體剪藏](https://github.com/siyuan-note/siyuan/issues/11557) * [改進帶有資料庫的文檔複製](https://github.com/siyuan-note/siyuan/issues/11602) * [改進清單項目最後刪除](https://github.com/siyuan-note/siyuan/issues/11606) -* [改進HTML標籤輸入](https://github.com/siyuan-note/siyuan/issues/11622) -* [屬性面板 - 資料庫支援欄位右鍵點擊](https://github.com/siyuan-note/siyuan/issues/11625) +* [改進 HTML 標籤輸入](https://github.com/siyuan-note/siyuan/issues/11622) +* [屬性面板 - 資料庫支援右鍵點選欄位](https://github.com/siyuan-note/siyuan/issues/11625) * [轉換清單支援設定快捷鍵](https://github.com/siyuan-note/siyuan/issues/11634) -* [改良`Ctrl+P`和`Ctrl+F`](https://github.com/siyuan-note/siyuan/issues/11637) -* [改進維基百科剪輯](https://github.com/siyuan-note/siyuan/issues/11640) -* [改進HTML程式碼剪輯](https://github.com/siyuan-note/siyuan/issues/11642) -* [改進網頁剪輯逃逸程式碼區塊標記](https://github.com/siyuan-note/siyuan/issues/11643) -* [改進`加入資料庫`搜尋](https://github.com/siyuan-note/siyuan/issues/11644) -* [改進StackExchange公式剪輯](https://github.com/siyuan-note/siyuan/issues/11646) +* [改進 `Ctrl+P` 和 `Ctrl+F`](https://github.com/siyuan-note/siyuan/issues/11637) +* [改進維基百科剪藏](https://github.com/siyuan-note/siyuan/issues/11640) +* [改進 HTML 程式碼剪藏](https://github.com/siyuan-note/siyuan/issues/11642) +* [改進網頁剪藏轉義程式碼區塊標記](https://github.com/siyuan-note/siyuan/issues/11643) +* [改進 `加入資料庫` 搜尋](https://github.com/siyuan-note/siyuan/issues/11644) +* [改進 StackExchange 公式剪藏](https://github.com/siyuan-note/siyuan/issues/11646) * [改進程式碼區塊中的遊標移動](https://github.com/siyuan-note/siyuan/issues/11647) * [在文件樹面板中顯示「已關閉筆記本」的數量](https://github.com/siyuan-note/siyuan/issues/11648) -* [Windows arm64和Linux arm64不再打包pandoc](https://github.com/siyuan-note/siyuan/issues/11649) -* [改進知乎公式剪輯](https://github.com/siyuan-note/siyuan/issues/11653) +* [Windows arm64 和 Linux arm64 不再打包 pandoc](https://github.com/siyuan-note/siyuan/issues/11649) +* [改進知識公式剪藏](https://github.com/siyuan-note/siyuan/issues/11653) * [在書籤面板顯示資料庫標題](https://github.com/siyuan-note/siyuan/issues/11666) -* [改進Mermaid的Markdown渲染](https://github.com/siyuan-note/siyuan/issues/11670) -* [改進Shift+↑/↓選擇](https://github.com/siyuan-note/siyuan/issues/11671) +* [改良 Mermaid 的 Markdown 渲染](https://github.com/siyuan-note/siyuan/issues/11670) +* [改進 Shift+↑/↓ 選擇](https://github.com/siyuan-note/siyuan/issues/11671) * [改進分割畫面中開啟文件的位置](https://github.com/siyuan-note/siyuan/issues/11676) * [在開頭貼上區塊並將其插入上方](https://github.com/siyuan-note/siyuan/issues/11677) -* [上傳資產時從檔案名稱移除看不見字元](https://github.com/siyuan-note/siyuan/issues/11683) +* [上傳資源時從檔案名稱移除看不見字元](https://github.com/siyuan-note/siyuan/issues/11683) * [改進行動端自訂表情渲染](https://github.com/siyuan-note/siyuan/issues/11690) -* [改進表格中的↑/↓移動](https://github.com/siyuan-note/siyuan/issues/11694) -* [匯出.sy.zip和data.zip時顯示詳情](https://github.com/siyuan-note/siyuan/issues/11696) +* [改進表格中的 ↑/↓ 移動](https://github.com/siyuan-note/siyuan/issues/11694) +* [匯出 .sy.zip 與 data.zip 時顯示詳情](https://github.com/siyuan-note/siyuan/issues/11696) * [在快速鍵設定中按輔助鍵時無提示](https://github.com/siyuan-note/siyuan/issues/11720) * [改進嵌入塊導出](https://github.com/siyuan-note/siyuan/issues/11725) -* [改進文件標題中`↓`的使用](https://github.com/siyuan-note/siyuan/issues/11729) -* [內核API OCR回傳文字座標資訊](https://github.com/siyuan-note/siyuan/pull/11738) +* [改進文件標題中 `↓` 的使用](https://github.com/siyuan-note/siyuan/issues/11729) * [改進行級元素貼上](https://github.com/siyuan-note/siyuan/issues/11740) -* [改進HTML公式剪輯](https://github.com/siyuan-note/siyuan/issues/11743) +* [改進 HTML 公式剪藏](https://github.com/siyuan-note/siyuan/issues/11743) * [自訂表情資料夾更改時不再需要手動刷新](https://github.com/siyuan-note/siyuan/issues/11749) * [圖片居中後改進選擇操作](https://github.com/siyuan-note/siyuan/issues/11757) -* [在PDF標籤的右鍵選單中新增「複製」](https://github.com/siyuan-note/siyuan/issues/11758) +* [在 PDF 標籤的右鍵選單中新增「複製」](https://github.com/siyuan-note/siyuan/issues/11758) * [改進包含圖片的區塊的多重選擇](https://github.com/siyuan-note/siyuan/issues/11763) * [改進表情搜尋](https://github.com/siyuan-note/siyuan/pull/11768) -* [改進匯出PDF註解超連結的頁碼顯示](https://github.com/siyuan-note/siyuan/issues/11780) -* [改進HTML表格剪輯](https://github.com/siyuan-note/siyuan/issues/11783) -* [匯出區塊引用`錨點哈希`支援文件層級](https://github.com/siyuan-note/siyuan/issues/11814) +* [改進匯出 PDF 註解超連結的頁碼顯示](https://github.com/siyuan-note/siyuan/issues/11780) +* [改進 HTML 表格剪藏](https://github.com/siyuan-note/siyuan/issues/11783) +* [匯出區塊引用 `錨點哈希` 支援文件層級](https://github.com/siyuan-note/siyuan/issues/11814) * [改良字體家族](https://github.com/siyuan-note/siyuan/issues/11841) -* [資料同步後重新索引筆記本並重新載入UI,如果筆記本設定改變](https://github.com/siyuan-note/siyuan/issues/11850) +* [如果筆記本配置改變,資料同步後重新索引筆記本並重新載入介面](https://github.com/siyuan-note/siyuan/issues/11850) ### 修復缺陷 * [行動超級塊的子塊異常](https://github.com/siyuan-note/siyuan/issues/11609) * [在多視窗編輯時,文件無法在新視窗正常開啟](https://github.com/siyuan-note/siyuan/issues/11610) -* [行動端無法使用`新增至資料庫`](https://github.com/siyuan-note/siyuan/issues/11651) -* [拖曳並撤銷HTML區塊將顯示標籤](https://github.com/siyuan-note/siyuan/issues/11656) +* [行動端無法使用 `新增至資料庫`](https://github.com/siyuan-note/siyuan/issues/11651) +* [拖曳並撤銷 HTML 區塊將顯示標籤](https://github.com/siyuan-note/siyuan/issues/11656) * [行動文件後無法重新命名](https://github.com/siyuan-note/siyuan/issues/11661) * [圖片標題的轉義內容重複](https://github.com/siyuan-note/siyuan/issues/11681) -* [啟用自適應寬度時,IFrame區塊不會調整大小](https://github.com/siyuan-note/siyuan/issues/11695) -* [含有`%`的行級備註無法顯示](https://github.com/siyuan-note/siyuan/issues/11709) -* [行級元素`Shift+Enter`無法正常運作](https://github.com/siyuan-note/siyuan/issues/11766) +* [啟用自適應寬度時,IFrame 區塊不會調整大小](https://github.com/siyuan-note/siyuan/issues/11695) +* [含 `%` 的行級備註無法顯示](https://github.com/siyuan-note/siyuan/issues/11709) +* [行級元素中 `Shift+Enter` 無法正常運作](https://github.com/siyuan-note/siyuan/issues/11766) * [在行級程式碼內貼上轉義文字異常](https://github.com/siyuan-note/siyuan/issues/11778) -* [無法編輯AI自訂操作](https://github.com/siyuan-note/siyuan/issues/11791) -* [使用`Ctrl+X`應剪切嵌入塊本身](https://github.com/siyuan-note/siyuan/issues/11793) +* [無法編輯 AI 自訂操作](https://github.com/siyuan-note/siyuan/issues/11791) +* [使用 `Ctrl+X` 應剪切嵌入塊本身](https://github.com/siyuan-note/siyuan/issues/11793) * [有時音訊或視訊無法播放](https://github.com/siyuan-note/siyuan/issues/11810) -* [搜尋UI XSS](https://github.com/siyuan-note/siyuan/issues/11848) -* [程式碼區塊語言搜尋XSS](https://github.com/siyuan-note/siyuan/issues/11869) +* [搜尋介面 XSS](https://github.com/siyuan-note/siyuan/issues/11848) +* [程式碼區塊語言搜尋 XSS](https://github.com/siyuan-note/siyuan/issues/11869) ### 改進文檔 @@ -89,6 +88,7 @@ ### 開發者 +* [核心 API OCR 傳回文字座標資訊](https://github.com/siyuan-note/siyuan/pull/11738) * [新增內部內核 `/api/attr/batchGetBlockAttrs`](https://github.com/siyuan-note/siyuan/issues/11786) ## 下載 diff --git a/app/changelogs/v3.1.0/v3.1.0_zh_CN.md b/app/changelogs/v3.1.0/v3.1.0_zh_CN.md index adf809b19f..a5794cf9dc 100644 --- a/app/changelogs/v3.1.0/v3.1.0_zh_CN.md +++ b/app/changelogs/v3.1.0/v3.1.0_zh_CN.md @@ -15,67 +15,66 @@ * [在创建空文档后改进交互指导](https://github.com/siyuan-note/siyuan/issues/10528) * [改进行级元素的菜单交互](https://github.com/siyuan-note/siyuan/issues/10577) * [改进展开标题的性能](https://github.com/siyuan-note/siyuan/issues/10935) -* [改进PDF导出](https://github.com/siyuan-note/siyuan/issues/11258) +* [改进 PDF 导出](https://github.com/siyuan-note/siyuan/issues/11258) * [复制数据库表视图字段时保持宽度](https://github.com/siyuan-note/siyuan/issues/11552) -* [改进HTML实体剪辑](https://github.com/siyuan-note/siyuan/issues/11557) +* [改进 HTML 实体剪藏](https://github.com/siyuan-note/siyuan/issues/11557) * [改进带数据库的文档复制](https://github.com/siyuan-note/siyuan/issues/11602) * [改进列表项末尾删除](https://github.com/siyuan-note/siyuan/issues/11606) -* [改进HTML标签输入](https://github.com/siyuan-note/siyuan/issues/11622) -* [属性面板 - 数据库支持字段右键点击](https://github.com/siyuan-note/siyuan/issues/11625) +* [改进 HTML 标签输入](https://github.com/siyuan-note/siyuan/issues/11622) +* [属性面板 - 数据库支持右键点击字段](https://github.com/siyuan-note/siyuan/issues/11625) * [转换列表支持配置快捷键](https://github.com/siyuan-note/siyuan/issues/11634) -* [改进`Ctrl+P`和`Ctrl+F`](https://github.com/siyuan-note/siyuan/issues/11637) -* [改进维基百科剪辑](https://github.com/siyuan-note/siyuan/issues/11640) -* [改进HTML代码剪辑](https://github.com/siyuan-note/siyuan/issues/11642) -* [改进网页剪辑逃逸代码块标记](https://github.com/siyuan-note/siyuan/issues/11643) -* [改进`添加到数据库`搜索](https://github.com/siyuan-note/siyuan/issues/11644) -* [改进StackExchange公式剪辑](https://github.com/siyuan-note/siyuan/issues/11646) +* [改进 `Ctrl+P` 和 `Ctrl+F`](https://github.com/siyuan-note/siyuan/issues/11637) +* [改进维基百科剪藏](https://github.com/siyuan-note/siyuan/issues/11640) +* [改进 HTML 代码剪藏](https://github.com/siyuan-note/siyuan/issues/11642) +* [改进网页剪藏转义代码块标记](https://github.com/siyuan-note/siyuan/issues/11643) +* [改进 `添加到数据库` 搜索](https://github.com/siyuan-note/siyuan/issues/11644) +* [改进 StackExchange 公式剪藏](https://github.com/siyuan-note/siyuan/issues/11646) * [改进代码块中的光标移动](https://github.com/siyuan-note/siyuan/issues/11647) * [在文档树面板中显示“已关闭笔记本”的数量](https://github.com/siyuan-note/siyuan/issues/11648) -* [Windows arm64和Linux arm64不再打包pandoc](https://github.com/siyuan-note/siyuan/issues/11649) -* [改进知乎公式剪辑](https://github.com/siyuan-note/siyuan/issues/11653) +* [Windows arm64 和 Linux arm64 不再打包 pandoc](https://github.com/siyuan-note/siyuan/issues/11649) +* [改进知乎公式剪藏](https://github.com/siyuan-note/siyuan/issues/11653) * [在书签面板显示数据库标题](https://github.com/siyuan-note/siyuan/issues/11666) -* [改进Mermaid的Markdown渲染](https://github.com/siyuan-note/siyuan/issues/11670) -* [改进Shift+↑/↓选择](https://github.com/siyuan-note/siyuan/issues/11671) +* [改进 Mermaid 的 Markdown 渲染](https://github.com/siyuan-note/siyuan/issues/11670) +* [改进 Shift+↑/↓ 选择](https://github.com/siyuan-note/siyuan/issues/11671) * [改进分屏中打开文档的位置](https://github.com/siyuan-note/siyuan/issues/11676) * [在开头粘贴块并将其插入上方](https://github.com/siyuan-note/siyuan/issues/11677) -* [上传资产时从文件名中移除不可见字符](https://github.com/siyuan-note/siyuan/issues/11683) +* [上传资源时从文件名中移除不可见字符](https://github.com/siyuan-note/siyuan/issues/11683) * [改进移动端自定义表情渲染](https://github.com/siyuan-note/siyuan/issues/11690) -* [改进表格中的↑/↓移动](https://github.com/siyuan-note/siyuan/issues/11694) -* [导出.sy.zip和data.zip时显示详情](https://github.com/siyuan-note/siyuan/issues/11696) +* [改进表格中的 ↑/↓ 移动](https://github.com/siyuan-note/siyuan/issues/11694) +* [导出 .sy.zip 和 data.zip 时显示详情](https://github.com/siyuan-note/siyuan/issues/11696) * [在快捷键设置中按辅助键时无提示](https://github.com/siyuan-note/siyuan/issues/11720) * [改进嵌入块导出](https://github.com/siyuan-note/siyuan/issues/11725) -* [改进文档标题中`↓`的使用](https://github.com/siyuan-note/siyuan/issues/11729) -* [内核API OCR返回文本坐标信息](https://github.com/siyuan-note/siyuan/pull/11738) +* [改进文档标题中 `↓` 的使用](https://github.com/siyuan-note/siyuan/issues/11729) * [改进行级元素粘贴](https://github.com/siyuan-note/siyuan/issues/11740) -* [改进HTML公式剪辑](https://github.com/siyuan-note/siyuan/issues/11743) +* [改进 HTML 公式剪藏](https://github.com/siyuan-note/siyuan/issues/11743) * [自定义表情文件夹更改时不再需要手动刷新](https://github.com/siyuan-note/siyuan/issues/11749) * [图片居中后改进选择操作](https://github.com/siyuan-note/siyuan/issues/11757) -* [在PDF标签的右键菜单中添加“复制”](https://github.com/siyuan-note/siyuan/issues/11758) +* [在 PDF 标签的右键菜单中添加“复制”](https://github.com/siyuan-note/siyuan/issues/11758) * [改进包含图片的块的多重选择](https://github.com/siyuan-note/siyuan/issues/11763) * [改进表情搜索](https://github.com/siyuan-note/siyuan/pull/11768) -* [改进导出PDF注释超链接的页码显示](https://github.com/siyuan-note/siyuan/issues/11780) -* [改进HTML表格剪辑](https://github.com/siyuan-note/siyuan/issues/11783) -* [导出块引用`锚点哈希`支持文档级别](https://github.com/siyuan-note/siyuan/issues/11814) +* [改进导出 PDF 注释超链接的页码显示](https://github.com/siyuan-note/siyuan/issues/11780) +* [改进 HTML 表格剪藏](https://github.com/siyuan-note/siyuan/issues/11783) +* [导出块引用 `锚点哈希` 支持文档级别](https://github.com/siyuan-note/siyuan/issues/11814) * [改进字体家族](https://github.com/siyuan-note/siyuan/issues/11841) -* [数据同步后重新索引笔记本并重新加载UI,如果笔记本配置改变](https://github.com/siyuan-note/siyuan/issues/11850) +* [如果笔记本配置改变,数据同步后重新索引笔记本并重新加载界面](https://github.com/siyuan-note/siyuan/issues/11850) ### 修复缺陷 * [移动超级块的子块异常](https://github.com/siyuan-note/siyuan/issues/11609) * [在多窗口编辑时,文档无法在新窗口正常打开](https://github.com/siyuan-note/siyuan/issues/11610) -* [移动端无法使用`添加到数据库`](https://github.com/siyuan-note/siyuan/issues/11651) -* [拖动和撤销HTML块将显示标签](https://github.com/siyuan-note/siyuan/issues/11656) +* [移动端无法使用 `添加到数据库`](https://github.com/siyuan-note/siyuan/issues/11651) +* [拖动和撤销 HTML 块将显示标签](https://github.com/siyuan-note/siyuan/issues/11656) * [移动文档后无法重命名](https://github.com/siyuan-note/siyuan/issues/11661) * [图片标题的转义内容重复](https://github.com/siyuan-note/siyuan/issues/11681) -* [启用自适应宽度时,IFrame块不会调整大小](https://github.com/siyuan-note/siyuan/issues/11695) -* [含有`%`的行级备注无法显示](https://github.com/siyuan-note/siyuan/issues/11709) -* [行级元素中`Shift+Enter`无法正常工作](https://github.com/siyuan-note/siyuan/issues/11766) +* [启用自适应宽度时,IFrame 块不会调整大小](https://github.com/siyuan-note/siyuan/issues/11695) +* [含有 `%` 的行级备注无法显示](https://github.com/siyuan-note/siyuan/issues/11709) +* [行级元素中 `Shift+Enter` 无法正常工作](https://github.com/siyuan-note/siyuan/issues/11766) * [在行级代码内粘贴转义文本异常](https://github.com/siyuan-note/siyuan/issues/11778) -* [无法编辑AI自定义操作](https://github.com/siyuan-note/siyuan/issues/11791) -* [使用`Ctrl+X`应剪切嵌入块本身](https://github.com/siyuan-note/siyuan/issues/11793) +* [无法编辑 AI 自定义操作](https://github.com/siyuan-note/siyuan/issues/11791) +* [使用 `Ctrl+X` 应剪切嵌入块本身](https://github.com/siyuan-note/siyuan/issues/11793) * [有时音频或视频无法播放](https://github.com/siyuan-note/siyuan/issues/11810) -* [搜索UI XSS](https://github.com/siyuan-note/siyuan/issues/11848) -* [代码块语言搜索XSS](https://github.com/siyuan-note/siyuan/issues/11869) +* [搜索界面 XSS](https://github.com/siyuan-note/siyuan/issues/11848) +* [代码块语言搜索 XSS](https://github.com/siyuan-note/siyuan/issues/11869) ### 改进文档 @@ -89,6 +88,7 @@ ### 开发者 +* [内核 API OCR 返回文本坐标信息](https://github.com/siyuan-note/siyuan/pull/11738) * [添加内部内核 `/api/attr/batchGetBlockAttrs`](https://github.com/siyuan-note/siyuan/issues/11786) ## 下载 From 4473715186a56163b945668a7004ca8c29924867 Mon Sep 17 00:00:00 2001 From: Daniel <845765@qq.com> Date: Fri, 5 Jul 2024 20:16:10 +0800 Subject: [PATCH 4/7] :art: Improve publish --- kernel/model/conf.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/kernel/model/conf.go b/kernel/model/conf.go index 4a35c8621d..8c5fa7dd18 100644 --- a/kernel/model/conf.go +++ b/kernel/model/conf.go @@ -361,6 +361,9 @@ func InitConf() { if nil == Conf.Publish { Conf.Publish = conf.NewPublish() } + if Conf.OpenHelp && Conf.Publish.Enable { + Conf.OpenHelp = false + } if nil == Conf.Repo { Conf.Repo = conf.NewRepo() From cd40ec50bbebe87ba6de7bf832805a73ffd5c476 Mon Sep 17 00:00:00 2001 From: Vanessa Date: Fri, 5 Jul 2024 21:00:21 +0800 Subject: [PATCH 5/7] :recycle: fix https://github.com/siyuan-note/siyuan/pull/11733 --- app/src/boot/globalEvent/keydown.ts | 6 +- app/src/card/openCard.ts | 3 + app/src/config/editor.ts | 10 +- app/src/index.ts | 46 ++-- app/src/layout/Wnd.ts | 4 +- app/src/layout/status.ts | 22 +- app/src/layout/tabUtil.ts | 2 +- app/src/layout/topBar.ts | 20 +- app/src/menus/Menu.ts | 3 + app/src/menus/commonMenuItem.ts | 4 +- app/src/menus/navigation.ts | 274 ++++++++++++------------ app/src/menus/workspace.ts | 58 ++--- app/src/mobile/index.ts | 75 +++---- app/src/mobile/menu/index.ts | 2 +- app/src/mobile/util/setEmpty.ts | 2 +- app/src/plugin/Menu.ts | 5 +- app/src/protyle/gutter/index.ts | 47 ++-- app/src/protyle/header/openTitleMenu.ts | 109 +++++----- app/src/types/index.d.ts | 1 + app/src/util/assets.ts | 6 +- app/src/window/index.ts | 40 ++-- 21 files changed, 341 insertions(+), 398 deletions(-) diff --git a/app/src/boot/globalEvent/keydown.ts b/app/src/boot/globalEvent/keydown.ts index 5ca1a3b91c..f05e177a34 100644 --- a/app/src/boot/globalEvent/keydown.ts +++ b/app/src/boot/globalEvent/keydown.ts @@ -287,7 +287,7 @@ const editKeydown = (app: App, event: KeyboardEvent) => { event.preventDefault(); return true; } - if (!isFileFocus && matchHotKey(window.siyuan.config.keymap.editor.general.quickMakeCard.custom, event)) { + if (!isFileFocus && matchHotKey(window.siyuan.config.keymap.editor.general.quickMakeCard.custom, event) && !window.siyuan.config.readonly) { if (protyle.title?.editElement.contains(range.startContainer)) { quickMakeCard(protyle, [protyle.title.element]); } else { @@ -316,7 +316,7 @@ const editKeydown = (app: App, event: KeyboardEvent) => { event.preventDefault(); return true; } - if (!isFileFocus && matchHotKey(window.siyuan.config.keymap.editor.general.spaceRepetition.custom, event)) { + if (!isFileFocus && matchHotKey(window.siyuan.config.keymap.editor.general.spaceRepetition.custom, event) && !window.siyuan.config.readonly) { fetchPost("/api/riff/getTreeRiffDueCards", {rootID: protyle.block.rootID}, (response) => { openCardByData(app, response.data, "doc", protyle.block.rootID, protyle.title?.editElement.textContent || window.siyuan.languages.untitled); }); @@ -593,7 +593,7 @@ const fileTreeKeydown = (app: App, event: KeyboardEvent) => { const pathString = liElements[0].getAttribute("data-path"); const isFile = liElements[0].getAttribute("data-type") === "navigation-file"; - if (matchHotKey(window.siyuan.config.keymap.editor.general.spaceRepetition.custom, event)) { + if (matchHotKey(window.siyuan.config.keymap.editor.general.spaceRepetition.custom, event) && !window.siyuan.config.readonly) { if (isFile) { const id = liElements[0].getAttribute("data-node-id"); fetchPost("/api/riff/getTreeRiffDueCards", {rootID: id}, (response) => { diff --git a/app/src/card/openCard.ts b/app/src/card/openCard.ts index 804a3403ad..b10998479e 100644 --- a/app/src/card/openCard.ts +++ b/app/src/card/openCard.ts @@ -672,6 +672,9 @@ const emitEvent = (app: App, card: ICard, type: string) => { }; export const openCard = (app: App) => { + if (window.siyuan.config.readonly) { + return + } fetchPost("/api/riff/getRiffDueCards", {deckID: ""}, (cardsResponse) => { openCardByData(app, cardsResponse.data, "all"); }); diff --git a/app/src/config/editor.ts b/app/src/config/editor.ts index 102acc26f3..851b2c65ec 100644 --- a/app/src/config/editor.ts +++ b/app/src/config/editor.ts @@ -310,12 +310,10 @@ export const editor = { if (fontFamilyElement.tagName === "SELECT") { let fontFamilyHTML = ``; fetchPost("/api/system/getSysFonts", {}, (response) => { - if (response.code === 0) { - response.data.forEach((item: string) => { - fontFamilyHTML += ``; - }); - fontFamilyElement.innerHTML = fontFamilyHTML; - } + response.data.forEach((item: string) => { + fontFamilyHTML += ``; + }); + fontFamilyElement.innerHTML = fontFamilyHTML; }); } editor.element.querySelector("#clearHistory").addEventListener("click", () => { diff --git a/app/src/index.ts b/app/src/index.ts index c666a0cc1a..0bcd88cf56 100644 --- a/app/src/index.ts +++ b/app/src/index.ts @@ -38,8 +38,6 @@ export class App { registerServiceWorker(`${Constants.SERVICE_WORKER_PATH}?v=${Constants.SIYUAN_VERSION}`); /// #endif addBaseURL(); - 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"), this.appId = Constants.SIYUAN_APPID; window.siyuan = { @@ -160,40 +158,24 @@ export class App { }; fetchPost("/api/system/getConf", {}, async (response) => { + 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; - - const promises = [ - loadPlugins(this), - new Promise(resolve => getLocalStorage(resolve)), - new Promise(resolve => fetchGet( - `/appearance/langs/${window.siyuan.config.appearance.lang}.json?v=${Constants.SIYUAN_VERSION}`, - (lauguages: IObject) => { - window.siyuan.languages = lauguages; - resolve(); - }, - )), - ]; - - if (!window.siyuan.config.readonly) { - promises.push(new Promise(resolve => { + await loadPlugins(this); + getLocalStorage(() => { + fetchGet(`/appearance/langs/${window.siyuan.config.appearance.lang}.json?v=${Constants.SIYUAN_VERSION}`, (lauguages: IObject) => { + window.siyuan.languages = lauguages; + window.siyuan.menus = new Menus(this); + bootSync(); fetchPost("/api/setting/getCloudUser", {}, userResponse => { window.siyuan.user = userResponse.data; - resolve(); + onGetConfig(response.data.start, this); + account.onSetaccount(); + setTitle(window.siyuan.languages.siyuanNote); + initMessage(); }); - })); - } - - await Promise.all(promises); - - if (!window.siyuan.config.readonly) { - bootSync(); - } - - window.siyuan.menus = new Menus(this); - onGetConfig(response.data.start, this); - account.onSetaccount(); - setTitle(window.siyuan.languages.siyuanNote); - initMessage(); + }); + }); }); setNoteBook(); initBlockPopover(this); diff --git a/app/src/layout/Wnd.ts b/app/src/layout/Wnd.ts index a2fd122736..64d18dae62 100644 --- a/app/src/layout/Wnd.ts +++ b/app/src/layout/Wnd.ts @@ -67,7 +67,7 @@ export class Wnd {