refactor: 统一将 Sidecar 模式中的 Server 更名为 App

- 将构建输出文件名从 `server-` 更改为 `app-` 以匹配新的命名规范。
- 将 Sidecar 模式中的 Server 统一更名为 App,以准确反映其作为主业务逻辑载体的角色,并同步更新相关配置、文件命名、日志信息及代码注释。
- 更新允许执行的二进制文件为应用程序二进制文件。
- 将 Sidecar Server 相关的术语和日志信息统一更新为 Sidecar App,以准确反映实际启动的应用程序名称。
- 将外部二进制文件路径从 server 更改为 app
This commit is contained in:
2026-01-18 16:33:48 +08:00
parent 0df0bcb855
commit 4035fcb202
5 changed files with 26 additions and 26 deletions

View File

@@ -7,7 +7,7 @@ use tauri_plugin_shell::ShellExt;
// ===== 配置常量 =====
/// Sidecar Server 启动超时时间(秒)
/// Sidecar App 启动超时时间(秒)
const STARTUP_TIMEOUT_SECS: u64 = 5;
/// 默认起始端口
@@ -73,7 +73,7 @@ pub fn spawn_sidecar(app_handle: tauri::AppHandle) {
// 生产模式:启动 sidecar 二进制
tauri::async_runtime::spawn(async move {
println!("🚀 生产模式:启动 Sidecar Server");
println!("🚀 生产模式:启动 Sidecar App");
// 查找可用端口
let port = find_available_port(DEFAULT_PORT).await;
@@ -82,8 +82,8 @@ pub fn spawn_sidecar(app_handle: tauri::AppHandle) {
// 启动 sidecar
let sidecar = app_handle
.shell()
.sidecar("server")
.expect("无法找到 server")
.sidecar("app")
.expect("无法找到 app")
.env("PORT", port.to_string());
let (mut rx, child) = sidecar.spawn().expect("启动 sidecar 失败");
@@ -96,17 +96,17 @@ pub fn spawn_sidecar(app_handle: tauri::AppHandle) {
// 监听 stdout等待服务器就绪信号
let start_time = std::time::Instant::now();
let timeout = Duration::from_secs(STARTUP_TIMEOUT_SECS);
let mut server_ready = false;
let mut app_ready = false;
while let Some(event) = rx.recv().await {
if let CommandEvent::Stdout(line) = event {
let output = String::from_utf8_lossy(&line);
println!("Server: {}", output);
println!("App: {}", output);
// 检测服务器启动成功的标志
// 检测 App 启动成功的标志
if output.contains("Listening on:") || output.contains("localhost") {
server_ready = true;
println!("Server 启动成功!");
app_ready = true;
println!("App 启动成功!");
// 创建主窗口
let url = format!("http://localhost:{}", port);
@@ -128,15 +128,15 @@ pub fn spawn_sidecar(app_handle: tauri::AppHandle) {
// 超时检查
if start_time.elapsed() > timeout {
eprintln!(
"✗ 启动超时: Server 未能在 {} 秒内启动",
"✗ 启动超时: App 未能在 {} 秒内启动",
STARTUP_TIMEOUT_SECS
);
break;
}
}
if !server_ready {
eprintln!("Server 启动失败");
if !app_ready {
eprintln!("App 启动失败");
std::process::exit(1);
}
});