hookehuyr

🐞 fix(个人首页): 屏蔽keepAlive,留言版完善read-only判断,返回个人首页时返回原来位置

...@@ -122,7 +122,8 @@ const setComment = () => { ...@@ -122,7 +122,8 @@ const setComment = () => {
122 path: '/client/videoDetail/comment', 122 path: '/client/videoDetail/comment',
123 query: { 123 query: {
124 prod_id: props.item.id, 124 prod_id: props.item.id,
125 - book_id: props.item.book_id 125 + book_id: props.item.book_id,
126 + type: props.item.type, // 特殊标识,判断入口 为keepAlive使用
126 } 127 }
127 }); 128 });
128 } 129 }
......
...@@ -130,25 +130,25 @@ const followUser = async () => { ...@@ -130,25 +130,25 @@ const followUser = async () => {
130 /****************** keepAlive 模块 *******************/ 130 /****************** keepAlive 模块 *******************/
131 131
132 // TAG: keepAlive 缓存页面 132 // TAG: keepAlive 缓存页面
133 -addPages() 133 +// addPages()
134 134
135 -onActivated(() => { // keepAlive 重置后执行回调 135 +// onActivated(() => { // keepAlive 重置后执行回调
136 - // TAG: pinia应用,动态刷新数据 136 +// // TAG: pinia应用,动态刷新数据
137 - // 处理数据未刷新数据显示问题 137 +// // 处理数据未刷新数据显示问题
138 - const { video_detail } = storeToRefs(store); 138 +// const { video_detail } = storeToRefs(store);
139 - // 如果作品信息有变化及时修正 139 +// // 如果作品信息有变化及时修正
140 - const arr = ref([]); 140 +// const arr = ref([]);
141 - _.each(userInfo.value.prod, (item) => { 141 +// _.each(userInfo.value.prod, (item) => {
142 - if (item.id === video_detail.value.id) { 142 +// if (item.id === video_detail.value.id) {
143 - item = video_detail.value 143 +// item = video_detail.value
144 - } 144 +// }
145 - arr.value.push(item); 145 +// arr.value.push(item);
146 - }) 146 +// })
147 - // 触发更新 147 +// // 触发更新
148 - userInfo.value.prod = arr.value; 148 +// userInfo.value.prod = arr.value;
149 - // 滚动恢复 149 +// // 滚动恢复
150 - resetScrollTop('scrollTopPerson'); 150 +// resetScrollTop('scrollTopPerson');
151 -}); 151 +// });
152 152
153 onBeforeRouteLeave(() => { 153 onBeforeRouteLeave(() => {
154 store.changeScrollTopPerson(window.scrollY) 154 store.changeScrollTopPerson(window.scrollY)
......
...@@ -20,13 +20,18 @@ ...@@ -20,13 +20,18 @@
20 <div class="video-main"> 20 <div class="video-main">
21 <van-row> 21 <van-row>
22 <van-col span="24" style="padding-top: 0.2rem;"> 22 <van-col span="24" style="padding-top: 0.2rem;">
23 - <van-tabs v-model:active="active" sticky :color="styleColor.baseColor" background="#F7F7F7" title-active-color="#222222" title-inactive-color="#777777" @click-tab="onClickTab"> 23 + <van-tabs v-model:active="active" sticky :color="styleColor.baseColor" background="#F7F7F7"
24 + title-active-color="#222222" title-inactive-color="#777777" @click-tab="onClickTab">
24 <van-tab title="简介" :title-style="tabClass"> 25 <van-tab title="简介" :title-style="tabClass">
25 <div class="intro">{{ videoInfo.note }}</div> 26 <div class="intro">{{ videoInfo.note }}</div>
26 <div style="height: 5rem;" /> 27 <div style="height: 5rem;" />
27 <donate-bar donate-type="C">为TA助力</donate-bar> 28 <donate-bar donate-type="C">为TA助力</donate-bar>
28 </van-tab> 29 </van-tab>
29 - <van-tab :title="'留言 ' + comment_num" :title-style="tabClass" :to="'/client/videoDetail/comment?prod_id=' + $route.query.prod_id + '&book_id=' + $route.query.book_id"> 30 + <!-- <van-tab :title="'留言 ' + comment_num" :title-style="tabClass"
31 + :to="'/client/videoDetail/comment?prod_id=' + $route.query.prod_id + '&book_id=' + $route.query.book_id + '&type=' + $route.query.type">
32 + <router-view />
33 + </van-tab> -->
34 + <van-tab :title="'留言 ' + comment_num" :title-style="tabClass">
30 <router-view /> 35 <router-view />
31 </van-tab> 36 </van-tab>
32 </van-tabs> 37 </van-tabs>
...@@ -39,11 +44,11 @@ ...@@ -39,11 +44,11 @@
39 <script setup> 44 <script setup>
40 import { ref, onMounted, watch } from 'vue' 45 import { ref, onMounted, watch } from 'vue'
41 import { useRoute, useRouter } from 'vue-router' 46 import { useRoute, useRouter } from 'vue-router'
42 -
43 import { axios, storeToRefs, mainStore, Toast } from '@/utils/generatePackage' 47 import { axios, storeToRefs, mainStore, Toast } from '@/utils/generatePackage'
44 import { VideoDetail, DonateBar } from '@/utils/generateModules' 48 import { VideoDetail, DonateBar } from '@/utils/generateModules'
45 import { icon_avatar } from '@/utils/generateIcons' 49 import { icon_avatar } from '@/utils/generateIcons'
46 import { styleColor } from '@/constant.js'; 50 import { styleColor } from '@/constant.js';
51 +import { prodInfoAPI } from '@/api/C/prod.js'
47 52
48 const $route = useRoute(); 53 const $route = useRoute();
49 const $router = useRouter(); 54 const $router = useRouter();
...@@ -61,8 +66,19 @@ const getUserInfo = () => { ...@@ -61,8 +66,19 @@ const getUserInfo = () => {
61 } 66 }
62 67
63 const active = ref(0); // index 0 为简介,1 为留言 68 const active = ref(0); // index 0 为简介,1 为留言
64 -const onClickTab = ({ title }) => { 69 +const onClickTab = ({ name }) => {
65 - // console.warn(title); 70 + // 适配read-only情况
71 + if (name) {
72 + $router.push({
73 + path: '/client/videoDetail/comment',
74 + query: {
75 + prod_id: $route.query.prod_id,
76 + book_id: $route.query.book_id,
77 + type: $route.query.type,
78 + }
79 + })
80 + }
81 +
66 }; 82 };
67 // 监听路由变化 83 // 监听路由变化
68 watch(() => $route.path, (v) => { 84 watch(() => $route.path, (v) => {
...@@ -76,43 +92,20 @@ const tabClass = { ...@@ -76,43 +92,20 @@ const tabClass = {
76 } 92 }
77 93
78 // 处理主路由的留言数量问题 94 // 处理主路由的留言数量问题
79 -const store = mainStore() 95 +const store = mainStore();
80 const { comment_num } = storeToRefs(store); 96 const { comment_num } = storeToRefs(store);
81 97
82 const videoInfo = ref(''); 98 const videoInfo = ref('');
83 - 99 +onMounted(async () => {
84 -onMounted(() => {
85 // 检查$route.path判断tab默认值 100 // 检查$route.path判断tab默认值
86 - if ($route.path === '/client/videoDetail') { 101 + $route.path === '/client/videoDetail' ? active.value = 0 : active.value = 1;
87 - active.value = 0;
88 - } else {
89 - active.value = 1;
90 - }
91 /** 102 /**
92 * 获取视频详情 103 * 获取视频详情
93 */ 104 */
94 - axios.get('/srv/?a=prod_info', { 105 + const { data } = await prodInfoAPI({ prod_id: $route.query.prod_id });
95 - params: { 106 + videoInfo.value = data;
96 - prod_id: $route.query.prod_id 107 + // 动态调整留言数量
97 - } 108 + store.changeCommentNum(data.comment_num);
98 - })
99 - .then(res => {
100 - if (res.data.code === 1) {
101 - videoInfo.value = res.data.data;
102 - // 动态调整留言数量
103 - store.changeCommentNum(res.data.data.comment_num);
104 - } else {
105 - console.warn(res);
106 - if (!res.data.show) return false;
107 - Toast({
108 - icon: 'close',
109 - message: res.data.msg
110 - });
111 - }
112 - })
113 - .catch(err => {
114 - console.error(err);
115 - });
116 }) 109 })
117 110
118 const onVideoDetail = (v) => { 111 const onVideoDetail = (v) => {
......