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 @@
-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 {
content: "\e62a";
}
......
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -5,6 +5,41 @@
"css_prefix_text": "icon-",
"description": "",
"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",
"name": "question-mark-o",
......
import Vue from 'vue'
import Router from 'vue-router'
import Index from '../views/index/Index'
import Login from '../views/login/Login'
// import Login from '../views/login/Login'
import Main from '../views/Main'
// import Home from '../views/Home'
......@@ -45,12 +45,12 @@ const router = new Router({
routes: [
{
path: '/',
redirect: '/index'
redirect: '/login'
},
{
path: '/index',
path: '/login',
name: '登录页',
component: Index
component: Login
},
// {
// 'path': '/login',
......
import axios from 'axios'
const service = axios.create(
{
baseURL: process.env.HOLMES,
timeout: 500000
}
)
const service = axios.create({
baseURL: process.env.HOLMES,
timeout: 500000
})
// request interceptor
// request 拦截器
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(
response => response,
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 @@
<script>
import { mapGetters } from 'vuex'
import menu from './menu.json'
// import { getUserDetail } from '@/api/getLogin/'
export default {
name: 'Aside',
data() {
......@@ -39,16 +40,46 @@ export default {
nav: [], // 左侧导航数据数组
defaultOpen: ['0'],
// 激活的菜单
activePath: ''
activePath: '',
menuList: [],
newNav: []
}
},
methods: {
getNav() {
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', {
nav: this.nav
// nav: this.nav
nav: this.newNav
})
},
toggle_collapse() {
if (this.getCollapseState === false) {
this.$store.commit('header/setCollapse', true)
......@@ -60,6 +91,14 @@ export default {
saveNavState(activePath) {
this.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: {
......@@ -72,8 +111,9 @@ export default {
})
},
created() {
this.getNav()
this.activePath = window.sessionStorage.getItem('activePath')
this.getUserDetail()
this.getNav()
}
}
</script>
......
<template>
<div class="login_container">
<div class="login_box">
<div class="avatar_box">
<img src="../../assets/image/qa.jpg" />
</div>
<el-form
:model="loginForm"
ref="loginFormRef"
:rules="loginFormRules"
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>
<div class="main">
<div class="container">
<h3 class="title">QA测试平台</h3>
<el-form style="margin-left:50px" :model="loginForm" :rules="loginRules" ref="loginFormRef">
<el-form-item prop="username" class="input-style">
<el-input v-model="loginForm.username" placeholder="请输入用户名" prefix-icon="el-icon-user-solid"></el-input>
</el-form-item>
<el-form-item prop="password">
<el-input
v-model="loginForm.password"
placeholder="请输入密码"
type="password"
prefix-icon="el-icon-lock"
></el-input>
<el-form-item prop="password" class="input-style">
<el-input type="password" @keyup.enter.native="login" v-model="loginForm.password" placeholder="请输入用户名" prefix-icon="el-icon-unlock" show-password></el-input>
</el-form-item>
<el-form-item class="btns">
<el-button type="primary" @click="login">登录</el-button>
<el-button type="info" v-on:click="resetForm">重置</el-button>
<el-form-item class="input-style" prop="namespace">
<el-select v-model="loginForm.namespace" placeholder="请选择环境" @change="handleSelectChange" style="width: 100%;">
<el-option v-for="item in nsOptions" :key="item.key" :label="item.desc" :value="item.key"></el-option>
</el-select>
</el-form-item>
<el-form-item class="input-style">
<el-button type="primary" style="width: 100%; margin-top: 20px;" @click="login">登录</el-button>
</el-form-item>
</el-form>
</div>
......@@ -32,101 +23,91 @@
</template>
<script>
import { getNamespaceList } from '@/api/getXyqbData/'
import { login } from '@/api/getLogin/'
export default {
data() {
return {
namespace: '',
nsOptions: [],
loginForm: {
username: '',
password: ''
password: '',
namespace: ''
},
loginRules: {
username: [
{ required: true, trigger: 'blur', message: '请输入用户名' }
],
password: [{ required: true, trigger: 'blur', message: '请输入密码' }],
namespace: [{ required: true, trigger: 'blur', message: '请选择环境' }]
},
loginFormRules: {
// username: [
// { required: true, message: '请输入用户名', trigger: 'blur' },
// { min: 3, max: 8, message: '长度在3到8个字符之间', trigger: 'blur' }
// ],
// password: [
// { required: true, message: '请输入密码', trigger: 'blur' },
// { min: 6, max: 15, message: '长度在6到16个字符之间', trigger: 'blur' }
// ]
}
token: ''
}
},
methods: {
resetForm() {
this.$refs.loginFormRef.resetFields()
// 给store.state.env赋值
handleSelectChange() {
window.sessionStorage.setItem('env', this.loginForm.namespace)
},
login() {
this.$refs.loginFormRef.validate(valid => {
this.$refs.loginFormRef.validate((valid) => {
if (!valid) {
return false
} else {
this.$axios
.post('login', this.loginForm)
.then(response => {
if (response.data.meta.status === 200) {
this.$message.success('登录成功')
window.sessionStorage.setItem('token', response.data.data.token)
this.$router.push('/home')
} else {
this.$message.error('登录失败')
}
// 调取登陆接口
login(this.loginForm)
.then((resp) => {
// 将token放到Application中
window.sessionStorage.setItem('token', resp.data.data.token)
this.$router.push('/main')
})
.catch(error => {
console.log(error)
.catch((error) => {
this.$message({ type: 'error', message: error })
})
}
})
},
getNamespaceList() {
getNamespaceList().then((resp) => {
this.nsOptions = resp.data.data
})
}
},
created() {
this.getNamespaceList()
}
}
</script>
<style lang="less" scoped>
.login_container {
background-color: #2b4b6b;
.main {
position: fixed;
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%;
height: 100%;
border-radius: 50%;
background-color: #eeeeee;
}
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;
}
}
.login_form {
position: absolute;
bottom: 0;
width: 100%;
padding: 0 10px;
box-sizing: border-box;
.title {
text-align: center;
font-size: 26px;
color: #ffffff;
}
.btns {
display: flex;
justify-content: flex-end;
.area {
margin-top: 40px;
}
.input-style {
width: 350px;
height: 50px;
}
/deep/.el-input__inner {
height: 45px !important;
}
</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