diff --git a/README.en.md b/README.en.md index fa226d4..c1c742b 100644 --- a/README.en.md +++ b/README.en.md @@ -2,7 +2,7 @@ [![img](https://img.shields.io/badge/license-MIT-blue.svg)](https://gitee.com/liqianglog/django-vue-admin/blob/master/LICENSE) [![img](https://img.shields.io/badge/python-%3E=3.7.x-green.svg)](https://python.org/) [![PyPI - Django Version badge](https://img.shields.io/badge/django%20versions-3.2-blue)](https://docs.djangoproject.com/zh-hans/3.2/) [![img](https://img.shields.io/badge/node-%3E%3D%2012.0.0-brightgreen)](https://nodejs.org/zh-cn/) [![img](https://gitee.com/liqianglog/django-vue-admin/badge/star.svg?theme=dark)](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」** diff --git a/README.md b/README.md index 8bf3bcd..08f6d41 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ [![img](https://img.shields.io/badge/license-MIT-blue.svg)](https://gitee.com/liqianglog/django-vue-admin/blob/master/LICENSE) [![img](https://img.shields.io/badge/python-%3E=3.7.x-green.svg)](https://python.org/) [![PyPI - Django Version badge](https://img.shields.io/badge/django%20versions-3.2-blue)](https://docs.djangoproject.com/zh-hans/3.2/) [![img](https://img.shields.io/badge/node-%3E%3D%2012.0.0-brightgreen)](https://nodejs.org/zh-cn/) [![img](https://gitee.com/liqianglog/django-vue-admin/badge/star.svg?theme=dark)](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) diff --git a/backend/dvadmin/system/views/system_config.py b/backend/dvadmin/system/views/system_config.py index f299b16..8168b50 100644 --- a/backend/dvadmin/system/views/system_config.py +++ b/backend/dvadmin/system/views/system_config.py @@ -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 diff --git a/web/src/stores/interface/index.ts b/web/src/stores/interface/index.ts index ee606cb..794b603 100644 --- a/web/src/stores/interface/index.ts +++ b/web/src/stores/interface/index.ts @@ -91,4 +91,7 @@ export interface ThemeConfigStates { export interface DictionaryStates { data: any; -} \ No newline at end of file +} +export interface ConfigStates { + systemConfig: any; +} diff --git a/web/src/stores/systemConfig.ts b/web/src/stores/systemConfig.ts new file mode 100644 index 0000000..77896af --- /dev/null +++ b/web/src/stores/systemConfig.ts @@ -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, + }, +}); diff --git a/web/src/views/system/login/component/account.vue b/web/src/views/system/login/component/account.vue index b89adad..9a98767 100644 --- a/web/src/views/system/login/component/account.vue +++ b/web/src/views/system/login/component/account.vue @@ -27,7 +27,7 @@ - + @@ -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), }; },