feat: panel初始化,api提取
This commit is contained in:
27
src/utils/api.js
Normal file
27
src/utils/api.js
Normal file
@@ -0,0 +1,27 @@
|
||||
/**
|
||||
* @author 陈劲松
|
||||
* @date 2021/6/11
|
||||
* @description 1.定义api;2.定义通用查询函数,函数名应为 获取详情getItem、获取列表getItemList。例如getUser、getUserList
|
||||
*/
|
||||
import { get } from '@/utils/http'
|
||||
|
||||
export const panel = '/visual/panel'
|
||||
export const chart = '/visual/chart'
|
||||
|
||||
export async function getPanelList (params) {
|
||||
return await getData(panel, params, true)
|
||||
}
|
||||
export async function getPanel (url, params) {
|
||||
return await getData(panel, params)
|
||||
}
|
||||
|
||||
export async function getData (url, params, isQueryList) {
|
||||
const request = new Promise((resolve, reject) => {
|
||||
get(url, params).then(response => {
|
||||
if (response.code === 200) {
|
||||
resolve(isQueryList ? response.data.list : response.data)
|
||||
}
|
||||
})
|
||||
})
|
||||
return await request
|
||||
}
|
||||
@@ -3,9 +3,18 @@ export const defaultPageSize = 20
|
||||
// 统一定义跳转来源
|
||||
export const fromRoute = {
|
||||
trafficSummary: 'trafficSummary',
|
||||
networkAppPerformance: 'networkAppPerformance',
|
||||
dnsServiceInsights: 'dnsServiceInsights',
|
||||
user: 'user'
|
||||
}
|
||||
|
||||
/* panel类别和路由之间的映射 */
|
||||
export const panelTypeAndRouteMapping = {
|
||||
trafficSummary: 1,
|
||||
networkAppPerformance: 2,
|
||||
dnsServiceInsights: 3
|
||||
}
|
||||
|
||||
export const position = {
|
||||
tableHeight: {
|
||||
normal: 'calc(100% - 48px)' // 常规高度,特例在下方定义
|
||||
|
||||
Reference in New Issue
Block a user