---修改编译文件,修改文件错误
This commit is contained in:
@ -15,4 +15,4 @@ VOLUME ["/etc/nginx/nginx.conf", "/usr/share/nginx/html"]
|
|||||||
|
|
||||||
CMD ["nginx","-g","daemon off;"]
|
CMD ["nginx","-g","daemon off;"]
|
||||||
|
|
||||||
# docker build -t docker.ges.bjgastx.com/itc-web:1.1.1 .
|
# docker build -t docker.ges.bjgastx.com/itc-web:1.1.3 .
|
||||||
|
|||||||
@ -15,8 +15,21 @@ export const runBuild = async () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
console.log(`✨ ${colors.cyan(`[${pkg.name}]`)}` + ' - build successfully!');
|
console.log(`✨ ${colors.cyan(`[${pkg.name}]`)}` + ' - build successfully!');
|
||||||
} catch (error) {
|
} catch (error: any) {
|
||||||
console.log(colors.red('vite build error:\n' + error));
|
console.error('\n');
|
||||||
|
console.error(colors.red('╔══════════════════════════════════════════════════════════════════╗'));
|
||||||
|
console.error(colors.red('║ 构建后处理错误 ║'));
|
||||||
|
console.error(colors.red('╚══════════════════════════════════════════════════════════════════╝'));
|
||||||
|
console.error('\n');
|
||||||
|
console.error(colors.yellow('错误详情:'));
|
||||||
|
console.error(error);
|
||||||
|
|
||||||
|
if (error.stack) {
|
||||||
|
console.error('\n');
|
||||||
|
console.error(colors.yellow('错误堆栈:'));
|
||||||
|
console.error(error.stack);
|
||||||
|
}
|
||||||
|
|
||||||
process.exit(1);
|
process.exit(1);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
99
build/vite/plugin/errorReporter.ts
Normal file
99
build/vite/plugin/errorReporter.ts
Normal file
@ -0,0 +1,99 @@
|
|||||||
|
import { PluginOption } from 'vite';
|
||||||
|
import colors from 'picocolors';
|
||||||
|
|
||||||
|
// 用于跟踪当前正在处理的文件
|
||||||
|
let currentProcessingFile: string | null = null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 增强构建错误报告的 Vite 插件
|
||||||
|
* 用于捕获和显示详细的 Vue 编译错误信息
|
||||||
|
*/
|
||||||
|
export function configErrorReporterPlugin(): PluginOption {
|
||||||
|
return {
|
||||||
|
name: 'vite-plugin-error-reporter',
|
||||||
|
enforce: 'pre',
|
||||||
|
|
||||||
|
// 捕获转换开始
|
||||||
|
transform(code, id) {
|
||||||
|
if (id.endsWith('.vue')) {
|
||||||
|
currentProcessingFile = id;
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
},
|
||||||
|
|
||||||
|
// 捕获构建错误
|
||||||
|
buildEnd(error) {
|
||||||
|
if (error) {
|
||||||
|
console.error('\n');
|
||||||
|
console.error(colors.red('╔══════════════════════════════════════════════════════════════════╗'));
|
||||||
|
console.error(colors.red('║ 构建错误详细信息 ║'));
|
||||||
|
console.error(colors.red('╚══════════════════════════════════════════════════════════════════╝'));
|
||||||
|
console.error('\n');
|
||||||
|
|
||||||
|
// 显示当前正在处理的文件
|
||||||
|
if (currentProcessingFile) {
|
||||||
|
console.error(colors.red('当前正在处理的文件:'));
|
||||||
|
console.error(colors.cyan(currentProcessingFile));
|
||||||
|
console.error('\n');
|
||||||
|
}
|
||||||
|
|
||||||
|
// 显示错误堆栈
|
||||||
|
if (error.stack) {
|
||||||
|
console.error(colors.yellow('错误堆栈:'));
|
||||||
|
console.error(error.stack);
|
||||||
|
console.error('\n');
|
||||||
|
}
|
||||||
|
|
||||||
|
// 尝试提取文件路径
|
||||||
|
const errorMessage = (error as any).message || '';
|
||||||
|
const fileMatch = errorMessage.match(/in\s+([\w\-/.\\]+\.vue)/i) ||
|
||||||
|
errorMessage.match(/at\s+([\w\-/.\\]+\.vue)/i) ||
|
||||||
|
errorMessage.match(/([\w\-/.\\]+\.vue)/i);
|
||||||
|
|
||||||
|
if (fileMatch) {
|
||||||
|
console.error(colors.yellow('可能出错的文件:'));
|
||||||
|
console.error(colors.cyan(fileMatch[1]));
|
||||||
|
console.error('\n');
|
||||||
|
}
|
||||||
|
|
||||||
|
// 显示原始错误信息
|
||||||
|
console.error(colors.yellow('错误信息:'));
|
||||||
|
console.error(errorMessage);
|
||||||
|
console.error('\n');
|
||||||
|
|
||||||
|
// 提示常见解决方案
|
||||||
|
console.error(colors.yellow('常见解决方案:'));
|
||||||
|
console.error('1. 检查 Vue 模板中 <template #slotName v-if="..."> 的用法');
|
||||||
|
console.error(' 应改为: <template v-if="..." #slotName>');
|
||||||
|
console.error('2. 检查 <template> 标签上是否使用了 v-show (应该改用 v-if)');
|
||||||
|
console.error('3. 检查模板中是否有未闭合的标签');
|
||||||
|
console.error('4. 检查 <template #[dynamicSlotName] v-if="..."> 的用法');
|
||||||
|
console.error(' 应改为: <template v-if="..." #[dynamicSlotName]>');
|
||||||
|
console.error('\n');
|
||||||
|
|
||||||
|
// 搜索建议
|
||||||
|
console.error(colors.yellow('建议搜索以下模式来定位问题:'));
|
||||||
|
console.error(colors.cyan(' grep -r "<template.*#.*v-if" src --include="*.vue"'));
|
||||||
|
console.error(colors.cyan(' grep -r "<template.*#.*v-show" src --include="*.vue"'));
|
||||||
|
console.error(colors.cyan(' grep -r "<template.*#\[.*v-if" src --include="*.vue"'));
|
||||||
|
console.error('\n');
|
||||||
|
|
||||||
|
throw error;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
// 配置服务器错误处理
|
||||||
|
configureServer(server) {
|
||||||
|
server.middlewares.use((req, res, next) => {
|
||||||
|
const originalEnd = res.end.bind(res);
|
||||||
|
res.end = function(chunk: any, encoding?: any, cb?: any) {
|
||||||
|
if (res.statusCode >= 400) {
|
||||||
|
console.error(colors.yellow(`\n请求错误: ${req.url} - 状态码: ${res.statusCode}\n`));
|
||||||
|
}
|
||||||
|
return originalEnd(chunk, encoding, cb);
|
||||||
|
};
|
||||||
|
next();
|
||||||
|
});
|
||||||
|
},
|
||||||
|
};
|
||||||
|
}
|
||||||
@ -14,11 +14,14 @@ import { configStyleImportPlugin } from './styleImport';
|
|||||||
import { configVisualizerConfig } from './visualizer';
|
import { configVisualizerConfig } from './visualizer';
|
||||||
import { configThemePlugin } from './theme';
|
import { configThemePlugin } from './theme';
|
||||||
import { configSvgIconsPlugin } from './svgSprite';
|
import { configSvgIconsPlugin } from './svgSprite';
|
||||||
|
import { configErrorReporterPlugin } from './errorReporter';
|
||||||
|
|
||||||
export function createVitePlugins(viteEnv: ViteEnv, isBuild: boolean) {
|
export function createVitePlugins(viteEnv: ViteEnv, isBuild: boolean) {
|
||||||
const { VITE_USE_MOCK, VITE_BUILD_COMPRESS, VITE_BUILD_COMPRESS_DELETE_ORIGIN_FILE } = viteEnv;
|
const { VITE_USE_MOCK, VITE_BUILD_COMPRESS, VITE_BUILD_COMPRESS_DELETE_ORIGIN_FILE } = viteEnv;
|
||||||
|
|
||||||
const vitePlugins: (PluginOption | PluginOption[])[] = [
|
const vitePlugins: (PluginOption | PluginOption[])[] = [
|
||||||
|
// 错误报告插件(放在最前面以捕获所有错误)
|
||||||
|
configErrorReporterPlugin(),
|
||||||
// have to
|
// have to
|
||||||
vue(),
|
vue(),
|
||||||
// have to
|
// have to
|
||||||
|
|||||||
@ -28,7 +28,7 @@
|
|||||||
{{ Number.format(Number.parse(record.qtySalesM3),numFormat) }}
|
{{ Number.format(Number.parse(record.qtySalesM3),numFormat) }}
|
||||||
</template>
|
</template>
|
||||||
<template v-if="column.dataIndex === 'qtyMeaGj'">
|
<template v-if="column.dataIndex === 'qtyMeaGj'">
|
||||||
<input-number v-model:value="record.qtyMeaGj":digits="3"
|
<input-number v-model:value="record.qtyMeaGj" :digits="3"
|
||||||
v-if="record.statusCode==='N'|| record.statusCode==='JLZ'" @change="numChange(record, index)" :min="0" style="width: 100%" />
|
v-if="record.statusCode==='N'|| record.statusCode==='JLZ'" @change="numChange(record, index)" :min="0" style="width: 100%" />
|
||||||
<div v-else>{{ Number.format(Number.parse(record.qtyMeaGj),numFormat) }}</div>
|
<div v-else>{{ Number.format(Number.parse(record.qtyMeaGj),numFormat) }}</div>
|
||||||
</template>
|
</template>
|
||||||
|
|||||||
Reference in New Issue
Block a user