hookehuyr

优化测试

<template>
<!-- 页面缓存 -->
<router-view v-slot="{ Component }">
<router-view v-slot="{ Component, route }">
<keep-alive :include="keepPages">
<component :is="Component" :key="$route.name" />
<component :is="Component" :key="route.name" />
</keep-alive>
</router-view>
</template>
......
......@@ -75,28 +75,26 @@ export default {
created() {
},
mounted() {
setTimeout(() => {
var mp = new MuiPlayer({
container: '#mui-player-' + this.item.id,
title: this.item.title,
src: this.item.video,
poster: this.item.cover,
autoFit: false,
videoAttribute: [ // 声明启用同层播放, 不让会自动全屏播放
{ attrKey: 'webkit-playsinline', attrValue: 'webkit-playsinline' },
{ attrKey: 'playsinline', attrValue: 'playsinline' },
{ attrKey: 'x5-video-player-type', attrValue: 'h5-page' },
]
})
this.mp = mp;
this.detail = _.cloneDeep(this.item);
var video = mp.video();
// 监听原生video事件
var _this = this;
video && video.addEventListener('play', function (event) {
_this.handleAction('play', _this.item.id)
});
}, 500);
var mp = new MuiPlayer({
container: '#mui-player-' + this.item.id,
title: this.item.title,
src: this.item.video,
poster: this.item.cover,
autoFit: false,
videoAttribute: [ // 声明启用同层播放, 不让会自动全屏播放
{ attrKey: 'webkit-playsinline', attrValue: 'webkit-playsinline' },
{ attrKey: 'playsinline', attrValue: 'playsinline' },
{ attrKey: 'x5-video-player-type', attrValue: 'h5-page' },
]
})
this.mp = mp;
this.detail = _.cloneDeep(this.item);
var video = mp.video();
// 监听原生video事件
var _this = this;
video && video.addEventListener('play', function (event) {
_this.handleAction('play', _this.item.id)
});
},
methods: {
goTo () { // 跳转作品详情页
......
......@@ -13,7 +13,7 @@ export const mainStore = defineStore('main', {
scrollTopCollection: 0,
scrollTopLike: 0,
scrollTopPerson: 0,
keepPages: 'default', // 很坑爹,空值全部都缓存
keepPages: ['default'], // 很坑爹,空值全部都缓存
};
},
getters: {
......@@ -44,20 +44,13 @@ export const mainStore = defineStore('main', {
this.scrollTopPerson = v;
},
changeKeepPages () { // 清空所有缓存,用一个不存在的值覆盖
this.keepPages = 'default';
this.keepPages = ['default'];
},
keepThisPage (page) { // 新增缓存页
const arr = this.keepPages.split(",");
arr.push(page);
this.keepPages = arr + "";
this.keepPages.push(page);
},
removeThisPage (page) { // 删除缓存页
const arr = this.keepPages.split(",");
const index = arr.findIndex(x => x === page);
if (index > 0) {
arr.splice(index, 1);
}
this.keepPages = arr + "";
_.remove(this.keepPages, item => item === page)
}
},
});
......