mirror of
https://github.com/Syngnat/GoNavi.git
synced 2026-05-22 08:50:17 +08:00
🐛 fix(table-menu): 补齐表相关右键快捷操作
- 表分组右键菜单新增新建表入口 - 表概览卡片和列表右键菜单新增复制表名 - 对齐左侧树与表视图的右键菜单体验
This commit is contained in:
@@ -3829,6 +3829,13 @@ const Sidebar: React.FC<{ onEditConnection?: (conn: SavedConnection) => void }>
|
||||
const currentSort = tableSortPreference[sortPreferenceKey] || 'name';
|
||||
|
||||
return [
|
||||
{
|
||||
key: 'new-table',
|
||||
label: '新建表',
|
||||
icon: <TableOutlined />,
|
||||
onClick: () => openNewTableDesign(node)
|
||||
},
|
||||
{ type: 'divider' },
|
||||
{
|
||||
key: 'sort-by-name',
|
||||
label: '按名称排序',
|
||||
|
||||
@@ -292,6 +292,20 @@ const TableOverview: React.FC<TableOverviewProps> = ({ tab }) => {
|
||||
}
|
||||
}, [buildConfig, tab.dbName]);
|
||||
|
||||
const handleCopyTableName = useCallback(async (tableName: string) => {
|
||||
const name = String(tableName || '').trim();
|
||||
if (!name) {
|
||||
message.warning('表名为空,无法复制');
|
||||
return;
|
||||
}
|
||||
try {
|
||||
await navigator.clipboard.writeText(name);
|
||||
message.success('表名已复制到剪贴板');
|
||||
} catch (e: any) {
|
||||
message.error('复制表名失败: ' + (e?.message || String(e)));
|
||||
}
|
||||
}, []);
|
||||
|
||||
const handleExport = useCallback(async (tableName: string, format: string) => {
|
||||
const config = buildConfig();
|
||||
if (!config) return;
|
||||
@@ -538,6 +552,7 @@ const TableOverview: React.FC<TableOverviewProps> = ({ tab }) => {
|
||||
}},
|
||||
{ type: 'divider' },
|
||||
{ key: 'design-table', label: '设计表', icon: <EditOutlined />, onClick: () => openDesign(t.name) },
|
||||
{ key: 'copy-table-name', label: '复制表名', icon: <CopyOutlined />, onClick: () => handleCopyTableName(t.name) },
|
||||
{ key: 'copy-structure', label: '复制表结构', icon: <CopyOutlined />, onClick: () => handleCopyStructure(t.name) },
|
||||
{ key: 'backup-table', label: '备份表 (SQL)', icon: <SaveOutlined />, onClick: () => handleExport(t.name, 'sql') },
|
||||
{ key: 'rename-table', label: '重命名表', icon: <EditOutlined />, onClick: () => handleRenameTable(t.name) },
|
||||
@@ -624,6 +639,7 @@ const TableOverview: React.FC<TableOverviewProps> = ({ tab }) => {
|
||||
}},
|
||||
{ type: 'divider' },
|
||||
{ key: 'design-table', label: '设计表', icon: <EditOutlined />, onClick: () => openDesign(t.name) },
|
||||
{ key: 'copy-table-name', label: '复制表名', icon: <CopyOutlined />, onClick: () => handleCopyTableName(t.name) },
|
||||
{ key: 'copy-structure', label: '复制表结构', icon: <CopyOutlined />, onClick: () => handleCopyStructure(t.name) },
|
||||
{ key: 'backup-table', label: '备份表 (SQL)', icon: <SaveOutlined />, onClick: () => handleExport(t.name, 'sql') },
|
||||
{ key: 'rename-table', label: '重命名表', icon: <EditOutlined />, onClick: () => handleRenameTable(t.name) },
|
||||
|
||||
Reference in New Issue
Block a user