feat: 完成登录与栅格下载桌面端

This commit is contained in:
2026-10-25 02:09:12 +08:00
commit 5ca491834e
76 changed files with 10637 additions and 0 deletions
+7
View File
@@ -0,0 +1,7 @@
# Generated by Cargo
# will have compiled files and executables
/target/
# Generated by Tauri
# will have schema files for capabilities auto-completion
/gen/schemas
+4952
View File
File diff suppressed because it is too large Load Diff
+39
View File
@@ -0,0 +1,39 @@
[package]
name = "desktop"
version = "0.1.0"
description = "A Tauri App"
authors = ["you"]
edition = "2024"
autobins = false
[[bin]]
name = "NqiTools"
path = "src/main.rs"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[lib]
# The `_lib` suffix may seem redundant but it is necessary
# to make the lib name unique and wouldn't conflict with the bin name.
# This seems to be only an issue on Windows, see https://github.com/rust-lang/cargo/issues/8519
name = "desktop_lib"
crate-type = ["staticlib", "cdylib", "rlib"]
[build-dependencies]
tauri-build = { version = "2", features = [] }
[dependencies]
tauri = { version = "2", features = [] }
tauri-plugin-opener = "2"
tauri-plugin-dialog = "2"
serde = { version = "1", features = ["derive"] }
serde_json = "1"
# Read the optimization guideline for more details: https://tauri.app/concept/size/#cargo-configuration
[profile.release]
codegen-units = 1
lto = true
opt-level = 3
panic = "abort"
strip = true
+3
View File
@@ -0,0 +1,3 @@
fn main() {
tauri_build::build()
}
@@ -0,0 +1,11 @@
{
"$schema": "../gen/schemas/desktop-schema.json",
"identifier": "default",
"description": "Capability for the main window",
"windows": ["main"],
"permissions": [
"core:default",
"opener:default",
"dialog:default"
]
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 567 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 536 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 777 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1020 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 848 B

Binary file not shown.
Binary file not shown.

After

Width:  |  Height:  |  Size: 37 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.5 KiB

+87
View File
@@ -0,0 +1,87 @@
use std::net::{SocketAddr, TcpStream};
use std::path::PathBuf;
use std::process::{Child, Command, Stdio};
use std::sync::Mutex;
use std::time::Duration;
static BACKEND: Mutex<Option<Child>> = Mutex::new(None);
fn backend_up() -> bool {
let address: SocketAddr = "127.0.0.1:8765".parse().expect("address");
TcpStream::connect_timeout(&address, Duration::from_millis(200)).is_ok()
}
fn start_backend() {
if backend_up() {
return;
}
let manifest = PathBuf::from(env!("CARGO_MANIFEST_DIR"));
let Some(repo) = manifest.parent().and_then(|path| path.parent()) else {
return;
};
let python = repo
.join("backend")
.join(".venv")
.join("Scripts")
.join("python.exe");
if !python.exists() {
return;
}
let log_dir = repo.join("data");
let _ = std::fs::create_dir_all(&log_dir);
let mut command = Command::new(python);
command
.args([
"-m",
"uvicorn",
"app.main:app",
"--host",
"127.0.0.1",
"--port",
"8765",
])
.current_dir(repo.join("backend"))
.stdin(Stdio::null());
if let Ok(log) = std::fs::OpenOptions::new()
.create(true)
.append(true)
.open(log_dir.join("backend.log"))
{
if let Ok(error_log) = log.try_clone() {
command.stdout(log).stderr(error_log);
}
}
#[cfg(windows)]
{
use std::os::windows::process::CommandExt;
command.creation_flags(0x0800_0000);
}
if let Ok(child) = command.spawn() {
*BACKEND.lock().expect("backend lock") = Some(child);
}
}
fn stop_backend() {
if let Ok(mut slot) = BACKEND.lock() {
if let Some(child) = slot.as_mut() {
let _ = child.kill();
let _ = child.wait();
}
*slot = None;
}
}
#[cfg_attr(mobile, tauri::mobile_entry_point)]
pub fn run() {
start_backend();
tauri::Builder::default()
.plugin(tauri_plugin_opener::init())
.plugin(tauri_plugin_dialog::init())
.build(tauri::generate_context!())
.expect("error while building tauri application")
.run(|_app, event| {
if matches!(event, tauri::RunEvent::Exit) {
stop_backend();
}
});
}
+6
View File
@@ -0,0 +1,6 @@
// Prevents additional console window on Windows in release, DO NOT REMOVE!!
#![cfg_attr(not(debug_assertions), windows_subsystem = "windows")]
fn main() {
desktop_lib::run()
}
+36
View File
@@ -0,0 +1,36 @@
{
"$schema": "https://schema.tauri.app/config/2",
"productName": "NqiTools",
"version": "0.1.0",
"identifier": "com.nqitools.app",
"build": {
"beforeDevCommand": "npm run dev",
"devUrl": "http://localhost:1420",
"beforeBuildCommand": "npm run build",
"frontendDist": "../dist"
},
"app": {
"windows": [
{
"title": "NqiTools",
"width": 1180,
"height": 780,
"minWidth": 980,
"minHeight": 640
}
],
"security": {
"csp": null
}
},
"bundle": {
"active": false,
"icon": [
"icons/32x32.png",
"icons/128x128.png",
"icons/128x128@2x.png",
"icons/icon.icns",
"icons/icon.ico"
]
}
}