59
59
import { defineComponent } from " vue" ;
60
60
import { ElMessageBox , ElNotification } from " element-plus" ;
61
61
import { ipcRenderer } from " electron" ;
62
- import { Config , Game , Saves , Save } from " ../background/saveTypes" ;
62
+ import { store } from " @/store" ;
63
+ import path from " path" ;
63
64
64
65
export default defineComponent ({
65
66
components: {},
@@ -163,11 +164,20 @@ export default defineComponent({
163
164
game_name: this .$route .params .name ,
164
165
});
165
166
},
167
+ beforeUnmount () {
168
+ ipcRenderer .removeAllListeners ();
169
+ },
166
170
methods: {
167
171
load_game (saves ) {
168
172
// 在路由切换后,把当前游戏的信息读取到data的table_data中
169
173
this .game .name = saves .name ;
170
174
this .table_data = saves .saves ;
175
+ this .game .save_path = path .join (
176
+ store .state .config .backup_path ,
177
+ this .game .name
178
+ );
179
+ this .game .game_path = store .state .config .games [this .game .name ].game_path ;
180
+ this .game .icon = saves .icon ;
171
181
},
172
182
button_handler (func ) {
173
183
// 触发按钮绑定的方法
@@ -183,25 +193,24 @@ export default defineComponent({
183
193
this .describe == " " ;
184
194
},
185
195
load_latest_save () {
186
- if (this .table_data [0 ].date ){
187
- this .apply_save (this .table_data [0 ].date )
188
- }else {
196
+ if (this .table_data [0 ].date ) {
197
+ this .apply_save (this .table_data [0 ].date );
198
+ } else {
189
199
ElNotification ({
190
200
type: " error" ,
191
201
message: " 发生了错误,可能您没有任何存档" ,
192
202
});
193
203
}
194
-
195
204
},
196
205
launch_game () {
197
- if (this .game .game_path .length < 4 ) {
206
+ if (this .game .game_path == undefined || this . game . game_path .length < 4 ) {
198
207
ElNotification ({
199
208
type: " error" ,
200
209
message: " 您并没有储存过该游戏的启动方式" ,
201
210
});
202
211
return ;
203
212
} else {
204
- ipcRenderer .send (" open_url " , this .game .game_path );
213
+ ipcRenderer .send (" open_exe " , this .game .game_path );
205
214
}
206
215
},
207
216
del_save (date ) {
0 commit comments