快速选择用户登陆
Former-commit-id: 610c12b2a8679bfcad918e3d24d04a1a6af41c4c [formerly 610c12b2a8679bfcad918e3d24d04a1a6af41c4c [formerly 610c12b2a8679bfcad918e3d24d04a1a6af41c4c [formerly 610c12b2a8679bfcad918e3d24d04a1a6af41c4c [formerly cc710028c0810b73facbb1f00ba054da58bd88da [formerly 39767add7846a4a3f27fb79c47d121ceb1d3d6a0]]]]] Former-commit-id: 740804501e73b47382d505ce1fa24e7bba3beb3b Former-commit-id: a61192c10d96e687b6fe7ebd5e40e2a2cc816d8b Former-commit-id: e142163ddd0be72d2de796dc90a54de29e64da4d [formerly 1f32a6afe0a2302808606bcb9c9776e93d4d805b] Former-commit-id: 2bd41fd483228f0aff6255f5be5b72aa72e4b64e Former-commit-id: bfd7e5e99f4774d60e8433e4f519d1d44db187ad Former-commit-id: 8c4f66b40505956019099d80abbdaaa88808b011 Former-commit-id: aa887c968ab01b652512c95dc5b8503f68230c49 Former-commit-id: 0785746511cac0ba75c813f15e5b0914fbd916c1
This commit is contained in:
parent
a43757c436
commit
31c16f2d3a
|
|
@ -166,7 +166,7 @@
|
|||
<div class="d2-app-loading d2-app-loading9"></div>
|
||||
</div>
|
||||
<div class="d2-app-loading-title">加载中</div>
|
||||
<div class="d2-app-loading-sub-title">欢迎使用 D2Admin 开发,初次加载会比较慢,请耐心等待</div>
|
||||
<div class="d2-app-loading-sub-title">欢迎使用 D2Admin 进行你的开发,初次加载会比较慢,请耐心等待</div>
|
||||
<div class="d2-app-loading-sub-info">如果很久很久都没有加载成功,请清空缓存重新加载页面</div>
|
||||
<div style="margin-top: 10px;">
|
||||
<a class="d2-app-loading-btn" href="https://github.com/d2-projects/d2-admin" target="blank">Github仓库</a>
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
.d2-layout-header-aside-group {
|
||||
height: 100%;
|
||||
width: 100%;
|
||||
min-width: 1000px;
|
||||
min-width: 900px;
|
||||
background-size: cover;
|
||||
background-position: center;
|
||||
overflow: hidden;
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
<template>
|
||||
<el-dropdown class="d2-mr">
|
||||
<span class="btn-text">你好 {{username}}</span>
|
||||
<span class="btn-text">你好 {{userInfo.name}}</span>
|
||||
<el-dropdown-menu slot="dropdown">
|
||||
<el-dropdown-item @click.native="logOff"><d2-icon name="power-off"/> 注销</el-dropdown-item>
|
||||
<el-dropdown-item><d2-icon name="user-circle-o"/> 个人中心</el-dropdown-item>
|
||||
|
|
@ -12,11 +12,10 @@
|
|||
// 插件
|
||||
import Cookies from 'js-cookie'
|
||||
import { mapState, mapMutations } from 'vuex'
|
||||
|
||||
export default {
|
||||
computed: {
|
||||
...mapState({
|
||||
username: state => state.d2admin.username
|
||||
userInfo: state => state.d2admin.userInfo
|
||||
})
|
||||
},
|
||||
methods: {
|
||||
|
|
@ -29,9 +28,9 @@ export default {
|
|||
cancelButtonText: '取消',
|
||||
type: 'warning'
|
||||
}).then(() => {
|
||||
// 删除用户名
|
||||
// 删除用户信息
|
||||
this.d2adminUtilDbRemoveByUuid({
|
||||
key: 'username',
|
||||
key: 'userInfo',
|
||||
emptyValue: ''
|
||||
})
|
||||
// 删除cookie
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ const db = low(adapter)
|
|||
db.defaults({
|
||||
themeActiveName: [],
|
||||
pageOpenedList: [],
|
||||
username: []
|
||||
userInfo: []
|
||||
})
|
||||
.write()
|
||||
|
||||
|
|
|
|||
|
|
@ -57,12 +57,8 @@ new Vue({
|
|||
util.uaGet(this)
|
||||
// 展示系统信息
|
||||
util.showInfo()
|
||||
// DB -> store 加载用户名
|
||||
this.$store.commit('d2adminUsernameLoad')
|
||||
// DB -> store 加载主题
|
||||
this.$store.commit('d2adminThemeLoad')
|
||||
// DB -> store 数据库加载上次退出时的多页列表
|
||||
this.$store.commit('d2adminPageOpenedListLoad')
|
||||
// 用户登陆后从数据库加载一系列的设置
|
||||
this.$store.commit('d2adminLoginSuccessLoad')
|
||||
// 初始化全屏监听
|
||||
this.fullscreenListenerInit()
|
||||
},
|
||||
|
|
|
|||
|
|
@ -6,6 +6,18 @@ const userDB = [
|
|||
password: 'admin',
|
||||
uuid: 'test-user-uuid',
|
||||
name: '管理员'
|
||||
},
|
||||
{
|
||||
username: 'editor',
|
||||
password: 'editor',
|
||||
uuid: 'editor-uuid',
|
||||
name: '编辑'
|
||||
},
|
||||
{
|
||||
username: 'user',
|
||||
password: 'user',
|
||||
uuid: 'user-uuid',
|
||||
name: '一般用户'
|
||||
}
|
||||
]
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1 @@
|
|||
468b5c0e8223d984392890b8854d37acc8a5af38
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
import page from './page'
|
||||
|
||||
export default page
|
||||
|
|
@ -0,0 +1,28 @@
|
|||
<template>
|
||||
<div class="page">
|
||||
<img src="./image/icon@2x.png" class="icon">
|
||||
<p class="title">您的 IE 浏览器版本过低</p>
|
||||
<p class="sub-title">请使用 IE 11+</p>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
@import '~@/assets/style/public.scss';
|
||||
.page {
|
||||
@extend %full;
|
||||
@extend %flex-center-col;
|
||||
background-color: #EDF4FA;
|
||||
.icon {
|
||||
width: 42px;
|
||||
}
|
||||
.title {
|
||||
font-size: 14px;
|
||||
color: #35495E;
|
||||
}
|
||||
.sub-title {
|
||||
font-size: 12px;
|
||||
color: #35495E;
|
||||
margin: 0px;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
|
@ -1,3 +1,3 @@
|
|||
import page from './login'
|
||||
import page from './page'
|
||||
|
||||
export default page
|
||||
|
|
|
|||
|
|
@ -32,12 +32,24 @@
|
|||
</el-form>
|
||||
</el-card>
|
||||
</div>
|
||||
<!-- 帮助按钮 -->
|
||||
<el-button type="info" class="button-help">
|
||||
需要帮助
|
||||
<i class="fa fa-question-circle"></i>
|
||||
<!-- 快速登陆按钮 -->
|
||||
<el-button type="info" class="button-help" @click="dialogVisible = true">
|
||||
快速选择用户(测试功能)
|
||||
</el-button>
|
||||
</div>
|
||||
<el-dialog
|
||||
title="快速选择用户"
|
||||
:visible.sync="dialogVisible"
|
||||
width="400px">
|
||||
<el-row :gutter="10" style="margin: -20px 0px -10px 0px;">
|
||||
<el-col v-for="(user, index) in users" :key="index" :span="8">
|
||||
<div class="user-btn" @click="handleUserBtnClick(user)">
|
||||
<d2-icon name="user-circle-o"/>
|
||||
<span>{{user.name}}</span>
|
||||
</div>
|
||||
</el-col>
|
||||
</el-row>
|
||||
</el-dialog>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
|
|
@ -53,11 +65,32 @@ import { mapMutations } from 'vuex'
|
|||
export default {
|
||||
data () {
|
||||
return {
|
||||
// 快速选择用户
|
||||
dialogVisible: false,
|
||||
users: [
|
||||
{
|
||||
name: '管理员',
|
||||
username: 'admin',
|
||||
password: 'admin'
|
||||
},
|
||||
{
|
||||
name: '编辑',
|
||||
username: 'editor',
|
||||
password: 'editor'
|
||||
},
|
||||
{
|
||||
name: '用户',
|
||||
username: 'user',
|
||||
password: 'user'
|
||||
}
|
||||
],
|
||||
// 表单
|
||||
formLogin: {
|
||||
username: 'admin',
|
||||
password: 'admin',
|
||||
code: 'v9am'
|
||||
},
|
||||
// 校验
|
||||
rules: {
|
||||
username: [
|
||||
{ required: true, message: '请输入用户名', trigger: 'blur' }
|
||||
|
|
@ -77,8 +110,21 @@ export default {
|
|||
},
|
||||
methods: {
|
||||
...mapMutations([
|
||||
'd2adminUsernameSet'
|
||||
'd2adminUserInfoSet',
|
||||
'd2adminLoginSuccessLoad'
|
||||
]),
|
||||
/**
|
||||
* @description 接收选择一个用户快速登陆的事件
|
||||
* @param {object} user 用户信息
|
||||
*/
|
||||
handleUserBtnClick (user) {
|
||||
this.formLogin.username = user.username
|
||||
this.formLogin.password = user.password
|
||||
this.submit()
|
||||
},
|
||||
/**
|
||||
* @description 提交表单
|
||||
*/
|
||||
// 提交登陆信息
|
||||
submit () {
|
||||
this.$refs.loginForm.validate((valid) => {
|
||||
|
|
@ -93,18 +139,19 @@ export default {
|
|||
}
|
||||
})
|
||||
.then(res => {
|
||||
console.group('登陆结果')
|
||||
console.log('res: ', res)
|
||||
console.groupEnd()
|
||||
// cookie 一天的有效期
|
||||
const setting = {
|
||||
expires: 1
|
||||
}
|
||||
// 设置 cookie 一定要存 uuid 和 token 两个 cookie,整个系统依赖这两个数据进行校验和存储
|
||||
Cookies.set('uuid', res.uuid, setting)
|
||||
Cookies.set('token', res.token, setting)
|
||||
// 设置 vuex
|
||||
this.d2adminUsernameSet(res.name)
|
||||
Cookies.set('uuid', res.data.uuid, setting)
|
||||
Cookies.set('token', res.data.token, setting)
|
||||
// 设置 vuex 用户信息
|
||||
this.d2adminUserInfoSet({
|
||||
name: res.data.name
|
||||
})
|
||||
// 用户登陆后从数据库加载一系列的设置
|
||||
this.d2adminLoginSuccessLoad()
|
||||
// 跳转路由
|
||||
this.$router.push({
|
||||
name: 'index'
|
||||
|
|
@ -127,4 +174,3 @@ export default {
|
|||
<style lang="scss">
|
||||
@import './style.scss';
|
||||
</style>
|
||||
|
||||
|
|
@ -63,4 +63,28 @@
|
|||
width: 300px;
|
||||
margin-top: 20px;
|
||||
}
|
||||
.user-btn {
|
||||
@extend %flex-center-col;
|
||||
@extend %unable-select;
|
||||
padding: 10px 0px;
|
||||
border-radius: 4px;
|
||||
&:hover {
|
||||
background-color: $color-bg;
|
||||
i {
|
||||
color: $color-text-normal;
|
||||
}
|
||||
span {
|
||||
color: $color-text-normal;
|
||||
}
|
||||
}
|
||||
i {
|
||||
font-size: 36px;
|
||||
color: $color-text-sub;
|
||||
}
|
||||
span {
|
||||
font-size: 12px;
|
||||
margin-top: 10px;
|
||||
color: $color-text-sub;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1 +1 @@
|
|||
51bf6b20922ac42bc614d4dafc3928f2f9017796
|
||||
d1fc661cca201ded872328bf7926689075938e00
|
||||
|
|
@ -1 +1 @@
|
|||
2831ac4870bc4916671225959f7721a1eeb52ebd
|
||||
cb5203e7da4a54f17ca8f08ae175eae15db544f0
|
||||
Loading…
Reference in New Issue