2.4 KiB
2.4 KiB
Backend Changes (src-tauri/
)
- Create
load_plugin_data
Command:- Implement a command
load_plugin_data(app_handle: AppHandle, server_path: String) -> Result<Vec<Plugin>, String>
. - Use
get_plugin_data_path
fromscanner.rs
to find the correctplugins.json
. - Read and deserialize
plugins.json
. - Return
Ok(plugins)
or an appropriateErr(String)
. - Register the command in
lib.rs
.
- Implement a command
- Create
save_plugin_data
Command:- Implement a command
save_plugin_data(app_handle: AppHandle, plugins: Vec<Plugin>, server_path: String) -> Result<(), String>
. - Use
get_plugin_data_path
fromscanner.rs
. - Serialize the
plugins
vector to JSON. - Write the JSON to
plugins.json
, creating the directory if needed. - Return
Ok(())
or an appropriateErr(String)
. - Register the command in
lib.rs
.
- Implement a command
- Align Bulk Update Events/Logic:
- In
update_checker.rs
(check_for_plugin_updates
), rename the emitted event from"update_check_started"
to"bulk_update_start"
. - In
update_checker.rs
(check_for_plugin_updates
), remove theapp_handle.emit("update_check_completed", ())
call. The result should be handled via the command's return value.
- In
Frontend Changes (src/App.tsx
)
- Align
Plugin
Interface Nullability:- Ensure
depend
,soft_depend
, andload_before
fields consistently usestring[] | null
.
- Ensure
- Rename Command Invokes:
- Change
invoke("check_single_plugin_update", ...)
toinvoke("check_single_plugin_update_command", ...)
. - Change
invoke("set_plugin_repository_source", ...)
toinvoke("set_plugin_repository", ...)
.
- Change
- Refactor
checkForUpdates
Result Handling:- Modify the
checkForUpdates
async function toawait
theinvoke("check_plugin_updates", ...)
call. - Use a
try...catch
block or.then().catch()
to handle theResult<Vec<Plugin>, String>
. - On success (
Ok(updatedPlugins)
), callsetPlugins(updatedPlugins)
and clear errors/loading states. - On error (
Err(error)
), callsetUpdateError(error)
and clear loading states.
- Modify the
- Adjust/Remove Event Listeners:
- In
useEffect
, rename the listener for"update_check_started"
to"bulk_update_start"
. - In
useEffect
, remove the listeners for"bulk_update_complete"
and"bulk_update_error"
.
- In