Showing
2 changed files
with
15 additions
and
1 deletions
| 1 | +/* | ||
| 2 | + * @Date: 2022-04-18 15:59:42 | ||
| 3 | + * @LastEditors: hookehuyr hookehuyr@gmail.com | ||
| 4 | + * @LastEditTime: 2022-06-13 11:30:40 | ||
| 5 | + * @FilePath: /tswj/src/store/index.js | ||
| 6 | + * @Description: 文件描述 | ||
| 7 | + */ | ||
| 1 | import { defineStore } from 'pinia'; | 8 | import { defineStore } from 'pinia'; |
| 2 | // import { testStore } from './test'; // 另一个store | 9 | // import { testStore } from './test'; // 另一个store |
| 3 | import _ from 'lodash'; | 10 | import _ from 'lodash'; | ... | ... |
| ... | @@ -43,7 +43,7 @@ | ... | @@ -43,7 +43,7 @@ |
| 43 | 43 | ||
| 44 | <script setup> | 44 | <script setup> |
| 45 | import { ref, onMounted, watch } from 'vue' | 45 | import { ref, onMounted, watch } from 'vue' |
| 46 | -import { useRoute, useRouter } from 'vue-router' | 46 | +import { useRoute, useRouter, onBeforeRouteLeave } from 'vue-router' |
| 47 | import { axios, storeToRefs, mainStore, Toast } from '@/utils/generatePackage' | 47 | import { axios, storeToRefs, mainStore, Toast } from '@/utils/generatePackage' |
| 48 | import { VideoDetail, DonateBar } from '@/utils/generateModules' | 48 | import { VideoDetail, DonateBar } from '@/utils/generateModules' |
| 49 | import { icon_avatar } from '@/utils/generateIcons' | 49 | import { icon_avatar } from '@/utils/generateIcons' |
| ... | @@ -113,6 +113,13 @@ const onVideoDetail = (v) => { | ... | @@ -113,6 +113,13 @@ const onVideoDetail = (v) => { |
| 113 | store.changeVideoDetail(v); | 113 | store.changeVideoDetail(v); |
| 114 | } | 114 | } |
| 115 | 115 | ||
| 116 | +onBeforeRouteLeave(async () => { | ||
| 117 | + // 缓存作品信息,给其他页使用 | ||
| 118 | + const { data } = await prodInfoAPI({ prod_id: $route.query.prod_id }); | ||
| 119 | + videoInfo.value = data; | ||
| 120 | + store.changeVideoDetail(videoInfo.value); | ||
| 121 | +}) | ||
| 122 | + | ||
| 116 | // 删除个人首页的keep-alive缓存 | 123 | // 删除个人首页的keep-alive缓存 |
| 117 | if (!$route.query.type) { // read-only 页不能删除 | 124 | if (!$route.query.type) { // read-only 页不能删除 |
| 118 | store.removeThisPage('personIndex'); | 125 | store.removeThisPage('personIndex'); | ... | ... |
-
Please register or login to post a comment