AstroResearch/build.rs
Asfmq e13fa2ad40 refactor!: 模块化拆分 src 结构,新增批量同步服务、查询解析器及前端分页/高级检索功能
- src/ 按 clients/services/api 分层,Config 提升至 crate 根
- 新增 batch_sync.rs(双源并行收割)、query_parser.rs(多平台检索式转换)
- build.rs 自动触发前端 npm install & build
- SearchPanel 支持分页/排序/每页条数/高级检索构建器,前端加入搜索缓存
- 新增 SyncPanel 替换 SettingsPanel;新增 live_search 集成测试
2026-06-09 10:29:24 +08:00

53 lines
2.0 KiB
Rust
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

// build.rs
use std::process::Command;
use std::path::Path;
fn main() {
// 声明:只有当 dashboard/src/ 目录或 build.rs 发生改变时,才重新触发构建脚本
println!("cargo:rerun-if-changed=dashboard/src");
println!("cargo:rerun-if-changed=dashboard/package.json");
println!("cargo:rerun-if-changed=build.rs");
let dashboard_dir = Path::new("dashboard");
let node_modules_exist = dashboard_dir.join("node_modules").exists();
let dist_exists = dashboard_dir.join("dist").exists();
// 1. 如果没有 node_modules自动运行 npm install
if !node_modules_exist {
println!("cargo:warning=未检测到 node_modules正在自动为您安装前端依赖 (npm install)...");
let status = Command::new("npm")
.arg("install")
.current_dir(dashboard_dir)
.status();
match status {
Ok(s) if s.success() => {
println!("cargo:warning=前端依赖安装成功。");
}
_ => {
panic!("错误: 自动执行 npm install 失败,请检查是否安装了 Node.js / npm 并配置了正确的环境变量。");
}
}
}
// 2. 如果 dist 目录不存在,或者检测到前端源码变化,自动运行 npm run build
// 提示:因为上面 rerun-if-changed 绑定了 src 目录,只有 src 变动或者 dist 不存在时才会走到这步
if !dist_exists || node_modules_exist {
println!("cargo:warning=正在自动为您构建前端静态资源 (npm run build)...");
let status = Command::new("npm")
.arg("run")
.arg("build")
.current_dir(dashboard_dir)
.status();
match status {
Ok(s) if s.success() => {
println!("cargo:warning=前端资源构建打包成功。");
}
_ => {
panic!("错误: 自动构建前端静态资源失败 (npm run build),请进入 dashboard 目录手动排查编译错误。");
}
}
}
}