fix: 全部页面 confirm() 替换为 ConfirmDialog 组件 — 9个页面统一回调模式
This commit is contained in:
1 parent
41dab3deab
commit
7f6a4bb6df
9 files changed
+153
-62
No files matched your search
@@ -4,6 +4,7 @@ import { ArrowLeft, Database, Table2, Users, Cpu, Play, RefreshCw } from 'lucide
|
||||
import { instanceDetailApi } from '@/api/instanceDetail';
|
||||
import { instanceApi } from '@/api/instance';
|
||||
import { queryApi } from '@/api/query';
|
||||
import { ConfirmDialog } from '@/components/ConfirmDialog';
|
||||
|
||||
interface InstanceInfo {
|
||||
id: number; name: string; db_type: string; host: string; port: number;
|
||||
@@ -27,6 +28,7 @@ export default function InstanceDetailPage() {
|
||||
var [sqlText, setSqlText] = useState('');
|
||||
var [queryResult, setQueryResult] = useState<any>(null);
|
||||
var [loading, setLoading] = useState(false);
|
||||
const [deleteConfirm, setDeleteConfirm] = useState<{msg: string; onConfirm: () => void} | null>(null);
|
||||
|
||||
var tabs: { key: TabKey; label: string; icon: React.ElementType }[] = [
|
||||
{ key: 'overview', label: '概览', icon: Database },
|
||||
@@ -81,12 +83,17 @@ export default function InstanceDetailPage() {
|
||||
};
|
||||
|
||||
var handleKill = function (pid: number) {
|
||||
if (!confirm('确定 Kill 进程 ' + pid + '?')) return;
|
||||
instanceDetailApi.killProcess(instanceId, pid).then(function () {
|
||||
instanceDetailApi.getProcesslist(instanceId).then(function (res: any) {
|
||||
setProcesses(res.processes || res || []);
|
||||
});
|
||||
}).catch(function () {});
|
||||
setDeleteConfirm({
|
||||
msg: '确定 Kill 进程 ' + pid + '?',
|
||||
onConfirm: () => {
|
||||
instanceDetailApi.killProcess(instanceId, pid).then(() => {
|
||||
instanceDetailApi.getProcesslist(instanceId).then((res: any) => {
|
||||
setProcesses(res.processes || res || []);
|
||||
});
|
||||
});
|
||||
}
|
||||
});
|
||||
return;
|
||||
};
|
||||
|
||||
if (!instance) return <div className="p-10 text-center text-[var(--dg-text-muted)]">加载中...</div>;
|
||||
@@ -255,6 +262,15 @@ export default function InstanceDetailPage() {
|
||||
{processes.length === 0 && <div className="text-center py-8 text-[var(--dg-text-muted)]">暂无进程</div>}
|
||||
</div>
|
||||
)}
|
||||
|
||||
<ConfirmDialog
|
||||
open={!!deleteConfirm}
|
||||
title={deleteConfirm?.msg || '确认操作'}
|
||||
variant="danger"
|
||||
confirmText="确定"
|
||||
onConfirm={() => { deleteConfirm?.onConfirm(); }}
|
||||
onCancel={() => setDeleteConfirm(null)}
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
Reference in new issue
Block a user