diff --git a/apps/redis/6.0.16/docker-compose.yml b/apps/redis/6.0.16/docker-compose.yml index 1621ee690..ec58ccc87 100644 --- a/apps/redis/6.0.16/docker-compose.yml +++ b/apps/redis/6.0.16/docker-compose.yml @@ -7,7 +7,7 @@ services: - 1panel ports: - ${PANEL_APP_PORT_HTTP}:6379 - command: redis-server --save 20 1 --loglevel warning --requirepass eYVX7EwVmmxKPCDmwMtyKVge8oLd2t81 + command: redis-server --save 20 1 --loglevel warning --requirepass ${PANEL_DB_ROOT_PASSWORD} volumes: - ./data:/data networks: diff --git a/apps/redis/7.0.5/docker-compose.yml b/apps/redis/7.0.5/docker-compose.yml index b2de06f97..e0eb96782 100644 --- a/apps/redis/7.0.5/docker-compose.yml +++ b/apps/redis/7.0.5/docker-compose.yml @@ -7,7 +7,7 @@ services: - 1panel ports: - ${PANEL_APP_PORT_HTTP}:6379 - command: redis-server --save 20 1 --loglevel warning --requirepass eYVX7EwVmmxKPCDmwMtyKVge8oLd2t81 + command: redis-server --save 20 1 --loglevel warning --requirepass ${PANEL_DB_ROOT_PASSWORD} volumes: - ./data:/data networks: diff --git a/backend/app/api/v1/app.go b/backend/app/api/v1/app.go index e1d84fd62..425f21d21 100644 --- a/backend/app/api/v1/app.go +++ b/backend/app/api/v1/app.go @@ -70,12 +70,13 @@ func (b *BaseApi) InstallApp(c *gin.Context) { helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInvalidParams, err) return } - if err := appService.Install(req.Name, req.AppDetailId, req.Params); err != nil { + install, err := appService.Install(req.Name, req.AppDetailId, req.Params) + if err != nil { helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err) return } - helper.SuccessWithData(c, nil) + helper.SuccessWithData(c, install) } func (b *BaseApi) DeleteAppBackup(c *gin.Context) { diff --git a/backend/app/api/v1/website.go b/backend/app/api/v1/website.go index 0532a1a30..648673eca 100644 --- a/backend/app/api/v1/website.go +++ b/backend/app/api/v1/website.go @@ -7,14 +7,29 @@ import ( "github.com/gin-gonic/gin" ) -func (b *BaseApi) CreateWebsite(c *gin.Context) { +func (b *BaseApi) PageWebsite(c *gin.Context) { + var req dto.WebSiteReq + if err := c.ShouldBindJSON(&req); err != nil { + helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInvalidParams, err) + return + } + total, websites, err := websiteService.PageWebSite(req) + if err != nil { + helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err) + return + } + helper.SuccessWithData(c, dto.PageResult{ + Total: total, + Items: websites, + }) +} +func (b *BaseApi) CreateWebsite(c *gin.Context) { var req dto.WebSiteCreate if err := c.ShouldBindJSON(&req); err != nil { helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInvalidParams, err) return } - err := websiteService.CreateWebsite(req) if err != nil { helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err) @@ -22,3 +37,17 @@ func (b *BaseApi) CreateWebsite(c *gin.Context) { } helper.SuccessWithData(c, nil) } + +func (b *BaseApi) DeleteWebSite(c *gin.Context) { + var req dto.WebSiteDel + if err := c.ShouldBindJSON(&req); err != nil { + helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInvalidParams, err) + return + } + err := websiteService.DeleteWebSite(req) + if err != nil { + helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err) + return + } + helper.SuccessWithData(c, nil) +} diff --git a/backend/app/api/v1/website_group.go b/backend/app/api/v1/website_group.go index 228171025..ed71ae22c 100644 --- a/backend/app/api/v1/website_group.go +++ b/backend/app/api/v1/website_group.go @@ -2,11 +2,12 @@ package v1 import ( "github.com/1Panel-dev/1Panel/backend/app/api/v1/helper" + "github.com/1Panel-dev/1Panel/backend/app/dto" "github.com/1Panel-dev/1Panel/backend/constant" "github.com/gin-gonic/gin" ) -func (b *BaseApi) GetGroups(c *gin.Context) { +func (b *BaseApi) GetWebGroups(c *gin.Context) { list, err := websiteGroupService.GetGroups() if err != nil { @@ -15,3 +16,18 @@ func (b *BaseApi) GetGroups(c *gin.Context) { } helper.SuccessWithData(c, list) } + +func (b *BaseApi) CreateWebGroup(c *gin.Context) { + + var req dto.WebSiteGroupCreate + if err := c.ShouldBindJSON(&req); err != nil { + helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInvalidParams, err) + return + } + + if err := websiteGroupService.CreateGroup(req); err != nil { + helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err) + return + } + helper.SuccessWithData(c, nil) +} diff --git a/backend/app/dto/app.go b/backend/app/dto/app.go index 31a5eb36f..36ce2d30c 100644 --- a/backend/app/dto/app.go +++ b/backend/app/dto/app.go @@ -29,6 +29,7 @@ type AppRequest struct { PageInfo Name string `json:"name"` Tags []string `json:"tags"` + Type string `json:"type"` } type AppInstallRequest struct { diff --git a/backend/app/dto/website.go b/backend/app/dto/website.go index 35a8e5841..8e4183aa5 100644 --- a/backend/app/dto/website.go +++ b/backend/app/dto/website.go @@ -1,16 +1,43 @@ package dto -type WebPage struct { +import "github.com/1Panel-dev/1Panel/backend/app/model" + +type WebSiteReq struct { PageInfo } +type AppType string + +const ( + NewApp AppType = "new" + InstalledApp AppType = "installed" +) + type WebSiteCreate struct { - PrimaryDomain string `json:"primaryDomain"` - Type string `json:"type"` - Alias string `json:"alias"` - Remark string `json:"remark"` - Domains []string `json:"domains"` - AppType string `json:"appType"` - AppInstallID uint `json:"appInstallID"` - WebSiteGroupID uint `json:"webSiteGroupID"` + PrimaryDomain string `json:"primaryDomain" validate:"required"` + Type string `json:"type" validate:"required"` + Alias string `json:"alias" validate:"required"` + Remark string `json:"remark"` + Domains []string `json:"domains"` + AppType AppType `json:"appType" validate:"required"` + AppInstall NewAppInstall `json:"appInstall"` + AppID uint `json:"appID"` + AppInstallID uint `json:"appInstallID"` + WebSiteGroupID uint `json:"webSiteGroupID" validate:"required"` +} + +type NewAppInstall struct { + Name string `json:"name"` + AppDetailId uint `json:"appDetailID"` + Params map[string]interface{} `json:"params"` +} + +type WebSiteDel struct { + ID uint `json:"id"` + DeleteApp bool `json:"deleteApp"` + DeleteBackup bool `json:"deleteBackup"` +} + +type WebSiteDTO struct { + model.WebSite } diff --git a/backend/app/dto/website_group.go b/backend/app/dto/website_group.go index e9fe56d55..37ba914d3 100644 --- a/backend/app/dto/website_group.go +++ b/backend/app/dto/website_group.go @@ -1,10 +1,10 @@ package dto -type WebSiteGroupCreateReq struct { +type WebSiteGroupCreate struct { Name string } -type WebSiteGroupUpdateReq struct { +type WebSiteGroupUpdate struct { ID uint Name string } diff --git a/backend/app/repo/common.go b/backend/app/repo/common.go index 6caea9d17..eedf2c374 100644 --- a/backend/app/repo/common.go +++ b/backend/app/repo/common.go @@ -2,6 +2,7 @@ package repo import ( "context" + "github.com/1Panel-dev/1Panel/backend/constant" "github.com/1Panel-dev/1Panel/backend/global" "gorm.io/gorm" ) @@ -70,10 +71,10 @@ func (c *CommonRepo) WithIdsNotIn(ids []uint) DBOption { } func getTx(ctx context.Context, opts ...DBOption) *gorm.DB { - if ctx == nil || ctx.Value("db") == nil { + if ctx == nil || ctx.Value(constant.DB) == nil { return getDb() } - tx := ctx.Value("db").(*gorm.DB) + tx := ctx.Value(constant.DB).(*gorm.DB) for _, opt := range opts { tx = opt(tx) } diff --git a/backend/app/repo/website.go b/backend/app/repo/website.go index 2e2d41dd8..883c24163 100644 --- a/backend/app/repo/website.go +++ b/backend/app/repo/website.go @@ -43,3 +43,7 @@ func (w WebSiteRepo) Create(ctx context.Context, app *model.WebSite) error { func (w WebSiteRepo) Save(ctx context.Context, app *model.WebSite) error { return getTx(ctx).Omit(clause.Associations).Save(app).Error } + +func (w WebSiteRepo) DeleteBy(ctx context.Context, opts ...DBOption) error { + return getTx(ctx, opts...).Delete(&model.WebSite{}).Error +} diff --git a/backend/app/repo/website_domain.go b/backend/app/repo/website_domain.go index 488b4e892..33d35962d 100644 --- a/backend/app/repo/website_domain.go +++ b/backend/app/repo/website_domain.go @@ -3,12 +3,18 @@ package repo import ( "context" "github.com/1Panel-dev/1Panel/backend/app/model" + "gorm.io/gorm" "gorm.io/gorm/clause" ) type WebSiteDomainRepo struct { } +func (w WebSiteDomainRepo) WithWebSiteId(websiteId uint) DBOption { + return func(db *gorm.DB) *gorm.DB { + return db.Where("web_site_id = ?", websiteId) + } +} func (w WebSiteDomainRepo) Page(page, size int, opts ...DBOption) (int64, []model.WebSiteDomain, error) { var domains []model.WebSiteDomain db := getDb(opts...).Model(&model.WebSiteDomain{}) @@ -47,3 +53,7 @@ func (w WebSiteDomainRepo) Create(ctx context.Context, app *model.WebSiteDomain) func (w WebSiteDomainRepo) Save(ctx context.Context, app *model.WebSiteDomain) error { return getTx(ctx).Omit(clause.Associations).Save(app).Error } + +func (w WebSiteDomainRepo) DeleteBy(ctx context.Context, opts ...DBOption) error { + return getTx(ctx, opts...).Delete(&model.WebSiteDomain{}).Error +} diff --git a/backend/app/service/app.go b/backend/app/service/app.go index ef4a12d66..debbd16df 100644 --- a/backend/app/service/app.go +++ b/backend/app/service/app.go @@ -34,6 +34,9 @@ func (a AppService) PageApp(req dto.AppRequest) (interface{}, error) { if req.Name != "" { opts = append(opts, commonRepo.WithLikeName(req.Name)) } + if req.Type != "" { + opts = append(opts, appRepo.WithType(req.Type)) + } if len(req.Tags) != 0 { tags, err := tagRepo.GetByKeys(req.Tags) if err != nil { @@ -212,7 +215,13 @@ func (a AppService) OperateInstall(req dto.AppInstallOperate) error { } install.Status = constant.Running case dto.Delete: - return deleteAppInstall(install) + tx, ctx := getTxAndContext() + if err := deleteAppInstall(ctx, install); err != nil { + tx.Rollback() + return err + } + tx.Commit() + return nil case dto.Sync: return a.SyncInstalled(install.ID) case dto.Backup: @@ -286,36 +295,38 @@ func (a AppService) ChangeAppPort(req dto.PortUpdate) error { return nil } -func (a AppService) Install(name string, appDetailId uint, params map[string]interface{}) error { + + +func (a AppService) Install(name string, appDetailId uint, params map[string]interface{}) (*model.AppInstall, error) { httpPort, err := checkPort("PANEL_APP_PORT_HTTP", params) if err != nil { - return fmt.Errorf("%d port is in used", httpPort) + return nil, fmt.Errorf("%d port is in used", httpPort) } httpsPort, err := checkPort("PANEL_APP_PORT_HTTPS", params) if err != nil { - return fmt.Errorf("%d port is in used", httpPort) + return nil, fmt.Errorf("%d port is in used", httpPort) } appDetail, err := appDetailRepo.GetFirst(commonRepo.WithByID(appDetailId)) if err != nil { - return err + return nil, err } app, err := appRepo.GetFirst(commonRepo.WithByID(appDetail.AppId)) if err != nil { - return err + return nil, err } if err := checkRequiredAndLimit(app); err != nil { - return err + return nil, err } if err := copyAppData(app.Key, appDetail.Version, name, params); err != nil { - return err + return nil, err } paramByte, err := json.Marshal(params) if err != nil { - return err + return nil, err } appInstall := model.AppInstall{ Name: name, @@ -331,7 +342,7 @@ func (a AppService) Install(name string, appDetailId uint, params map[string]int composeMap := make(map[string]interface{}) if err := yaml.Unmarshal([]byte(appDetail.DockerCompose), &composeMap); err != nil { - return err + return nil, err } servicesMap := composeMap["services"].(map[string]interface{}) changeKeys := make(map[string]string, len(servicesMap)) @@ -350,27 +361,27 @@ func (a AppService) Install(name string, appDetailId uint, params map[string]int } composeByte, err := yaml.Marshal(composeMap) if err != nil { - return err + return nil, err } appInstall.DockerCompose = string(composeByte) fileOp := files.NewFileOp() if err := fileOp.WriteFile(appInstall.GetComposePath(), strings.NewReader(string(composeByte)), 0775); err != nil { - return err + return nil, err } tx, ctx := getTxAndContext() if err := appInstallRepo.Create(ctx, &appInstall); err != nil { tx.Rollback() - return err + return nil, err } if err := createLink(ctx, app, &appInstall, params); err != nil { tx.Rollback() - return err + return nil, err } tx.Commit() go upApp(appInstall.GetComposePath(), appInstall) - return nil + return &appInstall, nil } func (a AppService) SyncAllInstalled() error { diff --git a/backend/app/service/app_utils.go b/backend/app/service/app_utils.go index ba156272b..9d582ce9d 100644 --- a/backend/app/service/app_utils.go +++ b/backend/app/service/app_utils.go @@ -150,7 +150,7 @@ func createLink(ctx context.Context, app model.App, appInstall *model.AppInstall return nil } -func deleteAppInstall(install model.AppInstall) error { +func deleteAppInstall(ctx context.Context, install model.AppInstall) error { op := files.NewFileOp() appDir := install.GetPath() dir, _ := os.Stat(appDir) @@ -164,20 +164,15 @@ func deleteAppInstall(install model.AppInstall) error { } } - tx, ctx := getTxAndContext() if err := appInstallRepo.Delete(ctx, install); err != nil { - tx.Rollback() return err } if err := deleteLink(ctx, &install); err != nil { - tx.Rollback() return err } if err := appInstallBackupRepo.Delete(ctx, appInstallBackupRepo.WithAppInstallID(install.ID)); err != nil { - tx.Rollback() return err } - tx.Commit() return nil } diff --git a/backend/app/service/helper.go b/backend/app/service/helper.go index d059c98b9..d498ec1b6 100644 --- a/backend/app/service/helper.go +++ b/backend/app/service/helper.go @@ -2,18 +2,13 @@ package service import ( "context" + "github.com/1Panel-dev/1Panel/backend/constant" "github.com/1Panel-dev/1Panel/backend/global" "gorm.io/gorm" ) -type DBContext string - -const ( - DB DBContext = "db" -) - func getTxAndContext() (tx *gorm.DB, ctx context.Context) { tx = global.DB.Begin() - ctx = context.WithValue(context.Background(), DB, tx) + ctx = context.WithValue(context.Background(), constant.DB, tx) return } diff --git a/backend/app/service/website.go b/backend/app/service/website.go index a5ce6c10e..db39a3b6a 100644 --- a/backend/app/service/website.go +++ b/backend/app/service/website.go @@ -4,6 +4,8 @@ import ( "github.com/1Panel-dev/1Panel/backend/app/dto" "github.com/1Panel-dev/1Panel/backend/app/model" "github.com/1Panel-dev/1Panel/backend/constant" + "github.com/pkg/errors" + "gorm.io/gorm" "reflect" "time" ) @@ -11,10 +13,22 @@ import ( type WebsiteService struct { } +func (w WebsiteService) PageWebSite(req dto.WebSiteReq) (int64, []dto.WebSiteDTO, error) { + var websiteDTOs []dto.WebSiteDTO + total, websites, err := websiteRepo.Page(req.Page, req.PageSize) + if err != nil { + return 0, nil, err + } + for _, web := range websites { + websiteDTOs = append(websiteDTOs, dto.WebSiteDTO{ + WebSite: web, + }) + } + return total, websiteDTOs, nil +} + func (w WebsiteService) CreateWebsite(create dto.WebSiteCreate) error { - defaultDate, _ := time.Parse(constant.DateLayout, constant.DefaultDate) - website := &model.WebSite{ PrimaryDomain: create.PrimaryDomain, Type: create.Type, @@ -26,6 +40,14 @@ func (w WebsiteService) CreateWebsite(create dto.WebSiteCreate) error { WebSiteGroupID: create.WebSiteGroupID, } + if create.AppType == dto.NewApp { + install, err := ServiceGroupApp.Install(create.AppInstall.Name, create.AppInstall.AppDetailId, create.AppInstall.Params) + if err != nil { + return err + } + website.AppInstallID = install.ID + } + tx, ctx := getTxAndContext() if err := websiteRepo.Create(ctx, website); err != nil { return err @@ -50,7 +72,7 @@ func (w WebsiteService) CreateWebsite(create dto.WebSiteCreate) error { } } - if err := configDefaultNginx(*website, domains); err != nil { + if err := configDefaultNginx(website, domains); err != nil { tx.Rollback() return err } @@ -58,3 +80,38 @@ func (w WebsiteService) CreateWebsite(create dto.WebSiteCreate) error { tx.Commit() return nil } + +func (w WebsiteService) DeleteWebSite(req dto.WebSiteDel) error { + + website, err := websiteRepo.GetFirst(commonRepo.WithByID(req.ID)) + if err != nil { + return err + } + if err := delNginxConfig(website); err != nil { + return err + } + tx, ctx := getTxAndContext() + + if req.DeleteApp { + appInstall, err := appInstallRepo.GetFirst(commonRepo.WithByID(website.AppInstallID)) + if err != nil && !errors.Is(err, gorm.ErrRecordNotFound) { + return err + } + if !reflect.DeepEqual(model.AppInstall{}, appInstall) { + if err := deleteAppInstall(ctx, appInstall); err != nil { + return err + } + } + } + //TODO 删除备份 + if err := websiteRepo.DeleteBy(ctx, commonRepo.WithByID(req.ID)); err != nil { + tx.Rollback() + return err + } + if err := websiteDomainRepo.DeleteBy(ctx, websiteDomainRepo.WithWebSiteId(req.ID)); err != nil { + tx.Rollback() + return err + } + tx.Commit() + return nil +} diff --git a/backend/app/service/website_group.go b/backend/app/service/website_group.go index 3a668d9bb..4ab56f319 100644 --- a/backend/app/service/website_group.go +++ b/backend/app/service/website_group.go @@ -8,7 +8,7 @@ import ( type WebsiteGroupService struct { } -func (w WebsiteGroupService) CreateGroup(create dto.WebSiteGroupCreateReq) error { +func (w WebsiteGroupService) CreateGroup(create dto.WebSiteGroupCreate) error { return websiteGroupRepo.Create(&model.WebSiteGroup{ Name: create.Name, }) @@ -18,7 +18,7 @@ func (w WebsiteGroupService) GetGroups() ([]model.WebSiteGroup, error) { return websiteGroupRepo.GetBy() } -func (w WebsiteGroupService) UpdateGroup(update dto.WebSiteGroupUpdateReq) error { +func (w WebsiteGroupService) UpdateGroup(update dto.WebSiteGroupUpdate) error { return websiteGroupRepo.Save(&model.WebSiteGroup{ BaseModel: model.BaseModel{ ID: update.ID, diff --git a/backend/app/service/website_utils.go b/backend/app/service/website_utils.go index bdbf784ea..cbee90775 100644 --- a/backend/app/service/website_utils.go +++ b/backend/app/service/website_utils.go @@ -5,10 +5,12 @@ import ( "github.com/1Panel-dev/1Panel/backend/app/model" "github.com/1Panel-dev/1Panel/backend/constant" "github.com/1Panel-dev/1Panel/backend/utils/cmd" + "github.com/1Panel-dev/1Panel/backend/utils/files" "github.com/1Panel-dev/1Panel/backend/utils/nginx" "github.com/1Panel-dev/1Panel/backend/utils/nginx/parser" "github.com/1Panel-dev/1Panel/cmd/server/nginx_conf" "github.com/pkg/errors" + "gorm.io/gorm" "path" "strconv" "strings" @@ -21,6 +23,7 @@ func getDomain(domainStr string, websiteID uint) (model.WebSiteDomain, error) { domainArray := strings.Split(domainStr, ":") if len(domainArray) == 1 { domain.Domain = domainArray[0] + domain.Port = 80 return domain, nil } if len(domainArray) > 1 { @@ -36,7 +39,7 @@ func getDomain(domainStr string, websiteID uint) (model.WebSiteDomain, error) { return model.WebSiteDomain{}, nil } -func configDefaultNginx(website model.WebSite, domains []model.WebSiteDomain) error { +func configDefaultNginx(website *model.WebSite, domains []model.WebSiteDomain) error { nginxApp, err := appRepo.GetFirst(appRepo.WithKey("nginx")) if err != nil { @@ -67,7 +70,7 @@ func configDefaultNginx(website model.WebSite, domains []model.WebSiteDomain) er server.UpdateListen(string(rune(domain.Port)), false) } server.UpdateServerName(serverNames) - proxy := fmt.Sprintf("%s:%d", appInstall.ServiceName, appInstall.HttpPort) + proxy := fmt.Sprintf("http://%s:%d", appInstall.ServiceName, appInstall.HttpPort) server.UpdateRootProxy([]string{proxy}) config.FilePath = configPath @@ -90,3 +93,34 @@ func opNginx(containerName, operate string) error { } return nil } + +func delNginxConfig(website model.WebSite) error { + + nginxApp, err := appRepo.GetFirst(appRepo.WithKey("nginx")) + if err != nil { + return err + } + nginxInstall, err := appInstallRepo.GetFirst(appInstallRepo.WithAppId(nginxApp.ID)) + if err != nil { + if errors.Is(err, gorm.ErrRecordNotFound) { + return nil + } + return err + } + + nginxFileName := website.PrimaryDomain + ".conf" + configPath := path.Join(constant.AppInstallDir, "nginx", nginxInstall.Name, "conf", "conf.d", nginxFileName) + fileOp := files.NewFileOp() + + if !fileOp.Stat(configPath) { + return nil + } + if err := fileOp.DeleteFile(configPath); err != nil { + return err + } + return opNginx(nginxInstall.ContainerName, "reload") +} + +func delApp() error { + return nil +} diff --git a/backend/constant/common.go b/backend/constant/common.go new file mode 100644 index 000000000..4488f1ffe --- /dev/null +++ b/backend/constant/common.go @@ -0,0 +1,7 @@ +package constant + +type DBContext string + +const ( + DB DBContext = "db" +) diff --git a/backend/router/ro_website.go b/backend/router/ro_website.go index fadb333d3..665a862db 100644 --- a/backend/router/ro_website.go +++ b/backend/router/ro_website.go @@ -16,5 +16,7 @@ func (a *WebsiteRouter) InitWebsiteRouter(Router *gin.RouterGroup) { baseApi := v1.ApiGroupApp.BaseApi { groupRouter.POST("", baseApi.CreateWebsite) + groupRouter.POST("/search", baseApi.PageWebsite) + groupRouter.POST("/del", baseApi.DeleteWebSite) } } diff --git a/backend/router/ro_website_group.go b/backend/router/ro_website_group.go index da91029d7..4f3895e73 100644 --- a/backend/router/ro_website_group.go +++ b/backend/router/ro_website_group.go @@ -15,6 +15,7 @@ func (a *WebsiteGroupRouter) InitWebsiteGroupRouter(Router *gin.RouterGroup) { baseApi := v1.ApiGroupApp.BaseApi { - groupRouter.GET("", baseApi.GetGroups) + groupRouter.GET("", baseApi.GetWebGroups) + //groupRouter.GET("", baseApi.GetGroups) } } diff --git a/frontend/src/api/interface/app.ts b/frontend/src/api/interface/app.ts index a2bc2cc74..f0e868076 100644 --- a/frontend/src/api/interface/app.ts +++ b/frontend/src/api/interface/app.ts @@ -39,8 +39,9 @@ export namespace App { } export interface AppReq extends ReqPage { - name: string; - tags: string[]; + name?: string; + tags?: string[]; + type?: string; } export interface AppParams { diff --git a/frontend/src/api/interface/website.ts b/frontend/src/api/interface/website.ts index e53a6b7e5..8284c17ff 100644 --- a/frontend/src/api/interface/website.ts +++ b/frontend/src/api/interface/website.ts @@ -1,6 +1,35 @@ -import { CommonModel } from '.'; +import { CommonModel, ReqPage } from '.'; export namespace WebSite { + export interface WebSite extends CommonModel { + primaryDomain: string; + type: string; + alias: string; + remark: string; + domains: string[]; + appType: string; + appInstallID?: number; + webSiteGroupID: number; + otherDomains: string; + appinstall?: NewAppInstall; + } + + export interface NewAppInstall { + name: string; + appDetailID: number; + params: any; + } + + export interface WebSiteSearch extends ReqPage { + name: string; + } + + export interface WebSiteDel { + id: number; + deleteApp: boolean; + deleteBackup: boolean; + } + export interface WebSiteCreateReq { primaryDomain: string; type: string; @@ -15,5 +44,6 @@ export namespace WebSite { export interface Group extends CommonModel { name: string; + default: boolean; } } diff --git a/frontend/src/api/modules/website.ts b/frontend/src/api/modules/website.ts index 46bcbdb94..6ab76ce61 100644 --- a/frontend/src/api/modules/website.ts +++ b/frontend/src/api/modules/website.ts @@ -1,10 +1,19 @@ import http from '@/api'; +import { ResPage } from '../interface'; import { WebSite } from '../interface/website'; -export const listGroups = () => { +export const SearchWebSites = (req: WebSite.WebSiteSearch) => { + return http.post>(`/websites/search`, req); +}; + +export const ListGroups = () => { return http.get(`/websites/groups`); }; export const CreateWebsite = (req: WebSite.WebSiteCreateReq) => { return http.post(`/websites`, req); }; + +export const DeleteWebsite = (req: WebSite.WebSiteDel) => { + return http.post(`/websites/del`, req); +}; diff --git a/frontend/src/lang/modules/zh.ts b/frontend/src/lang/modules/zh.ts index 284f85e1f..9e5e1b83e 100644 --- a/frontend/src/lang/modules/zh.ts +++ b/frontend/src/lang/modules/zh.ts @@ -633,6 +633,7 @@ export default { description: '一个现代化的 Linux 面板工具', }, app: { + app: '应用', installed: '已安装', all: '全部', version: '版本', @@ -676,5 +677,8 @@ export default { app_new: '新装应用', app_installed: '已装应用', create: '创建网站', + delete: '删除网站', + deleteApp: '删除应用', + deleteBackup: '删除备份', }, }; diff --git a/frontend/src/views/app-store/detail/index.vue b/frontend/src/views/app-store/detail/index.vue index d0ec7a6bf..329178f60 100644 --- a/frontend/src/views/app-store/detail/index.vue +++ b/frontend/src/views/app-store/detail/index.vue @@ -54,7 +54,7 @@ import { GetApp, GetAppDetail } from '@/api/modules/app'; import LayoutContent from '@/layout/layout-content.vue'; import { onMounted, ref } from 'vue'; -import Install from './install.vue'; +import Install from './install/index.vue'; interface OperateProps { id: number; diff --git a/frontend/src/views/app-store/detail/install.vue b/frontend/src/views/app-store/detail/install/index.vue similarity index 52% rename from frontend/src/views/app-store/detail/install.vue rename to frontend/src/views/app-store/detail/install/index.vue index a27d519b6..b0594cffd 100644 --- a/frontend/src/views/app-store/detail/install.vue +++ b/frontend/src/views/app-store/detail/install/index.vue @@ -4,26 +4,7 @@ -
- - - - - - - - -
+