mirror of https://github.com/1Panel-dev/1Panel
feat: 应用增加权重
parent
62709bcec6
commit
4d77345ce0
|
@ -47,6 +47,7 @@ type AppDefine struct {
|
|||
Required []string `json:"Required"`
|
||||
CrossVersionUpdate bool `json:"crossVersionUpdate"`
|
||||
Limit int `json:"limit"`
|
||||
Recommend int `json:"recommend"`
|
||||
Website string `json:"website"`
|
||||
Github string `json:"github"`
|
||||
Document string `json:"document"`
|
||||
|
|
|
@ -7,9 +7,10 @@ import (
|
|||
|
||||
type AppSearch struct {
|
||||
dto.PageInfo
|
||||
Name string `json:"name"`
|
||||
Tags []string `json:"tags"`
|
||||
Type string `json:"type"`
|
||||
Name string `json:"name"`
|
||||
Tags []string `json:"tags"`
|
||||
Type string `json:"type"`
|
||||
Recommend bool `json:"recommend"`
|
||||
}
|
||||
|
||||
type AppInstallCreate struct {
|
||||
|
|
|
@ -14,6 +14,7 @@ type App struct {
|
|||
Website string `json:"website" gorm:"type:varchar(64);not null"`
|
||||
Github string `json:"github" gorm:"type:varchar(64);not null"`
|
||||
Document string `json:"document" gorm:"type:varchar(64);not null"`
|
||||
Recommend int `json:"recommend" gorm:"type:Integer;not null"`
|
||||
Details []AppDetail `json:"-"`
|
||||
TagsKey []string `json:"-" gorm:"-"`
|
||||
AppTags []AppTag `json:"-" `
|
||||
|
|
|
@ -22,6 +22,18 @@ func (a AppRepo) WithType(typeStr string) DBOption {
|
|||
}
|
||||
}
|
||||
|
||||
func (a AppRepo) OrderByRecommend() DBOption {
|
||||
return func(g *gorm.DB) *gorm.DB {
|
||||
return g.Order("recommend asc")
|
||||
}
|
||||
}
|
||||
|
||||
func (a AppRepo) GetRecommend() DBOption {
|
||||
return func(g *gorm.DB) *gorm.DB {
|
||||
return g.Where("recommend < 9999")
|
||||
}
|
||||
}
|
||||
|
||||
func (a AppRepo) Page(page, size int, opts ...DBOption) (int64, []model.App, error) {
|
||||
var apps []model.App
|
||||
db := getDb(opts...).Model(&model.App{})
|
||||
|
|
|
@ -27,13 +27,16 @@ type AppService struct {
|
|||
|
||||
func (a AppService) PageApp(req request.AppSearch) (interface{}, error) {
|
||||
var opts []repo.DBOption
|
||||
opts = append(opts, commonRepo.WithOrderBy("name"))
|
||||
opts = append(opts, appRepo.OrderByRecommend())
|
||||
if req.Name != "" {
|
||||
opts = append(opts, commonRepo.WithLikeName(req.Name))
|
||||
}
|
||||
if req.Type != "" {
|
||||
opts = append(opts, appRepo.WithType(req.Type))
|
||||
}
|
||||
if req.Recommend {
|
||||
opts = append(opts, appRepo.GetRecommend())
|
||||
}
|
||||
if len(req.Tags) != 0 {
|
||||
tags, err := tagRepo.GetByKeys(req.Tags)
|
||||
if err != nil {
|
||||
|
@ -51,7 +54,6 @@ func (a AppService) PageApp(req request.AppSearch) (interface{}, error) {
|
|||
for _, t := range appTags {
|
||||
appIds = append(appIds, t.AppId)
|
||||
}
|
||||
|
||||
opts = append(opts, commonRepo.WithIdsIn(appIds))
|
||||
}
|
||||
var res response.AppRes
|
||||
|
@ -377,6 +379,11 @@ func (a AppService) SyncAppList() error {
|
|||
iconStr := base64.StdEncoding.EncodeToString(icon)
|
||||
app.Icon = iconStr
|
||||
app.TagsKey = l.Tags
|
||||
if l.Recommend > 0 {
|
||||
app.Recommend = l.Recommend
|
||||
} else {
|
||||
app.Recommend = 9999
|
||||
}
|
||||
|
||||
versions := l.Versions
|
||||
detailsMap := getAppDetails(app.Details, versions)
|
||||
|
|
|
@ -77,7 +77,7 @@ func createLink(ctx context.Context, app model.App, appInstall *model.AppInstall
|
|||
appInstall.Param = string(authByte)
|
||||
}
|
||||
}
|
||||
if app.Type == "website" {
|
||||
if app.Type == "website" || app.Type == "tool" {
|
||||
paramByte, err := json.Marshal(params)
|
||||
if err != nil {
|
||||
return err
|
||||
|
|
|
@ -43,6 +43,7 @@ export namespace App {
|
|||
name?: string;
|
||||
tags?: string[];
|
||||
type?: string;
|
||||
recommend?: boolean;
|
||||
}
|
||||
|
||||
export interface AppParams {
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
v-if="p.type == 'text'"
|
||||
:type="p.type"
|
||||
@change="updateParam"
|
||||
:disabled="p.disabled"
|
||||
></el-input>
|
||||
<el-input
|
||||
v-model.number="form[p.envKey]"
|
||||
|
|
|
@ -45,6 +45,7 @@ let req = reactive({
|
|||
tags: [],
|
||||
page: 1,
|
||||
pageSize: 50,
|
||||
recommend: true,
|
||||
});
|
||||
|
||||
const baseInfo = ref({
|
||||
|
|
Loading…
Reference in New Issue