@@ -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 >
0 commit comments