Skip to content

Commit 2c840c4

Browse files
author
chunqiuyiyu
committed
Fix bug of spilt menu
1 parent ed44d17 commit 2c840c4

File tree

2 files changed

+23
-13
lines changed

2 files changed

+23
-13
lines changed

app/components/Tab/TabContainer.jsx

Lines changed: 21 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import config from 'config'
1414
import pluginStore from 'components/Plugins/store'
1515
import WelcomePage from './WelcomePage'
1616
import Changelog from './Changelog'
17+
import state from './state'
1718

1819
const contextMenuItems = [
1920
{
@@ -30,15 +31,6 @@ const contextMenuItems = [
3031
command: 'tab:close_all'
3132
},
3233
{ isDivider: true },
33-
{
34-
name: i18n`tab.contextMenu.verticalSplit`,
35-
icon: '',
36-
command: 'tab:split_v'
37-
}, {
38-
name: i18n`tab.contextMenu.horizontalSplit`,
39-
icon: '',
40-
command: 'tab:split_h'
41-
}
4234
]
4335

4436
@observer
@@ -70,9 +62,27 @@ class TabContainer extends Component {
7062
})
7163
}
7264

65+
// Render split menu in correct time
66+
renderItem = (tabGroup) => {
67+
const isDisabled = tabGroup.tabs.length === 1
68+
69+
if (contextMenuItems.length === 4 || isDisabled) {
70+
return contextMenuItems.concat([{
71+
name: i18n`tab.contextMenu.verticalSplit`,
72+
icon: '',
73+
isDisabled,
74+
command: 'tab:split_v'
75+
}, {
76+
name: i18n`tab.contextMenu.horizontalSplit`,
77+
icon: '',
78+
isDisabled,
79+
command: 'tab:split_h'
80+
}])
81+
}
82+
}
83+
7384
componentWillUnmount () {
7485
if (this.dispose) {
75-
console.log(this.dispose)
7686
this.dispose()
7787
}
7888
}
@@ -83,7 +93,7 @@ class TabContainer extends Component {
8393
return (
8494
<div className={cx('tab-container', { fullscreen: fullScreenActiveContent })}>
8595
<TabBar tabGroup={tabGroup}
86-
contextMenuItems={contextMenuItems}
96+
contextMenuItems={this.renderItem(tabGroup)}
8797
closePane={closePane}
8898
handleFullScreen={this.handleFullScreen}
8999
/>

app/i18n/zh_CN/tab.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
"close": "关闭标签",
99
"closeOthers": "关闭其他标签",
1010
"closeAll": "关闭全部标签",
11-
"verticalSplit": "垂直切分",
12-
"horizontalSplit": "水平切分"
11+
"verticalSplit": "上下切分",
12+
"horizontalSplit": "左右切分"
1313
}
1414
}

0 commit comments

Comments
 (0)