feat(extensions): add ZIP installation and unify action dialogs

This commit is contained in:
2026-09-06 00:52:59 +08:00
parent ba66b182af
commit 99a92e9eb1
29 changed files with 554 additions and 50 deletions
+3
View File
@@ -84,6 +84,9 @@ async function request<T>(path: string, options: RequestOptions = {}): Promise<T
}
export const apiClient = {
postBinary<T>(path: string, body: Blob) {
return request<T>(path, { method: 'POST', body, headers: { 'Content-Type': 'application/zip' } })
},
get<T>(path: string, options?: Omit<RequestOptions, 'method'>) {
return request<T>(path, { ...options, method: 'GET' })
},
+5 -2
View File
@@ -50,8 +50,11 @@ export async function getPlugin(pluginId: string): Promise<Plugin> {
return toPlugin(await apiClient.get<ApiPlugin>(`/api/plugins/${pluginId}`))
}
export async function installPlugin(packagePath: string): Promise<Plugin> {
return toPlugin(await apiClient.post<ApiPlugin>('/api/plugins/install', { package_path: packagePath }))
export async function installPlugin(source: string | File): Promise<Plugin> {
const installed = typeof source === 'string'
? await apiClient.post<ApiPlugin>('/api/plugins/install', { package_path: source })
: await apiClient.postBinary<ApiPlugin>('/api/plugins/install-zip', source)
return toPlugin(installed)
}
export async function enablePlugin(pluginId: string): Promise<Plugin> {
+5 -2
View File
@@ -27,8 +27,11 @@ export async function getSkill(skillId: string): Promise<Skill> {
return toSkill(await apiClient.get<ApiSkill>(`/api/skills/${skillId}`))
}
export async function installSkill(packagePath: string): Promise<Skill> {
return toSkill(await apiClient.post<ApiSkill>('/api/skills/install', { package_path: packagePath }))
export async function installSkill(source: string | File): Promise<Skill> {
const installed = typeof source === 'string'
? await apiClient.post<ApiSkill>('/api/skills/install', { package_path: source })
: await apiClient.postBinary<ApiSkill>('/api/skills/install-zip', source)
return toSkill(installed)
}
export async function enableSkill(skillId: string): Promise<Skill> {