v1.5 正式版发布 ,详情查看发行版说明
This commit is contained in:
@@ -1,24 +0,0 @@
|
|||||||
import request from '@/utils/request'
|
|
||||||
|
|
||||||
export function add(data) {
|
|
||||||
return request({
|
|
||||||
url: 'api/myTest',
|
|
||||||
method: 'post',
|
|
||||||
data
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
export function del(id) {
|
|
||||||
return request({
|
|
||||||
url: 'api/myTest/' + id,
|
|
||||||
method: 'delete'
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
export function edit(data) {
|
|
||||||
return request({
|
|
||||||
url: 'api/myTest',
|
|
||||||
method: 'put',
|
|
||||||
data
|
|
||||||
})
|
|
||||||
}
|
|
||||||
@@ -2,7 +2,7 @@ import router from './router'
|
|||||||
import store from './store'
|
import store from './store'
|
||||||
import NProgress from 'nprogress' // progress bar
|
import NProgress from 'nprogress' // progress bar
|
||||||
import 'nprogress/nprogress.css'// progress bar style
|
import 'nprogress/nprogress.css'// progress bar style
|
||||||
import { getToken, getStorageToken } from '@/utils/auth' // getToken from cookie
|
import { getToken } from '@/utils/auth' // getToken from cookie
|
||||||
import { buildMenus } from '@/api/menu'
|
import { buildMenus } from '@/api/menu'
|
||||||
import { filterAsyncRouter } from './store/modules/permission'
|
import { filterAsyncRouter } from './store/modules/permission'
|
||||||
|
|
||||||
@@ -12,7 +12,7 @@ const whiteList = ['/login']// no redirect whitelist
|
|||||||
|
|
||||||
router.beforeEach((to, from, next) => {
|
router.beforeEach((to, from, next) => {
|
||||||
NProgress.start() // start progress bar
|
NProgress.start() // start progress bar
|
||||||
if (getToken() || getStorageToken()) {
|
if (getToken()) {
|
||||||
// 已登录且要跳转的页面是登录页
|
// 已登录且要跳转的页面是登录页
|
||||||
if (to.path === '/login') {
|
if (to.path === '/login') {
|
||||||
next({ path: '/' })
|
next({ path: '/' })
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import { login, getInfo } from '@/api/login'
|
import { login, getInfo } from '@/api/login'
|
||||||
import { getToken, setToken, setStorageToken, removeToken } from '@/utils/auth'
|
import { getToken, setToken, removeToken } from '@/utils/auth'
|
||||||
import { parseTime } from '@/utils/index'
|
import { parseTime } from '@/utils/index'
|
||||||
|
|
||||||
const user = {
|
const user = {
|
||||||
@@ -41,11 +41,8 @@ const user = {
|
|||||||
const rememberMe = userInfo.rememberMe
|
const rememberMe = userInfo.rememberMe
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
login(username, password).then(res => {
|
login(username, password).then(res => {
|
||||||
setToken(res.token)
|
setToken(res.token, rememberMe)
|
||||||
commit('SET_TOKEN', res.token)
|
commit('SET_TOKEN', res.token)
|
||||||
if (rememberMe) {
|
|
||||||
setStorageToken(res.token)
|
|
||||||
}
|
|
||||||
resolve()
|
resolve()
|
||||||
}).catch(error => {
|
}).catch(error => {
|
||||||
reject(error)
|
reject(error)
|
||||||
|
|||||||
@@ -1,25 +1,17 @@
|
|||||||
import Cookies from 'js-cookie'
|
import Cookies from 'js-cookie'
|
||||||
|
|
||||||
const TokenKey = 'Admin-Token'
|
const TokenKey = 'Admin-Token'
|
||||||
const storageTokenKey = 'EL_ADMIN_COOKIE_TOKEN'
|
|
||||||
|
|
||||||
export function getToken() {
|
export function getToken() {
|
||||||
return Cookies.get(TokenKey)
|
return Cookies.get(TokenKey)
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getStorageToken() {
|
export function setToken(token, rememberMe) {
|
||||||
return localStorage.getItem(storageTokenKey)
|
if (rememberMe) {
|
||||||
}
|
return Cookies.set(TokenKey, token, { expires: 1 })
|
||||||
|
} else return Cookies.set(TokenKey, token)
|
||||||
export function setToken(token) {
|
|
||||||
return Cookies.set(TokenKey, token)
|
|
||||||
}
|
|
||||||
|
|
||||||
export function setStorageToken(token) {
|
|
||||||
return localStorage.setItem(storageTokenKey, token)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export function removeToken() {
|
export function removeToken() {
|
||||||
localStorage.removeItem(storageTokenKey)
|
|
||||||
return Cookies.remove(TokenKey)
|
return Cookies.remove(TokenKey)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ import axios from 'axios'
|
|||||||
import router from '@/router'
|
import router from '@/router'
|
||||||
import { Notification, MessageBox } from 'element-ui'
|
import { Notification, MessageBox } from 'element-ui'
|
||||||
import store from '../store'
|
import store from '../store'
|
||||||
import { getToken, getStorageToken } from '@/utils/auth'
|
import { getToken } from '@/utils/auth'
|
||||||
|
|
||||||
// 创建axios实例
|
// 创建axios实例
|
||||||
const service = axios.create({
|
const service = axios.create({
|
||||||
@@ -15,8 +15,6 @@ service.interceptors.request.use(
|
|||||||
config => {
|
config => {
|
||||||
if (getToken()) {
|
if (getToken()) {
|
||||||
config.headers['Authorization'] = 'Bearer ' + getToken() // 让每个请求携带自定义token 请根据实际情况自行修改
|
config.headers['Authorization'] = 'Bearer ' + getToken() // 让每个请求携带自定义token 请根据实际情况自行修改
|
||||||
} else if (getStorageToken()) {
|
|
||||||
config.headers['Authorization'] = 'Bearer ' + getStorageToken()
|
|
||||||
}
|
}
|
||||||
config.headers['Content-Type'] = 'application/json'
|
config.headers['Content-Type'] = 'application/json'
|
||||||
return config
|
return config
|
||||||
|
|||||||
@@ -12,27 +12,29 @@
|
|||||||
<svg-icon slot="prefix" icon-class="password" class="el-input__icon" style="height: 39px;width: 13px;margin-left: 2px;" />
|
<svg-icon slot="prefix" icon-class="password" class="el-input__icon" style="height: 39px;width: 13px;margin-left: 2px;" />
|
||||||
</el-input>
|
</el-input>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-checkbox v-model="loginForm.rememberMe" style="margin:0px 0px 35px 0px;">记住密码</el-checkbox>
|
<el-checkbox v-model="loginForm.rememberMe" style="margin:0px 0px 25px 0px;">记住密码</el-checkbox>
|
||||||
<el-form-item style="width:100%;">
|
<el-form-item style="width:100%;">
|
||||||
<el-button :loading="loading" size="medium" type="primary" style="width:100%;" @click.native.prevent="handleLogin">
|
<el-button :loading="loading" size="medium" type="primary" style="width:100%;" @click.native.prevent="handleLogin">
|
||||||
<span v-if="!loading">登 录</span>
|
<span v-if="!loading">登 录</span>
|
||||||
<span v-else>登 录 中...</span>
|
<span v-else>登 录 中...</span>
|
||||||
</el-button>
|
</el-button>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
|
<p class="login-tip">系统默认用户名:admin,密码:123456</p>
|
||||||
</el-form>
|
</el-form>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import { md5 } from '@/utils/md5'
|
import { md5 } from '@/utils/md5'
|
||||||
|
import Cookies from 'js-cookie'
|
||||||
export default {
|
export default {
|
||||||
name: 'Login',
|
name: 'Login',
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
checked: false,
|
md5Pwd: '',
|
||||||
loginForm: {
|
loginForm: {
|
||||||
username: 'admin',
|
username: '',
|
||||||
password: '123456',
|
password: '',
|
||||||
rememberMe: false
|
rememberMe: false
|
||||||
},
|
},
|
||||||
loginRules: {
|
loginRules: {
|
||||||
@@ -40,7 +42,6 @@ export default {
|
|||||||
password: [{ required: true, trigger: 'blur', message: '密码不能为空' }]
|
password: [{ required: true, trigger: 'blur', message: '密码不能为空' }]
|
||||||
},
|
},
|
||||||
loading: false,
|
loading: false,
|
||||||
pwdType: 'password',
|
|
||||||
redirect: undefined
|
redirect: undefined
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@@ -52,19 +53,38 @@ export default {
|
|||||||
immediate: true
|
immediate: true
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
created() {
|
||||||
|
this.getCookie()
|
||||||
|
},
|
||||||
methods: {
|
methods: {
|
||||||
showPwd() {
|
getCookie() {
|
||||||
if (this.pwdType === 'password') {
|
const username = Cookies.get('username')
|
||||||
this.pwdType = ''
|
const password = Cookies.get('password')
|
||||||
} else {
|
const rememberMe = Cookies.get('rememberMe')
|
||||||
this.pwdType = 'password'
|
// 保存cookie里面的加密后的密码
|
||||||
|
this.md5Pwd = password === undefined ? '' : password
|
||||||
|
this.loginForm = {
|
||||||
|
username: username === undefined ? '' : username,
|
||||||
|
password: this.md5Pwd,
|
||||||
|
rememberMe: rememberMe === undefined ? false : Boolean(rememberMe)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
handleLogin() {
|
handleLogin() {
|
||||||
this.$refs.loginForm.validate(valid => {
|
this.$refs.loginForm.validate(valid => {
|
||||||
const user = { username: this.loginForm.username, password: md5(this.loginForm.password), rememberMe: this.loginForm.rememberMe }
|
let pass = this.loginForm.password
|
||||||
|
if (pass !== this.md5Pwd) { pass = md5(pass) }
|
||||||
|
const user = { username: this.loginForm.username, password: pass, rememberMe: this.loginForm.rememberMe }
|
||||||
if (valid) {
|
if (valid) {
|
||||||
this.loading = true
|
this.loading = true
|
||||||
|
if (user.rememberMe) {
|
||||||
|
Cookies.set('username', user.username, { expires: 1 })
|
||||||
|
Cookies.set('password', user.password, { expires: 1 })
|
||||||
|
Cookies.set('rememberMe', user.rememberMe, { expires: 1 })
|
||||||
|
} else {
|
||||||
|
Cookies.remove('username')
|
||||||
|
Cookies.remove('password')
|
||||||
|
Cookies.remove('rememberMe')
|
||||||
|
}
|
||||||
this.$store.dispatch('Login', user).then(() => {
|
this.$store.dispatch('Login', user).then(() => {
|
||||||
this.loading = false
|
this.loading = false
|
||||||
this.$router.push({ path: this.redirect || '/' })
|
this.$router.push({ path: this.redirect || '/' })
|
||||||
@@ -92,7 +112,7 @@ export default {
|
|||||||
.title {
|
.title {
|
||||||
margin: 0px auto 40px auto;
|
margin: 0px auto 40px auto;
|
||||||
text-align: center;
|
text-align: center;
|
||||||
color: #555;
|
color: #707070;
|
||||||
}
|
}
|
||||||
|
|
||||||
.login-form {
|
.login-form {
|
||||||
@@ -107,4 +127,9 @@ export default {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
.login-tip {
|
||||||
|
font-size: 13px;
|
||||||
|
text-align: center;
|
||||||
|
color: #bfbfbf;
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|||||||
@@ -1,5 +1,8 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="container">
|
<div :style="'width:' + width" class="container">
|
||||||
|
<el-tooltip :content="content" class="lock item" effect="dark" placement="left">
|
||||||
|
<el-button type="info" size="mini" circle @click="doLock"><svg-icon :icon-class="ico"/></el-button>
|
||||||
|
</el-tooltip>
|
||||||
<div id="console" :style="'height:'+ height" class="console">
|
<div id="console" :style="'height:'+ height" class="console">
|
||||||
<div v-for="item in data" :key="item.time">
|
<div v-for="item in data" :key="item.time">
|
||||||
<span>{{ item.name }}</span>
|
<span>{{ item.name }}</span>
|
||||||
@@ -24,7 +27,9 @@ export default {
|
|||||||
name: 'Msg',
|
name: 'Msg',
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
height: document.documentElement.clientHeight - 95 + 'px;',
|
ico: 'unlock', unlock: true, content: '锁定滚动条',
|
||||||
|
height: document.documentElement.clientHeight - 94.5 + 'px;',
|
||||||
|
width: document.documentElement.clientWidth - 185 + 'px;',
|
||||||
data: [{ name: 'elAdmin-', timestamp: new Date(), threadName: 'system-prompt-message', level: 'INFO', className: 'me.zhengjie.AppRun' + ' :', body: 'Welcome, no log output~' }],
|
data: [{ name: 'elAdmin-', timestamp: new Date(), threadName: 'system-prompt-message', level: 'INFO', className: 'me.zhengjie.AppRun' + ' :', body: 'Welcome, no log output~' }],
|
||||||
// level
|
// level
|
||||||
INFO: '#0000ff', WARN: '#FFFF00', ERROR: '#FF0000', DEBUG: '#DEA000'
|
INFO: '#0000ff', WARN: '#FFFF00', ERROR: '#FF0000', DEBUG: '#DEA000'
|
||||||
@@ -40,8 +45,10 @@ export default {
|
|||||||
data: {
|
data: {
|
||||||
handler(val, oldVal) {
|
handler(val, oldVal) {
|
||||||
this.$nextTick(() => {
|
this.$nextTick(() => {
|
||||||
|
if (this.unlock) {
|
||||||
var div = document.getElementById('console')
|
var div = document.getElementById('console')
|
||||||
div.scrollTop = div.scrollHeight
|
div.scrollTop = div.scrollHeight
|
||||||
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -106,11 +113,21 @@ export default {
|
|||||||
} else {
|
} else {
|
||||||
return this.ERROR
|
return this.ERROR
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
doLock() {
|
||||||
|
if (this.unlock) {
|
||||||
|
this.content = '解除锁定'
|
||||||
|
this.ico = 'lock'
|
||||||
|
} else {
|
||||||
|
this.content = '锁定滚动条'
|
||||||
|
this.ico = 'unlock'
|
||||||
|
}
|
||||||
|
this.unlock = !this.unlock
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style scoped>
|
<style scoped>
|
||||||
button,input,textarea{outline:0}.container .buttons .closes,.container .buttons .maximize,.container .buttons .minimize{padding:0;margin:0;margin-right:6px;width:12px;height:12px;border:1px solid transparent;border-radius:6px}.container{width:100%;margin:5px}.container .console{font-family:consolas;overflow-y:scroll;background:#494949;color:#f7f7f7;padding:10px;font-size:14px}
|
button,input,textarea{outline:0}.container .buttons .closes,.container .buttons .maximize,.container .buttons .minimize{padding:0;margin:0;margin-right:6px;width:12px;height:12px;border:1px solid transparent;border-radius:6px}.container{width:100%;margin:5px}.container .console{font-family:consolas;overflow-y:scroll;background:#494949;color:#f7f7f7;padding:10px;font-size:14px} .lock {position: fixed;right: 45px;bottom: 6.8%;z-index: 100000}
|
||||||
</style>
|
</style>
|
||||||
|
|||||||
Reference in New Issue
Block a user