mirror of
https://github.com/jumpserver/jumpserver.git
synced 2025-09-04 08:55:40 +00:00
perf: 修改命令command input 长度问题 (#7996)
* perf: 修改命令command input max_length 1024 * perf: 修改命令command input 长度问题 * perf: 修改命令command input 长度问题 * perf: 修改命令command input 长度问题 * perf: 修改命令command input 长度问题 Co-authored-by: Jiangjie.Bai <bugatti_it@163.com>
This commit is contained in:
@@ -338,3 +338,24 @@ def get_file_by_arch(dir, filename):
|
||||
settings.BASE_DIR, dir, platform_name, arch, filename
|
||||
)
|
||||
return file_path
|
||||
|
||||
|
||||
def pretty_string(data: str, max_length=128, ellipsis_str='...'):
|
||||
"""
|
||||
params:
|
||||
data: abcdefgh
|
||||
max_length: 7
|
||||
ellipsis_str: ...
|
||||
return:
|
||||
ab...gh
|
||||
"""
|
||||
if len(data) < max_length:
|
||||
return data
|
||||
remain_length = max_length - len(ellipsis_str)
|
||||
half = remain_length // 2
|
||||
if half <= 1:
|
||||
return data[:max_length]
|
||||
start = data[:half]
|
||||
end = data[-half:]
|
||||
data = f'{start}{ellipsis_str}{end}'
|
||||
return data
|
||||
|
Reference in New Issue
Block a user