开起来tfto
This commit is contained in:
parent
66a08a9c05
commit
bec0d21d20
@ -4,7 +4,7 @@ version = "1.0.0"
|
|||||||
edition = "2024"
|
edition = "2024"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
smol = "1" # or any other runtime/executor
|
tokio = "1.47.1"
|
||||||
async-tftp = "0.3.6"
|
async-tftp = "0.3.6"
|
||||||
slint = "1.12.1"
|
slint = "1.12.1"
|
||||||
rfd = "0.15.4"
|
rfd = "0.15.4"
|
||||||
|
35
src/main.rs
35
src/main.rs
@ -1,15 +1,18 @@
|
|||||||
// use async_tftp::server::TftpServerBuilder;
|
use async_tftp::server::TftpServerBuilder;
|
||||||
// use async_tftp::Result;
|
use async_tftp::Result;
|
||||||
use rfd::FileDialog;
|
use rfd::FileDialog;
|
||||||
use slint::SharedString;
|
use slint::SharedString;
|
||||||
|
use std::error::Error;
|
||||||
|
// ?use smol::{prelude::*};
|
||||||
|
|
||||||
slint::include_modules!();
|
slint::include_modules!();
|
||||||
// fn main() -> Result<()> {
|
|
||||||
// smol::block_on(async {
|
async fn StartTftpServer(Dir: &str) -> Result<()> {
|
||||||
// let tftpd = TftpServerBuilder::with_dir_ro("C:/Users/anonymous/Desktop/Rust/VoiletTftp/target/debug")?.build().await?;
|
println!("Start Tftp Server Dir With:{Dir}");
|
||||||
// tftpd.serve().await?;
|
let tftpd = TftpServerBuilder::with_dir_ro(Dir)?.build().await?;
|
||||||
// Ok(())
|
tftpd.serve().await?;
|
||||||
// })
|
Ok(())
|
||||||
// }
|
}
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
let ui = MainWindow::new().unwrap();
|
let ui = MainWindow::new().unwrap();
|
||||||
@ -26,19 +29,11 @@ fn main() {
|
|||||||
});
|
});
|
||||||
//启动按钮的回调函数
|
//启动按钮的回调函数
|
||||||
ui.on_StartTftp(move || {
|
ui.on_StartTftp(move || {
|
||||||
println!("Start Tftp Dir:");
|
// smol::spawn(StartTftpServer("C:/Users/anonymous/Desktop/Rust/VoiletTftp/target/release/")).detach();
|
||||||
});
|
});
|
||||||
//停止按钮的回调函数
|
//停止按钮的回调函数
|
||||||
ui.on_StopTftp(move || {
|
ui.on_StopTftp(move || {
|
||||||
println!("Stop Tftp Dir:");
|
|
||||||
});
|
});
|
||||||
ui.run().unwrap();
|
ui.run().unwrap();
|
||||||
// // 实现 Slint 中定义的 select_path 函数
|
}
|
||||||
// ui.global::<MainWindow>().invoke_select_path(move || {
|
//启动一个TFTP服务器帮我改写
|
||||||
// // 使用 rfd 库打开文件选择对话框
|
|
||||||
// if let Some(path) = FileDialog::new().pick_folder() {
|
|
||||||
// // 将选择的路径设置到 Slint 的 selected_path 属性中
|
|
||||||
// ui.global::<MainWindow>().set_selected_path(path.to_str().unwrap_or(""));
|
|
||||||
// }
|
|
||||||
// });
|
|
||||||
}
|
|
Loading…
x
Reference in New Issue
Block a user