123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172 |
- import { defineStore } from "pinia";
- import router from "@/router";
- interface RecogFillSetType {
- fillColor: string;
- fillShow: boolean;
- unfillColor: string;
- unfillShow: boolean;
- borderWidth: number;
- }
- export const useUserStore = defineStore<
- "user",
- {
- curExam: Exam | null;
- imageCheckLoopTime: number;
- userInfo: any;
- recogFillSet: RecogFillSetType;
- },
- any,
- any
- >("user", {
- persist: [
- {
- storage: sessionStorage,
- paths: ["userInfo"],
- },
- {
- storage: localStorage,
- paths: ["curExam", "imageCheckLoopTime", "recogFillSet"],
- },
- ],
- state: () => ({
- userInfo: null,
- curExam: null,
- imageCheckLoopTime: 0,
- recogFillSet: {
- fillColor: "#f53f3f ",
- fillShow: true,
- unfillColor: "#165DFF",
- unfillShow: false,
- borderWidth: 2,
- },
- }),
- actions: {
- setUserInfo(info: any) {
- this.userInfo = info;
- },
- setCurExam(exam: Exam) {
- this.curExam = exam;
- },
- setImageCheckLoopTime(imageCheckLoopTime: number) {
- this.imageCheckLoopTime = imageCheckLoopTime;
- },
- setRecogFillSet(recogFillSet: RecogFillSetType) {
- this.recogFillSet = recogFillSet;
- },
- setState(data: any) {
- this.$patch(data);
- },
- resetUserInfo() {
- this.$reset();
- },
- async logout() {
- //todo 退出登录接口
- // await logout();
- this.setUserInfo(null);
- router.push({ name: "Login" });
- window.electronApi?.changeWinSize("small");
- },
- },
- });
|