(tabId: string)
| 96 | } |
| 97 | |
| 98 | const getContextMenuItems = (tabId: string): MenuProps['items'] => { |
| 99 | const tab = tabs.find((t) => t.id === tabId) |
| 100 | const items: MenuProps['items'] = [] |
| 101 | |
| 102 | if (tab?.preview) { |
| 103 | items.push({ |
| 104 | key: 'keep', |
| 105 | label: '保持打开', |
| 106 | onClick: ({ domEvent }) => { |
| 107 | domEvent.stopPropagation() |
| 108 | keepTab(tabId) |
| 109 | } |
| 110 | }) |
| 111 | items.push({ type: 'divider' }) |
| 112 | } |
| 113 | |
| 114 | items.push( |
| 115 | { |
| 116 | key: 'close', |
| 117 | label: '关闭', |
| 118 | extra: getShortcutLabel('tabClose'), |
| 119 | onClick: ({ domEvent }) => { |
| 120 | domEvent.stopPropagation() |
| 121 | closeTab(tabId) |
| 122 | } |
| 123 | }, |
| 124 | { |
| 125 | key: 'closeOthers', |
| 126 | label: '关闭其他', |
| 127 | onClick: ({ domEvent }) => { |
| 128 | domEvent.stopPropagation() |
| 129 | closeOtherTabs(tabId) |
| 130 | } |
| 131 | }, |
| 132 | { |
| 133 | key: 'closeRight', |
| 134 | label: '关闭右侧', |
| 135 | onClick: ({ domEvent }) => { |
| 136 | domEvent.stopPropagation() |
| 137 | closeRightTabs(tabId) |
| 138 | } |
| 139 | }, |
| 140 | { |
| 141 | key: 'closeAll', |
| 142 | label: '关闭全部', |
| 143 | onClick: ({ domEvent }) => { |
| 144 | domEvent.stopPropagation() |
| 145 | closeAllTabs() |
| 146 | } |
| 147 | }, |
| 148 | { type: 'divider' }, |
| 149 | { |
| 150 | key: 'pin', |
| 151 | label: tab?.pinned ? '取消固定' : '固定', |
| 152 | onClick: ({ domEvent }) => { |
| 153 | domEvent.stopPropagation() |
| 154 | togglePinTab(tabId) |
| 155 | } |
no test coverage detected