🎨 Data snapshot save device ID, name and OS https://github.com/siyuan-note/siyuan/issues/8094
This commit is contained in:
parent
9f9afdcfd0
commit
051ddf74ae
7 changed files with 26 additions and 5 deletions
|
@ -161,6 +161,9 @@ const renderRepoItem = (response: IWebSocketData, element: Element, type: string
|
|||
hCreated: string,
|
||||
count: number,
|
||||
hSize: string,
|
||||
systemID: string,
|
||||
systemName: string,
|
||||
systemOS: string,
|
||||
tag: string,
|
||||
typesCount: { type: string, count: number }[]
|
||||
}) => {
|
||||
|
@ -178,13 +181,15 @@ const renderRepoItem = (response: IWebSocketData, element: Element, type: string
|
|||
<span class="b3-chip b3-chip--secondary b3-chip--small${item.tag ? "" : " fn__none"}">${item.tag}</span>
|
||||
</div>
|
||||
<div class="b3-list-item__meta">
|
||||
<code class="fn__code">${item.id.substring(0, 7)}</code>
|
||||
<code class="fn__code">${item.id.substring(0, 7)}</code>
|
||||
<span class="fn__space"></span>
|
||||
<span data-type="hCreated">${item.hCreated}</span>
|
||||
<span class="fn__space"></span>
|
||||
${item.hSize}
|
||||
<span class="fn__space"></span>
|
||||
${window.siyuan.languages.fileCount} ${item.count}
|
||||
<span class="fn__space"></span>
|
||||
${item.systemOS}/${item.systemName}
|
||||
</div>
|
||||
${statHTML}`;
|
||||
/// #if MOBILE
|
||||
|
|
|
@ -22,6 +22,7 @@ import (
|
|||
|
||||
type System struct {
|
||||
ID string `json:"id"`
|
||||
Name string `json:"name"`
|
||||
KernelVersion string `json:"kernelVersion"`
|
||||
OS string `json:"os"`
|
||||
OSPlatform string `json:"osPlatform"`
|
||||
|
@ -47,6 +48,7 @@ type System struct {
|
|||
func NewSystem() *System {
|
||||
return &System{
|
||||
ID: util.GetDeviceID(),
|
||||
Name: util.GetDeviceName(),
|
||||
KernelVersion: util.Ver,
|
||||
NetworkProxy: &NetworkProxy{},
|
||||
DownloadInstallPkg: true,
|
||||
|
|
|
@ -44,7 +44,7 @@ require (
|
|||
github.com/radovskyb/watcher v1.0.7
|
||||
github.com/sashabaranov/go-gpt3 v1.4.0
|
||||
github.com/shirou/gopsutil/v3 v3.23.2
|
||||
github.com/siyuan-note/dejavu v0.0.0-20230421144748-43d79a87c9f9
|
||||
github.com/siyuan-note/dejavu v0.0.0-20230424035816-c47703a13fd4
|
||||
github.com/siyuan-note/encryption v0.0.0-20220713091850-5ecd92177b75
|
||||
github.com/siyuan-note/eventbus v0.0.0-20230216103454-41885eac6c2b
|
||||
github.com/siyuan-note/filelock v0.0.0-20230417044524-125ee78b5cc9
|
||||
|
|
|
@ -277,8 +277,10 @@ github.com/shopspring/decimal v1.3.1 h1:2Usl1nmF/WZucqkFZhnfFYxxxu8LG21F6nPQBE5g
|
|||
github.com/shopspring/decimal v1.3.1/go.mod h1:DKyhrW/HYNuLGql+MJL6WCR6knT2jwCFRcu2hWCYk4o=
|
||||
github.com/shurcooL/gofontwoff v0.0.0-20181114050219-180f79e6909d h1:lvCTyBbr36+tqMccdGMwuEU+hjux/zL6xSmf5S9ITaA=
|
||||
github.com/shurcooL/gofontwoff v0.0.0-20181114050219-180f79e6909d/go.mod h1:05UtEgK5zq39gLST6uB0cf3NEHjETfB4Fgr3Gx5R9Vw=
|
||||
github.com/siyuan-note/dejavu v0.0.0-20230421144748-43d79a87c9f9 h1:vOGSTlJpei7tyVOpgwSXVChmf65NHkuL9GvMWPjfPgo=
|
||||
github.com/siyuan-note/dejavu v0.0.0-20230421144748-43d79a87c9f9/go.mod h1:R3PnH4Y9/0TollG4g0tX7jGW7lvhNIEL9hYi5zQ4+sI=
|
||||
github.com/siyuan-note/dejavu v0.0.0-20230424034810-63afce096499 h1:2cAa1Y8GG1f13cyy1g1SLWHty/EYaj02EMza2ql3FTs=
|
||||
github.com/siyuan-note/dejavu v0.0.0-20230424034810-63afce096499/go.mod h1:R3PnH4Y9/0TollG4g0tX7jGW7lvhNIEL9hYi5zQ4+sI=
|
||||
github.com/siyuan-note/dejavu v0.0.0-20230424035816-c47703a13fd4 h1:5hkMgzn1kyrBVK0BQTSh6jrCMrNDBKoJD/tR7U+4Tqc=
|
||||
github.com/siyuan-note/dejavu v0.0.0-20230424035816-c47703a13fd4/go.mod h1:R3PnH4Y9/0TollG4g0tX7jGW7lvhNIEL9hYi5zQ4+sI=
|
||||
github.com/siyuan-note/encryption v0.0.0-20220713091850-5ecd92177b75 h1:Bi7/7f29LW+Fm0cHc0J1NO1cZqyJwljSWVmfOqVZgaE=
|
||||
github.com/siyuan-note/encryption v0.0.0-20220713091850-5ecd92177b75/go.mod h1:H8fyqqAbp9XreANjeSbc72zEdFfKTXYN34tc1TjZwtw=
|
||||
github.com/siyuan-note/eventbus v0.0.0-20230216103454-41885eac6c2b h1:828lTUW2C0uNiolODqoACu7J8sDUzswD4Xo04mUombg=
|
||||
|
|
|
@ -235,8 +235,12 @@ func InitConf() {
|
|||
if "" == Conf.System.ID {
|
||||
Conf.System.ID = util.GetDeviceID()
|
||||
}
|
||||
if "" == Conf.System.Name {
|
||||
Conf.System.Name = util.GetDeviceName()
|
||||
}
|
||||
if util.ContainerStd == util.Container {
|
||||
Conf.System.ID = util.GetDeviceID()
|
||||
Conf.System.Name = util.GetDeviceName()
|
||||
}
|
||||
|
||||
Conf.System.AppDir = util.WorkingDir
|
||||
|
|
|
@ -1401,7 +1401,7 @@ func newRepository() (ret *dejavu.Repo, err error) {
|
|||
|
||||
ignoreLines := getIgnoreLines()
|
||||
ignoreLines = append(ignoreLines, "/.siyuan/conf.json") // 忽略旧版同步配置
|
||||
ret, err = dejavu.NewRepo(util.DataDir, util.RepoDir, util.HistoryDir, util.TempDir, Conf.System.ID, Conf.Repo.Key, ignoreLines, cloudRepo)
|
||||
ret, err = dejavu.NewRepo(util.DataDir, util.RepoDir, util.HistoryDir, util.TempDir, Conf.System.ID, Conf.System.Name, Conf.System.OS, Conf.Repo.Key, ignoreLines, cloudRepo)
|
||||
if nil != err {
|
||||
logging.LogErrorf("init data repo failed: %s", err)
|
||||
return
|
||||
|
|
|
@ -83,6 +83,14 @@ func GetDeviceID() string {
|
|||
return gulu.Rand.String(12)
|
||||
}
|
||||
|
||||
func GetDeviceName() string {
|
||||
ret, err := os.Hostname()
|
||||
if nil != err {
|
||||
return "unknown"
|
||||
}
|
||||
return ret
|
||||
}
|
||||
|
||||
func SetNetworkProxy(proxyURL string) {
|
||||
if err := os.Setenv("HTTPS_PROXY", proxyURL); nil != err {
|
||||
logging.LogErrorf("set env [HTTPS_PROXY] failed: %s", err)
|
||||
|
|
Loading…
Add table
Reference in a new issue