Add local plugin import functionality

Implemented backend API and frontend UI for importing local plugin zip files. The backend now supports file uploads via a new /Plugin/Import endpoint using multer, and the frontend provides a button to upload and import plugins directly from the dashboard.

Prompt to register plugin manager if not loaded

Renames plugin_develop.ts to plugin-develop.ts for consistency. Updates the plugin import handler to prompt the user to register the plugin manager if it is not loaded, improving user experience and error handling.
This commit is contained in:
手瓜一十雪
2026-01-30 11:55:53 +08:00
parent 40409a3841
commit 05d27e86ce
4 changed files with 134 additions and 2 deletions

View File

@@ -96,6 +96,27 @@ export default class PluginManager {
await serverRequest.post<ServerResponse<void>>('/Plugin/Uninstall', { id, cleanData });
}
/**
* 导入本地插件包
* @param file 插件 zip 文件
*/
public static async importLocalPlugin (file: File): Promise<{ message: string; pluginId: string; installPath: string; }> {
const formData = new FormData();
formData.append('plugin', file);
const { data } = await serverRequest.post<ServerResponse<{ message: string; pluginId: string; installPath: string; }>>(
'/Plugin/Import',
formData,
{
headers: {
'Content-Type': 'multipart/form-data',
},
timeout: 60000, // 60秒超时
}
);
return data.data;
}
// ==================== 插件商店 ====================
/**