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 1fd776c..f0cb7a0 100644
--- a/pages.json
+++ b/pages.json
@@ -1,22 +1,9 @@
{
"pages": [
- {
- "path": "pages/login/login",
- "style": {
- "navigationBarTitleText": "登录"
- }
- },
- {
- "path": "pages/login/redirect-page",
- "style": {
- "navigationBarTitleText": "登录"
- }
- },
{
"path": "pages/message/message",
"style": {
- "navigationBarTitleText": "消息",
- "navigationStyle": "custom"
+ "navigationBarTitleText": "消息"
}
},
{
@@ -211,6 +198,18 @@
"style": {
"navigationBarTitleText": "上传证照"
}
+ },
+ {
+ "path": "pages/login/login",
+ "style": {
+ "navigationBarTitleText": "登录"
+ }
+ },
+ {
+ "path": "pages/login/redirect-page",
+ "style": {
+ "navigationBarTitleText": "登录"
+ }
}
],
"globalStyle": {
diff --git a/pages/message/message.vue b/pages/message/message.vue
index 5a18dd7..f7b4ec6 100644
--- a/pages/message/message.vue
+++ b/pages/message/message.vue
@@ -1,5 +1,25 @@
+
+
+
+ 处理中
+
+
+
+ 已结束
+
+
+
+
@@ -31,7 +51,15 @@