From 915897c21d140e9a004f9a2d293cd9111394afa9 Mon Sep 17 00:00:00 2001 From: mubai <1609539827@qq.com> Date: Wed, 18 Oct 2023 23:04:25 +0800 Subject: [PATCH] add pc film history test version v1 --- client/components.d.ts | 2 + client/index.html | 3 +- client/src/components/Header.vue | 199 +++++++++++++++++++++++++++++-- client/src/utils/cookie.ts | 47 ++++++++ client/src/views/index/Play.vue | 17 ++- 5 files changed, 252 insertions(+), 16 deletions(-) create mode 100644 client/src/utils/cookie.ts diff --git a/client/components.d.ts b/client/components.d.ts index 0ded4d5..3489d26 100644 --- a/client/components.d.ts +++ b/client/components.d.ts @@ -21,6 +21,8 @@ declare module '@vue/runtime-core' { ElMain: typeof import('element-plus/es')['ElMain'] ElPagination: typeof import('element-plus/es')['ElPagination'] ElRow: typeof import('element-plus/es')['ElRow'] + ElTimeline: typeof import('element-plus/es')['ElTimeline'] + ElTimelineItem: typeof import('element-plus/es')['ElTimelineItem'] FilmList: typeof import('./src/components/FilmList.vue')['default'] Footer: typeof import('./src/components/Footer.vue')['default'] Header: typeof import('./src/components/Header.vue')['default'] diff --git a/client/index.html b/client/index.html index 40d6e0a..089a2da 100644 --- a/client/index.html +++ b/client/index.html @@ -10,7 +10,8 @@ (╥﹏╥) - + +
diff --git a/client/src/components/Header.vue b/client/src/components/Header.vue index aa367a4..a831a00 100644 --- a/client/src/components/Header.vue +++ b/client/src/components/Header.vue @@ -11,18 +11,40 @@ + @@ -33,9 +55,30 @@ import {useRouter} from "vue-router"; import {Search, CircleClose} from '@element-plus/icons-vue' import {ElMessage} from "element-plus"; import {ApiGet} from "../utils/request"; - -// +import {cookieUtil,COOKIE_KEY_MAP} from "../utils/cookie"; +// 搜索关键字 const keyword = ref('') +// 弹窗隐藏显示 +const data = reactive({ + historyFlag: false, + historyList: [{}], +}) +// +const handleHistory = (flag:boolean)=>{ + data.historyFlag = flag + if (flag) { + // 获取cookie中的filmHistory + let historyMap = cookieUtil.getCookie(COOKIE_KEY_MAP.FILM_HISTORY)?JSON.parse(cookieUtil.getCookie(COOKIE_KEY_MAP.FILM_HISTORY)):null + let arr = [] + if (historyMap) { + for (let k in historyMap) { + arr.push(historyMap[k]) + } + arr.sort((item1,item2)=> item2.timeStamp-item1.timeStamp) + } + data.historyList = arr + } +} // 从父组件获取当前路由对象 @@ -69,11 +112,11 @@ onMounted(() => { } }) }) - - + +