|
293 | 293 | </div>
|
294 | 294 | <div class="float-right">
|
295 | 295 | <div class="btn-group btn-group-sm">
|
296 |
| - <!-- <button class="btn btn-info" @click="$emit('installFunc', 'forge', ver)"> |
297 |
| - <i class="fa fa-cloud-download"></i> |
298 |
| - Forge |
299 |
| - </button> |
300 | 296 | <button class="btn btn-info" @click="$emit('installFunc', 'fabric', ver)">
|
301 | 297 | <i class="fa fa-cloud-download"></i>
|
302 | 298 | Fabric
|
303 | 299 | </button>
|
| 300 | + <button class="btn btn-info" @click="$emit('installFunc', 'forge', ver)"> |
| 301 | + <i class="fa fa-cloud-download"></i> |
| 302 | + Forge |
| 303 | + </button> |
304 | 304 | <button class="btn btn-info" @click="$emit('installFunc', 'optifine', ver)">
|
305 | 305 | <i class="fa fa-cloud-download"></i>
|
306 | 306 | OptiFine
|
307 |
| - </button> --> |
| 307 | + </button> |
308 | 308 | <button class="btn btn-danger" @click="deleteVersion(ver)">
|
309 | 309 | <i class="fa fa-trash"></i>
|
310 | 310 | </button>
|
|
423 | 423 | <script src="./vue-i18n.global.prod.js"></script>
|
424 | 424 | <script type="module">
|
425 | 425 | // TODO: Version
|
426 |
| - const VERSION = "0.4.2"; |
| 426 | + const VERSION = "0.5.0"; |
427 | 427 | const { createApp } = Vue;
|
428 | 428 | const { createI18n } = VueI18n;
|
429 | 429 | let api = null;
|
|
457 | 457 | install: "Install Game",
|
458 | 458 | installing: "Installing {ver}...",
|
459 | 459 | downloadingResource: "Downloading resources...",
|
460 |
| - versionNotFound: "Version not found, please reinstall" |
| 460 | + versionNotFound: "Version not found, please reinstall", |
| 461 | + installFunc: "Install {type} for {ver}", |
| 462 | + installFailed: "Installation Failed" |
461 | 463 | // TODO: i18n en
|
462 | 464 | },
|
463 | 465 | zh: {
|
|
486 | 488 | install: "安装游戏",
|
487 | 489 | installing: "正在安装 {ver}...",
|
488 | 490 | downloadingResource: "正在下载资源文件...",
|
489 |
| - versionNotFound: "未找到此版本,请重新安装" |
| 491 | + versionNotFound: "未找到此版本,请重新安装", |
| 492 | + installFunc: "为 {ver} 安装 {type}", |
| 493 | + installFailed: "安装失败" |
490 | 494 | // TODO: i18n zh
|
491 | 495 | }
|
492 | 496 | }
|
|
846 | 850 | snapshot: "Snapshot",
|
847 | 851 | oldAlpha: "Old Alpha",
|
848 | 852 | oldBeta: "Old Beta",
|
849 |
| - deleteConfirm: "Are you sure to delete this version?", |
| 853 | + deleteConfirm: "Are you sure to delete this version? This will not affect saves, mods, etc.", |
850 | 854 | deleteVersion: "Delete Version",
|
851 | 855 | gameFolder: "Game",
|
852 | 856 | savesFolder: "Saves",
|
|
863 | 867 | snapshot: "快照版",
|
864 | 868 | oldAlpha: "远古 Alpha 版",
|
865 | 869 | oldBeta: "远古 Beta 版",
|
866 |
| - deleteConfirm: "确定要删除这个版本吗?", |
| 870 | + deleteConfirm: "确定要删除这个版本吗?这不会影响地图、模组等数据。", |
867 | 871 | deleteVersion: "删除版本",
|
868 | 872 | gameFolder: "游戏",
|
869 | 873 | savesFolder: "地图",
|
|
980 | 984 | });
|
981 | 985 | const res = await api.cmcl_waiting(["install", ver]);
|
982 | 986 | await this.finishLoading();
|
| 987 | + const resList = res.split("\n"); |
| 988 | + if (resList.length == 2) { |
| 989 | + const warn = resList[0]; |
| 990 | + this.showWarning(this.$t("installFailed"), warn); |
| 991 | + } |
983 | 992 | },
|
984 | 993 |
|
985 |
| - // TODO: Install xxx |
| 994 | + // TODO: InstallFunc |
| 995 | + async installFunc(type, ver) { |
986 | 996 |
|
| 997 | + await this.startLoading(this.$t("installFunc", { type, ver }), |
| 998 | + this.$t("installing", { ver: type }), (result, loading) => { |
| 999 | + |
| 1000 | + const msg = result.replace(/\u0008/g, "").replace(/\(\d+%\)/g, ""); |
| 1001 | + console.log(msg); |
| 1002 | + |
| 1003 | + |
| 1004 | + loading.log = msg; |
| 1005 | + loading.progress += 5; |
| 1006 | + |
| 1007 | + }); |
| 1008 | + |
| 1009 | + const res = await api.cmcl(["version", ver, `--${type}`], ""); |
| 1010 | + console.log(res); |
| 1011 | + const reg = /\(.+(\d+\.\d+\.\d+)\)/; |
| 1012 | + const match = reg.exec(res); |
| 1013 | + if (!match) { |
| 1014 | + this.finishLoading(); |
| 1015 | + this.showWarning(this.$t("installFailed"), res); |
| 1016 | + return; |
| 1017 | + } |
| 1018 | + |
| 1019 | + const version = match[1]; |
| 1020 | + await api.cmcl_waiting(["version", ver, `--${type}=${version}`]); |
| 1021 | + |
| 1022 | + await this.finishLoading(); |
| 1023 | + }, |
987 | 1024 |
|
988 | 1025 | async addOfflineAccount() {
|
989 | 1026 | const name = await this.requestInput(
|
|
0 commit comments