Selaa lähdekoodia

fix:修改时间显示和气象预警数据

wangsisi 1 kuukausi sitten
vanhempi
commit
b0d084c1ad

BIN
src/assets/images/home/base.png


+ 3 - 3
src/components/charts/options/oneLineOption.js

@@ -67,7 +67,7 @@ export const oneLine = {
     series: [
         {
             name: "温度",
-            data: [12, 11, 14, 16, 23, 18, 22],
+            data: [19, 18, 20, 11, 23, 18, 22],
             type: 'line',
             smooth: true,
             symbol: "none",
@@ -117,7 +117,7 @@ export const oneLine = {
                         name: "text",
                         value: "最低",
                         xAxis: '2/13',
-                        yAxis: 11,
+                        yAxis: 18,
                         symbolOffset: [0, "-50%"],
                         label: {
                             offset: [0, 22],
@@ -129,7 +129,7 @@ export const oneLine = {
                     {
                         name: "mark",
                         xAxis: '2/13',
-                        yAxis: 11,
+                        yAxis: 18,
                         value: "",
                         label: {
                             backgroundColor: "#fff",

+ 26 - 2
src/components/fnHeader.vue

@@ -21,7 +21,7 @@
       <el-icon size="25"><MoreFilled /></el-icon>
       <div class="time">
         <div>{{time}}</div>
-        <span>2025.01.14 星期二</span>
+        <span>{{getCurrentFormattedTime('date')}} {{getCurrentDayOfWeek()}}</span>
       </div>
     </div>
   </div>
@@ -51,6 +51,30 @@ const toggleFarm = (val) => {
     router.push({ name: "Home" });
 };
 
+function getCurrentFormattedTime(type) {
+    const now = new Date();
+ 
+    const year = now.getFullYear();
+    const month = String(now.getMonth() + 1).padStart(2, '0'); // Months are zero based
+    const day = String(now.getDate()).padStart(2, '0');
+    const hours = String(now.getHours()).padStart(2, '0');
+    const minutes = String(now.getMinutes()).padStart(2, '0');
+    const seconds = String(now.getSeconds()).padStart(2, '0');
+    if(type==='date'){
+      return `${year}.${month}.${day}`;
+    }else{
+      return `${hours}:${minutes}:${seconds}`;
+    }
+}
+
+function getCurrentDayOfWeek() {
+    const now = new Date();
+    const dayOfWeek = now.getDay();
+    const daysOfWeek = ['星期日', '星期一', '星期二', '星期三', '星期四', '星期五', '星期六'];
+ 
+    return daysOfWeek[dayOfWeek];
+}
+
 function formatTimeToHHmmss(date) {
   const hours = String(date.getHours()).padStart(2, '0');
   const minutes = String(date.getMinutes()).padStart(2, '0');
@@ -63,7 +87,7 @@ const time = ref("21:05:46")
 const timer = ref(null)
 onMounted(()=>{
   timer.value = setInterval(()=>{
-    time.value = formatTimeToHHmmss(new Date())
+    time.value = getCurrentFormattedTime(new Date())
   },1000)
 })
 

+ 1 - 1
src/views/home/components/homePage.vue

@@ -174,7 +174,7 @@ const evaluateYData = [1, 8, 7]
     .base-wrap{
       width: 100%;
       height: 65px;
-      margin: 5px 0;
+      margin-top: 4px;
       img{
         width: 100%;
         height: 100%;