mirror of
https://github.com/acepanel/panel.git
synced 2026-02-04 06:47:20 +08:00
feat: api支持传递locale,close #155
This commit is contained in:
@@ -11,8 +11,8 @@ import (
|
||||
)
|
||||
|
||||
type API struct {
|
||||
panelVersion string
|
||||
client *resty.Client
|
||||
panelVersion, locale string
|
||||
client *resty.Client
|
||||
}
|
||||
|
||||
type Response struct {
|
||||
@@ -20,7 +20,7 @@ type Response struct {
|
||||
Data any `json:"data"`
|
||||
}
|
||||
|
||||
func NewAPI(panelVersion string, url ...string) *API {
|
||||
func NewAPI(panelVersion, locale string, url ...string) *API {
|
||||
if len(panelVersion) == 0 {
|
||||
panic("panel version is required")
|
||||
}
|
||||
@@ -37,6 +37,7 @@ func NewAPI(panelVersion string, url ...string) *API {
|
||||
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.SetQueryParam("locale", locale)
|
||||
|
||||
return &API{
|
||||
panelVersion: panelVersion,
|
||||
|
||||
@@ -13,7 +13,7 @@ type APITestSuite struct {
|
||||
|
||||
func TestAPITestSuite(t *testing.T) {
|
||||
suite.Run(t, &APITestSuite{
|
||||
api: NewAPI("2.3.0"),
|
||||
api: NewAPI("2.3.0", "en"),
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user