From f47c1619e8dec26211d3d814718d950d7cb5fb35 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=9B=AE=E6=A3=83?= Date: Sun, 24 Nov 2024 11:26:26 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=8E=A8=20=E8=B0=83=E6=95=B4=E5=B8=96?= =?UTF-8?q?=E5=AD=90=E6=9F=A5=E6=89=BEoverlay=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/userAchi/tua-achi-overlay.vue | 4 +- src/components/viewPost/vp-overlay-search.vue | 44 ++++++++++--------- src/pages/common/PostNews.vue | 1 + 3 files changed, 27 insertions(+), 22 deletions(-) diff --git a/src/components/userAchi/tua-achi-overlay.vue b/src/components/userAchi/tua-achi-overlay.vue index f1bb50f4..764a1124 100644 --- a/src/components/userAchi/tua-achi-overlay.vue +++ b/src/components/userAchi/tua-achi-overlay.vue @@ -72,8 +72,8 @@ interface ToAchiInfoEmits { const props = defineProps(); const emits = defineEmits(); -const showSearch = ref(false); -const search = ref(""); +const showSearch = ref(false); +const search = ref(); const visible = computed({ get: () => props.modelValue, diff --git a/src/components/viewPost/vp-overlay-search.vue b/src/components/viewPost/vp-overlay-search.vue index 72d58243..d10059ec 100644 --- a/src/components/viewPost/vp-overlay-search.vue +++ b/src/components/viewPost/vp-overlay-search.vue @@ -25,17 +25,17 @@ import TPostCard from "../app/t-postcard.vue"; import showSnackbar from "../func/snackbar.js"; // data -const search = ref(""); -const lastId = ref(""); -const game = ref("2"); -const isLast = ref(false); +const search = ref(); +const lastId = ref(""); +const game = ref("2"); +const isLast = ref(false); const results = ref([]); -const load = ref(false); +const load = ref(false); interface ToPostSearchProps { modelValue: boolean; gid: string; - keyword: string; + keyword?: string; } interface ToPostSearchEmits { @@ -69,40 +69,44 @@ function onCancel() { } onMounted(async () => { - search.value = props.keyword; game.value = props.gid; + if (props.keyword && props.keyword !== "") search.value = props.keyword; + if (props.modelValue) await searchPosts(); }); watch( () => props.modelValue, - async (value) => { - if (value && results.value.length === 0) { + async () => { + if (props.modelValue && results.value.length === 0) { await searchPosts(); - } else { - visible.value = value; + return; } + visible.value = props.modelValue; }, ); watch( () => props.keyword, - async (value) => { - if (search.value === "" && value !== "") { - search.value = value; - } else if (search.value !== value && value !== "") { - search.value = value; + async () => { + if (search.value === "" && props.keyword !== "") { + search.value = props.keyword; + return; + } + if (search.value !== props.keyword && props.keyword !== "") { + search.value = props.keyword; results.value = []; lastId.value = ""; isLast.value = false; + if (props.modelValue) await searchPosts(); } }, ); watch( () => props.gid, - async (value) => { - if (game.value !== value) { - game.value = value; + async () => { + if (game.value !== props.gid) { + game.value = props.gid; results.value = []; lastId.value = ""; isLast.value = false; @@ -111,7 +115,7 @@ watch( ); async function searchPosts() { - if (load.value) return; + if (load.value || !search.value) return; load.value = true; if (!props.gid || !props.keyword) { showSnackbar.warn("参数错误"); diff --git a/src/pages/common/PostNews.vue b/src/pages/common/PostNews.vue index a0c813f0..44b4863f 100644 --- a/src/pages/common/PostNews.vue +++ b/src/pages/common/PostNews.vue @@ -197,6 +197,7 @@ async function searchPost(): Promise { showSearch.value = true; } else { await createPost(search.value); + showSearch.value = false; } }