mirror of
https://github.com/Yuyi-Oak/BlueArchiveToolkit.git
synced 2026-09-18 10:04:55 +08:00
fix(api): 补齐 bat-api 控制与后端 RPC
This commit is contained in:
@@ -190,14 +190,57 @@ type taskIDParam struct {
|
||||
TaskID string `json:"task_id"`
|
||||
}
|
||||
|
||||
type TextUnitQueryParams struct {
|
||||
Offset int `json:"offset,omitempty"`
|
||||
Limit int `json:"limit,omitempty"`
|
||||
Destination string `json:"destination,omitempty"`
|
||||
PathPattern string `json:"path_pattern,omitempty"`
|
||||
ArchiveEntry string `json:"archive_entry,omitempty"`
|
||||
PathID *int64 `json:"path_id,omitempty"`
|
||||
ClassID *int `json:"class_id,omitempty"`
|
||||
FieldPath string `json:"field_path,omitempty"`
|
||||
Format string `json:"format,omitempty"`
|
||||
}
|
||||
|
||||
type UnityFSTextAssetPatchParams struct {
|
||||
BundlePath string `json:"bundle_path"`
|
||||
SerializedFilePath string `json:"serialized_file_path"`
|
||||
PathID int64 `json:"path_id"`
|
||||
ReplacementPath string `json:"replacement_path"`
|
||||
TargetPath string `json:"target_path"`
|
||||
ExpectedName *string `json:"expected_name,omitempty"`
|
||||
}
|
||||
|
||||
type UnityFSStringFieldPatchParams struct {
|
||||
BundlePath string `json:"bundle_path"`
|
||||
SerializedFilePath string `json:"serialized_file_path"`
|
||||
PathID int64 `json:"path_id"`
|
||||
FieldPath string `json:"field_path"`
|
||||
ReplacementText *string `json:"replacement_text,omitempty"`
|
||||
ReplacementPath string `json:"replacement_path,omitempty"`
|
||||
TargetPath string `json:"target_path"`
|
||||
ExpectedValue *string `json:"expected_value,omitempty"`
|
||||
}
|
||||
|
||||
type UnityFSFieldPatchParams struct {
|
||||
BundlePath string `json:"bundle_path"`
|
||||
SerializedFilePath string `json:"serialized_file_path"`
|
||||
PathID int64 `json:"path_id"`
|
||||
FieldPath string `json:"field_path"`
|
||||
Replacement json.RawMessage `json:"replacement"`
|
||||
TargetPath string `json:"target_path"`
|
||||
ExpectedValue json.RawMessage `json:"expected_value,omitempty"`
|
||||
}
|
||||
|
||||
// Ack is returned by accepted daemon control methods.
|
||||
type Ack struct {
|
||||
Command string `json:"command"`
|
||||
Status string `json:"status"`
|
||||
Message string `json:"message"`
|
||||
StateDir string `json:"state_dir"`
|
||||
SocketPath string `json:"socket_path"`
|
||||
Force *bool `json:"force,omitempty"`
|
||||
Command string `json:"command"`
|
||||
Status string `json:"status"`
|
||||
Message string `json:"message"`
|
||||
StateDir string `json:"state_dir"`
|
||||
SocketPath string `json:"socket_path"`
|
||||
ControllerPID *int `json:"controller_pid,omitempty"`
|
||||
Force *bool `json:"force,omitempty"`
|
||||
}
|
||||
|
||||
// TaskAccepted is returned when an async backend task is queued.
|
||||
@@ -324,6 +367,12 @@ func (c *Client) DaemonStop(ctx context.Context) (*Ack, error) {
|
||||
return &out, err
|
||||
}
|
||||
|
||||
func (c *Client) DaemonRestart(ctx context.Context) (*Ack, error) {
|
||||
var out Ack
|
||||
_, err := c.Call(ctx, "daemon.restart", nil, &out)
|
||||
return &out, err
|
||||
}
|
||||
|
||||
func (c *Client) DaemonReload(ctx context.Context) (*Ack, error) {
|
||||
var out Ack
|
||||
_, err := c.Call(ctx, "daemon.reload", nil, &out)
|
||||
@@ -396,6 +445,34 @@ func (c *Client) CatalogRefresh(ctx context.Context, force bool) (*TaskAccepted,
|
||||
return &out, err
|
||||
}
|
||||
|
||||
func (c *Client) ParseStatus(ctx context.Context) (json.RawMessage, error) {
|
||||
return c.rawData(ctx, "parse.status", nil)
|
||||
}
|
||||
|
||||
func (c *Client) ParseTextUnits(ctx context.Context, query TextUnitQueryParams) (json.RawMessage, error) {
|
||||
return c.rawData(ctx, "parse.text_units", query)
|
||||
}
|
||||
|
||||
func (c *Client) ParseErrors(ctx context.Context, query TextUnitQueryParams) (json.RawMessage, error) {
|
||||
return c.rawData(ctx, "parse.errors", query)
|
||||
}
|
||||
|
||||
func (c *Client) LocalizedStatus(ctx context.Context) (json.RawMessage, error) {
|
||||
return c.rawData(ctx, "localized.status", nil)
|
||||
}
|
||||
|
||||
func (c *Client) UnityFSPatchTextAsset(ctx context.Context, params UnityFSTextAssetPatchParams) (json.RawMessage, error) {
|
||||
return c.rawData(ctx, "unityfs.patch_text_asset", params)
|
||||
}
|
||||
|
||||
func (c *Client) UnityFSPatchStringField(ctx context.Context, params UnityFSStringFieldPatchParams) (json.RawMessage, error) {
|
||||
return c.rawData(ctx, "unityfs.patch_string_field", params)
|
||||
}
|
||||
|
||||
func (c *Client) UnityFSPatchField(ctx context.Context, params UnityFSFieldPatchParams) (json.RawMessage, error) {
|
||||
return c.rawData(ctx, "unityfs.patch_field", params)
|
||||
}
|
||||
|
||||
func (c *Client) TaskStatus(ctx context.Context, taskID string) (*TaskRecord, error) {
|
||||
var out TaskRecord
|
||||
_, err := c.Call(ctx, "task.status", taskIDParam{TaskID: taskID}, &out)
|
||||
|
||||
Reference in New Issue
Block a user