Files
xk-doctor-wx/store/index.js
2026-06-01 13:24:36 +08:00

74 lines
1.3 KiB
JavaScript
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import Vue from 'vue'
import Vuex from 'vuex'
import { disconnectWebSocket } from '@/utils/ws/initWebSocket.js';
import {
registerList
} from '@/api/consult.js'
Vue.use(Vuex)
const store = new Vuex.Store({
state: {
utils: null,
consult: [], //咨询会话列表
docSession: [], //医生首页消息会话列表
status: 1
},
mutations: {
SET_CONSULT(state, res) {
state.consult = res;
},
SET_DOCSESSION(state, res) {
state.docSession = res;
},
},
actions: {
/**
* 登出
* 职责断开WebSocket连接清理状态
*/
logout({
state,
dispatch
}) {
dispatch('closeWebSocket');
},
/**
* 初始化(保留用于其他初始化逻辑)
* 注意WebSocket初始化已在App.vue中统一处理
*/
init({
state,
dispatch
}) {
// WebSocket初始化已移至App.vue这里保留其他初始化逻辑
// state.utils = new Utils()
// 获取会话列表
// dispatch('getSessionList')
},
/**
* 关闭WebSocket
* 职责断开WebSocket连接
*/
closeWebSocket() {
disconnectWebSocket();
},
// 获取挂号信息
getConsult({
state,
commit
}) {
registerList({
status: state.status,
page: 1
}).then(res => {
if (res.errcode == 0) {
commit('SET_CONSULT', res.data);
}
})
},
}
})
export default store