Skip to content

Commit f546ffe

Browse files
feat: 应用商店增加版本控制 (#2068)
1 parent 6a8bd49 commit f546ffe

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
@@ -670,6 +670,21 @@ func (a AppService) GetAppUpdate() (*response.AppUpdateRes, error) {
670670
res.CanUpdate = true
671671
return res, err
672672
}
673+
if err = getAppFromRepo(fmt.Sprintf("%s/%s/1panel.json.zip", global.CONF.System.AppRepo, global.CONF.System.Mode)); err != nil {
674+
return nil, err
675+
}
676+
listFile := path.Join(constant.ResourceDir, "1panel.json")
677+
content, err := os.ReadFile(listFile)
678+
if err != nil {
679+
return nil, err
680+
}
681+
list := &dto.AppList{}
682+
if err = json.Unmarshal(content, list); err != nil {
683+
return nil, err
684+
}
685+
if list.Extra.Version != "" && !common.CompareVersion(setting.SystemVersion, list.Extra.Version) {
686+
return nil, buserr.New("ErrVersionTooLow")
687+
}
673688
return res, nil
674689
}
675690

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)