From 341fd63bf5ad5bb3e0b9982f4eb6284ba45fad5d Mon Sep 17 00:00:00 2001 From: DIYgod Date: Wed, 16 Jul 2025 18:11:12 +0800 Subject: [PATCH] fix(desktop): microsoft store build check - Introduce MICROSOFT_STORE_BUILD constant to determine if the app is running from the Microsoft Store - Update appUpdaterConfig to conditionally enable core updates based on the new constant - Modify header creation logic to use MICROSOFT_STORE_BUILD for Windows platform detection This change enhances the application's compatibility with Microsoft Store by ensuring proper update handling and header configuration. --- apps/desktop/layer/main/src/updater/configs.ts | 4 ++-- packages/internal/shared/src/constants.ts | 6 ++++++ packages/internal/utils/src/headers.ts | 4 ++-- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/apps/desktop/layer/main/src/updater/configs.ts b/apps/desktop/layer/main/src/updater/configs.ts index 9432099d3..b55ea71bc 100644 --- a/apps/desktop/layer/main/src/updater/configs.ts +++ b/apps/desktop/layer/main/src/updater/configs.ts @@ -1,4 +1,4 @@ -import { DEV, MODE, ModeEnum } from "@follow/shared/constants" +import { DEV, MICROSOFT_STORE_BUILD, MODE, ModeEnum } from "@follow/shared/constants" import path from "pathe" import { isWindows } from "../env" @@ -8,7 +8,7 @@ export const appUpdaterConfig = { enableRenderHotUpdate: !DEV && MODE !== ModeEnum.staging, enableCoreUpdate: !process.mas && - !process.windowsStore && + !MICROSOFT_STORE_BUILD && // Disable core update if platfrom is windows and application is't executing from default installion path. // If the process is not executed from the default installation path, // it is usually managed through a package manager like Scoop. diff --git a/packages/internal/shared/src/constants.ts b/packages/internal/shared/src/constants.ts index b2c0768df..2a9325916 100644 --- a/packages/internal/shared/src/constants.ts +++ b/packages/internal/shared/src/constants.ts @@ -37,3 +37,9 @@ declare const ELECTRON: boolean */ export const ELECTRON_BUILD = !!ELECTRON export const WEB_BUILD = !ELECTRON + +export const MICROSOFT_STORE_BUILD = + typeof process !== "undefined" + ? process.platform === "win32" && + (process.windowsStore || process.execPath.startsWith("C:\\Program Files\\WindowsApps")) + : false diff --git a/packages/internal/utils/src/headers.ts b/packages/internal/utils/src/headers.ts index 8e86a4a7b..e786fc650 100644 --- a/packages/internal/utils/src/headers.ts +++ b/packages/internal/utils/src/headers.ts @@ -1,4 +1,4 @@ -import { DEV, WEB_BUILD } from "@follow/shared/constants" +import { DEV, MICROSOFT_STORE_BUILD, WEB_BUILD } from "@follow/shared/constants" import { imageRefererMatches } from "./img-proxy" @@ -81,7 +81,7 @@ export const createDesktopAPIHeaders = ({ version }: { version: string }) => { break } case "win32": { - if (process.windowsStore) { + if (MICROSOFT_STORE_BUILD) { platform = DesktopPlatform.DesktopWindowsMS } else { platform = DesktopPlatform.DesktopWindowsEXE