feat(projects): add websocket demo

This commit is contained in:
Soybean
2023-06-18 22:23:42 +08:00
parent de2829fde7
commit af53ec7625
8 changed files with 140 additions and 4 deletions

View File

@ -1,5 +1,6 @@
import { nextTick } from 'vue';
import { defineStore } from 'pinia';
import type { Socket } from 'socket.io-client';
import { LAYOUT_SCROLL_EL_ID } from '@soybeanjs/vue-materials';
interface AppState {
@ -17,6 +18,8 @@ interface AppState {
siderCollapse: boolean;
/** vertical-mix模式下 侧边栏的固定状态 */
mixSiderFixed: boolean;
/** socket.io 实例 */
socket: Socket | null;
}
export const useAppStore = defineStore('app-store', {
@ -27,7 +30,8 @@ export const useAppStore = defineStore('app-store', {
reloadFlag: true,
settingDrawerVisible: false,
siderCollapse: false,
mixSiderFixed: false
mixSiderFixed: false,
socket: null
}),
actions: {
/**
@ -97,6 +101,10 @@ export const useAppStore = defineStore('app-store', {
/** 设置主体内容全屏 */
setContentFull(full: boolean) {
this.contentFull = full;
},
/** 设置socket实例 */
setSocket<T extends Socket = Socket>(socket: T) {
this.socket = socket;
}
}
});