build(vue.config): 打包后自动打开目录增加错误捕获

新增try-catch捕获打开输出目录失败的异常,避免打包流程因目录打开失败中断,同时添加失败提示日志
This commit is contained in:
2026-05-25 11:56:50 +08:00
parent a2dd7eb6f1
commit 63789124f4

View File

@@ -264,12 +264,15 @@ class VersionInjectPlugin {
execSync(command, { stdio: 'inherit' });
console.log(`✅ H5 ZIP: ${zipFileName}`);
// 打包成功后默认打开输出目录
const openDir = h5Dir.replace(/'/g, "''");
if (process.platform === 'win32') {
execSync(`explorer "${openDir}"`, { stdio: 'ignore' });
} else {
execSync(`open "${openDir}"`, { stdio: 'ignore' });
try {
const openDir = h5Dir.replace(/'/g, "''");
if (process.platform === 'win32') {
execSync(`explorer "${openDir}"`, { stdio: 'ignore' });
} else {
execSync(`open "${openDir}"`, { stdio: 'ignore' });
}
} catch (openErr) {
console.warn(`⚠️ 打开目录失败(不影响 ZIP 打包): ${openErr.message}`);
}
// 删除已打包的源目录