소스 검색

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

Vanessa 2 년 전
부모
커밋
9e83c53872
2개의 변경된 파일12개의 추가작업 그리고 1개의 파일을 삭제
  1. 2 1
      app/src/plugin/API.ts
  2. 10 0
      app/src/util/functions.ts

+ 2 - 1
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,

+ 10 - 0
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/")) {