11
This commit is contained in:
@@ -4,7 +4,8 @@
|
|||||||
# Tauri Rust 请求后端基址(拉取 appConfig、脚本等)
|
# Tauri Rust 请求后端基址(拉取 appConfig、脚本等)
|
||||||
# AICLIENT_API_BASE=http://127.0.0.1:8001
|
# AICLIENT_API_BASE=http://127.0.0.1:8001
|
||||||
|
|
||||||
|
# ffmpeg(抖音流水线提音频必需):放入 src-tauri/binaries/ffmpeg.exe 或设置绝对路径
|
||||||
|
# AICLIENT_FFMPEG_PATH=C:/path/to/ffmpeg.exe
|
||||||
|
|
||||||
# 应用配置在 pythonbackend 的 MySQL 表 desktop_configs(name/value),
|
# 应用配置在 pythonbackend 的 MySQL 表 desktop_configs(name/value),
|
||||||
# 登录后自动同步;Node 流水线通过环境变量 AICLIENT_CFG_<NAME> 读取。
|
# 登录后自动同步;Node 流水线通过环境变量 AICLIENT_CFG_<NAME> 读取。
|
||||||
|
|||||||
@@ -65,13 +65,18 @@ pub async fn request_json(
|
|||||||
|
|
||||||
let res = req.send().await.map_err(|e| {
|
let res = req.send().await.map_err(|e| {
|
||||||
if e.is_connect() {
|
if e.is_connect() {
|
||||||
|
println!("无法连接服务器,请确认后端已启动");
|
||||||
"无法连接服务器,请确认后端已启动".to_string()
|
"无法连接服务器,请确认后端已启动".to_string()
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
println!("e: {}", e);
|
||||||
e.to_string()
|
e.to_string()
|
||||||
|
|
||||||
}
|
}
|
||||||
})?;
|
})?;
|
||||||
|
|
||||||
let status = res.status().as_u16();
|
let status = res.status().as_u16();
|
||||||
|
println!("status: {}", status);
|
||||||
let encrypted = res
|
let encrypted = res
|
||||||
.headers()
|
.headers()
|
||||||
.get(ENCRYPTED_HEADER)
|
.get(ENCRYPTED_HEADER)
|
||||||
|
|||||||
@@ -211,6 +211,7 @@ impl AppConfig {
|
|||||||
self.clear_server().await;
|
self.clear_server().await;
|
||||||
return Ok(());
|
return Ok(());
|
||||||
}
|
}
|
||||||
|
|
||||||
match fetch_from_server(token).await {
|
match fetch_from_server(token).await {
|
||||||
Ok(map) => {
|
Ok(map) => {
|
||||||
let mut g = self.inner.write().await;
|
let mut g = self.inner.write().await;
|
||||||
@@ -243,10 +244,15 @@ async fn fetch_from_server(token: &str) -> Result<HashMap<String, String>, AppCo
|
|||||||
format!("Bearer {}", token.trim()),
|
format!("Bearer {}", token.trim()),
|
||||||
);
|
);
|
||||||
|
|
||||||
let (status, v) = crate::api_client::request_json("GET", "/appConfig", None, headers)
|
let (status, v) = match crate::api_client::request_json("GET", "/appConfig", None, headers).await
|
||||||
.await
|
{
|
||||||
.map_err(|e| AppConfigError::Fetch(e))?;
|
Ok(pair) => pair,
|
||||||
|
Err(e) => {
|
||||||
|
log::warn!(target: "app_config", "GET /appConfig 请求失败(未拿到响应体): {e}");
|
||||||
|
println!("GET /appConfig 请求失败(未拿到响应体): {e}");
|
||||||
|
return Err(AppConfigError::Fetch(e));
|
||||||
|
}
|
||||||
|
};
|
||||||
if status == 401 {
|
if status == 401 {
|
||||||
return Err(AppConfigError::Fetch("未认证或令牌已失效".into()));
|
return Err(AppConfigError::Fetch("未认证或令牌已失效".into()));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -43,6 +43,11 @@ pub fn locate_ffmpeg() -> Option<PathBuf> {
|
|||||||
if flat.exists() {
|
if flat.exists() {
|
||||||
return Some(flat);
|
return Some(flat);
|
||||||
}
|
}
|
||||||
|
// target/debug/tauri-app.exe → src-tauri/binaries/ffmpeg.exe
|
||||||
|
let dev_bin = dir.join("..").join("..").join("binaries").join(exe_name());
|
||||||
|
if dev_bin.exists() {
|
||||||
|
return Some(dev_bin);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
let dev = PathBuf::from("src-tauri/binaries").join(exe_name());
|
let dev = PathBuf::from("src-tauri/binaries").join(exe_name());
|
||||||
|
|||||||
@@ -364,6 +364,11 @@ async fn run_script_bundle(
|
|||||||
for (key, value) in config_env {
|
for (key, value) in config_env {
|
||||||
cmd.env(key, value);
|
cmd.env(key, value);
|
||||||
}
|
}
|
||||||
|
if let Some(ffmpeg_path) = crate::ffmpeg::locate_ffmpeg() {
|
||||||
|
if ffmpeg_path.exists() {
|
||||||
|
cmd.env("AICLIENT_FFMPEG_PATH", ffmpeg_path);
|
||||||
|
}
|
||||||
|
}
|
||||||
let mut child = cmd.spawn()?;
|
let mut child = cmd.spawn()?;
|
||||||
|
|
||||||
// 把 params JSON 灌进 stdin
|
// 把 params JSON 灌进 stdin
|
||||||
|
|||||||
@@ -48,6 +48,8 @@ async function loadAll() {
|
|||||||
invoke("list_local_app_config"),
|
invoke("list_local_app_config"),
|
||||||
invoke("get_app_config_detail"),
|
invoke("get_app_config_detail"),
|
||||||
]);
|
]);
|
||||||
|
// console.log("local",local)
|
||||||
|
// console.log("detail",detail)
|
||||||
localItems.value = Array.isArray(local) ? local : [];
|
localItems.value = Array.isArray(local) ? local : [];
|
||||||
mergedDetail.value = Array.isArray(detail) ? detail : [];
|
mergedDetail.value = Array.isArray(detail) ? detail : [];
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
|
|||||||
Reference in New Issue
Block a user