mirror of https://github.com/jumpserver/jumpserver
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
parent
5e0babdba8
commit
5c28b15e39
|
@ -1,3 +1,7 @@
|
||||||
|
#2025-05-30 Version 1.2
|
||||||
|
## 功能更新
|
||||||
|
- 新增用户配置的语言支持,默认使用系统当前语言
|
||||||
|
|
||||||
#2024-10-24 Version 1.1
|
#2024-10-24 Version 1.1
|
||||||
## 功能优化
|
## 功能优化
|
||||||
- 优化快速点击造成页面卡住的问题
|
- 优化快速点击造成页面卡住的问题
|
||||||
|
|
|
@ -13,7 +13,7 @@ from code_dialog import CodeDialog, wrapper_progress_bar
|
||||||
from common import (Asset, User, Account, Platform, Step)
|
from common import (Asset, User, Account, Platform, Step)
|
||||||
from common import (BaseApplication)
|
from common import (BaseApplication)
|
||||||
from common import (notify_err_message, block_input, unblock_input)
|
from common import (notify_err_message, block_input, unblock_input)
|
||||||
|
from common import get_system_language
|
||||||
|
|
||||||
class Command(Enum):
|
class Command(Enum):
|
||||||
TYPE = 'type'
|
TYPE = 'type'
|
||||||
|
@ -251,6 +251,10 @@ class AppletApplication(BaseApplication):
|
||||||
# 加载 extensions
|
# 加载 extensions
|
||||||
extension_paths = load_extensions()
|
extension_paths = load_extensions()
|
||||||
self._chrome_options.add_argument('--load-extension={}'.format(','.join(extension_paths)))
|
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
|
@wrapper_progress_bar
|
||||||
def run(self):
|
def run(self):
|
||||||
|
|
|
@ -80,6 +80,22 @@ def wait_pid(pid):
|
||||||
print("pid {} is not alive".format(pid))
|
print("pid {} is not alive".format(pid))
|
||||||
break
|
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):
|
class DictObj(dict):
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
|
@ -186,6 +202,13 @@ class Platform(DictObj):
|
||||||
return item.setting
|
return item.setting
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
class ConnectOption(DictObj):
|
||||||
|
lang: str
|
||||||
|
charset: str
|
||||||
|
terminal_theme_name: str
|
||||||
|
disableautohash: bool
|
||||||
|
backspaceAsCtrlH: bool
|
||||||
|
|
||||||
|
|
||||||
class Manifest(DictObj):
|
class Manifest(DictObj):
|
||||||
name: str
|
name: str
|
||||||
|
@ -234,6 +257,7 @@ class BaseApplication(abc.ABC):
|
||||||
self.asset = Asset(kwargs.get('asset', {}))
|
self.asset = Asset(kwargs.get('asset', {}))
|
||||||
self.account = Account(kwargs.get('account', {}))
|
self.account = Account(kwargs.get('account', {}))
|
||||||
self.platform = Platform(kwargs.get('platform', {}))
|
self.platform = Platform(kwargs.get('platform', {}))
|
||||||
|
self.connect_option = ConnectOption(kwargs.get('connect_options', {}))
|
||||||
|
|
||||||
@abc.abstractmethod
|
@abc.abstractmethod
|
||||||
def run(self):
|
def run(self):
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
name: chrome
|
name: chrome
|
||||||
display_name: "{{ 'Chrome Browser' | trans }}"
|
display_name: "{{ 'Chrome Browser' | trans }}"
|
||||||
version: 1.1
|
version: 1.2
|
||||||
comment: "{{ 'Chrome Browser Open URL Page Address' | trans }}"
|
comment: "{{ 'Chrome Browser Open URL Page Address' | trans }}"
|
||||||
author: JumpServer Team
|
author: JumpServer Team
|
||||||
exec_type: python
|
exec_type: python
|
||||||
|
|
|
@ -2,3 +2,4 @@
|
||||||
|
|
||||||
- When connecting to a database application, it is necessary to download the driver. You can either install it offline
|
- 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.
|
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.
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
## DBeaver
|
## DBeaver
|
||||||
|
|
||||||
- データベースに接続する際には、ドライバをダウンロードする必要があります。事前にオフラインでインストールするか、接続時に表示される指示に従って該当するドライバをインストールしてください。
|
- データベースに接続する際には、ドライバをダウンロードする必要があります。事前にオフラインでインストールするか、接続時に表示される指示に従って該当するドライバをインストールしてください。
|
||||||
|
|
||||||
|
- 代入力の実装方式により、接続するデータベースのパスワードで | 記号は使用できません。
|
|
@ -2,3 +2,4 @@
|
||||||
|
|
||||||
- 连接数据库应用时,需要下载驱动,可提前离线安装或者连接时按提示安装相应驱动
|
- 连接数据库应用时,需要下载驱动,可提前离线安装或者连接时按提示安装相应驱动
|
||||||
|
|
||||||
|
- 因代填的实现机制,连接的数据库密码不支持使用 `|` 字符
|
Loading…
Reference in New Issue