hookehuyr

✨ feat(keepAlive模块): 头像访问嵌套问题,返回列表位置问题处理

......@@ -121,7 +121,7 @@ export default {
path: '/client/videoDetail',
query: {
prod_id: this.item.id,
path: this.item.path // 特殊标识,判断入口 为keepAlive使用
type: this.item.type // 特殊标识,判断入口 为keepAlive使用
}
});
},
......
......@@ -95,7 +95,7 @@ export default {
path: '/client/videoDetail',
query: {
prod_id: this.item.id,
path: this.item.path // 特殊标识,判断入口 为keepAlive使用
type: this.item.type // 特殊标识,判断入口 为keepAlive使用
}
});
},
......
......@@ -29,7 +29,7 @@ export const useUnwatchList = () => {
prod_list.value = _.concat(prod_list.value, res.data.data.prod);
prod_list.value = _.uniqBy(prod_list.value, 'id');
_.each(prod_list.value, (item) => {
item.path = 'unWatchList'
item.type = 'read-only' // 特殊标识,判断入口 为keepAlive使用
})
offset.value = prod_list.value.length;
loading.value = false;
......
......@@ -62,25 +62,22 @@ import { ref, onActivated, onMounted } from 'vue'
import { useRoute, useRouter, onBeforeRouteLeave } from 'vue-router'
import axios from '@/utils/axios';
import _ from 'lodash';
import $ from 'jquery';
import { Toast } from 'vant';
const $route = useRoute();
const $router = useRouter();
const store = mainStore();
const userInfo = ref({});
onMounted(() => {
// 获取表演者信息
axios.get('/srv/?a=perf_info', {
// 获取表演者信息
axios.get('/srv/?a=perf_info', {
params: {
perf_id: $route.query.perf_id
}
})
})
.then(res => {
if (res.data.code === 1) {
_.each(res.data.data.prod, (item) => {
item.path = 'personIndex'
item.type = 'read-only' // 特殊标识,判断入口 为keepAlive使用
})
userInfo.value = res.data.data;
} else {
......@@ -94,7 +91,6 @@ onMounted(() => {
.catch(err => {
console.error(err);
});
})
// 关注个人用户
const followUser = (status) => {
......@@ -141,6 +137,10 @@ onActivated(() => { // keepAlive 重置后执行回调
})
// 触发更新
userInfo.value.prod = arr.value;
// BUG: 暂时找不到问题,只能先强制刷新,数据串了。
if (userInfo.value.id && userInfo.value.id !== +$route.query.perf_id) {
location.reload();
}
});
const changeRouterKeepAlive = (path, keepAlive) => {
......@@ -155,7 +155,7 @@ onBeforeRouteLeave((to, from) => {
// 如果是从页面返回,需要重置keepAlive状态
// 列表页 =》 详情页
// TAG: keepAlive
if (to.path === '/client/videoDetail' && to.query.path) {
if (to.path === '/client/videoDetail' && to.query.type === 'read-only') {
changeRouterKeepAlive(from.path, true);
} else {
changeRouterKeepAlive(from.path, false);
......
......@@ -49,7 +49,7 @@ const $router = useRouter();
const getUserInfo = () => {
// 从个人头像进入的,不能再往下级进入
if (!$route.query.path) {
if ($route.query.type !== 'read-only') {
$router.push({
path: '/client/personIndex',
query: {
......
......@@ -39,7 +39,7 @@ axios.get('/srv/?a=my_favor')
if (res.data.code === 1) {
prodList.value = res.data.data.prod;
_.each(prodList.value, (item) => {
item.path = 'myCollection'
item.type = 'read-only' // 特殊标识,判断入口 为keepAlive使用
})
} else {
console.warn(res);
......
......@@ -39,7 +39,7 @@ axios.get('/srv/?a=my_like')
if (res.data.code === 1) {
prodList.value = res.data.data.prod;
_.each(prodList.value, (item) => {
item.path = 'myLike'
item.type = 'read-only'; // 特殊标识,判断入口 为keepAlive使用
})
} else {
console.warn(res);
......
......@@ -23,7 +23,6 @@ import $ from 'jquery'
import _ from 'lodash';
import { wxInfo } from '@/utils/tools';
const $route = useRoute();
const $router = useRouter();
const { onLoad, prod_list, finished, loading } = useUnwatchList();
......@@ -50,7 +49,7 @@ onActivated(() => { // keepAlive 重置后执行回调
* 判断微信环境
*/
if (wxInfo().isiOS || wxInfo().isAndroid) {
// TODO: 手机微信浏览器位置变动了,需要手动调整位置,但是无刷新是起作用的
// TAG: 手机微信浏览器位置变动了,需要手动调整位置,但是无刷新是起作用的
const { scrollTop } = storeToRefs(store);
if (scrollTop.value) {
$("html,body").animate({ "scrollTop": scrollTop.value })
......@@ -75,7 +74,7 @@ onBeforeRouteLeave((to, from) => {
// 如果是从页面返回,需要重置keepAlive状态
// 列表页 =》 详情页
// TAG: keepAlive
if (to.path === '/client/videoDetail' && to.query.path) {
if (to.path === '/client/videoDetail' && to.query.type === 'read-only') {
changeRouterKeepAlive(from.path, true);
} else {
changeRouterKeepAlive(from.path, false);
......