Skip to content

Commit da6fc52

Browse files
committed
Merge branch 'dev' into master
2 parents 2488af9 + 1adb39c commit da6fc52

File tree

6 files changed

+36
-18
lines changed

6 files changed

+36
-18
lines changed

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"url": "https://github.com/mcthesw"
66
},
77
"description": "一个简单的游戏存档管理工具",
8-
"version": "0.1.0",
8+
"version": "0.1.1",
99
"private": true,
1010
"scripts": {
1111
"serve": "vue-cli-service serve",

src/background/config.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ function init_config() {
55
// 初始化配置文件
66
console.log("初始化配置文件");
77
let default_config: Config = {
8-
version: "0.0.1",
8+
version: "0.1.1",
99
backup_path: "./save_data",
1010
games: {},
1111
};

src/background/ipcHandler.ts

+6
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import {
99
delete_game,
1010
} from "./saveManager";
1111
import { Config, Game, Saves, Save } from "./saveTypes";
12+
import { exec } from 'child_process';
1213

1314
export function init_ipc() {
1415
ipcMain.on("open_url", async (Event, arg) => {
@@ -106,4 +107,9 @@ export function init_ipc() {
106107
let saves = get_game_saves_info(arg.game_name)
107108
Event.reply("reply_get_game_backup", saves)
108109
})
110+
111+
ipcMain.on("open_exe",(Event,arg)=>{
112+
console.log("启动游戏", arg)
113+
exec(arg);
114+
})
109115
}

src/background/saveManager.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ export function create_game_backup(
129129
save_path: save_path,
130130
};
131131
if (game_path) {
132-
game.game_path = game_name;
132+
game.game_path = game_path;
133133
}
134134

135135
let config = get_config();

src/components/AddGame/MainContent.vue

+11-8
Original file line numberDiff line numberDiff line change
@@ -162,20 +162,20 @@ export default defineComponent({
162162
import() {
163163
// TODO:导入已有配置
164164
ElNotification({
165-
type:"warning",
166-
message:"--WIP-- 这个功能尚未完成"
167-
})
165+
type: "warning",
166+
message: "--WIP-- 这个功能尚未完成",
167+
});
168168
},
169-
change(){
169+
change() {
170170
// TODO:改变已有配置
171171
ElNotification({
172-
type:"warning",
173-
message:"--WIP-- 这个功能尚未完成"
174-
})
172+
type: "warning",
173+
message: "--WIP-- 这个功能尚未完成",
174+
});
175175
},
176176
save() {
177177
// 保存当前配置
178-
console.log("保存当前编辑的配置")
178+
console.log("保存当前编辑的配置");
179179
ipcRenderer.send("add_game", {
180180
game_name: this.game_name,
181181
save_path: this.save_path,
@@ -198,6 +198,9 @@ export default defineComponent({
198198
});
199199
},
200200
},
201+
beforeUnmount() {
202+
ipcRenderer.removeAllListeners();
203+
},
201204
});
202205
</script>
203206

src/views/GameManage.vue

+16-7
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,8 @@
5959
import { defineComponent } from "vue";
6060
import { ElMessageBox, ElNotification } from "element-plus";
6161
import { ipcRenderer } from "electron";
62-
import { Config, Game, Saves, Save } from "../background/saveTypes";
62+
import { store } from "@/store";
63+
import path from "path";
6364
6465
export default defineComponent({
6566
components: {},
@@ -163,11 +164,20 @@ export default defineComponent({
163164
game_name: this.$route.params.name,
164165
});
165166
},
167+
beforeUnmount() {
168+
ipcRenderer.removeAllListeners();
169+
},
166170
methods: {
167171
load_game(saves) {
168172
// 在路由切换后,把当前游戏的信息读取到data的table_data中
169173
this.game.name = saves.name;
170174
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;
171181
},
172182
button_handler(func) {
173183
// 触发按钮绑定的方法
@@ -183,25 +193,24 @@ export default defineComponent({
183193
this.describe == "";
184194
},
185195
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 {
189199
ElNotification({
190200
type: "error",
191201
message: "发生了错误,可能您没有任何存档",
192202
});
193203
}
194-
195204
},
196205
launch_game() {
197-
if (this.game.game_path.length < 4) {
206+
if (this.game.game_path == undefined || this.game.game_path.length < 4) {
198207
ElNotification({
199208
type: "error",
200209
message: "您并没有储存过该游戏的启动方式",
201210
});
202211
return;
203212
} else {
204-
ipcRenderer.send("open_url", this.game.game_path);
213+
ipcRenderer.send("open_exe", this.game.game_path);
205214
}
206215
},
207216
del_save(date) {

0 commit comments

Comments
 (0)