fix(修复登录界面验证码关闭issue): 🐛 https://gitee.com/huge-dream/django-vue3-admin/issues/I6OS75
This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
|
||||
[](https://gitee.com/liqianglog/django-vue-admin/blob/master/LICENSE) [](https://python.org/) [](https://docs.djangoproject.com/zh-hans/3.2/) [](https://nodejs.org/zh-cn/) [](https://gitee.com/liqianglog/django-vue-admin)
|
||||
|
||||
[preview](https://demo.django-vue-admin.com) | [Official website document](https://www.django-vue-admin.com) | [qq group](https://qm.qq.com/cgi-bin/qm/qr?k=fOdnHhC8DJlRHGYSnyhoB8P5rgogA6Vs&jump_from=webapi) | [community](https://bbs.django-vue-admin.com) | [plugins market](https://bbs.django-vue-admin.com/plugMarket.html) | [Github](https://github.com/liqianglog/django-vue-admin)
|
||||
[preview](https://demo.dvadmin.com) | [Official website document](https://www.django-vue-admin.com) | [qq group](https://qm.qq.com/cgi-bin/qm/qr?k=fOdnHhC8DJlRHGYSnyhoB8P5rgogA6Vs&jump_from=webapi) | [community](https://bbs.django-vue-admin.com) | [plugins market](https://bbs.django-vue-admin.com/plugMarket.html) | [Github](https://github.com/liqianglog/django-vue-admin)
|
||||
|
||||
💡 **「About」**
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
[](https://gitee.com/liqianglog/django-vue-admin/blob/master/LICENSE) [](https://python.org/) [](https://docs.djangoproject.com/zh-hans/3.2/) [](https://nodejs.org/zh-cn/) [](https://gitee.com/liqianglog/django-vue-admin)
|
||||
|
||||
[预 览](https://demo.django-vue-admin.com) | [官网文档](https://www.django-vue-admin.com) | [群聊](https://qm.qq.com/cgi-bin/qm/qr?k=fOdnHhC8DJlRHGYSnyhoB8P5rgogA6Vs&jump_from=webapi) | [社区](https://bbs.django-vue-admin.com) | [插件市场](https://bbs.django-vue-admin.com/plugMarket.html) | [Github](https://github.com/liqianglog/django-vue-admin)
|
||||
[预 览](https://demo.dvadmin.com) | [官网文档](https://www.django-vue-admin.com) | [群聊](https://qm.qq.com/cgi-bin/qm/qr?k=fOdnHhC8DJlRHGYSnyhoB8P5rgogA6Vs&jump_from=webapi) | [社区](https://bbs.django-vue-admin.com) | [插件市场](https://bbs.django-vue-admin.com/plugMarket.html) | [Github](https://github.com/liqianglog/django-vue-admin)
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -61,10 +61,10 @@ class SystemConfigChinldernSerializer(CustomModelSerializer):
|
||||
"""
|
||||
系统配置子级-序列化器
|
||||
"""
|
||||
chinldern = serializers.SerializerMethodField()
|
||||
children = serializers.SerializerMethodField()
|
||||
form_item_type_label = serializers.CharField(source='get_form_item_type_display', read_only=True)
|
||||
|
||||
def get_chinldern(self, instance):
|
||||
def get_children(self, instance):
|
||||
queryset = SystemConfig.objects.filter(parent=instance)
|
||||
serializer = SystemConfigSerializer(queryset, many=True)
|
||||
return serializer.data
|
||||
|
||||
@@ -92,3 +92,6 @@ export interface ThemeConfigStates {
|
||||
export interface DictionaryStates {
|
||||
data: any;
|
||||
}
|
||||
export interface ConfigStates {
|
||||
systemConfig: any;
|
||||
}
|
||||
|
||||
37
web/src/stores/systemConfig.ts
Normal file
37
web/src/stores/systemConfig.ts
Normal file
@@ -0,0 +1,37 @@
|
||||
import { defineStore } from 'pinia';
|
||||
import { ConfigStates } from './interface';
|
||||
import { request } from '../utils/service';
|
||||
|
||||
export const urlPrefix = '/api/system/system_config/';
|
||||
|
||||
/**
|
||||
* 系统配置数据
|
||||
* @methods getSystemConfig 获取系统配置数据
|
||||
*/
|
||||
export const SystemConfigStore = defineStore('SystemConfig', {
|
||||
state: (): ConfigStates => ({
|
||||
systemConfig: {},
|
||||
}),
|
||||
actions: {
|
||||
async getSystemConfigs() {
|
||||
request({
|
||||
url: urlPrefix,
|
||||
method: 'get',
|
||||
}).then((ret: { data: [] }) => {
|
||||
// 转换数据格式并保存到pinia
|
||||
let dataList = ret.data;
|
||||
dataList.forEach((item: any) => {
|
||||
let childrens = item.children;
|
||||
if (childrens.length > 1) {
|
||||
this.systemConfig[item.key] = childrens;
|
||||
} else {
|
||||
this.systemConfig[item.key] = item.value;
|
||||
}
|
||||
});
|
||||
});
|
||||
},
|
||||
},
|
||||
persist: {
|
||||
enabled: true,
|
||||
},
|
||||
});
|
||||
@@ -27,7 +27,7 @@
|
||||
</template>
|
||||
</el-input>
|
||||
</el-form-item>
|
||||
<el-form-item class="login-animation3">
|
||||
<el-form-item class="login-animation3" v-if="showCaptcha()">
|
||||
<el-col :span="15">
|
||||
<el-input
|
||||
type="text"
|
||||
@@ -46,7 +46,6 @@
|
||||
<el-col :span="8">
|
||||
<el-button class="login-content-captcha">
|
||||
<el-image :src="ruleForm.captchaImgBase" @click="refreshCaptcha" />
|
||||
<!-- TODO 完成点击刷新验证码 -->
|
||||
</el-button>
|
||||
</el-col>
|
||||
</el-form-item>
|
||||
@@ -74,7 +73,8 @@ import { NextLoading } from '/@/utils/loading';
|
||||
import * as loginApi from '/@/views/system/login/api';
|
||||
import { useUserInfo } from '/@/stores/userInfo';
|
||||
import { DictionaryStore } from '/@/stores/dictionary';
|
||||
import {BtnPermissionStore} from "/@/plugin/permission/store.permission";
|
||||
import { SystemConfigStore } from '/@/stores/systemConfig';
|
||||
import { BtnPermissionStore } from '/@/plugin/permission/store.permission';
|
||||
import { Md5 } from 'ts-md5';
|
||||
|
||||
export default defineComponent({
|
||||
@@ -104,6 +104,10 @@ export default defineComponent({
|
||||
return formatAxis(new Date());
|
||||
});
|
||||
|
||||
const showCaptcha = (): boolean => {
|
||||
return SystemConfigStore().systemConfig.captcha_state;
|
||||
};
|
||||
|
||||
const getCaptcha = async () => {
|
||||
loginApi.getCaptcha().then((ret: any) => {
|
||||
state.ruleForm.captchaImgBase = ret.data.image_base;
|
||||
@@ -118,7 +122,7 @@ export default defineComponent({
|
||||
};
|
||||
const loginClick = async () => {
|
||||
loginApi.login({ ...state.ruleForm, password: Md5.hashStr(state.ruleForm.password) }).then((ret: any) => {
|
||||
Session.set('token', ret.data.access);
|
||||
Session.set('token', ret.data.access);
|
||||
Cookies.set('username', ret.data.name);
|
||||
if (!themeConfig.value.isRequestRoutes) {
|
||||
// 前端控制路由,2、请注意执行顺序
|
||||
@@ -142,6 +146,8 @@ export default defineComponent({
|
||||
getUserInfo();
|
||||
//获取所有字典
|
||||
DictionaryStore().getSystemDictionarys();
|
||||
//获取系统配置
|
||||
SystemConfigStore().getSystemConfigs();
|
||||
// 初始化登录成功时间问候语
|
||||
let currentTimeInfo = currentTime.value;
|
||||
// 登录成功,跳到转首页
|
||||
@@ -170,6 +176,7 @@ export default defineComponent({
|
||||
refreshCaptcha,
|
||||
loginClick,
|
||||
loginSuccess,
|
||||
showCaptcha,
|
||||
...toRefs(state),
|
||||
};
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user