123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475 |
- /** @format */
- import { defineStore } from 'pinia'
- import { id } from 'element-plus/es/locales.mjs'
- import { useUserStore } from './user'
- export const useCommonStore = defineStore(
- 'commonStore',
- () => {
- const navigateTextColor = ref('#ffffff')
- const navigateBgColor = ref('#0F0820')
- const loginType = ref<string>('choice')
- 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()
- /**
- * 设置头部导航背景色
- * @returns
- */
- 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
- }
- return {
- navigateTextColor,
- navigateBgColor,
- setNavigateBgColor,
- setLoginType,
- accountList,
- loginType,
- setAccountList,
- }
- },
- {
- persist: true,
- },
- )
|