common.ts 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. /** @format */
  2. import { defineStore } from 'pinia'
  3. import { id } from 'element-plus/es/locales.mjs'
  4. import { useUserStore } from './user'
  5. export const useCommonStore = defineStore(
  6. 'commonStore',
  7. () => {
  8. const navigateTextColor = ref('#ffffff')
  9. const navigateBgColor = ref('#0F0820')
  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. * @returns
  28. */
  29. const setNavigateBgColor = (color: string) => {
  30. if (!color)
  31. return
  32. color = color.toUpperCase()
  33. if (color === '#0F0820') {
  34. navigateTextColor.value = '#ffffff'
  35. navigateBgColor.value = 'rgba(15,8,32, 0.7)'
  36. }
  37. else if (color === '#F3F4FB') {
  38. navigateTextColor.value = '#0F0820'
  39. navigateBgColor.value = 'rgba(243,244,251, 0.7)'
  40. }
  41. else if (color === '#FFFFFF') {
  42. navigateTextColor.value = '#0F0820'
  43. navigateBgColor.value = 'rgba(255, 255, 255, 0.7)'
  44. }
  45. }
  46. /**
  47. * 设置已经登陆的账号列表 (在登陆成功后调用)
  48. */
  49. const setAccountList = (list: any[]) => {
  50. if (!list || !Array.isArray(list))
  51. return
  52. accountList.value = list
  53. }
  54. const setLoginType = (type: string) => {
  55. if (!type)
  56. return
  57. loginType.value = type
  58. }
  59. /**
  60. * 设置当前的下载的目录数据
  61. */
  62. const setDownloadCatalog = (catalog: any) => {
  63. if (!catalog)
  64. return
  65. downloadCatalog.value = catalog
  66. }
  67. return {
  68. navigateTextColor,
  69. navigateBgColor,
  70. downloadCatalog,
  71. setNavigateBgColor,
  72. setLoginType,
  73. accountList,
  74. loginType,
  75. setAccountList,
  76. setDownloadCatalog,
  77. }
  78. },
  79. {
  80. persist: true,
  81. },
  82. )