Please add the language selection interface (although it is not yet completed)

This commit is contained in:
2025-11-25 16:49:22 +08:00
parent 630d1d2f07
commit da7f2d6475
4 changed files with 117 additions and 19 deletions

View File

@@ -7,22 +7,26 @@ import (
"github.com/OmniX-Space/MeowBox-Core/internal/service" "github.com/OmniX-Space/MeowBox-Core/internal/service"
) )
func StartInstall(config *service.Config) {
log.Println("[Info] Starting installation process.")
server := service.CreateWebService(config)
router := http.NewServeMux()
router.Handle("/", RouteInstall())
staticRouter := RouteStaticFiles()
router.Handle("/favicon.ico", staticRouter)
router.Handle("/css/", staticRouter)
router.Handle("/font-awesome/", staticRouter)
router.Handle("/js/", staticRouter)
router.Handle("/img/", staticRouter)
router.Handle("/.well-known/", RouteWebDevTools())
server.Handler = InjectWebServerHeaders(config, router)
service.ListenWebService(config, server)
}
func CheckInstall(config *service.Config) { func CheckInstall(config *service.Config) {
if GetInstallLock(config) == false { if GetInstallLock(config) == false {
log.Println("[Info] MeowBox-Core is not installed.") log.Println("[Info] MeowBox-Core is not installed.")
log.Println("[Info] Starting installation process.") StartInstall(config)
server := service.CreateWebService(config)
router := http.NewServeMux()
router.Handle("/", RouteInstall())
staticRouter := RouteStaticFiles()
router.Handle("/favicon.ico", staticRouter)
router.Handle("/css/", staticRouter)
router.Handle("/font-awesome/", staticRouter)
router.Handle("/js/", staticRouter)
router.Handle("/img/", staticRouter)
router.Handle("/.well-known/", RouteWebDevTools())
server.Handler = InjectWebServerHeaders(config, router)
service.ListenWebService(config, server)
return return
} }
log.Println("[Info] MeowBox-Core is already installed.") log.Println("[Info] MeowBox-Core is already installed.")

View File

@@ -10,18 +10,33 @@
.welcome-button { .welcome-button {
position: absolute; position: absolute;
height: 32px;
width: 32px;
bottom: 64px; bottom: 64px;
width: 150px;
backdrop-filter: blur(3px); backdrop-filter: blur(3px);
border: 0; border: 0;
border-radius: 20px; border-radius: 100%;
background-color: rgba(255, 255, 255, 0.2); background-color: rgba(255, 255, 255, 0.2);
color: white; color: white;
padding: 8px; padding: 6px;
font-size: 24px; font-size: 24px;
cursor: pointer; cursor: pointer;
} }
.welcome-button i {
position: relative;
top: -3px;
left: -5px;
}
.welcome-button:hover {
background-color: rgba(255, 255, 255, 0.3);
}
.welcome-button:active {
background-color: rgba(255, 255, 255, 0.4);
}
.welcome h1 { .welcome h1 {
font-weight: bold; font-weight: bold;
font-size: 64px; font-size: 64px;
@@ -53,6 +68,39 @@
animation: fadeInOut 3s forwards; animation: fadeInOut 3s forwards;
} }
.language-select {
position: fixed;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
width: 80%;
height: 95%;
border-radius: 20px;
background-color: #fff;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
box-shadow: 5px 5px 15px rgba(0, 0, 0, 0.2);
}
.language-select i {
position: absolute;
color: rgb(0, 102, 255);
font-size: 256px;
left: 32px;
}
.language-select-container {
position: absolute;
width: calc(100% - 416px);
height: calc(90% - 64px);
right: 32px;
bottom: 64px;
border-radius: 16px;
background-color: rgba(0, 0, 0, 0.08);
}
.container { .container {
width: 80%; width: 80%;
height: calc(100% - 100px); height: calc(100% - 100px);
@@ -60,4 +108,29 @@
backdrop-filter: blur(3px); backdrop-filter: blur(3px);
background-color: rgba(255, 255, 255, 0.2); background-color: rgba(255, 255, 255, 0.2);
margin: 50px auto; margin: 50px auto;
}
@media (max-width: 768px) {
.language-select {
width: 65%;
}
.language-select i {
font-size: 128px;
left: auto;
top: 64px;
}
.language-select-container {
width: 80%;
height: calc(100% - 288px);
right: auto;
bottom: 64px;
}
}
@media (max-width: 480px) {
.language-select {
width: 85%;
}
} }

View File

@@ -9,11 +9,17 @@
const en = { const en = {
"hello": "Hello", "hello": "Hello",
}; };
const zhCN = { const zhCN = {
"hello": "你好", "hello": "你好",
}; };
const zhTW = {
"hello": "哈囉",
};
const jp = { const jp = {
"hello": "こんにちは", "hello": "こんにちは",
}; };
const languages = [en, zhCN, jp]; const languages = [en, zhCN, zhTW, jp];

View File

@@ -6,7 +6,11 @@ function welcome() {
welcomeDiv.classList.add("welcome"); welcomeDiv.classList.add("welcome");
const welcomeButton = document.createElement("button"); const welcomeButton = document.createElement("button");
welcomeButton.classList.add("welcome-button"); welcomeButton.classList.add("welcome-button");
welcomeButton.innerHTML = 'Next <i class="fa-solid fa-circle-arrow-right"></i>'; welcomeButton.innerHTML = '<i class="fa-regular fa-circle-right"></i>';
welcomeButton.addEventListener("click", () => {
page.removeChild(welcomeDiv);
language_select();
});
welcomeDiv.appendChild(welcomeButton); welcomeDiv.appendChild(welcomeButton);
function displayNextLanguage() { function displayNextLanguage() {
if (currentIndex >= languages.length) { if (currentIndex >= languages.length) {
@@ -26,9 +30,20 @@ function welcome() {
page.appendChild(welcomeDiv); page.appendChild(welcomeDiv);
} }
function install() { function language_select() {
const languageSelectDiv = document.createElement("div");
languageSelectDiv.classList.add("language-select");
const languageIcon = document.createElement("i");
languageIcon.classList.add("fa-solid", "fa-earth-americas");
languageSelectDiv.appendChild(languageIcon);
const languageSelectContainer = document.createElement("div");
languageSelectContainer.classList.add("language-select-container");
languageSelectDiv.appendChild(languageSelectContainer);
page.appendChild(languageSelectDiv);
} }
function env_detection() { }
// Load external script // Load external script
function loadScript(scriptUrl) { function loadScript(scriptUrl) {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {