perf: update chrome applet to support language setting (#15509)

* perf: update chrome applet to support language setting

* perf: fix field name

---------

Co-authored-by: Eric <xplzv@126.com>
pull/15520/head
fit2bot 2025-06-03 13:54:04 +08:00 committed by GitHub
parent 5e0babdba8
commit 5c28b15e39
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
7 changed files with 38 additions and 2 deletions

View File

@ -1,3 +1,7 @@
#2025-05-30 Version 1.2
## 功能更新
- 新增用户配置的语言支持,默认使用系统当前语言
#2024-10-24 Version 1.1
## 功能优化
- 优化快速点击造成页面卡住的问题

View File

@ -13,7 +13,7 @@ from code_dialog import CodeDialog, wrapper_progress_bar
from common import (Asset, User, Account, Platform, Step)
from common import (BaseApplication)
from common import (notify_err_message, block_input, unblock_input)
from common import get_system_language
class Command(Enum):
TYPE = 'type'
@ -251,6 +251,10 @@ class AppletApplication(BaseApplication):
# 加载 extensions
extension_paths = load_extensions()
self._chrome_options.add_argument('--load-extension={}'.format(','.join(extension_paths)))
# 设置语言
lang = self.connect_option.lang if self.connect_option.lang else get_system_language()
self._chrome_options.add_experimental_option('prefs', {'intl.accept_languages': lang})
self._chrome_options.add_argument('--lang={}'.format(lang))
@wrapper_progress_bar
def run(self):

View File

@ -80,6 +80,22 @@ def wait_pid(pid):
print("pid {} is not alive".format(pid))
break
def get_system_language():
"""
获取系统默认语言
:return: 系统默认语言代码
"""
try:
import ctypes
import locale
# 获取系统默认的语言ID
lang_id = ctypes.windll.kernel32.GetUserDefaultUILanguage()
# 转换为语言代码
language = locale.windows_locale[lang_id]
return language
except Exception as e:
print(f"获取系统语言失败: {e}")
return 'en_US'
class DictObj(dict):
def __init__(self, *args, **kwargs):
@ -186,6 +202,13 @@ class Platform(DictObj):
return item.setting
return None
class ConnectOption(DictObj):
lang: str
charset: str
terminal_theme_name: str
disableautohash: bool
backspaceAsCtrlH: bool
class Manifest(DictObj):
name: str
@ -234,6 +257,7 @@ class BaseApplication(abc.ABC):
self.asset = Asset(kwargs.get('asset', {}))
self.account = Account(kwargs.get('account', {}))
self.platform = Platform(kwargs.get('platform', {}))
self.connect_option = ConnectOption(kwargs.get('connect_options', {}))
@abc.abstractmethod
def run(self):

View File

@ -1,6 +1,6 @@
name: chrome
display_name: "{{ 'Chrome Browser' | trans }}"
version: 1.1
version: 1.2
comment: "{{ 'Chrome Browser Open URL Page Address' | trans }}"
author: JumpServer Team
exec_type: python

View File

@ -2,3 +2,4 @@
- When connecting to a database application, it is necessary to download the driver. You can either install it offline
in advance or install the corresponding driver as prompted when connecting.
- Due to the implementation mechanism of autofill, the database password used for connection does not support the | character.

View File

@ -1,3 +1,5 @@
## DBeaver
- データベースに接続する際には、ドライバをダウンロードする必要があります。事前にオフラインでインストールするか、接続時に表示される指示に従って該当するドライバをインストールしてください。
- 代入力の実装方式により、接続するデータベースのパスワードで | 記号は使用できません。

View File

@ -2,3 +2,4 @@
- 连接数据库应用时,需要下载驱动,可提前离线安装或者连接时按提示安装相应驱动
- 因代填的实现机制,连接的数据库密码不支持使用 `|` 字符