Procházet zdrojové kódy

修改配置项、时间逻辑调整

wdq před 9 měsíci
rodič
revize
2fc3dfb239

+ 0 - 15
package-lock.json

@@ -9,7 +9,6 @@
       "version": "0.1.0",
       "dependencies": {
         "axios": "^1.7.7",
-        "moment": "^2.30.1",
         "vue": "^3.2.13",
         "vue-router": "^4.0.3",
         "vuex": "^4.0.0"
@@ -4940,15 +4939,6 @@
       "integrity": "sha512-23g5BFj4zdQL/b6tor7Ji+QY4pEfNH784BMslY9Qb0UnJWRAt+lQGLYmRaM0KDBwIG23ffEBELhZDP2rhi9f/Q==",
       "dev": true
     },
-    "node_modules/moment": {
-      "version": "2.30.1",
-      "resolved": "https://mirrors.huaweicloud.com/repository/npm/moment/-/moment-2.30.1.tgz",
-      "integrity": "sha512-uEmtNhbDOrWPFS+hdjFCBfy9f2YoyzRpwcl+DqpC6taX21FzsTLQVbMV/W7PzNSX6x/bhC1zA3c2UQ5NzH6how==",
-      "license": "MIT",
-      "engines": {
-        "node": "*"
-      }
-    },
     "node_modules/mrmime": {
       "version": "2.0.0",
       "resolved": "https://registry.npmmirror.com/mrmime/-/mrmime-2.0.0.tgz",
@@ -11867,11 +11857,6 @@
       "integrity": "sha512-23g5BFj4zdQL/b6tor7Ji+QY4pEfNH784BMslY9Qb0UnJWRAt+lQGLYmRaM0KDBwIG23ffEBELhZDP2rhi9f/Q==",
       "dev": true
     },
-    "moment": {
-      "version": "2.30.1",
-      "resolved": "https://mirrors.huaweicloud.com/repository/npm/moment/-/moment-2.30.1.tgz",
-      "integrity": "sha512-uEmtNhbDOrWPFS+hdjFCBfy9f2YoyzRpwcl+DqpC6taX21FzsTLQVbMV/W7PzNSX6x/bhC1zA3c2UQ5NzH6how=="
-    },
     "mrmime": {
       "version": "2.0.0",
       "resolved": "https://registry.npmmirror.com/mrmime/-/mrmime-2.0.0.tgz",

+ 0 - 1
package.json

@@ -8,7 +8,6 @@
   },
   "dependencies": {
     "axios": "^1.7.7",
-    "moment": "^2.30.1",
     "vue": "^3.2.13",
     "vue-router": "^4.0.3",
     "vuex": "^4.0.0"

+ 11 - 1
public/static/config/config.js

@@ -4,4 +4,14 @@ var scriptObj = {
         "/static/plugins/skyscenery/plugins/CGCS2000ArcGisMapServerImageryProvider.js",
         "/static/plugins/skyscenery/plugins/Wall/DynamicWallMaterialProperty.js"
     ]
-}
+}
+
+var userLoginConfig = {
+    "userName": "user001",
+    "password": "1234567890",
+    "clientId": 1,
+    "serviceId": 0
+}
+
+// var oauthUrl = "http://10.235.245.174:8888/"
+var oauthUrl = "http://121.43.55.7:10086"

+ 48 - 6
src/components/Header.vue

@@ -1,6 +1,10 @@
 <template>
   <div id="header">
     <!-- 时间 -->
+    <div class="clock">
+      <p class="time">{{ time }}</p>
+      <p class="date">{{ date }}</p>
+    </div>
     <!-- title -->
     <!-- 天气 -->
   </div>
@@ -8,13 +12,16 @@
 
 <script>
 import axios from "axios";
-import moment from "moment";
+// import moment from "moment";
 export default {
   data() {
-    return {};
+    return {
+      time: "",
+      date: ""
+    };
   },
   mounted() {
-    // this.timeRefresh();
+    this.timeRefresh();
   },
   methods: {
     // 前提获取
@@ -55,9 +62,44 @@ export default {
     },
     // 时间监听
     timeRefresh() {
-      setInterval(() => {
-        console.log(moment(new Date()).format("YYYY-MM-DD HH:mm:ss"));
-      }, 1000);
+      let that = this;
+      var week = [
+        "星期天",
+        "星期一",
+        "星期二",
+        "星期三",
+        "星期四",
+        "星期五",
+        "星期六"
+      ];
+      setInterval(updateTime, 1000);
+      updateTime();
+      function updateTime() {
+        var cd = new Date();
+        that.time =
+          zeroPadding(cd.getHours(), 2) +
+          ":" +
+          zeroPadding(cd.getMinutes(), 2) +
+          ":" +
+          zeroPadding(cd.getSeconds(), 2);
+        that.date =
+          zeroPadding(cd.getFullYear(), 4) +
+          "-" +
+          zeroPadding(cd.getMonth() + 1, 2) +
+          "-" +
+          zeroPadding(cd.getDate(), 2) +
+          " " +
+          week[cd.getDay()];
+
+        console.log(that.date + "  " + that.time);
+        function zeroPadding(num, digit) {
+          var zero = "";
+          for (var i = 0; i < digit; i++) {
+            zero += "0";
+            return (zero + num).slice(-digit);
+          }
+        }
+      }
     }
   },
   computed: {

+ 7 - 7
src/components/Map.vue

@@ -13,18 +13,19 @@ export default {
     getToken() {
       let that = this;
       let loginInfo = new FormData();
-      loginInfo.append("userName", "user_dianxin");
-      loginInfo.append("password", "Dx123456");
-      loginInfo.append("clientId", 1);
-      loginInfo.append("serviceId", 0);
-      fetch("http://10.235.245.174:8888/oauth/api/user/login", {
+      for (const key in userLoginConfig) {
+        if (Object.prototype.hasOwnProperty.call(userLoginConfig, key)) {
+          loginInfo.append(key, userLoginConfig[key]);
+        }
+      }
+      fetch(oauthUrl + "/oauth/api/user/login", {
         method: "POST",
         body: loginInfo
       })
         .then(resp => resp.json())
         .then(data => {
           SkySceneryConfig = {
-            authUrl: "http://10.235.245.174:8888/",
+            authUrl: oauthUrl,
             token: data.message
           };
           that.addScripts(scriptObj.main).then(function() {
@@ -217,7 +218,6 @@ export default {
 };
 </script>
 
-<!-- Add "scoped" attribute to limit CSS to this component only -->
 <style lang="less" scoped>
 #skysceneryContainer {
   width: 100%;

+ 1 - 2
src/views/HomeView.vue

@@ -5,8 +5,7 @@
   </div>
 </template>
 
-<script>
-// @ is an alias to /src
+<script> 
 import Map from "@/components/Map.vue";
 import Header from "@/components/Header.vue";