mirror of
https://github.com/LHY0125/PathEditor.git
synced 2026-06-29 01:37:22 +08:00
fix: e2e 类型声明 + ESLint 覆盖 e2e + backup 路径校验 + DX 脚本
- e2e/global.d.ts: Window.__TAURI_INTERNALS__ 类型声明 - e2e search-clean: 未使用参数 _args 前缀 - tsconfig.test.json: include e2e/ - CI: ESLint 扫描范围扩展到 e2e/ - backup_registry: 拒绝写入系统目录 (C:\Windows\, C:\Program Files\) - package.json: 新增 lint:fix / format 脚本 Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
@@ -28,7 +28,7 @@ jobs:
|
|||||||
run: npx tsc -b --noEmit
|
run: npx tsc -b --noEmit
|
||||||
|
|
||||||
- name: ESLint
|
- name: ESLint
|
||||||
run: npx eslint src/ tests/
|
run: npx eslint src/ tests/ e2e/
|
||||||
|
|
||||||
- name: Vitest 测试
|
- name: Vitest 测试
|
||||||
run: npm test
|
run: npm test
|
||||||
|
|||||||
+8
-1
@@ -19,7 +19,14 @@ pub fn get_appdata_dir() -> String {
|
|||||||
/// 在保存前调用,备份的是注册表中的当前值(保存前的状态)
|
/// 在保存前调用,备份的是注册表中的当前值(保存前的状态)
|
||||||
pub fn backup_registry(custom_dir: Option<String>) -> Result<String, String> {
|
pub fn backup_registry(custom_dir: Option<String>) -> Result<String, String> {
|
||||||
let backup_dir = match custom_dir {
|
let backup_dir = match custom_dir {
|
||||||
Some(ref dir) if !dir.is_empty() => std::path::PathBuf::from(dir),
|
Some(ref dir) if !dir.is_empty() => {
|
||||||
|
let p = std::path::PathBuf::from(dir);
|
||||||
|
let normalized = dir.replace('/', "\\").to_lowercase();
|
||||||
|
if normalized.starts_with("c:\\windows\\") || normalized.starts_with("c:\\program files\\") {
|
||||||
|
return Err("不允许备份到系统目录".into());
|
||||||
|
}
|
||||||
|
p
|
||||||
|
}
|
||||||
_ => backup_base_dir(),
|
_ => backup_base_dir(),
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Vendored
+5
@@ -0,0 +1,5 @@
|
|||||||
|
interface Window {
|
||||||
|
__TAURI_INTERNALS__?: {
|
||||||
|
invoke: (cmd: string, args?: Record<string, unknown>) => Promise<unknown>;
|
||||||
|
};
|
||||||
|
}
|
||||||
@@ -3,8 +3,7 @@ import { test, expect } from '@playwright/test';
|
|||||||
test.beforeEach(async ({ page }) => {
|
test.beforeEach(async ({ page }) => {
|
||||||
await page.addInitScript(() => {
|
await page.addInitScript(() => {
|
||||||
window.__TAURI_INTERNALS__ = {
|
window.__TAURI_INTERNALS__ = {
|
||||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
invoke: async (cmd, _args) => {
|
||||||
invoke: async (cmd, args) => {
|
|
||||||
switch (cmd) {
|
switch (cmd) {
|
||||||
case 'check_admin': return true;
|
case 'check_admin': return true;
|
||||||
case 'load_system_paths': return ['C:\\\\Windows', 'invalid_path', 'C:\\\\Temp'];
|
case 'load_system_paths': return ['C:\\\\Windows', 'invalid_path', 'C:\\\\Temp'];
|
||||||
|
|||||||
@@ -7,6 +7,8 @@
|
|||||||
"dev": "vite",
|
"dev": "vite",
|
||||||
"build": "tsc -b && vite build",
|
"build": "tsc -b && vite build",
|
||||||
"lint": "eslint .",
|
"lint": "eslint .",
|
||||||
|
"lint:fix": "eslint . --fix",
|
||||||
|
"format": "cargo fmt",
|
||||||
"preview": "vite preview",
|
"preview": "vite preview",
|
||||||
"test": "vitest run",
|
"test": "vitest run",
|
||||||
"test:watch": "vitest",
|
"test:watch": "vitest",
|
||||||
|
|||||||
+1
-1
@@ -4,5 +4,5 @@
|
|||||||
"tsBuildInfoFile": "./node_modules/.tmp/tsconfig.test.tsbuildinfo",
|
"tsBuildInfoFile": "./node_modules/.tmp/tsconfig.test.tsbuildinfo",
|
||||||
"types": ["vite/client", "vitest/globals"]
|
"types": ["vite/client", "vitest/globals"]
|
||||||
},
|
},
|
||||||
"include": ["src", "tests"]
|
"include": ["src", "tests", "e2e"]
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user