diff --git a/src/stores/image.js b/src/stores/image.js index a385559..a0a111e 100644 --- a/src/stores/image.js +++ b/src/stores/image.js @@ -17,7 +17,12 @@ export const useImageStore = defineStore('anylink-image', () => { const image = ref({}) /** - * 在同一个session中的需要渲染的image对象数组 + * 在同一个session中的需要渲染的image对象 + * + * { + * sessionId_01: {objectId_x: {objectId: objectId_x, originUrl: xxx, thumbUrl: xxx}...}, + * sessionId_02: {objectId_x: {objectId: objectId_x, originUrl: xxx, thumbUrl: xxx}...}, + * } */ const imageInSession = ref({}) @@ -27,14 +32,14 @@ export const useImageStore = defineStore('anylink-image', () => { const setImageInSession = (sessionId, obj) => { if (!imageInSession.value[sessionId]) { - imageInSession.value[sessionId] = [] + imageInSession.value[sessionId] = {} } - imageInSession.value[sessionId].push(obj) + imageInSession.value[sessionId][obj.objectId] = obj } const clearImageInSession = (sessionId) => { if (imageInSession.value[sessionId]) { - imageInSession.value[sessionId] = [] + imageInSession.value[sessionId] = {} } } diff --git a/src/views/message/components/MsgBoxImage.vue b/src/views/message/components/MsgBoxImage.vue index f9c41de..95e0428 100644 --- a/src/views/message/components/MsgBoxImage.vue +++ b/src/views/message/components/MsgBoxImage.vue @@ -47,7 +47,7 @@ const url = computed(() => { }) const imageInSessionSort = computed(() => { - const imageList = imageData.imageInSession[props.sessionId] + const imageList = Object.values(imageData.imageInSession[props.sessionId]) return imageList.sort((a, b) => { const bTime = new Date(b.createdTime).getTime() const aTime = new Date(a.createdTime).getTime()