-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
/
system.go
70 lines (61 loc) · 2.41 KB
/
system.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
// SiYuan - Refactor your thinking
// 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/>.
package conf
import (
"github.com/siyuan-note/siyuan/kernel/util"
)
type System struct {
ID string `json:"id"`
Name string `json:"name"`
KernelVersion string `json:"kernelVersion"`
OS string `json:"os"`
OSPlatform string `json:"osPlatform"`
Container string `json:"container"` // docker, android, ios, std
IsMicrosoftStore bool `json:"isMicrosoftStore"`
IsInsider bool `json:"isInsider"`
HomeDir string `json:"homeDir"`
WorkspaceDir string `json:"workspaceDir"`
AppDir string `json:"appDir"`
ConfDir string `json:"confDir"`
DataDir string `json:"dataDir"`
NetworkServe bool `json:"networkServe"` // 是否开启网络伺服
NetworkProxy *NetworkProxy `json:"networkProxy"`
UploadErrLog bool `json:"uploadErrLog"`
DisableGoogleAnalytics bool `json:"disableGoogleAnalytics"`
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
}
func NewSystem() *System {
return &System{
ID: util.GetDeviceID(),
Name: util.GetDeviceName(),
KernelVersion: util.Ver,
NetworkProxy: &NetworkProxy{},
DownloadInstallPkg: true,
}
}
type NetworkProxy struct {
Scheme string `json:"scheme"`
Host string `json:"host"`
Port string `json:"port"`
}
func (np *NetworkProxy) String() string {
if "" == np.Scheme {
return ""
}
return np.Scheme + "://" + np.Host + ":" + np.Port
}