mirror of
https://github.com/BTMuli/TeyvatGuide.git
synced 2025-12-14 09:38:13 +08:00
🎨 调整帖子查找overlay逻辑
This commit is contained in:
@@ -72,8 +72,8 @@ interface ToAchiInfoEmits {
|
|||||||
|
|
||||||
const props = defineProps<ToAchiInfoProps>();
|
const props = defineProps<ToAchiInfoProps>();
|
||||||
const emits = defineEmits<ToAchiInfoEmits>();
|
const emits = defineEmits<ToAchiInfoEmits>();
|
||||||
const showSearch = ref(false);
|
const showSearch = ref<boolean>(false);
|
||||||
const search = ref("");
|
const search = ref<string>();
|
||||||
|
|
||||||
const visible = computed({
|
const visible = computed({
|
||||||
get: () => props.modelValue,
|
get: () => props.modelValue,
|
||||||
|
|||||||
@@ -25,17 +25,17 @@ import TPostCard from "../app/t-postcard.vue";
|
|||||||
import showSnackbar from "../func/snackbar.js";
|
import showSnackbar from "../func/snackbar.js";
|
||||||
|
|
||||||
// data
|
// data
|
||||||
const search = ref("");
|
const search = ref<string>();
|
||||||
const lastId = ref("");
|
const lastId = ref<string>("");
|
||||||
const game = ref("2");
|
const game = ref<string>("2");
|
||||||
const isLast = ref(false);
|
const isLast = ref<boolean>(false);
|
||||||
const results = ref<TGApp.Plugins.Mys.Post.FullData[]>([]);
|
const results = ref<TGApp.Plugins.Mys.Post.FullData[]>([]);
|
||||||
const load = ref(false);
|
const load = ref<boolean>(false);
|
||||||
|
|
||||||
interface ToPostSearchProps {
|
interface ToPostSearchProps {
|
||||||
modelValue: boolean;
|
modelValue: boolean;
|
||||||
gid: string;
|
gid: string;
|
||||||
keyword: string;
|
keyword?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
interface ToPostSearchEmits {
|
interface ToPostSearchEmits {
|
||||||
@@ -69,40 +69,44 @@ function onCancel() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
onMounted(async () => {
|
onMounted(async () => {
|
||||||
search.value = props.keyword;
|
|
||||||
game.value = props.gid;
|
game.value = props.gid;
|
||||||
|
if (props.keyword && props.keyword !== "") search.value = props.keyword;
|
||||||
|
if (props.modelValue) await searchPosts();
|
||||||
});
|
});
|
||||||
|
|
||||||
watch(
|
watch(
|
||||||
() => props.modelValue,
|
() => props.modelValue,
|
||||||
async (value) => {
|
async () => {
|
||||||
if (value && results.value.length === 0) {
|
if (props.modelValue && results.value.length === 0) {
|
||||||
await searchPosts();
|
await searchPosts();
|
||||||
} else {
|
return;
|
||||||
visible.value = value;
|
|
||||||
}
|
}
|
||||||
|
visible.value = props.modelValue;
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
watch(
|
watch(
|
||||||
() => props.keyword,
|
() => props.keyword,
|
||||||
async (value) => {
|
async () => {
|
||||||
if (search.value === "" && value !== "") {
|
if (search.value === "" && props.keyword !== "") {
|
||||||
search.value = value;
|
search.value = props.keyword;
|
||||||
} else if (search.value !== value && value !== "") {
|
return;
|
||||||
search.value = value;
|
}
|
||||||
|
if (search.value !== props.keyword && props.keyword !== "") {
|
||||||
|
search.value = props.keyword;
|
||||||
results.value = [];
|
results.value = [];
|
||||||
lastId.value = "";
|
lastId.value = "";
|
||||||
isLast.value = false;
|
isLast.value = false;
|
||||||
|
if (props.modelValue) await searchPosts();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
watch(
|
watch(
|
||||||
() => props.gid,
|
() => props.gid,
|
||||||
async (value) => {
|
async () => {
|
||||||
if (game.value !== value) {
|
if (game.value !== props.gid) {
|
||||||
game.value = value;
|
game.value = props.gid;
|
||||||
results.value = [];
|
results.value = [];
|
||||||
lastId.value = "";
|
lastId.value = "";
|
||||||
isLast.value = false;
|
isLast.value = false;
|
||||||
@@ -111,7 +115,7 @@ watch(
|
|||||||
);
|
);
|
||||||
|
|
||||||
async function searchPosts() {
|
async function searchPosts() {
|
||||||
if (load.value) return;
|
if (load.value || !search.value) return;
|
||||||
load.value = true;
|
load.value = true;
|
||||||
if (!props.gid || !props.keyword) {
|
if (!props.gid || !props.keyword) {
|
||||||
showSnackbar.warn("参数错误");
|
showSnackbar.warn("参数错误");
|
||||||
|
|||||||
@@ -197,6 +197,7 @@ async function searchPost(): Promise<void> {
|
|||||||
showSearch.value = true;
|
showSearch.value = true;
|
||||||
} else {
|
} else {
|
||||||
await createPost(search.value);
|
await createPost(search.value);
|
||||||
|
showSearch.value = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
Reference in New Issue
Block a user