fix
Some checks failed
Check / lint (push) Has been cancelled
Check / typecheck (push) Has been cancelled
Check / build (build, 18.x, ubuntu-latest) (push) Has been cancelled
Check / build (build, 18.x, windows-latest) (push) Has been cancelled
Check / build (build:app, 18.x, ubuntu-latest) (push) Has been cancelled
Check / build (build:app, 18.x, windows-latest) (push) Has been cancelled
Check / build (build:mp-weixin, 18.x, ubuntu-latest) (push) Has been cancelled
Check / build (build:mp-weixin, 18.x, windows-latest) (push) Has been cancelled
Some checks failed
Check / lint (push) Has been cancelled
Check / typecheck (push) Has been cancelled
Check / build (build, 18.x, ubuntu-latest) (push) Has been cancelled
Check / build (build, 18.x, windows-latest) (push) Has been cancelled
Check / build (build:app, 18.x, ubuntu-latest) (push) Has been cancelled
Check / build (build:app, 18.x, windows-latest) (push) Has been cancelled
Check / build (build:mp-weixin, 18.x, ubuntu-latest) (push) Has been cancelled
Check / build (build:mp-weixin, 18.x, windows-latest) (push) Has been cancelled
This commit is contained in:
parent
afc4d72db1
commit
0f8c0e4fa6
@ -167,11 +167,13 @@ class Talk extends Base {
|
|||||||
insertTalkRecord() {
|
insertTalkRecord() {
|
||||||
let record = this.resource
|
let record = this.resource
|
||||||
let newRecord = formatTalkRecord(this.getAccountId(), this.resource);
|
let newRecord = formatTalkRecord(this.getAccountId(), this.resource);
|
||||||
|
const {addDialogueRecord,addChatRecord} = useDialogueListStore()
|
||||||
// 群成员变化的消息,需要更新群成员列表
|
// 群成员变化的消息,需要更新群成员列表
|
||||||
if ([1102, 1103, 1104].includes(record.msg_type)) {
|
if ([1102, 1103, 1104].includes(record.msg_type)) {
|
||||||
useDialogueStore().updateGroupMembers()
|
useDialogueStore().updateGroupMembers()
|
||||||
}
|
}
|
||||||
useDialogueListStore().addDialogueRecord([newRecord],'add')
|
addDialogueRecord([newRecord],'add')
|
||||||
|
addChatRecord(this.getIndexName(),newRecord)
|
||||||
useDialogueStore().addDialogueRecord(newRecord)
|
useDialogueStore().addDialogueRecord(newRecord)
|
||||||
|
|
||||||
if (!this.isCurrSender()) {
|
if (!this.isCurrSender()) {
|
||||||
|
@ -3,18 +3,16 @@ import { ServeTalkRecords } from '@/api/chat'
|
|||||||
import { useDialogueStore, useDialogueListStore } from '@/store'
|
import { useDialogueStore, useDialogueListStore } from '@/store'
|
||||||
import { formatTalkRecord } from '@/utils/talk'
|
import { formatTalkRecord } from '@/utils/talk'
|
||||||
import { addClass, removeClass } from '@/utils/dom'
|
import { addClass, removeClass } from '@/utils/dom'
|
||||||
import { storeToRefs } from 'pinia'
|
|
||||||
|
|
||||||
export const useTalkRecord = (uid) => {
|
export const useTalkRecord = (uid) => {
|
||||||
const dialogueStore = useDialogueStore()
|
const dialogueStore = useDialogueStore()
|
||||||
const dialogueListStore = useDialogueListStore()
|
const { getDialogueList,addDialogueRecord,zpagingComplete } = useDialogueListStore()
|
||||||
const { getDialogueList } = storeToRefs(dialogueListStore)
|
|
||||||
const records = computed(() => {
|
const records = computed(() => {
|
||||||
const dialogueList = getDialogueList.value(dialogueStore.index_name)
|
const dialogueList = getDialogueList(dialogueStore.index_name)
|
||||||
if(dialogueList){
|
if(dialogueList){
|
||||||
return dialogueList.records
|
return dialogueList.records.toReversed()
|
||||||
}
|
}
|
||||||
return dialogueStore.records
|
return dialogueStore.records.toReversed()
|
||||||
} )
|
} )
|
||||||
|
|
||||||
const location = reactive({
|
const location = reactive({
|
||||||
@ -105,8 +103,9 @@ export const useTalkRecord = (uid) => {
|
|||||||
}
|
}
|
||||||
const reverseItems = items.toReversed()
|
const reverseItems = items.toReversed()
|
||||||
dialogueStore.unshiftDialogueRecord(reverseItems)
|
dialogueStore.unshiftDialogueRecord(reverseItems)
|
||||||
dialogueListStore.addDialogueRecord(params.direction=='down'?reverseItems:items,params.direction=='down'?'add':'unshift')
|
addDialogueRecord(params.direction=='down'?reverseItems:items,params.direction=='down'?'add':'unshift')
|
||||||
const dialogueList = getDialogueList.value(dialogueStore.index_name)
|
zpagingComplete(dialogueStore.index_name)
|
||||||
|
const dialogueList = getDialogueList(dialogueStore.index_name)
|
||||||
loadConfig.status = dialogueList.records[0].sequence > 1 ? 1 : 2
|
loadConfig.status = dialogueList.records[0].sequence > 1 ? 1 : 2
|
||||||
// loadConfig.cursor = data.cursor
|
// loadConfig.cursor = data.cursor
|
||||||
|
|
||||||
@ -132,7 +131,7 @@ export const useTalkRecord = (uid) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const onRefreshLoad = () => {
|
const onRefreshLoad = () => {
|
||||||
let dialogueList = getDialogueList.value(dialogueStore.index_name)
|
let dialogueList = getDialogueList(dialogueStore.index_name)
|
||||||
if (dialogueList.records[0].sequence === 1 ) {
|
if (dialogueList.records[0].sequence === 1 ) {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
@ -149,7 +148,7 @@ export const useTalkRecord = (uid) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const onLoad = async (params) => {
|
const onLoad = async (params) => {
|
||||||
let dialogueList = getDialogueList.value(params.index_name)
|
let dialogueList = getDialogueList(params.index_name)
|
||||||
if (!dialogueList) {
|
if (!dialogueList) {
|
||||||
loadConfig.cursor = 0
|
loadConfig.cursor = 0
|
||||||
}else{
|
}else{
|
||||||
|
@ -114,13 +114,13 @@ const choosePhoto = () => {
|
|||||||
if (item.type.indexOf('image/') === 0) {
|
if (item.type.indexOf('image/') === 0) {
|
||||||
console.log("进入图片")
|
console.log("进入图片")
|
||||||
let data = await onUploadImage(item)
|
let data = await onUploadImage(item)
|
||||||
return false;
|
// return false;
|
||||||
emit('selectImg', data)
|
emit('selectImg', data)
|
||||||
// if (src) {
|
// if (src) {
|
||||||
// quill.insertEmbed(index, 'image', src)
|
// quill.insertEmbed(index, 'image', src)
|
||||||
// quill.setSelection(index + 1)
|
// quill.setSelection(index + 1)
|
||||||
// }
|
// }
|
||||||
return
|
// return
|
||||||
}
|
}
|
||||||
|
|
||||||
if (item.type.indexOf('video/') === 0) {
|
if (item.type.indexOf('video/') === 0) {
|
||||||
|
@ -168,19 +168,17 @@ import emojiPanel from './components/emojiPanel.vue'
|
|||||||
import filePanel from './components/filePanel.vue'
|
import filePanel from './components/filePanel.vue'
|
||||||
import lodash from "lodash";
|
import lodash from "lodash";
|
||||||
import { ServePublishMessage } from '@/api/chat'
|
import { ServePublishMessage } from '@/api/chat'
|
||||||
import { storeToRefs } from 'pinia'
|
|
||||||
|
|
||||||
Quill.register('formats/emoji', EmojiBlot)
|
Quill.register('formats/emoji', EmojiBlot)
|
||||||
|
|
||||||
const dialogueListStore = useDialogueListStore()
|
const { getDialogueList,updateZpagingRef } = useDialogueListStore()
|
||||||
const { getDialogueList } = storeToRefs(dialogueListStore)
|
|
||||||
const talkStore = useTalkStore()
|
const talkStore = useTalkStore()
|
||||||
const settingsStore = useSettingsStore()
|
const settingsStore = useSettingsStore()
|
||||||
const userStore = useUserStore()
|
const userStore = useUserStore()
|
||||||
const dialogueStore = useDialogueStore()
|
const dialogueStore = useDialogueStore()
|
||||||
const editorDraftStore = useEditorDraftStore()
|
const editorDraftStore = useEditorDraftStore()
|
||||||
const editor = ref()
|
const editor = ref()
|
||||||
const zpagingRef = ref(null)
|
const zpagingRef = ref()
|
||||||
useZPaging(zpagingRef)
|
useZPaging(zpagingRef)
|
||||||
const indexName = computed(() => dialogueStore.index_name)
|
const indexName = computed(() => dialogueStore.index_name)
|
||||||
const talkParams = reactive({
|
const talkParams = reactive({
|
||||||
@ -305,11 +303,6 @@ const evnets = {
|
|||||||
|
|
||||||
const { loadConfig, records, onLoad, onRefreshLoad, onJumpMessage } = useTalkRecord(talkParams.uid)
|
const { loadConfig, records, onLoad, onRefreshLoad, onJumpMessage } = useTalkRecord(talkParams.uid)
|
||||||
|
|
||||||
// 添加计算属性来反转records数组
|
|
||||||
const reversedRecords = computed(() => {
|
|
||||||
return [...records.value].reverse()
|
|
||||||
})
|
|
||||||
|
|
||||||
const getQuill = () => {
|
const getQuill = () => {
|
||||||
return editor.value?.getQuill()
|
return editor.value?.getQuill()
|
||||||
}
|
}
|
||||||
@ -450,17 +443,15 @@ const virtualListChange = (vList) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
watch(() => reversedRecords.value, (newValue, oldValue) => {
|
watch(() => zpagingRef.value, (newValue, oldValue) => {
|
||||||
zpagingRef.value?.complete(newValue)
|
if (newValue) {
|
||||||
|
updateZpagingRef(newValue)
|
||||||
}, { deep: true, immediate: true })
|
|
||||||
|
|
||||||
onMounted(async() => {
|
|
||||||
const dialogueList = getDialogueList.value(talkParams.index_name)
|
|
||||||
if (dialogueList?.records?.length) {
|
|
||||||
debugger
|
|
||||||
zpagingRef.value?.complete(dialogueList.records)
|
|
||||||
}
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
const initData = async() => {
|
||||||
|
const dialogueList = getDialogueList(talkParams.index_name)
|
||||||
|
|
||||||
let objT = {
|
let objT = {
|
||||||
uid: talkParams.uid,
|
uid: talkParams.uid,
|
||||||
talk_type: talkParams.type,
|
talk_type: talkParams.type,
|
||||||
@ -469,7 +460,12 @@ onMounted(async() => {
|
|||||||
direction:dialogueList?'down':'up',
|
direction:dialogueList?'down':'up',
|
||||||
no_limit: dialogueList?1:0,
|
no_limit: dialogueList?1:0,
|
||||||
}
|
}
|
||||||
onLoad({ ...objT })
|
await onLoad({ ...objT })
|
||||||
|
// zpagingRef.value?.complete(records.value)
|
||||||
|
}
|
||||||
|
|
||||||
|
onMounted(async() => {
|
||||||
|
initData()
|
||||||
})
|
})
|
||||||
|
|
||||||
onUnmounted(() => {
|
onUnmounted(() => {
|
||||||
|
@ -4,7 +4,7 @@ import {uniStorage} from "@/utils/uniStorage.js"
|
|||||||
import {ref} from 'vue'
|
import {ref} from 'vue'
|
||||||
export const useAuth = createGlobalState(() => {
|
export const useAuth = createGlobalState(() => {
|
||||||
// const token = useStorage('token', '', uniStorage)
|
// const token = useStorage('token', '', uniStorage)
|
||||||
const token = ref('30119d9978a6f3321fb4779c0040e997df4dd0dd0cf6b71119657617d2249ed783f940b0050d5be7e758740ea467afdf3eeb4d28fb5ea234af60ebe51fb218ffea38d3362de44912166520e87a6f38dae8dda9ac1ca35393126a287143c4b6bf18216b911f8a76572c62563bf215ccfbf481b73f0bf6d5275d6ba21139798506790b4824a503c2fbbe8230a1118dd07583187e5c342dd8f8ca02f70dbd2dcea17ac3c5fbcf6e39893a63d2e79b34908949ce628eaede23e241afbcf5b83e01b9')
|
const token = ref('30119d9978a6f3321fb4779c0040e997df4dd0dd0cf6b71119657617d2249ed783f940b0050d5be7e758740ea467afdf3eeb4d28fb5ea234af60ebe51fb218ff6a0563074f3084b41c1bc8dc0733d06bfbb433a8d5a1d13eb6227adbf50a5da566a4cacdbf91899e563f10864fe2acfe62e0966fbd28506c80ffdda3f2f2f1cdf47228c1222630dd71bf9086f3fd73b23ac4fa18032fd834babe4ba7c7c210a329e9767e3e70b35f7745f2c84fda47c1c0ee95bdc6bf946fbef5927b397b37f7614b53736e13edef3e504c70124204b44913e3def0c87bf860be2788bf0360c3')
|
||||||
const refreshToken = useStorage('refreshToken', '', uniStorage)
|
const refreshToken = useStorage('refreshToken', '', uniStorage)
|
||||||
const userInfo = useStorage('userInfo', {}, uniStorage)
|
const userInfo = useStorage('userInfo', {}, uniStorage)
|
||||||
const leaderList = useStorage('leaderList', [], uniStorage)
|
const leaderList = useStorage('leaderList', [], uniStorage)
|
||||||
|
@ -2,78 +2,98 @@ import { defineStore } from 'pinia'
|
|||||||
import { useDialogueStore } from '@/store'
|
import { useDialogueStore } from '@/store'
|
||||||
import lodash from 'lodash'
|
import lodash from 'lodash'
|
||||||
|
|
||||||
export const useDialogueListStore = defineStore('dialogueList', {
|
import {ref} from 'vue'
|
||||||
persist: true,
|
import {createGlobalState,useStorage} from '@vueuse/core'
|
||||||
state: () => {
|
import {uniStorage} from "@/utils/uniStorage.js"
|
||||||
return {
|
|
||||||
dialogueList:[]
|
|
||||||
}
|
|
||||||
},
|
|
||||||
getters: {
|
|
||||||
getDialogueList:(state)=>{
|
|
||||||
return (indexName) => state.dialogueList.find(item=>item.index_name===indexName)
|
|
||||||
}
|
|
||||||
},
|
|
||||||
actions: {
|
|
||||||
// 添加对话
|
|
||||||
addDialogueRecord(newRecords,type='add') {
|
|
||||||
console.log(newRecords);
|
|
||||||
|
|
||||||
const dialogue = lodash.cloneDeep(useDialogueStore())
|
export const useDialogueListStore = createGlobalState(() => {
|
||||||
if (!dialogue || typeof dialogue !== 'object') return
|
const dialogueList = useStorage('dialogueList', [], uniStorage)
|
||||||
// 检查是否已存在相同 index_name 的对话
|
const zpagingRef = ref()
|
||||||
const existingIndex = this.$state.dialogueList.findIndex(item => item.index_name === dialogue.index_name)
|
|
||||||
if (existingIndex === -1) {
|
|
||||||
// 如果不存在,直接添加
|
|
||||||
this.$state.dialogueList.push(dialogue)
|
|
||||||
} else {
|
|
||||||
// 如果对话存在,处理 records 数组
|
|
||||||
const { records = [] } = dialogue
|
|
||||||
newRecords.forEach(newRecord => {
|
|
||||||
const recordIndex = this.$state.dialogueList[existingIndex].records.findIndex(
|
|
||||||
record => record.msg_id === newRecord.msg_id
|
|
||||||
)
|
|
||||||
|
|
||||||
if (recordIndex === -1) {
|
const getDialogueList=(indexName)=>{
|
||||||
// 如果记录不存在,添加到 records 数组
|
return dialogueList.value.find(item=>item.index_name===indexName)
|
||||||
if(type==='add'){
|
}
|
||||||
this.$state.dialogueList[existingIndex].records.push(newRecord)
|
|
||||||
}else{
|
const addDialogueRecord=(newRecords,type='add')=>{
|
||||||
this.$state.dialogueList[existingIndex].records.unshift(newRecord)
|
console.log(newRecords);
|
||||||
}
|
|
||||||
|
const dialogue = lodash.cloneDeep(useDialogueStore())
|
||||||
|
if (!dialogue || typeof dialogue !== 'object') return
|
||||||
|
// 检查是否已存在相同 index_name 的对话
|
||||||
|
const existingIndex = dialogueList.value.findIndex(item => item.index_name === dialogue.index_name)
|
||||||
|
if (existingIndex === -1) {
|
||||||
|
// 如果不存在,直接添加
|
||||||
|
dialogueList.value.push(dialogue)
|
||||||
|
} else {
|
||||||
|
// 如果对话存在,处理 records 数组
|
||||||
|
const { records = [] } = dialogue
|
||||||
|
newRecords.forEach(newRecord => {
|
||||||
|
const recordIndex = dialogueList.value[existingIndex].records.findIndex(
|
||||||
|
record => record.msg_id === newRecord.msg_id
|
||||||
|
)
|
||||||
|
|
||||||
|
if (recordIndex === -1) {
|
||||||
|
// 如果记录不存在,添加到 records 数组
|
||||||
|
if(type==='add'){
|
||||||
|
dialogueList.value[existingIndex].records.push(newRecord)
|
||||||
|
}else{
|
||||||
|
dialogueList.value[existingIndex].records.unshift(newRecord)
|
||||||
}
|
}
|
||||||
})
|
|
||||||
|
|
||||||
// 更新除 records 和 index_name 外的其他属性
|
|
||||||
const { index_name, records: _, ...updateProps } = dialogue
|
|
||||||
this.$state.dialogueList[existingIndex] = {
|
|
||||||
...this.$state.dialogueList[existingIndex],
|
|
||||||
...updateProps
|
|
||||||
}
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
// 更新除 records 和 index_name 外的其他属性
|
||||||
|
const { index_name, records: _, ...updateProps } = dialogue
|
||||||
|
dialogueList.value[existingIndex] = {
|
||||||
|
...dialogueList.value[existingIndex],
|
||||||
|
...updateProps
|
||||||
}
|
}
|
||||||
},
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// // 更新上传图片进度
|
const deleteDialogueRecord=(record)=>{
|
||||||
// updateUploadProgress(msgId,progress){
|
const dialogue = lodash.cloneDeep(useDialogueStore())
|
||||||
// console.log('updateUploadProgress');
|
const item = getDialogueList(dialogue.index_name)
|
||||||
|
const recordIndex = item.records.findIndex(item=>item.msg_id===record.msg_id)
|
||||||
|
if(recordIndex!==-1){
|
||||||
|
item.records.splice(recordIndex,1)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// const dialogue = lodash.cloneDeep(useDialogueStore())
|
const updateUploadProgress=(id,progress)=>{
|
||||||
// const item = this.getDialogueList(dialogue.index_name)
|
const dialogue = lodash.cloneDeep(useDialogueStore())
|
||||||
// const record = item.records.find(item=>item.msg_id===msgId)
|
const item = getDialogueList(dialogue.index_name)
|
||||||
// if(record){
|
const record = item.records.find(item=>item.msg_id===id)
|
||||||
// record.uploadCurrent = progress
|
if(record){
|
||||||
// console.log(record.uploadCurrent);
|
record.uploadCurrent = progress
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// }
|
const updateZpagingRef=(params)=>{
|
||||||
// }
|
zpagingRef.value=params
|
||||||
|
}
|
||||||
|
|
||||||
// 自增好友键盘输入事件
|
const zpagingComplete=(index_name)=>{
|
||||||
// triggerKeyboard() {
|
const item = getDialogueList(index_name)
|
||||||
// this.keyboard = true
|
zpagingRef.value?.complete(item.records.toReversed())
|
||||||
|
}
|
||||||
|
|
||||||
// clearTimeout(keyboardTimeout)
|
const addChatRecord = (indexName,item)=>{
|
||||||
|
const dialogue = lodash.cloneDeep(useDialogueStore())
|
||||||
|
if (dialogue?.index_name === indexName) {
|
||||||
|
zpagingRef.value?.addChatRecordData(item.records)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// keyboardTimeout = setTimeout(() => (this.keyboard = false), 2000)
|
return {
|
||||||
// },
|
dialogueList,
|
||||||
|
zpagingRef,
|
||||||
|
getDialogueList,
|
||||||
|
addDialogueRecord,
|
||||||
|
deleteDialogueRecord,
|
||||||
|
updateUploadProgress,
|
||||||
|
updateZpagingRef,
|
||||||
|
zpagingComplete,
|
||||||
|
addChatRecord,
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
@ -9,7 +9,6 @@ export const useTalkStore = defineStore('talk', {
|
|||||||
return {
|
return {
|
||||||
// 加载状态[1:未加载;2:加载中;3:加载完成;4:加载失败;]
|
// 加载状态[1:未加载;2:加载中;3:加载完成;4:加载失败;]
|
||||||
loadStatus: 2,
|
loadStatus: 2,
|
||||||
|
|
||||||
// 会话列表
|
// 会话列表
|
||||||
items: []
|
items: []
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user