feat: 后端国际化、pie图表准备

This commit is contained in:
chenjinsong
2021-06-22 21:19:04 +08:00
parent 5fa8c1d31d
commit b0d72f20e7
13 changed files with 173 additions and 72 deletions

View File

@@ -1,11 +1,17 @@
/**
* @author 陈劲松
* @date 2021/6/11
* @description 1.定义api2.定义通用查询函数,函数名应为 获取详情getItem、获取列表getItemList。例如getUser、getUserList
* @description 1.定义api2.定义通用查询方法,函数名应为 获取详情getItem、获取列表getItemList。例如getUser、getUserList
*/
import { get } from '@/utils/http'
import { get, post } from '@/utils/http'
import { sortByOrderNum } from '@/permission'
export const api = {
// 系统相关
permission: '/sys/user/permissions',
i18n: '/sys/i18n/lang',
dict: '/sys/dict',
// 业务
panel: '/visual/panel',
chart: '/visual/chart'
}
@@ -23,9 +29,13 @@ export async function getChartList (params) {
export async function getChart (id) {
return await getData(`${api.chart}/${id}`)
}
/* 字典 */
export async function getDictList (params) {
return await getData(api.dict, params, true)
}
export async function getData (url, params = {}, isQueryList) {
const request = new Promise((resolve, reject) => {
const request = new Promise(resolve => {
get(url, params).then(response => {
if (response.code === 200) {
resolve(isQueryList ? response.data.list : response.data)
@@ -34,3 +44,36 @@ export async function getData (url, params = {}, isQueryList) {
})
return await request
}
export async function getConfigJson () {
const request = new Promise(resolve => {
get(`${process.env.BASE_URL}config.json?Timestamp=${new Date().getTime()}`).then(config => {
resolve(config)
})
})
return await request
}
export async function getPermission () {
const request = new Promise(resolve => {
post(api.permission, { token: sessionStorage.getItem('cn-token') }).then(response => {
resolve({
menuList: sortByOrderNum(response.data.menus),
buttonList: response.data.buttons,
roleList: response.data.roles
})
})
})
return await request
}
export async function getI18n () {
const dictData = await getDictList()
const langs = dictData.map(d => d.value).join(',')
const request = new Promise(resolve => {
get(api.i18n, { l: langs }).then(response => {
resolve(response.data)
})
})
return await request
}