acdr-ui/dist/dev/mp-weixin/store/message.js.map

1 line
2.0 KiB
Plaintext
Raw Normal View History

2024-09-19 07:20:14 +08:00
{"version":3,"file":"message.js","sources":["../../../../src/store/message.js"],"sourcesContent":["import { defineStore } from 'pinia'\r\nimport { ref, computed } from 'vue'\r\n\r\n// 初始化状态\r\nconst initState = {\r\n unreadMessages: [], // 未读消息列表\r\n readMessages: [], // 已读消息列表\r\n}\r\n\r\nexport const useMessageStore = defineStore('message', () => {\r\n const messages = ref({ ...initState })\r\n\r\n // 设置未读消息\r\n const setUnreadMessages = (newMessages) => {\r\n messages.value.unreadMessages = newMessages\r\n }\r\n\r\n // 标记消息为已读\r\n const markMessageAsRead = (messageId) => {\r\n const index = messages.value.unreadMessages.findIndex((msg) => msg.id === messageId)\r\n if (index !== -1) {\r\n const readMessage = messages.value.unreadMessages.splice(index, 1)[0]\r\n messages.value.readMessages.push(readMessage)\r\n }\r\n }\r\n\r\n // 获取未读消息数量\r\n const unreadCount = computed(() => messages.value.unreadMessages.length)\r\n\r\n // 清空所有消息(用于重置或清理)\r\n const clearMessages = () => {\r\n messages.value = { ...initState }\r\n }\r\n\r\n return {\r\n messages,\r\n setUnreadMessages,\r\n markMessageAsRead,\r\n unreadCount,\r\n clearMessages,\r\n }\r\n})\r\n"],"names":["defineStore","ref","computed"],"mappings":";;;;;;;;;;;;;;;;;;AAIA,MAAM,YAAY;AAAA,EAChB,gBAAgB,CAAE;AAAA;AAAA,EAClB,cAAc,CAAE;AAAA;AAClB;AAEY,MAAC,kBAAkBA,cAAAA,YAAY,WAAW,MAAM;AAC1D,QAAM,WAAWC,cAAAA,IAAI,mBAAK,UAAW;AAGrC,QAAM,oBAAoB,CAAC,gBAAgB;AACzC,aAAS,MAAM,iBAAiB;AAAA,EACjC;AAGD,QAAM,oBAAoB,CAAC,cAAc;AACvC,UAAM,QAAQ,SAAS,MAAM,eAAe,UAAU,CAAC,QAAQ,IAAI,OAAO,SAAS;AACnF,QAAI,UAAU,IAAI;AAChB,YAAM,cAAc,SAAS,MAAM,eAAe,OAAO,OAAO,CAAC,EAAE,CAAC;AACpE,eAAS,MAAM,aAAa,KAAK,WAAW;AAAA,IAC7C;AAAA,EACF;AAGD,QAAM,cAAcC,cAAAA,SAAS,MAAM,SAAS,MAAM,eAAe,MAAM;AAGvE,QAAM,gBAAgB,MAAM;AAC1B,aAAS,QAAQ,mBAAK;AAAA,EACvB;AAED,SAAO;AAAA,IACL;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACD;AACH,CAAC;;"}