66from time import localtime
77from datetime import datetime
88from tools .software import find_hwnd , close , get_pid
9+ from random import randint
910
1011
1112class MainDown (MainBottom ):
@@ -55,6 +56,14 @@ def load_main_config(self):
5556 self .indicate ("主配置文件损坏,从备份中恢复" )
5657 self .config .update (config )
5758 # 获取设置及分类
59+ if not exists ("personal/config" ):
60+ makedirs ("personal/config" )
61+ _listdir = listdir ("personal/config" )
62+ if not _listdir :
63+ newname = "默认配置" + str (randint (999 , 10000 ))
64+ copyfile (r"assets\main_window\default_config.json" ,
65+ r"personal\config\00%s.json" % newname )
66+ _listdir = listdir ("personal/config" )
5867 for file in listdir ("personal/config" ):
5968 name , suffix = splitext (file )
6069 if suffix == ".json" :
@@ -84,8 +93,6 @@ def load_main_config(self):
8493 config_list += [self .box_config_change .itemText (i )]
8594 if _text in config_list :
8695 self .box_config_change .setCurrentText (_text )
87- # print(self.box_config_change.currentText())
88- # print(self.box_config_change.currentIndex())
8996 self .state ["text" ] = _text
9097 self .state ["index" ] = self .box_config_change .currentIndex ()
9198 else :
@@ -98,10 +105,12 @@ def load_main_config(self):
98105 if env .workdir != self .config ["work_path" ]:
99106 if not exists ("cache" ):
100107 makedirs ("cache" )
108+ if not exists ("personal/bat" ):
109+ makedirs ("personal/bat" )
101110 self .config ["work_path" ] = env .workdir
102111 vbs_dir = "%s/personal/bat" % env .workdir
103112 vbs_path = "%s/personal/bat/start-SGA.vbs" % env .workdir
104- with open ("personal /schtasks_index.json" , 'r' , encoding = 'utf-8' ) as m :
113+ with open ("assets/main_window /schtasks_index.json" , 'r' , encoding = 'utf-8' ) as m :
105114 xml_dir = load (m )
106115 xml_list = xml_dir ["part2" ]
107116 xml_list [32 ] = " <Command>" + vbs_path + "</Command>\n "
@@ -110,31 +119,36 @@ def load_main_config(self):
110119 with open ("personal/schtasks_index.json" , 'w' , encoding = 'utf-8' ) as x :
111120 dump (xml_dir , x , ensure_ascii = False , indent = 1 )
112121
113- f = open ("personal/bat /start-SGA.bat" , 'r' , encoding = 'utf-8' )
122+ f = open ("assets/main_window/bat_scr /start-SGA.bat" , 'r' , encoding = 'utf-8' )
114123 start_list = f .readlines ()
115124 f .close ()
116125 start_list [5 ] = "start /d \" %s\" SGA.exe True\n " % env .workdir
117126 f = open ("personal/bat/start-SGA.bat" , 'w' , encoding = 'utf-8' )
118127 f .writelines (start_list )
119128 f .close ()
120129
121- f = open ("personal/bat /restart.bat" , 'r' , encoding = 'utf-8' )
130+ f = open ("assets/main_window/bat_scr /restart.bat" , 'r' , encoding = 'utf-8' )
122131 start_list = f .readlines ()
123132 f .close ()
124133 start_list [2 ] = "start /d \" %s\" SGA.exe\n " % env .workdir
125134 f = open ("personal/bat/restart.bat" , 'w' , encoding = 'utf-8' )
126135 f .writelines (start_list )
127136 f .close ()
128137
129- _path = "personal/bat/maa_create.bat"
130- if exists (_path ):
131- f = open (_path , 'r' , encoding = 'ansi' )
132- bat_list = f .readlines ()
133- f .close ()
134- bat_list [1 ] = f" cd. > \" { env .workdir } /cache/maa_complete.txt\" "
135- f = open (_path , 'w' , encoding = 'ansi' )
136- f .writelines (bat_list )
137- f .close ()
138+ f = open ("assets/main_window/bat_scr/maa_create.bat" , 'r' , encoding = 'ansi' )
139+ bat_list = f .readlines ()
140+ f .close ()
141+ bat_list [1 ] = f" cd. > \" { env .workdir } /cache/maa_complete.txt\" "
142+ f = open ("personal/bat/maa_create.bat" , 'w' , encoding = 'ansi' )
143+ f .writelines (bat_list )
144+ f .close ()
145+
146+ if not exists ("personal/bat/restart.vbs" ):
147+ copyfile (r"assets/main_window/bat_scr/restart.vbs" ,
148+ "personal/bat/restart.vbs" )
149+ if not exists ("personal/bat/start-SGA.vbs" ):
150+ copyfile (r"assets/main_window/bat_scr/restart.vbs" ,
151+ "personal/bat/start-SGA.vbs" )
138152
139153 # 保存主设置
140154 def save_main_data (self ):
0 commit comments