tcjs/run.md

106 lines
3.3 KiB
Markdown
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.

# 运行与打包说明
建筑材料放射性判定系统Rust + Tauri + React + TypeScript
## 1. 环境要求
| 工具 | 版本 | 说明 |
| --- | --- | --- |
| Node.js | ≥ 18 | 前端构建Vite |
| npm | 随 Node 安装 | 依赖管理 |
| Rust | ≥ 1.78(已验证 1.93 | 计算引擎与 Tauri 后端,`rustup` 安装 |
| Tauri 前置依赖 | Windows: WebView2 RuntimeWin11 已内置) | 见 <https://tauri.app/start/prerequisites/> |
首次准备:
```powershell
npm install
```
> Rust 依赖在首次 `cargo`/`tauri` 命令时自动下载编译。
## 2. 开发运行
### 2.1 仅前端(浏览器预览,不含 Tauri 原生命令)
```powershell
npm run dev
```
打开 <http://localhost:1420>。注意:此模式下 `invoke("calculate")` 不可用,仅用于调样式。
### 2.2 完整桌面应用(推荐)
```powershell
npm run tauri:dev
```
该命令会自动启动 Vite 开发服务器并编译 Rust 后端,弹出桌面窗口,支持热重载。
## 3. 测试
计算引擎(含蒙特卡洛仿真)的单元/集成测试:
```powershell
cargo test -p ceramic-radioactivity
```
前端类型检查与生产构建:
```powershell
npm run build
```
## 4. 打包(生成 Windows 安装包)
1.`src-tauri/tauri.conf.json` 中将 `bundle.active` 设为 `true`
```json
"bundle": {
"active": true,
"targets": ["nsis", "msi"],
"icon": ["icons/icon.ico"]
}
```
- `nsis` 生成 `.exe` 安装包,`msi` 生成 `.msi`(需安装 WiX Toolset可只保留 `nsis`)。
- `icon` 需指向有效图标;可用 `npx tauri icon path\to\logo.png` 生成整套图标。
2. 执行构建:
```powershell
npm run tauri:build
```
3. 产物输出目录:
```
src-tauri/target/release/ # 可执行文件 建筑材料放射性判定.exe
src-tauri/target/release/bundle/nsis/ # NSIS 安装包
src-tauri/target/release/bundle/msi/ # MSI 安装包(如启用)
```
> 首次 release 构建较慢(需编译全部 Rust 依赖),后续增量构建会显著加快。
## 5. 项目结构
```
src/ 计算引擎(库 crateceramic-radioactivity
├─ domain.rs 输入/输出/校准/判定/MCM 数据结构
├─ calculator.rs GUM 法不确定度计算与三态判定
└─ mcm.rs 蒙特卡洛法仿真10000 次,含 PRNG
tests/ 计算引擎测试
src-tauri/ Tauri 桌面外壳command: calculate
ui/ React + Ant Design 前端
run.md 本说明
```
## 6. 功能说明(计算与判定)
- **GUM 法**A 类(标准差 / 极差法、B 类不确定度合成,输出 IRa、Ir 及相对不确定度。
- `ur ≤ 20%``OK`;否则次数 < 6 `请增加试验次数至 6 次`否则 `校准仪器后重新测量`
- **蒙特卡洛法MCM**对各核素校准比活度按正态分布抽样10000 次仿真传播至 IRaIr
输出**平均值标准偏差P2.5P97.5**95% 包含区间并与**标准值**比较给出**合格 / 不合格概率**。
- 标准值IRaIr 限值可在界面校准参数 / 判定标准值中修改默认均为 `1.0`GB 6566 主体材料)。
- 仿真使用固定随机种子结果可复现