From ea961d8f9492f2c98de21829a26cf80a9f12cbfa Mon Sep 17 00:00:00 2001 From: xsx <825657193@qq.com> Date: Thu, 15 Aug 2024 21:41:33 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BB=A3=E7=A0=81=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- im-uniapp/App.vue | 9 ++------- im-uniapp/components/chat-at-box/chat-at-box.vue | 1 - .../chat-group-readed/chat-group-readed.vue | 1 - .../components/group-rtc-join/group-rtc-join.vue | 1 - im-uniapp/main.js | 15 +++++++++------ im-uniapp/pages/chat/chat-box.vue | 8 +------- im-uniapp/pages/chat/chat-group-video.vue | 2 -- im-uniapp/pages/chat/chat-private-video.vue | 2 -- im-uniapp/pages/chat/chat.vue | 1 - im-uniapp/pages/common/user-info.vue | 3 --- im-uniapp/pages/friend/friend-add.vue | 2 -- im-uniapp/pages/friend/friend.vue | 1 - im-uniapp/pages/group/group-edit.vue | 3 --- im-uniapp/pages/group/group-info.vue | 5 +---- im-uniapp/pages/group/group-invite.vue | 1 - im-uniapp/pages/group/group-member.vue | 1 - im-uniapp/pages/group/group.vue | 1 - im-uniapp/pages/mine/mine-edit.vue | 1 - im-uniapp/pages/mine/mine.vue | 4 +--- im-uniapp/store/chatStore.js | 8 ++++---- 20 files changed, 18 insertions(+), 52 deletions(-) diff --git a/im-uniapp/App.vue b/im-uniapp/App.vue index 6031398..363b9e0 100644 --- a/im-uniapp/App.vue +++ b/im-uniapp/App.vue @@ -5,15 +5,10 @@ import * as enums from './common/enums'; import * as wsApi from './common/wssocket'; import UNI_APP from '@/.env.js' - + import { getCurrentInstance } from 'vue' export default { data() { return { - chatStore: this.useChatStore(), - friendStore: this.useFriendStore(), - groupStore: this.useGroupStore(), - configStore: this.useConfigStore(), - userStore: this.useUserStore(), isExit: false, // 是否已退出 audioTip: null, reconnecting: false // 正在重连标志 @@ -355,10 +350,10 @@ } }, onLaunch() { + this.$mountStore(); // 登录状态校验 let loginInfo = uni.getStorageSync("loginInfo") if (!this.isExpired(loginInfo)) { - console.log("初始化") // 初始化 this.init(); // 跳转到聊天页面 diff --git a/im-uniapp/components/chat-at-box/chat-at-box.vue b/im-uniapp/components/chat-at-box/chat-at-box.vue index d40518a..a44a179 100644 --- a/im-uniapp/components/chat-at-box/chat-at-box.vue +++ b/im-uniapp/components/chat-at-box/chat-at-box.vue @@ -49,7 +49,6 @@ }, data() { return { - userStore: this.useUserStore(), searchText: "", showMembers:[] }; diff --git a/im-uniapp/components/chat-group-readed/chat-group-readed.vue b/im-uniapp/components/chat-group-readed/chat-group-readed.vue index 117636d..a55649b 100644 --- a/im-uniapp/components/chat-group-readed/chat-group-readed.vue +++ b/im-uniapp/components/chat-group-readed/chat-group-readed.vue @@ -37,7 +37,6 @@ name: "chat-group-readed", data() { return { - chatStore: this.useChatStore(), items: ['已读', '未读'], current: 0, readedMembers: [], diff --git a/im-uniapp/components/group-rtc-join/group-rtc-join.vue b/im-uniapp/components/group-rtc-join/group-rtc-join.vue index 2ffcec1..6b36b55 100644 --- a/im-uniapp/components/group-rtc-join/group-rtc-join.vue +++ b/im-uniapp/components/group-rtc-join/group-rtc-join.vue @@ -26,7 +26,6 @@ export default { data() { return { - userStore: this.useUserStore(), rtcInfo: {} } }, diff --git a/im-uniapp/main.js b/im-uniapp/main.js index 1f3965c..7e5c597 100644 --- a/im-uniapp/main.js +++ b/im-uniapp/main.js @@ -22,6 +22,7 @@ import * as recorder from './common/recorder-app'; // #endif + export function createApp() { const app = createSSRApp(App) app.use(uviewPlus); @@ -33,12 +34,14 @@ export function createApp() { app.config.globalProperties.$enums = enums; app.config.globalProperties.$date = date; app.config.globalProperties.$rc = recorder; - app.config.globalProperties.useChatStore = useChatStore; - app.config.globalProperties.useFriendStore = useFriendStore; - app.config.globalProperties.useGroupStore = useGroupStore; - app.config.globalProperties.useConfigStore = useConfigStore; - app.config.globalProperties.useUserStore = useUserStore; - + // 初始化时再挂载store对象 + app.config.globalProperties.$mountStore = ()=>{ + app.config.globalProperties.chatStore = useChatStore(); + app.config.globalProperties.friendStore = useFriendStore(); + app.config.globalProperties.groupStore = useGroupStore(); + app.config.globalProperties.configStore = useConfigStore(); + app.config.globalProperties.userStore = useUserStore(); + } return { app, pinia diff --git a/im-uniapp/pages/chat/chat-box.vue b/im-uniapp/pages/chat/chat-box.vue index bee917f..64c943f 100644 --- a/im-uniapp/pages/chat/chat-box.vue +++ b/im-uniapp/pages/chat/chat-box.vue @@ -119,16 +119,10 @@