1919 read_behind_scenes_settings ,
2020 write_behind_scenes_settings ,
2121)
22+ from app .common .behind_scenes .behind_scenes_utils import BehindScenesUtils
2223from app .view .settings .list_management .shared_file_watcher import (
2324 get_shared_file_watcher ,
2425)
@@ -116,6 +117,22 @@ def __init__(self, parent=None):
116117
117118 def create_class_selection (self ):
118119 """创建班级选择区域"""
120+ self .enabled_global_switch = SwitchButton ()
121+ self .enabled_global_switch .setOffText (
122+ get_content_switchbutton_name_async (
123+ "behind_scenes_settings" , "enabled_global" , "disable"
124+ )
125+ )
126+ self .enabled_global_switch .setOnText (
127+ get_content_switchbutton_name_async (
128+ "behind_scenes_settings" , "enabled_global" , "enable"
129+ )
130+ )
131+ self .enabled_global_switch .setChecked (self ._get_enabled_global_value ())
132+ self .enabled_global_switch .checkedChanged .connect (
133+ self .on_enabled_global_changed
134+ )
135+
119136 # 模式选择(点名/抽奖)
120137 self .mode_comboBox = ComboBox ()
121138 self .mode_comboBox .addItems (
@@ -144,6 +161,12 @@ def create_class_selection(self):
144161 self .pool_comboBox .setVisible (False )
145162 self .pool_comboBox .currentIndexChanged .connect (self .refresh_data )
146163
164+ self .addGroup (
165+ get_theme_icon ("ic_fluent_power_20_filled" ),
166+ get_content_name_async ("behind_scenes_settings" , "enabled_global" ),
167+ get_content_description_async ("behind_scenes_settings" , "enabled_global" ),
168+ self .enabled_global_switch ,
169+ )
147170 self .addGroup (
148171 get_theme_icon ("ic_fluent_lottery_20_filled" ),
149172 get_content_name_async ("behind_scenes_settings" , "select_mode" ),
@@ -163,6 +186,26 @@ def create_class_selection(self):
163186 self .pool_comboBox ,
164187 )
165188
189+ def _get_enabled_global_value (self ) -> bool :
190+ try :
191+ settings = read_behind_scenes_settings ()
192+ if not settings or not isinstance (settings , dict ):
193+ return True
194+ return bool (settings .get ("enabled_global" , True ))
195+ except Exception :
196+ return True
197+
198+ def on_enabled_global_changed (self ):
199+ try :
200+ settings = read_behind_scenes_settings ()
201+ if not settings or not isinstance (settings , dict ):
202+ settings = {}
203+ settings ["enabled_global" ] = bool (self .enabled_global_switch .isChecked ())
204+ write_behind_scenes_settings (settings )
205+ BehindScenesUtils .clear_cache ()
206+ except Exception as e :
207+ logger .exception (f"保存内幕总开关失败: { e } " )
208+
166209 def on_mode_changed (self ):
167210 """当模式改变时,更新名单下拉框"""
168211 mode = self .mode_comboBox .currentIndex ()
0 commit comments