common.ts 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. /** @format */
  2. import { defineStore } from 'pinia'
  3. import { useUserStore } from './user'
  4. export const useCommonStore = defineStore(
  5. 'commonStore',
  6. () => {
  7. const navigateTextColor = ref('#ffffff')
  8. const navigateBgColor = ref('#0F0820')
  9. const isCompletedInfo = ref<boolean>(true) // 是否提交过的信息
  10. const loginType = ref<string>('choice')
  11. const downloadCatalog = ref<any>(null)
  12. const accountList = ref([
  13. {
  14. name: 'EJET Spark 12',
  15. email: '185@163.com',
  16. id: '1',
  17. },
  18. {
  19. name: 'EJET Spark 34',
  20. email: '18525917172@gmail.com',
  21. id: '2',
  22. },
  23. ])
  24. // const userStore = useUserStore()
  25. /**
  26. * 设置头部导航背景色
  27. */
  28. const setNavigateBgColor = (color: string) => {
  29. if (!color)
  30. return
  31. color = color.toUpperCase()
  32. if (color === '#0F0820') {
  33. navigateTextColor.value = '#ffffff'
  34. navigateBgColor.value = 'rgba(15,8,32, 0.7)'
  35. }
  36. else if (color === '#F3F4FB') {
  37. navigateTextColor.value = '#0F0820'
  38. navigateBgColor.value = 'rgba(243,244,251, 0.7)'
  39. }
  40. else if (color === '#FFFFFF') {
  41. navigateTextColor.value = '#0F0820'
  42. navigateBgColor.value = 'rgba(255, 255, 255, 0.7)'
  43. }
  44. }
  45. /**
  46. * 设置已经登陆的账号列表 (在登陆成功后调用)
  47. */
  48. const setAccountList = (list: any[]) => {
  49. if (!list || !Array.isArray(list))
  50. return
  51. accountList.value = list
  52. }
  53. const setLoginType = (type: string) => {
  54. if (!type)
  55. return
  56. loginType.value = type
  57. }
  58. /**
  59. * 设置当前的下载的目录数据
  60. */
  61. const setDownloadCatalog = (catalog: any) => {
  62. if (!catalog)
  63. return
  64. downloadCatalog.value = catalog
  65. }
  66. /**
  67. * 记录用户是否提交过信息
  68. */
  69. const setFilledInfo = (filled: boolean) => {
  70. // isCompletedInfo.value = filled
  71. }
  72. return {
  73. navigateTextColor,
  74. navigateBgColor,
  75. downloadCatalog,
  76. isCompletedInfo,
  77. setNavigateBgColor,
  78. setLoginType,
  79. accountList,
  80. loginType,
  81. setAccountList,
  82. setFilledInfo,
  83. setDownloadCatalog,
  84. }
  85. },
  86. {
  87. persist: true,
  88. },
  89. )