From fb64e5a0725e29c3bde4fff6d073a02ee54cb746 Mon Sep 17 00:00:00 2001 From: zbx1425 Date: Wed, 6 Dec 2023 17:14:41 +0800 Subject: [PATCH] Fix carousel --- assets/js/app.js | 70 ++++++++++++++++++++--------------------- assets/js/lang/de.js | 1 + assets/js/lang/en.js | 1 + assets/js/lang/zh.js | 1 + assets/js/lang/zh_cn.js | 1 + index.html | 13 ++++---- 6 files changed, 44 insertions(+), 43 deletions(-) diff --git a/assets/js/app.js b/assets/js/app.js index 4aff560..6de278f 100644 --- a/assets/js/app.js +++ b/assets/js/app.js @@ -1,42 +1,40 @@ -var messages = {}; +'use strict' -document.addEventListener("DOMContentLoaded", function() { - let userLanguage = (navigator.language || navigator.userLanguage).toLowerCase(); - while (userLanguage && !messages[userLanguage]) { - if (userLanguage.indexOf('-') === -1) { - userLanguage = 'en'; - break; - } else { - userLanguage = userLanguage.substring(0, userLanguage.lastIndexOf('-')); - } +let userLanguage = (navigator.language || navigator.userLanguage).toLowerCase(); +while (userLanguage && !messages[userLanguage]) { + if (userLanguage.indexOf('-') === -1) { + userLanguage = 'en'; + break; + } else { + userLanguage = userLanguage.substring(0, userLanguage.lastIndexOf('-')); } +} - const i18n = VueI18n.createI18n({ - locale: userLanguage, - fallbackLocale: 'en', - messages, - }); - - const app = Vue.createApp({ - setup() { - const langs = Vue.ref(messages); - const showNavbar = Vue.ref(false); - const scrolled = Vue.ref(false); - - return { - langs, - showNavbar, - scrolled - }; - }, +const i18n = VueI18n.createI18n({ + locale: userLanguage, + fallbackLocale: 'en', + messages, +}); - mounted() { - window.addEventListener('scroll', () => { - this.scrolled = window.scrollY > 0; - }); - } - }); +const app = Vue.createApp({ + setup() { + const langs = Vue.ref(messages); + const showNavbar = Vue.ref(false); + const scrolled = Vue.ref(false); + + return { + langs, + showNavbar, + scrolled + }; + }, - app.use(i18n) - app.mount('body') + mounted() { + window.addEventListener('scroll', () => { + this.scrolled = window.scrollY > 0; + }); + } }); + +app.use(i18n); +app.mount('body'); diff --git a/assets/js/lang/de.js b/assets/js/lang/de.js index 99efc8b..fe1a9e2 100644 --- a/assets/js/lang/de.js +++ b/assets/js/lang/de.js @@ -1,3 +1,4 @@ +if (!messages) var messages = {}; messages["de"] = { "lang.name": "DE", diff --git a/assets/js/lang/en.js b/assets/js/lang/en.js index 204457a..d375437 100644 --- a/assets/js/lang/en.js +++ b/assets/js/lang/en.js @@ -1,3 +1,4 @@ +if (!messages) var messages = {}; messages["en"] = { "lang.name": "EN", diff --git a/assets/js/lang/zh.js b/assets/js/lang/zh.js index 8eb6a93..af5348c 100644 --- a/assets/js/lang/zh.js +++ b/assets/js/lang/zh.js @@ -1,3 +1,4 @@ +if (!messages) var messages = {}; messages["zh"] = { "lang.name": "繁中", diff --git a/assets/js/lang/zh_cn.js b/assets/js/lang/zh_cn.js index 8017021..54c3cf3 100644 --- a/assets/js/lang/zh_cn.js +++ b/assets/js/lang/zh_cn.js @@ -1,3 +1,4 @@ +if (!messages) var messages = {}; messages["zh-cn"] = { "lang.name": "简中", diff --git a/index.html b/index.html index 8a81b78..9466ba8 100644 --- a/index.html +++ b/index.html @@ -14,14 +14,13 @@ - - - - - - - + + + + + + Minecraft Transit Railway