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: Apps in Chinese mainland app stores no longer provide AI access settings https://github.com/siyuan-note/siyuan/issues/13051
Daniele585263970ea
diff --git a/app/src/mobile/menu/index.ts b/app/src/mobile/menu/index.tsindex 3fc4ddf3fd..3d8c09c4fb 100644--- a/app/src/mobile/menu/index.ts+++ b/app/src/mobile/menu/index.ts@@ -16,7 +16,7 @@ import {initAbout} from "../settings/about";import {getRecentDocs} from "./getRecentDocs";import {initEditor} from "../settings/editor";import {App} from "../../index";-import {isHuawei, isInAndroid, isInIOS, isIPhone} from "../../protyle/util/compatibility";+import {isDisabledFeature, isHuawei, isInAndroid, isInIOS, isIPhone} from "../../protyle/util/compatibility";import {newFile} from "../../util/newFile";import {afterLoadPlugin} from "../../plugin/loader";import {commandPanel} from "../../boot/globalEvent/command/panel";@@ -45,8 +45,9 @@ export const initRightMenu = (app: App) => {let aiHTML = `<div class="b3-menu__item${window.siyuan.config.readonly ? " fn__none" : ""}" id="menuAI"><svg class="b3-menu__icon"><use xlink:href="#iconSparkles"></use></svg><span class="b3-menu__label">AI</span></div>`;- if (isHuawei()) {+ if (isHuawei() || isDisabledFeature("ai")) {// Access to the OpenAI API is no longer supported on Huawei devices https://github.com/siyuan-note/siyuan/issues/8192+ // Apps in Chinese mainland app stores no longer provide AI access settings https://github.com/siyuan-note/siyuan/issues/13051aiHTML = "";}diff --git a/app/src/protyle/util/compatibility.ts b/app/src/protyle/util/compatibility.tsindex c3f4bdae8f..597b43dc90 100644--- a/app/src/protyle/util/compatibility.ts+++ b/app/src/protyle/util/compatibility.ts@@ -110,6 +110,10 @@ export const isHuawei = () => {return window.siyuan.config.system.osPlatform.toLowerCase().indexOf("huawei") > -1;};+export const isDisabledFeature = (feature: string): boolean => {+ return window.siyuan.config.system.disabledFeatures.indexOf(feature) > -1;+}+export const isIPhone = () => {return navigator.userAgent.indexOf("iPhone") > -1;};diff --git a/app/src/types/config.d.ts b/app/src/types/config.d.tsindex af1d6422cd..5a1a9362d0 100644--- a/app/src/types/config.d.ts+++ b/app/src/types/config.d.ts@@ -1521,6 +1521,10 @@ declare namespace Config {* The absolute path of the workspace directory*/workspaceDir: string;+ /**+ * Disabled features.+ */+ disabledFeatures: string[];}/**diff --git a/kernel/conf/system.go b/kernel/conf/system.goindex 6d51b4ce10..7640ca2241 100644--- a/kernel/conf/system.go+++ b/kernel/conf/system.go@@ -44,6 +44,8 @@ type System struct {DownloadInstallPkg bool `json:"downloadInstallPkg"`AutoLaunch2 int `json:"autoLaunch2"` // 0:不自动启动,1:自动启动,2:自动启动+隐藏主窗口LockScreenMode int `json:"lockScreenMode"` // 0:手动,1:手动+跟随系统 https://github.com/siyuan-note/siyuan/issues/9087++ DisabledFeatures []string `json:"disabledFeatures"`}func NewSystem() *System {diff --git a/kernel/mobile/kernel.go b/kernel/mobile/kernel.goindex 900238fcfb..7e2e01a798 100644--- a/kernel/mobile/kernel.go+++ b/kernel/mobile/kernel.go@@ -114,3 +114,7 @@ func SetTimezone(container, appDir, timezoneID string) {}time.Local = z}++func DisableFeature(feature string) {+ util.DisableFeature(feature)+}diff --git a/kernel/model/conf.go b/kernel/model/conf.goindex fd71dcb336..67947f333c 100644--- a/kernel/model/conf.go+++ b/kernel/model/conf.go@@ -220,6 +220,7 @@ func InitConf() {util.UseSingleLineSave = Conf.FileTree.UseSingleLineSaveutil.CurrentCloudRegion = Conf.CloudRegion+ Conf.System.DisabledFeatures = util.DisabledFeaturesif nil == Conf.Tag {Conf.Tag = conf.NewTag()diff --git a/kernel/util/runtime.go b/kernel/util/runtime.goindex 4182d70420..387b3d4649 100644--- a/kernel/util/runtime.go+++ b/kernel/util/runtime.go@@ -38,6 +38,13 @@ import ("github.com/siyuan-note/logging")+var DisabledFeatures []string++func DisableFeature(feature string) {+ DisabledFeatures = append(DisabledFeatures, feature)+ DisabledFeatures = gulu.Str.RemoveDuplicatedElem(DisabledFeatures)+}+// UseSingleLineSave 是否使用单行保存 .sy 和数据库 .json 文件。var UseSingleLineSave = true@@ -88,6 +95,9 @@ func logBootInfo() {" * database [ver=%s]\n"+" * workspace directory [%s]",Ver, runtime.GOARCH, plat, os.Getpid(), Mode, WorkingDir, ReadOnly, Container, DatabaseVer, WorkspaceDir)+ if 0 < len(DisabledFeatures) {+ logging.LogInfof("disabled features [%s]", strings.Join(DisabledFeatures, ", "))+ }}func RandomSleep(minMills, maxMills int) {