From e4ddd99863ac3e294e205bc5b4301a5df2d7a904 Mon Sep 17 00:00:00 2001 From: Liang Ding Date: Thu, 8 Sep 2022 10:29:27 +0800 Subject: [PATCH] =?UTF-8?q?:art:=20=E6=A1=8C=E9=9D=A2=E7=AB=AF=E8=87=AA?= =?UTF-8?q?=E5=8A=A8=E4=B8=8B=E8=BD=BD=E6=9B=B4=E6=96=B0=E5=AE=89=E8=A3=85?= =?UTF-8?q?=E5=8C=85=20https://github.com/siyuan-note/siyuan/issues/5837?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/config/about.ts | 2 +- app/src/types/index.d.ts | 1 + kernel/conf/system.go | 11 ++++++----- kernel/model/conf.go | 3 ++- kernel/model/updater.go | 4 ++-- kernel/util/working.go | 6 +++++- scripts/win-build.bat | 2 +- 7 files changed, 18 insertions(+), 11 deletions(-) diff --git a/app/src/config/about.ts b/app/src/config/about.ts index 29757e68d..4c53dc984 100644 --- a/app/src/config/about.ts +++ b/app/src/config/about.ts @@ -125,7 +125,7 @@ export const about = { ${window.siyuan.languages.checkUpdate} -
+
${window.siyuan.languages.autoDownloadUpdatePkg}
${window.siyuan.languages.autoDownloadUpdatePkgTip}
diff --git a/app/src/types/index.d.ts b/app/src/types/index.d.ts index 46579cd3d..5502ba73f 100644 --- a/app/src/types/index.d.ts +++ b/app/src/types/index.d.ts @@ -299,6 +299,7 @@ declare interface IConfig { confDir: string dataDir: string container: "std" | "android" | "docker" | "ios" + isMicrosoftStore: boolean os: "windows" | "linux" | "darwin" homeDir: string xanadu: boolean diff --git a/kernel/conf/system.go b/kernel/conf/system.go index 9e47bf5b4..1a6dc85e9 100644 --- a/kernel/conf/system.go +++ b/kernel/conf/system.go @@ -21,11 +21,12 @@ import ( ) type System struct { - ID string `json:"id"` - KernelVersion string `json:"kernelVersion"` - OS string `json:"os"` - Container string `json:"container"` // docker, android, ios, std - IsInsider bool `json:"isInsider"` + ID string `json:"id"` + KernelVersion string `json:"kernelVersion"` + OS string `json:"os"` + Container string `json:"container"` // docker, android, ios, std + IsMicrosoftStore bool `json:"isMicrosoftStore"` + IsInsider bool `json:"isInsider"` HomeDir string `json:"homeDir"` WorkspaceDir string `json:"workspaceDir"` diff --git a/kernel/model/conf.go b/kernel/model/conf.go index c608eec9e..9b6813a29 100644 --- a/kernel/model/conf.go +++ b/kernel/model/conf.go @@ -222,6 +222,7 @@ func InitConf() { Conf.System.WorkspaceDir = util.WorkspaceDir Conf.System.DataDir = util.DataDir Conf.System.Container = util.Container + Conf.System.IsMicrosoftStore = util.ISMicrosoftStore Conf.System.OS = runtime.GOOS Conf.Newbie = util.IsNewbie @@ -375,7 +376,7 @@ func Close(force bool, execInstallPkg int) (exitCode int) { //}) newVerInstallPkgPath := "" - if Conf.System.DownloadInstallPkg && 0 == execInstallPkg { + if Conf.System.DownloadInstallPkg && !util.ISMicrosoftStore && 0 == execInstallPkg { newVerInstallPkgPath = GetNewVerInstallPkgPath() if "" != newVerInstallPkgPath { exitCode = 2 diff --git a/kernel/model/updater.go b/kernel/model/updater.go index 3790b9141..c215830cb 100644 --- a/kernel/model/updater.go +++ b/kernel/model/updater.go @@ -35,7 +35,7 @@ import ( ) func GetNewVerInstallPkgPath() string { - if !Conf.System.DownloadInstallPkg { + if !Conf.System.DownloadInstallPkg || util.ISMicrosoftStore { return "" } @@ -58,7 +58,7 @@ var checkDownloadInstallPkgLock = sync.Mutex{} func checkDownloadInstallPkg() { defer logging.Recover() - if !Conf.System.DownloadInstallPkg { + if !Conf.System.DownloadInstallPkg || util.ISMicrosoftStore { return } diff --git a/kernel/util/working.go b/kernel/util/working.go index 08fcaa611..8ba204134 100644 --- a/kernel/util/working.go +++ b/kernel/util/working.go @@ -83,6 +83,9 @@ func Boot() { Container = ContainerDocker } + msStoreFilePath := filepath.Join(WorkingDir, "ms-store") + ISMicrosoftStore = gulu.File.IsExist(msStoreFilePath) + UserAgent = UserAgent + " " + Container httpclient.SetUserAgent(UserAgent) @@ -276,7 +279,8 @@ var ( AccessAuthCode string Lang = "" - Container string // docker, android, ios, std + Container string // docker, android, ios, std + ISMicrosoftStore bool // 桌面端是否是微软商店版 ) const ( diff --git a/scripts/win-build.bat b/scripts/win-build.bat index 49e42d2a6..069253efe 100644 --- a/scripts/win-build.bat +++ b/scripts/win-build.bat @@ -35,5 +35,5 @@ call pnpm run dist-win32 cd .. echo 'Building Appx' -echo . > app\build\win-unpacked\resources\ms-store +cd . > app\build\win-unpacked\resources\ms-store electron-windows-store --input-directory app\build\win-unpacked --output-directory app\build\ --package-version 1.0.0.0 --package-name SiYuan --manifest app\appx\AppxManifest.xml --assets app\appx\assets\ --make-pri true