- 修复循环播放
This commit is contained in:
@@ -3,6 +3,9 @@ mod models;
|
||||
mod server;
|
||||
mod storage;
|
||||
|
||||
use std::io::{Read, Write};
|
||||
use std::time::Duration;
|
||||
|
||||
#[cfg_attr(mobile, tauri::mobile_entry_point)]
|
||||
pub fn run() {
|
||||
// 在后台线程启动 HTTP 服务器
|
||||
@@ -13,6 +16,25 @@ pub fn run() {
|
||||
});
|
||||
});
|
||||
|
||||
// 等待 HTTP 服务器就绪后再打开窗口
|
||||
for i in 0..50 {
|
||||
if let Ok(mut s) = std::net::TcpStream::connect_timeout(
|
||||
&"127.0.0.1:8000".parse().unwrap(),
|
||||
Duration::from_millis(500),
|
||||
) {
|
||||
// 发送一个简单的 HTTP 请求测试
|
||||
let _ = s.write_all(b"GET /api/state HTTP/1.0\r\n\r\n");
|
||||
let mut buf = [0u8; 4];
|
||||
if s.read(&mut buf).is_ok() {
|
||||
break;
|
||||
}
|
||||
}
|
||||
if i == 0 {
|
||||
eprintln!("[dpm] 等待 HTTP 服务器启动...");
|
||||
}
|
||||
std::thread::sleep(Duration::from_millis(100));
|
||||
}
|
||||
|
||||
tauri::Builder::default()
|
||||
.plugin(tauri_plugin_opener::init())
|
||||
.run(tauri::generate_context!())
|
||||
|
||||
Reference in New Issue
Block a user