Compare commits

...
10 Commits
Author SHA1 Message Date
zhengkunwang adc34aaf75 feat: 增加文件压缩解压的超时时间 (#2886)
Refs https://github.com/1Panel-dev/1Panel/issues/2884
2023-11-10 09:04:07 +00:00
zhengkunwang acb0bf2bfd fix: 解决网站设置默认站点失败的问题 (#2885) 2023-11-10 08:54:07 +00:00
zhengkunwang 88ad8b1b71 fix: 解决文件复制粘贴路径中带空格导致失败的问题 (#2883)
Refs https://github.com/1Panel-dev/1Panel/issues/2877
2023-11-10 08:38:07 +00:00
zhengkunwang 8660ac6fe5 fix: 解决本地应用备份恢复报错的问题 (#2879)
Refs https://github.com/1Panel-dev/1Panel/issues/2854
2023-11-10 07:06:07 +00:00
zhengkunwang 24098e397f feat: 取消检测文件是否存在接口的日志打印 (#2878) 2023-11-10 06:36:07 +00:00
zhengkunwang 21f9e4f201 fix: 解决网站反向代理缓存时间选择年报错的问题 (#2873)
Refs https://github.com/1Panel-dev/1Panel/issues/2866
2023-11-10 03:04:06 +00:00
zhengkunwang f60500791a feat: 增加证书续签的超时时间 (#2869) 2023-11-09 13:58:07 +00:00
zhengkunwang 70c0602970 fix: 解决网站保存设置报错的问题 (#2864) 2023-11-09 13:56:06 +00:00
Node adfa021760 fix:解决备份还原到新建应用失败的问题 #2854 (#2863) 2023-11-09 21:53:38 +08:00
Node 0e93d7815b feat:增加控制台静态资源/assets/浏览器缓存 (#2859)
#### What this PR does / why we need it?
当前操作控制台(每点击一个不同的页面)或刷新后,都需要从服务器加载静态资源且没有缓存,在网络差的情况下访问特别慢

#### Summary of your change
给静态资源增加浏览器缓存时间
#### Please indicate you've done the following:

- [x] Made sure tests are passing and test coverage is added if needed.
- [x] Made sure commit message follow the rule of [Conventional Commits specification](https://www.conventionalcommits.org/).
- [x] Considered the docs impact and opened a new docs issue or PR with docs changes if needed.
2023-11-09 02:44:15 +00:00
13 changed files with 47 additions and 53 deletions
-1
View File
@@ -340,7 +340,6 @@ func (b *BaseApi) UploadFiles(c *gin.Context) {
// @Success 200
// @Security ApiKeyAuth
// @Router /files/check [post]
// @x-panel-log {"bodyKeys":["path"],"paramKeys":[],"BeforeFunctions":[],"formatZH":"检测文件 [path] 是否存在","formatEN":"Check whether file [path] exists"}
func (b *BaseApi) CheckFile(c *gin.Context) {
var req request.FilePathCheck
if err := helper.CheckBindAndValidate(&req, c); err != nil {
+1 -1
View File
@@ -14,7 +14,7 @@ type NginxScopeReq struct {
type NginxConfigUpdate struct {
Scope dto.NginxKey `json:"scope"`
Operate string `json:"operate" validate:"required;oneof=add update delete"`
Operate string `json:"operate" validate:"required,oneof=add update delete"`
WebsiteID uint `json:"websiteId" validate:"required"`
Params interface{} `json:"params"`
}
+1 -1
View File
@@ -148,7 +148,7 @@ type WebsiteLogReq struct {
}
type WebsiteDefaultUpdate struct {
ID uint `json:"id" validate:"required"`
ID uint `json:"id"`
}
type WebsitePHPConfigUpdate struct {
+4 -4
View File
@@ -27,18 +27,18 @@ type AppInstall struct {
}
func (i *AppInstall) GetPath() string {
return path.Join(i.getAppPath(), i.Name)
return path.Join(i.GetAppPath(), i.Name)
}
func (i *AppInstall) GetComposePath() string {
return path.Join(i.getAppPath(), i.Name, "docker-compose.yml")
return path.Join(i.GetAppPath(), i.Name, "docker-compose.yml")
}
func (i *AppInstall) GetEnvPath() string {
return path.Join(i.getAppPath(), i.Name, ".env")
return path.Join(i.GetAppPath(), i.Name, ".env")
}
func (i *AppInstall) getAppPath() string {
func (i *AppInstall) GetAppPath() string {
if i.App.Resource == constant.AppResourceLocal {
return path.Join(constant.LocalAppInstallDir, strings.TrimPrefix(i.App.Key, constant.AppResourceLocal))
} else {
+1 -1
View File
@@ -225,7 +225,7 @@ func handleAppRecover(install *model.AppInstall, recoverFile string, isRollback
_ = fileOp.Rename(appDir, backPath)
_ = fileOp.CreateDir(appDir, 0755)
if err := handleUnTar(tmpPath+"/app.tar.gz", fmt.Sprintf("%s/%s", constant.AppInstallDir, install.App.Key)); err != nil {
if err := handleUnTar(tmpPath+"/app.tar.gz", install.GetAppPath()); err != nil {
global.LOG.Errorf("handle recover from app.tar.gz failed, err: %v", err)
_ = fileOp.DeleteDir(appDir)
_ = fileOp.Rename(backPath, appDir)
+7
View File
@@ -4,6 +4,7 @@ import (
"github.com/gin-contrib/gzip"
"html/template"
"net/http"
"strings"
"github.com/1Panel-dev/1Panel/backend/global"
"github.com/1Panel-dev/1Panel/backend/i18n"
@@ -19,6 +20,12 @@ import (
func setWebStatic(rootRouter *gin.RouterGroup) {
rootRouter.StaticFS("/public", http.FS(web.Favicon))
rootRouter.Use(func(c *gin.Context) {
if strings.HasPrefix(c.Request.URL.Path, "/assets/") {
c.Header("Cache-Control", "max-age=31536000")
}
c.Next()
})
rootRouter.GET("/assets/*filepath", func(c *gin.Context) {
staticServer := http.FileServer(http.FS(web.Assets))
staticServer.ServeHTTP(c.Writer, c.Request)
+7 -5
View File
@@ -299,7 +299,8 @@ func (f FileOp) Cut(oldPaths []string, dst, name string, cover bool) error {
if cover {
coverFlag = "-f"
}
cmdStr := fmt.Sprintf("mv %s %s %s", coverFlag, p, dstPath)
cmdStr := fmt.Sprintf(`mv %s "%s" "%s"`, coverFlag, p, dstPath)
if err := cmd.ExecCmd(cmdStr); err != nil {
return err
}
@@ -362,13 +363,13 @@ func (f FileOp) CopyAndReName(src, dst, name string, cover bool) error {
if name != "" && !cover {
dstPath = filepath.Join(dst, name)
}
return cmd.ExecCmd(fmt.Sprintf("cp -rf %s %s", src, dstPath))
return cmd.ExecCmd(fmt.Sprintf(`cp -rf "%s" "%s"`, src, dstPath))
} else {
dstPath := filepath.Join(dst, name)
if cover {
dstPath = dst
}
return cmd.ExecCmd(fmt.Sprintf("cp -f %s %s", src, dstPath))
return cmd.ExecCmd(fmt.Sprintf(`cp -f "%s" "%s"`, src, dstPath))
}
}
@@ -381,11 +382,12 @@ func (f FileOp) CopyDir(src, dst string) error {
if err = f.Fs.MkdirAll(dstDir, srcInfo.Mode()); err != nil {
return err
}
return cmd.ExecCmd(fmt.Sprintf("cp -rf %s %s", src, dst+"/"))
return cmd.ExecCmd(fmt.Sprintf(`cp -rf "%s" "%s"`, src, dst+"/"))
}
func (f FileOp) CopyFile(src, dst string) error {
return cmd.ExecCmd(fmt.Sprintf("cp -f %s %s", src, dst+"/"))
dst = filepath.Clean(dst) + string(filepath.Separator)
return cmd.ExecCmd(fmt.Sprintf(`cp -f "%s" "%s"`, src, dst+"/"))
}
func (f FileOp) GetDirSize(path string) (float64, error) {
+9 -14
View File
@@ -1,5 +1,5 @@
// Code generated by swaggo/swag. DO NOT EDIT.
// Package docs GENERATED BY SWAG; DO NOT EDIT
// This file was generated by swaggo/swag
package docs
import "github.com/swaggo/swag"
@@ -5160,15 +5160,6 @@ const docTemplate = `{
"200": {
"description": "OK"
}
},
"x-panel-log": {
"BeforeFunctions": [],
"bodyKeys": [
"path"
],
"formatEN": "Check whether file [path] exists",
"formatZH": "检测文件 [path] 是否存在",
"paramKeys": []
}
}
},
@@ -17373,11 +17364,17 @@ const docTemplate = `{
"request.NginxConfigUpdate": {
"type": "object",
"required": [
"operate",
"websiteId"
],
"properties": {
"operate": {
"type": "string"
"type": "string",
"enum": [
"add",
"update",
"delete"
]
},
"params": {},
"scope": {
@@ -18195,8 +18192,6 @@ const docTemplate = `{
"request.WebsiteProxyConfig": {
"type": "object",
"required": [
"cacheTime",
"cacheUnit",
"id",
"match",
"modifier",
+7 -12
View File
@@ -5153,15 +5153,6 @@
"200": {
"description": "OK"
}
},
"x-panel-log": {
"BeforeFunctions": [],
"bodyKeys": [
"path"
],
"formatEN": "Check whether file [path] exists",
"formatZH": "检测文件 [path] 是否存在",
"paramKeys": []
}
}
},
@@ -17366,11 +17357,17 @@
"request.NginxConfigUpdate": {
"type": "object",
"required": [
"operate",
"websiteId"
],
"properties": {
"operate": {
"type": "string"
"type": "string",
"enum": [
"add",
"update",
"delete"
]
},
"params": {},
"scope": {
@@ -18188,8 +18185,6 @@
"request.WebsiteProxyConfig": {
"type": "object",
"required": [
"cacheTime",
"cacheUnit",
"id",
"match",
"modifier",
+5 -9
View File
@@ -3229,6 +3229,10 @@ definitions:
request.NginxConfigUpdate:
properties:
operate:
enum:
- add
- update
- delete
type: string
params: {}
scope:
@@ -3236,6 +3240,7 @@ definitions:
websiteId:
type: integer
required:
- operate
- websiteId
type: object
request.NginxProxyUpdate:
@@ -3810,8 +3815,6 @@ definitions:
type: string
type: object
required:
- cacheTime
- cacheUnit
- id
- match
- modifier
@@ -7659,13 +7662,6 @@ paths:
summary: Check file exist
tags:
- File
x-panel-log:
BeforeFunctions: []
bodyKeys:
- path
formatEN: Check whether file [path] exists
formatZH: 检测文件 [path] 是否存在
paramKeys: []
/files/chunkdownload:
post:
consumes:
+2 -2
View File
@@ -34,11 +34,11 @@ export const ChangeFileMode = (form: File.FileCreate) => {
};
export const CompressFile = (form: File.FileCompress) => {
return http.post<File.File>('files/compress', form);
return http.post<File.File>('files/compress', form, TimeoutEnum.T_10M);
};
export const DeCompressFile = (form: File.FileDeCompress) => {
return http.post<File.File>('files/decompress', form);
return http.post<File.File>('files/decompress', form, TimeoutEnum.T_10M);
};
export const GetFileContent = (params: File.ReqFile) => {
+2 -2
View File
@@ -121,7 +121,7 @@ export const ApplySSL = (req: Website.SSLApply) => {
};
export const RenewSSL = (req: Website.SSLRenew) => {
return http.post<any>(`/websites/ssl/renew`, req);
return http.post<any>(`/websites/ssl/renew`, req, TimeoutEnum.T_10M);
};
export const UpdateSSL = (req: Website.SSLUpdate) => {
@@ -129,7 +129,7 @@ export const UpdateSSL = (req: Website.SSLUpdate) => {
};
export const GetDnsResolve = (req: Website.DNSResolveReq) => {
return http.post<Website.DNSResolve[]>(`/websites/ssl/resolve`, req, TimeoutEnum.T_60S);
return http.post<Website.DNSResolve[]>(`/websites/ssl/resolve`, req, TimeoutEnum.T_5M);
};
export const GetHTTPSConfig = (id: number) => {
+1 -1
View File
@@ -120,5 +120,5 @@ export const Units = [
{ label: i18n.global.t('commons.units.day'), value: 'd' },
{ label: i18n.global.t('commons.units.week'), value: 'w' },
{ label: i18n.global.t('commons.units.month'), value: 'M' },
{ label: i18n.global.t('commons.units.year'), value: 'Y' },
{ label: i18n.global.t('commons.units.year'), value: 'y' },
];