mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-17 23:20:13 +01:00
🎨 记录操作系统平台
This commit is contained in:
parent
d316e4abc3
commit
235d940cad
7 changed files with 72 additions and 5 deletions
1
app/src/types/index.d.ts
vendored
1
app/src/types/index.d.ts
vendored
|
|
@ -424,6 +424,7 @@ declare interface IConfig {
|
||||||
container: "std" | "android" | "docker" | "ios"
|
container: "std" | "android" | "docker" | "ios"
|
||||||
isMicrosoftStore: boolean
|
isMicrosoftStore: boolean
|
||||||
os: "windows" | "linux" | "darwin"
|
os: "windows" | "linux" | "darwin"
|
||||||
|
osPlatform: string
|
||||||
homeDir: string
|
homeDir: string
|
||||||
xanadu: boolean
|
xanadu: boolean
|
||||||
udanax: boolean
|
udanax: boolean
|
||||||
|
|
|
||||||
|
|
@ -23,10 +23,10 @@ const loadThirdIcon = (iconURL: string, data: IAppearance) => {
|
||||||
|
|
||||||
export const loadAssets = (data: IAppearance) => {
|
export const loadAssets = (data: IAppearance) => {
|
||||||
const htmlElement = document.getElementsByTagName("html")[0];
|
const htmlElement = document.getElementsByTagName("html")[0];
|
||||||
htmlElement.setAttribute("lang",window.siyuan.config.appearance.lang);
|
htmlElement.setAttribute("lang", window.siyuan.config.appearance.lang);
|
||||||
htmlElement.setAttribute("data-theme-mode",getThemeMode());
|
htmlElement.setAttribute("data-theme-mode", getThemeMode());
|
||||||
htmlElement.setAttribute("data-light-theme",window.siyuan.config.appearance.themeLight);
|
htmlElement.setAttribute("data-light-theme", window.siyuan.config.appearance.themeLight);
|
||||||
htmlElement.setAttribute("data-dark-theme",window.siyuan.config.appearance.themeDark);
|
htmlElement.setAttribute("data-dark-theme", window.siyuan.config.appearance.themeDark);
|
||||||
const OSTheme = window.matchMedia("(prefers-color-scheme: dark)").matches ? "dark" : "light";
|
const OSTheme = window.matchMedia("(prefers-color-scheme: dark)").matches ? "dark" : "light";
|
||||||
if (window.siyuan.config.appearance.modeOS && (
|
if (window.siyuan.config.appearance.modeOS && (
|
||||||
(window.siyuan.config.appearance.mode === 1 && OSTheme === "light") ||
|
(window.siyuan.config.appearance.mode === 1 && OSTheme === "light") ||
|
||||||
|
|
@ -172,6 +172,7 @@ export const addGA = () => {
|
||||||
version: Constants.SIYUAN_VERSION,
|
version: Constants.SIYUAN_VERSION,
|
||||||
container: window.siyuan.config.system.container,
|
container: window.siyuan.config.system.container,
|
||||||
os: window.siyuan.config.system.os,
|
os: window.siyuan.config.system.os,
|
||||||
|
osPlatform: window.siyuan.config.system.osPlatform,
|
||||||
isLoggedIn: false,
|
isLoggedIn: false,
|
||||||
subscriptionStatus: -1,
|
subscriptionStatus: -1,
|
||||||
subscriptionPlan: -1,
|
subscriptionPlan: -1,
|
||||||
|
|
|
||||||
|
|
@ -24,6 +24,7 @@ type System struct {
|
||||||
ID string `json:"id"`
|
ID string `json:"id"`
|
||||||
KernelVersion string `json:"kernelVersion"`
|
KernelVersion string `json:"kernelVersion"`
|
||||||
OS string `json:"os"`
|
OS string `json:"os"`
|
||||||
|
OSPlatform string `json:"osPlatform"`
|
||||||
Container string `json:"container"` // docker, android, ios, std
|
Container string `json:"container"` // docker, android, ios, std
|
||||||
IsMicrosoftStore bool `json:"isMicrosoftStore"`
|
IsMicrosoftStore bool `json:"isMicrosoftStore"`
|
||||||
IsInsider bool `json:"isInsider"`
|
IsInsider bool `json:"isInsider"`
|
||||||
|
|
|
||||||
|
|
@ -236,6 +236,7 @@ func InitConf() {
|
||||||
logging.LogInfof("using Microsoft Store edition")
|
logging.LogInfof("using Microsoft Store edition")
|
||||||
}
|
}
|
||||||
Conf.System.OS = runtime.GOOS
|
Conf.System.OS = runtime.GOOS
|
||||||
|
Conf.System.OSPlatform = util.GetOSPlatform()
|
||||||
Conf.Newbie = util.IsNewbie
|
Conf.Newbie = util.IsNewbie
|
||||||
|
|
||||||
if "" != Conf.UserData {
|
if "" != Conf.UserData {
|
||||||
|
|
|
||||||
33
kernel/util/os.go
Normal file
33
kernel/util/os.go
Normal file
|
|
@ -0,0 +1,33 @@
|
||||||
|
// SiYuan - Build Your Eternal Digital Garden
|
||||||
|
// Copyright (c) 2020-present, b3log.org
|
||||||
|
//
|
||||||
|
// This program is free software: you can redistribute it and/or modify
|
||||||
|
// it under the terms of the GNU Affero General Public License as published by
|
||||||
|
// the Free Software Foundation, either version 3 of the License, or
|
||||||
|
// (at your option) any later version.
|
||||||
|
//
|
||||||
|
// This program is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
// GNU Affero General Public License for more details.
|
||||||
|
//
|
||||||
|
// You should have received a copy of the GNU Affero General Public License
|
||||||
|
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
//go:build !ios && !android
|
||||||
|
|
||||||
|
package util
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/shirou/gopsutil/v3/host"
|
||||||
|
"github.com/siyuan-note/logging"
|
||||||
|
)
|
||||||
|
|
||||||
|
func GetOSPlatform() (ret string) {
|
||||||
|
ret, _, _, err := host.PlatformInformation()
|
||||||
|
if nil != err {
|
||||||
|
logging.LogWarnf("get os platform failed: %s", err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
29
kernel/util/os_mobile.go
Normal file
29
kernel/util/os_mobile.go
Normal file
|
|
@ -0,0 +1,29 @@
|
||||||
|
// SiYuan - Build Your Eternal Digital Garden
|
||||||
|
// Copyright (c) 2020-present, b3log.org
|
||||||
|
//
|
||||||
|
// This program is free software: you can redistribute it and/or modify
|
||||||
|
// it under the terms of the GNU Affero General Public License as published by
|
||||||
|
// the Free Software Foundation, either version 3 of the License, or
|
||||||
|
// (at your option) any later version.
|
||||||
|
//
|
||||||
|
// This program is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
// GNU Affero General Public License for more details.
|
||||||
|
//
|
||||||
|
// You should have received a copy of the GNU Affero General Public License
|
||||||
|
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
//go:build ios || android
|
||||||
|
|
||||||
|
package util
|
||||||
|
|
||||||
|
func GetOSPlatform() (ret string) {
|
||||||
|
if ContainerIOS == Container {
|
||||||
|
return "iOS"
|
||||||
|
}
|
||||||
|
if ContainerAndroid == Container {
|
||||||
|
return "Android"
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
@ -49,6 +49,7 @@ func logBootInfo() {
|
||||||
logging.LogInfof("kernel is booting:\n"+
|
logging.LogInfof("kernel is booting:\n"+
|
||||||
" * ver [%s]\n"+
|
" * ver [%s]\n"+
|
||||||
" * arch [%s]\n"+
|
" * arch [%s]\n"+
|
||||||
|
" * os [%s] "+
|
||||||
" * pid [%d]\n"+
|
" * pid [%d]\n"+
|
||||||
" * runtime mode [%s]\n"+
|
" * runtime mode [%s]\n"+
|
||||||
" * working directory [%s]\n"+
|
" * working directory [%s]\n"+
|
||||||
|
|
@ -56,7 +57,7 @@ func logBootInfo() {
|
||||||
" * container [%s]\n"+
|
" * container [%s]\n"+
|
||||||
" * database [ver=%s]\n"+
|
" * database [ver=%s]\n"+
|
||||||
" * workspace directory [%s]",
|
" * workspace directory [%s]",
|
||||||
Ver, runtime.GOARCH, os.Getpid(), Mode, WorkingDir, ReadOnly, Container, DatabaseVer, WorkspaceDir)
|
Ver, runtime.GOARCH, GetOSPlatform(), os.Getpid(), Mode, WorkingDir, ReadOnly, Container, DatabaseVer, WorkspaceDir)
|
||||||
}
|
}
|
||||||
|
|
||||||
func IsMutexLocked(m *sync.Mutex) bool {
|
func IsMutexLocked(m *sync.Mutex) bool {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue