Commit 5f846a5c authored by 晓彤's avatar 晓彤

菜单展示

parent 1f444afa
import request from '@/utils/holmesRequest'
// 登陆接口
export function login(data) {
return request({
url: '/user/login',
method: 'post',
data
})
}
export function getUserDetail(paramInfo) {
return request({
url: '/user/info',
method: 'get',
params: paramInfo
})
}
...@@ -13,6 +13,26 @@ ...@@ -13,6 +13,26 @@
-moz-osx-font-smoothing: grayscale; -moz-osx-font-smoothing: grayscale;
} }
.icon-password:before {
content: "\e609";
}
.icon-username:before {
content: "\e73f";
}
.icon-password1:before {
content: "\e606";
}
.icon-password2:before {
content: "\e610";
}
.icon-username1:before {
content: "\e601";
}
.icon-questionmarko:before { .icon-questionmarko:before {
content: "\e62a"; content: "\e62a";
} }
......
This source diff could not be displayed because it is too large. You can view the blob instead.
...@@ -5,6 +5,41 @@ ...@@ -5,6 +5,41 @@
"css_prefix_text": "icon-", "css_prefix_text": "icon-",
"description": "", "description": "",
"glyphs": [ "glyphs": [
{
"icon_id": "5700816",
"name": "password",
"font_class": "password",
"unicode": "e609",
"unicode_decimal": 58889
},
{
"icon_id": "7712744",
"name": "username",
"font_class": "username",
"unicode": "e73f",
"unicode_decimal": 59199
},
{
"icon_id": "11219362",
"name": "password",
"font_class": "password1",
"unicode": "e606",
"unicode_decimal": 58886
},
{
"icon_id": "16474557",
"name": "password",
"font_class": "password2",
"unicode": "e610",
"unicode_decimal": 58896
},
{
"icon_id": "20981768",
"name": "username",
"font_class": "username1",
"unicode": "e601",
"unicode_decimal": 58881
},
{ {
"icon_id": "737960", "icon_id": "737960",
"name": "question-mark-o", "name": "question-mark-o",
......
import Vue from 'vue' import Vue from 'vue'
import Router from 'vue-router' import Router from 'vue-router'
import Index from '../views/index/Index' import Login from '../views/login/Login'
// import Login from '../views/login/Login' // import Login from '../views/login/Login'
import Main from '../views/Main' import Main from '../views/Main'
// import Home from '../views/Home' // import Home from '../views/Home'
...@@ -45,12 +45,12 @@ const router = new Router({ ...@@ -45,12 +45,12 @@ const router = new Router({
routes: [ routes: [
{ {
path: '/', path: '/',
redirect: '/index' redirect: '/login'
}, },
{ {
path: '/index', path: '/login',
name: '登录页', name: '登录页',
component: Index component: Login
}, },
// { // {
// 'path': '/login', // 'path': '/login',
......
import axios from 'axios' import axios from 'axios'
const service = axios.create( const service = axios.create({
{
baseURL: process.env.HOLMES, baseURL: process.env.HOLMES,
timeout: 500000 timeout: 500000
} })
)
// request interceptor // request 拦截器
service.interceptors.request.use( service.interceptors.request.use(
config => {
let token = window.sessionStorage.getItem('token')
// console.log('666', token)
if (token) {
config.headers.token = token
}
return config
},
error => {
console.error(error)
Promise.reject(error)
}
) )
// response interceptor // response 拦截器
service.interceptors.response.use( service.interceptors.response.use(
response => response, response => response,
error => { error => {
......
<template>
<div class="main">
<div class="container">
<h3 class="title">QA测试平台</h3>
<el-select v-model="namespace" placeholder="请选择环境" @change="handleSelectChange" style="width: 100%; margin-top: 20px">
<el-option v-for="item in nsOptions" :key="item.key" :label="item.desc" :value="item.key"></el-option>
</el-select>
<el-button type="primary" style="width: 100%; margin-top: 40px;" @click="login">登录</el-button>
</div>
</div>
</template>
<script>
import { getNamespaceList } from '@/api/getXyqbData/'
export default {
data() {
return {
namespace: '',
nsOptions: []
}
},
methods: {
// 给store.state.env赋值
handleSelectChange() {
window.sessionStorage.setItem('env', this.namespace)
},
login() {
if (this.namespace === '') {
return this.$message.error('请先选择环境')
}
this.$router.push('/main')
},
getNamespaceList() {
getNamespaceList().then((resp) => {
this.nsOptions = resp.data.data
})
}
},
created() {
this.getNamespaceList()
}
}
</script>
<style lang="less" scoped>
.main {
position: fixed;
height: 100%;
width: 100%;
// background-color: #2d3a4b;
background-image: url('../../assets/image/quant.png');
background-size: contain;
.container {
height: 300px;
width: 400px;
margin: 200px auto;
padding: 20px;
}
}
.title {
text-align: center;
font-size: 26px;
color: #ffffff;
}
.area {
margin-top: 40px;
}
</style>
...@@ -32,6 +32,7 @@ ...@@ -32,6 +32,7 @@
<script> <script>
import { mapGetters } from 'vuex' import { mapGetters } from 'vuex'
import menu from './menu.json' import menu from './menu.json'
// import { getUserDetail } from '@/api/getLogin/'
export default { export default {
name: 'Aside', name: 'Aside',
data() { data() {
...@@ -39,16 +40,46 @@ export default { ...@@ -39,16 +40,46 @@ export default {
nav: [], // 左侧导航数据数组 nav: [], // 左侧导航数据数组
defaultOpen: ['0'], defaultOpen: ['0'],
// 激活的菜单 // 激活的菜单
activePath: '' activePath: '',
menuList: [],
newNav: []
} }
}, },
methods: { methods: {
getNav() { getNav() {
this.nav = menu.menu this.nav = menu.menu
console.log('444', this.nav)
// 循环判断新列表里的是数据是否在旧列表里出现
this.nav.forEach((element) => {
var temp = {}
temp['id'] = element.id
temp['icon'] = element.icon
temp['title'] = element.title
temp['child'] = []
element.child.forEach((children) => {
console.log('children: ', children)
var flag = false
console.log(this.menuList)
this.menuList.forEach((menu) => {
console.log('menu: ', menu)
console.log('children.path', children.path)
if (menu === children.path) {
flag = true
}
})
if (flag === true) {
temp['child'].push(children)
}
})
this.newNav.push(temp)
})
console.log('newNav', this.newNav)
this.$store.dispatch('header/setNavs', { this.$store.dispatch('header/setNavs', {
nav: this.nav // nav: this.nav
nav: this.newNav
}) })
}, },
toggle_collapse() { toggle_collapse() {
if (this.getCollapseState === false) { if (this.getCollapseState === false) {
this.$store.commit('header/setCollapse', true) this.$store.commit('header/setCollapse', true)
...@@ -60,6 +91,14 @@ export default { ...@@ -60,6 +91,14 @@ export default {
saveNavState(activePath) { saveNavState(activePath) {
this.activePath = activePath this.activePath = activePath
window.sessionStorage.setItem('activePath', activePath) window.sessionStorage.setItem('activePath', activePath)
},
// 获取用户详细信息
async getUserDetail() {
// getUserDetail().then((resp) => {
// this.menuList = resp.data.data.menuList
// console.log('menuList----', this.menuList)
// })
// this.getNav()
} }
}, },
computed: { computed: {
...@@ -72,8 +111,9 @@ export default { ...@@ -72,8 +111,9 @@ export default {
}) })
}, },
created() { created() {
this.getNav()
this.activePath = window.sessionStorage.getItem('activePath') this.activePath = window.sessionStorage.getItem('activePath')
this.getUserDetail()
this.getNav()
} }
} }
</script> </script>
......
<template> <template>
<div class="login_container"> <div class="main">
<div class="login_box"> <div class="container">
<div class="avatar_box"> <h3 class="title">QA测试平台</h3>
<img src="../../assets/image/qa.jpg" /> <el-form style="margin-left:50px" :model="loginForm" :rules="loginRules" ref="loginFormRef">
</div> <el-form-item prop="username" class="input-style">
<el-form <el-input v-model="loginForm.username" placeholder="请输入用户名" prefix-icon="el-icon-user-solid"></el-input>
:model="loginForm" </el-form-item>
ref="loginFormRef" <el-form-item prop="password" class="input-style">
:rules="loginFormRules" <el-input type="password" @keyup.enter.native="login" v-model="loginForm.password" placeholder="请输入用户名" prefix-icon="el-icon-unlock" show-password></el-input>
label-width="0px"
class="login_form"
>
<el-form-item prop="username">
<el-input v-model="loginForm.username" placeholder="请输入用户名" prefix-icon="el-icon-user"></el-input>
</el-form-item> </el-form-item>
<el-form-item prop="password"> <el-form-item class="input-style" prop="namespace">
<el-input <el-select v-model="loginForm.namespace" placeholder="请选择环境" @change="handleSelectChange" style="width: 100%;">
v-model="loginForm.password" <el-option v-for="item in nsOptions" :key="item.key" :label="item.desc" :value="item.key"></el-option>
placeholder="请输入密码" </el-select>
type="password"
prefix-icon="el-icon-lock"
></el-input>
</el-form-item> </el-form-item>
<el-form-item class="btns"> <el-form-item class="input-style">
<el-button type="primary" @click="login">登录</el-button> <el-button type="primary" style="width: 100%; margin-top: 20px;" @click="login">登录</el-button>
<el-button type="info" v-on:click="resetForm">重置</el-button>
</el-form-item> </el-form-item>
</el-form> </el-form>
</div> </div>
...@@ -32,101 +23,91 @@ ...@@ -32,101 +23,91 @@
</template> </template>
<script> <script>
import { getNamespaceList } from '@/api/getXyqbData/'
import { login } from '@/api/getLogin/'
export default { export default {
data() { data() {
return { return {
namespace: '',
nsOptions: [],
loginForm: { loginForm: {
username: '', username: '',
password: '' password: '',
namespace: ''
}, },
loginFormRules: { loginRules: {
// username: [ username: [
// { required: true, message: '请输入用户名', trigger: 'blur' }, { required: true, trigger: 'blur', message: '请输入用户名' }
// { min: 3, max: 8, message: '长度在3到8个字符之间', trigger: 'blur' } ],
// ], password: [{ required: true, trigger: 'blur', message: '请输入密码' }],
// password: [ namespace: [{ required: true, trigger: 'blur', message: '请选择环境' }]
// { required: true, message: '请输入密码', trigger: 'blur' }, },
// { min: 6, max: 15, message: '长度在6到16个字符之间', trigger: 'blur' } token: ''
// ]
}
} }
}, },
methods: { methods: {
resetForm() { // 给store.state.env赋值
this.$refs.loginFormRef.resetFields() handleSelectChange() {
window.sessionStorage.setItem('env', this.loginForm.namespace)
}, },
login() { login() {
this.$refs.loginFormRef.validate(valid => { this.$refs.loginFormRef.validate((valid) => {
if (!valid) { if (!valid) {
return false return false
} else { } else {
this.$axios // 调取登陆接口
.post('login', this.loginForm) login(this.loginForm)
.then(response => { .then((resp) => {
if (response.data.meta.status === 200) { // 将token放到Application中
this.$message.success('登录成功') window.sessionStorage.setItem('token', resp.data.data.token)
window.sessionStorage.setItem('token', response.data.data.token) this.$router.push('/main')
this.$router.push('/home')
} else {
this.$message.error('登录失败')
}
}) })
.catch(error => { .catch((error) => {
console.log(error) this.$message({ type: 'error', message: error })
}) })
} }
}) })
},
getNamespaceList() {
getNamespaceList().then((resp) => {
this.nsOptions = resp.data.data
})
} }
},
created() {
this.getNamespaceList()
} }
} }
</script> </script>
<style lang="less" scoped> <style lang="less" scoped>
.login_container { .main {
background-color: #2b4b6b; position: fixed;
height: 100%; height: 100%;
}
.login_box {
width: 500px;
height: 320px;
background-color: #ffffff;
border-radius: 3px;
position: absolute;
left: 50%;
top: 50%;
transform: translate(-50%, -50%);
.avatar_box {
height: 130px;
width: 130px;
border: 1px solid #eeeeee;
border-radius: 50%;
padding: 10px;
box-shadow: 0 0 10px #dddddd;
position: absolute;
left: 50%;
transform: translate(-50%, -50%);
background-color: #ffffff;
img {
width: 100%; width: 100%;
height: 100%; // background-color: #2d3a4b;
border-radius: 50%; background-image: url('../../assets/image/quant.png');
background-color: #eeeeee; background-size: contain;
} .container {
height: 300px;
width: 400px;
margin: 200px auto;
padding: 20px;
} }
} }
.title {
.login_form { text-align: center;
position: absolute; font-size: 26px;
bottom: 0; color: #ffffff;
width: 100%;
padding: 0 10px;
box-sizing: border-box;
} }
.area {
.btns { margin-top: 40px;
display: flex; }
justify-content: flex-end; .input-style {
width: 350px;
height: 50px;
}
/deep/.el-input__inner {
height: 45px !important;
} }
</style> </style>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment