An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作
TypeScript agentic-aiai-agentknowledge-baselocal-firstmarkdownmcpmindmapnote-takingself-hostedsiyuanworkspace
:art: https://github.com/siyuan-note/siyuan/issues/14167
Vanessa67bca6c5bd72
diff --git a/app/src/config/appearance.ts b/app/src/config/appearance.tsindex 773d345744..acdac0d507 100644--- a/app/src/config/appearance.ts+++ b/app/src/config/appearance.ts@@ -171,9 +171,10 @@ export const appearance = {const themeLight = (appearance.element.querySelector("#themeLight") as HTMLSelectElement).value;const themeDark = (appearance.element.querySelector("#themeDark") as HTMLSelectElement).value;const modeElementValue = parseInt((appearance.element.querySelector("#mode") as HTMLSelectElement).value);+ const OSTheme = window.matchMedia("(prefers-color-scheme: dark)").matches ? "dark" : "light";fetchPost("/api/setting/setAppearance", {icon: (appearance.element.querySelector("#icon") as HTMLSelectElement).value,- mode: modeElementValue === 2 ? window.siyuan.config.appearance.mode : modeElementValue,+ mode: modeElementValue === 2 ? (OSTheme === "light" ? 0 : 1) : modeElementValue,modeOS: modeElementValue === 2,codeBlockThemeDark: (appearance.element.querySelector("#codeBlockThemeDark") as HTMLSelectElement).value,codeBlockThemeLight: (appearance.element.querySelector("#codeBlockThemeLight") as HTMLSelectElement).value,@@ -187,19 +188,21 @@ export const appearance = {hideStatusBar: (appearance.element.querySelector("#hideStatusBar") as HTMLInputElement).checked,}, async response => {if (window.siyuan.config.appearance.themeJS) {- if (window.destroyTheme) {- try {- await window.destroyTheme();- window.destroyTheme = undefined;- } catch (e) {- console.error("destroyTheme error: " + e);- }- } else {- if (!response.data.modeOS && (- response.data.mode !== window.siyuan.config.appearance.mode ||- window.siyuan.config.appearance.themeLight !== response.data.themeLight ||- window.siyuan.config.appearance.themeDark !== response.data.themeDark- )) {+ if (response.data.mode !== window.siyuan.config.appearance.mode ||+ (response.data.mode === window.siyuan.config.appearance.mode && (+ (response.data.mode === 0 && window.siyuan.config.appearance.themeLight !== response.data.themeLight) ||+ (response.data.mode === 1 && window.siyuan.config.appearance.themeDark !== response.data.themeDark))+ )+ ) {+ if (window.destroyTheme) {+ try {+ await window.destroyTheme();+ window.destroyTheme = undefined;+ document.getElementById("themeScript").remove();+ } catch (e) {+ console.error("destroyTheme error: " + e);+ }+ } else {exportLayout({errorExit: false,cb() {@@ -208,18 +211,6 @@ export const appearance = {});return;}- const OSTheme = window.matchMedia("(prefers-color-scheme: dark)").matches ? "dark" : "light";- if (response.data.modeOS && (- (response.data.mode === 1 && OSTheme === "light") || (response.data.mode === 0 && OSTheme === "dark")- )) {- exportLayout({- cb() {- window.location.reload();- },- errorExit: false,- });- return;- }}}appearance.onSetappearance(response.data);diff --git a/app/src/config/bazaar.ts b/app/src/config/bazaar.tsindex 4a932e13f3..51edf7b90d 100644--- a/app/src/config/bazaar.ts+++ b/app/src/config/bazaar.ts@@ -685,6 +685,7 @@ export const bazaar = {try {await window.destroyTheme();window.destroyTheme = undefined;+ document.getElementById("themeScript").remove();} catch (e) {console.error("destroyTheme error: " + e);}@@ -775,11 +776,11 @@ export const bazaar = {try {await window.destroyTheme();window.destroyTheme = undefined;+ document.getElementById("themeScript").remove();+ addScript(`/appearance/themes/${currentTheme}/theme.js?v=${response.data.appearance.themeVer}`, "themeScript");} catch (e) {console.error("destroyTheme error: " + e);}- document.getElementById("themeScript").remove();- addScript(`/appearance/themes/${currentTheme}/theme.js?v=${response.data.appearance.themeVer}`, "themeScript");} else {exportLayout({cb() {@@ -869,6 +870,7 @@ export const bazaar = {try {await window.destroyTheme();window.destroyTheme = undefined;+ document.getElementById("themeScript").remove();} catch (e) {console.error("destroyTheme error: " + e);}diff --git a/app/src/util/assets.ts b/app/src/util/assets.tsindex f3dca2fca5..a54f060a86 100644--- a/app/src/util/assets.ts+++ b/app/src/util/assets.ts@@ -90,10 +90,13 @@ export const loadAssets = (data: Config.IAppearance) => {const themeScriptElement = document.getElementById("themeScript");const themeScriptAddress = `/appearance/themes/${data.mode === 1 ? data.themeDark : data.themeLight}/theme.js?v=${data.themeVer}`;if (themeScriptElement) {- // https://github.com/siyuan-note/siyuan/issues/10341- themeScriptElement.remove();+ if (!themeScriptElement.getAttribute("src").startsWith(themeScriptAddress)) {+ themeScriptElement.remove();+ addScript(themeScriptAddress, "themeScript");+ }+ } else {+ addScript(themeScriptAddress, "themeScript");}- addScript(themeScriptAddress, "themeScript");const iconDefaultScriptElement = document.getElementById("iconDefaultScript");// 不能使用 data.iconVer,因为其他主题也需要加载默认图标,此时 data.iconVer 为其他图标的版本号@@ -140,6 +143,7 @@ export const initAssets = () => {try {await window.destroyTheme();window.destroyTheme = undefined;+ document.getElementById("themeScript").remove();} catch (e) {console.error("destroyTheme error: " + e);}@@ -382,6 +386,7 @@ export const setMode = (modeElementValue: number) => {try {await window.destroyTheme();window.destroyTheme = undefined;+ document.getElementById("themeScript").remove();} catch (e) {console.error("destroyTheme error: " + e);}