From 2dddbd1af47251edbc86db54622cb33ec60e5e01 Mon Sep 17 00:00:00 2001
From: shuishen <1109946754@qq.com>
Date: Thu, 08 Apr 2021 09:30:27 +0800
Subject: [PATCH] 项目顶部修改

---
 src/page/index/top/top-menu.vue |  161 +++++++++++--------
 src/page/index/top/index.vue    |  284 ++++++++++++++++++----------------
 2 files changed, 246 insertions(+), 199 deletions(-)

diff --git a/src/page/index/top/index.vue b/src/page/index/top/index.vue
index 9851c99..6b58be5 100644
--- a/src/page/index/top/index.vue
+++ b/src/page/index/top/index.vue
@@ -1,98 +1,118 @@
 <template>
   <div class="avue-top">
     <div class="top-bar__left">
-      <div class="avue-breadcrumb"
-           :class="[{ 'avue-breadcrumb--active': isCollapse }]"
-           v-if="showCollapse">
-        <i class="icon-navicon"
-           @click="setCollapse"></i>
+      <div
+        class="avue-breadcrumb"
+        :class="[{ 'avue-breadcrumb--active': isCollapse }]"
+        v-if="showCollapse"
+      >
+        <i class="icon-navicon" @click="setCollapse"></i>
       </div>
     </div>
     <div class="top-bar__title">
-      <div class="top-bar__item top-bar__item--show"
-           v-if="showMenu">
+      <div class="top-bar__item top-bar__item--show" v-if="showMenu">
         <top-menu ref="topMenu"></top-menu>
       </div>
       <!--去除顶部搜索栏-->
-<!--      <span class="top-bar__item"-->
-<!--            v-if="showSearch">-->
-<!--        <top-search></top-search>-->
-<!--      </span>-->
+      <!--      <span class="top-bar__item"-->
+      <!--            v-if="showSearch">-->
+      <!--        <top-search></top-search>-->
+      <!--      </span>-->
     </div>
     <div class="top-bar__right">
-
-      <img src="/img/ydlg.png" style="height: 44px; vertical-align: middle;" alt="">
-      <el-tooltip v-if="showColor"
-                  effect="dark"
-                  :content="$t('navbar.color')"
-                  placement="bottom">
+      <img
+        src="/img/ydlg.png"
+        style="height: 44px; vertical-align: middle"
+        alt=""
+      />
+      <el-tooltip
+        v-if="showColor"
+        effect="dark"
+        :content="$t('navbar.color')"
+        placement="bottom"
+      >
         <div class="top-bar__item">
           <top-color></top-color>
         </div>
       </el-tooltip>
-      <el-tooltip v-if="showDebug"
-                  effect="dark"
-                  :content="logsFlag?$t('navbar.bug'):logsLen+$t('navbar.bugs')"
-                  placement="bottom">
+      <el-tooltip
+        v-if="showDebug"
+        effect="dark"
+        :content="logsFlag ? $t('navbar.bug') : logsLen + $t('navbar.bugs')"
+        placement="bottom"
+      >
         <div class="top-bar__item">
           <top-logs></top-logs>
         </div>
       </el-tooltip>
-      <el-tooltip v-if="showLock"
-                  effect="dark"
-                  :content="$t('navbar.lock')"
-                  placement="bottom">
+      <el-tooltip
+        v-if="showLock"
+        effect="dark"
+        :content="$t('navbar.lock')"
+        placement="bottom"
+      >
         <div class="top-bar__item">
           <top-lock></top-lock>
         </div>
       </el-tooltip>
-      <el-tooltip v-if="showTheme"
-                  effect="dark"
-                  :content="$t('navbar.theme')"
-                  placement="bottom">
+      <el-tooltip
+        v-if="showTheme"
+        effect="dark"
+        :content="$t('navbar.theme')"
+        placement="bottom"
+      >
         <div class="top-bar__item top-bar__item--show">
           <top-theme></top-theme>
         </div>
       </el-tooltip>
-<!--      <el-tooltip effect="dark"-->
-<!--                  :content="$t('navbar.notice')"-->
-<!--                  placement="bottom">-->
-<!--        <div class="top-bar__item top-bar__item&#45;&#45;show">-->
-<!--          <top-notice></top-notice>-->
-<!--        </div>-->
-<!--      </el-tooltip>-->
-      <el-tooltip effect="dark"
-                  :content="$t('navbar.language')"
-                  placement="bottom">
+      <!--      <el-tooltip effect="dark"-->
+      <!--                  :content="$t('navbar.notice')"-->
+      <!--                  placement="bottom">-->
+      <!--        <div class="top-bar__item top-bar__item&#45;&#45;show">-->
+      <!--          <top-notice></top-notice>-->
+      <!--        </div>-->
+      <!--      </el-tooltip>-->
+      <el-tooltip
+        effect="dark"
+        :content="$t('navbar.language')"
+        placement="bottom"
+      >
         <div class="top-bar__item top-bar__item--show">
           <top-lang></top-lang>
         </div>
       </el-tooltip>
-      <el-tooltip v-if="showFullScren"
-                  effect="dark"
-                  :content="isFullScren?$t('navbar.screenfullF'):$t('navbar.screenfull')"
-                  placement="bottom">
+      <el-tooltip
+        v-if="showFullScren"
+        effect="dark"
+        :content="
+          isFullScren ? $t('navbar.screenfullF') : $t('navbar.screenfull')
+        "
+        placement="bottom"
+      >
         <div class="top-bar__item">
-          <i :class="isFullScren?'icon-tuichuquanping':'icon-quanping'"
-             @click="handleScreen"></i>
+          <i
+            :class="isFullScren ? 'icon-tuichuquanping' : 'icon-quanping'"
+            @click="handleScreen"
+          ></i>
         </div>
       </el-tooltip>
-      <img class="top-bar__img"
-           :src="userInfo.avatar">
+      <img class="top-bar__img" :src="userInfo.avatar" />
       <el-dropdown>
         <span class="el-dropdown-link">
-          {{userInfo.userName}}
+          {{ userInfo.userName }}
           <i class="el-icon-arrow-down el-icon--right"></i>
         </span>
         <el-dropdown-menu slot="dropdown">
           <el-dropdown-item>
-            <router-link to="/">{{$t('navbar.dashboard')}}</router-link>
+            <router-link to="/">{{ $t("navbar.dashboard") }}</router-link>
           </el-dropdown-item>
           <el-dropdown-item>
-            <router-link to="/info/index">{{$t('navbar.userinfo')}}</router-link>
+            <router-link to="/info/index">{{
+              $t("navbar.userinfo")
+            }}</router-link>
           </el-dropdown-item>
-          <el-dropdown-item @click.native="logout"
-                            divided>{{$t('navbar.logOut')}}
+          <el-dropdown-item @click.native="logout" divided
+            >{{ $t("navbar.logOut") }}
           </el-dropdown-item>
         </el-dropdown-menu>
       </el-dropdown>
@@ -100,93 +120,91 @@
   </div>
 </template>
 <script>
-  import {resetRouter} from '@/router/router'
-  import {mapGetters, mapState} from "vuex";
-  import {fullscreenToggel, listenfullscreen} from "@/util/util";
-  import topLock from "./top-lock";
-  import topMenu from "./top-menu";
-  import topSearch from "./top-search";
-  import topTheme from "./top-theme";
-  import topLogs from "./top-logs";
-  import topColor from "./top-color";
-  import topNotice from './top-notice'
-  import topLang from "./top-lang";
+import { resetRouter } from "@/router/router";
+import { mapGetters, mapState } from "vuex";
+import { fullscreenToggel, listenfullscreen } from "@/util/util";
+import topLock from "./top-lock";
+import topMenu from "./top-menu";
+import topSearch from "./top-search";
+import topTheme from "./top-theme";
+import topLogs from "./top-logs";
+import topColor from "./top-color";
+import topNotice from "./top-notice";
+import topLang from "./top-lang";
 
-  export default {
-    components: {
-      topLock,
-      topMenu,
-      topSearch,
-      topTheme,
-      topLogs,
-      topColor,
-      topNotice,
-      topLang
+export default {
+  components: {
+    topLock,
+    topMenu,
+    topSearch,
+    topTheme,
+    topLogs,
+    topColor,
+    topNotice,
+    topLang,
+  },
+  name: "top",
+  data() {
+    return {};
+  },
+  filters: {},
+  created() {},
+  mounted() {
+    listenfullscreen(this.setScreen);
+  },
+  computed: {
+    ...mapState({
+      showDebug: (state) => state.common.showDebug,
+      showTheme: (state) => state.common.showTheme,
+      showLock: (state) => state.common.showLock,
+      showFullScren: (state) => state.common.showFullScren,
+      showCollapse: (state) => state.common.showCollapse,
+      showSearch: (state) => state.common.showSearch,
+      showMenu: (state) => state.common.showMenu,
+      showColor: (state) => state.common.showColor,
+    }),
+    ...mapGetters([
+      "userInfo",
+      "isFullScren",
+      "tagWel",
+      "tagList",
+      "isCollapse",
+      "tag",
+      "logsLen",
+      "logsFlag",
+    ]),
+  },
+  methods: {
+    handleScreen() {
+      fullscreenToggel();
     },
-    name: "top",
-    data() {
-      return {};
+    setCollapse() {
+      this.$store.commit("SET_COLLAPSE");
     },
-    filters: {},
-    created() {
+    setScreen() {
+      this.$store.commit("SET_FULLSCREN");
     },
-    mounted() {
-      listenfullscreen(this.setScreen);
-    },
-    computed: {
-      ...mapState({
-        showDebug: state => state.common.showDebug,
-        showTheme: state => state.common.showTheme,
-        showLock: state => state.common.showLock,
-        showFullScren: state => state.common.showFullScren,
-        showCollapse: state => state.common.showCollapse,
-        showSearch: state => state.common.showSearch,
-        showMenu: state => state.common.showMenu,
-        showColor: state => state.common.showColor
-      }),
-      ...mapGetters([
-        "userInfo",
-        "isFullScren",
-        "tagWel",
-        "tagList",
-        "isCollapse",
-        "tag",
-        "logsLen",
-        "logsFlag"
-      ])
-    },
-    methods: {
-      handleScreen() {
-        fullscreenToggel();
-      },
-      setCollapse() {
-        this.$store.commit("SET_COLLAPSE");
-      },
-      setScreen() {
-        this.$store.commit("SET_FULLSCREN");
-      },
-      logout() {
-        this.$confirm(this.$t("logoutTip"), this.$t("tip"), {
-          confirmButtonText: this.$t("submitText"),
-          cancelButtonText: this.$t("cancelText"),
-          type: "warning"
-        }).then(() => {
+    logout() {
+      this.$confirm(this.$t("logoutTip"), this.$t("tip"), {
+        confirmButtonText: this.$t("submitText"),
+        cancelButtonText: this.$t("cancelText"),
+        type: "warning",
+      }).then(() => {
+        //关闭webSocket
+        window.socket.close();
+        //关闭报警循环
+        window.clearTimeout(window.realTimeQuery);
+        //关闭心跳循环
+        window.clearTimeout(window.websockPing);
 
-          //关闭webSocket
-          window.socket.close();
-          //关闭报警循环
-          window.clearTimeout(window.realTimeQuery);
-          //关闭心跳循环
-          window.clearTimeout(window.websockPing);
-
-          this.$store.dispatch("LogOut").then(() => {
-            resetRouter();
-            this.$router.push({path: "/login"});
-          });
+        this.$store.dispatch("LogOut").then(() => {
+          resetRouter();
+          this.$router.push({ path: "/login" });
         });
-      }
-    }
-  };
+      });
+    },
+  },
+};
 </script>
 
 <style lang="scss" scoped>
diff --git a/src/page/index/top/top-menu.vue b/src/page/index/top/top-menu.vue
index 672df99..132efd0 100644
--- a/src/page/index/top/top-menu.vue
+++ b/src/page/index/top/top-menu.vue
@@ -1,25 +1,36 @@
 <template>
   <div class="top-menu">
-    <el-menu :default-active="activeIndex"
-             mode="horizontal"
-             text-color="#333">
-      <el-menu-item index="0" @click.native="openHome(itemHome)" key="0">
+    <el-menu :default-active="activeIndex" mode="horizontal" text-color="#333">
+      <el-menu-item index="0" @click.native="openHome(dataItem)" key="0">
         <template slot="title">
-          <i :class="itemHome.source"></i>
-          <span>{{generateTitle(itemHome)}}</span>
+          <i :class="dataItem.source" :title="dataItem.name"></i>
         </template>
       </el-menu-item>
-<!--      <el-menu-item index="0" @click.native="openHomes(ZHAJ)" key="0">-->
-<!--        <template slot="title">-->
-<!--          <i :class="ZHAJ.source"></i>-->
-<!--          <span>{{generateTitle(ZHAJ)}}</span>-->
-<!--        </template>-->
-<!--      </el-menu-item>-->
-      <template v-for="(item,index) in items">
-        <el-menu-item :index="item.id+''" @click.native="openMenu(item)" :key="index">
+      <el-menu-item index="1" @click.native="openHome(mapItem)" key="0">
+        <template slot="title">
+          <i :class="mapItem.source" :title="mapItem.name"></i>
+        </template>
+      </el-menu-item>
+      <el-menu-item index="2" @click.native="openHome(cardItem)" key="0">
+        <template slot="title">
+          <i :class="cardItem.source" :title="cardItem.name"></i>
+        </template>
+      </el-menu-item>
+      <!--      <el-menu-item index="0" @click.native="openHomes(ZHAJ)" key="0">-->
+      <!--        <template slot="title">-->
+      <!--          <i :class="ZHAJ.source"></i>-->
+      <!--          <span>{{generateTitle(ZHAJ)}}</span>-->
+      <!--        </template>-->
+      <!--      </el-menu-item>-->
+      <template v-for="(item, index) in items">
+        <el-menu-item
+          :index="item.id + ''"
+          @click.native="openMenu(item)"
+          :key="index"
+        >
           <template slot="title">
-            <i :class="item.source" style="padding-right: 5px;"></i>
-            <span>{{generateTitle(item)}}</span>
+            <i :class="item.source" style="padding-right: 5px"></i>
+            <span>{{ generateTitle(item) }}</span>
           </template>
         </el-menu-item>
       </template>
@@ -28,58 +39,76 @@
 </template>
 
 <script>
-  import {mapGetters} from "vuex";
+import { mapGetters } from "vuex";
 
-  export default {
-    name: "top-menu",
-    data() {
-      return {
-        itemHome: {
-          name: '数据模式',
-          source: 'el-icon-menu',
-        },
-        ZHAJ: {
-          name: '智慧安检',
-          source: 'icon-anbao',
-        },
-        activeIndex: "0",
-        items: [],
-      };
+export default {
+  name: "top-menu",
+  data() {
+    return {
+      dataItem: {
+        name: "数据模式",
+        source: "el-icon-s-data",
+        path: "/wel/index",
+      },
+      mapItem: {
+        name: "地图模式",
+        source: "el-icon-location",
+        path: "/welcomeData/map",
+      },
+      cardItem: {
+        name: "卡片模式",
+        source: "el-icon-menu",
+        path: "/welcomeData/card",
+      },
+      ZHAJ: {
+        name: "智慧安检",
+        source: "icon-anbao",
+      },
+      activeIndex: "0",
+      items: [],
+    };
+  },
+  inject: ["index"],
+  created() {
+    this.getMenu();
+  },
+  computed: {
+    ...mapGetters(["tagCurrent", "menu"]),
+  },
+  methods: {
+    openHome(itemHome) {
+      this.index.openMenu(itemHome);
+      this.$router.push({
+        path: itemHome.path,
+      });
     },
-    inject: ["index"],
-    created() {
-      this.getMenu();
+    openHomes(itemHome) {
+      this.index.openMenu(itemHome);
+      this.$router.push({
+        path: this.$router.$avueRouter.getPath(
+          {
+            name: itemHome.name,
+            src:
+              "https://cas.sf-express.com/cas/login?service=http://fengkong.sf-express.com/backstageprd/#/homeInfo/infoOverview",
+          },
+          {}
+        ),
+      });
     },
-    computed: {
-      ...mapGetters(["tagCurrent", "menu"])
+    openMenu(item) {
+      this.index.openMenu(item);
     },
-    methods: {
-      openHome(itemHome) {
-        this.index.openMenu(itemHome);
-        this.$router.push({
-          path: this.$router.$avueRouter.getPath({name: itemHome.name, src: ''}, {})
-        });
-      },
-      openHomes(itemHome) {
-        this.index.openMenu(itemHome);
-        this.$router.push({
-          path: this.$router.$avueRouter.getPath({name: itemHome.name, src: 'https://cas.sf-express.com/cas/login?service=http://fengkong.sf-express.com/backstageprd/#/homeInfo/infoOverview'}, {})
-        });
-      },
-      openMenu(item) {
-        this.index.openMenu(item)
-      },
-      getMenu() {
-        this.$store.dispatch("GetTopMenu").then(res => {
-          this.items = res;
-        });
-      },
-      generateTitle(item) {
-        return this.$router.$avueRouter.generateTitle(
-          item.name,
-          (item.meta || {}).i18n
-        );
-      },
-    }
-  };
+    getMenu() {
+      this.$store.dispatch("GetTopMenu").then((res) => {
+        this.items = res;
+      });
+    },
+    generateTitle(item) {
+      return this.$router.$avueRouter.generateTitle(
+        item.name,
+        (item.meta || {}).i18n
+      );
+    },
+  },
+};
 </script>

--
Gitblit v1.9.3