diff --git a/App.vue b/App.vue index 9fedd72..973d67f 100644 --- a/App.vue +++ b/App.vue @@ -5,9 +5,20 @@ import { globalTimChatManager } from "@/utils/tim-chat.js"; export default { onLaunch: function () { // 需在 pinia 安装后再获取 store,避免 getActivePinia 报错 - const { login } = useAccountStore(); - login(); - console.log("App Launch: "); + const { account, login, initIMAfterLogin } = useAccountStore(); + + // 如果已有缓存的账户信息,尝试初始化 IM,否则重新登录 + if (account && account.openid) { + console.log("App Launch: 已有登录信息,初始化 IM"); + initIMAfterLogin().catch(err => { + console.error('IM初始化失败:', err); + }); + } else { + console.log("App Launch: 无登录信息,开始登录"); + login().catch(err => { + console.error('自动登录失败:', err); + }); + } }, onShow: function () { console.log("App Show"); diff --git a/hooks/useGuard.js b/hooks/useGuard.js index 4dffd6f..3460047 100644 --- a/hooks/useGuard.js +++ b/hooks/useGuard.js @@ -25,6 +25,7 @@ export default function useGuard() { const onShowOptions = ref({}) function toLoginPage(options, path) { + const params = Object.keys(options).map(key => `${key}=${options[key]}`).join('&'); const redirectUrl = encodeURIComponent(`${path}?${params}`); uni.redirectTo({ diff --git a/pages.json b/pages.json index a825f10..203a112 100644 --- a/pages.json +++ b/pages.json @@ -1,18 +1,17 @@ { "pages": [ + { + "path": "pages/message/message", + "style": { + "navigationBarTitleText": "消息" + } + }, { "path": "pages/login/redirect-page", "style": { "navigationBarTitleText": "登录" } }, - { - "path": "pages/message/message", - "style": { - "navigationBarTitleText": "消息", - "navigationStyle": "custom" - } - }, { "path": "pages/message/common-phrases", "style": { diff --git a/pages/message/components/chat-input.vue b/pages/message/components/chat-input.vue index 72024ec..41f1bcb 100644 --- a/pages/message/components/chat-input.vue +++ b/pages/message/components/chat-input.vue @@ -400,7 +400,7 @@ const morePanelButtons = [ { text: "照片", icon: "/static/icon/zhaopian.png", action: showImagePicker }, { text: "回访任务", - icon: "/static/icon/zhaopian.png", + icon: "/static/icon/huifangrenwu.png", action: showImagePicker, }, { diff --git a/pages/message/message.vue b/pages/message/message.vue index 5a18dd7..4ebf662 100644 --- a/pages/message/message.vue +++ b/pages/message/message.vue @@ -1,5 +1,25 @@