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 enums from './common/enums';
import * as wsApi from './common/wssocket'; import * as wsApi from './common/wssocket';
import UNI_APP from '@/.env.js' import UNI_APP from '@/.env.js'
import { getCurrentInstance } from 'vue'
export default { export default {
data() { data() {
return { return {
chatStore: this.useChatStore(),
friendStore: this.useFriendStore(),
groupStore: this.useGroupStore(),
configStore: this.useConfigStore(),
userStore: this.useUserStore(),
isExit: false, // 退 isExit: false, // 退
audioTip: null, audioTip: null,
reconnecting: false // reconnecting: false //
@ -355,10 +350,10 @@
} }
}, },
onLaunch() { onLaunch() {
this.$mountStore();
// //
let loginInfo = uni.getStorageSync("loginInfo") let loginInfo = uni.getStorageSync("loginInfo")
if (!this.isExpired(loginInfo)) { if (!this.isExpired(loginInfo)) {
console.log("初始化")
// //
this.init(); this.init();
// //

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

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

1
im-uniapp/components/chat-group-readed/chat-group-readed.vue

@ -37,7 +37,6 @@
name: "chat-group-readed", name: "chat-group-readed",
data() { data() {
return { return {
chatStore: this.useChatStore(),
items: ['已读', '未读'], items: ['已读', '未读'],
current: 0, current: 0,
readedMembers: [], readedMembers: [],

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

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

15
im-uniapp/main.js

@ -22,6 +22,7 @@ import * as recorder from './common/recorder-app';
// #endif // #endif
export function createApp() { export function createApp() {
const app = createSSRApp(App) const app = createSSRApp(App)
app.use(uviewPlus); app.use(uviewPlus);
@ -33,12 +34,14 @@ export function createApp() {
app.config.globalProperties.$enums = enums; app.config.globalProperties.$enums = enums;
app.config.globalProperties.$date = date; app.config.globalProperties.$date = date;
app.config.globalProperties.$rc = recorder; app.config.globalProperties.$rc = recorder;
app.config.globalProperties.useChatStore = useChatStore; // 初始化时再挂载store对象
app.config.globalProperties.useFriendStore = useFriendStore; app.config.globalProperties.$mountStore = ()=>{
app.config.globalProperties.useGroupStore = useGroupStore; app.config.globalProperties.chatStore = useChatStore();
app.config.globalProperties.useConfigStore = useConfigStore; app.config.globalProperties.friendStore = useFriendStore();
app.config.globalProperties.useUserStore = useUserStore; app.config.globalProperties.groupStore = useGroupStore();
app.config.globalProperties.configStore = useConfigStore();
app.config.globalProperties.userStore = useUserStore();
}
return { return {
app, app,
pinia pinia

8
im-uniapp/pages/chat/chat-box.vue

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

5
im-uniapp/pages/group/group-info.vue

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

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

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

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

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

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

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

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

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

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

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

8
im-uniapp/store/chatStore.js

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

Loading…
Cancel
Save