From e251153d146a49e58b4cdb7016f569e3fb754809 Mon Sep 17 00:00:00 2001 From: qiube <18969599531@163.com> Date: Fri, 26 Dec 2025 10:54:17 +0800 Subject: [PATCH] =?UTF-8?q?chore(config):=20=E6=9B=B4=E6=96=B0=E7=94=9F?= =?UTF-8?q?=E4=BA=A7=E7=8E=AF=E5=A2=83=E9=85=8D=E7=BD=AE=E5=92=8C=E6=9E=84?= =?UTF-8?q?=E5=BB=BA=E8=AE=BE=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 修复 .env.production 文件中的注释编码问题 - 移除路由守卫中的调试日志输出 - 调整错误处理机制,生产环境静默处理错误 - 移除应用挂载时的调试日志和异常处理包装 - 添加构建配置和基础路径设置 --- .env.production | 9 +++++---- src/main.js | 16 ++++++---------- src/router/index.js | 2 -- vite.config.js | 11 +++++++++++ 4 files changed, 22 insertions(+), 16 deletions(-) diff --git a/.env.production b/.env.production index 52168c1..27a9aef 100644 --- a/.env.production +++ b/.env.production @@ -1,7 +1,8 @@ -# 鐢熶骇鐜閰嶇疆 -# 鏈嶅姟鍣ㄥ湴鍧€: 175.178.252.59 +# 生产环境配置 +# 服务器地址: 175.178.252.59 -# 鍚庣API鍦板潃 +# 后端API地址 VITE_API_BASE_URL=http://175.178.252.59:8082/api -# PingPong妯″紡锛坰andbox/production锛塦nVITE_PINGPONG_MODE=sandbox +# PingPong模式(sandbox/production)`nVITE_PINGPONG_MODE=sandbox + diff --git a/src/main.js b/src/main.js index 0cff274..864898a 100644 --- a/src/main.js +++ b/src/main.js @@ -17,18 +17,14 @@ app.use(router) app.use(ElementPlus) app.use(i18n) -// 添加错误处理 +// 添加错误处理(生产环境静默处理) app.config.errorHandler = (err, instance, info) => { - console.error('Vue错误:', err) - console.error('错误信息:', info) - console.error('组件实例:', instance) + // 生产环境可以记录到错误追踪服务 + if (import.meta.env.DEV) { + console.error('Vue错误:', err, info) + } } // 挂载应用 -try { - app.mount('#app') - console.log('Vue应用已成功挂载') -} catch (error) { - console.error('应用挂载失败:', error) -} +app.mount('#app') diff --git a/src/router/index.js b/src/router/index.js index 832bfa2..9124d1c 100644 --- a/src/router/index.js +++ b/src/router/index.js @@ -111,8 +111,6 @@ const router = createRouter({ // 路由守卫 router.beforeEach((to, from, next) => { - console.log('路由导航:', from.path, '->', to.path) - // 检查是否需要认证 if (to.meta.requiresAuth) { // 检查是否已登录 diff --git a/vite.config.js b/vite.config.js index e7c31ef..0718d6f 100644 --- a/vite.config.js +++ b/vite.config.js @@ -12,6 +12,17 @@ export default defineConfig({ '@': path.resolve(__dirname, 'src') } }, + // 构建配置 + build: { + outDir: 'dist', + assetsDir: 'assets', + // 确保资源路径正确 + assetsInlineLimit: 4096, + // 生成source map(生产环境可以关闭) + sourcemap: false + }, + // 基础路径(如果部署在子目录下需要配置) + base: '/', server: { port: 3000, proxy: {