feat: 添加同步进度显示和中文界面支持
refactor: 重构同步引擎以支持进度跟踪 style: 更新前端界面为中文 docs: 更新README为中文文档
This commit is contained in:
@@ -30,11 +30,26 @@ func NewClient(serverURL, token string) (*Client, error) {
|
||||
}
|
||||
|
||||
func (c *Client) do(path string) (*http.Response, error) {
|
||||
apiURL := c.baseURL.JoinPath(path)
|
||||
q := apiURL.Query()
|
||||
reqURL := c.baseURL.JoinPath(path)
|
||||
q := reqURL.Query()
|
||||
q.Set("token", c.token)
|
||||
apiURL.RawQuery = q.Encode()
|
||||
resp, err := c.httpClient.Get(apiURL.String())
|
||||
reqURL.RawQuery = q.Encode()
|
||||
resp, err := c.httpClient.Get(reqURL.String())
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("request failed: %w", err)
|
||||
}
|
||||
return resp, nil
|
||||
}
|
||||
|
||||
func (c *Client) doSearch(path string, params map[string]string) (*http.Response, error) {
|
||||
reqURL := c.baseURL.JoinPath(path)
|
||||
q := reqURL.Query()
|
||||
q.Set("token", c.token)
|
||||
for k, v := range params {
|
||||
q.Set(k, v)
|
||||
}
|
||||
reqURL.RawQuery = q.Encode()
|
||||
resp, err := c.httpClient.Get(reqURL.String())
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("request failed: %w", err)
|
||||
}
|
||||
@@ -59,8 +74,10 @@ func (c *Client) ValidateToken() (*GiteaUser, error) {
|
||||
}
|
||||
|
||||
func (c *Client) SearchRepos(page, limit int) ([]GiteaRepo, error) {
|
||||
path := fmt.Sprintf("/api/v1/repos/search?page=%d&limit=%d", page, limit)
|
||||
resp, err := c.do(path)
|
||||
resp, err := c.doSearch("/api/v1/repos/search", map[string]string{
|
||||
"page": fmt.Sprintf("%d", page),
|
||||
"limit": fmt.Sprintf("%d", limit),
|
||||
})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user