diff --git a/agent/app/dto/response/app.go b/agent/app/dto/response/app.go
index 803a2be32..94c367ee4 100644
--- a/agent/app/dto/response/app.go
+++ b/agent/app/dto/response/app.go
@@ -45,6 +45,7 @@ type AppDto struct {
Github string `json:"github"`
Website string `json:"website"`
GpuSupport bool `json:"gpuSupport"`
+ Recommend int `json:"recommend"`
}
type TagDTO struct {
diff --git a/agent/app/repo/app.go b/agent/app/repo/app.go
index 88946e29f..12a2f84d6 100644
--- a/agent/app/repo/app.go
+++ b/agent/app/repo/app.go
@@ -30,6 +30,7 @@ type IAppRepo interface {
Create(ctx context.Context, app *model.App) error
Save(ctx context.Context, app *model.App) error
BatchDelete(ctx context.Context, apps []model.App) error
+ DeleteByIDs(ctx context.Context, ids []uint) error
}
func NewIAppRepo() IAppRepo {
@@ -91,7 +92,7 @@ func (a AppRepo) Page(page, size int, opts ...DBOption) (int64, []model.App, err
var apps []model.App
db := getDb(opts...).Model(&model.App{})
count := int64(0)
- db = db.Count(&count)
+ db = db.Count(&count).Debug()
err := db.Limit(size).Offset(size * (page - 1)).Preload("AppTags").Find(&apps).Error
return count, apps, err
}
@@ -137,3 +138,7 @@ func (a AppRepo) Save(ctx context.Context, app *model.App) error {
func (a AppRepo) BatchDelete(ctx context.Context, apps []model.App) error {
return getTx(ctx).Omit(clause.Associations).Delete(&apps).Error
}
+
+func (a AppRepo) DeleteByIDs(ctx context.Context, ids []uint) error {
+ return getTx(ctx).Where("id in (?)", ids).Delete(&model.App{}).Error
+}
diff --git a/agent/app/repo/app_detail.go b/agent/app/repo/app_detail.go
index de1267d95..84e54776c 100644
--- a/agent/app/repo/app_detail.go
+++ b/agent/app/repo/app_detail.go
@@ -19,6 +19,7 @@ type IAppDetailRepo interface {
Update(ctx context.Context, detail model.AppDetail) error
BatchCreate(ctx context.Context, details []model.AppDetail) error
DeleteByAppIds(ctx context.Context, appIds []uint) error
+ DeleteByIDs(ctx context.Context, appIds []uint) error
GetBy(opts ...DBOption) ([]model.AppDetail, error)
BatchUpdateBy(maps map[string]interface{}, opts ...DBOption) error
BatchDelete(ctx context.Context, appDetails []model.AppDetail) error
@@ -64,6 +65,10 @@ func (a AppDetailRepo) DeleteByAppIds(ctx context.Context, appIds []uint) error
return getTx(ctx).Where("app_id in (?)", appIds).Delete(&model.AppDetail{}).Error
}
+func (a AppDetailRepo) DeleteByIDs(ctx context.Context, appIds []uint) error {
+ return getTx(ctx).Where("id in (?)", appIds).Delete(&model.AppDetail{}).Error
+}
+
func (a AppDetailRepo) GetBy(opts ...DBOption) ([]model.AppDetail, error) {
var details []model.AppDetail
err := getDb(opts...).Find(&details).Error
diff --git a/agent/app/repo/app_tag.go b/agent/app/repo/app_tag.go
index a32ef0097..c2d54522b 100644
--- a/agent/app/repo/app_tag.go
+++ b/agent/app/repo/app_tag.go
@@ -2,6 +2,7 @@ package repo
import (
"context"
+ "gorm.io/gorm"
"github.com/1Panel-dev/1Panel/agent/app/model"
)
@@ -15,12 +16,21 @@ type IAppTagRepo interface {
DeleteAll(ctx context.Context) error
GetByAppId(appId uint) ([]model.AppTag, error)
GetByTagIds(tagIds []uint) ([]model.AppTag, error)
+ DeleteBy(ctx context.Context, opts ...DBOption) error
+
+ WithByTagID(tagID uint) DBOption
}
func NewIAppTagRepo() IAppTagRepo {
return &AppTagRepo{}
}
+func (a AppTagRepo) WithByTagID(tagID uint) DBOption {
+ return func(g *gorm.DB) *gorm.DB {
+ return g.Where("tag_id = ?", tagID)
+ }
+}
+
func (a AppTagRepo) BatchCreate(ctx context.Context, tags []*model.AppTag) error {
return getTx(ctx).Create(&tags).Error
}
@@ -48,3 +58,7 @@ func (a AppTagRepo) GetByTagIds(tagIds []uint) ([]model.AppTag, error) {
}
return appTags, nil
}
+
+func (a AppTagRepo) DeleteBy(ctx context.Context, opts ...DBOption) error {
+ return getTx(ctx, opts...).Delete(&model.AppTag{}).Error
+}
diff --git a/agent/app/repo/tag.go b/agent/app/repo/tag.go
index 9f008bcd2..6b2788e8e 100644
--- a/agent/app/repo/tag.go
+++ b/agent/app/repo/tag.go
@@ -16,6 +16,9 @@ type ITagRepo interface {
GetByIds(ids []uint) ([]model.Tag, error)
GetByKeys(keys []string) ([]model.Tag, error)
GetByAppId(appId uint) ([]model.Tag, error)
+ DeleteByID(ctx context.Context, id uint) error
+ Create(ctx context.Context, tag *model.Tag) error
+ Save(ctx context.Context, tag *model.Tag) error
}
func NewITagRepo() ITagRepo {
@@ -61,3 +64,15 @@ func (t TagRepo) GetByAppId(appId uint) ([]model.Tag, error) {
}
return tags, nil
}
+
+func (t TagRepo) DeleteByID(ctx context.Context, id uint) error {
+ return getTx(ctx).Where("id = ?", id).Delete(&model.Tag{}).Error
+}
+
+func (t TagRepo) Create(ctx context.Context, tag *model.Tag) error {
+ return getTx(ctx).Create(tag).Error
+}
+
+func (t TagRepo) Save(ctx context.Context, tag *model.Tag) error {
+ return getTx(ctx).Save(tag).Error
+}
diff --git a/agent/app/service/app.go b/agent/app/service/app.go
index 5eb7c1b8c..bad1caa68 100644
--- a/agent/app/service/app.go
+++ b/agent/app/service/app.go
@@ -120,6 +120,7 @@ func (a AppService) PageApp(req request.AppSearch) (interface{}, error) {
Website: ap.Website,
Github: ap.Github,
GpuSupport: ap.GpuSupport,
+ Recommend: ap.Recommend,
}
appDTOs = append(appDTOs, appDTO)
appTags, err := appTagRepo.GetByAppId(ap.ID)
diff --git a/agent/app/service/app_utils.go b/agent/app/service/app_utils.go
index 13c221581..2eee09a64 100644
--- a/agent/app/service/app_utils.go
+++ b/agent/app/service/app_utils.go
@@ -7,6 +7,7 @@ import (
"fmt"
"github.com/1Panel-dev/1Panel/agent/utils/nginx"
"github.com/1Panel-dev/1Panel/agent/utils/nginx/parser"
+ "github.com/1Panel-dev/1Panel/agent/utils/xpack"
"log"
"math"
"net/http"
@@ -403,27 +404,6 @@ func deleteAppInstall(deleteReq request.AppInstallDelete) error {
}
switch install.App.Key {
- case constant.AppOpenresty:
- //TODO 删除 Openresty 不再删除网站
- //websites, _ := websiteRepo.List()
- //for _, website := range websites {
- // if website.AppInstallID > 0 {
- // websiteAppInstall, _ := appInstallRepo.GetFirst(commonRepo.WithByID(website.AppInstallID))
- // if websiteAppInstall.AppId > 0 {
- // websiteApp, _ := appRepo.GetFirst(commonRepo.WithByID(websiteAppInstall.AppId))
- // if websiteApp.Type == constant.RuntimePHP {
- // go func() {
- // _, _ = compose.Down(websiteAppInstall.GetComposePath())
- // _ = op.DeleteDir(websiteAppInstall.GetPath())
- // }()
- // _ = appInstallRepo.Delete(ctx, websiteAppInstall)
- // }
- // }
- // }
- //}
- //_ = websiteRepo.DeleteAll(ctx)
- //_ = websiteDomainRepo.DeleteAll(ctx)
- //xpack.RemoveTamper("")
case constant.AppMysql, constant.AppMariaDB:
_ = mysqlRepo.Delete(ctx, mysqlRepo.WithByMysqlName(install.Name))
case constant.AppPostgresql:
@@ -1045,7 +1025,15 @@ func upApp(task *task.Task, appInstall *model.AppInstall, pullImages bool) {
if err != nil {
return err
}
+ imagePrefix := xpack.GetImagePrefix()
for _, image := range images {
+ if imagePrefix != "" {
+ lastSlashIndex := strings.LastIndex(image, "/")
+ if lastSlashIndex != -1 {
+ image = image[lastSlashIndex+1:]
+ }
+ image = imagePrefix + "/" + image
+ }
task.Log(i18n.GetWithName("PullImageStart", image))
if out, err = cmd.ExecWithTimeOut("docker pull "+image, 20*time.Minute); err != nil {
if out != "" {
@@ -1555,6 +1543,22 @@ func addDockerComposeCommonParam(composeMap map[string]interface{}, serviceName
if !serviceValid {
return buserr.New(constant.ErrFileParse)
}
+ imagePreFix := xpack.GetImagePrefix()
+ if imagePreFix != "" {
+ for _, service := range services {
+ serviceValue := service.(map[string]interface{})
+ if image, ok := serviceValue["image"]; ok {
+ imageStr := image.(string)
+ lastSlashIndex := strings.LastIndex(imageStr, "/")
+ if lastSlashIndex != -1 {
+ imageStr = imageStr[lastSlashIndex+1:]
+ }
+ imageStr = imagePreFix + "/" + imageStr
+ serviceValue["image"] = imageStr
+ }
+ }
+ }
+
service, serviceExist := services[serviceName]
if !serviceExist {
return buserr.New(constant.ErrFileParse)
diff --git a/agent/i18n/lang/en.yaml b/agent/i18n/lang/en.yaml
index 4bb84471c..fffec4c77 100644
--- a/agent/i18n/lang/en.yaml
+++ b/agent/i18n/lang/en.yaml
@@ -70,7 +70,11 @@ MoveSiteDir: "The current upgrade requires migrating the OpenResty website direc
MoveSiteToDir: "Migrate the website directory to {{ .name }}"
ErrMoveSiteDir: "Failed to migrate the website directory"
MoveSiteDirSuccess: "Successfully migrated the website directory"
-DeleteRuntimePHP: "Delete PHP runtime environment"
+DeleteRuntimePHP: "Delete PHP runtime environment",
+CustomAppStoreNotConfig: "Please configure the offline package address in the app store settings",
+CustomAppStoreNotFound: "Failed to retrieve app store package, please check if it exists",
+CustomAppStoreFileValid: "App store package must be in .tar.gz format"
+
#file
ErrFileCanNotRead: "File can not read"
diff --git a/agent/i18n/lang/zh-Hant.yaml b/agent/i18n/lang/zh-Hant.yaml
index d202689aa..256ca4b2f 100644
--- a/agent/i18n/lang/zh-Hant.yaml
+++ b/agent/i18n/lang/zh-Hant.yaml
@@ -71,7 +71,11 @@ MoveSiteDir: "當前升級需要遷移 OpenResty 網站目錄"
MoveSiteToDir: "遷移網站目錄到 {{ .name }}"
ErrMoveSiteDir: "遷移網站目錄失敗"
MoveSiteDirSuccess: "遷移網站目錄成功"
-DeleteRuntimePHP: "刪除運行環境 PHP 版本"
+DeleteRuntimePHP: "刪除運行環境 PHP 版本",
+CustomAppStoreNotConfig: "請在應用商店設置離線包地址",
+CustomAppStoreNotFound: "應用商店包獲取失敗,請檢查是否存在",
+CustomAppStoreFileValid: "應用商店包需要 .tar.gz 格式"
+
#file
ErrFileCanNotRead: "此文件不支持預覽"
diff --git a/agent/i18n/lang/zh.yaml b/agent/i18n/lang/zh.yaml
index 21f063b2c..2fb15aae5 100644
--- a/agent/i18n/lang/zh.yaml
+++ b/agent/i18n/lang/zh.yaml
@@ -71,6 +71,9 @@ MoveSiteToDir: "迁移网站目录到 {{ .name }}"
ErrMoveSiteDir: "迁移网站目录失败"
MoveSiteDirSuccess: "迁移网站目录成功"
DeleteRuntimePHP: "删除 PHP 运行环境"
+CustomAppStoreNotConfig: "请在应用商店设置离线包地址"
+CustomAppStoreNotFound: "应用商店包获取失败,请检查是否存在"
+CustomAppStoreFileValid: "应用商店包需要 .tar.gz 格式"
#file
ErrFileCanNotRead: "此文件不支持预览"
diff --git a/agent/utils/xpack/xpack.go b/agent/utils/xpack/xpack.go
index b85ccb523..12303b282 100644
--- a/agent/utils/xpack/xpack.go
+++ b/agent/utils/xpack/xpack.go
@@ -43,3 +43,7 @@ func InitNodeData(tx *gorm.DB) (bool, string, error) { return true, "127.0.0.1",
func RequestToMaster(reqUrl, reqMethod string, reqBody io.Reader) (interface{}, error) {
return nil, nil
}
+
+func GetImagePrefix() string {
+ return ""
+}
diff --git a/frontend/src/api/modules/app.ts b/frontend/src/api/modules/app.ts
index 6d022c55a..a7a6c6cfa 100644
--- a/frontend/src/api/modules/app.ts
+++ b/frontend/src/api/modules/app.ts
@@ -118,3 +118,7 @@ export const GetAppStoreConfig = () => {
export const UpdateAppStoreConfig = (req: App.AppStoreConfig) => {
return http.post(`apps/store/update`, req);
};
+
+export const SyncCutomAppStore = (req: App.AppStoreSync) => {
+ return http.post(`/custom/app/sync`, req);
+};
diff --git a/frontend/src/views/app-store/apps/index.vue b/frontend/src/views/app-store/apps/index.vue
index 27ef8be4e..56980869d 100644
--- a/frontend/src/views/app-store/apps/index.vue
+++ b/frontend/src/views/app-store/apps/index.vue
@@ -175,7 +175,7 @@
diff --git a/frontend/src/views/app-store/setting/index.vue b/frontend/src/views/app-store/setting/index.vue
index ce7b7d8a2..a6fc5fbdb 100644
--- a/frontend/src/views/app-store/setting/index.vue
+++ b/frontend/src/views/app-store/setting/index.vue
@@ -4,7 +4,7 @@
-
+
+
+
+ {{ $t('commons.button.set') }}
+
+
{{ $t('app.defaultWebDomainHepler') }}
-
-
- {{ $t('commons.button.confirm') }}
-
-
+
+