msg.ts 571 B

1234567891011121314151617181920212223242526
  1. import { defineStore } from 'pinia'
  2. import { useIndexedDBStore } from './indexedDB'
  3. export const useMsgStore = defineStore('msg', {
  4. state: () => ({
  5. msgUuid: <string>'',
  6. messages: <any[]>[],
  7. pageInfoList: []
  8. }),
  9. actions: {
  10. addMsg(msg: any) {
  11. const { useStore } = useIndexedDBStore()
  12. useStore(this.msgUuid).add(msg)
  13. this.messages.push(msg)
  14. },
  15. addMsg1(msg: any) {
  16. this.messages.push(msg)
  17. },
  18. msgToDB(msg: any) {
  19. const { useStore } = useIndexedDBStore()
  20. useStore(this.msgUuid).add(msg)
  21. }
  22. }
  23. })