mirror of
https://github.com/Syngnat/GoNavi.git
synced 2026-08-11 01:03:51 +08:00
- 数据导入工作台新增数据库模式,支持 SQL 文件选择、目标库、进度、取消与重试 - 新增受连接保护约束的 ImportDatabaseSQL 接口并复用流式执行链路 - SQL 导出支持切换数据库上下文,兼顾原库备份和跨库导入 - 调整侧栏与表概览入口,备份先进入工作台确认配置再执行 - 同步 Wails 绑定、Web 运行时限制、六语文案和回归测试
50 lines
1.6 KiB
TypeScript
50 lines
1.6 KiB
TypeScript
import { t } from '../i18n';
|
|
import type { TabData } from '../types';
|
|
|
|
export const DATA_IMPORT_WORKBENCH_TAB_ID = 'data-import-workbench';
|
|
|
|
export type DataImportMode = 'table' | 'database';
|
|
|
|
export type BuildDataImportWorkbenchTabInput = {
|
|
connectionId?: string;
|
|
dbName?: string;
|
|
tableName?: string;
|
|
mode?: DataImportMode;
|
|
launchKey?: string;
|
|
title?: string;
|
|
};
|
|
|
|
const normalizeOptionalText = (value: string | undefined): string | undefined => {
|
|
const normalized = String(value || '').trim();
|
|
return normalized || undefined;
|
|
};
|
|
|
|
export const buildDataImportWorkbenchTab = (
|
|
input: BuildDataImportWorkbenchTabInput = {},
|
|
): TabData => {
|
|
const mode: DataImportMode = input.mode === 'database' ? 'database' : 'table';
|
|
const launchKey = normalizeOptionalText(input.launchKey)
|
|
|| `data-import-${Date.now()}-${Math.random().toString(36).slice(2, 8)}`;
|
|
return {
|
|
id: DATA_IMPORT_WORKBENCH_TAB_ID,
|
|
title: String(input.title || t('data_import.workbench.title')).trim()
|
|
|| t('data_import.workbench.title'),
|
|
type: 'data-import' as TabData['type'],
|
|
connectionId: normalizeOptionalText(input.connectionId) || '',
|
|
dbName: normalizeOptionalText(input.dbName),
|
|
tableName: mode === 'table' ? normalizeOptionalText(input.tableName) : undefined,
|
|
dataImportMode: mode,
|
|
dataImportLaunchKey: launchKey,
|
|
initialTab: 'target',
|
|
};
|
|
};
|
|
|
|
export const resolveDataImportWorkbenchLaunchTab = (
|
|
existingTab: TabData | undefined,
|
|
input: BuildDataImportWorkbenchTabInput = {},
|
|
): TabData => (
|
|
existingTab?.type === 'data-import' && existingTab.dataImportRunning
|
|
? existingTab
|
|
: buildDataImportWorkbenchTab(input)
|
|
);
|