connectionStore.ts 685 B

123456789101112131415161718192021222324
  1. import { defineStore } from 'pinia'
  2. export const useConnectionStore = defineStore('connection', {
  3. state: () => {
  4. return {
  5. connectStatus: '正在连接后端服务器……',
  6. connectType: 'primary' as 'primary' | 'success' | 'danger',
  7. newConnect: false,
  8. }
  9. },
  10. actions: {
  11. setConnectStatus(connectStatus: string) {
  12. if (this.newConnect === true) return
  13. this.connectStatus = connectStatus
  14. },
  15. setConnectType(connectType: 'primary' | 'success' | 'danger') {
  16. if (this.newConnect === true) return
  17. this.connectType = connectType
  18. },
  19. setNewConnect(newConnect: boolean) {
  20. this.newConnect = newConnect
  21. },
  22. },
  23. })