imageInSession的结构重构

This commit is contained in:
bob
2025-05-13 16:43:16 +08:00
parent 653bbccb24
commit ad0d0ad7a0
2 changed files with 10 additions and 5 deletions

View File

@@ -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] = {}
}
}

View File

@@ -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()