feat(修改ico,logo,菜单管理crud基本功能完成): 🐛 修复登录未使用MD5
This commit is contained in:
52
web/src/stores/dictionary.ts
Normal file
52
web/src/stores/dictionary.ts
Normal file
@@ -0,0 +1,52 @@
|
||||
import { defineStore } from 'pinia';
|
||||
import { DictionaryStates } from './interface';
|
||||
import { request } from '../utils/service';
|
||||
|
||||
export const urlPrefix = '/api/init/dictionary/'
|
||||
export const BUTTON_VALUE_TO_COLOR_MAPPING: any = {
|
||||
1: 'success',
|
||||
true: 'success',
|
||||
0: 'danger',
|
||||
false: 'danger',
|
||||
Search: 'warning', // 查询
|
||||
Update: 'primary', // 编辑
|
||||
Create: 'success', // 新增
|
||||
Retrieve: 'info', // 单例
|
||||
Delete: 'danger' // 删除
|
||||
}
|
||||
|
||||
export function getButtonSettings(objectSettings: any) {
|
||||
return objectSettings.map((item: any) => ({
|
||||
label: item.label,
|
||||
value: item.value,
|
||||
color: item.color || BUTTON_VALUE_TO_COLOR_MAPPING[item.value]
|
||||
}))
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 字典管理数据
|
||||
* @methods getSystemDictionarys 获取系统字典数据
|
||||
*/
|
||||
export const DictionaryStore = defineStore('Dictionary', {
|
||||
state: (): DictionaryStates => ({
|
||||
data: {}
|
||||
}),
|
||||
actions: {
|
||||
async getSystemDictionarys() {
|
||||
request({
|
||||
url: '/api/init/dictionary/?dictionary_key=all',
|
||||
method: 'get',
|
||||
}).then((ret: {
|
||||
data: []
|
||||
}) => {
|
||||
// 转换数据格式并保存到pinia
|
||||
let dataList = ret.data
|
||||
dataList.forEach((item: any) => {
|
||||
let childrens = item.children
|
||||
this.data[item.value] = childrens
|
||||
})
|
||||
})
|
||||
},
|
||||
},
|
||||
});
|
||||
@@ -25,8 +25,8 @@ export const useUserInfo = defineStore('userInfo', {
|
||||
this.userInfos = Session.get('userInfo');
|
||||
} else {
|
||||
let userInfos: any = await this.getApiUserInfo();
|
||||
this.userInfos.userName = userInfos.name;
|
||||
this.userInfos.photo = userInfos.avatar || 'https://img2.baidu.com/it/u=1978192862,2048448374&fm=253&fmt=auto&app=138&f=JPEG?w=504&h=500'
|
||||
this.userInfos.userName = userInfos.data.name;
|
||||
this.userInfos.photo = userInfos.data.avatar || 'https://img2.baidu.com/it/u=1978192862,2048448374&fm=253&fmt=auto&app=138&f=JPEG?w=504&h=500'
|
||||
this.userInfos.time = new Date().getTime()
|
||||
this.userInfos.roles = ['admin']
|
||||
Session.set('userInfo', this.userInfos)
|
||||
|
||||
Reference in New Issue
Block a user