From 56f81b7b1b9e9355e1dd281124fe730e3418f43e Mon Sep 17 00:00:00 2001 From: zjp Date: Fri, 29 Nov 2024 20:22:10 +0800 Subject: [PATCH] fix(TargetDropDown): call change when component is initialized --- os-checks/components/TargetDropDown.vue | 26 +++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/os-checks/components/TargetDropDown.vue b/os-checks/components/TargetDropDown.vue index 60584f8..d08a7f8 100644 --- a/os-checks/components/TargetDropDown.vue +++ b/os-checks/components/TargetDropDown.vue @@ -21,22 +21,13 @@ const defaultTarget = "All-Targets"; const selected = ref(defaultTarget); const targets = ref([defaultTarget]); const visible = ref(true); +const candidates = useBasicStore(); // 随路由页面变化而下载相应的 basic.json const route = useRoute(); -watch(() => [route.path, route.params], ([path, params]) => { - // console.log("path =", path); - if (path === "/" || path === "/repos" || path === "/charts" || path === "/target" || path === "/workflows") { - visible.value = false; - return; - } else if (params) { - // console.log("path =", path); - fetch(); - } - visible.value = true; -}); +change(route.path, route.params); +watch(() => [route.path, route.params], ([path, params]) => change(path as string, params)); -const candidates = useBasicStore(); fetch(); watch(selected, (val) => candidates.update_current(val)); @@ -52,6 +43,17 @@ function fetch() { }); } +function change(path: string, params: any) { + // console.log("path =", path); + if (path === "/" || path === "/repos" || path === "/charts" || path === "/target" || path === "/workflows") { + visible.value = false; + return; + } else if (params) { + // console.log("path =", path); + fetch(); + } + visible.value = true; +}