update routesMap

This commit is contained in:
Qiuxia Fan 2022-03-23 13:00:31 +08:00
parent 92f142d9e1
commit 4fe4f83111
2 changed files with 14 additions and 56 deletions

View File

@ -73,7 +73,6 @@ export const dashboardStore = defineStore({
sessionStorage.setItem("dashboards", JSON.stringify(list)); sessionStorage.setItem("dashboards", JSON.stringify(list));
}, },
setCurrentDashboard(item: DashboardItem) { setCurrentDashboard(item: DashboardItem) {
console.log(item);
this.currentDashboard = item; this.currentDashboard = item;
}, },
addControl(type: string) { addControl(type: string) {

View File

@ -32,25 +32,25 @@ const route = useRoute();
const { t } = useI18n(); const { t } = useI18n();
const appStore = useAppStoreWithOut(); const appStore = useAppStoreWithOut();
const dashboardStore = useDashboardStore(); const dashboardStore = useDashboardStore();
const routeNames = [ const routesMap: { [key: string]: string } = {
"GeneralServices", GeneralServices: "GENERAL",
"Database", Database: "VIRTUAL_DATABASE",
"MeshServices", MESH: "MESH",
"ControlPanel", ControlPanel: "MESH_CP",
"DataPanel", DataPanel: "MESH_DP",
"Linux", Linux: "OS_LINUX",
"SkyWalkingServer", SkyWalkingServer: "SO11Y_OAP",
"Satellite", Satellite: "SO11Y_SATELLITE",
"Functions", Functions: "FAAS",
"Browser", Browser: "BROWSER",
"Kubernetes", Kubernetes: "K8S",
]; };
const layer = ref<string>("GENERAL"); const layer = ref<string>("GENERAL");
getDashboard(); getDashboard();
async function getDashboard() { async function getDashboard() {
setLayer(String(route.name)); layer.value = routesMap[String(route.name)];
dashboardStore.setLayer(layer.value); dashboardStore.setLayer(layer.value);
dashboardStore.setEntity(EntityType[1].value); dashboardStore.setEntity(EntityType[1].value);
dashboardStore.setMode(false); dashboardStore.setMode(false);
@ -69,47 +69,6 @@ async function getDashboard() {
const item = dashboardStore.dashboards[index]; const item = dashboardStore.dashboards[index];
dashboardStore.setCurrentDashboard(item); dashboardStore.setCurrentDashboard(item);
} }
function setLayer(n: string) {
switch (n) {
case routeNames[0]:
layer.value = "GENERAL";
break;
case routeNames[1]:
layer.value = "VIRTUAL_DATABASE";
break;
case routeNames[2]:
layer.value = "MESH";
break;
case routeNames[3]:
layer.value = "MESH_CP";
break;
case routeNames[4]:
layer.value = "MESH_DP";
break;
case routeNames[5]:
layer.value = "OS_LINUX";
break;
case routeNames[6]:
layer.value = "SO11Y_OAP";
break;
case routeNames[7]:
layer.value = "SO11Y_SATELLITE";
break;
case routeNames[8]:
layer.value = "FAAS";
break;
case routeNames[9]:
layer.value = "BROWSER";
break;
case routeNames[10]:
layer.value = "K8S";
break;
default:
layer.value = "GENERAL";
break;
}
}
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>
.no-root { .no-root {