From eee119eba12c0a953c42c05ead1b68f2615e1e9e Mon Sep 17 00:00:00 2001 From: fit2bot <68588906+fit2bot@users.noreply.github.com> Date: Thu, 2 Nov 2023 18:51:17 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E4=B8=AA=E4=BA=BA=E8=AE=BE=E7=BD=AE=20?= =?UTF-8?q?rdp=20smart=20size=E5=8F=AF=E9=85=8D=E7=BD=AE=20(#12021)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: feng <1304903146@qq.com> --- apps/authentication/api/connection_token.py | 3 ++- apps/users/const.py | 5 +++++ apps/users/serializers/preference/luna.py | 11 ++++++++++- 3 files changed, 17 insertions(+), 2 deletions(-) diff --git a/apps/authentication/api/connection_token.py b/apps/authentication/api/connection_token.py index 8739e32c1..3d58f0cf8 100644 --- a/apps/authentication/api/connection_token.py +++ b/apps/authentication/api/connection_token.py @@ -27,6 +27,7 @@ from perms.models import ActionChoices from terminal.connect_methods import NativeClient, ConnectMethodUtil from terminal.models import EndpointRule, Endpoint from users.const import FileNameConflictResolution +from users.const import RDPSmartSize from users.models import Preference from ..models import ConnectionToken, date_expired_default from ..serializers import ( @@ -66,7 +67,6 @@ class RDPFileClientProtocolURLMixin: 'autoreconnection enabled:i': '1', 'bookmarktype:i': '3', 'use redirection server name:i': '0', - 'smart sizing:i': '1', } # 设置多屏显示 multi_mon = is_true(self.request.query_params.get('multi_mon')) @@ -106,6 +106,7 @@ class RDPFileClientProtocolURLMixin: rdp_options['dynamic resolution:i'] = '0' # 设置其他选项 + rdp_options['smart sizing:i'] = self.request.query_params.get('rdp_smart_size', RDPSmartSize.DISABLE) rdp_options['session bpp:i'] = os.getenv('JUMPSERVER_COLOR_DEPTH', '32') rdp_options['audiomode:i'] = self.parse_env_bool('JUMPSERVER_DISABLE_AUDIO', 'false', '2', '0') diff --git a/apps/users/const.py b/apps/users/const.py index cc8d03b2d..a2ddb4ce9 100644 --- a/apps/users/const.py +++ b/apps/users/const.py @@ -33,6 +33,11 @@ class RDPClientOption(TextChoices): DRIVES_REDIRECT = 'drives_redirect', _('Drives redirect') +class RDPSmartSize(TextChoices): + DISABLE = '0', _('Disable') + ENABLE = '1', _('Enable') + + class KeyboardLayout(TextChoices): EN_US_QWERTY = 'en-us-qwerty', 'US English (Qwerty)' EN_UK_QWERTY = 'en-gb-qwerty', 'UK English (Qwerty)' diff --git a/apps/users/serializers/preference/luna.py b/apps/users/serializers/preference/luna.py index 68046ab2e..2df89f7bc 100644 --- a/apps/users/serializers/preference/luna.py +++ b/apps/users/serializers/preference/luna.py @@ -3,7 +3,10 @@ import json from django.utils.translation import gettext_lazy as _ from rest_framework import serializers -from users.const import RDPResolution, KeyboardLayout, RDPClientOption, AppletConnectionMethod +from users.const import ( + RDPResolution, RDPSmartSize, KeyboardLayout, + RDPClientOption, AppletConnectionMethod +) class MultipleChoiceField(serializers.MultipleChoiceField): @@ -37,6 +40,12 @@ class GraphicsSerializer(serializers.Serializer): choices=RDPClientOption.choices, default={RDPClientOption.FULL_SCREEN}, label=_('RDP client option'), required=False ) + rdp_smart_size = serializers.ChoiceField( + RDPSmartSize.choices, default=RDPSmartSize.DISABLE, + required=False, label=_('Rdp smart size'), + help_text=_('Determines whether the client computer should scale the content on the remote ' + 'computer to fit the window size of the client computer when the window is resized.') + ) applet_connection_method = serializers.ChoiceField( AppletConnectionMethod.choices, default=AppletConnectionMethod.WEB, required=False, label=_('Remote application connection method')