Showing
2 changed files
with
49 additions
and
2 deletions
| ... | @@ -63,6 +63,9 @@ export default defineConfig(async (merge) => { | ... | @@ -63,6 +63,9 @@ export default defineConfig(async (merge) => { |
| 63 | data: `@import "@nutui/nutui-taro/dist/styles/variables.scss";` | 63 | data: `@import "@nutui/nutui-taro/dist/styles/variables.scss";` |
| 64 | }, | 64 | }, |
| 65 | mini: { | 65 | mini: { |
| 66 | + // 关闭开发环境的调试日志 | ||
| 67 | + enableSourceMap: false, | ||
| 68 | + debugReact: false, | ||
| 66 | miniCssExtractPluginOption: { | 69 | miniCssExtractPluginOption: { |
| 67 | ignoreOrder: true | 70 | ignoreOrder: true |
| 68 | }, | 71 | }, | ... | ... |
| ... | @@ -14,19 +14,63 @@ import { useUserStore } from '@/stores/user' | ... | @@ -14,19 +14,63 @@ import { useUserStore } from '@/stores/user' |
| 14 | const App = createApp({ | 14 | const App = createApp({ |
| 15 | // 对应 onLaunch | 15 | // 对应 onLaunch |
| 16 | async onLaunch(options) { | 16 | async onLaunch(options) { |
| 17 | - console.log('小程序启动', options) | ||
| 18 | - | ||
| 19 | // 获取用户 store | 17 | // 获取用户 store |
| 20 | const userStore = useUserStore() | 18 | const userStore = useUserStore() |
| 21 | 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) | ||
| 52 | + | ||
| 22 | // 检查登录状态 | 53 | // 检查登录状态 |
| 23 | // - 如果 is_openid=false,会自动调用 wx.login 授权 | 54 | // - 如果 is_openid=false,会自动调用 wx.login 授权 |
| 24 | // - 如果授权后返回 user,说明已自动登录 | 55 | // - 如果授权后返回 user,说明已自动登录 |
| 25 | // - 如果 is_login=false,会跳转到登录页 | 56 | // - 如果 is_login=false,会跳转到登录页 |
| 26 | try { | 57 | try { |
| 27 | await userStore.checkLoginStatus() | 58 | await userStore.checkLoginStatus() |
| 59 | + | ||
| 60 | + // 打印用户登录状态(在检查完成后) | ||
| 61 | + console.log('\n==================== 用户信息 ====================') | ||
| 62 | + if (userStore.isLoggedIn && userStore.userInfo) { | ||
| 63 | + console.log(`✅ 登录状态: 已登录`) | ||
| 64 | + console.log(`👤 用户ID: ${userStore.userInfo.id || '未知'}`) | ||
| 65 | + console.log(`👤 用户名: ${userStore.userInfo.name || userStore.userInfo.nickname || '未知'}`) | ||
| 66 | + console.log(`📱 手机号: ${userStore.userInfo.phone || userStore.userInfo.mobile || '未绑定'}`) | ||
| 67 | + } else { | ||
| 68 | + console.log(`❌ 登录状态: 未登录`) | ||
| 69 | + } | ||
| 70 | + console.log('====================================================\n') | ||
| 28 | } catch (error) { | 71 | } catch (error) { |
| 29 | console.error('启动时检查登录状态失败:', error) | 72 | console.error('启动时检查登录状态失败:', error) |
| 73 | + console.log('❌ 登录状态: 检查失败') | ||
| 30 | // 即使失败也继续,让用户可以正常使用小程序 | 74 | // 即使失败也继续,让用户可以正常使用小程序 |
| 31 | } | 75 | } |
| 32 | }, | 76 | }, | ... | ... |
-
Please register or login to post a comment