Browse Source

代码优化

master
xsx 2 years ago
parent
commit
ea961d8f94
  1. 9
      im-uniapp/App.vue
  2. 1
      im-uniapp/components/chat-at-box/chat-at-box.vue
  3. 1
      im-uniapp/components/chat-group-readed/chat-group-readed.vue
  4. 1
      im-uniapp/components/group-rtc-join/group-rtc-join.vue
  5. 15
      im-uniapp/main.js
  6. 8
      im-uniapp/pages/chat/chat-box.vue
  7. 2
      im-uniapp/pages/chat/chat-group-video.vue
  8. 2
      im-uniapp/pages/chat/chat-private-video.vue
  9. 1
      im-uniapp/pages/chat/chat.vue
  10. 3
      im-uniapp/pages/common/user-info.vue
  11. 2
      im-uniapp/pages/friend/friend-add.vue
  12. 1
      im-uniapp/pages/friend/friend.vue
  13. 3
      im-uniapp/pages/group/group-edit.vue
  14. 5
      im-uniapp/pages/group/group-info.vue
  15. 1
      im-uniapp/pages/group/group-invite.vue
  16. 1
      im-uniapp/pages/group/group-member.vue
  17. 1
      im-uniapp/pages/group/group.vue
  18. 1
      im-uniapp/pages/mine/mine-edit.vue
  19. 4
      im-uniapp/pages/mine/mine.vue
  20. 8
      im-uniapp/store/chatStore.js

9
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();
//

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

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

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

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

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

15
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

8
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: {},

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,

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",

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

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

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: {}
}
},

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

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

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

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

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: {

5
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: []

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

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

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

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

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

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

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

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

4
im-uniapp/pages/mine/mine.vue

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

8
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;

Loading…
Cancel
Save