diff --git a/backend/dvadmin/system/models.py b/backend/dvadmin/system/models.py index e3c2b84..2326c83 100644 --- a/backend/dvadmin/system/models.py +++ b/backend/dvadmin/system/models.py @@ -397,12 +397,20 @@ class SystemConfig(CoreModel): return f"{self.title}" def save(self, force_insert=False, force_update=False, using=None, update_fields=None): + # from application.websocketConfig import websocket_push + # websocket_push("dvadmin", message={"sender": 'system', "contentType": 'SYSTEM', + # "content": '系统配置有变化~', "systemConfig": True}) + super().save(force_insert, force_update, using, update_fields) dispatch.refresh_system_config() # 有更新则刷新系统配置 def delete(self, using=None, keep_parents=False): res = super().delete(using, keep_parents) dispatch.refresh_system_config() + from application.websocketConfig import websocket_push + websocket_push("dvadmin", message={"sender": 'system', "contentType": 'SYSTEM', + "content": '系统配置有变化~', "systemConfig": True}) + return res diff --git a/backend/dvadmin/system/views/system_config.py b/backend/dvadmin/system/views/system_config.py index b625d33..85cb81f 100644 --- a/backend/dvadmin/system/views/system_config.py +++ b/backend/dvadmin/system/views/system_config.py @@ -13,6 +13,7 @@ from rest_framework import serializers from rest_framework.views import APIView from application import dispatch +from application.websocketConfig import websocket_push from dvadmin.system.models import SystemConfig from dvadmin.utils.json_response import DetailResponse, SuccessResponse, ErrorResponse from dvadmin.utils.models import get_all_models_objects @@ -179,6 +180,8 @@ class SystemConfigViewSet(CustomModelViewSet): serializer = SystemConfigCreateSerializer(instance_obj, data=data) if serializer.is_valid(raise_exception=True): serializer.save() + websocket_push("dvadmin", message={"sender": 'system', "contentType": 'SYSTEM', + "content": '系统配置有变化~', "systemConfig": True}) return DetailResponse(msg="保存成功") def get_association_table(self, request):