🎨 Apps in Chinese mainland app stores no longer provide AI access settings https://github.com/siyuan-note/siyuan/issues/13051

This commit is contained in:
Daniel 2024-11-07 16:51:59 +08:00
parent a134f0adb4
commit e585263970
No known key found for this signature in database
GPG key ID: 86211BA83DF03017
7 changed files with 28 additions and 2 deletions

View file

@ -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/13051
aiHTML = "";
}

View file

@ -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;
};

View file

@ -1521,6 +1521,10 @@ declare namespace Config {
* The absolute path of the workspace directory
*/
workspaceDir: string;
/**
* Disabled features.
*/
disabledFeatures: string[];
}
/**

View file

@ -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 {

View file

@ -114,3 +114,7 @@ func SetTimezone(container, appDir, timezoneID string) {
}
time.Local = z
}
func DisableFeature(feature string) {
util.DisableFeature(feature)
}

View file

@ -220,6 +220,7 @@ func InitConf() {
util.UseSingleLineSave = Conf.FileTree.UseSingleLineSave
util.CurrentCloudRegion = Conf.CloudRegion
Conf.System.DisabledFeatures = util.DisabledFeatures
if nil == Conf.Tag {
Conf.Tag = conf.NewTag()

View file

@ -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) {