2023西安数博会CIM演示-【前端】-Web
AdaKing88
2023-08-21 bc03b832caa49bbcd2674fe4cae3701b5059bf95
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
<!--
 * @Description: 头部导航
 * @Author: 王旭
 * @Date: 2022-03-01 15:49:47
 * @LastEditTime: 2023-05-06 11:34:57
 * @LastEditors: Andy
-->
<template>
  <div class="header_box" :style="styleVar">
    <el-menu
      :default-active="`${pathName}`"
      class="el-menu-demo"
      :background-color="styleVar['--header-color']"
      mode="horizontal"
      active-text-color="#2bb8de"
      router
    >
      <el-menu-item class="logo_box">
        <div>
          <el-image
            :src="url"
            fit="cover"
            style="width: 33px; height: 33px"
          ></el-image>
          <span class="appName"> {{ appName }}</span>
        </div>
      </el-menu-item>
      <!-- <el-menu-item index="/developcenter">
        <span class="menu_title">全息展示</span>
      </el-menu-item> -->
      <el-submenu index="1">
        <template slot="title" index=""
          ><span class="menu_title">资源中心</span></template
        >
        <el-menu-item index="/developcenter"
          ><span class="menu_title">全息展示</span></el-menu-item
        >
        <el-menu-item index="/mysource"
          ><span class="menu_title">我的资源</span></el-menu-item
        >
        <!-- <el-menu-item index="/cimdata"><span class="menu_sub_title">CIM成果库</span></el-menu-item>
        <el-menu-item index="/spacetime"><span class="menu_sub_title">时空数据</span></el-menu-item>
        <el-menu-item index="/iotdata"><span class="menu_sub_title">物联感知</span></el-menu-item>
        <el-menu-item index="/engineerdata"><span class="menu_sub_title">工程项目</span></el-menu-item>
        <el-menu-item index="/plandata"><span class="menu_sub_title">规划管理</span></el-menu-item>
        <el-menu-item index="/surveydata"><span class="menu_sub_title">资源调查</span></el-menu-item>
        <el-menu-item index="/publicdata"><span class="menu_sub_title">公共专题</span></el-menu-item> -->
      </el-submenu>
      <el-menu-item index="/servicesmanager">
        <span class="menu_title">服务中心</span>
      </el-menu-item>
      <el-menu-item index="/appusecenter">
        <span class="menu_title">应用中心</span>
      </el-menu-item>
      <!-- <el-menu-item index="/sysmanager">
        <span class="menu_title">运维中心</span>
      </el-menu-item> -->
      <el-submenu index="3">
        <template slot="title" index=""
          ><span class="help_title">运维中心</span></template
        >
        <el-menu-item index="/usermanager"
          ><span class="menu_sub_title">用户管理</span></el-menu-item
        >
        <el-menu-item index="/rolemanager"
          ><span class="menu_sub_title">角色管理</span></el-menu-item
        >
        <el-menu-item index="/devmanager"
          ><span class="menu_sub_title">部门管理</span></el-menu-item
        >
      </el-submenu>
      <el-submenu index="2">
        <template slot="title" index=""
          ><span class="help_title">开发中心</span></template
        >
        <el-menu-item index="/demosource"
          ><span class="menu_sub_title">开发示例</span></el-menu-item
        >
        <el-menu-item index="/apidoc"
          ><span class="menu_sub_title">接口文档</span></el-menu-item
        >
      </el-submenu>
      <!-- <el-menu-item index="/demosource">
        <span class="menu_title">开发中心</span>
      </el-menu-item> -->
 
      <div class="nav_box">
        <el-menu-item>
          <!-- 用户信息 -->
          <el-dropdown @command="handleCommand" trigger="click">
            <span class="menu_title el-icon-user-solid"
              >{{ user.username
              }}<i class="el-icon-arrow-down el-icon--right"></i
            ></span>
            <el-dropdown-menu slot="dropdown">
              <el-dropdown-item icon="el-icon-error" command="1"
                >退出登陆</el-dropdown-item
              >
            </el-dropdown-menu>
          </el-dropdown>
        </el-menu-item>
      </div>
    </el-menu>
  </div>
</template>
 
<script>
import { removeToken } from "@/utils/auth";
import { mapState } from "vuex";
export default {
  //import引入的组件需要注入到对象中才能使用
  components: {},
  props: {
    user: {
      type: Object,
      default: () => {
        return { username: "admin" };
      },
    },
  },
  data() {
    //这里存放数据
    return {
      styleVar: {
        "--color": "rgba(14, 22, 32, 0.65)",
        "--header-color": "#fff",
        "--background-hover": "transparent",
      },
      pathName: "",
      url: require("../assets/img/firstpage/logo.png"),
      testData: {},
      imgUrl:
        "https://cube.elemecdn.com/3/7c/3ea6beec64369c2642b92c6726f1epng.png",
    };
  },
  watch: {
    // 监听,当路由发生变化的时候执行
    $route(to, from) {
      this.UPstyle(to.path);
      this.pathName = to.path;
    },
    appName(val, newVal) {
      console.log('xxxxx',val, newVal)
    }
  },
  //方法集合
  methods: {
    // 退出登录
    handleCommand(command) {
      if (command == 1) {
        this.$confirm("确认要退出系统么?", "退出", {
          confirmButtonText: "确定",
          cancelButtonText: "取消",
          type: "warning",
        })
          .then(() => {
            removeToken();
            this.$router.push("/login");
            // this.$router.go(0);
          })
          .catch(() => {});
      }
    },
    //修改样式
    UPstyle(e) {
      if (e == "/firstpage") {
        this.styleVar["--header-color"] = "#0d1b2e";
        this.styleVar["--color"] = "rgba(240, 250, 254, 0.85)";
      } else {
        this.styleVar["--header-color"] = "#fff";
        this.styleVar["--color"] = "rgba(14, 22, 32, 0.65)";
      }
    },
  },
  computed: {
    ...mapState(["appName", "headerColor"]),
  },
  created() {
    this.pathName = this.$route.path;
    this.UPstyle(this.$route.path);
  },
};
</script>
<style lang="less" scoped>
//@import url(); 引入公共css类
.appName {
  font-size: 26px;
  font-weight: 500;
  color: #00a6e2;
}
 
.el-menu-demo {
  border-bottom: 0 !important;
}
 
.el-menu-item {
  color: var(--color);
}
 
.nav_box {
  display: flex;
  justify-content: flex-end;
 
  .menu_title {
    font-weight: 600;
    font-size: 16px;
  }
}
 
.el-menu-item:hover {
  background-color: var(--background-hover) !important;
  outline: 0 !important;
  color: #2bb8de !important;
}
 
.el-menu-item.is-active {
  border-bottom: 3px solid #2bb8de !important;
  background-color: var(--background-hover) !important;
}
 
.logo_box {
  background: url("../assets/img/firstpage/heardlogo.png") no-repeat;
  background-position: center;
  background-size: 100% 100%;
  display: flex;
  justify-content: space-around;
  align-items: center;
}
</style>