feat: 后端国际化、pie图表准备
This commit is contained in:
@@ -1,11 +1,17 @@
|
||||
/**
|
||||
* @author 陈劲松
|
||||
* @date 2021/6/11
|
||||
* @description 1.定义api;2.定义通用查询函数,函数名应为 获取详情getItem、获取列表getItemList。例如getUser、getUserList
|
||||
* @description 1.定义api;2.定义通用查询方法,函数名应为 获取详情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
|
||||
}
|
||||
|
||||
@@ -1,5 +1,21 @@
|
||||
export const defaultPageSize = 20
|
||||
|
||||
export const storageKey = {
|
||||
i18n: 'cn-i18n',
|
||||
language: 'cn-language',
|
||||
timezone: 'cn-timezone',
|
||||
timezoneOffset: 'cn-timezone-offset',
|
||||
timezoneLocalOffset: 'cn-timezone-local-offset',
|
||||
token: 'cn-token',
|
||||
username: 'cn-username',
|
||||
sysName: 'cn-sys-name',
|
||||
sysLogo: 'cn-sys-logo',
|
||||
tableTitlePrefix: 'cn-table-title',
|
||||
tablePageSizePrefix: 'cn-page-size',
|
||||
leftMenuShrink: 'cn-left-menu-shrink',
|
||||
unsavedChange: 'cn-unsaved-change'
|
||||
}
|
||||
|
||||
// 统一定义跳转来源
|
||||
export const fromRoute = {
|
||||
trafficSummary: 'trafficSummary',
|
||||
@@ -22,4 +38,4 @@ export const position = {
|
||||
}
|
||||
|
||||
export const chartTableDefaultPageSize = 10 // table类型图表默认每页数据量
|
||||
export const chartTableTopOptions = [10, 50, 100] // table类型图表的TOP-N选项
|
||||
export const chartTableTopOptions = [10, 100] // table类型图表的TOP-N选项
|
||||
|
||||
Reference in New Issue
Block a user