diff --git a/src/api/login.ts b/src/api/login.ts index 71a2340..ed0a9da 100644 --- a/src/api/login.ts +++ b/src/api/login.ts @@ -1,6 +1,7 @@ import * as other from "@/utils/other"; import {ElMessage} from "element-plus"; import request, {CommonHeaderEnum, postData} from "@/utils/request"; +import { Local, Session } from "@/utils/storage"; const registerUrl = "/admin/register/user" @@ -8,6 +9,9 @@ const logoutUrl = "/admin/token/logout" export const login = (data: any) => { return new Promise(resolve => { + Local.clear() + Session.clear() + const basicAuth = 'Basic ' + window.btoa(import.meta.env.VITE_OAUTH2_PASSWORD_CLIENT); let encPassword = data.password; diff --git a/src/api/user.ts b/src/api/user.ts index b83ec01..aafecc7 100644 --- a/src/api/user.ts +++ b/src/api/user.ts @@ -66,7 +66,7 @@ export function userPage(data: any) { }).then((res: any) => { resolve(res.data) }).catch(err => { - console.log(err) + resolve(err) }) }) } @@ -77,7 +77,7 @@ export function userList(data: any): Promise { .then((res: any) => { resolve(res.data) }).catch(err => { - console.log(err) + resolve(err) }) }) } diff --git a/src/stores/remote-ws-store.ts b/src/stores/remote-ws-store.ts index cf2a01f..02307e2 100644 --- a/src/stores/remote-ws-store.ts +++ b/src/stores/remote-ws-store.ts @@ -1,5 +1,5 @@ import { defineStore } from "pinia"; -import { Local, Session } from "@/utils/storage"; +import { Session } from "@/utils/storage"; const vitalUrl = "ws://localhost:5173/socket.io/admin/rax/vitalSignsMedicine?token=" + Session.getToken() const medicineUrl = "ws://localhost:5173/socket.io/admin/rax/addMedicine?token=" + Session.getToken() @@ -11,7 +11,7 @@ export const useRemoteWsStore = defineStore("remoteWs", { patient: {} as any, remoteTasks: [] as any, remoteTasksCap: 10, - currentTaskIndex: 0, + currentTaskIndex: -1, varMedicine: ["丙泊酚", "舒芬太尼", "瑞芬太尼", "顺阿曲库胺"], fixedMedicine: ["尼卡地平", "艾司洛尔", "麻黄素", "阿托品"], exceptionType: ["BIS_except", "DBP_except", "EtCO2_except", "HR_except", "SBP_except", "ST_except"], @@ -24,26 +24,26 @@ export const useRemoteWsStore = defineStore("remoteWs", { actions: { setCurrentTaskIndex(i: number) { this.currentTaskIndex = i - Local.set("currentTaskIndex", i) + Session.set("currentTaskIndex", i) }, getCurrentTaskIndex() { - if (Local.get("currentTaskIndex")) { - this.currentTaskIndex = Local.get("currentTaskIndex") + if (Session.get("currentTaskIndex")) { + this.currentTaskIndex = Session.get("currentTaskIndex") } return this.currentTaskIndex }, setRemoteTask() { - Local.set("remoteTasks", this.remoteTasks) + Session.set("remoteTasks", this.remoteTasks) }, getRemoteTask() { - if (Local.get("remoteTasks")) { - this.remoteTasks = Local.get("remoteTasks") + if (Session.get("remoteTasks")) { + this.remoteTasks = Session.get("remoteTasks") } return this.remoteTasks }, initRemoteTask() { - if (Local.get("remoteTasks")) { - this.remoteTasks = Local.get("remoteTasks") + if (Session.get("remoteTasks")) { + this.remoteTasks = Session.get("remoteTasks") } if (this.remoteTasks.length <= 0) { for (let i = 0; i < 10; i++) { @@ -79,7 +79,7 @@ export const useRemoteWsStore = defineStore("remoteWs", { index: i, message: [] }) - Local.set("remoteTasks", this.remoteTasks) + Session.set("remoteTasks", this.remoteTasks) }, getActiveRemoteTask() { for (let i = 0; i < this.remoteTasks.length; i++) { @@ -89,8 +89,8 @@ export const useRemoteWsStore = defineStore("remoteWs", { setRemoteLog(log: any, i: number) { this.remoteTasks[i].log.push(log) }, - createConnect(name: string, id: string, date: string) { - if (!this.patient[name + id + date]) { + createConnect(name: string, id: string, date: string, index: number) { + if (!this.patient[name + id + date + index]) { const vitalWS = new WebSocket(vitalUrl) const medicineWS = new WebSocket(medicineUrl) const chatWS = new WebSocket(chatUrl) @@ -115,42 +115,42 @@ export const useRemoteWsStore = defineStore("remoteWs", { date: date })) } - this.patient[name + id + date] = { + this.patient[name + id + date + index] = { vitalWS, medicineWS, chatWS } } }, - disconnect(name: string, id: string, date: string) { - const patient: any = this.patient[name + id + date] + disconnect(name: string, id: string, date: string, index: number) { + const patient: any = this.patient[name + id + date + index] if (patient) { patient.vitalWS.close() patient.medicineWS.close() patient.chatWS.close() - delete this.patient[name + id + date] + delete this.patient[name + id + date + index] } }, - subscribeVital(name: string, id: string, date: string, cb: any) { - const patient: any = this.patient[name + id + date] + subscribeVital(name: string, id: string, date: string, index: number, cb: any) { + const patient: any = this.patient[name + id + date + index] if (patient) { patient.vitalWS.onmessage = cb patient.vitalCB = cb } else { - this.createConnect(name, id, date) - this.patient[name + id + date].vitalWS.onmessage = cb - this.patient[name + id + date].vitalCB = cb + this.createConnect(name, id, date, index) + this.patient[name + id + date + index].vitalWS.onmessage = cb + this.patient[name + id + date + index].vitalCB = cb } }, - unsubscribeVital(name: string, id: string, date: string) { - const patient: any = this.patient[name + id + date] + unsubscribeVital(name: string, id: string, date: string, index: number) { + const patient: any = this.patient[name + id + date + index] if (patient && patient.vitalWS) { patient.vitalWS.onmessage = undefined; patient.vitalCB = undefined; } }, - sendMsg(name: string, id: string, date: string, msg: string, cb: any) { - const patient: any = this.patient[name + id + date] + sendMsg(name: string, id: string, date: string, msg: string, index: number, cb: any) { + const patient: any = this.patient[name + id + date + index] if (patient) { const params = { patientName: name, @@ -169,8 +169,8 @@ export const useRemoteWsStore = defineStore("remoteWs", { }) } }, - subscribeChat(name: string, id: string, date: string, cb: any) { - const patient: any = this.patient[name + id + date] + subscribeChat(name: string, id: string, date: string, index: number, cb: any) { + const patient: any = this.patient[name + id + date + index] if (patient) { patient.chatCB = cb patient.chatWS.onmessage = cb @@ -181,8 +181,8 @@ export const useRemoteWsStore = defineStore("remoteWs", { }) } }, - unsubscribeChat(name: string, id: string, date: string) { - const patient: any = this.patient[name + id + date] + unsubscribeChat(name: string, id: string, date: string, index: number) { + const patient: any = this.patient[name + id + date + index] patient.chatCB = undefined; patient.chatWS.onmessage = undefined; }, @@ -193,8 +193,8 @@ export const useRemoteWsStore = defineStore("remoteWs", { flag: string, medicine: string, value: string - }, cb: any) { - const patient: any = this.patient[args.name + args.id + args.date] + }, index: number, cb: any) { + const patient: any = this.patient[args.name + args.id + args.date + index] if (patient) { const params = { patientName: args.name, @@ -215,8 +215,8 @@ export const useRemoteWsStore = defineStore("remoteWs", { }) } }, - subscribeMedicine(name: string, id: string, date: string, cb: any) { - const patient = this.patient[name + id + date] + subscribeMedicine(name: string, id: string, date: string, index: number, cb: any) { + const patient = this.patient[name + id + date + index] if (patient) { patient.medicineCB = cb patient.medicineWS.onmessage = cb @@ -227,8 +227,8 @@ export const useRemoteWsStore = defineStore("remoteWs", { }) } }, - unsubscribeMedicine(name: string, id: string, date: string) { - const patient: any = this.patient[name + id + date] + unsubscribeMedicine(name: string, id: string, date: string, index: number) { + const patient: any = this.patient[name + id + date + index] patient.medicineCB = undefined; patient.medicineWS.onmessage = undefined; } diff --git a/src/stores/user-info-store.ts b/src/stores/user-info-store.ts index 9346810..3ee9e5d 100644 --- a/src/stores/user-info-store.ts +++ b/src/stores/user-info-store.ts @@ -1,6 +1,6 @@ import {defineStore} from 'pinia' import {getUserMenu} from "@/api/menu"; -import {Session} from "@/utils/storage"; +import {Local, Session} from "@/utils/storage"; import router from "@/router"; export const useUserStore = defineStore('login', { @@ -37,6 +37,7 @@ export const useUserStore = defineStore('login', { }, logout() { Session.clear(); + Local.clear(); router.removeRoute("root"); router.addRoute({ name: "root", diff --git a/src/views/home/index.vue b/src/views/home/index.vue index d52818c..efd8787 100644 --- a/src/views/home/index.vue +++ b/src/views/home/index.vue @@ -5,8 +5,8 @@
-

【{{ item.category }}】 {{ item.message }}

+

【{{ item.category }}】 {{ item.message }}

@@ -17,7 +17,7 @@
- +

待办任务

@@ -27,22 +27,22 @@
- +
- +
- +
- +
- +
@@ -50,51 +50,18 @@ 更多
- +
- -
- - -

{{ item.message }}

- -
-
- - -