chore(config): 更新生产环境配置和构建设置
- 修复 .env.production 文件中的注释编码问题 - 移除路由守卫中的调试日志输出 - 调整错误处理机制,生产环境静默处理错误 - 移除应用挂载时的调试日志和异常处理包装 - 添加构建配置和基础路径设置
This commit is contained in:
@@ -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
|
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
|
||||||
|
|
||||||
|
|||||||
14
src/main.js
14
src/main.js
@@ -17,18 +17,14 @@ app.use(router)
|
|||||||
app.use(ElementPlus)
|
app.use(ElementPlus)
|
||||||
app.use(i18n)
|
app.use(i18n)
|
||||||
|
|
||||||
// 添加错误处理
|
// 添加错误处理(生产环境静默处理)
|
||||||
app.config.errorHandler = (err, instance, info) => {
|
app.config.errorHandler = (err, instance, info) => {
|
||||||
console.error('Vue错误:', err)
|
// 生产环境可以记录到错误追踪服务
|
||||||
console.error('错误信息:', info)
|
if (import.meta.env.DEV) {
|
||||||
console.error('组件实例:', instance)
|
console.error('Vue错误:', err, info)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 挂载应用
|
// 挂载应用
|
||||||
try {
|
|
||||||
app.mount('#app')
|
app.mount('#app')
|
||||||
console.log('Vue应用已成功挂载')
|
|
||||||
} catch (error) {
|
|
||||||
console.error('应用挂载失败:', error)
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|||||||
@@ -111,8 +111,6 @@ const router = createRouter({
|
|||||||
|
|
||||||
// 路由守卫
|
// 路由守卫
|
||||||
router.beforeEach((to, from, next) => {
|
router.beforeEach((to, from, next) => {
|
||||||
console.log('路由导航:', from.path, '->', to.path)
|
|
||||||
|
|
||||||
// 检查是否需要认证
|
// 检查是否需要认证
|
||||||
if (to.meta.requiresAuth) {
|
if (to.meta.requiresAuth) {
|
||||||
// 检查是否已登录
|
// 检查是否已登录
|
||||||
|
|||||||
@@ -12,6 +12,17 @@ export default defineConfig({
|
|||||||
'@': path.resolve(__dirname, 'src')
|
'@': path.resolve(__dirname, 'src')
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
// 构建配置
|
||||||
|
build: {
|
||||||
|
outDir: 'dist',
|
||||||
|
assetsDir: 'assets',
|
||||||
|
// 确保资源路径正确
|
||||||
|
assetsInlineLimit: 4096,
|
||||||
|
// 生成source map(生产环境可以关闭)
|
||||||
|
sourcemap: false
|
||||||
|
},
|
||||||
|
// 基础路径(如果部署在子目录下需要配置)
|
||||||
|
base: '/',
|
||||||
server: {
|
server: {
|
||||||
port: 3000,
|
port: 3000,
|
||||||
proxy: {
|
proxy: {
|
||||||
|
|||||||
Reference in New Issue
Block a user