1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495 |
- /** @format */
- import { defineStore } from 'pinia'
- import { useUserStore } from './user'
- export const useCommonStore = defineStore(
- 'commonStore',
- () => {
- const navigateTextColor = ref('#ffffff')
- const navigateBgColor = ref('#0F0820')
- const isCompletedInfo = ref<boolean>(true) // 是否提交过的信息
- const loginType = ref<string>('choice')
- const downloadCatalog = ref<any>(null)
- const accountList = ref([
- {
- name: 'EJET Spark 12',
- email: '185@163.com',
- id: '1',
- },
- {
- name: 'EJET Spark 34',
- email: '18525917172@gmail.com',
- id: '2',
- },
- ])
- // const userStore = useUserStore()
- /**
- * 设置头部导航背景色
- */
- const setNavigateBgColor = (color: string) => {
- if (!color)
- return
- color = color.toUpperCase()
- if (color === '#0F0820') {
- navigateTextColor.value = '#ffffff'
- navigateBgColor.value = 'rgba(15,8,32, 0.7)'
- }
- else if (color === '#F3F4FB') {
- navigateTextColor.value = '#0F0820'
- navigateBgColor.value = 'rgba(243,244,251, 0.7)'
- }
- else if (color === '#FFFFFF') {
- navigateTextColor.value = '#0F0820'
- navigateBgColor.value = 'rgba(255, 255, 255, 0.7)'
- }
- }
- /**
- * 设置已经登陆的账号列表 (在登陆成功后调用)
- */
- const setAccountList = (list: any[]) => {
- if (!list || !Array.isArray(list))
- return
- accountList.value = list
- }
- const setLoginType = (type: string) => {
- if (!type)
- return
- loginType.value = type
- }
- /**
- * 设置当前的下载的目录数据
- */
- const setDownloadCatalog = (catalog: any) => {
- if (!catalog)
- return
- downloadCatalog.value = catalog
- }
- /**
- * 记录用户是否提交过信息
- */
- const setFilledInfo = (filled: boolean) => {
- // isCompletedInfo.value = filled
- }
- return {
- navigateTextColor,
- navigateBgColor,
- downloadCatalog,
- isCompletedInfo,
- setNavigateBgColor,
- setLoginType,
- accountList,
- loginType,
- setAccountList,
- setFilledInfo,
- setDownloadCatalog,
- }
- },
- {
- persist: true,
- },
- )
|