Toggle navigation
Toggle navigation
This project
Loading...
Sign in
Hooke
/
tswj
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Snippets
Network
Create a new issue
Builds
Commits
Issue Boards
Authored by
hookehuyr
2022-05-13 09:12:18 +0800
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
e71206298b57cef3892e776a2268806a37489256
e7120629
1 parent
59da61f2
✨ feat(keepAlive模块): 头像访问嵌套问题,返回列表位置问题处理
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
35 additions
and
36 deletions
src/components/AuditVideoCard/index.vue
src/components/VideoCard/index.vue
src/composables/useUnwatchList.js
src/views/client/personIndex.vue
src/views/client/videoDetail.vue
src/views/me/collection.vue
src/views/me/like.vue
src/views/me/unwatchList.vue
src/components/AuditVideoCard/index.vue
View file @
e712062
...
...
@@ -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使用
}
});
},
...
...
src/components/VideoCard/index.vue
View file @
e712062
...
...
@@ -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使用
}
});
},
...
...
src/composables/useUnwatchList.js
View file @
e712062
...
...
@@ -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
;
...
...
src/views/client/personIndex.vue
View file @
e712062
...
...
@@ -62,39 +62,35 @@ 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', {
params: {
perf_id: $route.query.perf_id
// 获取表演者信息
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.type = 'read-only' // 特殊标识,判断入口 为keepAlive使用
})
userInfo.value = res.data.data;
} else {
console.warn(res);
Toast({
icon: 'close',
message: res.data.msg
});
}
})
.then(res => {
if (res.data.code === 1) {
_.each(res.data.data.prod, (item) => {
item.path = 'personIndex'
})
userInfo.value = res.data.data;
} else {
console.warn(res);
Toast({
icon: 'close',
message: res.data.msg
});
}
})
.catch(err => {
console.error(err);
});
})
.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);
...
...
src/views/client/videoDetail.vue
View file @
e712062
...
...
@@ -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: {
...
...
src/views/me/collection.vue
View file @
e712062
...
...
@@ -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);
...
...
src/views/me/like.vue
View file @
e712062
...
...
@@ -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);
...
...
src/views/me/unwatchList.vue
View file @
e712062
...
...
@@ -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) {
// T
ODO
: 手机微信浏览器位置变动了,需要手动调整位置,但是无刷新是起作用的
// T
AG
: 手机微信浏览器位置变动了,需要手动调整位置,但是无刷新是起作用的
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);
...
...
Please
register
or
login
to post a comment