引入语言包

This commit is contained in:
2026-01-14 12:14:32 +08:00
parent e01690803d
commit 2ce76820da
9 changed files with 406 additions and 21 deletions

View File

@@ -1,5 +1,9 @@
<script setup>
import { ref } from 'vue'
import { useI18n } from '@/hooks/useI18n'
import LanguageSwitcher from '@/layouts/components/LanguageSwitcher.vue'
const { t } = useI18n()
const loginForm = ref({
username: '',
@@ -16,46 +20,51 @@ const handleLogin = () => {
console.log('登录信息:', loginForm.value)
loading.value = false
// 这里可以添加实际的登录逻辑
alert('登录成功!(模拟')
alert(t('login.loginSuccess') + '(模拟)')
}, 1000)
}
</script>
<template>
<div class="login-container">
<div class="language-switcher-wrapper">
<LanguageSwitcher />
</div>
<div class="login-card">
<div class="login-header">
<h2>用户登录</h2>
<p>欢迎回来请登录您的账户</p>
<h2>{{ t('login.title') }}</h2>
<p>{{ t('login.subtitle') }}</p>
</div>
<form @submit.prevent="handleLogin" class="login-form">
<div class="form-group">
<label for="username">用户名</label>
<input id="username" v-model="loginForm.username" type="text" placeholder="请输入用户名" required />
<label for="username">{{ t('common.username') }}</label>
<input id="username" v-model="loginForm.username" type="text"
:placeholder="t('login.usernamePlaceholder')" required />
</div>
<div class="form-group">
<label for="password">密码</label>
<input id="password" v-model="loginForm.password" type="password" placeholder="请输入密码" required />
<label for="password">{{ t('common.password') }}</label>
<input id="password" v-model="loginForm.password" type="password"
:placeholder="t('login.passwordPlaceholder')" required />
</div>
<div class="form-options">
<label class="remember-me">
<input type="checkbox" />
<span>记住我</span>
<span>{{ t('common.rememberMe') }}</span>
</label>
<a href="#" class="forgot-password">忘记密码</a>
<a href="#" class="forgot-password">{{ t('common.forgotPassword') }}</a>
</div>
<button type="submit" class="login-btn" :disabled="loading">
<span v-if="!loading">登录</span>
<span v-else>登录中...</span>
<span v-if="!loading">{{ t('login.loginButton') }}</span>
<span v-else>{{ t('common.loading') }}</span>
</button>
</form>
<div class="login-footer">
<p>还没有账户 <a href="#">立即注册</a></p>
<p>{{ t('login.noAccount') }} <a href="#">{{ t('login.registerNow') }}</a></p>
</div>
</div>
</div>
@@ -73,6 +82,13 @@ const handleLogin = () => {
overflow: hidden;
}
.language-switcher-wrapper {
position: absolute;
top: 20px;
right: 20px;
z-index: 10;
}
/* 网格背景 */
.login-container::before {
content: '';