refactor: src-tauri 重命名为 gui
Tauri CLI 自动检测 workspace 成员,构建不受影响。 Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@@ -38,7 +38,7 @@ jobs:
|
|||||||
runs-on: windows-latest
|
runs-on: windows-latest
|
||||||
defaults:
|
defaults:
|
||||||
run:
|
run:
|
||||||
working-directory: src-tauri
|
working-directory: gui
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v4
|
||||||
|
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ jobs:
|
|||||||
|
|
||||||
- name: 上传安装包到 Release
|
- name: 上传安装包到 Release
|
||||||
run: |
|
run: |
|
||||||
$installer = Get-ChildItem -Path "src-tauri\target\release\bundle\nsis\*.exe" | Select-Object -First 1
|
$installer = Get-ChildItem -Path "target\release\bundle\nsis\*.exe" | Select-Object -First 1
|
||||||
if (gh release view $env:GITHUB_REF_NAME 2>$null) {
|
if (gh release view $env:GITHUB_REF_NAME 2>$null) {
|
||||||
gh release upload $env:GITHUB_REF_NAME "$installer" --clobber
|
gh release upload $env:GITHUB_REF_NAME "$installer" --clobber
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -2,6 +2,6 @@
|
|||||||
resolver = "2"
|
resolver = "2"
|
||||||
members = [
|
members = [
|
||||||
"core",
|
"core",
|
||||||
"src-tauri",
|
"gui",
|
||||||
"cli",
|
"cli",
|
||||||
]
|
]
|
||||||
|
|||||||
@@ -174,10 +174,10 @@ npm run dev
|
|||||||
npm test
|
npm test
|
||||||
|
|
||||||
# Rust 后端检查
|
# Rust 后端检查
|
||||||
cd src-tauri && cargo check
|
cd gui && cargo check
|
||||||
|
|
||||||
# Rust 后端测试
|
# Rust 后端测试
|
||||||
cd src-tauri && cargo test
|
cd gui && cargo test
|
||||||
```
|
```
|
||||||
|
|
||||||
### 技术栈
|
### 技术栈
|
||||||
@@ -211,7 +211,7 @@ src/ # React 前端
|
|||||||
├── i18n/ # zh-CN / en
|
├── i18n/ # zh-CN / en
|
||||||
└── config/ # default.json
|
└── config/ # default.json
|
||||||
|
|
||||||
src-tauri/ # Rust 后端
|
gui/ # Rust 后端
|
||||||
└── src/commands/
|
└── src/commands/
|
||||||
├── registry.rs # 注册表读写
|
├── registry.rs # 注册表读写
|
||||||
├── system.rs # 权限检测、路径验证、环境变量展开
|
├── system.rs # 权限检测、路径验证、环境变量展开
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ import reactRefresh from 'eslint-plugin-react-refresh';
|
|||||||
import globals from 'globals';
|
import globals from 'globals';
|
||||||
|
|
||||||
export default tseslint.config(
|
export default tseslint.config(
|
||||||
{ ignores: ['dist', 'src-tauri'] },
|
{ ignores: ['dist', 'gui'] },
|
||||||
{
|
{
|
||||||
extends: [js.configs.recommended, ...tseslint.configs.recommended],
|
extends: [js.configs.recommended, ...tseslint.configs.recommended],
|
||||||
files: ['**/*.{ts,tsx}'],
|
files: ['**/*.{ts,tsx}'],
|
||||||
|
|||||||
@@ -0,0 +1,4 @@
|
|||||||
|
# Generated by Cargo
|
||||||
|
# will have compiled files and executables
|
||||||
|
/target/
|
||||||
|
/gen/schemas
|
||||||
@@ -0,0 +1,25 @@
|
|||||||
|
[package]
|
||||||
|
name = "patheditor"
|
||||||
|
version = "5.0.0"
|
||||||
|
description = "Windows PATH Environment Variable Editor"
|
||||||
|
authors = ["刘航宇"]
|
||||||
|
license = "MIT"
|
||||||
|
repository = "https://github.com/LHY0125/PathEditor"
|
||||||
|
edition = "2021"
|
||||||
|
rust-version = "1.77.2"
|
||||||
|
|
||||||
|
[lib]
|
||||||
|
name = "app_lib"
|
||||||
|
crate-type = ["staticlib", "rlib"]
|
||||||
|
|
||||||
|
[build-dependencies]
|
||||||
|
tauri-build = { version = "2.6.2", features = [] }
|
||||||
|
|
||||||
|
[dependencies]
|
||||||
|
path-editor-core = { path = "../core" }
|
||||||
|
serde_json = "1.0"
|
||||||
|
serde = { version = "1.0", features = ["derive"] }
|
||||||
|
log = "0.4"
|
||||||
|
tauri = { version = "2.11.2", features = [] }
|
||||||
|
tauri-plugin-log = "2"
|
||||||
|
tauri-plugin-dialog = "2"
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
fn main() {
|
||||||
|
tauri_build::build()
|
||||||
|
}
|
||||||
@@ -0,0 +1,12 @@
|
|||||||
|
{
|
||||||
|
"$schema": "../gen/schemas/desktop-schema.json",
|
||||||
|
"identifier": "default",
|
||||||
|
"description": "enables the default permissions",
|
||||||
|
"windows": [
|
||||||
|
"main"
|
||||||
|
],
|
||||||
|
"permissions": [
|
||||||
|
"core:default",
|
||||||
|
"dialog:default"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
After Width: | Height: | Size: 11 KiB |
|
After Width: | Height: | Size: 23 KiB |
|
After Width: | Height: | Size: 2.2 KiB |
|
After Width: | Height: | Size: 9.0 KiB |
|
After Width: | Height: | Size: 12 KiB |
|
After Width: | Height: | Size: 13 KiB |
|
After Width: | Height: | Size: 25 KiB |
|
After Width: | Height: | Size: 2.0 KiB |
|
After Width: | Height: | Size: 28 KiB |
|
After Width: | Height: | Size: 3.3 KiB |
|
After Width: | Height: | Size: 5.9 KiB |
|
After Width: | Height: | Size: 7.4 KiB |
|
After Width: | Height: | Size: 3.9 KiB |
|
After Width: | Height: | Size: 37 KiB |
|
After Width: | Height: | Size: 49 KiB |
@@ -0,0 +1,6 @@
|
|||||||
|
use path_editor_core::backup;
|
||||||
|
|
||||||
|
#[tauri::command]
|
||||||
|
pub fn backup_registry(custom_dir: Option<String>) -> Result<String, String> { backup::backup_registry(custom_dir) }
|
||||||
|
#[tauri::command]
|
||||||
|
pub fn get_appdata_dir() -> String { backup::get_appdata_dir() }
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
use path_editor_core::disabled;
|
||||||
|
|
||||||
|
#[tauri::command]
|
||||||
|
pub fn save_disabled_state(system: Vec<String>, user: Vec<String>) -> Result<(), String> { disabled::save_disabled_state(system, user) }
|
||||||
|
#[tauri::command]
|
||||||
|
pub fn load_disabled_state() -> Result<(Vec<String>, Vec<String>), String> { disabled::load_disabled_state() }
|
||||||
@@ -0,0 +1,4 @@
|
|||||||
|
use path_editor_core::fs;
|
||||||
|
|
||||||
|
#[tauri::command]
|
||||||
|
pub fn read_text_file(path: &str) -> Result<String, String> { fs::read_text_file(path) }
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
pub mod backup;
|
||||||
|
pub mod disabled;
|
||||||
|
pub mod fs;
|
||||||
|
pub mod profiles;
|
||||||
|
pub mod registry;
|
||||||
|
pub mod scanner;
|
||||||
|
pub mod system;
|
||||||
@@ -0,0 +1,12 @@
|
|||||||
|
use path_editor_core::profiles;
|
||||||
|
|
||||||
|
#[tauri::command]
|
||||||
|
pub fn list_profiles() -> Result<Vec<profiles::ProfileMeta>, String> { profiles::list_profiles() }
|
||||||
|
#[tauri::command]
|
||||||
|
pub fn save_profile(name: String, sys: Vec<profiles::ProfilePathEntry>, user: Vec<profiles::ProfilePathEntry>) -> Result<(), String> { profiles::save_profile(name, sys, user) }
|
||||||
|
#[tauri::command]
|
||||||
|
pub fn load_profile(name: String) -> Result<profiles::ProfileData, String> { profiles::load_profile(name) }
|
||||||
|
#[tauri::command]
|
||||||
|
pub fn delete_profile(name: String) -> Result<(), String> { profiles::delete_profile(name) }
|
||||||
|
#[tauri::command]
|
||||||
|
pub fn rename_profile(old_name: String, new_name: String) -> Result<(), String> { profiles::rename_profile(old_name, new_name) }
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
use path_editor_core::registry;
|
||||||
|
|
||||||
|
#[tauri::command]
|
||||||
|
pub fn load_system_paths() -> Result<Vec<String>, String> { registry::load_system_paths() }
|
||||||
|
#[tauri::command]
|
||||||
|
pub fn load_user_paths() -> Result<Vec<String>, String> { registry::load_user_paths() }
|
||||||
|
#[tauri::command]
|
||||||
|
pub fn save_system_paths(paths: Vec<String>) -> Result<(), String> { registry::save_system_paths(paths) }
|
||||||
|
#[tauri::command]
|
||||||
|
pub fn save_user_paths(paths: Vec<String>) -> Result<(), String> { registry::save_user_paths(paths) }
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
use path_editor_core::scanner;
|
||||||
|
|
||||||
|
#[tauri::command]
|
||||||
|
pub fn scan_conflicts(paths: Vec<String>) -> Result<Vec<scanner::ConflictEntry>, String> { scanner::scan_conflicts(paths) }
|
||||||
|
#[tauri::command]
|
||||||
|
pub fn scan_tools(paths: Vec<String>, query: String) -> Result<Vec<scanner::ToolGroup>, String> { scanner::scan_tools(paths, query) }
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
use path_editor_core::system;
|
||||||
|
|
||||||
|
#[tauri::command]
|
||||||
|
pub fn check_admin() -> bool { system::check_admin() }
|
||||||
|
#[tauri::command]
|
||||||
|
pub fn validate_path(path: &str) -> bool { system::validate_path(path) }
|
||||||
|
#[tauri::command]
|
||||||
|
pub fn expand_env_vars(path: &str) -> String { system::expand_env_vars(path) }
|
||||||
|
#[tauri::command]
|
||||||
|
pub fn broadcast_env_change() { system::broadcast_env_change() }
|
||||||
@@ -0,0 +1,41 @@
|
|||||||
|
mod commands;
|
||||||
|
|
||||||
|
#[cfg_attr(mobile, tauri::mobile_entry_point)]
|
||||||
|
pub fn run() {
|
||||||
|
tauri::Builder::default()
|
||||||
|
.plugin(tauri_plugin_dialog::init())
|
||||||
|
.setup(|app| {
|
||||||
|
if cfg!(debug_assertions) {
|
||||||
|
app.handle().plugin(
|
||||||
|
tauri_plugin_log::Builder::default()
|
||||||
|
.level(log::LevelFilter::Info)
|
||||||
|
.build(),
|
||||||
|
)?;
|
||||||
|
}
|
||||||
|
Ok(())
|
||||||
|
})
|
||||||
|
.invoke_handler(tauri::generate_handler![
|
||||||
|
commands::registry::load_system_paths,
|
||||||
|
commands::registry::load_user_paths,
|
||||||
|
commands::registry::save_system_paths,
|
||||||
|
commands::registry::save_user_paths,
|
||||||
|
commands::system::check_admin,
|
||||||
|
commands::system::validate_path,
|
||||||
|
commands::system::expand_env_vars,
|
||||||
|
commands::system::broadcast_env_change,
|
||||||
|
commands::backup::backup_registry,
|
||||||
|
commands::backup::get_appdata_dir,
|
||||||
|
commands::fs::read_text_file,
|
||||||
|
commands::disabled::save_disabled_state,
|
||||||
|
commands::disabled::load_disabled_state,
|
||||||
|
commands::scanner::scan_conflicts,
|
||||||
|
commands::scanner::scan_tools,
|
||||||
|
commands::profiles::list_profiles,
|
||||||
|
commands::profiles::save_profile,
|
||||||
|
commands::profiles::load_profile,
|
||||||
|
commands::profiles::delete_profile,
|
||||||
|
commands::profiles::rename_profile,
|
||||||
|
])
|
||||||
|
.run(tauri::generate_context!())
|
||||||
|
.expect("error while running tauri application");
|
||||||
|
}
|
||||||
@@ -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() {
|
||||||
|
app_lib::run();
|
||||||
|
}
|
||||||
@@ -0,0 +1,40 @@
|
|||||||
|
{
|
||||||
|
"$schema": "../node_modules/@tauri-apps/cli/config.schema.json",
|
||||||
|
"productName": "PathEditor",
|
||||||
|
"version": "5.0.0",
|
||||||
|
"identifier": "com.liuhangyu.patheditor",
|
||||||
|
"build": {
|
||||||
|
"frontendDist": "../dist",
|
||||||
|
"devUrl": "http://localhost:5173",
|
||||||
|
"beforeDevCommand": "npm run dev",
|
||||||
|
"beforeBuildCommand": "npm run build"
|
||||||
|
},
|
||||||
|
"app": {
|
||||||
|
"windows": [
|
||||||
|
{
|
||||||
|
"title": "PathEditor v5.0",
|
||||||
|
"width": 900,
|
||||||
|
"height": 700,
|
||||||
|
"minWidth": 800,
|
||||||
|
"minHeight": 600,
|
||||||
|
"resizable": true,
|
||||||
|
"fullscreen": false
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"security": {
|
||||||
|
"csp": null
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"bundle": {
|
||||||
|
"active": true,
|
||||||
|
"targets": "nsis",
|
||||||
|
"resources": ["WebView2Loader.dll"],
|
||||||
|
"icon": [
|
||||||
|
"icons/32x32.png",
|
||||||
|
"icons/128x128.png",
|
||||||
|
"icons/128x128@2x.png",
|
||||||
|
"icons/icon.icns",
|
||||||
|
"icons/icon.ico"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -27,7 +27,7 @@ export function join_path(paths: string[]): string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** 分割 PATH 字符串。
|
/** 分割 PATH 字符串。
|
||||||
* 注意:Rust 端 src-tauri/src/commands/registry.rs 有相同逻辑的 split_path,修改时需同步两端。 */
|
* 注意:Rust 端 core/src/registry.rs 有相同逻辑的 split_path,修改时需同步两端。 */
|
||||||
export function split_path(raw: string): string[] {
|
export function split_path(raw: string): string[] {
|
||||||
return raw
|
return raw
|
||||||
.split(';')
|
.split(';')
|
||||||
|
|||||||
@@ -8,6 +8,6 @@ export default defineConfig({
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
test: {
|
test: {
|
||||||
exclude: ['e2e/**', 'node_modules/**', 'src-tauri/**'],
|
exclude: ['e2e/**', 'node_modules/**', 'gui/**'],
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|||||||