diff --git a/desktop/.env.development b/desktop/.env.development new file mode 100644 index 0000000..9805f79 --- /dev/null +++ b/desktop/.env.development @@ -0,0 +1,5 @@ +# SaaS 服务地址(开发环境) +VITE_SAAS_URL=http://127.0.0.1:8080 +# Gateway 服务地址(开发环境) +VITE_GATEWAY_HTTP=http://127.0.0.1:50051 +VITE_GATEWAY_WS=ws://127.0.0.1:50051/ws diff --git a/desktop/.env.production b/desktop/.env.production new file mode 100644 index 0000000..0e2649f --- /dev/null +++ b/desktop/.env.production @@ -0,0 +1,5 @@ +# SaaS 服务地址(生产环境) +VITE_SAAS_URL=https://saas.zclaw.com +# Gateway 服务地址(生产环境) +VITE_GATEWAY_HTTP=https://gateway.zclaw.com +VITE_GATEWAY_WS=wss://gateway.zclaw.com/ws diff --git a/desktop/src/components/LoginPage.tsx b/desktop/src/components/LoginPage.tsx index 40c65a4..19ce45e 100644 --- a/desktop/src/components/LoginPage.tsx +++ b/desktop/src/components/LoginPage.tsx @@ -22,12 +22,10 @@ import { } from 'lucide-react'; import { useSaaSStore } from '../store/saasStore'; import { cn } from '../lib/utils'; -import { isTauriRuntime } from '../lib/tauri-gateway'; // === Constants === -const PRODUCTION_SAAS_URL = 'https://saas.zclaw.com'; -const DEV_SAAS_URL = 'http://127.0.0.1:8080'; +const SAAS_URL = import.meta.env.VITE_SAAS_URL || 'http://127.0.0.1:8080'; // === Animation Variants === @@ -86,8 +84,7 @@ function ZclawLogo({ className }: { className?: string }) { /** 根据运行环境自动选择 SaaS 服务器地址 */ function getSaasUrl(): string { - if (import.meta.env.DEV) return DEV_SAAS_URL; - return isTauriRuntime() ? PRODUCTION_SAAS_URL : DEV_SAAS_URL; + return SAAS_URL; } // === Component === diff --git a/desktop/src/components/SaaS/SaaSLogin.tsx b/desktop/src/components/SaaS/SaaSLogin.tsx index e6440b7..0f3412e 100644 --- a/desktop/src/components/SaaS/SaaSLogin.tsx +++ b/desktop/src/components/SaaS/SaaSLogin.tsx @@ -246,7 +246,7 @@ export function SaaSLogin({ onLogin, onLoginWithTotp, onRegister, initialUrl, is type="url" value={serverUrl} onChange={(e) => setServerUrl(e.target.value)} - placeholder="https://saas.zclaw.com" + placeholder={import.meta.env.VITE_SAAS_URL || 'http://127.0.0.1:8080'} className="w-full pl-10 pr-3 py-2 border border-gray-300 rounded-lg text-sm focus:outline-none focus:ring-2 focus:ring-emerald-500/20 focus:border-emerald-500 bg-white text-gray-900" disabled={isLoggingIn} /> diff --git a/desktop/src/lib/saas-client.ts b/desktop/src/lib/saas-client.ts index fa95fa0..a3726b1 100644 --- a/desktop/src/lib/saas-client.ts +++ b/desktop/src/lib/saas-client.ts @@ -508,4 +508,4 @@ export interface SaaSClient { * Global SaaS client singleton. * Initialized with a default URL; the URL and token are updated on login. */ -export const saasClient = new SaaSClient('https://saas.zclaw.com'); +export const saasClient = new SaaSClient(import.meta.env.VITE_SAAS_URL || 'http://127.0.0.1:8080'); diff --git a/desktop/src/store/saasStore.ts b/desktop/src/store/saasStore.ts index dedbc30..411a7dc 100644 --- a/desktop/src/store/saasStore.ts +++ b/desktop/src/store/saasStore.ts @@ -128,9 +128,7 @@ export type SaaSStore = SaaSStateSlice & SaaSActionsSlice; // === Constants === -const DEFAULT_SAAS_URL = import.meta.env.DEV - ? 'http://127.0.0.1:8080' - : 'https://saas.zclaw.com'; +const DEFAULT_SAAS_URL = import.meta.env.VITE_SAAS_URL || 'http://127.0.0.1:8080'; // === Helpers ===