|
37 | 37 | :init="init"></version-list>
|
38 | 38 | <text-input v-else-if="ui === 'input'" @finish="input.resolveFunc" @close="goBack" :title="input.title"
|
39 | 39 | :desc="input.desc" :placeholder="input.placeholder"></text-input>
|
| 40 | + <install-java v-else-if="ui === 'installJava'" :show-warning="showWarning" |
| 41 | + :ui-init="uiInit"></install-java> |
40 | 42 | <div v-else-if="ui === 'main'">
|
41 | 43 | <button class="ctrl button account-menu" @click="changeUI('playerList')">
|
42 | 44 | <div style="font-size: 1.2rem; font-weight: bold;">
|
|
366 | 368 | </transition>
|
367 | 369 | </template>
|
368 | 370 |
|
| 371 | + <template id="install-java"> |
| 372 | + <ui-container> |
| 373 | + <template #title> |
| 374 | + <i class="fa fa-coffee"></i> |
| 375 | + {{ $t('javaNotFound') }} |
| 376 | + </template> |
| 377 | + <template #content> |
| 378 | + <div> |
| 379 | + {{ $t('tips') }} |
| 380 | + </div> |
| 381 | + <div class="btn-group mt-2"> |
| 382 | + <a href="https://download.oracle.com/java/22/latest/jdk-22_windows-x64_bin.exe" |
| 383 | + class="btn btn-info"> |
| 384 | + <i class="fa fa-download"></i> |
| 385 | + Windows <br> |
| 386 | + </a> |
| 387 | + <a href="https://download.oracle.com/java/22/latest/jdk-22_macos-x64_bin.dmg" |
| 388 | + class="btn btn-info"> |
| 389 | + <i class="fa fa-download"></i> |
| 390 | + macOS <br> |
| 391 | + (Intel) |
| 392 | + </a> |
| 393 | + <a href="https://download.oracle.com/java/22/latest/jdk-22_macos-aarch64_bin.dmg" |
| 394 | + class="btn btn-info"> |
| 395 | + <i class="fa fa-download"></i> |
| 396 | + macOS <br> |
| 397 | + (Apple Silicon) |
| 398 | + </a> |
| 399 | + <a href="https://download.oracle.com/java/22/latest/jdk-22_linux-x64_bin.rpm" |
| 400 | + class="btn btn-info"> |
| 401 | + <i class="fa fa-download"></i> |
| 402 | + Linux <br> |
| 403 | + (x64) |
| 404 | + </a> |
| 405 | + <a href="https://download.oracle.com/java/22/latest/jdk-22_linux-aarch64_bin.rpm" |
| 406 | + class="btn btn-info"> |
| 407 | + <i class="fa fa-download"></i> |
| 408 | + Linux <br> |
| 409 | + (ARM64) |
| 410 | + </a> |
| 411 | + </div> |
| 412 | + <button class="btn btn-success btn-block mt-2" @click="retry"> |
| 413 | + <i class="fa fa-check"></i> {{ $t('retry') }} |
| 414 | + </button> |
| 415 | + </template> |
| 416 | + </ui-container> |
| 417 | + </template> |
| 418 | + |
369 | 419 |
|
370 | 420 | <!-- TODO: Component templates -->
|
371 | 421 |
|
372 | 422 | <script src="./vue.global.prod.js"></script>
|
373 | 423 | <script src="./vue-i18n.global.prod.js"></script>
|
374 | 424 | <script type="module">
|
375 | 425 | // TODO: Version
|
376 |
| - const VERSION = "0.3.0"; |
| 426 | + const VERSION = "0.4.0"; |
377 | 427 | const { createApp } = Vue;
|
378 | 428 | const { createI18n } = VueI18n;
|
379 | 429 | let api = null;
|
|
823 | 873 | }
|
824 | 874 | };
|
825 | 875 |
|
| 876 | + const InstallJava = { |
| 877 | + components: { |
| 878 | + UiContainer |
| 879 | + }, |
| 880 | + props: { |
| 881 | + uiInit: { |
| 882 | + type: Function |
| 883 | + }, |
| 884 | + showWarning: { |
| 885 | + type: Function |
| 886 | + } |
| 887 | + }, |
| 888 | + template: "#install-java", |
| 889 | + methods: { |
| 890 | + async retry() { |
| 891 | + const res = await this.uiInit(); |
| 892 | + if (!res) { |
| 893 | + this.showWarning(this.$t("javaNotFound"), this.$t("stillFail")); |
| 894 | + } |
| 895 | + } |
| 896 | + }, |
| 897 | + i18n: { |
| 898 | + messages: { |
| 899 | + en: { |
| 900 | + javaNotFound: "Java not detected", |
| 901 | + tips: "Minecraft requires Java Runtime. Please click the button below to download Java installer for your system.", |
| 902 | + retry: "I have downloaded and installed Java", |
| 903 | + stillFail: "Java still not detected, please try again or restart SMCL" |
| 904 | + }, |
| 905 | + zh: { |
| 906 | + javaNotFound: "未检测到 Java", |
| 907 | + tips: "Minecraft 需要 Java 运行环境,请点击下方的按钮下载对应的 Java 安装包。", |
| 908 | + retry: "我已经下载并安装了 Java", |
| 909 | + stillFail: "仍然无法检测到 Java,请再次尝试,或重启 SMCL" |
| 910 | + } |
| 911 | + } |
| 912 | + } |
| 913 | + }; |
| 914 | + |
826 | 915 | // TODO: Components
|
827 | 916 | const app = createApp({
|
828 | 917 | components: {
|
|
831 | 920 | Settings,
|
832 | 921 | PlayerList,
|
833 | 922 | VersionList,
|
834 |
| - TextInput |
| 923 | + TextInput, |
| 924 | + InstallJava |
835 | 925 | },
|
836 | 926 | data() {
|
837 | 927 | // TODO: data
|
|
1018 | 1108 | this.downloadSource = config.downloadSource;
|
1019 | 1109 | this.gameDir = config.gameDir;
|
1020 | 1110 | await api.set_title(`SMCL ${VERSION} - Minecraft: ${curVer} - ${this.$t('player')}: ${playerName} - by xuanzhi33`);
|
| 1111 | + }, |
| 1112 | + async uiInit() { |
| 1113 | + try { |
| 1114 | + await api.init_cmcl(); |
| 1115 | + await this.init(); |
| 1116 | + this.ui = "main"; |
| 1117 | + return true; |
| 1118 | + } catch (e) { |
| 1119 | + this.ui = "installJava"; |
| 1120 | + return false; |
| 1121 | + } |
1021 | 1122 | }
|
1022 | 1123 | },
|
1023 | 1124 | watch: {
|
|
1036 | 1137 | },
|
1037 | 1138 | async mounted() {
|
1038 | 1139 | await this.init_api();
|
1039 |
| - await api.init_cmcl(); |
1040 |
| - await this.init(); |
1041 |
| - this.ui = "main"; |
| 1140 | + await this.uiInit(); |
1042 | 1141 | },
|
1043 | 1142 | template: "#main"
|
1044 | 1143 | });
|
|
0 commit comments