2021-06-07 18:35:16 +08:00
|
|
|
|
<template>
|
|
|
|
|
|
<div class="cn-header">
|
|
|
|
|
|
<!-- <div class="left-menu--pin" :class="false ? 'left-menu--pin-normal' : 'left-menu--pin-reverse'" @click="shrink"><i :class="{'icon-reverse': false}" class="el-icon-s-fold"></i></div>-->
|
|
|
|
|
|
<!--导航面包屑-->
|
2021-08-13 09:39:02 +08:00
|
|
|
|
<div class="header__left">
|
|
|
|
|
|
<span @click="shrink" class="shrink-button" :class="{'shrink-button--collapse': isShrink}"><i class="cn-icon cn-icon-expand"></i></span>
|
|
|
|
|
|
<el-breadcrumb separator="/" style="padding-left: 20px; padding-top: 6px;">
|
|
|
|
|
|
<el-breadcrumb-item :title="item" v-for="item in breadcrumb" :key="item" style="display: inline-block; max-width: 300px; height: 16px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;">
|
|
|
|
|
|
{{item}}
|
|
|
|
|
|
</el-breadcrumb-item>
|
2021-08-12 18:11:38 +08:00
|
|
|
|
</el-breadcrumb>
|
2021-08-13 09:39:02 +08:00
|
|
|
|
<el-select
|
|
|
|
|
|
size="small"
|
|
|
|
|
|
v-model="from"
|
|
|
|
|
|
v-if="showEntityTypeSelector"
|
|
|
|
|
|
style="padding-left: 25px; width: 130px;"
|
|
|
|
|
|
>
|
|
|
|
|
|
<el-option v-for="(value, key) in entityType" :key="key" :label="value" :value="key"></el-option>
|
|
|
|
|
|
</el-select>
|
2021-08-12 18:11:38 +08:00
|
|
|
|
</div>
|
2021-06-07 18:35:16 +08:00
|
|
|
|
<!--个人操作-->
|
|
|
|
|
|
<div class="personal">
|
|
|
|
|
|
<el-dropdown>
|
2021-08-13 09:39:02 +08:00
|
|
|
|
<div class="header-menu--item"><i class="cn-icon cn-icon-language"></i></div>
|
2021-06-07 18:35:16 +08:00
|
|
|
|
<template #dropdown>
|
|
|
|
|
|
<el-dropdown-menu>
|
|
|
|
|
|
<el-dropdown-item>
|
|
|
|
|
|
<div id="header-to-english" :style="language === 'en'?'color:#0091ff':''" @click="changeLocal('en')">English</div>
|
|
|
|
|
|
</el-dropdown-item>
|
|
|
|
|
|
<el-dropdown-item>
|
|
|
|
|
|
<div id="header-to-chinese" :style="language === 'cn'?'color:#0091ff':''" @click="changeLocal('cn')">中文</div>
|
|
|
|
|
|
</el-dropdown-item>
|
|
|
|
|
|
</el-dropdown-menu>
|
|
|
|
|
|
</template>
|
|
|
|
|
|
</el-dropdown>
|
|
|
|
|
|
<el-dropdown>
|
|
|
|
|
|
<div class='login-user header-menu--item'>{{username}} <i class="cn-icon cn-icon-arrow-down"></i></div>
|
|
|
|
|
|
<template #dropdown>
|
2021-08-13 09:39:02 +08:00
|
|
|
|
<el-dropdown-menu>
|
2021-06-07 18:35:16 +08:00
|
|
|
|
<el-dropdown-item>
|
|
|
|
|
|
<div id="header-to-changepin" @click="showPinDialog">Change pin</div>
|
|
|
|
|
|
</el-dropdown-item>
|
|
|
|
|
|
<el-dropdown-item>
|
|
|
|
|
|
<div id="header-to-logout" @click="logout">Sign out</div>
|
|
|
|
|
|
</el-dropdown-item>
|
|
|
|
|
|
</el-dropdown-menu>
|
|
|
|
|
|
</template>
|
|
|
|
|
|
</el-dropdown>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
<!-- <change-password :cur-user="username" :show-dialog="showChangePin" @click="showPinDialog" @dialogClosed="dialogClosed"></change-password>-->
|
2021-08-24 17:36:27 +08:00
|
|
|
|
<el-dialog title="提示"
|
|
|
|
|
|
v-model="showChangePin"
|
|
|
|
|
|
width="30%"
|
|
|
|
|
|
:before-close="handleClose">
|
|
|
|
|
|
<el-form :rules="changePassFormRules" :model="changePassForm" ref="changePassForm">
|
|
|
|
|
|
<el-row :gutter="20">
|
|
|
|
|
|
<el-col :span="24">
|
|
|
|
|
|
<el-form-item label="旧密码" prop="oldPass">
|
|
|
|
|
|
<el-input v-model="changePassForm.oldPass" type="password"></el-input>
|
|
|
|
|
|
</el-form-item>
|
|
|
|
|
|
</el-col>
|
|
|
|
|
|
<el-col :span="24">
|
|
|
|
|
|
<el-form-item label="新密码" prop="newPass">
|
|
|
|
|
|
<el-input v-model="changePassForm.newPass" type="password"></el-input>
|
|
|
|
|
|
</el-form-item>
|
|
|
|
|
|
</el-col>
|
|
|
|
|
|
<el-col :span="24">
|
|
|
|
|
|
<el-form-item label="确认新密码" prop="newPass2">
|
|
|
|
|
|
<el-input v-model="changePassForm.newPass2" type="password"></el-input>
|
|
|
|
|
|
</el-form-item>
|
|
|
|
|
|
</el-col>
|
|
|
|
|
|
</el-row>
|
|
|
|
|
|
</el-form>
|
|
|
|
|
|
<template #footer>
|
|
|
|
|
|
<span class="dialog-footer">
|
|
|
|
|
|
<el-button @click="showChangePin = false">取 消</el-button>
|
|
|
|
|
|
<el-button type="primary" @click="submit">确认更改密码</el-button>
|
|
|
|
|
|
</span>
|
|
|
|
|
|
</template>
|
|
|
|
|
|
</el-dialog>
|
2021-06-07 18:35:16 +08:00
|
|
|
|
</div>
|
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
|
|
<script>
|
2021-08-12 18:11:38 +08:00
|
|
|
|
import { useRoute } from 'vue-router'
|
2021-08-24 17:36:27 +08:00
|
|
|
|
import { get, put } from '@/utils/http'
|
2021-08-13 09:39:02 +08:00
|
|
|
|
import { entityType, storageKey } from '@/utils/constants'
|
2021-08-24 17:36:27 +08:00
|
|
|
|
import { ElMessage } from 'element-plus'
|
2021-06-07 18:35:16 +08:00
|
|
|
|
export default {
|
|
|
|
|
|
name: 'Header',
|
|
|
|
|
|
data () {
|
2021-08-24 17:36:27 +08:00
|
|
|
|
const passwordYN = (rule, value, callback) => {
|
|
|
|
|
|
if (value === '') {
|
|
|
|
|
|
callback(new Error('请再次输入密码'))
|
|
|
|
|
|
} else if (value !== this.changePassForm.newPass) {
|
|
|
|
|
|
callback(new Error('两次输入密码不一致!'))
|
|
|
|
|
|
} else {
|
|
|
|
|
|
callback()
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2021-06-07 18:35:16 +08:00
|
|
|
|
return {
|
|
|
|
|
|
username: 'admin', // sessionStorage.getItem('cn-username'),
|
|
|
|
|
|
language: localStorage.getItem('cn-language') ? localStorage.getItem('cn-language') : 'en',
|
2021-08-12 18:11:38 +08:00
|
|
|
|
showChangePin: false,
|
|
|
|
|
|
breadcrumbMap: [
|
|
|
|
|
|
{
|
|
|
|
|
|
path: '/panel/trafficSummary',
|
|
|
|
|
|
parentName: this.$t('overall.dashboard'),
|
|
|
|
|
|
name: this.$t('trafficSummary.trafficSummary')
|
|
|
|
|
|
},
|
|
|
|
|
|
{
|
|
|
|
|
|
path: '/panel/networkAppPerformance',
|
|
|
|
|
|
parentName: this.$t('overall.dashboard'),
|
|
|
|
|
|
name: this.$t('networkAppPerformance.networkAppPerformance')
|
|
|
|
|
|
}, {
|
|
|
|
|
|
path: '/panel/dnsServiceInsights',
|
|
|
|
|
|
parentName: this.$t('overall.dashboard'),
|
|
|
|
|
|
name: this.$t('dnsServiceInsights')
|
|
|
|
|
|
}, {
|
|
|
|
|
|
path: '/entityExplorer',
|
2021-08-13 09:39:02 +08:00
|
|
|
|
parentName: this.$t('overall.entities'),
|
|
|
|
|
|
name: this.$t('overall.entityExplorer'),
|
|
|
|
|
|
childName: ''
|
2021-08-12 18:11:38 +08:00
|
|
|
|
}, {
|
|
|
|
|
|
path: '/user',
|
2021-08-13 09:39:02 +08:00
|
|
|
|
parentName: this.$t('overall.setting'),
|
|
|
|
|
|
name: this.$t('overall.user')
|
2021-08-12 18:11:38 +08:00
|
|
|
|
}, {
|
|
|
|
|
|
path: '/role',
|
2021-08-13 09:39:02 +08:00
|
|
|
|
parentName: this.$t('overall.setting'),
|
|
|
|
|
|
name: this.$t('overall.role')
|
2021-08-12 18:11:38 +08:00
|
|
|
|
}, {
|
|
|
|
|
|
path: '/operationLog',
|
2021-08-13 09:39:02 +08:00
|
|
|
|
parentName: this.$t('overall.setting'),
|
2021-08-12 18:11:38 +08:00
|
|
|
|
name: this.$t('overall.operationLog')
|
|
|
|
|
|
}, {
|
|
|
|
|
|
path: '/i18n',
|
2021-08-13 09:39:02 +08:00
|
|
|
|
parentName: this.$t('overall.setting'),
|
|
|
|
|
|
name: 'I18N'
|
2021-08-12 18:11:38 +08:00
|
|
|
|
}
|
2021-08-13 09:39:02 +08:00
|
|
|
|
],
|
2021-08-24 17:36:27 +08:00
|
|
|
|
from: '', // entity类型
|
|
|
|
|
|
changePassForm: {
|
|
|
|
|
|
oldPass: '',
|
|
|
|
|
|
newPass: '',
|
|
|
|
|
|
newPass2: ''
|
|
|
|
|
|
},
|
|
|
|
|
|
changePassFormRules: {
|
|
|
|
|
|
oldPass: [{ required: true, message: '请输入旧密码', trigger: 'blur' }],
|
|
|
|
|
|
newPass: [{ required: true, message: '请输入新密码', trigger: 'blur' }],
|
|
|
|
|
|
newPass2: [{ required: true, message: '请输入新密码', trigger: 'blur' }, { validator: passwordYN, trigger: 'blur' }]
|
|
|
|
|
|
}
|
2021-08-12 18:11:38 +08:00
|
|
|
|
}
|
|
|
|
|
|
},
|
|
|
|
|
|
computed: {
|
|
|
|
|
|
breadcrumb () {
|
|
|
|
|
|
const breadcrumb = this.breadcrumbMap.find(b => this.path === b.path)
|
2021-08-13 09:39:02 +08:00
|
|
|
|
const breadcrumbArray = breadcrumb ? [breadcrumb.parentName, breadcrumb.name] : []
|
|
|
|
|
|
if (breadcrumbArray.length > 0 && breadcrumb.childName) {
|
|
|
|
|
|
breadcrumbArray.push(breadcrumb.childName)
|
|
|
|
|
|
}
|
|
|
|
|
|
return breadcrumbArray
|
2021-08-12 18:11:38 +08:00
|
|
|
|
},
|
|
|
|
|
|
path () {
|
|
|
|
|
|
const { path } = useRoute()
|
|
|
|
|
|
return path
|
2021-08-13 09:39:02 +08:00
|
|
|
|
},
|
|
|
|
|
|
showEntityTypeSelector () {
|
|
|
|
|
|
return this.$store.getters.getShowEntityTypeSelector
|
|
|
|
|
|
},
|
|
|
|
|
|
isShrink () {
|
|
|
|
|
|
return this.$store.getters.getIsShrink
|
|
|
|
|
|
},
|
|
|
|
|
|
entityName () {
|
|
|
|
|
|
return this.$store.getters.entityName
|
2021-08-13 18:57:49 +08:00
|
|
|
|
},
|
|
|
|
|
|
storeFrom () {
|
|
|
|
|
|
return this.$store.getters.from
|
2021-08-13 09:39:02 +08:00
|
|
|
|
}
|
|
|
|
|
|
},
|
|
|
|
|
|
watch: {
|
|
|
|
|
|
from (n) {
|
|
|
|
|
|
this.$store.commit('entityTypeChange', n)
|
|
|
|
|
|
},
|
2021-08-13 18:57:49 +08:00
|
|
|
|
storeFrom (n) {
|
|
|
|
|
|
if (this.from !== n) {
|
|
|
|
|
|
this.from = n
|
|
|
|
|
|
}
|
|
|
|
|
|
},
|
2021-08-13 09:39:02 +08:00
|
|
|
|
entityName (n) {
|
|
|
|
|
|
const breadcrumb = this.breadcrumbMap.find(b => b.path === '/entityExplorer')
|
|
|
|
|
|
breadcrumb.childName = n
|
|
|
|
|
|
}
|
|
|
|
|
|
},
|
|
|
|
|
|
mounted () {
|
|
|
|
|
|
this.from = Object.keys(this.entityType)[0]
|
|
|
|
|
|
},
|
|
|
|
|
|
setup () {
|
|
|
|
|
|
return {
|
|
|
|
|
|
entityType // 所有entity类型,用于header下拉框选择
|
2021-06-07 18:35:16 +08:00
|
|
|
|
}
|
|
|
|
|
|
},
|
|
|
|
|
|
methods: {
|
2021-08-24 17:36:27 +08:00
|
|
|
|
handleClose () {
|
|
|
|
|
|
this.showChangePin = false
|
|
|
|
|
|
},
|
2021-06-07 18:35:16 +08:00
|
|
|
|
changeLocal (lang) {
|
|
|
|
|
|
if (lang !== localStorage.getItem('cn-language')) {
|
|
|
|
|
|
localStorage.setItem('cn-language', lang)
|
|
|
|
|
|
// this.$i18n.locale = lang
|
|
|
|
|
|
window.location.reload()
|
|
|
|
|
|
}
|
|
|
|
|
|
},
|
|
|
|
|
|
showPinDialog () {
|
|
|
|
|
|
this.showChangePin = true
|
|
|
|
|
|
},
|
|
|
|
|
|
logout () {
|
2021-08-13 09:39:02 +08:00
|
|
|
|
sessionStorage.removeItem(storageKey.token)
|
|
|
|
|
|
get('/logout')
|
2021-06-07 18:35:16 +08:00
|
|
|
|
},
|
|
|
|
|
|
refreshLang () {
|
|
|
|
|
|
this.language = localStorage.getItem('cn-language')
|
|
|
|
|
|
this.$i18n.locale = this.language
|
|
|
|
|
|
this.$nextTick(() => {
|
|
|
|
|
|
window.location.reload()
|
|
|
|
|
|
})
|
|
|
|
|
|
},
|
|
|
|
|
|
shrink () {
|
2021-08-13 09:39:02 +08:00
|
|
|
|
this.$store.commit('isShrink', !this.isShrink)
|
2021-08-24 17:36:27 +08:00
|
|
|
|
},
|
|
|
|
|
|
submit () {
|
|
|
|
|
|
this.$refs.changePassForm.validate((valid) => {
|
|
|
|
|
|
if (valid) {
|
|
|
|
|
|
put('sys/user/pin', { oldPin: this.changePassForm.oldPass, newPin: this.changePassForm.newPass }).then(res => {
|
|
|
|
|
|
if (res.code === 200) {
|
|
|
|
|
|
ElMessage.success({
|
|
|
|
|
|
message: '密码修改成功',
|
|
|
|
|
|
type: 'success'
|
|
|
|
|
|
})
|
|
|
|
|
|
this.showChangePin = false
|
|
|
|
|
|
} else if (res.msg == 'user oldpwd error') {
|
|
|
|
|
|
ElMessage.error('密码错误')
|
|
|
|
|
|
}
|
|
|
|
|
|
})
|
|
|
|
|
|
} else {
|
|
|
|
|
|
return false
|
|
|
|
|
|
}
|
|
|
|
|
|
})
|
2021-06-07 18:35:16 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
|
|
<style lang="scss">
|
|
|
|
|
|
.cn-header {
|
|
|
|
|
|
display: flex;
|
|
|
|
|
|
height: 50px;
|
|
|
|
|
|
|
2021-08-13 09:39:02 +08:00
|
|
|
|
.header__left {
|
|
|
|
|
|
display: flex;
|
|
|
|
|
|
align-items: center;
|
|
|
|
|
|
flex-grow: 1;
|
|
|
|
|
|
|
|
|
|
|
|
.shrink-button {
|
|
|
|
|
|
margin-left: 20px;
|
|
|
|
|
|
color: #A4ADB5;
|
|
|
|
|
|
cursor: pointer;
|
|
|
|
|
|
transition: all linear .4s;
|
|
|
|
|
|
|
|
|
|
|
|
&.shrink-button--collapse {
|
|
|
|
|
|
transform: rotateY(180deg);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2021-06-07 18:35:16 +08:00
|
|
|
|
.header-menu {
|
|
|
|
|
|
display: flex;
|
|
|
|
|
|
justify-content: flex-end;
|
|
|
|
|
|
flex-grow: 1;
|
|
|
|
|
|
|
|
|
|
|
|
.el-dropdown {
|
|
|
|
|
|
width: 60px;
|
|
|
|
|
|
text-align: center;
|
|
|
|
|
|
height: 36px;
|
|
|
|
|
|
line-height: 50px;
|
|
|
|
|
|
.el-dialog{
|
|
|
|
|
|
width: 1000px;
|
|
|
|
|
|
height: 70px;
|
|
|
|
|
|
.el-dialog__header{
|
|
|
|
|
|
.el-dialog__title{
|
|
|
|
|
|
color: #fff;
|
|
|
|
|
|
}
|
|
|
|
|
|
.el-dialog__close{
|
|
|
|
|
|
color: #fff;
|
|
|
|
|
|
line-height: 50px;
|
|
|
|
|
|
font-size: 30px;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
.header-menu--item {
|
|
|
|
|
|
color: #778391;
|
|
|
|
|
|
cursor: pointer;
|
|
|
|
|
|
transition: color linear .2s;
|
|
|
|
|
|
i {
|
|
|
|
|
|
font-size: 18px;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
.header-menu--item:hover {
|
|
|
|
|
|
color: #313336;
|
|
|
|
|
|
}
|
|
|
|
|
|
.personal {
|
|
|
|
|
|
display: flex;
|
|
|
|
|
|
.el-dropdown {
|
|
|
|
|
|
margin: 0 10px 0 30px;
|
|
|
|
|
|
height: 36px;
|
|
|
|
|
|
line-height: 50px;
|
|
|
|
|
|
text-align: center;
|
|
|
|
|
|
}
|
|
|
|
|
|
.login-user {
|
|
|
|
|
|
color: #333;
|
|
|
|
|
|
i {
|
|
|
|
|
|
color: #999;
|
|
|
|
|
|
font-size: 12px;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
.left-menu--pin {
|
|
|
|
|
|
width: 20px;
|
|
|
|
|
|
font-size: 20px;
|
|
|
|
|
|
font-weight: 100;
|
|
|
|
|
|
color: #999999;
|
|
|
|
|
|
transition: all .4s;
|
|
|
|
|
|
height: 100%;
|
|
|
|
|
|
line-height: 50px;
|
|
|
|
|
|
margin-left: 10px;
|
|
|
|
|
|
i {
|
|
|
|
|
|
transform: rotateY(0);
|
|
|
|
|
|
transition: transform .4s;
|
|
|
|
|
|
}
|
|
|
|
|
|
i.icon-reverse {
|
|
|
|
|
|
transform: rotateY(180deg);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
.left-menu--pin-normal{
|
|
|
|
|
|
}
|
|
|
|
|
|
.left-menu--pin-reverse{
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
.link-title a {
|
|
|
|
|
|
color: inherit;
|
|
|
|
|
|
text-decoration: none;
|
|
|
|
|
|
}
|
|
|
|
|
|
.cn-breakcrumb {
|
|
|
|
|
|
padding-left: 15px;
|
|
|
|
|
|
line-height: 50px;
|
|
|
|
|
|
|
|
|
|
|
|
.el-breadcrumb__item .el-breadcrumb__inner {
|
|
|
|
|
|
color: #999;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
</style>
|