fix rerender

This commit is contained in:
Qiuxia Fan 2022-03-17 16:17:10 +08:00
parent a23013bb28
commit 0cf2c15cdc
4 changed files with 14 additions and 7 deletions

View File

@ -42,6 +42,9 @@ onMounted(async () => {
setTimeout(() => {
const instance = getInstance();
if (!instance) {
return;
}
instance.on("click", (params: any) => {
emits("select", params);
});

View File

@ -141,10 +141,10 @@ export default defineComponent({
watch(
() => [props.data.metricTypes, props.data.metrics],
() => {
if (
dashboardStore.selectedGrid &&
props.data.i !== dashboardStore.selectedGrid.i
) {
if (!dashboardStore.selectedGrid) {
return;
}
if (props.data.i !== dashboardStore.selectedGrid.i) {
return;
}
if (TableChartTypes.includes(dashboardStore.selectedGrid.graph.type)) {

View File

@ -39,7 +39,7 @@ limitations under the License. -->
<div class="no-data-tips" v-else>Please add widgets.</div>
</template>
<script lang="ts">
import { defineComponent } from "vue";
import { defineComponent, onBeforeUnmount } from "vue";
import { useDashboardStore } from "@/store/modules/dashboard";
import { LayoutConfig } from "@/types/dashboard";
import controls from "../controls/index";
@ -56,6 +56,9 @@ export default defineComponent({
dashboardStore.activeGridItem(item.i);
dashboardStore.selectWidget(item);
}
onBeforeUnmount(() => {
dashboardStore.setLayout([]);
});
return {
dashboardStore,
layoutUpdatedEvent,

View File

@ -108,7 +108,8 @@ const selectorStore = useSelectorStore();
const appStore = useAppStoreWithOut();
const params = useRoute().params;
const type = EntityType.filter((d: Option) => d.value === params.entity)[0];
const toolIcons = ref<any[]>(PodRelationTools);
const toolIcons =
ref<{ name: string; content: string; id: string }[]>(PodRelationTools);
const states = reactive<{
destService: string;
destPod: string;
@ -129,6 +130,7 @@ const states = reactive<{
dashboardStore.setLayer(String(params.layerId));
dashboardStore.setEntity(String(params.entity));
appStore.setEventStack([initSelector]);
initSelector();
@ -423,7 +425,6 @@ function getTools() {
toolIcons.value = PodRelationTools;
}
}
appStore.setEventStack([initSelector]);
</script>
<style lang="scss" scoped>
.dashboard-tool {