refactor: clean code

This commit is contained in:
Fu Diwei 2025-05-25 23:32:41 +08:00
parent b798b824db
commit 0909671be6
28 changed files with 81 additions and 92 deletions

View File

@ -82,9 +82,9 @@ func (d *DeployerProvider) Deploy(ctx context.Context, certPEM string, privkeyPE
return &deployer.DeployResult{}, nil return &deployer.DeployResult{}, nil
} }
func createSdkClient(apiUrl, apiVersion, apiKey string, skipTlsVerify bool) (*onepanelsdk.Client, error) { func createSdkClient(serverUrl, apiVersion, apiKey string, skipTlsVerify bool) (*onepanelsdk.Client, error) {
if _, err := url.Parse(apiUrl); err != nil { if _, err := url.Parse(serverUrl); err != nil {
return nil, errors.New("invalid 1panel api url") return nil, errors.New("invalid 1panel server url")
} }
if apiVersion == "" { if apiVersion == "" {
@ -95,7 +95,7 @@ func createSdkClient(apiUrl, apiVersion, apiKey string, skipTlsVerify bool) (*on
return nil, errors.New("invalid 1panel api key") return nil, errors.New("invalid 1panel api key")
} }
client := onepanelsdk.NewClient(apiUrl, apiVersion, apiKey) client := onepanelsdk.NewClient(serverUrl, apiVersion, apiKey)
if skipTlsVerify { if skipTlsVerify {
client.WithTLSConfig(&tls.Config{InsecureSkipVerify: true}) client.WithTLSConfig(&tls.Config{InsecureSkipVerify: true})
} }

View File

@ -177,9 +177,9 @@ func (d *DeployerProvider) deployToCertificate(ctx context.Context, certPEM stri
return nil return nil
} }
func createSdkClient(apiUrl, apiVersion, apiKey string, skipTlsVerify bool) (*onepanelsdk.Client, error) { func createSdkClient(serverUrl, apiVersion, apiKey string, skipTlsVerify bool) (*onepanelsdk.Client, error) {
if _, err := url.Parse(apiUrl); err != nil { if _, err := url.Parse(serverUrl); err != nil {
return nil, errors.New("invalid 1panel api url") return nil, errors.New("invalid 1panel server url")
} }
if apiVersion == "" { if apiVersion == "" {
@ -190,7 +190,7 @@ func createSdkClient(apiUrl, apiVersion, apiKey string, skipTlsVerify bool) (*on
return nil, errors.New("invalid 1panel api key") return nil, errors.New("invalid 1panel api key")
} }
client := onepanelsdk.NewClient(apiUrl, apiVersion, apiKey) client := onepanelsdk.NewClient(serverUrl, apiVersion, apiKey)
if skipTlsVerify { if skipTlsVerify {
client.WithTLSConfig(&tls.Config{InsecureSkipVerify: true}) client.WithTLSConfig(&tls.Config{InsecureSkipVerify: true})
} }

View File

@ -82,16 +82,16 @@ func (d *DeployerProvider) Deploy(ctx context.Context, certPEM string, privkeyPE
return &deployer.DeployResult{}, nil return &deployer.DeployResult{}, nil
} }
func createSdkClient(apiUrl, apiKey string, skipTlsVerify bool) (*btsdk.Client, error) { func createSdkClient(serverUrl, apiKey string, skipTlsVerify bool) (*btsdk.Client, error) {
if _, err := url.Parse(apiUrl); err != nil { if _, err := url.Parse(serverUrl); err != nil {
return nil, errors.New("invalid baota api url") return nil, errors.New("invalid baota server url")
} }
if apiKey == "" { if apiKey == "" {
return nil, errors.New("invalid baota api key") return nil, errors.New("invalid baota api key")
} }
client := btsdk.NewClient(apiUrl, apiKey) client := btsdk.NewClient(serverUrl, apiKey)
if skipTlsVerify { if skipTlsVerify {
client.WithTLSConfig(&tls.Config{InsecureSkipVerify: true}) client.WithTLSConfig(&tls.Config{InsecureSkipVerify: true})
} }

View File

@ -124,16 +124,16 @@ func (d *DeployerProvider) Deploy(ctx context.Context, certPEM string, privkeyPE
return &deployer.DeployResult{}, nil return &deployer.DeployResult{}, nil
} }
func createSdkClient(apiUrl, apiKey string, skipTlsVerify bool) (*btsdk.Client, error) { func createSdkClient(serverUrl, apiKey string, skipTlsVerify bool) (*btsdk.Client, error) {
if _, err := url.Parse(apiUrl); err != nil { if _, err := url.Parse(serverUrl); err != nil {
return nil, errors.New("invalid baota api url") return nil, errors.New("invalid baota server url")
} }
if apiKey == "" { if apiKey == "" {
return nil, errors.New("invalid baota api key") return nil, errors.New("invalid baota api key")
} }
client := btsdk.NewClient(apiUrl, apiKey) client := btsdk.NewClient(serverUrl, apiKey)
if skipTlsVerify { if skipTlsVerify {
client.WithTLSConfig(&tls.Config{InsecureSkipVerify: true}) client.WithTLSConfig(&tls.Config{InsecureSkipVerify: true})
} }

View File

@ -70,16 +70,16 @@ func (d *DeployerProvider) Deploy(ctx context.Context, certPEM string, privkeyPE
return &deployer.DeployResult{}, nil return &deployer.DeployResult{}, nil
} }
func createSdkClient(apiUrl, apiKey string, skipTlsVerify bool) (*btsdk.Client, error) { func createSdkClient(serverUrl, apiKey string, skipTlsVerify bool) (*btsdk.Client, error) {
if _, err := url.Parse(apiUrl); err != nil { if _, err := url.Parse(serverUrl); err != nil {
return nil, errors.New("invalid baota api url") return nil, errors.New("invalid baota server url")
} }
if apiKey == "" { if apiKey == "" {
return nil, errors.New("invalid baota api key") return nil, errors.New("invalid baota api key")
} }
client := btsdk.NewClient(apiUrl, apiKey) client := btsdk.NewClient(serverUrl, apiKey)
if skipTlsVerify { if skipTlsVerify {
client.WithTLSConfig(&tls.Config{InsecureSkipVerify: true}) client.WithTLSConfig(&tls.Config{InsecureSkipVerify: true})
} }

View File

@ -133,16 +133,16 @@ func (d *DeployerProvider) Deploy(ctx context.Context, certPEM string, privkeyPE
return &deployer.DeployResult{}, nil return &deployer.DeployResult{}, nil
} }
func createSdkClient(apiUrl, apiKey string, skipTlsVerify bool) (*btsdk.Client, error) { func createSdkClient(serverUrl, apiKey string, skipTlsVerify bool) (*btsdk.Client, error) {
if _, err := url.Parse(apiUrl); err != nil { if _, err := url.Parse(serverUrl); err != nil {
return nil, errors.New("invalid baota api url") return nil, errors.New("invalid baota server url")
} }
if apiKey == "" { if apiKey == "" {
return nil, errors.New("invalid baota api key") return nil, errors.New("invalid baota api key")
} }
client := btsdk.NewClient(apiUrl, apiKey) client := btsdk.NewClient(serverUrl, apiKey)
if skipTlsVerify { if skipTlsVerify {
client.WithTLSConfig(&tls.Config{InsecureSkipVerify: true}) client.WithTLSConfig(&tls.Config{InsecureSkipVerify: true})
} }

View File

@ -160,9 +160,9 @@ func (d *DeployerProvider) deployToCertificate(ctx context.Context, certPEM stri
return nil return nil
} }
func createSdkClient(apiUrl, apiKey, apiSecret string, skipTlsVerify bool) (*cfsdk.Client, error) { func createSdkClient(serverUrl, apiKey, apiSecret string, skipTlsVerify bool) (*cfsdk.Client, error) {
if _, err := url.Parse(apiUrl); err != nil { if _, err := url.Parse(serverUrl); err != nil {
return nil, errors.New("invalid cachefly api url") return nil, errors.New("invalid cachefly server url")
} }
if apiKey == "" { if apiKey == "" {
@ -173,7 +173,7 @@ func createSdkClient(apiUrl, apiKey, apiSecret string, skipTlsVerify bool) (*cfs
return nil, errors.New("invalid cachefly api secret") return nil, errors.New("invalid cachefly api secret")
} }
client := cfsdk.NewClient(apiUrl, apiKey, apiSecret) client := cfsdk.NewClient(serverUrl, apiKey, apiSecret)
if skipTlsVerify { if skipTlsVerify {
client.WithTLSConfig(&tls.Config{InsecureSkipVerify: true}) client.WithTLSConfig(&tls.Config{InsecureSkipVerify: true})
} }

View File

@ -119,9 +119,9 @@ func (d *DeployerProvider) deployToCertificate(ctx context.Context, certPEM stri
return nil return nil
} }
func createSdkClient(apiUrl, apiRole, accessKeyId, accessKey string, skipTlsVerify bool) (*flexcdnsdk.Client, error) { func createSdkClient(serverUrl, apiRole, accessKeyId, accessKey string, skipTlsVerify bool) (*flexcdnsdk.Client, error) {
if _, err := url.Parse(apiUrl); err != nil { if _, err := url.Parse(serverUrl); err != nil {
return nil, errors.New("invalid flexcdn api url") return nil, errors.New("invalid flexcdn server url")
} }
if apiRole != "user" && apiRole != "admin" { if apiRole != "user" && apiRole != "admin" {
@ -136,7 +136,7 @@ func createSdkClient(apiUrl, apiRole, accessKeyId, accessKey string, skipTlsVeri
return nil, errors.New("invalid flexcdn access key") return nil, errors.New("invalid flexcdn access key")
} }
client := flexcdnsdk.NewClient(apiUrl, apiRole, accessKeyId, accessKey) client := flexcdnsdk.NewClient(serverUrl, apiRole, accessKeyId, accessKey)
if skipTlsVerify { if skipTlsVerify {
client.WithTLSConfig(&tls.Config{InsecureSkipVerify: true}) client.WithTLSConfig(&tls.Config{InsecureSkipVerify: true})
} }

View File

@ -119,9 +119,9 @@ func (d *DeployerProvider) deployToCertificate(ctx context.Context, certPEM stri
return nil return nil
} }
func createSdkClient(apiUrl, apiRole, accessKeyId, accessKey string, skipTlsVerify bool) (*goedgesdk.Client, error) { func createSdkClient(serverUrl, apiRole, accessKeyId, accessKey string, skipTlsVerify bool) (*goedgesdk.Client, error) {
if _, err := url.Parse(apiUrl); err != nil { if _, err := url.Parse(serverUrl); err != nil {
return nil, errors.New("invalid goedge api url") return nil, errors.New("invalid goedge server url")
} }
if apiRole != "user" && apiRole != "admin" { if apiRole != "user" && apiRole != "admin" {
@ -136,7 +136,7 @@ func createSdkClient(apiUrl, apiRole, accessKeyId, accessKey string, skipTlsVeri
return nil, errors.New("invalid goedge access key") return nil, errors.New("invalid goedge access key")
} }
client := goedgesdk.NewClient(apiUrl, apiRole, accessKeyId, accessKey) client := goedgesdk.NewClient(serverUrl, apiRole, accessKeyId, accessKey)
if skipTlsVerify { if skipTlsVerify {
client.WithTLSConfig(&tls.Config{InsecureSkipVerify: true}) client.WithTLSConfig(&tls.Config{InsecureSkipVerify: true})
} }

View File

@ -141,9 +141,9 @@ func (d *DeployerProvider) deployToCertificate(ctx context.Context, certPEM stri
return nil return nil
} }
func createSdkClient(apiUrl, apiVersion, apiRole, username, password string, skipTlsVerify bool) (interface{}, error) { func createSdkClient(serverUrl, apiVersion, apiRole, username, password string, skipTlsVerify bool) (interface{}, error) {
if _, err := url.Parse(apiUrl); err != nil { if _, err := url.Parse(serverUrl); err != nil {
return nil, errors.New("invalid lecdn api url") return nil, errors.New("invalid lecdn server url")
} }
if username == "" { if username == "" {
@ -156,7 +156,7 @@ func createSdkClient(apiUrl, apiVersion, apiRole, username, password string, ski
if apiVersion == apiVersionV3 && apiRole == apiRoleClient { if apiVersion == apiVersionV3 && apiRole == apiRoleClient {
// v3 版客户端 // v3 版客户端
client := leclientsdkv3.NewClient(apiUrl, username, password) client := leclientsdkv3.NewClient(serverUrl, username, password)
if skipTlsVerify { if skipTlsVerify {
client.WithTLSConfig(&tls.Config{InsecureSkipVerify: true}) client.WithTLSConfig(&tls.Config{InsecureSkipVerify: true})
} }
@ -164,7 +164,7 @@ func createSdkClient(apiUrl, apiVersion, apiRole, username, password string, ski
return client, nil return client, nil
} else if apiVersion == apiVersionV3 && apiRole == apiRoleMaster { } else if apiVersion == apiVersionV3 && apiRole == apiRoleMaster {
// v3 版主控端 // v3 版主控端
client := lemastersdkv3.NewClient(apiUrl, username, password) client := lemastersdkv3.NewClient(serverUrl, username, password)
if skipTlsVerify { if skipTlsVerify {
client.WithTLSConfig(&tls.Config{InsecureSkipVerify: true}) client.WithTLSConfig(&tls.Config{InsecureSkipVerify: true})
} }

View File

@ -91,9 +91,9 @@ func (d *DeployerProvider) Deploy(ctx context.Context, certPEM string, privkeyPE
return &deployer.DeployResult{}, nil return &deployer.DeployResult{}, nil
} }
func createSdkClient(apiUrl, apiToken, apiTokenSecret string, skipTlsVerify bool) (*proxmox.Client, error) { func createSdkClient(serverUrl, apiToken, apiTokenSecret string, skipTlsVerify bool) (*proxmox.Client, error) {
if _, err := url.Parse(apiUrl); err != nil { if _, err := url.Parse(serverUrl); err != nil {
return nil, errors.New("invalid pve api url") return nil, errors.New("invalid pve server url")
} }
if apiToken == "" { if apiToken == "" {
@ -112,7 +112,7 @@ func createSdkClient(apiUrl, apiToken, apiTokenSecret string, skipTlsVerify bool
} }
} }
client := proxmox.NewClient( client := proxmox.NewClient(
strings.TrimRight(apiUrl, "/")+"/api2/json", strings.TrimRight(serverUrl, "/")+"/api2/json",
proxmox.WithHTTPClient(httpClient), proxmox.WithHTTPClient(httpClient),
proxmox.WithAPIToken(apiToken, apiTokenSecret), proxmox.WithAPIToken(apiToken, apiTokenSecret),
) )

View File

@ -72,9 +72,9 @@ func (d *DeployerProvider) Deploy(ctx context.Context, certPEM string, privkeyPE
return &deployer.DeployResult{}, nil return &deployer.DeployResult{}, nil
} }
func createSdkClient(apiUrl string, accessTokenId int32, accessToken string, skipTlsVerify bool) (*rpsdk.Client, error) { func createSdkClient(serverUrl string, accessTokenId int32, accessToken string, skipTlsVerify bool) (*rpsdk.Client, error) {
if _, err := url.Parse(apiUrl); err != nil { if _, err := url.Parse(serverUrl); err != nil {
return nil, errors.New("invalid ratpanel api url") return nil, errors.New("invalid ratpanel server url")
} }
if accessTokenId == 0 { if accessTokenId == 0 {
@ -85,7 +85,7 @@ func createSdkClient(apiUrl string, accessTokenId int32, accessToken string, ski
return nil, errors.New("invalid ratpanel access token") return nil, errors.New("invalid ratpanel access token")
} }
client := rpsdk.NewClient(apiUrl, accessTokenId, accessToken) client := rpsdk.NewClient(serverUrl, accessTokenId, accessToken)
if skipTlsVerify { if skipTlsVerify {
client.WithTLSConfig(&tls.Config{InsecureSkipVerify: true}) client.WithTLSConfig(&tls.Config{InsecureSkipVerify: true})
} }

View File

@ -79,9 +79,9 @@ func (d *DeployerProvider) Deploy(ctx context.Context, certPEM string, privkeyPE
return &deployer.DeployResult{}, nil return &deployer.DeployResult{}, nil
} }
func createSdkClient(apiUrl string, accessTokenId int32, accessToken string, skipTlsVerify bool) (*rpsdk.Client, error) { func createSdkClient(serverUrl string, accessTokenId int32, accessToken string, skipTlsVerify bool) (*rpsdk.Client, error) {
if _, err := url.Parse(apiUrl); err != nil { if _, err := url.Parse(serverUrl); err != nil {
return nil, errors.New("invalid ratpanel api url") return nil, errors.New("invalid ratpanel server url")
} }
if accessTokenId == 0 { if accessTokenId == 0 {
@ -92,7 +92,7 @@ func createSdkClient(apiUrl string, accessTokenId int32, accessToken string, ski
return nil, errors.New("invalid ratpanel access token") return nil, errors.New("invalid ratpanel access token")
} }
client := rpsdk.NewClient(apiUrl, accessTokenId, accessToken) client := rpsdk.NewClient(serverUrl, accessTokenId, accessToken)
if skipTlsVerify { if skipTlsVerify {
client.WithTLSConfig(&tls.Config{InsecureSkipVerify: true}) client.WithTLSConfig(&tls.Config{InsecureSkipVerify: true})
} }

View File

@ -98,16 +98,16 @@ func (d *DeployerProvider) deployToCertificate(ctx context.Context, certPEM stri
return nil return nil
} }
func createSdkClient(apiUrl, apiToken string, skipTlsVerify bool) (*safelinesdk.Client, error) { func createSdkClient(serverUrl, apiToken string, skipTlsVerify bool) (*safelinesdk.Client, error) {
if _, err := url.Parse(apiUrl); err != nil { if _, err := url.Parse(serverUrl); err != nil {
return nil, errors.New("invalid safeline api url") return nil, errors.New("invalid safeline server url")
} }
if apiToken == "" { if apiToken == "" {
return nil, errors.New("invalid safeline api token") return nil, errors.New("invalid safeline api token")
} }
client := safelinesdk.NewClient(apiUrl, apiToken) client := safelinesdk.NewClient(serverUrl, apiToken)
if skipTlsVerify { if skipTlsVerify {
client.WithTLSConfig(&tls.Config{InsecureSkipVerify: true}) client.WithTLSConfig(&tls.Config{InsecureSkipVerify: true})
} }

View File

@ -132,9 +132,9 @@ func (u *UploaderProvider) getCertIfExists(ctx context.Context, certPEM string,
return nil, nil return nil, nil
} }
func createSdkClient(apiUrl, apiVersion, apiKey string) (*onepanelsdk.Client, error) { func createSdkClient(serverUrl, apiVersion, apiKey string) (*onepanelsdk.Client, error) {
if _, err := url.Parse(apiUrl); err != nil { if _, err := url.Parse(serverUrl); err != nil {
return nil, errors.New("invalid 1panel api url") return nil, errors.New("invalid 1panel server url")
} }
if apiVersion == "" { if apiVersion == "" {
@ -145,6 +145,6 @@ func createSdkClient(apiUrl, apiVersion, apiKey string) (*onepanelsdk.Client, er
return nil, errors.New("invalid 1panel api key") return nil, errors.New("invalid 1panel api key")
} }
client := onepanelsdk.NewClient(apiUrl, apiVersion, apiKey) client := onepanelsdk.NewClient(serverUrl, apiVersion, apiKey)
return client, nil return client, nil
} }

View File

@ -19,13 +19,13 @@ type Client struct {
client *resty.Client client *resty.Client
} }
func NewClient(apiHost, apiVersion, apiKey string) *Client { func NewClient(serverUrl, apiVersion, apiKey string) *Client {
if apiVersion == "" { if apiVersion == "" {
apiVersion = "v1" apiVersion = "v1"
} }
client := resty.New(). client := resty.New().
SetBaseURL(strings.TrimRight(apiHost, "/") + "/api/" + apiVersion). SetBaseURL(strings.TrimRight(serverUrl, "/") + "/api/" + apiVersion).
SetPreRequestHook(func(c *resty.Client, req *http.Request) error { SetPreRequestHook(func(c *resty.Client, req *http.Request) error {
timestamp := fmt.Sprintf("%d", time.Now().Unix()) timestamp := fmt.Sprintf("%d", time.Now().Unix())
tokenMd5 := md5.Sum([]byte("1panel" + apiKey + timestamp)) tokenMd5 := md5.Sum([]byte("1panel" + apiKey + timestamp))

View File

@ -19,9 +19,9 @@ type Client struct {
client *resty.Client client *resty.Client
} }
func NewClient(apiHost, apiKey string) *Client { func NewClient(serverUrl, apiKey string) *Client {
client := resty.New(). client := resty.New().
SetBaseURL(strings.TrimRight(apiHost, "/")) SetBaseURL(strings.TrimRight(serverUrl, "/"))
return &Client{ return &Client{
apiKey: apiKey, apiKey: apiKey,

View File

@ -17,9 +17,9 @@ type Client struct {
client *resty.Client client *resty.Client
} }
func NewClient(apiHost, apiKey string) *Client { func NewClient(serverUrl, apiKey string) *Client {
client := resty.New(). client := resty.New().
SetBaseURL(strings.TrimRight(apiHost, "/") + "/api"). SetBaseURL(strings.TrimRight(serverUrl, "/") + "/api").
SetPreRequestHook(func(c *resty.Client, req *http.Request) error { SetPreRequestHook(func(c *resty.Client, req *http.Request) error {
timestamp := fmt.Sprintf("%d", time.Now().Unix()) timestamp := fmt.Sprintf("%d", time.Now().Unix())
keyMd5 := md5.Sum([]byte(apiKey)) keyMd5 := md5.Sum([]byte(apiKey))

View File

@ -15,9 +15,9 @@ type Client struct {
client *resty.Client client *resty.Client
} }
func NewClient(apiHost, apiKey, apiSecret string) *Client { func NewClient(serverUrl, apiKey, apiSecret string) *Client {
client := resty.New(). client := resty.New().
SetBaseURL(strings.TrimRight(apiHost, "/")). SetBaseURL(strings.TrimRight(serverUrl, "/")).
SetHeader("api-key", apiKey). SetHeader("api-key", apiKey).
SetHeader("api-secret", apiSecret) SetHeader("api-secret", apiSecret)

View File

@ -24,14 +24,14 @@ type Client struct {
client *resty.Client client *resty.Client
} }
func NewClient(apiHost, apiRole, accessKeyId, accessKey string) *Client { func NewClient(serverUrl, apiRole, accessKeyId, accessKey string) *Client {
client := &Client{ client := &Client{
apiRole: apiRole, apiRole: apiRole,
accessKeyId: accessKeyId, accessKeyId: accessKeyId,
accessKey: accessKey, accessKey: accessKey,
} }
client.client = resty.New(). client.client = resty.New().
SetBaseURL(strings.TrimRight(apiHost, "/")). SetBaseURL(strings.TrimRight(serverUrl, "/")).
SetPreRequestHook(func(c *resty.Client, req *http.Request) error { SetPreRequestHook(func(c *resty.Client, req *http.Request) error {
if client.accessToken != "" { if client.accessToken != "" {
req.Header.Set("X-Cloud-Access-Token", client.accessToken) req.Header.Set("X-Cloud-Access-Token", client.accessToken)

View File

@ -24,14 +24,14 @@ type Client struct {
client *resty.Client client *resty.Client
} }
func NewClient(apiHost, apiRole, accessKeyId, accessKey string) *Client { func NewClient(serverUrl, apiRole, accessKeyId, accessKey string) *Client {
client := &Client{ client := &Client{
apiRole: apiRole, apiRole: apiRole,
accessKeyId: accessKeyId, accessKeyId: accessKeyId,
accessKey: accessKey, accessKey: accessKey,
} }
client.client = resty.New(). client.client = resty.New().
SetBaseURL(strings.TrimRight(apiHost, "/")). SetBaseURL(strings.TrimRight(serverUrl, "/")).
SetPreRequestHook(func(c *resty.Client, req *http.Request) error { SetPreRequestHook(func(c *resty.Client, req *http.Request) error {
if client.accessToken != "" { if client.accessToken != "" {
req.Header.Set("X-Edge-Access-Token", client.accessToken) req.Header.Set("X-Edge-Access-Token", client.accessToken)

View File

@ -22,13 +22,13 @@ type Client struct {
client *resty.Client client *resty.Client
} }
func NewClient(apiHost, username, password string) *Client { func NewClient(serverUrl, username, password string) *Client {
client := &Client{ client := &Client{
username: username, username: username,
password: password, password: password,
} }
client.client = resty.New(). client.client = resty.New().
SetBaseURL(strings.TrimRight(apiHost, "/") + "/prod-api"). SetBaseURL(strings.TrimRight(serverUrl, "/") + "/prod-api").
SetPreRequestHook(func(c *resty.Client, req *http.Request) error { SetPreRequestHook(func(c *resty.Client, req *http.Request) error {
if client.accessToken != "" { if client.accessToken != "" {
req.Header.Set("Authorization", "Bearer "+client.accessToken) req.Header.Set("Authorization", "Bearer "+client.accessToken)

View File

@ -22,13 +22,13 @@ type Client struct {
client *resty.Client client *resty.Client
} }
func NewClient(apiHost, username, password string) *Client { func NewClient(serverUrl, username, password string) *Client {
client := &Client{ client := &Client{
username: username, username: username,
password: password, password: password,
} }
client.client = resty.New(). client.client = resty.New().
SetBaseURL(strings.TrimRight(apiHost, "/") + "/prod-api"). SetBaseURL(strings.TrimRight(serverUrl, "/") + "/prod-api").
SetPreRequestHook(func(c *resty.Client, req *http.Request) error { SetPreRequestHook(func(c *resty.Client, req *http.Request) error {
if client.accessToken != "" { if client.accessToken != "" {
req.Header.Set("Authorization", "Bearer "+client.accessToken) req.Header.Set("Authorization", "Bearer "+client.accessToken)

View File

@ -20,9 +20,9 @@ type Client struct {
client *resty.Client client *resty.Client
} }
func NewClient(apiHost string, accessTokenId int32, accessToken string) *Client { func NewClient(serverUrl string, accessTokenId int32, accessToken string) *Client {
client := resty.New(). client := resty.New().
SetBaseURL(strings.TrimRight(apiHost, "/")+"/api"). SetBaseURL(strings.TrimRight(serverUrl, "/")+"/api").
SetHeader("Accept", "application/json"). SetHeader("Accept", "application/json").
SetHeader("Content-Type", "application/json"). SetHeader("Content-Type", "application/json").
SetPreRequestHook(func(c *resty.Client, req *http.Request) error { SetPreRequestHook(func(c *resty.Client, req *http.Request) error {

View File

@ -14,9 +14,9 @@ type Client struct {
client *resty.Client client *resty.Client
} }
func NewClient(apiHost, apiToken string) *Client { func NewClient(serverUrl, apiToken string) *Client {
client := resty.New(). client := resty.New().
SetBaseURL(strings.TrimRight(apiHost, "/")). SetBaseURL(strings.TrimRight(serverUrl, "/")).
SetHeader("X-SLCE-API-TOKEN", apiToken) SetHeader("X-SLCE-API-TOKEN", apiToken)
return &Client{ return &Client{

View File

@ -4,7 +4,6 @@ import {
CloseCircleOutlined as CloseCircleOutlinedIcon, CloseCircleOutlined as CloseCircleOutlinedIcon,
EllipsisOutlined as EllipsisOutlinedIcon, EllipsisOutlined as EllipsisOutlinedIcon,
FormOutlined as FormOutlinedIcon, FormOutlined as FormOutlinedIcon,
MergeOutlined as MergeOutlinedIcon,
MoreOutlined as MoreOutlinedIcon, MoreOutlined as MoreOutlinedIcon,
} from "@ant-design/icons"; } from "@ant-design/icons";
import { useControllableValue } from "ahooks"; import { useControllableValue } from "ahooks";
@ -149,12 +148,6 @@ const SharedNodeMenu = ({ menus, trigger, node, disabled, branchId, branchIndex,
setTimeout(() => nameInputRef.current?.focus(), 1); setTimeout(() => nameInputRef.current?.focus(), 1);
}, },
}, },
// {
// key: "duplicate",
// disabled: disabled || isNodeReadOnly(node),
// label: isNodeBranchLike(node) ? t("workflow_node.action.duplicate_branch") : t("workflow_node.action.duplicate_node"),
// icon: <MergeOutlinedIcon />,
// },
{ {
type: "divider", type: "divider",
}, },

View File

@ -1,11 +1,9 @@
{ {
"workflow_node.action.configure_node": "Configure node", "workflow_node.action.configure_node": "Configure node",
"workflow_node.action.add_node": "Add node", "workflow_node.action.add_node": "Add node",
"workflow_node.action.duplicate_node": "Duplicate node",
"workflow_node.action.rename_node": "Rename node", "workflow_node.action.rename_node": "Rename node",
"workflow_node.action.remove_node": "Delete node", "workflow_node.action.remove_node": "Delete node",
"workflow_node.action.add_branch": "Add branch", "workflow_node.action.add_branch": "Add branch",
"workflow_node.action.duplicate_branch": "Duplicate branch",
"workflow_node.action.rename_branch": "Rename branch", "workflow_node.action.rename_branch": "Rename branch",
"workflow_node.action.remove_branch": "Delete branch", "workflow_node.action.remove_branch": "Delete branch",

View File

@ -1,11 +1,9 @@
{ {
"workflow_node.action.configure_node": "配置节点", "workflow_node.action.configure_node": "配置节点",
"workflow_node.branch.add_node": "添加节点", "workflow_node.branch.add_node": "添加节点",
"workflow_node.action.duplicate_node": "复制节点",
"workflow_node.action.rename_node": "重命名", "workflow_node.action.rename_node": "重命名",
"workflow_node.action.remove_node": "删除节点", "workflow_node.action.remove_node": "删除节点",
"workflow_node.action.add_branch": "添加并行分支", "workflow_node.action.add_branch": "添加并行分支",
"workflow_node.action.duplicate_branch": "复制分支",
"workflow_node.action.rename_branch": "重命名", "workflow_node.action.rename_branch": "重命名",
"workflow_node.action.remove_branch": "删除分支", "workflow_node.action.remove_branch": "删除分支",