From a1a20e51d6c9efea406cf18facf707ea50e3d18c Mon Sep 17 00:00:00 2001
From: Ntkskwk <natsukawa247@outlook.com>
Date: Tue, 3 Sep 2024 07:41:34 +0800
Subject: refactor: Optimize the structure of the code

---
 site/src/views/index/Left.vue | 84 +++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 84 insertions(+)
 create mode 100644 site/src/views/index/Left.vue

(limited to 'site/src/views/index/Left.vue')

diff --git a/site/src/views/index/Left.vue b/site/src/views/index/Left.vue
new file mode 100644
index 0000000..f774223
--- /dev/null
+++ b/site/src/views/index/Left.vue
@@ -0,0 +1,84 @@
+<script lang="ts">
+export default {
+  data(){
+    return{
+      day:0,
+      hour:0,
+      min:0,
+      sec:0,
+      timer:0
+    }
+  },
+  props:{
+    msg:{
+      type:String,
+      require:true
+    },
+    date:{
+      type:Date,
+      default:new Date('2024-07-14T12:00:00Z')
+    }
+  },
+  methods:{
+    getTime(){
+      this.timer=window.setTimeout(()=>{
+        const date1 = new Date();
+        const date2 = new Date(this.date);
+        const timeDiff = Math.abs(date2.getTime() - date1.getTime());
+        this.day = Math.floor(timeDiff / (1000 * 60 * 60 * 24));
+        this.hour = Math.floor(timeDiff / (1000 * 60 * 60)%24);
+        this.min = Math.floor((timeDiff / (1000 * 60)) % 60);
+        this.sec = Math.floor((timeDiff / 1000) % 60);
+        this.getTime()
+      },1000)
+    }
+  },
+  beforeMount() {
+    this.getTime()
+  }
+
+}
+</script>
+
+<template>
+  <div class="greetings">
+    <h1 class="green">{{ msg }}</h1>
+    <h3>
+      距离水系公测计划：
+    </h3>
+    <h2>
+      {{ day }} 天 {{ hour }} 时 {{ min }} 分 {{ sec }} 秒
+    </h2>
+  </div>
+</template>
+
+<style scoped>
+h1 {
+  font-weight: 500;
+  font-size: 2.6rem;
+  position: relative;
+  top: -10px;
+}
+
+h3 {
+  font-size: 1.2rem;
+}
+
+.greetings h1,
+.greetings h2 {
+  text-align: center;
+}
+.greetings h3 {
+  text-align: center;
+}
+
+@media screen and (orientation:landscape) {
+  .greetings h1,
+  .greetings h2 {
+    text-align: left;
+  }
+  .greetings h3 {
+    text-align: left;
+  }
+}
+</style>
-- 
cgit v1.2.3-70-g09d2

