新增:初始化配置验证码是否开启及快速登录
parent
e5113c9f95
commit
af5e917643
|
@ -12,6 +12,7 @@ from django_filters.rest_framework import BooleanFilter
|
||||||
from rest_framework import serializers
|
from rest_framework import serializers
|
||||||
from rest_framework.views import APIView
|
from rest_framework.views import APIView
|
||||||
|
|
||||||
|
from application import settings
|
||||||
from dvadmin.system.models import SystemConfig
|
from dvadmin.system.models import SystemConfig
|
||||||
from dvadmin.utils.json_response import DetailResponse, SuccessResponse, ErrorResponse
|
from dvadmin.utils.json_response import DetailResponse, SuccessResponse, ErrorResponse
|
||||||
from dvadmin.utils.models import get_all_models_objects
|
from dvadmin.utils.models import get_all_models_objects
|
||||||
|
@ -215,5 +216,6 @@ class InitSettingsViewSet(APIView):
|
||||||
"help_url": "https://django-vue-admin.com", # 帮助
|
"help_url": "https://django-vue-admin.com", # 帮助
|
||||||
"privacy_url": "#", # 隐私
|
"privacy_url": "#", # 隐私
|
||||||
"clause_url": "#", # 条款
|
"clause_url": "#", # 条款
|
||||||
|
"captcha_state": settings.CAPTCHA_STATE, # 验证码
|
||||||
}
|
}
|
||||||
return DetailResponse(data=data)
|
return DetailResponse(data=data)
|
||||||
|
|
|
@ -20,7 +20,8 @@ export default {
|
||||||
keepRecord: (state) => state.settings.keepRecord, // 备案
|
keepRecord: (state) => state.settings.keepRecord, // 备案
|
||||||
helpUrl: (state) => state.settings.helpUrl, // 帮助
|
helpUrl: (state) => state.settings.helpUrl, // 帮助
|
||||||
privacyUrl: (state) => state.settings.privacyUrl, // 隐私
|
privacyUrl: (state) => state.settings.privacyUrl, // 隐私
|
||||||
clauseUrl: (state) => state.settings.clauseUrl // 条款
|
clauseUrl: (state) => state.settings.clauseUrl, // 条款
|
||||||
|
captchaState: (state) => state.settings.captchaState || true// 验证码
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
beforeCreate () {
|
beforeCreate () {
|
||||||
|
@ -52,17 +53,24 @@ export default {
|
||||||
message: '请输入密码',
|
message: '请输入密码',
|
||||||
trigger: 'blur'
|
trigger: 'blur'
|
||||||
}
|
}
|
||||||
],
|
|
||||||
captcha: [
|
|
||||||
{
|
|
||||||
required: true,
|
|
||||||
message: '请输入验证码',
|
|
||||||
trigger: 'blur'
|
|
||||||
}
|
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
captchaKey: null,
|
captchaKey: null,
|
||||||
image_base: null
|
image_base: null,
|
||||||
|
// 快速登录,用于dev开发环境
|
||||||
|
selectUsersDialogVisible: false,
|
||||||
|
users: [
|
||||||
|
{
|
||||||
|
name: '超管',
|
||||||
|
username: 'superadmin',
|
||||||
|
password: 'admin123456'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: '管理员',
|
||||||
|
username: 'admin',
|
||||||
|
password: 'admin123456'
|
||||||
|
}
|
||||||
|
]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
mounted () {},
|
mounted () {},
|
||||||
|
@ -73,11 +81,13 @@ export default {
|
||||||
* 获取验证码
|
* 获取验证码
|
||||||
*/
|
*/
|
||||||
getCaptcha () {
|
getCaptcha () {
|
||||||
api.getCaptcha().then((ret) => {
|
if (this.captchaState) {
|
||||||
this.formLogin.captcha = null
|
api.getCaptcha().then((ret) => {
|
||||||
this.captchaKey = ret.data.key
|
this.formLogin.captcha = null
|
||||||
this.image_base = ret.data.image_base
|
this.captchaKey = ret.data.key
|
||||||
})
|
this.image_base = ret.data.image_base
|
||||||
|
})
|
||||||
|
}
|
||||||
},
|
},
|
||||||
/**
|
/**
|
||||||
* @description 提交表单
|
* @description 提交表单
|
||||||
|
@ -108,6 +118,16 @@ export default {
|
||||||
this.$message.error('表单校验失败,请检查')
|
this.$message.error('表单校验失败,请检查')
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
},
|
||||||
|
// 快速登录
|
||||||
|
handleUserBtnClick (user) {
|
||||||
|
this.formLogin.username = user.username
|
||||||
|
this.formLogin.password = user.password
|
||||||
|
// this.submit()
|
||||||
|
this.selectUsersDialogVisible = false
|
||||||
|
if (!this.captchaState) {
|
||||||
|
this.submit()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
created () {
|
created () {
|
||||||
|
|
|
@ -49,7 +49,11 @@
|
||||||
>
|
>
|
||||||
</el-input>
|
</el-input>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item prop="captcha">
|
<el-form-item
|
||||||
|
prop="captcha"
|
||||||
|
v-if="captchaState"
|
||||||
|
:rules="{required: true,message: '请输入验证码',trigger: 'blur'}"
|
||||||
|
>
|
||||||
<el-input
|
<el-input
|
||||||
type="text"
|
type="text"
|
||||||
v-model="formLogin.captcha"
|
v-model="formLogin.captcha"
|
||||||
|
@ -75,9 +79,27 @@
|
||||||
</el-tab-pane>
|
</el-tab-pane>
|
||||||
</el-tabs>
|
</el-tabs>
|
||||||
</el-card>
|
</el-card>
|
||||||
|
<el-button
|
||||||
|
class="page-login--quick"
|
||||||
|
size="default"
|
||||||
|
type="success"
|
||||||
|
@click="selectUsersDialogVisible = true"
|
||||||
|
v-if="$env === 'development'"
|
||||||
|
>
|
||||||
|
快速选择用户登录(限dev环境)
|
||||||
|
</el-button>
|
||||||
<!-- footer -->
|
<!-- footer -->
|
||||||
<div class="footer">
|
<div class="footer">
|
||||||
|
<p class="page-login--content-footer-locales">
|
||||||
|
<a
|
||||||
|
v-for="language in $languages"
|
||||||
|
:key="language.value"
|
||||||
|
@click="onChangeLocale(language.value)"
|
||||||
|
style="cursor:pointer;"
|
||||||
|
>
|
||||||
|
{{ language.label }}
|
||||||
|
</a>
|
||||||
|
</p>
|
||||||
<p>Copyright © {{ copyright }}</p>
|
<p>Copyright © {{ copyright }}</p>
|
||||||
<p>
|
<p>
|
||||||
<a href="https://beian.miit.gov.cn" target="_blank">{{
|
<a href="https://beian.miit.gov.cn" target="_blank">{{
|
||||||
|
@ -94,6 +116,16 @@
|
||||||
<!-- //main content -->
|
<!-- //main content -->
|
||||||
</div>
|
</div>
|
||||||
<!-- //container -->
|
<!-- //container -->
|
||||||
|
<el-dialog title="快速选择用户" :visible.sync="selectUsersDialogVisible" width="400px" append-to-body>
|
||||||
|
<el-row :gutter="10" style="margin: -20px 0px -10px 0px">
|
||||||
|
<el-col v-for="(user, index) in users" :key="index" :span="8">
|
||||||
|
<div class="page-login--quick-user" @click="handleUserBtnClick(user)">
|
||||||
|
<d2-icon name="user-circle-o" />
|
||||||
|
<span>{{ user.name }}</span>
|
||||||
|
</div>
|
||||||
|
</el-col>
|
||||||
|
</el-row>
|
||||||
|
</el-dialog>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
<script>
|
<script>
|
||||||
|
@ -123,4 +155,31 @@ export default {
|
||||||
font-size: 0;
|
font-size: 0;
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
}
|
}
|
||||||
|
// 快速选择用户面板
|
||||||
|
.page-login--quick{
|
||||||
|
margin-top: 20px;
|
||||||
|
}
|
||||||
|
.page-login--quick-user {
|
||||||
|
@extend %flex-center-col;
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|
Loading…
Reference in New Issue