feat: panel初始化,api提取
This commit is contained in:
35
src/views/charts/Panel.vue
Normal file
35
src/views/charts/Panel.vue
Normal file
@@ -0,0 +1,35 @@
|
||||
<template>
|
||||
<div>{{panel.name}}</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { useRoute } from 'vue-router'
|
||||
import { panelTypeAndRouteMapping } from '@/utils/constants'
|
||||
import { panel as api, getPanelList } from '@/utils/api'
|
||||
|
||||
export default {
|
||||
name: 'Panel',
|
||||
data () {
|
||||
return {
|
||||
panel: {}
|
||||
}
|
||||
},
|
||||
async mounted () {
|
||||
this.panel = (await getPanelList({ type: this.panelType }))[0]
|
||||
},
|
||||
setup () {
|
||||
// 取得panel的type
|
||||
let panelType = 1
|
||||
const { params } = useRoute()
|
||||
panelTypeAndRouteMapping[params.typeName] && (panelType = panelTypeAndRouteMapping[params.typeName])
|
||||
return {
|
||||
panelType,
|
||||
api
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style>
|
||||
|
||||
</style>
|
||||
Reference in New Issue
Block a user