hookehuyr

perf(config): 优化环境日志打印顺序

- 将环境信息和用户信息延迟到最后打印
- 确保其他初始化日志先输出完毕
- 避免重要信息被大量日志淹没
- 关闭开发环境 debug 模式以减少干扰
1 /* 1 /*
2 * @Date: 2025-06-28 10:33:00 2 * @Date: 2025-06-28 10:33:00
3 * @LastEditors: hookehuyr hookehuyr@gmail.com 3 * @LastEditors: hookehuyr hookehuyr@gmail.com
4 - * @LastEditTime: 2025-06-28 10:45:27 4 + * @LastEditTime: 2026-02-11 20:36:39
5 - * @FilePath: /myApp/config/dev.js 5 + * @FilePath: /manulife-weapp/config/dev.js
6 * @Description: 文件描述 6 * @Description: 文件描述
7 */ 7 */
8 export default { 8 export default {
...@@ -15,7 +15,7 @@ export default { ...@@ -15,7 +15,7 @@ export default {
15 }, 15 },
16 mini: { 16 mini: {
17 // 开启 vConsole 调试工具 17 // 开启 vConsole 调试工具
18 - debug: true 18 + debug: false
19 }, 19 },
20 h5: { 20 h5: {
21 // H5 端也可以使用 eruda(另一种调试工具) 21 // H5 端也可以使用 eruda(另一种调试工具)
......
...@@ -17,37 +17,6 @@ const App = createApp({ ...@@ -17,37 +17,6 @@ const App = createApp({
17 // 获取用户 store 17 // 获取用户 store
18 const userStore = useUserStore() 18 const userStore = useUserStore()
19 19
20 - // 打印环境信息(第一部分:基本信息)
21 - const env = process.env.NODE_ENV || 'unknown'
22 - const platform = process.env.TARO_ENV || 'unknown'
23 -
24 - console.log('\n==================== 环境信息 ====================')
25 - console.log(`📱 当前环境: ${env === 'development' ? '开发环境' : env === 'production' ? '生产环境' : env}`)
26 - console.log(`🔧 运行平台: ${platform === 'weapp' ? '微信小程序' : platform === 'h5' ? 'H5' : platform}`)
27 - console.log(`⏰ 启动时间: ${new Date().toLocaleString('zh-CN', { hour12: false })}`)
28 -
29 - // 打印当前页面路径
30 - try {
31 - const pages = getCurrentPages()
32 - if (pages.length > 0) {
33 - const currentPage = pages[pages.length - 1]
34 - console.log(`📄 当前页面: ${currentPage.route || 'app'}`)
35 - }
36 - } catch (err) {
37 - console.log('📄 当前页面: 无法获取')
38 - }
39 -
40 - // 打印会话信息
41 - try {
42 - const sessionid = wx.getStorageSync('sessionid')
43 - console.log(`🔐 会话状态: ${sessionid ? '已建立' : '未建立'}`)
44 - } catch (err) {
45 - console.log('🔐 会话状态: 无法获取')
46 - }
47 -
48 - // 用户状态:检查中
49 - console.log('👤 用户状态: 检查中...')
50 - console.log('====================================================\n')
51 console.log('小程序启动', options) 20 console.log('小程序启动', options)
52 21
53 // 检查登录状态 22 // 检查登录状态
...@@ -56,8 +25,41 @@ const App = createApp({ ...@@ -56,8 +25,41 @@ const App = createApp({
56 // - 如果 is_login=false,会跳转到登录页 25 // - 如果 is_login=false,会跳转到登录页
57 try { 26 try {
58 await userStore.checkLoginStatus() 27 await userStore.checkLoginStatus()
28 + } catch (error) {
29 + console.error('启动时检查登录状态失败:', error)
30 + // 即使失败也继续,让用户可以正常使用小程序
31 + }
32 +
33 + // 延迟打印环境信息和用户信息(确保在其他日志之后)
34 + setTimeout(() => {
35 + const env = process.env.NODE_ENV || 'unknown'
36 + const platform = process.env.TARO_ENV || 'unknown'
37 +
38 + console.log('\n==================== 环境信息 ====================')
39 + console.log(`📱 当前环境: ${env === 'development' ? '开发环境' : env === 'production' ? '生产环境' : env}`)
40 + console.log(`🔧 运行平台: ${platform === 'weapp' ? '微信小程序' : platform === 'h5' ? 'H5' : platform}`)
41 + console.log(`⏰ 启动时间: ${new Date().toLocaleString('zh-CN', { hour12: false })}`)
42 +
43 + // 打印当前页面路径
44 + try {
45 + const pages = getCurrentPages()
46 + if (pages.length > 0) {
47 + const currentPage = pages[pages.length - 1]
48 + console.log(`📄 当前页面: ${currentPage.route || 'app'}`)
49 + }
50 + } catch (err) {
51 + console.log('📄 当前页面: 无法获取')
52 + }
53 +
54 + // 打印会话信息
55 + try {
56 + const sessionid = wx.getStorageSync('sessionid')
57 + console.log(`🔐 会话状态: ${sessionid ? '已建立' : '未建立'}`)
58 + } catch (err) {
59 + console.log('🔐 会话状态: 无法获取')
60 + }
59 61
60 - // 打印用户登录状态(在检查完成后) 62 + // 打印用户登录状态
61 console.log('\n==================== 用户信息 ====================') 63 console.log('\n==================== 用户信息 ====================')
62 if (userStore.isLoggedIn && userStore.userInfo) { 64 if (userStore.isLoggedIn && userStore.userInfo) {
63 console.log(`✅ 登录状态: 已登录`) 65 console.log(`✅ 登录状态: 已登录`)
...@@ -67,12 +69,9 @@ const App = createApp({ ...@@ -67,12 +69,9 @@ const App = createApp({
67 } else { 69 } else {
68 console.log(`❌ 登录状态: 未登录`) 70 console.log(`❌ 登录状态: 未登录`)
69 } 71 }
72 +
70 console.log('====================================================\n') 73 console.log('====================================================\n')
71 - } catch (error) { 74 + }, 100)
72 - console.error('启动时检查登录状态失败:', error)
73 - console.log('❌ 登录状态: 检查失败')
74 - // 即使失败也继续,让用户可以正常使用小程序
75 - }
76 }, 75 },
77 76
78 onShow() { 77 onShow() {
......