diff --git a/.env.development b/.env.development index 2c0416c..d72020a 100644 --- a/.env.development +++ b/.env.development @@ -1,5 +1,6 @@ VITE_PLATFORM=DESKTOP -VITE_PROTOCOL=oxygen-desktop +VITE_DESKTOP_PROTOCOL=oxygen-desktop +VITE_APP_PROTOCOL=oxygen-app VITE_UI_URL=${DEV_UI_URL} VITE_API_URL=${DEV_API_URL} VITE_API_TOKEN_URL=${VITE_API_URL}/token diff --git a/.env.production b/.env.production index da3f3f3..679f473 100644 --- a/.env.production +++ b/.env.production @@ -1,5 +1,6 @@ VITE_PLATFORM=DESKTOP -VITE_PROTOCOL=oxygen-desktop +VITE_DESKTOP_PROTOCOL=oxygen-desktop +VITE_APP_PROTOCOL=oxygen-app VITE_UI_URL=${PRODUCT_UI_URL} VITE_API_URL=${PRODUCT_API_URL} VITE_API_TOKEN_URL=${VITE_API_URL}/token diff --git a/.env.testing b/.env.testing index d6afba7..9afafb8 100644 --- a/.env.testing +++ b/.env.testing @@ -1,6 +1,7 @@ NODE_ENV=development VITE_PLATFORM=DESKTOP -VITE_PROTOCOL=oxygen-desktop +VITE_DESKTOP_PROTOCOL=oxygen-desktop +VITE_APP_PROTOCOL=oxygen-app VITE_UI_URL=${TEST_UI_URL} VITE_API_URL=${TEST_API_URL} VITE_API_TOKEN_URL=${VITE_API_URL}/token diff --git a/src/main/global.d.ts b/src/main/global.d.ts index f698dd2..b5a29c7 100644 --- a/src/main/global.d.ts +++ b/src/main/global.d.ts @@ -2,7 +2,8 @@ type Platform = 'WEB' | 'DESKTOP' | 'ANDROID' interface ImportMetaEnv { readonly VITE_PLATFORM: Platform - readonly VITE_PROTOCOL: string + readonly VITE_DESKTOP_PROTOCOL: string + readonly VITE_APP_PROTOCOL: string readonly VITE_UI_URL: string readonly VITE_API_URL: string readonly VITE_API_TOKEN_URL: string diff --git a/src/main/index.ts b/src/main/index.ts index ff80db5..af871d8 100644 --- a/src/main/index.ts +++ b/src/main/index.ts @@ -18,11 +18,11 @@ if (!app.isPackaged) { args.push(path.resolve(process.argv[1])) } args.push('--') -app.setAsDefaultProtocolClient(import.meta.env.VITE_PROTOCOL, process.execPath, args) -// app.removeAsDefaultProtocolClient(import.meta.env.VITE_PROTOCOL, process.execPath, args) +app.setAsDefaultProtocolClient(import.meta.env.VITE_DESKTOP_PROTOCOL, process.execPath, args) +// app.removeAsDefaultProtocolClient(import.meta.env.VITE_DESKTOP_PROTOCOL, process.execPath, args) const handleArgv = (argv: string[]) => { - const prefix = `${import.meta.env.VITE_PROTOCOL}:` + const prefix = `${import.meta.env.VITE_DESKTOP_PROTOCOL}:` const offset = app.isPackaged ? 1 : 2 const url = argv.find((arg, index) => index >= offset && arg.startsWith(prefix)) if (url) { diff --git a/src/renderer/src/components/tools/StoreCard.tsx b/src/renderer/src/components/tools/StoreCard.tsx index eb1fcaf..12cf00e 100644 --- a/src/renderer/src/components/tools/StoreCard.tsx +++ b/src/renderer/src/components/tools/StoreCard.tsx @@ -235,7 +235,7 @@ const StoreCard = ({ if (!checkDesktop()) { void message.loading({ content: '启动桌面端中……', key: 'LOADING', duration: 0 }) protocolCheck( - `oxygen://openurl/view/${author.username}/${toolId}`, + `${import.meta.env.VITE_DESKTOP_PROTOCOL}://openurl/view/${author.username}/${toolId}`, () => { void message.warning('打开失败,此应用需要桌面端环境,请安装桌面端后重试') void message.destroy('LOADING') diff --git a/src/renderer/src/global.d.ts b/src/renderer/src/global.d.ts index 27ebd04..02256df 100644 --- a/src/renderer/src/global.d.ts +++ b/src/renderer/src/global.d.ts @@ -6,7 +6,8 @@ type Platform = 'WEB' | 'DESKTOP' | 'ANDROID' interface ImportMetaEnv { readonly VITE_PLATFORM: Platform - readonly VITE_PROTOCOL: string + readonly VITE_DESKTOP_PROTOCOL: string + readonly VITE_APP_PROTOCOL: string readonly VITE_UI_URL: string readonly VITE_API_URL: string readonly VITE_API_TOKEN_URL: string diff --git a/src/renderer/src/util/navigation.ts b/src/renderer/src/util/navigation.ts index 79ce25b..0290cae 100644 --- a/src/renderer/src/util/navigation.ts +++ b/src/renderer/src/util/navigation.ts @@ -153,4 +153,4 @@ export const getViewPath = ( } export const getAndroidUrl = (username: string, toolId: string) => - `oxygen://opentool/${username}/${toolId}` + `${import.meta.env.VITE_APP_PROTOCOL}://opentool/${username}/${toolId}`