diff --git a/internal/data/app.go b/internal/data/app.go index 92254a1f..1b0cc331 100644 --- a/internal/data/app.go +++ b/internal/data/app.go @@ -10,7 +10,6 @@ import ( "github.com/hashicorp/go-version" "github.com/knadh/koanf/v2" "github.com/leonelquinteros/gotext" - "github.com/libtnb/utils/collect" "github.com/spf13/cast" "gorm.io/gorm" @@ -71,8 +70,7 @@ func (r *appRepo) UpdateExist(slug string) bool { for channel := range slices.Values(item.Channels) { if channel.Slug == installed.Channel { - current := collect.First(channel.Subs) - if current != nil && current.Version != installed.Version { + if channel.Version != installed.Version { return true } } @@ -174,7 +172,7 @@ func (r *appRepo) Install(channel, slug string) error { } shellUrl = ch.Install shellChannel = ch.Slug - shellVersion = collect.First(ch.Subs).Version + shellVersion = ch.Version break } } @@ -284,7 +282,7 @@ func (r *appRepo) Update(slug string) error { } shellUrl = ch.Update shellChannel = ch.Slug - shellVersion = collect.First(ch.Subs).Version + shellVersion = ch.Version break } } diff --git a/internal/service/app.go b/internal/service/app.go index 2d3e3bbd..f0105a69 100644 --- a/internal/service/app.go +++ b/internal/service/app.go @@ -51,29 +51,36 @@ func (s *AppService) List(w http.ResponseWriter, r *http.Request) { updateExist = s.appRepo.UpdateExist(item.Slug) show = installedAppMap[item.Slug].Show } - apps = append(apps, types.AppCenter{ - Icon: item.Icon, - Name: item.Name, - Description: item.Description, - Slug: item.Slug, - Channels: []struct { - Slug string `json:"slug"` - Name string `json:"name"` - Panel string `json:"panel"` - Install string `json:"-"` - Uninstall string `json:"-"` - Update string `json:"-"` - Subs []struct { - Log string `json:"log"` - Version string `json:"version"` - } `json:"subs"` - }(item.Channels), + + app := types.AppCenter{ + Icon: item.Icon, + Name: item.Name, + Description: item.Description, + Slug: item.Slug, Installed: installed, InstalledChannel: installedChannel, InstalledVersion: installedVersion, UpdateExist: updateExist, Show: show, - }) + } + + for _, c := range item.Channels { + app.Channels = append(app.Channels, struct { + Slug string `json:"slug"` + Name string `json:"name"` + Panel string `json:"panel"` + Version string `json:"version"` + Log string `json:"log"` + }{ + Slug: c.Slug, + Name: c.Name, + Panel: c.Panel, + Version: c.Version, + Log: c.Log, + }) + } + + apps = append(apps, app) } paged, total := Paginate(r, apps) diff --git a/pkg/api/api.go b/pkg/api/api.go index 242132f7..413293a4 100644 --- a/pkg/api/api.go +++ b/pkg/api/api.go @@ -25,7 +25,7 @@ func NewAPI(panelVersion, locale string, url ...string) *API { panic("panel version is required") } if len(url) == 0 { - url = append(url, "https://panel.haozi.net/api") + url = append(url, "https://api.acepanel.net") } hostInfo, err := host.Info() @@ -36,7 +36,12 @@ func NewAPI(panelVersion, locale string, url ...string) *API { client := resty.New() client.SetTimeout(10 * time.Second) client.SetBaseURL(url[0]) - client.SetHeader("User-Agent", fmt.Sprintf("rat-panel/%s %s/%s", panelVersion, hostInfo.Platform, hostInfo.PlatformVersion)) + client.SetHeader( + "User-Agent", + fmt.Sprintf("acepanel/%s/%s %s/%s arch/%s kernel/%s", + panelVersion, locale, hostInfo.Platform, hostInfo.PlatformVersion, hostInfo.KernelArch, hostInfo.KernelVersion, + ), + ) client.SetQueryParam("locale", locale) return &API{ diff --git a/pkg/api/app.go b/pkg/api/app.go index 9dd385a0..1da6134f 100644 --- a/pkg/api/app.go +++ b/pkg/api/app.go @@ -13,18 +13,16 @@ type App struct { Name string `json:"name"` Description string `json:"description"` Categories []string `json:"categories"` - Depends string `json:"depends"` + Depends string `json:"depends"` // 依赖表达式 Channels []struct { - Slug string `json:"slug"` - Name string `json:"name"` - Panel string `json:"panel"` - Install string `json:"install"` - Uninstall string `json:"uninstall"` - Update string `json:"update"` - Subs []struct { - Log string `json:"log"` - Version string `json:"version"` - } `json:"subs"` + Slug string `json:"slug"` // 渠道代号 + Name string `json:"name"` // 渠道名称 + Panel string `json:"panel"` // 最低支持面板版本 + Install string `json:"install"` // 安装脚本 + Uninstall string `json:"uninstall"` // 卸载脚本 + Update string `json:"update"` // 更新脚本 + Version string `json:"version"` // 版本号 + Log string `json:"log"` // 更新日志 } `json:"channels"` Order int `json:"order"` } diff --git a/pkg/types/app.go b/pkg/types/app.go index d70d0b78..9a2deabc 100644 --- a/pkg/types/app.go +++ b/pkg/types/app.go @@ -14,16 +14,11 @@ type AppCenter struct { Description string `json:"description"` Slug string `json:"slug"` Channels []struct { - Slug string `json:"slug"` - Name string `json:"name"` - Panel string `json:"panel"` - Install string `json:"-"` - Uninstall string `json:"-"` - Update string `json:"-"` - Subs []struct { - Log string `json:"log"` - Version string `json:"version"` - } `json:"subs"` + Slug string `json:"slug"` + Name string `json:"name"` + Panel string `json:"panel"` + Version string `json:"version"` + Log string `json:"log"` } `json:"channels"` Installed bool `json:"installed"` InstalledChannel string `json:"installed_channel"` diff --git a/web/src/views/app/VersionModal.vue b/web/src/views/app/VersionModal.vue index 33be9b02..352e635c 100644 --- a/web/src/views/app/VersionModal.vue +++ b/web/src/views/app/VersionModal.vue @@ -45,7 +45,7 @@ const handleSubmit = () => { const handleChannelUpdate = (value: string) => { const channel = info.value.channels.find((channel) => channel.slug === value) if (channel) { - model.value.version = channel.subs[0].version + model.value.version = channel.version } } diff --git a/web/src/views/app/types.ts b/web/src/views/app/types.ts index e742d8a2..c9021c00 100644 --- a/web/src/views/app/types.ts +++ b/web/src/views/app/types.ts @@ -14,10 +14,6 @@ export interface Channel { slug: string name: string panel: string - subs: Sub[] -} - -export interface Sub { - log: string version: string + log: string }