feat(web,plugin): P1 跨插件引用 — 前端 Phase 4
- plugins.ts: PluginFieldSchema 新增 ref_plugin/ref_fallback_label, PluginEntitySchema 新增 is_public - pluginData.ts: 新增 resolveRefLabels/getPluginEntityRegistry API - EntitySelect: 支持 refPlugin 跨插件查询,目标不可用时降级为禁用 Input - PluginCRUDPage: 表格列解析引用标签(蓝色 Tag),entity_select 表单传 refPlugin/fallbackLabel
This commit is contained in:
@@ -171,3 +171,40 @@ export async function getPluginTimeseries(
|
||||
);
|
||||
return data.data;
|
||||
}
|
||||
|
||||
// ─── 跨插件引用 API ──────────────────────────────────────────────────
|
||||
|
||||
export interface ResolveLabelsResult {
|
||||
labels: Record<string, Record<string, string | null>>;
|
||||
meta: Record<string, {
|
||||
target_plugin: string;
|
||||
target_entity: string;
|
||||
label_field: string;
|
||||
plugin_installed: boolean;
|
||||
}>;
|
||||
}
|
||||
|
||||
export async function resolveRefLabels(
|
||||
pluginId: string,
|
||||
entity: string,
|
||||
fields: Record<string, string[]>,
|
||||
): Promise<ResolveLabelsResult> {
|
||||
const { data } = await client.post<{ success: boolean; data: ResolveLabelsResult }>(
|
||||
`/plugins/${pluginId}/${entity}/resolve-labels`,
|
||||
{ fields },
|
||||
);
|
||||
return data.data;
|
||||
}
|
||||
|
||||
export interface PublicEntity {
|
||||
manifest_id: string;
|
||||
entity_name: string;
|
||||
display_name: string;
|
||||
}
|
||||
|
||||
export async function getPluginEntityRegistry(): Promise<PublicEntity[]> {
|
||||
const { data } = await client.get<{ success: boolean; data: PublicEntity[] }>(
|
||||
'/plugin-registry/entities',
|
||||
);
|
||||
return data.data;
|
||||
}
|
||||
|
||||
@@ -139,6 +139,8 @@ export interface PluginFieldSchema {
|
||||
ref_entity?: string;
|
||||
ref_label_field?: string;
|
||||
ref_search_fields?: string[];
|
||||
ref_plugin?: string;
|
||||
ref_fallback_label?: string;
|
||||
cascade_from?: string;
|
||||
cascade_filter?: string;
|
||||
validation?: PluginFieldValidation;
|
||||
@@ -159,6 +161,7 @@ export interface PluginEntitySchema {
|
||||
fields: PluginFieldSchema[];
|
||||
relations?: PluginRelationSchema[];
|
||||
data_scope?: boolean;
|
||||
is_public?: boolean;
|
||||
}
|
||||
|
||||
export interface PluginSchemaResponse {
|
||||
|
||||
Reference in New Issue
Block a user