|
@@ -1,6 +1,9 @@
|
|
import { defineStore } from "pinia";
|
|
import { defineStore } from "pinia";
|
|
import router from "@/router";
|
|
import router from "@/router";
|
|
|
|
+import { adminLogout, heatBeatApi } from "@/ap/system";
|
|
|
|
+import HeatBeatWorker from "@/utils/heatbeat.worker?worker";
|
|
|
|
|
|
|
|
+const heatBeatWorker = new HeatBeatWorker();
|
|
interface RecogFillSetType {
|
|
interface RecogFillSetType {
|
|
fillColor: string;
|
|
fillColor: string;
|
|
fillShow: boolean;
|
|
fillShow: boolean;
|
|
@@ -12,6 +15,7 @@ interface RecogFillSetType {
|
|
export const useUserStore = defineStore<
|
|
export const useUserStore = defineStore<
|
|
"user",
|
|
"user",
|
|
{
|
|
{
|
|
|
|
+ heatBeatWorker: Worker | null;
|
|
curExam: Exam | null;
|
|
curExam: Exam | null;
|
|
imageCheckLoopTime: number;
|
|
imageCheckLoopTime: number;
|
|
userInfo: any;
|
|
userInfo: any;
|
|
@@ -31,6 +35,8 @@ export const useUserStore = defineStore<
|
|
},
|
|
},
|
|
],
|
|
],
|
|
state: () => ({
|
|
state: () => ({
|
|
|
|
+ heatBeatWorker: null,
|
|
|
|
+ heatBeatIsActive: false,
|
|
userInfo: null,
|
|
userInfo: null,
|
|
curExam: null,
|
|
curExam: null,
|
|
imageCheckLoopTime: 0,
|
|
imageCheckLoopTime: 0,
|
|
@@ -43,8 +49,27 @@ export const useUserStore = defineStore<
|
|
},
|
|
},
|
|
}),
|
|
}),
|
|
actions: {
|
|
actions: {
|
|
|
|
+ initHeatBeat() {
|
|
|
|
+ this.heatBeatWorker = new HeatBeatWorker();
|
|
|
|
+ this.heatBeatWorker.onmessage = (e: any) => {
|
|
|
|
+ const data = e.data;
|
|
|
|
+ if (typeof e.data === "boolean") {
|
|
|
|
+ this.heatBeatIsActive = !!data;
|
|
|
|
+ } else if (e.data === "") {
|
|
|
|
+ heatBeatApi();
|
|
|
|
+ }
|
|
|
|
+ };
|
|
|
|
+ },
|
|
|
|
+ startHeatBeat() {
|
|
|
|
+ this.heatBeatWorker.postMessage(true);
|
|
|
|
+ },
|
|
setUserInfo(info: any) {
|
|
setUserInfo(info: any) {
|
|
this.userInfo = info;
|
|
this.userInfo = info;
|
|
|
|
+ if (!info) {
|
|
|
|
+ this.heatBeatWorker.postMessage(false);
|
|
|
|
+ } else {
|
|
|
|
+ this.heatBeatWorker.postMessage(true);
|
|
|
|
+ }
|
|
},
|
|
},
|
|
setCurExam(exam: Exam) {
|
|
setCurExam(exam: Exam) {
|
|
this.curExam = exam;
|
|
this.curExam = exam;
|
|
@@ -62,8 +87,7 @@ export const useUserStore = defineStore<
|
|
this.$reset();
|
|
this.$reset();
|
|
},
|
|
},
|
|
async logout() {
|
|
async logout() {
|
|
- //todo 退出登录接口
|
|
|
|
- // await logout();
|
|
|
|
|
|
+ await adminLogout();
|
|
this.setUserInfo(null);
|
|
this.setUserInfo(null);
|
|
router.push({ name: "Login" });
|
|
router.push({ name: "Login" });
|
|
window.electronApi?.changeWinSize("small");
|
|
window.electronApi?.changeWinSize("small");
|