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 NProgress from 'nprogress' // progress bar
|
||||
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 { filterAsyncRouter } from './store/modules/permission'
|
||||
|
||||
@@ -12,7 +12,7 @@ const whiteList = ['/login']// no redirect whitelist
|
||||
|
||||
router.beforeEach((to, from, next) => {
|
||||
NProgress.start() // start progress bar
|
||||
if (getToken() || getStorageToken()) {
|
||||
if (getToken()) {
|
||||
// 已登录且要跳转的页面是登录页
|
||||
if (to.path === '/login') {
|
||||
next({ path: '/' })
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
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'
|
||||
|
||||
const user = {
|
||||
@@ -41,11 +41,8 @@ const user = {
|
||||
const rememberMe = userInfo.rememberMe
|
||||
return new Promise((resolve, reject) => {
|
||||
login(username, password).then(res => {
|
||||
setToken(res.token)
|
||||
setToken(res.token, rememberMe)
|
||||
commit('SET_TOKEN', res.token)
|
||||
if (rememberMe) {
|
||||
setStorageToken(res.token)
|
||||
}
|
||||
resolve()
|
||||
}).catch(error => {
|
||||
reject(error)
|
||||
|
||||
@@ -1,25 +1,17 @@
|
||||
import Cookies from 'js-cookie'
|
||||
|
||||
const TokenKey = 'Admin-Token'
|
||||
const storageTokenKey = 'EL_ADMIN_COOKIE_TOKEN'
|
||||
|
||||
export function getToken() {
|
||||
return Cookies.get(TokenKey)
|
||||
}
|
||||
|
||||
export function getStorageToken() {
|
||||
return localStorage.getItem(storageTokenKey)
|
||||
}
|
||||
|
||||
export function setToken(token) {
|
||||
return Cookies.set(TokenKey, token)
|
||||
}
|
||||
|
||||
export function setStorageToken(token) {
|
||||
return localStorage.setItem(storageTokenKey, token)
|
||||
export function setToken(token, rememberMe) {
|
||||
if (rememberMe) {
|
||||
return Cookies.set(TokenKey, token, { expires: 1 })
|
||||
} else return Cookies.set(TokenKey, token)
|
||||
}
|
||||
|
||||
export function removeToken() {
|
||||
localStorage.removeItem(storageTokenKey)
|
||||
return Cookies.remove(TokenKey)
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@ import axios from 'axios'
|
||||
import router from '@/router'
|
||||
import { Notification, MessageBox } from 'element-ui'
|
||||
import store from '../store'
|
||||
import { getToken, getStorageToken } from '@/utils/auth'
|
||||
import { getToken } from '@/utils/auth'
|
||||
|
||||
// 创建axios实例
|
||||
const service = axios.create({
|
||||
@@ -15,8 +15,6 @@ service.interceptors.request.use(
|
||||
config => {
|
||||
if (getToken()) {
|
||||
config.headers['Authorization'] = 'Bearer ' + getToken() // 让每个请求携带自定义token 请根据实际情况自行修改
|
||||
} else if (getStorageToken()) {
|
||||
config.headers['Authorization'] = 'Bearer ' + getStorageToken()
|
||||
}
|
||||
config.headers['Content-Type'] = 'application/json'
|
||||
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;" />
|
||||
</el-input>
|
||||
</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-button :loading="loading" size="medium" type="primary" style="width:100%;" @click.native.prevent="handleLogin">
|
||||
<span v-if="!loading">登 录</span>
|
||||
<span v-else>登 录 中...</span>
|
||||
</el-button>
|
||||
</el-form-item>
|
||||
<p class="login-tip">系统默认用户名:admin,密码:123456</p>
|
||||
</el-form>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { md5 } from '@/utils/md5'
|
||||
import Cookies from 'js-cookie'
|
||||
export default {
|
||||
name: 'Login',
|
||||
data() {
|
||||
return {
|
||||
checked: false,
|
||||
md5Pwd: '',
|
||||
loginForm: {
|
||||
username: 'admin',
|
||||
password: '123456',
|
||||
username: '',
|
||||
password: '',
|
||||
rememberMe: false
|
||||
},
|
||||
loginRules: {
|
||||
@@ -40,7 +42,6 @@ export default {
|
||||
password: [{ required: true, trigger: 'blur', message: '密码不能为空' }]
|
||||
},
|
||||
loading: false,
|
||||
pwdType: 'password',
|
||||
redirect: undefined
|
||||
}
|
||||
},
|
||||
@@ -52,19 +53,38 @@ export default {
|
||||
immediate: true
|
||||
}
|
||||
},
|
||||
created() {
|
||||
this.getCookie()
|
||||
},
|
||||
methods: {
|
||||
showPwd() {
|
||||
if (this.pwdType === 'password') {
|
||||
this.pwdType = ''
|
||||
} else {
|
||||
this.pwdType = 'password'
|
||||
getCookie() {
|
||||
const username = Cookies.get('username')
|
||||
const password = Cookies.get('password')
|
||||
const rememberMe = Cookies.get('rememberMe')
|
||||
// 保存cookie里面的加密后的密码
|
||||
this.md5Pwd = password === undefined ? '' : password
|
||||
this.loginForm = {
|
||||
username: username === undefined ? '' : username,
|
||||
password: this.md5Pwd,
|
||||
rememberMe: rememberMe === undefined ? false : Boolean(rememberMe)
|
||||
}
|
||||
},
|
||||
handleLogin() {
|
||||
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) {
|
||||
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.loading = false
|
||||
this.$router.push({ path: this.redirect || '/' })
|
||||
@@ -92,7 +112,7 @@ export default {
|
||||
.title {
|
||||
margin: 0px auto 40px auto;
|
||||
text-align: center;
|
||||
color: #555;
|
||||
color: #707070;
|
||||
}
|
||||
|
||||
.login-form {
|
||||
@@ -107,4 +127,9 @@ export default {
|
||||
}
|
||||
}
|
||||
}
|
||||
.login-tip {
|
||||
font-size: 13px;
|
||||
text-align: center;
|
||||
color: #bfbfbf;
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -1,5 +1,8 @@
|
||||
<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 v-for="item in data" :key="item.time">
|
||||
<span>{{ item.name }}</span>
|
||||
@@ -24,7 +27,9 @@ export default {
|
||||
name: 'Msg',
|
||||
data() {
|
||||
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~' }],
|
||||
// level
|
||||
INFO: '#0000ff', WARN: '#FFFF00', ERROR: '#FF0000', DEBUG: '#DEA000'
|
||||
@@ -40,8 +45,10 @@ export default {
|
||||
data: {
|
||||
handler(val, oldVal) {
|
||||
this.$nextTick(() => {
|
||||
var div = document.getElementById('console')
|
||||
div.scrollTop = div.scrollHeight
|
||||
if (this.unlock) {
|
||||
var div = document.getElementById('console')
|
||||
div.scrollTop = div.scrollHeight
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -106,11 +113,21 @@ export default {
|
||||
} else {
|
||||
return this.ERROR
|
||||
}
|
||||
},
|
||||
doLock() {
|
||||
if (this.unlock) {
|
||||
this.content = '解除锁定'
|
||||
this.ico = 'lock'
|
||||
} else {
|
||||
this.content = '锁定滚动条'
|
||||
this.ico = 'unlock'
|
||||
}
|
||||
this.unlock = !this.unlock
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<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>
|
||||
|
||||
Reference in New Issue
Block a user