Skip to content

Commit ff120c4

Browse files
zhengkunwang223wanghe-fit2cloud
authored andcommitted
feat: 应用商店增加版本控制 (#2068)
1 parent 4d5993c commit ff120c4

File tree

5 files changed

+20
-1
lines changed

5 files changed

+20
-1
lines changed

backend/app/dto/app.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,8 @@ type LocalAppInstallDefine struct {
6767
}
6868

6969
type ExtraProperties struct {
70-
Tags []Tag `json:"tags"`
70+
Tags []Tag `json:"tags"`
71+
Version string `json:"version"`
7172
}
7273

7374
type AppProperty struct {

backend/app/service/app.go

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -668,6 +668,21 @@ func (a AppService) GetAppUpdate() (*response.AppUpdateRes, error) {
668668
res.CanUpdate = true
669669
return res, err
670670
}
671+
if err = getAppFromRepo(fmt.Sprintf("%s/%s/1panel.json.zip", global.CONF.System.AppRepo, global.CONF.System.Mode)); err != nil {
672+
return nil, err
673+
}
674+
listFile := path.Join(constant.ResourceDir, "1panel.json")
675+
content, err := os.ReadFile(listFile)
676+
if err != nil {
677+
return nil, err
678+
}
679+
list := &dto.AppList{}
680+
if err = json.Unmarshal(content, list); err != nil {
681+
return nil, err
682+
}
683+
if list.Extra.Version != "" && !common.CompareVersion(setting.SystemVersion, list.Extra.Version) {
684+
return nil, buserr.New("ErrVersionTooLow")
685+
}
671686
return res, nil
672687
}
673688

backend/i18n/lang/en.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ ErrContainerNotFound: '{{ .name }} container does not exist'
4646
ErrContainerMsg: '{{ .name }} container is abnormal, please check the log on the container page for details'
4747
ErrAppBackup: '{{ .name }} application backup failed err {{.err}}'
4848
ErrImagePull: '{{ .name }} image pull failed err {{.err}}'
49+
ErrVersionTooLow: 'The current 1Panel version is too low to update the app store, please upgrade the version'
4950

5051
#file
5152
ErrFileCanNotRead: "File can not read"

backend/i18n/lang/zh-Hant.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ ErrContainerNotFound: '{{ .name }} 容器不存在'
4646
ErrContainerMsg: '{{ .name }} 容器異常,具體請在容器頁面查看日誌'
4747
ErrAppBackup: '{{ .name }} 應用備份失敗 err {{.err}}'
4848
ErrImagePull: '{{ .name }} 鏡像拉取失敗 err {{.err}}'
49+
ErrVersionTooLow: '當前 1Panel 版本過低,無法更新應用商店,請升級版本之後操作'
4950

5051
#file
5152
ErrFileCanNotRead: "此文件不支持預覽"

backend/i18n/lang/zh.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ ErrContainerNotFound: '{{ .name }} 容器不存在'
4646
ErrContainerMsg: '{{ .name }} 容器异常,具体请在容器页面查看日志'
4747
ErrAppBackup: '{{ .name }} 应用备份失败 err {{.err}}'
4848
ErrImagePull: '镜像拉取失败 {{.err}}'
49+
ErrVersionTooLow: '当前 1Panel 版本过低,无法更新应用商店,请升级版本之后操作'
4950

5051
#file
5152
ErrFileCanNotRead: "此文件不支持预览"

0 commit comments

Comments
 (0)