diff --git a/apps/authentication/api/connection_token.py b/apps/authentication/api/connection_token.py index 2158a25f1..bc79d26a2 100644 --- a/apps/authentication/api/connection_token.py +++ b/apps/authentication/api/connection_token.py @@ -27,7 +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.const import RDPSmartSize, RDPColorQuality from users.models import Preference from ..models import ConnectionToken, date_expired_default from ..serializers import ( @@ -49,7 +49,6 @@ class RDPFileClientProtocolURLMixin: 'full address:s': '', 'username:s': '', 'use multimon:i': '0', - 'session bpp:i': '32', 'audiomode:i': '0', 'disable wallpaper:i': '0', 'disable full window drag:i': '0', @@ -100,10 +99,13 @@ class RDPFileClientProtocolURLMixin: rdp_options['winposstr:s'] = f'0,1,0,0,{width},{height}' rdp_options['dynamic resolution:i'] = '0' + color_quality = self.request.query_params.get('rdp_color_quality') + color_quality = color_quality if color_quality else os.getenv('JUMPSERVER_COLOR_DEPTH', RDPColorQuality.HIGH) + # 设置其他选项 - 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['session bpp:i'] = color_quality rdp_options['audiomode:i'] = self.parse_env_bool('JUMPSERVER_DISABLE_AUDIO', 'false', '2', '0') + rdp_options['smart sizing:i'] = self.request.query_params.get('rdp_smart_size', RDPSmartSize.DISABLE) # 设置远程应用, 不是 Mstsc if token.connect_method != NativeClient.mstsc: diff --git a/apps/users/const.py b/apps/users/const.py index 6b6fd5fa8..38edeaf2d 100644 --- a/apps/users/const.py +++ b/apps/users/const.py @@ -38,6 +38,11 @@ class RDPSmartSize(TextChoices): ENABLE = '1', _('Enable') +class RDPColorQuality(TextChoices): + HIGH = '32', 'High(32 bit)' + MEDIUM = '16', 'Medium(16 bit)' + + 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 2df89f7bc..b89bf4b36 100644 --- a/apps/users/serializers/preference/luna.py +++ b/apps/users/serializers/preference/luna.py @@ -5,7 +5,7 @@ from rest_framework import serializers from users.const import ( RDPResolution, RDPSmartSize, KeyboardLayout, - RDPClientOption, AppletConnectionMethod + RDPClientOption, AppletConnectionMethod, RDPColorQuality, ) @@ -40,6 +40,10 @@ class GraphicsSerializer(serializers.Serializer): choices=RDPClientOption.choices, default={RDPClientOption.FULL_SCREEN}, label=_('RDP client option'), required=False ) + rdp_color_quality = serializers.ChoiceField( + choices=RDPColorQuality.choices, default=RDPColorQuality.HIGH, + label=_('RDP color quality'), required=False + ) rdp_smart_size = serializers.ChoiceField( RDPSmartSize.choices, default=RDPSmartSize.DISABLE, required=False, label=_('Rdp smart size'),