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(() => { setTimeout(() => {
const instance = getInstance(); const instance = getInstance();
if (!instance) {
return;
}
instance.on("click", (params: any) => { instance.on("click", (params: any) => {
emits("select", params); emits("select", params);
}); });

View File

@ -141,10 +141,10 @@ export default defineComponent({
watch( watch(
() => [props.data.metricTypes, props.data.metrics], () => [props.data.metricTypes, props.data.metrics],
() => { () => {
if ( if (!dashboardStore.selectedGrid) {
dashboardStore.selectedGrid && return;
props.data.i !== dashboardStore.selectedGrid.i }
) { if (props.data.i !== dashboardStore.selectedGrid.i) {
return; return;
} }
if (TableChartTypes.includes(dashboardStore.selectedGrid.graph.type)) { 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> <div class="no-data-tips" v-else>Please add widgets.</div>
</template> </template>
<script lang="ts"> <script lang="ts">
import { defineComponent } from "vue"; import { defineComponent, onBeforeUnmount } from "vue";
import { useDashboardStore } from "@/store/modules/dashboard"; import { useDashboardStore } from "@/store/modules/dashboard";
import { LayoutConfig } from "@/types/dashboard"; import { LayoutConfig } from "@/types/dashboard";
import controls from "../controls/index"; import controls from "../controls/index";
@ -56,6 +56,9 @@ export default defineComponent({
dashboardStore.activeGridItem(item.i); dashboardStore.activeGridItem(item.i);
dashboardStore.selectWidget(item); dashboardStore.selectWidget(item);
} }
onBeforeUnmount(() => {
dashboardStore.setLayout([]);
});
return { return {
dashboardStore, dashboardStore,
layoutUpdatedEvent, layoutUpdatedEvent,

View File

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