界面迁移更新

This commit is contained in:
2026-09-05 00:12:11 +08:00
parent e2762d631d
commit 0aa66e1ec7
3187 changed files with 667915 additions and 211 deletions
@@ -0,0 +1,29 @@
import { symlinkSync, lstatSync, existsSync } from 'node:fs';
import { resolve } from 'node:path';
import { platform } from 'node:process';
// Windows 用 junction(免管理员、仅限目录);其它平台用 dir 符号链接
const LINK_TYPE = platform === 'win32' ? 'junction' : 'dir';
export function isLink(p) {
try {
return lstatSync(p).isSymbolicLink();
} catch {
return false;
}
}
// 在 linkPath 建一个指向 targetPath 的目录链接。
// 返回 'created' | 'exists';目标不存在或 linkPath 已被真实文件占用则抛错。
export function ensureJunction(linkPath, targetPath) {
const target = resolve(targetPath); // junction 要求绝对目标
if (!existsSync(target)) {
throw new Error(`junction target 不存在: ${target}`);
}
if (isLink(linkPath)) return 'exists';
if (existsSync(linkPath)) {
throw new Error(`路径已存在且非链接,拒绝覆盖: ${linkPath}`);
}
symlinkSync(target, linkPath, LINK_TYPE);
return 'created';
}