MCPcopy Create free account
hub / github.com/experdot/pointer / useConfirmDialog

Function useConfirmDialog

src/renderer/src/components/common/ConfirmDialog.tsx:15–55  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

13
14// Hook 方式使用确认对话框
15export function useConfirmDialog(): {
16 showConfirmDialog: (options: ConfirmDialogOptions) => void
17 showDeleteConfirm: (options: {
18 title?: string
19 content?: React.ReactNode
20 onOk: () => void | Promise<void>
21 }) => void
22} {
23 const { modal } = App.useApp()
24
25 const showConfirmDialog = (options: ConfirmDialogOptions): void => {
26 const { title, content, okText = '确定', cancelText = '取消', danger, onOk, onCancel } = options
27
28 modal.confirm({
29 title,
30 content,
31 icon: <ExclamationCircleOutlined />,
32 okText,
33 cancelText,
34 okButtonProps: danger ? { danger: true } : undefined,
35 onOk,
36 onCancel
37 })
38 }
39
40 const showDeleteConfirm = (options: {
41 title?: string
42 content?: React.ReactNode
43 onOk: () => void | Promise<void>
44 }): void => {
45 showConfirmDialog({
46 title: options.title || '确认删除',
47 content: options.content || '此操作不可撤销,确定要删除吗?',
48 okText: '删除',
49 danger: true,
50 onOk: options.onOk
51 })
52 }
53
54 return { showConfirmDialog, showDeleteConfirm }
55}

Callers 4

ExplorerFunction · 0.90
ConfigTreeFunction · 0.90
TreeViewFunction · 0.90
MessageContent.tsxFile · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected