浏览代码

更新 icon路径转化逻辑

wzh 4 年之前
父节点
当前提交
aac0909959

+ 1 - 3
src/components/Base.vue

@@ -3,13 +3,11 @@
 <script>
 import { ref, onMounted, computed } from "vue";
 import { mapState } from "vuex";
+import exchangeUrl from "utils/exchangeUrl";
 
 export default {
   setup() {
     function init() {}
-    function exchangeUrl(icon) {
-      return `/${icon}.png`;
-    }
     onMounted(() => {
       init();
     });

+ 1 - 3
src/components/CapacityCard.vue

@@ -41,13 +41,11 @@
 <script>
 import { ref, onMounted } from "vue";
 import { mapState } from "vuex";
+import exchangeUrl from "utils/exchangeUrl";
 
 export default {
   computed: mapState(["capacity"]),
   setup() {
-    function exchangeUrl(icon) {
-      return `/${icon}.png`;
-    }
     onMounted(() => {});
     return {
       exchangeUrl,

+ 2 - 3
src/components/CargoOwnderCard.vue

@@ -22,6 +22,7 @@
 <script>
 import { ref, onMounted } from "vue";
 import { mapState } from "vuex";
+import exchangeUrl from "utils/exchangeUrl";
 
 export default {
   computed: mapState(["cargoOwnerInfo"]),
@@ -31,9 +32,7 @@ export default {
     function openContract(contractId = 1) {
       console.log("查看电子合同:", contractId);
     }
-    function exchangeUrl(icon) {
-      return `/${icon}.png`;
-    }
+
     onMounted(() => {
       init();
     });

+ 2 - 3
src/components/DamCard.vue

@@ -7,13 +7,12 @@
 <script>
 import { ref, onMounted, computed } from "vue";
 import { mapState } from "vuex";
+import exchangeUrl from "utils/exchangeUrl";
 
 export default {
   setup() {
     function init() {}
-    function exchangeUrl(icon) {
-      return `/${icon}.png`;
-    }
+
     onMounted(() => {
       init();
     });

+ 3 - 4
src/components/EnvironmentalModule.vue

@@ -14,14 +14,13 @@
 <script>
 import { ref, onMounted } from "vue";
 import { mapState } from "vuex";
+import exchangeUrl from "utils/exchangeUrl";
 
 export default {
   computed: mapState(["damInfo"]),
   setup() {
     function init() {}
-    function exchangeUrl(icon) {
-      return `/${icon}.png`;
-    }
+
     onMounted(() => {
       init();
     });
@@ -33,4 +32,4 @@ export default {
 };
 </script>
 <style lang="scss" scoped>
-</style>
+</style>

+ 1 - 3
src/components/IconInfo.vue

@@ -19,6 +19,7 @@
 
 <script>
 import { ref, onMounted, computed } from "vue";
+import exchangeUrl from "utils/exchangeUrl";
 
 export default {
   props: {
@@ -51,9 +52,6 @@ export default {
   },
   setup() {
     function init() {}
-    function exchangeUrl(icon) {
-      return `/${icon}.png`;
-    }
     onMounted(() => {
       init();
     });

+ 2 - 3
src/components/IntelligentModule.vue

@@ -35,6 +35,7 @@
 
 <script>
 import { ref, onMounted } from "vue";
+import exchangeUrl from "utils/exchangeUrl";
 
 export default {
   setup() {
@@ -73,9 +74,7 @@ export default {
       { loadPort: "上海", discPort: "青岛" },
     ]);
     function init() {}
-    function exchangeUrl(icon) {
-      return `/${icon}.png`;
-    }
+
     onMounted(() => {
       init();
     });

+ 3 - 3
src/components/Number.vue

@@ -22,6 +22,8 @@
 <script>
 import { ref, onMounted } from "vue";
 import CountUp from "countup";
+import exchangeUrl from "utils/exchangeUrl";
+
 export default {
   setup() {
     let options = {
@@ -50,9 +52,7 @@ export default {
       num2.start();
       num3.start();
     }
-    function exchangeUrl(icon) {
-      return `/${icon}.png`;
-    }
+
     onMounted(() => {
       init();
     });

+ 2 - 3
src/components/PortsCard.vue

@@ -14,15 +14,14 @@
 <script>
 import { ref, onMounted, computed } from "vue";
 import { mapState } from "vuex";
+import exchangeUrl from "utils/exchangeUrl";
 
 export default {
   setup() {
     let arr = ref([]);
     arr.value.length = 50;
     function init() {}
-    function exchangeUrl(icon) {
-      return `/${icon}.png`;
-    }
+
     onMounted(() => {
       init();
     });

+ 1 - 3
src/components/Radar.vue

@@ -5,6 +5,7 @@
 <script>
 import { ref, onMounted, computed, inject } from "vue";
 import { mapState } from "vuex";
+import exchangeUrl from "utils/exchangeUrl";
 
 export default {
   setup() {
@@ -17,9 +18,6 @@ export default {
       radarChart.value = echarts.init(radartDom.value, "dark");
       radarChart.value.setOption(option.value);
     }
-    function exchangeUrl(icon) {
-      return `/${icon}.png`;
-    }
 
     let option = ref({
       title: {},

+ 2 - 3
src/components/SafetyModule.vue

@@ -10,13 +10,12 @@
 
 <script>
 import { ref, onMounted } from "vue";
+import exchangeUrl from "utils/exchangeUrl";
 
 export default {
   setup() {
     function init() {}
-    function exchangeUrl(icon) {
-      return `/${icon}.png`;
-    }
+
     onMounted(() => {
       init();
     });

+ 2 - 3
src/components/ShipInfoCard.vue

@@ -24,14 +24,13 @@
 <script>
 import { ref, onMounted } from "vue";
 import { mapState } from "vuex";
+import exchangeUrl from "utils/exchangeUrl";
 
 export default {
   computed: mapState(["shipInfo"]),
   setup() {
     function init() {}
-    function exchangeUrl(icon) {
-      return `/${icon}.png`;
-    }
+
     onMounted(() => {
       init();
     });

+ 2 - 3
src/components/ShipOwnerInfo.vue

@@ -21,6 +21,7 @@
 <script>
 import { ref, onMounted, computed } from "vue";
 import { mapState } from "vuex";
+import exchangeUrl from "utils/exchangeUrl";
 
 export default {
   props: {
@@ -35,9 +36,7 @@ export default {
   },
   setup() {
     function init() {}
-    function exchangeUrl(icon) {
-      return `/${icon}.png`;
-    }
+
     onMounted(() => {
       init();
     });

+ 2 - 3
src/components/Swiper.vue

@@ -13,6 +13,7 @@
 <script>
 import { ref, onMounted, computed } from "vue";
 import { mapState } from "vuex";
+import exchangeUrl from "utils/exchangeUrl";
 
 export default {
   setup() {
@@ -30,9 +31,7 @@ export default {
         },
       });
     }
-    function exchangeUrl(icon) {
-      return `/${icon}.png`;
-    }
+
     onMounted(() => {
       init();
     });

+ 2 - 3
src/components/TitleLine.vue

@@ -28,6 +28,7 @@
 
 <script>
 import { ref, onMounted } from "vue";
+import exchangeUrl from "utils/exchangeUrl";
 
 export default {
   props: {
@@ -54,9 +55,7 @@ export default {
   },
   setup() {
     function init() {}
-    function exchangeUrl(icon) {
-      return `/${icon}.png`;
-    }
+
     onMounted(() => {
       init();
     });

+ 2 - 4
src/components/Warning.vue

@@ -9,13 +9,11 @@
 <script>
 import { ref, onMounted, computed } from "vue";
 import { mapState } from "vuex";
-
+import exchangeUrl from "utils/exchangeUrl";
 export default {
   setup() {
     function init() {}
-    function exchangeUrl(icon) {
-      return `/${icon}.png`;
-    }
+
     onMounted(() => {
       init();
     });

+ 5 - 0
src/utils/exchangeUrl.js

@@ -0,0 +1,5 @@
+function exchangeUrl(icon, path = "safety-icons") {
+  return `/${path}/${icon}.png`;
+}
+
+export default exchangeUrl;