mirror of
https://github.com/Syngnat/GoNavi.git
synced 2026-05-12 12:19:47 +08:00
- 新增 RedisMonitor 面板,展示 QPS、内存、CPU、连接数和键数量趋势图 - 引入 recharts 依赖并补齐监控图表所需前端包与锁文件 - Sidebar 新增 Redis 实例监控入口,TabManager 与 TabData 接入 redis-monitor 页签类型 - RedisCommandEditor 支持多行脚本块解析、选区执行、耗时记录与终端化结果展示 - Oracle 表预览移除自动精确 COUNT(*),避免打开大表时额外阻塞 - 无筛选整表预览接入 ALL_TABLES.NUM_ROWS 近似总数展示,并拆分近似总数与近似总页数语义
95 lines
2.5 KiB
TypeScript
95 lines
2.5 KiB
TypeScript
import type { ConnectionConfig } from '../types';
|
|
|
|
type ConnectionLike = Pick<ConnectionConfig, 'type' | 'driver'> | null | undefined;
|
|
|
|
const normalizeDataSourceToken = (raw: string): string => {
|
|
const normalized = String(raw || '').trim().toLowerCase();
|
|
switch (normalized) {
|
|
case 'doris':
|
|
return 'diros';
|
|
case 'postgresql':
|
|
return 'postgres';
|
|
case 'dm':
|
|
return 'dameng';
|
|
default:
|
|
return normalized;
|
|
}
|
|
};
|
|
|
|
export const resolveDataSourceType = (config: ConnectionLike): string => {
|
|
if (!config) return '';
|
|
const type = normalizeDataSourceToken(String(config.type || ''));
|
|
if (type === 'custom') {
|
|
const driver = normalizeDataSourceToken(String(config.driver || ''));
|
|
return driver || 'custom';
|
|
}
|
|
return type;
|
|
};
|
|
|
|
const SQL_QUERY_EXPORT_TYPES = new Set([
|
|
'mysql',
|
|
'mariadb',
|
|
'diros',
|
|
'sphinx',
|
|
'postgres',
|
|
'kingbase',
|
|
'highgo',
|
|
'vastbase',
|
|
'sqlserver',
|
|
'sqlite',
|
|
'duckdb',
|
|
'oracle',
|
|
'dameng',
|
|
'tdengine',
|
|
'clickhouse',
|
|
]);
|
|
|
|
const COPY_INSERT_TYPES = new Set([
|
|
'mysql',
|
|
'mariadb',
|
|
'diros',
|
|
'sphinx',
|
|
'postgres',
|
|
'kingbase',
|
|
'highgo',
|
|
'vastbase',
|
|
'sqlserver',
|
|
'sqlite',
|
|
'duckdb',
|
|
'oracle',
|
|
'dameng',
|
|
'tdengine',
|
|
'clickhouse',
|
|
]);
|
|
|
|
const QUERY_EDITOR_DISABLED_TYPES = new Set(['redis']);
|
|
const FORCE_READ_ONLY_QUERY_TYPES = new Set(['tdengine', 'clickhouse']);
|
|
const MANUAL_TOTAL_COUNT_TYPES = new Set(['duckdb', 'oracle']);
|
|
const APPROXIMATE_TABLE_COUNT_TYPES = new Set(['duckdb', 'oracle']);
|
|
const APPROXIMATE_TOTAL_PAGE_TYPES = new Set(['duckdb']);
|
|
|
|
export type DataSourceCapabilities = {
|
|
type: string;
|
|
supportsQueryEditor: boolean;
|
|
supportsSqlQueryExport: boolean;
|
|
supportsCopyInsert: boolean;
|
|
forceReadOnlyQueryResult: boolean;
|
|
preferManualTotalCount: boolean;
|
|
supportsApproximateTableCount: boolean;
|
|
supportsApproximateTotalPages: boolean;
|
|
};
|
|
|
|
export const getDataSourceCapabilities = (config: ConnectionLike): DataSourceCapabilities => {
|
|
const type = resolveDataSourceType(config);
|
|
return {
|
|
type,
|
|
supportsQueryEditor: !QUERY_EDITOR_DISABLED_TYPES.has(type),
|
|
supportsSqlQueryExport: SQL_QUERY_EXPORT_TYPES.has(type),
|
|
supportsCopyInsert: COPY_INSERT_TYPES.has(type),
|
|
forceReadOnlyQueryResult: FORCE_READ_ONLY_QUERY_TYPES.has(type),
|
|
preferManualTotalCount: MANUAL_TOTAL_COUNT_TYPES.has(type),
|
|
supportsApproximateTableCount: APPROXIMATE_TABLE_COUNT_TYPES.has(type),
|
|
supportsApproximateTotalPages: APPROXIMATE_TOTAL_PAGE_TYPES.has(type),
|
|
};
|
|
};
|