mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-09-22 08:30:42 +02:00
🎨 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:
parent
a134f0adb4
commit
e585263970
7 changed files with 28 additions and 2 deletions
|
@ -16,7 +16,7 @@ import {initAbout} from "../settings/about";
|
||||||
import {getRecentDocs} from "./getRecentDocs";
|
import {getRecentDocs} from "./getRecentDocs";
|
||||||
import {initEditor} from "../settings/editor";
|
import {initEditor} from "../settings/editor";
|
||||||
import {App} from "../../index";
|
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 {newFile} from "../../util/newFile";
|
||||||
import {afterLoadPlugin} from "../../plugin/loader";
|
import {afterLoadPlugin} from "../../plugin/loader";
|
||||||
import {commandPanel} from "../../boot/globalEvent/command/panel";
|
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">
|
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>
|
<svg class="b3-menu__icon"><use xlink:href="#iconSparkles"></use></svg><span class="b3-menu__label">AI</span>
|
||||||
</div>`;
|
</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
|
// 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 = "";
|
aiHTML = "";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -110,6 +110,10 @@ export const isHuawei = () => {
|
||||||
return window.siyuan.config.system.osPlatform.toLowerCase().indexOf("huawei") > -1;
|
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 = () => {
|
export const isIPhone = () => {
|
||||||
return navigator.userAgent.indexOf("iPhone") > -1;
|
return navigator.userAgent.indexOf("iPhone") > -1;
|
||||||
};
|
};
|
||||||
|
|
4
app/src/types/config.d.ts
vendored
4
app/src/types/config.d.ts
vendored
|
@ -1521,6 +1521,10 @@ declare namespace Config {
|
||||||
* The absolute path of the workspace directory
|
* The absolute path of the workspace directory
|
||||||
*/
|
*/
|
||||||
workspaceDir: string;
|
workspaceDir: string;
|
||||||
|
/**
|
||||||
|
* Disabled features.
|
||||||
|
*/
|
||||||
|
disabledFeatures: string[];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -44,6 +44,8 @@ type System struct {
|
||||||
DownloadInstallPkg bool `json:"downloadInstallPkg"`
|
DownloadInstallPkg bool `json:"downloadInstallPkg"`
|
||||||
AutoLaunch2 int `json:"autoLaunch2"` // 0:不自动启动,1:自动启动,2:自动启动+隐藏主窗口
|
AutoLaunch2 int `json:"autoLaunch2"` // 0:不自动启动,1:自动启动,2:自动启动+隐藏主窗口
|
||||||
LockScreenMode int `json:"lockScreenMode"` // 0:手动,1:手动+跟随系统 https://github.com/siyuan-note/siyuan/issues/9087
|
LockScreenMode int `json:"lockScreenMode"` // 0:手动,1:手动+跟随系统 https://github.com/siyuan-note/siyuan/issues/9087
|
||||||
|
|
||||||
|
DisabledFeatures []string `json:"disabledFeatures"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewSystem() *System {
|
func NewSystem() *System {
|
||||||
|
|
|
@ -114,3 +114,7 @@ func SetTimezone(container, appDir, timezoneID string) {
|
||||||
}
|
}
|
||||||
time.Local = z
|
time.Local = z
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func DisableFeature(feature string) {
|
||||||
|
util.DisableFeature(feature)
|
||||||
|
}
|
||||||
|
|
|
@ -220,6 +220,7 @@ func InitConf() {
|
||||||
util.UseSingleLineSave = Conf.FileTree.UseSingleLineSave
|
util.UseSingleLineSave = Conf.FileTree.UseSingleLineSave
|
||||||
|
|
||||||
util.CurrentCloudRegion = Conf.CloudRegion
|
util.CurrentCloudRegion = Conf.CloudRegion
|
||||||
|
Conf.System.DisabledFeatures = util.DisabledFeatures
|
||||||
|
|
||||||
if nil == Conf.Tag {
|
if nil == Conf.Tag {
|
||||||
Conf.Tag = conf.NewTag()
|
Conf.Tag = conf.NewTag()
|
||||||
|
|
|
@ -38,6 +38,13 @@ import (
|
||||||
"github.com/siyuan-note/logging"
|
"github.com/siyuan-note/logging"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
var DisabledFeatures []string
|
||||||
|
|
||||||
|
func DisableFeature(feature string) {
|
||||||
|
DisabledFeatures = append(DisabledFeatures, feature)
|
||||||
|
DisabledFeatures = gulu.Str.RemoveDuplicatedElem(DisabledFeatures)
|
||||||
|
}
|
||||||
|
|
||||||
// UseSingleLineSave 是否使用单行保存 .sy 和数据库 .json 文件。
|
// UseSingleLineSave 是否使用单行保存 .sy 和数据库 .json 文件。
|
||||||
var UseSingleLineSave = true
|
var UseSingleLineSave = true
|
||||||
|
|
||||||
|
@ -88,6 +95,9 @@ func logBootInfo() {
|
||||||
" * database [ver=%s]\n"+
|
" * database [ver=%s]\n"+
|
||||||
" * workspace directory [%s]",
|
" * workspace directory [%s]",
|
||||||
Ver, runtime.GOARCH, plat, os.Getpid(), Mode, WorkingDir, ReadOnly, Container, DatabaseVer, WorkspaceDir)
|
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) {
|
func RandomSleep(minMills, maxMills int) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue