Bladeren bron

inital commit

Runhang Zhang 5 jaren geleden
bovenliggende
commit
d153451e1d
3 gewijzigde bestanden met toevoegingen van 269 en 229 verwijderingen
  1. 228 228
      package-lock.json
  2. 37 0
      src/components/CountDown/index.vue
  3. 4 1
      src/views/Dashboard/Analysis.vue

File diff suppressed because it is too large
+ 228 - 228
package-lock.json


+ 37 - 0
src/components/CountDown/index.vue

@@ -0,0 +1,37 @@
+<template>
+  <span>{{ lastTime }}</span>
+</template>
+
+<script>
+export default {
+  props: ["target", "onEnd"],
+  data() {
+    return {
+      lastTime: this.initTime(),
+      timer: null
+    };
+  },
+  methods: {
+    fixedZero(val) {
+      return val * 1 < 10 ? `0${val}` : val;
+    },
+    initTime() {
+      let lastTime = 0;
+      let targetTime = 0;
+      try {
+        if (Object.prototype.toString.call(this.target) === "[object Date]") {
+          targetTime = this.target.getTime();
+        } else {
+          targetTime = new Date(this.target).getTime();
+        }
+      } catch (e) {
+        throw new Error("invalid target prop", e);
+      }
+      lastTime = targetTime - new Date().getTime();
+      return lastTime < 0 ? 0 : lastTime;
+    }
+  }
+};
+</script>
+
+<style></style>

+ 4 - 1
src/views/Dashboard/Analysis.vue

@@ -1,5 +1,6 @@
 <template>
   <div>
+    <CountDown :target="new Date().getTime() + 3900000" />
     {{ $t("message")["app.dashboard.analysis.timeLabel"] }} :
     <a-date-picker></a-date-picker>
     <Chart :option="chartOption" style="height: 400px" />
@@ -10,6 +11,7 @@
 <script>
 import request from "../../utils/request";
 import Chart from "../../components/Chart";
+import CountDown from "../../components/CountDown";
 import chartCode from "!!raw-loader!../../components/Chart";
 export default {
   data() {
@@ -55,7 +57,8 @@ export default {
     clearInterval(this.interval);
   },
   components: {
-    Chart
+    Chart,
+    CountDown
   }
 };
 </script>

Some files were not shown because too many files changed in this diff