This commit is contained in:
949036910@qq.com
2026-05-27 22:09:08 +08:00
parent 2ed1d98f6c
commit 3641422037
3 changed files with 11 additions and 11 deletions

View File

@@ -32,9 +32,17 @@ struct Inner {
pub struct AppConfig {
inner: Arc<RwLock<Inner>>,
}
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`。

View File

@@ -43,9 +43,7 @@ impl From<rquickjs::Error> 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<String, JsError> {
let q = urlencoding::encode(script_name);

View File

@@ -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<String, NodeError> {
let q = urlencoding::encode(script_name);