From 364142203799277ae9630cb4070333ca4bb2215d Mon Sep 17 00:00:00 2001 From: "949036910@qq.com" <> Date: Wed, 27 May 2026 22:09:08 +0800 Subject: [PATCH] 1 --- src-tauri/src/app_config.rs | 12 ++++++++++-- src-tauri/src/js_runtime/mod.rs | 4 +--- src-tauri/src/nodejs.rs | 6 ------ 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src-tauri/src/app_config.rs b/src-tauri/src/app_config.rs index 3ab5772..8bd40ea 100644 --- a/src-tauri/src/app_config.rs +++ b/src-tauri/src/app_config.rs @@ -32,9 +32,17 @@ struct Inner { pub struct AppConfig { inner: Arc>, } - +fn is_dev() -> bool { + cfg!(debug_assertions) +} pub fn api_base() -> String { - std::env::var("AICLIENT_API_BASE").unwrap_or_else(|_| "http://127.0.0.1:8001".to_string()) + std::env::var("AICLIENT_API_BASE").unwrap_or_else(|_| { + if is_dev() { + "http://127.0.0.1:8001".to_string() + } else { + "http://81.71.163.140:8001".to_string() + } + }) } /// 将库表 `name` 转为 Node 环境变量名(不含前缀),如 `llm.api_key` → `LLM_API_KEY`。 diff --git a/src-tauri/src/js_runtime/mod.rs b/src-tauri/src/js_runtime/mod.rs index 4529e2a..8db6a84 100644 --- a/src-tauri/src/js_runtime/mod.rs +++ b/src-tauri/src/js_runtime/mod.rs @@ -43,9 +43,7 @@ impl From for JsError { } } -fn api_base() -> String { - std::env::var("AICLIENT_API_BASE").unwrap_or_else(|_| "http://127.0.0.1:8001".to_string()) -} + async fn fetch_script_source(script_name: &str) -> Result { let q = urlencoding::encode(script_name); diff --git a/src-tauri/src/nodejs.rs b/src-tauri/src/nodejs.rs index cd03297..ee62115 100644 --- a/src-tauri/src/nodejs.rs +++ b/src-tauri/src/nodejs.rs @@ -254,12 +254,6 @@ async fn write_script_bundle( Ok((bundle_dir, runner_path)) } -// --------------------------------------------------------------------------- -// 从后端拉脚本源码 -// --------------------------------------------------------------------------- -fn api_base() -> String { - std::env::var("AICLIENT_API_BASE").unwrap_or_else(|_| "http://127.0.0.1:8001".to_string()) -} async fn fetch_node_script_source(script_name: &str) -> Result { let q = urlencoding::encode(script_name);