userInfo.ts 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. //引入pinia
  2. import { defineStore } from 'pinia'
  3. import { ref } from 'vue'
  4. const userInfoStore = defineStore(
  5. 'userInfo',
  6. () => {
  7. //定义正在进行中的计划
  8. const planCurrentNum = ref<number>(0)
  9. //定义已完成但是未读的测试记录
  10. const unreadNum = ref<number>(0)
  11. //定义token
  12. const token = ref<string>('')
  13. //定义用户信息
  14. const userInfo = ref<any>({
  15. account: ''
  16. })
  17. //信息--查看是否做过了练习测试
  18. //这个是形状知觉测试的练习测试通过标志
  19. const isPass = ref<boolean>(false)
  20. //这个是人脸测试通过的标志
  21. const isPassETB01 = ref<boolean>(false)
  22. //这是点探测的标志
  23. const isPassDot = ref<boolean>(false)
  24. //将通过状态改变为通过false
  25. const saveIspass = (flag: string) => {
  26. //这个是形状知觉的练习测试通过标志
  27. if (flag == '') {
  28. isPass.value = true;
  29. } else if (flag == 'ETB01') {
  30. isPassETB01.value = true;
  31. } else if (flag == 'FDOT') {
  32. isPassDot.value = true
  33. }
  34. }
  35. //保存正在进行中的计划的文本
  36. const savePlanCurrentNum = (val: number) => {
  37. planCurrentNum.value = val
  38. }
  39. //保存已完成的测试记录-但是未读的
  40. const saveUnreadNum = (val: number) => {
  41. unreadNum.value = val;
  42. }
  43. //保存token信息
  44. const saveToken = (val: string) => {
  45. token.value = val
  46. }
  47. //保存用户信息
  48. const saveUserInfo = (val: any) => {
  49. //重置用户信息
  50. userInfo.value = val
  51. }
  52. //清除用户信息
  53. const clearUserInfo = () => {
  54. userInfo.value = { account: '' }
  55. token.value = ''
  56. isPass.value = false
  57. isPassETB01.value = false
  58. isPassDot.value = false
  59. planCurrentNum.value = 0
  60. unreadNum.value = 0
  61. }
  62. return { planCurrentNum, clearUserInfo, savePlanCurrentNum, token, saveToken, userInfo, saveUserInfo, isPass, isPassETB01, isPassDot, saveIspass, unreadNum, saveUnreadNum }
  63. },
  64. { persist: true }
  65. )
  66. export { userInfoStore }