Skip to content

Commit 3a12997

Browse files
committed
fix: 强制清理一次缓存
1 parent f33df80 commit 3a12997

2 files changed

Lines changed: 21 additions & 8 deletions

File tree

src/views/course.vue

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,14 @@ export default {
9696
for (let i = 0; i <= this.totalWeek; i++) {
9797
this.lessonsList.push([]);
9898
}
99+
// 强制清理一下缓存
100+
if (localStorage.getItem("refresh") === null) {
101+
this.clearLocalCache();
102+
localStorage.setItem("refresh", "true");
103+
console.log("清理缓存");
104+
} else if (this.curWeek > this.totalWeek || this.curWeek === 0) {
105+
localStorage.removeItem("refresh");
106+
}
99107
this.setActiveDay();
100108
this.get();
101109
this.week = this.curWeek;
@@ -161,8 +169,8 @@ export default {
161169
let exp = localStorage.getItem("exp");
162170
let norm = localStorage.getItem("norm");
163171
let setCourse = () => {
164-
exp = exp == null ? [] : JSON.parse(exp);
165-
norm = norm == null ? [] : JSON.parse(norm);
172+
exp = (exp == null ? [] : JSON.parse(exp));
173+
norm = (norm == null ? [] : JSON.parse(norm));
166174
const fillCourse = async (w) => {
167175
if (this.lessonsList[w].length === 0) {
168176
this.lessonsList[w] = simpleSelectWeek(w, exp.concat(norm));
@@ -236,7 +244,13 @@ export default {
236244
randomColor: function (num) {
237245
const colors = ["#f44336", "#e91e63", "#9c27b0", "#673ab7", "#3f51b5", "#2196f3", "#03a9f4", "#00bcd4", "#009688", "#4caf50", "#8bc34a", "#795548", "#607d8b"];
238246
return colors[num % colors.length];
239-
}
247+
},
248+
249+
clearLocalCache: function () {
250+
localStorage.removeItem("lessons");
251+
localStorage.removeItem("norm");
252+
localStorage.removeItem("exp");
253+
},
240254
}
241255
}
242256
</script>

src/views/index.vue

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,8 @@
8282
<van-tabbar-item icon="more-o">更多</van-tabbar-item>
8383
<van-tabbar-item icon="logistics">探索</van-tabbar-item>
8484
</van-tabbar>
85+
<!-- 提前加载课程表 -->
86+
<course-table v-if="isLogin" style="display: none"/>
8587
</div>
8688
</div>
8789
</template>
@@ -100,11 +102,11 @@ import IndexGrid from "@/components/IndexGrid.vue";
100102
import DigitalClock from "@/components/DigitalClock.vue";
101103
import HitokotoPanel from "@/components/HitokotoPanel.vue";
102104
import {getWebVersion} from "@/api/webInfoApi";
103-
import {refreshExpCourse, refreshNormalCourse} from "@/js/CourseUtils";
105+
import CourseTable from "@/views/course.vue";
104106
105107
export default {
106108
name: "indexPanel",
107-
components: {HitokotoPanel, DigitalClock, IndexGrid, IndexButton, AppButton, AppCard},
109+
components: {CourseTable, HitokotoPanel, DigitalClock, IndexGrid, IndexButton, AppButton, AppCard},
108110
mounted() {
109111
// ACG模式
110112
if (localStorage.getItem('ACG_MODE') === 'true') {
@@ -127,9 +129,6 @@ export default {
127129
if (new Date().getHours() >= 0 && new Date().getHours() <= 6) {
128130
showNotify({type: 'primary', message: '每晚0:00一站式认证接口维护'});
129131
}
130-
// 课表更新
131-
refreshExpCourse();
132-
refreshNormalCourse();
133132
},
134133
data() {
135134
return {

0 commit comments

Comments
 (0)