fix: 修复管理端前端 lint 与构建问题
- 收敛 easyflow-ui-admin 的 lint、格式和类型问题 - 修正 demo 页面与管理端前端构建失败点 - 验证 pnpm lint 与 pnpm build 均已通过
This commit is contained in:
@@ -1,12 +1,12 @@
|
||||
import { api } from '#/api/request';
|
||||
|
||||
export interface DatasetRefPayload {
|
||||
sourceId: number | string | null;
|
||||
catalogId?: number | string | null;
|
||||
sourceId: null | number | string;
|
||||
catalogId?: null | number | string;
|
||||
catalogName?: string;
|
||||
tableId: number | string | null;
|
||||
tableId: null | number | string;
|
||||
tableName: string;
|
||||
versionId?: number | string | null;
|
||||
versionId?: null | number | string;
|
||||
}
|
||||
|
||||
export interface ManagedDatasetFieldOption {
|
||||
@@ -57,21 +57,25 @@ function shouldSkipSourceError(error: any) {
|
||||
function dedupeManagedDatasetOptions(options: ManagedDatasetOption[]) {
|
||||
const uniqueOptions = new Map<string, ManagedDatasetOption>();
|
||||
for (const option of options || []) {
|
||||
const key = option.datasetRef?.tableId != null
|
||||
? String(option.datasetRef.tableId)
|
||||
: [
|
||||
option.datasetRef?.sourceId ?? '',
|
||||
option.datasetRef?.catalogId ?? '',
|
||||
option.tableName ?? '',
|
||||
].join(':');
|
||||
const tableId = option.datasetRef?.tableId;
|
||||
const key =
|
||||
tableId === null || tableId === undefined
|
||||
? [
|
||||
option.datasetRef?.sourceId ?? '',
|
||||
option.datasetRef?.catalogId ?? '',
|
||||
option.tableName ?? '',
|
||||
].join(':')
|
||||
: String(tableId);
|
||||
if (!uniqueOptions.has(key)) {
|
||||
uniqueOptions.set(key, option);
|
||||
}
|
||||
}
|
||||
return Array.from(uniqueOptions.values());
|
||||
return [...uniqueOptions.values()];
|
||||
}
|
||||
|
||||
export async function loadManagedDatasetOptions(): Promise<ManagedDatasetOption[]> {
|
||||
export async function loadManagedDatasetOptions(): Promise<
|
||||
ManagedDatasetOption[]
|
||||
> {
|
||||
const sourceRes = await api.get('/api/v1/datacenterSource/page', {
|
||||
params: {
|
||||
pageNumber: 1,
|
||||
@@ -89,19 +93,23 @@ export async function loadManagedDatasetOptions(): Promise<ManagedDatasetOption[
|
||||
});
|
||||
const catalogs = catalogRes.data || [];
|
||||
for (const catalog of catalogs) {
|
||||
const tableRes = await api.get('/api/v1/datacenterDataset/managedTables', {
|
||||
params: {
|
||||
sourceId: source.id,
|
||||
catalogId: catalog.id,
|
||||
const tableRes = await api.get(
|
||||
'/api/v1/datacenterDataset/managedTables',
|
||||
{
|
||||
params: {
|
||||
sourceId: source.id,
|
||||
catalogId: catalog.id,
|
||||
},
|
||||
},
|
||||
});
|
||||
);
|
||||
const tables = tableRes.data || [];
|
||||
for (const table of tables) {
|
||||
const label = `${source.sourceName} / ${catalog.catalogName} / ${table.tableName}`;
|
||||
options.push({
|
||||
label,
|
||||
value: table.id,
|
||||
keywords: `${source.sourceName} ${catalog.catalogName} ${table.tableName}`.toLowerCase(),
|
||||
keywords:
|
||||
`${source.sourceName} ${catalog.catalogName} ${table.tableName}`.toLowerCase(),
|
||||
sourceName: source.sourceName,
|
||||
sourceType: source.sourceType,
|
||||
catalogName: catalog.catalogName,
|
||||
@@ -132,7 +140,7 @@ export function groupManagedDatasetOptions(
|
||||
const grouped = new Map<number | string, ManagedDatasetSourceOption>();
|
||||
for (const option of dedupeManagedDatasetOptions(options || [])) {
|
||||
const sourceId = option.datasetRef?.sourceId;
|
||||
if (sourceId == null) {
|
||||
if (sourceId === null || sourceId === undefined) {
|
||||
continue;
|
||||
}
|
||||
if (!grouped.has(sourceId)) {
|
||||
@@ -145,9 +153,12 @@ export function groupManagedDatasetOptions(
|
||||
tables: [],
|
||||
});
|
||||
}
|
||||
grouped.get(sourceId)!.tables.push(option);
|
||||
const group = grouped.get(sourceId);
|
||||
if (group) {
|
||||
group.tables.push(option);
|
||||
}
|
||||
}
|
||||
return Array.from(grouped.values()).map((item) => ({
|
||||
return [...grouped.values()].map((item) => ({
|
||||
...item,
|
||||
keywords: `${item.sourceName} ${item.tables
|
||||
.map((table) => `${table.catalogName} ${table.tableName}`)
|
||||
|
||||
Reference in New Issue
Block a user