@@ -28,7 +28,7 @@ def handle_tab_switch_and_create(currentKey, latestDeletePane, origin_items, act
2828 具体策略:
2929 1.当左侧某个菜单项被新选中,且右侧标签页子项尚未包含此项时,新建并切换
3030 2.当左侧某个菜单项被新选中,且右侧标签页子项已包含此项时,切换
31- 3.当右侧标签页子项某项被删除时,销毁对应标签页的同时切换回主标签页
31+ 3.当右侧标签页子项某项被删除时,销毁对应标签页的同时切换回最后新增的标签页
3232 """
3333
3434 trigger_id = dash .ctx .triggered_id
@@ -154,18 +154,24 @@ def handle_tab_switch_and_create(currentKey, latestDeletePane, origin_items, act
154154 'icon' : 'antd-close-circle'
155155 }
156156 ]
157- if index == 1 and len (origin_items ) == 2 :
158- new_items [0 ]['contextMenu' ] = context_menu
159- elif len (origin_items ) == 3 :
160- context_menu .insert (1 , {
161- 'key' : '关闭当前' ,
162- 'label' : '关闭当前' ,
163- 'icon' : 'antd-close'
164- })
165- if index == 1 :
166- new_items [2 ]['contextMenu' ] = context_menu
167- if index == 2 :
168- new_items [1 ]['contextMenu' ] = context_menu
157+ if index == 1 :
158+ if len (origin_items ) == 2 :
159+ new_items [0 ]['contextMenu' ] = context_menu
160+ else :
161+ origin_items [2 ]['contextMenu' ].remove ({
162+ 'key' : '关闭左侧' ,
163+ 'label' : '关闭左侧' ,
164+ 'icon' : 'antd-arrow-left'
165+ })
166+ new_items [2 ]['contextMenu' ] = origin_items [2 ]['contextMenu' ]
167+ elif index == 2 :
168+ if len (origin_items ) == 3 :
169+ origin_items [1 ]['contextMenu' ].remove ({
170+ 'key' : '关闭右侧' ,
171+ 'label' : '关闭右侧' ,
172+ 'icon' : 'antd-arrow-right'
173+ })
174+ new_items [1 ]['contextMenu' ] = origin_items [1 ]['contextMenu' ]
169175 else :
170176 if index == len (origin_items ) - 1 :
171177 new_items [index - 1 ]['contextMenu' ] = item ['contextMenu' ]
@@ -227,18 +233,24 @@ def handle_via_context_menu(clickedContextMenu, origin_items, activeKey):
227233 'icon' : 'antd-close-circle'
228234 }
229235 ]
230- if index == 1 and len (origin_items ) == 2 :
231- new_items [0 ]['contextMenu' ] = context_menu
232- elif len (origin_items ) == 3 :
233- context_menu .insert (1 , {
234- 'key' : '关闭当前' ,
235- 'label' : '关闭当前' ,
236- 'icon' : 'antd-close'
237- })
238- if index == 1 :
239- new_items [2 ]['contextMenu' ] = context_menu
240- if index == 2 :
241- new_items [1 ]['contextMenu' ] = context_menu
236+ if index == 1 :
237+ if len (origin_items ) == 2 :
238+ new_items [0 ]['contextMenu' ] = context_menu
239+ else :
240+ origin_items [2 ]['contextMenu' ].remove ({
241+ 'key' : '关闭左侧' ,
242+ 'label' : '关闭左侧' ,
243+ 'icon' : 'antd-arrow-left'
244+ })
245+ new_items [2 ]['contextMenu' ] = origin_items [2 ]['contextMenu' ]
246+ elif index == 2 :
247+ if len (origin_items ) == 3 :
248+ origin_items [1 ]['contextMenu' ].remove ({
249+ 'key' : '关闭右侧' ,
250+ 'label' : '关闭右侧' ,
251+ 'icon' : 'antd-arrow-right'
252+ })
253+ new_items [1 ]['contextMenu' ] = origin_items [1 ]['contextMenu' ]
242254 else :
243255 if index == len (origin_items ) - 1 :
244256 new_items [index - 1 ]['contextMenu' ] = item ['contextMenu' ]
0 commit comments