fix: update

This commit is contained in:
Fine 2023-08-30 17:15:13 +08:00
parent d4e63a3df9
commit 30f67290ae
2 changed files with 7 additions and 9 deletions

View File

@ -22,7 +22,7 @@ limitations under the License. -->
:to="{ path: getName(path).path || '' }" :to="{ path: getName(path).path || '' }"
> >
<el-dropdown size="small" placement="bottom" :persistent="false"> <el-dropdown size="small" placement="bottom" :persistent="false">
<span class="cp">{{ getName(path).name }}</span> <span class="cp name">{{ getName(path).name }}</span>
<template #dropdown> <template #dropdown>
<el-dropdown-menu> <el-dropdown-menu>
<el-dropdown-item @click="setName(p)" v-for="(p, index) in path" :key="index"> <el-dropdown-item @click="setName(p)" v-for="(p, index) in path" :key="index">
@ -88,14 +88,12 @@ limitations under the License. -->
} }
function setName(item: any) { function setName(item: any) {
pathNames.value = pathNames.value.map((list: any[]) => { pathNames.value = pathNames.value.map((list: { path?: string; name: string; selected: boolean }[]) => {
const index = list.findIndex( const p = list.find((i: any) => i.entity === item.entity && item.layer === i.layer && i.name === item.name);
(i: any) => i.entity === item.entity && item.layer === i.layer && i.name === item.name, if (p) {
);
if (index > -1) {
list = list.map((d: any) => { list = list.map((d: any) => {
d.selected = false; d.selected = false;
if (d.entity === item.entity && item.layer === d.layer) { if (d.entity === item.entity && item.layer === d.layer && d.name === item.name) {
d.selected = true; d.selected = true;
} }
return d; return d;
@ -126,7 +124,7 @@ limitations under the License. -->
pageTitle.value = ""; pageTitle.value = "";
const dashboard = dashboardStore.currentDashboard; const dashboard = dashboardStore.currentDashboard;
if (!dashboard) { if (!(dashboard && dashboard.name)) {
updateNavTitle(); updateNavTitle();
return; return;
} }

View File

@ -112,7 +112,7 @@ limitations under the License. -->
} }
onUnmounted(() => { onUnmounted(() => {
dashboardStore.setCurrentDashboard(null); dashboardStore.setCurrentDashboard({});
}); });
return { return {