feat(web): 插件前端全面增强 — 搜索/筛选/排序/详情页/条件表单/timeline 视图
- pluginData API: 支持 filter/search/sort_by/sort_order 参数 - plugins API: 新增 PluginFieldSchema/PluginEntitySchema/PluginPageSchema 类型 - PluginCRUDPage: 添加搜索框、筛选栏、视图切换(表格/时间线) - PluginCRUDPage: 添加详情 Drawer(Descriptions + 嵌套 CRUD) - PluginCRUDPage: 支持 visible_when 条件表单字段动态显示/隐藏 - PluginCRUDPage: 支持 compact 模式用于 detail 页面内嵌
This commit is contained in:
@@ -16,15 +16,32 @@ interface PaginatedDataResponse {
|
||||
total_pages: number;
|
||||
}
|
||||
|
||||
export interface PluginDataListOptions {
|
||||
filter?: Record<string, string>;
|
||||
search?: string;
|
||||
sort_by?: string;
|
||||
sort_order?: 'asc' | 'desc';
|
||||
}
|
||||
|
||||
export async function listPluginData(
|
||||
pluginId: string,
|
||||
entity: string,
|
||||
page = 1,
|
||||
pageSize = 20,
|
||||
options?: PluginDataListOptions,
|
||||
) {
|
||||
const params: Record<string, string> = {
|
||||
page: String(page),
|
||||
page_size: String(pageSize),
|
||||
};
|
||||
if (options?.filter) params.filter = JSON.stringify(options.filter);
|
||||
if (options?.search) params.search = options.search;
|
||||
if (options?.sort_by) params.sort_by = options.sort_by;
|
||||
if (options?.sort_order) params.sort_order = options.sort_order;
|
||||
|
||||
const { data } = await client.get<{ success: boolean; data: PaginatedDataResponse }>(
|
||||
`/plugins/${pluginId}/${entity}`,
|
||||
{ params: { page, page_size: pageSize } },
|
||||
{ params },
|
||||
);
|
||||
return data.data;
|
||||
}
|
||||
|
||||
@@ -119,3 +119,44 @@ export async function getPluginSchema(id: string) {
|
||||
);
|
||||
return data.data;
|
||||
}
|
||||
|
||||
// ── Schema 类型定义 ──
|
||||
|
||||
export interface PluginFieldSchema {
|
||||
name: string;
|
||||
field_type: string;
|
||||
required: boolean;
|
||||
display_name?: string;
|
||||
ui_widget?: string;
|
||||
options?: { label: string; value: string }[];
|
||||
searchable?: boolean;
|
||||
filterable?: boolean;
|
||||
sortable?: boolean;
|
||||
visible_when?: string;
|
||||
unique?: boolean;
|
||||
}
|
||||
|
||||
export interface PluginEntitySchema {
|
||||
name: string;
|
||||
display_name: string;
|
||||
fields: PluginFieldSchema[];
|
||||
}
|
||||
|
||||
export interface PluginSchemaResponse {
|
||||
entities: PluginEntitySchema[];
|
||||
ui?: PluginUiSchema;
|
||||
}
|
||||
|
||||
export interface PluginUiSchema {
|
||||
pages: PluginPageSchema[];
|
||||
}
|
||||
|
||||
export type PluginPageSchema =
|
||||
| { type: 'crud'; entity: string; label: string; icon?: string; enable_search?: boolean; enable_views?: string[] }
|
||||
| { type: 'tree'; entity: string; label: string; icon?: string; id_field: string; parent_field: string; label_field: string }
|
||||
| { type: 'detail'; entity: string; label: string; sections: PluginSectionSchema[] }
|
||||
| { type: 'tabs'; label: string; icon?: string; tabs: PluginPageSchema[] };
|
||||
|
||||
export type PluginSectionSchema =
|
||||
| { type: 'fields'; label: string; fields: string[] }
|
||||
| { type: 'crud'; label: string; entity: string; filter_field?: string; enable_views?: string[] };
|
||||
|
||||
Reference in New Issue
Block a user