websocketStore.ts 583 B

123456789101112131415161718192021222324252627
  1. import { sendSock, createWebSocket, closeSock } from '@/utils/websocket.js';
  2. const websocketStore = defineStore('websocket', {
  3. state: () => ({
  4. webSocketList: {
  5. bizType: null,
  6. content: '',
  7. id: '',
  8. remindLevel: 0,
  9. senderId: null,
  10. type: 1,
  11. userId: null
  12. }
  13. }),
  14. actions: {
  15. init() {
  16. console.log('websocket init');
  17. createWebSocket(this.handleData);
  18. },
  19. handleData(res) {
  20. console.log('websocket handleData', res);
  21. Object.assign(this.webSocketList, res);
  22. }
  23. }
  24. });
  25. export default websocketStore;