xsx 1 год назад
Родитель
Сommit
ea961d8f94

+ 2 - 7
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();
 				// 跳转到聊天页面

+ 0 - 1
im-uniapp/components/chat-at-box/chat-at-box.vue

@@ -49,7 +49,6 @@
 		},
 		data() {
 			return {
-				userStore: this.useUserStore(),
 				searchText: "",
 				showMembers:[]
 			};

+ 0 - 1
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: [],

+ 0 - 1
im-uniapp/components/group-rtc-join/group-rtc-join.vue

@@ -26,7 +26,6 @@
 	export default {
 		data() {
 			return {
-				userStore: this.useUserStore(),
 				rtcInfo: {}
 			}
 		},

+ 9 - 6
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

+ 1 - 7
im-uniapp/pages/chat/chat-box.vue

@@ -119,16 +119,10 @@
 
 <script>
 	import UNI_APP from '@/.env.js';
-	import useChatStore  from '@/store/chatStore.js'
-	
+
 	export default {
 		data() {
 			return {
-				chatStore: useChatStore(),
-				friendStore: this.useFriendStore(),
-				groupStore: this.useGroupStore(),
-				configStore: this.useConfigStore(),
-				userStore: this.useUserStore(),
 				chat: {},
 				friend: {},
 				group: {},

+ 0 - 2
im-uniapp/pages/chat/chat-group-video.vue

@@ -7,8 +7,6 @@
 	export default {
 		data() {
 			return {
-				configStore: this.useConfigStore(),
-				userStore: this.useUserStore(),
 				url: "",
 				wv: '',
 				isHost: false,

+ 0 - 2
im-uniapp/pages/chat/chat-private-video.vue

@@ -7,8 +7,6 @@
 	export default {
 		data() {
 			return {
-				configStore: this.useConfigStore(),
-				userStore: this.useUserStore(),
 				url: "",
 				wv: '',
 				mode: "video",

+ 0 - 1
im-uniapp/pages/chat/chat.vue

@@ -31,7 +31,6 @@
 	export default {
 		data() {
 			return {
-				chatStore: useChatStore(),
 				searchText: "",
 				menu: {
 					show: false,

+ 0 - 3
im-uniapp/pages/common/user-info.vue

@@ -35,9 +35,6 @@
 	export default {
 		data() {
 			return {
-				userStore: this.useUserStore(),
-				chatStore: this.useChatStore(),
-				friendStore: this.useFriendStore(),
 				userInfo: {}
 			}
 		},

+ 0 - 2
im-uniapp/pages/friend/friend-add.vue

@@ -28,8 +28,6 @@
 	export default {
 		data() {
 			return {
-				friendStore: this.useFriendStore(),
-				userStore: this.useUserStore(),
 				searchText: "",
 				users: []
 			}

+ 0 - 1
im-uniapp/pages/friend/friend.vue

@@ -34,7 +34,6 @@
 	export default {
 		data() {
 			return {
-				friendStore: this.useFriendStore(),
 				searchText: ''
 			}
 		},

+ 0 - 3
im-uniapp/pages/group/group-edit.vue

@@ -30,9 +30,6 @@
 	export default {
 		data() {
 			return {
-				chatStore: this.useChatStore(),
-				groupStore: this.useGroupStore(),
-				userStore: this.useUserStore(),
 				group: {},
 				rules: {
 					name: {

+ 1 - 4
im-uniapp/pages/group/group-info.vue

@@ -31,7 +31,7 @@
 
 			<uni-section title="群名备注:" titleFontSize="14px">
 				<template v-slot:right>
-					<text class="detail-text"> {{group.showGroupName}}</text>
+					<text class="detail-text"> {{group.remarkGroupName}}</text>
 				</template>
 			</uni-section>
 			<uni-section title="我在本群的昵称:" titleFontSize="14px">
@@ -56,9 +56,6 @@
 	export default {
 		data() {
 			return {
-				chatStore: this.useChatStore(),
-				groupStore: this.useGroupStore(),
-				userStore: this.useUserStore(),
 				groupId: null,
 				group:{},
 				groupMembers: []

+ 0 - 1
im-uniapp/pages/group/group-invite.vue

@@ -30,7 +30,6 @@
 	export default {
 		data() {
 			return {
-				friendStore: this.useFriendStore(),
 				groupId: null,
 				searchText: "",
 				groupMembers: [],

+ 0 - 1
im-uniapp/pages/group/group-member.vue

@@ -29,7 +29,6 @@
 	export default {
 		data() {
 			return {
-				userStore: this.useUserStore(),
 				isModify: false,
 				searchText: "",
 				group: {},

+ 0 - 1
im-uniapp/pages/group/group.vue

@@ -27,7 +27,6 @@
 	export default {
 		data() {
 			return {
-				groupStore: this.useGroupStore(),
 				searchText: ""
 			}
 		},

+ 0 - 1
im-uniapp/pages/mine/mine-edit.vue

@@ -31,7 +31,6 @@
 	export default {
 		data() {
 			return {
-				userStore: this.useUserStore(),
 				userInfo: {}
 			}
 		},

+ 1 - 3
im-uniapp/pages/mine/mine.vue

@@ -34,9 +34,7 @@
 <script>
 	export default {
 		data() {
-			return {
-				userStore: this.useUserStore()
-			}
+			return {}
 		},
 		methods: {
 			onModifyInfo() {

+ 4 - 4
im-uniapp/store/chatStore.js

@@ -258,8 +258,8 @@ export default defineStore('chatStore', {
 		},
 		updateChatFromFriend(friend) {
 			let chat = this.findChatByFriend(friend.id)
-			if (chat.headImage != friend.headImageThumb ||
-				chat.showName != friend.nickName) {
+			if (chat && (chat.headImage != friend.headImageThumb ||
+				chat.showName != friend.nickName)) {
 				// 更新会话中的群名和头像
 				chat.headImage = friend.headImageThumb;
 				chat.showName = friend.nickName;
@@ -269,8 +269,8 @@ export default defineStore('chatStore', {
 		},
 		updateChatFromGroup(group) {
 			let chat = this.findChatByGroup(group.id);
-			if (chat.headImage != group.headImageThumb ||
-				chat.showName != group.showGroupName) {
+			if (chat && (chat.headImage != group.headImageThumb ||
+				chat.showName != group.showGroupName)) {
 				// 更新会话中的群名称和头像
 				chat.headImage = group.headImageThumb;
 				chat.showName = group.showGroupName;