From 5c5380f4f70aca087bbe6f8c6df0e67c7afb42a0 Mon Sep 17 00:00:00 2001 From: BTMuli Date: Sun, 25 May 2025 14:26:53 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=8E=A8=20defineModel?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/app/t-gameNav.vue | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/components/app/t-gameNav.vue b/src/components/app/t-gameNav.vue index 7ea3e27f..c7fd6191 100644 --- a/src/components/app/t-gameNav.vue +++ b/src/components/app/t-gameNav.vue @@ -27,8 +27,7 @@ import { computed, onMounted, ref, shallowRef, watch } from "vue"; import ToLivecode from "./to-livecode.vue"; -type TGameNavProps = { modelValue: number }; -const props = withDefaults(defineProps(), { modelValue: 2 }); +const model = defineModel({ default: 2 }); const { isLogin } = storeToRefs(useAppStore()); const nav = shallowRef([]); @@ -46,12 +45,12 @@ const hasNav = computed(() => { onMounted(async () => await loadNav()); watch( - () => props.modelValue, + () => model.value, async () => await loadNav(), ); async function loadNav(): Promise { - nav.value = await ApiHubReq.home(props.modelValue); + nav.value = await ApiHubReq.home(model.value); } async function tryGetCode(): Promise { @@ -121,7 +120,7 @@ async function toBBS(link: URL): Promise { } if (link.hostname === "forum") { const forumId = link.pathname.split("/").pop(); - const localPath = `/posts/forum/${props.modelValue}/${forumId}`; + const localPath = `/posts/forum/${model.value}/${forumId}`; await emit("active_deep_link", `router?path=${localPath}`); return; }