1
0
mirror of https://github.com/1Panel-dev/1Panel.git synced 2025-01-19 16:29:17 +08:00

fix: 解决部分情况下打开文件中文乱码的问题 (#5425)

Refs https://github.com/1Panel-dev/1Panel/issues/5374
This commit is contained in:
zhengkunwang 2024-06-12 14:32:37 +08:00 committed by GitHub
parent 9bd9700bac
commit 09dc15a940
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 16 additions and 14 deletions

View File

@ -10,6 +10,7 @@ import (
"path/filepath"
"strings"
"time"
"unicode/utf8"
"github.com/1Panel-dev/1Panel/backend/app/dto/request"
"github.com/1Panel-dev/1Panel/backend/app/dto/response"
@ -236,12 +237,11 @@ func (f *FileService) GetContent(op request.FileContentReq) (response.FileInfo,
}
content := []byte(info.Content)
var decodeName string
if len(content) > 1024 {
_, decodeName, _ = charset.DetermineEncoding(content[:1024], "")
} else {
_, decodeName, _ = charset.DetermineEncoding(content, "")
content = content[:1024]
}
if !utf8.Valid(content) {
_, decodeName, _ := charset.DetermineEncoding(content, "")
if decodeName == "windows-1252" {
reader := strings.NewReader(info.Content)
item := transform.NewReader(reader, simplifiedchinese.GBK.NewDecoder())
@ -251,6 +251,7 @@ func (f *FileService) GetContent(op request.FileContentReq) (response.FileInfo,
}
info.Content = string(contents)
}
}
return response.FileInfo{FileInfo: *info}, nil
}

View File

@ -1729,7 +1729,8 @@ const message = {
takeDown: 'TakeDown',
allReadyInstalled: 'Installed',
installHelper: 'Configuring image acceleration can solve the problem of image pull failure',
upgradeHelper: 'The abnormal application needs to be synchronized to the normal state first',
upgradeHelper:
'Abnormal applications need to be synchronized to normal status first. If the upgrade fails, please check the failure reason in the log audit-system log',
installWarn:
'Currently, if the port external access is not checked, it will not be able to access through the external network IP: port. Do you want to continue?',
showIgnore: 'View ignore application',

View File

@ -1610,7 +1610,7 @@ const message = {
takeDown: '已廢棄',
allReadyInstalled: '已安裝',
installHelper: '配置鏡像加速可以解決鏡像拉取失敗的問題',
upgradeHelper: '異常應用需要先同步到正常狀態',
upgradeHelper: '異常應用程式需要先同步到正常狀態升級失敗請在日誌審計-系統日誌中查看失敗原因',
installWarn: '當前未勾選端口外部訪問將無法通過外網IP:端口訪問是否繼續 ',
showIgnore: '查看忽略應用',
cancelIgnore: '取消忽略',

View File

@ -1610,7 +1610,7 @@ const message = {
takeDown: '已废弃',
allReadyInstalled: '已安装',
installHelper: '配置镜像加速可以解决镜像拉取失败的问题',
upgradeHelper: '异常应用需要先同步到正常状态',
upgradeHelper: '异常应用需要先同步到正常状态升级失败请在日志审计-系统日志中查看失败原因',
installWarn: '当前未勾选端口外部访问将无法通过外网IP:端口访问是否继续',
showIgnore: '查看忽略应用',
cancelIgnore: '取消忽略',