Skip to content

An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作

:art: https://github.com/siyuan-note/siyuan/issues/5066 getBackend

Vanessa9e83c53872f2
diff --git a/app/src/plugin/API.ts b/app/src/plugin/API.ts
index 584cc1efd9..4e25f61229 100644
--- a/app/src/plugin/API.ts
+++ b/app/src/plugin/API.ts
@@ -4,7 +4,7 @@ import {showMessage} from "../dialog/message";
import {Dialog} from "../dialog";
import {Menu as SiyuanMenu} from "../menus/Menu";
import {fetchGet, fetchPost, fetchSyncPost} from "../util/fetch";
-import {getFrontend} from "../util/functions";
+import {getBackend, getFrontend} from "../util/functions";
/// #if !MOBILE
import {openFile, openFileById} from "../editor/util";
/// #endif
@@ -205,6 +205,7 @@ export const API = {
fetchSyncPost,
fetchGet,
getFrontend,
+ getBackend,
openTab,
Plugin,
Dialog,
diff --git a/app/src/util/functions.ts b/app/src/util/functions.ts
index 708ac78422..b2c912c3d1 100644
--- a/app/src/util/functions.ts
+++ b/app/src/util/functions.ts
@@ -2,6 +2,16 @@ export const isMobile = () => {
return document.getElementById("sidebar") ? true : false;
};
+// "windows" | "linux" | "darwin" | "docker" | "android" | "ios"
+export const getBackend = () => {
+ if (["docker", "ios", "android"].includes(window.siyuan.config.system.container)) {
+ return window.siyuan.config.system.container
+ } else {
+ return window.siyuan.config.system.os
+ }
+};
+
+// "desktop" | "desktop-window" | "mobile" | "browser-desktop" | "browser-mobile"
export const getFrontend = () => {
/// #if MOBILE
if (window.navigator.userAgent.startsWith("SiYuan/")) {