Kaynağa Gözat

feat: 暑假公告

chenlei 1 ay önce
ebeveyn
işleme
e15b1429a9

+ 30 - 3
web/src/App.vue

@@ -1,16 +1,27 @@
 <template>
   <div id="app">
+    <NoticeDialog :show.sync="noticeVisible" />
+
     <Router-view />
   </div>
 </template>
 
 
 <script>
+import NoticeDialog from './components/NoticeDialog/index.vue';
 
-export default {
+const NOTICE_KEY = 'notice1'
 
+export default {
+  data() {
+    return {
+      noticeVisible: false
+    }
+  },
+  components: {
+    NoticeDialog
+  },
   created() {
-
     // 移动端和pc端的切换
     if (
       window.navigator.userAgent.match(
@@ -22,8 +33,24 @@ export default {
         window.location.href = window.location.origin + '/mobile/index.html#/Layout/Home'
       }
     }
-  }
+  },
+  mounted() {
+    if (this.checkDailyDialog()) {
+      this.noticeVisible = true
+    }
+  },
+  methods: {
+    checkDailyDialog() {
+      const lastShown = localStorage.getItem(NOTICE_KEY)
+      const today = new Date().toDateString()
 
+      if (lastShown !== today) {
+        localStorage.setItem(NOTICE_KEY, today)
+        return true
+      }
+      return false
+    }
+  }
 }
 </script>
 

BIN
web/src/components/NoticeDialog/images/icon-close@2x.png


Dosya farkı çok büyük olduğundan ihmal edildi
+ 98 - 0
web/src/components/NoticeDialog/index.vue


Dosya farkı çok büyük olduğundan ihmal edildi
+ 8802 - 0
web/yarn.lock


+ 30 - 2
webM/src/App.vue

@@ -1,14 +1,26 @@
 <template>
   <div id="app">
+    <NoticeDialog :show.sync="noticeVisible" />
+
     <Router-view />
   </div>
 </template>
 
 
 <script>
+import NoticeDialog from './components/NoticeDialog/index.vue';
 
-export default {
+const NOTICE_KEY = 'notice1'
 
+export default {
+  data() {
+    return {
+      noticeVisible: false
+    }
+  },
+  components: {
+    NoticeDialog
+  },
   created() {
     // 移动端和pc端的切换
     if (
@@ -25,8 +37,24 @@ export default {
       }
     }
 
-  }
+  },
+  mounted() {
+    if (this.checkDailyDialog()) {
+      this.noticeVisible = true
+    }
+  },
+  methods: {
+    checkDailyDialog() {
+      const lastShown = localStorage.getItem(NOTICE_KEY)
+      const today = new Date().toDateString()
 
+      if (lastShown !== today) {
+        localStorage.setItem(NOTICE_KEY, today)
+        return true
+      }
+      return false
+    }
+  }
 }
 </script>
 

BIN
webM/src/components/NoticeDialog/images/icon-close@2x.png


Dosya farkı çok büyük olduğundan ihmal edildi
+ 106 - 0
webM/src/components/NoticeDialog/index.vue