index.vue
2.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
<template>
<div class="p-10" style="min-height: calc(100vh - 320px)">
<HomeRecommend :recommendList="list" :navTitle="keyword" navIcon="tag" />
<el-empty v-show="!list.length" description="未搜索到相关内容" />
<el-pagination
background
layout="prev, pager, next"
:hide-on-single-page="true"
v-model:page-size="params.pageSize"
v-model:current-page="params.pageNum"
:total="total"
@current-change="onPageChange"
/>
</div>
</template>
<script lang="ts" setup>
import type { appType } from "~/api/types/app";
import { getAppList } from "~/api/app";
import type { webSiteType } from "~/api/types/webSite";
const route = useRoute();
const router = useRouter();
const config = useRuntimeConfig();
const webSite = useState<webSiteType>("webSite");
const { keyword } = route.query as { keyword: string };
const list = ref<appType[]>([]);
const total = ref<number>(0);
const params = ref<any>({
pageNum: 1,
pageSize: 10,
title: keyword,
});
function onPageChange(pageNum: number) {
router.push({
path: route.path + "/page/" + pageNum,
query: {
keyword: keyword,
},
});
}
const res = await getAppList(params.value);
list.value = res.rows;
total.value = res.total;
useHead({
title: `"${keyword}" 搜索结果 - ${webSite.value.webname}`,
meta: [
{ name: "description", content: `搜索"${keyword}"相关的AI工具,找到${total.value}个结果。${webSite.value.webdescription}` },
{ name: "keywords", content: `${keyword},AI工具搜索,${webSite.value.webkeywords}` },
{ name: "robots", content: "noindex, follow" },
{ property: "og:title", content: `"${keyword}" 搜索结果 - ${webSite.value.webname}` },
{ property: "og:description", content: `搜索"${keyword}"相关的AI工具结果页面。` },
{ property: "og:type", content: "website" },
{ property: "og:url", content: config.public.baseUrl + route.fullPath },
{ property: "og:site_name", content: webSite.value.webname },
],
link: [
{ rel: "canonical", href: config.public.baseUrl + route.fullPath }
]
});
</script>