Browse Source

缓存优化

master
xuhuajiao 3 weeks ago
parent
commit
0f88e6b6be
  1. 10
      src/views/index.vue
  2. 4
      src/views/mixins/index.js
  3. 1
      src/views/pageOne/index.vue

10
src/views/index.vue

@ -14,10 +14,9 @@
<PageFour v-if="currentIndex === 3" /> <PageFour v-if="currentIndex === 3" />
<PageFive v-if="currentIndex === 4" /> --> <PageFive v-if="currentIndex === 4" /> -->
<!-- 正常运行时 --> <!-- 正常运行时 -->
<!-- <keep-alive>
<component :is="currentPage && currentPage.title" />
</keep-alive> -->
<keep-alive :include="cachedComponentNames">
<component :is="currentPage && currentPage.title" /> <component :is="currentPage && currentPage.title" />
</keep-alive>
<!-- bottom --> <!-- bottom -->
<div class="bottom-bg"> <div class="bottom-bg">
<div class="bottom-content"> <div class="bottom-content">
@ -71,6 +70,11 @@ export default {
yearTimer: null yearTimer: null
} }
}, },
computed: {
cachedComponentNames() {
return ['PageOne', 'PageTwo', 'PageFour']
}
},
created() { created() {
// const METAWA = require('../assets/js/META.common.min.js') // const METAWA = require('../assets/js/META.common.min.js')
// const meta = new METAWA('665e845538d68') // const meta = new METAWA('665e845538d68')

4
src/views/mixins/index.js

@ -134,8 +134,7 @@ export const pageCrud = {
startPageSwitch() { startPageSwitch() {
// 清除可能存在的旧定时器 // 清除可能存在的旧定时器
this.stopAutoSwitch() this.stopAutoSwitch()
if (!this.pageData.length) return // 无页面数据则退出
if (!this.pageData.length) return
// 获取当前页面的延迟时间 // 获取当前页面的延迟时间
const currentDelay = parseInt(this.pageData[this.currentIndex].delayed) * 1000 const currentDelay = parseInt(this.pageData[this.currentIndex].delayed) * 1000
@ -159,7 +158,6 @@ export const pageCrud = {
}, currentDelay) }, currentDelay)
}, },
stopAutoSwitch() { stopAutoSwitch() {
// 清除定时器(注意变量名从intervalId改为timeoutId)
if (this.timeoutId) { if (this.timeoutId) {
clearTimeout(this.timeoutId) clearTimeout(this.timeoutId)
this.timeoutId = null this.timeoutId = null

1
src/views/pageOne/index.vue

@ -658,7 +658,6 @@ export default {
}) })
Promise.all(this.newList).then(results => { Promise.all(this.newList).then(results => {
//
this.newList = results.filter(item => item !== null) this.newList = results.filter(item => item !== null)
// //
const halfLength = Math.ceil(this.newList.length / 2) const halfLength = Math.ceil(this.newList.length / 2)

Loading…
Cancel
Save