注册全局组件SVG,集成pinia,封装axios

This commit is contained in:
2024-08-08 19:08:15 +08:00
parent f0cc1b54c2
commit 74bd16dc51
31 changed files with 4753 additions and 122 deletions

View File

@@ -0,0 +1,14 @@
/**
* 本地缓存Key
*/
// 用户信息
export const USER_INFO = 'userInfo'
// WEB端布局配置
export const STORE_CONFIG = 'storeConfig'
// 后台标签页
export const STORE_TAB_VIEW_CONFIG = 'storeTabViewConfig'
// 字典
export const DICT_DATA = 'dictData'

View File

@@ -0,0 +1,3 @@
import { createPinia } from 'pinia'
const pinia = createPinia()
export default pinia

View File

@@ -0,0 +1,95 @@
// 变量名对应含义请在 /stores/* 里边找
import type { RouteRecordRaw, RouteLocationNormalized } from 'vue-router'
export interface Layout {
showDrawer: boolean
shrink: boolean
layoutMode: string
mainAnimation: string
isDark: boolean
menuWidth: number
menuDefaultIcon: string
menuCollapse: boolean
menuUniqueOpened: boolean
menuShowTopBar: boolean
elementUiPrimary: string[]
tableHeaderBackground: string[]
tableHeaderColor: string[]
tableCurrent: string[]
menuBackground: string[]
menuColor: string[]
menuActiveBackground: string[]
menuActiveColor: string[]
menuTopBarBackground: string[]
headerBarTabColor: string[]
headerBarBackground: string[]
headerBarHoverBackground: string[]
headerBarTabActiveBackground: string[]
headerBarTabActiveColor: string[]
}
export interface NavTabs {
activeIndex: number
activeRoute: RouteLocationNormalized | null
tabsView: RouteLocationNormalized[]
tabFullScreen: boolean
tabsViewRoutes: RouteRecordRaw[]
authNode: Map<string, string[]>
}
// 用户信息
export interface UserInfo {
access_token: string
token_type: string
refresh_token: string
expires_in: number
scope: string
nickname: string
userType: number
deptIndex: string
userIndex: string
client_id: string
headSculpture: any
jti: string
name: string
deptId: string
phone: string
email: string
limitIpStart: string
limitIpEnd: string
limitTime: string
casualUser: number
type: number
smsNotice: number
emailNotice: number
role: string[]
devCode: any
id: string
loginName: string
state: number
registerTime: string
loginTime: string
deptName: string
areaId: string
areaName: string
deptLevel: number
roleList: string[]
roleCode: string[]
}
// 字典数据
export interface DictData {
basic: BasicDictData[]
area: BasicDictData[]
areaTree: BasicDictData[]
userList: string[]
}
export interface BasicDictData {
name: string
id: string
code: string
value: null
sort: number | null
children?: BasicDictData[]
}

View File

@@ -0,0 +1,75 @@
import { defineStore } from 'pinia'
import { USER_INFO } from '@/stores/constant/cacheKey'
import type { UserInfo } from '@/stores/interface'
export const useUserInfoStore = defineStore('userInfo', {
// 行为
actions: {
dataFill(state: UserInfo) {
this.$state = { ...this.$state, ...state }
},
removeToken() {
this.access_token = ''
this.refresh_token = ''
},
setToken(token: string, type: 'auth' | 'refresh') {
const field = type == 'auth' ? 'token' : 'refresh_token'
this[field] = token
},
getToken(type: 'auth' | 'refresh' = 'auth') {
if (type === 'auth') {
if (this.token_type && this.access_token) {
return this.token_type + ' ' + this.access_token
} else {
return ''
}
} else {
return this.refresh_token
}
},
},
// 状态
state: (): UserInfo => {
return {
access_token: '',
token_type: '',
refresh_token: '',
expires_in: 0,
scope: '',
nickname: '',
userType: 0,
deptIndex: '',
userIndex: '',
client_id: '',
headSculpture: '',
jti: '',
name: '',
deptId: '',
phone: '',
email: '',
limitIpStart: '',
limitIpEnd: '',
limitTime: '',
casualUser: 0,
type: 0,
smsNotice: 0,
emailNotice: 0,
role: [],
devCode: '',
id: '',
loginName: '',
state: 0,
registerTime: '',
loginTime: '',
deptName: '',
areaId: '',
areaName: '',
deptLevel: 0,
roleList: [],
roleCode: [],
}
},
persist: {
key: USER_INFO,
},
})