fix: 修复管理端前端 lint 与构建问题

- 收敛 easyflow-ui-admin 的 lint、格式和类型问题

- 修正 demo 页面与管理端前端构建失败点

- 验证 pnpm lint 与 pnpm build 均已通过
This commit is contained in:
2026-04-05 21:39:13 +08:00
parent bb72e19c84
commit 7e7c236c2a
240 changed files with 5151 additions and 4701 deletions

View File

@@ -3,9 +3,11 @@ import type {
ManagedDatasetOption,
ManagedDatasetSourceOption,
} from './datasetOptions';
import huaweiIcon from '#/assets/datacenter/huawei-icon.svg';
import mysqlIcon from '#/assets/datacenter/mysql-icon.svg';
import postgresqlIcon from '#/assets/datacenter/postgresql-icon.svg';
import {
groupManagedDatasetOptions,
loadManagedDatasetOptions,
@@ -24,15 +26,15 @@ const SOURCE_LOGO_MAP: Record<string, string> = {
};
type NodeLike = {
id: string;
data?: Record<string, any>;
id: string;
};
type UpdateNodeData = (
nodeId: string,
data:
| Record<string, any>
| ((node: Record<string, any>) => Record<string, any>),
| ((node: Record<string, any>) => Record<string, any>)
| Record<string, any>,
) => void;
type FlowInstance = {
@@ -42,10 +44,10 @@ type FlowInstance = {
type RenderContext = FlowInstance | undefined;
type RendererState = {
pickerOpen: boolean;
loadingOptions: boolean;
optionsLoaded: boolean;
options: ManagedDatasetOption[];
optionsLoaded: boolean;
pickerOpen: boolean;
sources: ManagedDatasetSourceOption[];
tableSearchText: string;
updateNodeData?: UpdateNodeData;
@@ -75,11 +77,13 @@ function getUpdateNodeData(parent: HTMLElement, flowInstance?: RenderContext) {
}
function getDatasetKey(datasetRef?: DatasetRefPayload | null) {
return datasetRef?.tableId == null ? '' : String(datasetRef.tableId);
const tableId = datasetRef?.tableId;
return tableId === null || tableId === undefined ? '' : String(tableId);
}
function getSourceKey(datasetRef?: DatasetRefPayload | null) {
return datasetRef?.sourceId == null ? '' : String(datasetRef.sourceId);
const sourceId = datasetRef?.sourceId;
return sourceId === null || sourceId === undefined ? '' : String(sourceId);
}
function createSourceOnlyDatasetRef(
@@ -95,7 +99,7 @@ function createSourceOnlyDatasetRef(
};
}
function escapeHtml(value?: string | number | null) {
function escapeHtml(value?: null | number | string) {
return String(value ?? '')
.replaceAll('&', '&amp;')
.replaceAll('<', '&lt;')
@@ -410,7 +414,7 @@ function buildSourceList(
activeKey: string,
emptyText: string,
) {
if (!options.length) {
if (options.length === 0) {
return `<div class="dataset-node-empty">${emptyText}</div>`;
}
return options
@@ -432,7 +436,7 @@ function buildTableList(
activeKey: string,
emptyText: string,
) {
if (!options.length) {
if (options.length === 0) {
return `<div class="dataset-node-empty">${emptyText}</div>`;
}
return options
@@ -465,8 +469,10 @@ function bindInteractiveElements(parent: HTMLElement) {
parent
.querySelectorAll<HTMLElement>('button, input, select, textarea')
.forEach((element) => {
element.onpointerdown = (event) => event.stopPropagation();
element.onmousedown = (event) => event.stopPropagation();
element.addEventListener('pointerdown', (event) =>
event.stopPropagation(),
);
element.addEventListener('mousedown', (event) => event.stopPropagation());
});
}
@@ -539,7 +545,7 @@ export function rerenderSearchNode(
state.pickerOpen = false;
const nextDatasetRef = createSourceOnlyDatasetRef(source);
node.data = {
...(node.data || {}),
...node.data,
datasetRef: nextDatasetRef,
sourceName: source.sourceName,
sourceType: source.sourceType,
@@ -606,7 +612,7 @@ export function rerenderSaveNode(
return;
}
node.data = {
...(node.data || {}),
...node.data,
datasetRef: option.datasetRef,
sourceName: option.sourceName,
sourceType: option.sourceType,

View File

@@ -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}`)