From 1ecd79b815143180313dec146f6636b8c3304f25 Mon Sep 17 00:00:00 2001 From: Dylan Date: Wed, 30 Oct 2024 14:18:10 +0800 Subject: [PATCH] =?UTF-8?q?add:=20=E4=B8=BA=E5=BD=B1=E7=89=87=E8=AF=A6?= =?UTF-8?q?=E6=83=85=E9=A1=B5=E9=9D=A2=E6=B7=BB=E5=8A=A0SEO=E4=BC=98?= =?UTF-8?q?=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- client/package.json | 1 + client/src/main.ts | 5 +++-- client/src/views/index/FilmDetails.vue | 14 +++++++++++++- 3 files changed, 17 insertions(+), 3 deletions(-) diff --git a/client/package.json b/client/package.json index cca106d..708fb7a 100644 --- a/client/package.json +++ b/client/package.json @@ -12,6 +12,7 @@ "dependencies": { "@element-plus/icons-vue": "^2.3.1", "@videojs-player/vue": "^1.0.0", + "@vueuse/head": "^2.0.0", "axios": "^1.3.4", "element-plus": "^2.8.6", "video.js": "^8.0.4", diff --git a/client/src/main.ts b/client/src/main.ts index 893f543..304e9e3 100644 --- a/client/src/main.ts +++ b/client/src/main.ts @@ -5,8 +5,9 @@ import { router} from "./router/router"; // 引入elementPlus import ElementPlus from 'element-plus' import 'element-plus/dist/index.css' -// 使用自定义loading +import {createHead} from '@vueuse/head' +// 使用自定义loading const app = createApp(App) @@ -15,7 +16,7 @@ app.use(ElementPlus) // 引入路由 app.use(router) - +app.use(createHead()) app.mount('#app') diff --git a/client/src/views/index/FilmDetails.vue b/client/src/views/index/FilmDetails.vue index 939399c..763f149 100644 --- a/client/src/views/index/FilmDetails.vue +++ b/client/src/views/index/FilmDetails.vue @@ -101,6 +101,7 @@ import {ApiGet} from "../../utils/request"; import {ElMessage} from 'element-plus' import {Promotion, CaretRight} from "@element-plus/icons-vue"; import RelateList from "../../components/index/RelateList.vue"; +import {useSeoMeta} from "@vueuse/head"; // 获取路由对象 const router = useRouter() const data = reactive({ @@ -202,6 +203,17 @@ onBeforeMount(() => { message: resp.msg, }) } + }).then(() => { + const titleName = `《${data.detail.name}》在线观看-迅雷下载-${data.detail.descriptor.classTag} ` + const keywords = `${data.detail.name},${data.detail.descriptor.classTag},${data.detail.descriptor.area},${data.detail.descriptor.actor},${data.detail.descriptor.director}` + // 页面加载完成后,将当前影片信息存入store + //useTitleHelper(titleName) + useSeoMeta({ + title: titleName, + description: data.detail.descriptor.blurb, + keywords: keywords + } + ) }) }) @@ -400,4 +412,4 @@ onBeforeMount(() => { margin-right: 10px; } - \ No newline at end of file +