帖子搜索集成

fix #103
This commit is contained in:
目棃
2024-04-04 18:48:35 +08:00
parent 623d137457
commit 6bf24bd8c2
10 changed files with 290 additions and 36 deletions

View File

@@ -8,7 +8,7 @@
v-model="search"
class="news-search"
append-icon="mdi-magnify"
label="请输入米游社帖子 ID"
label="请输入帖子 ID 或搜索词"
:single-line="true"
hide-details
@click:append="searchPost"
@@ -40,6 +40,7 @@
</v-window-item>
</v-window>
<ToChannel v-model="showList" :gid="gid" />
<ToPostSearch :gid="gid" v-model="showSearch" :keyword="search" />
</template>
<script lang="ts" setup>
@@ -50,6 +51,7 @@ import showSnackbar from "../../components/func/snackbar";
import TPostCard from "../../components/main/t-postcard.vue";
import ToChannel from "../../components/overlay/to-channel.vue";
import ToLoading from "../../components/overlay/to-loading.vue";
import ToPostSearch from "../../components/post/to-postSearch.vue";
import Mys from "../../plugins/Mys";
import { useAppStore } from "../../store/modules/app";
import TGLogger from "../../utils/TGLogger";
@@ -87,6 +89,7 @@ const loadingSub = ref<boolean>(false);
const appStore = useAppStore();
const tab = ref<NewsKey>("notice");
const showList = ref<boolean>(false);
const showSearch = ref<boolean>(false);
const tabValues = ref<Array<NewsKey>>(["notice", "activity", "news"]);
// 渲染数据
@@ -193,13 +196,11 @@ function searchPost(): void {
});
return;
}
if (!isNaN(Number(search.value))) {
createPost(search.value);
const numCheck = Number(search.value);
if (isNaN(numCheck)) {
showSearch.value = true;
} else {
showSnackbar({
text: "请输入搜索内容",
color: "error",
});
createPost(search.value);
}
}
</script>

View File

@@ -27,7 +27,7 @@
v-model="search"
class="post-switch-item"
append-inner-icon="mdi-magnify"
label="请输入帖子 ID"
label="请输入帖子 ID 或搜索词"
variant="outlined"
:single-line="true"
hide-details
@@ -51,6 +51,7 @@
</div>
</div>
</div>
<ToPostSearch :gid="curGid.toString()" v-model="showSearch" :keyword="search" />
</template>
<script setup lang="ts">
import { nextTick, onMounted, ref, watch } from "vue";
@@ -59,6 +60,7 @@ import showConfirm from "../../components/func/confirm";
import showSnackbar from "../../components/func/snackbar";
import TPostCard from "../../components/main/t-postcard.vue";
import ToLoading from "../../components/overlay/to-loading.vue";
import ToPostSearch from "../../components/post/to-postSearch.vue";
import Mys from "../../plugins/Mys";
import TGClient from "../../utils/TGClient";
import TGLogger from "../../utils/TGLogger";
@@ -162,7 +164,8 @@ const curSortType = ref<number>(0);
// 渲染数据
const posts = ref<TGApp.Plugins.Mys.Post.FullData[]>([]);
const nav = ref<TGApp.BBS.Navigator.Navigator[]>([]);
const search = ref<string>();
const search = ref<string>("");
const showSearch = ref<boolean>(false);
onMounted(async () => {
await TGLogger.Info(
@@ -281,20 +284,18 @@ function freshCurForum(newVal: string): void {
// 查询帖子
function searchPost(): void {
if (search.value === undefined || search.value === "") {
if (search.value === "") {
showSnackbar({
text: "请输入搜索内容",
color: "error",
});
return;
}
if (!isNaN(Number(search.value))) {
createPost(search.value);
const numCheck = Number(search.value);
if (isNaN(numCheck)) {
showSearch.value = true;
} else {
showSnackbar({
text: "请输入搜索内容",
color: "error",
});
createPost(search.value);
}
}
</script>
@@ -351,7 +352,7 @@ function searchPost(): void {
}
.post-switch-item {
max-width: 200px;
width: fit-content;
height: 50px;
}