windows/app/pages/register.vue

790 lines
17 KiB
Vue
Raw Normal View History

2025-09-26 09:41:29 +00:00
<template>
2025-09-27 02:41:29 +00:00
<div class="setup-screen">
<!-- macOS Style Background -->
<div class="background-image">
<div class="blur-overlay"></div>
<div class="gradient-overlay"></div>
</div>
<!-- Glass Layer -->
<div class="glass-layer"></div>
<!-- Setup Content -->
<div class="setup-content">
<!-- Setup Header -->
<div class="setup-header">
<div class="setup-icon">👤</div>
<h1 class="setup-title">{{ $t('auth.register.title') }}</h1>
<p class="setup-subtitle">{{ $t('auth.register.subtitle') }}</p>
2025-09-26 09:41:29 +00:00
</div>
2025-09-27 02:41:29 +00:00
<!-- Setup Form -->
<div class="setup-form">
<form @submit.prevent="handleRegister" class="form">
<!-- Full Name Field -->
<div class="form-field">
<input
v-model="form.fullName"
type="text"
:placeholder="$t('auth.register.fullNamePlaceholder')"
class="setup-input"
:class="{ 'error': errors.fullName }"
required
/>
2025-09-26 09:41:29 +00:00
</div>
2025-09-27 02:41:29 +00:00
<!-- Email Field -->
<div class="form-field">
<input
v-model="form.email"
type="email"
:placeholder="$t('auth.register.emailPlaceholder')"
class="setup-input"
:class="{ 'error': errors.email }"
required
/>
</div>
<!-- Password Field -->
<div class="form-field">
<input
v-model="form.password"
type="password"
:placeholder="$t('auth.register.passwordPlaceholder')"
class="setup-input"
:class="{ 'error': errors.password }"
required
/>
</div>
<!-- Confirm Password Field -->
<div class="form-field">
<input
v-model="form.confirmPassword"
type="password"
:placeholder="$t('auth.register.confirmPasswordPlaceholder')"
class="setup-input"
:class="{ 'error': errors.confirmPassword }"
required
/>
</div>
<!-- Terms and Conditions -->
<div class="terms-section">
<label class="terms-label">
<input v-model="form.agreeTerms" type="checkbox" class="terms-checkbox" required />
<span class="terms-text">
{{ $t('auth.register.agreeTerms') }}
<button type="button" class="terms-link" @click="showTerms">
{{ $t('auth.register.termsAndConditions') }}
</button>
</span>
</label>
2025-09-26 09:41:29 +00:00
</div>
2025-09-27 02:41:29 +00:00
<!-- Unified Error Messages -->
<div class="error-messages">
<div v-if="errors.fullName" class="error-message">{{ errors.fullName }}</div>
<div v-if="errors.email" class="error-message">{{ errors.email }}</div>
<div v-if="errors.password" class="error-message">{{ errors.password }}</div>
<div v-if="errors.confirmPassword" class="error-message">{{ errors.confirmPassword }}</div>
</div>
<!-- Submit Button -->
<button type="submit" class="setup-button" :disabled="isLoading">
<span v-if="isLoading" class="loading-spinner"></span>
{{ isLoading ? $t('auth.common.loading') : $t('auth.register.registerButton') }}
</button>
</form>
<!-- Sign In Link -->
<div class="setup-footer">
<p class="footer-text">
{{ $t('auth.register.hasAccount') }}
<button class="footer-link" @click="goToLogin">
{{ $t('auth.register.signIn') }}
</button>
</p>
2025-09-26 09:41:29 +00:00
</div>
</div>
</div>
2025-09-27 02:41:29 +00:00
<!-- Status Bar -->
<div class="status-bar">
<div class="status-left">
<!-- Empty for now -->
</div>
<div class="status-center">
<!-- Empty for now -->
</div>
<div class="status-right">
<!-- Language Toggle -->
<div class="language-switcher-wrapper" ref="languageSwitcherWrapper">
<button @click="toggleLanguageMenu" class="language-switcher">
{{ currentLanguageDisplay }}
</button>
<div v-if="isLanguageMenuOpen" class="language-menu">
<ul>
<li v-for="lang in availableLanguages" :key="lang.key" @click="selectLanguage(lang.key as 'en' | 'zh')">
<span class="checkmark" :style="{ visibility: locale === lang.key ? 'visible' : 'hidden' }"></span>
<span>{{ lang.label }}</span>
</li>
</ul>
</div>
</div>
</div>
2025-09-26 09:41:29 +00:00
</div>
</div>
</template>
<script setup lang="ts">
2025-09-27 02:41:29 +00:00
import { ref, reactive, computed, onMounted, onUnmounted, watch } from 'vue';
2025-09-26 09:41:29 +00:00
import { useRouter } from 'vue-router';
import { useI18n } from 'vue-i18n';
const router = useRouter();
2025-09-27 02:41:29 +00:00
const { t, locale, setLocale } = useI18n();
2025-09-26 09:41:29 +00:00
// Form data
const form = reactive({
fullName: '',
email: '',
password: '',
confirmPassword: '',
agreeTerms: false
});
// Form validation
const errors = reactive({
fullName: '',
email: '',
password: '',
confirmPassword: ''
});
// Loading state
const isLoading = ref(false);
2025-09-27 02:41:29 +00:00
// --- Language Switcher Logic ---
const isLanguageMenuOpen = ref(false);
const languageSwitcherWrapper = ref<HTMLElement | null>(null);
const availableLanguages = computed(() => [
{ key: 'en', label: 'English', display: 'EN' },
{ key: 'zh', label: '繁體中文', display: '注' },
]);
const currentLanguageDisplay = computed(() => {
const current = availableLanguages.value.find(lang => lang.key === locale.value);
return current?.display || '注';
});
2025-09-26 09:41:29 +00:00
// Validation functions
const validateEmail = (email: string) => {
const emailRegex = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
return emailRegex.test(email);
};
const validateForm = () => {
errors.fullName = '';
errors.email = '';
errors.password = '';
errors.confirmPassword = '';
if (!form.fullName) {
errors.fullName = t('auth.common.required');
return false;
}
if (!form.email) {
errors.email = t('auth.common.required');
return false;
}
if (!validateEmail(form.email)) {
errors.email = t('auth.common.invalidEmail');
return false;
}
if (!form.password) {
errors.password = t('auth.common.required');
return false;
}
if (form.password.length < 8) {
errors.password = t('auth.common.passwordTooShort');
return false;
}
if (!form.confirmPassword) {
errors.confirmPassword = t('auth.common.required');
return false;
}
if (form.password !== form.confirmPassword) {
errors.confirmPassword = t('auth.common.passwordsDoNotMatch');
return false;
}
if (!form.agreeTerms) {
alert(t('auth.common.required'));
return false;
}
return true;
};
// Event handlers
const handleRegister = async () => {
if (!validateForm()) return;
isLoading.value = true;
try {
// Simulate API call
await new Promise(resolve => setTimeout(resolve, 2000));
// Success - redirect to home
router.push('/');
} catch (error) {
console.error('Registration error:', error);
} finally {
isLoading.value = false;
}
};
const showTerms = () => {
// TODO: Implement terms and conditions modal
alert('Terms and Conditions coming soon!');
};
const goToLogin = () => {
router.push('/login');
};
const goHome = () => {
router.push('/');
};
2025-09-27 02:41:29 +00:00
// Language switcher functions
function toggleLanguageMenu() {
isLanguageMenuOpen.value = !isLanguageMenuOpen.value;
}
function selectLanguage(lang: 'en' | 'zh') {
setLocale(lang);
isLanguageMenuOpen.value = false;
}
const handleClickOutside = (event: MouseEvent) => {
if (languageSwitcherWrapper.value && !languageSwitcherWrapper.value.contains(event.target as Node)) {
isLanguageMenuOpen.value = false;
}
};
// Lifecycle
onMounted(() => {
// Add any initialization logic here
});
onUnmounted(() => {
document.removeEventListener('click', handleClickOutside);
});
// Watch for language menu state
watch(isLanguageMenuOpen, (isOpen) => {
if (isOpen) {
document.addEventListener('click', handleClickOutside);
} else {
document.removeEventListener('click', handleClickOutside);
}
});
2025-09-26 09:41:29 +00:00
</script>
<style scoped>
2025-09-27 02:41:29 +00:00
.setup-screen {
2025-09-26 09:41:29 +00:00
position: fixed;
top: 0;
left: 0;
width: 100vw;
height: 100vh;
2025-09-27 02:41:29 +00:00
font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'Helvetica Neue', Helvetica, Arial, sans-serif;
2025-09-26 09:41:29 +00:00
overflow: hidden;
2025-09-27 02:41:29 +00:00
display: flex;
flex-direction: column;
2025-09-26 09:41:29 +00:00
}
2025-09-27 02:41:29 +00:00
.background-image {
2025-09-26 09:41:29 +00:00
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
2025-09-27 02:41:29 +00:00
background: linear-gradient(135deg,
#f8fafc 0%,
#e2e8f0 25%,
#cbd5e1 50%,
#94a3b8 75%,
#64748b 100%);
background-size: 400% 400%;
animation: gradient-shift 15s ease infinite;
2025-09-26 09:41:29 +00:00
z-index: 0;
}
2025-09-27 02:41:29 +00:00
.glass-layer {
position: absolute;
top: 0;
left: 0;
2025-09-26 09:41:29 +00:00
width: 100%;
height: 100%;
2025-09-27 02:41:29 +00:00
background: rgba(255, 255, 255, 0.1);
backdrop-filter: blur(20px);
-webkit-backdrop-filter: blur(20px);
z-index: 1;
2025-09-26 09:41:29 +00:00
}
2025-09-27 02:41:29 +00:00
@keyframes gradient-shift {
0% { background-position: 0% 50%; }
50% { background-position: 100% 50%; }
100% { background-position: 0% 50%; }
2025-09-26 09:41:29 +00:00
}
2025-09-27 02:41:29 +00:00
.blur-overlay {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
backdrop-filter: blur(20px);
-webkit-backdrop-filter: blur(20px);
2025-09-26 09:41:29 +00:00
}
2025-09-27 02:41:29 +00:00
.gradient-overlay {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
background: linear-gradient(
180deg,
rgba(0, 0, 0, 0.1) 0%,
rgba(0, 0, 0, 0.3) 50%,
rgba(0, 0, 0, 0.6) 100%
);
2025-09-26 09:41:29 +00:00
}
2025-09-27 02:41:29 +00:00
.setup-content {
position: relative;
z-index: 2;
flex: 1;
2025-09-26 09:41:29 +00:00
display: flex;
2025-09-27 02:41:29 +00:00
flex-direction: column;
justify-content: center;
2025-09-26 09:41:29 +00:00
align-items: center;
2025-09-27 02:41:29 +00:00
padding: 60px 40px 40px;
color: white;
min-height: 100vh;
box-sizing: border-box;
2025-09-26 09:41:29 +00:00
}
2025-09-27 02:41:29 +00:00
.setup-header {
text-align: center;
margin-bottom: 40px;
position: relative;
width: 100%;
2025-09-26 09:41:29 +00:00
display: flex;
2025-09-27 02:41:29 +00:00
flex-direction: column;
justify-content: center;
2025-09-26 09:41:29 +00:00
align-items: center;
}
2025-09-27 02:41:29 +00:00
.setup-icon {
font-size: 4rem;
margin-bottom: 20px;
filter: drop-shadow(0 2px 8px rgba(0, 0, 0, 0.3));
2025-09-26 09:41:29 +00:00
}
2025-09-27 02:41:29 +00:00
.setup-title {
font-size: 2.5rem;
font-weight: 300;
margin-bottom: 12px;
text-shadow: 0 2px 20px rgba(0, 0, 0, 0.3);
line-height: 1.2;
2025-09-26 09:41:29 +00:00
}
2025-09-27 02:41:29 +00:00
.setup-subtitle {
font-size: 1.2rem;
font-weight: 300;
opacity: 0.9;
text-shadow: 0 1px 10px rgba(0, 0, 0, 0.3);
line-height: 1.4;
2025-09-26 09:41:29 +00:00
}
2025-09-27 02:41:29 +00:00
.setup-form {
2025-09-26 09:41:29 +00:00
display: flex;
2025-09-27 02:41:29 +00:00
flex-direction: column;
2025-09-26 09:41:29 +00:00
align-items: center;
2025-09-27 02:41:29 +00:00
gap: 20px;
position: relative;
width: 100%;
max-width: 400px;
2025-09-26 09:41:29 +00:00
justify-content: center;
}
2025-09-27 02:41:29 +00:00
.form {
display: flex;
flex-direction: column;
align-items: center;
gap: 16px;
width: 100%;
2025-09-26 09:41:29 +00:00
}
2025-09-27 02:41:29 +00:00
.form-field {
width: 100%;
position: relative;
2025-09-26 09:41:29 +00:00
}
2025-09-27 02:41:29 +00:00
.setup-input {
width: 100%;
height: 50px;
padding: 14px 24px;
background: rgba(255, 255, 255, 0.15);
backdrop-filter: blur(20px);
border: 2px solid rgba(255, 255, 255, 0.3);
border-radius: 50px;
color: white;
font-size: 1rem;
font-weight: 300;
2025-09-26 09:41:29 +00:00
text-align: center;
2025-09-27 02:41:29 +00:00
outline: none;
text-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
transition: all 0.3s ease;
box-sizing: border-box;
2025-09-26 09:41:29 +00:00
}
2025-09-27 02:41:29 +00:00
.setup-input::placeholder {
color: rgba(255, 255, 255, 0.7);
text-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
2025-09-26 09:41:29 +00:00
}
2025-09-27 02:41:29 +00:00
.setup-input:focus {
background: rgba(255, 255, 255, 0.2);
border-color: rgba(255, 255, 255, 0.5);
outline: none;
2025-09-26 09:41:29 +00:00
}
2025-09-27 02:41:29 +00:00
.setup-input.error {
border-color: #ff6b6b;
background: rgba(255, 107, 107, 0.2);
animation: shake 0.5s ease-in-out;
2025-09-26 09:41:29 +00:00
}
2025-09-27 02:41:29 +00:00
@keyframes shake {
0%, 100% { transform: translateX(0); }
25% { transform: translateX(-10px); }
75% { transform: translateX(10px); }
2025-09-26 09:41:29 +00:00
}
2025-09-27 02:41:29 +00:00
.terms-section {
2025-09-26 09:41:29 +00:00
width: 100%;
2025-09-27 02:41:29 +00:00
margin: 8px 0;
2025-09-26 09:41:29 +00:00
}
2025-09-27 02:41:29 +00:00
.terms-label {
2025-09-26 09:41:29 +00:00
display: flex;
align-items: flex-start;
cursor: pointer;
2025-09-27 02:41:29 +00:00
font-size: 0.9rem;
color: rgba(255, 255, 255, 0.8);
2025-09-26 09:41:29 +00:00
line-height: 1.4;
2025-09-27 02:41:29 +00:00
text-align: center;
justify-content: center;
2025-09-26 09:41:29 +00:00
}
2025-09-27 02:41:29 +00:00
.terms-checkbox {
2025-09-26 09:41:29 +00:00
margin-right: 8px;
margin-top: 2px;
width: 16px;
height: 16px;
flex-shrink: 0;
}
2025-09-27 02:41:29 +00:00
.terms-text {
2025-09-26 09:41:29 +00:00
display: flex;
flex-wrap: wrap;
align-items: center;
2025-09-27 02:41:29 +00:00
justify-content: center;
2025-09-26 09:41:29 +00:00
}
.terms-link {
background: none;
border: none;
2025-09-27 02:41:29 +00:00
color: rgba(255, 255, 255, 0.9);
font-size: 0.9rem;
2025-09-26 09:41:29 +00:00
cursor: pointer;
text-decoration: underline;
margin-left: 4px;
}
.terms-link:hover {
2025-09-27 02:41:29 +00:00
color: white;
}
.error-messages {
display: flex;
flex-direction: column;
align-items: center;
gap: 8px;
margin-top: 12px;
min-height: 20px;
2025-09-26 09:41:29 +00:00
}
2025-09-27 02:41:29 +00:00
.error-message {
font-size: 0.9rem;
color: #ff6b6b;
text-shadow: 0 1px 3px rgba(0, 0, 0, 0.5);
text-align: center;
white-space: nowrap;
}
.setup-button {
2025-09-26 09:41:29 +00:00
width: 100%;
2025-09-27 02:41:29 +00:00
height: 50px;
padding: 14px 24px;
background: rgba(255, 255, 255, 0.2);
backdrop-filter: blur(20px);
border: 2px solid rgba(255, 255, 255, 0.3);
border-radius: 50px;
2025-09-26 09:41:29 +00:00
color: white;
2025-09-27 02:41:29 +00:00
font-size: 1rem;
font-weight: 500;
2025-09-26 09:41:29 +00:00
cursor: pointer;
transition: all 0.3s ease;
display: flex;
align-items: center;
justify-content: center;
gap: 8px;
2025-09-27 02:41:29 +00:00
outline: none;
text-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
2025-09-26 09:41:29 +00:00
}
2025-09-27 02:41:29 +00:00
.setup-button:hover:not(:disabled) {
background: rgba(255, 255, 255, 0.3);
border-color: rgba(255, 255, 255, 0.5);
2025-09-26 09:41:29 +00:00
transform: translateY(-2px);
2025-09-27 02:41:29 +00:00
box-shadow: 0 8px 25px rgba(0, 0, 0, 0.3);
2025-09-26 09:41:29 +00:00
}
2025-09-27 02:41:29 +00:00
.setup-button:disabled {
2025-09-26 09:41:29 +00:00
opacity: 0.6;
cursor: not-allowed;
2025-09-27 02:41:29 +00:00
transform: none;
2025-09-26 09:41:29 +00:00
}
.loading-spinner {
2025-09-27 02:41:29 +00:00
width: 20px;
height: 20px;
2025-09-26 09:41:29 +00:00
border: 2px solid transparent;
2025-09-27 02:41:29 +00:00
border-top: 2px solid currentColor;
2025-09-26 09:41:29 +00:00
border-radius: 50%;
animation: spin 1s linear infinite;
}
@keyframes spin {
0% { transform: rotate(0deg); }
100% { transform: rotate(360deg); }
}
2025-09-27 02:41:29 +00:00
.setup-footer {
2025-09-26 09:41:29 +00:00
margin-top: 24px;
text-align: center;
}
2025-09-27 02:41:29 +00:00
.footer-text {
font-size: 0.9rem;
color: rgba(255, 255, 255, 0.8);
text-shadow: 0 1px 3px rgba(0, 0, 0, 0.5);
2025-09-26 09:41:29 +00:00
}
2025-09-27 02:41:29 +00:00
.footer-link {
2025-09-26 09:41:29 +00:00
background: none;
border: none;
2025-09-27 02:41:29 +00:00
color: rgba(255, 255, 255, 0.9);
font-size: 0.9rem;
2025-09-26 09:41:29 +00:00
cursor: pointer;
text-decoration: underline;
margin-left: 4px;
}
2025-09-27 02:41:29 +00:00
.footer-link:hover {
color: white;
}
.status-bar {
position: absolute;
top: 0;
left: 0;
right: 0;
height: 22px;
display: flex;
justify-content: space-between;
align-items: center;
padding: 0 20px;
background: var(--taskbar-background);
backdrop-filter: blur(20px);
-webkit-backdrop-filter: blur(20px);
color: var(--taskbar-item-text-color);
font-size: 12px;
font-weight: 500;
z-index: 2;
border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}
.status-left,
.status-center,
.status-right {
display: flex;
align-items: center;
gap: 8px;
}
.language-switcher-wrapper {
position: relative;
}
.language-switcher {
background: none;
border: none;
color: var(--taskbar-item-text-color);
font-size: 12px;
font-weight: 500;
cursor: pointer;
padding: 0 4px;
width: 24px;
height: 22px;
text-align: center;
line-height: 22px;
display: flex;
align-items: center;
justify-content: center;
}
.language-menu {
position: absolute;
top: calc(100% + 4px);
right: 0;
width: 160px;
background-color: var(--start-menu-background);
border: 1px solid var(--start-menu-border-color);
border-radius: 8px;
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
padding: 4px;
z-index: 10001;
}
.language-menu ul {
list-style: none;
padding: 0;
margin: 0;
}
.language-menu li {
display: flex;
align-items: center;
padding: 4px 8px;
border-radius: 4px;
cursor: pointer;
transition: background-color 0.15s ease-in-out;
}
.language-menu li:hover {
background-color: var(--taskbar-item-background-hover);
}
.checkmark {
width: 16px;
text-align: center;
margin-right: 4px;
2025-09-26 09:41:29 +00:00
}
/* Responsive Design */
@media (max-width: 768px) {
2025-09-27 02:41:29 +00:00
.setup-content {
padding: 60px 20px 20px;
2025-09-26 09:41:29 +00:00
}
2025-09-27 02:41:29 +00:00
.setup-title {
font-size: 2rem;
2025-09-26 09:41:29 +00:00
}
2025-09-27 02:41:29 +00:00
.setup-subtitle {
font-size: 1rem;
}
.setup-icon {
font-size: 3rem;
}
.setup-input {
height: 44px;
padding: 12px 20px;
font-size: 0.9rem;
}
.setup-button {
height: 44px;
font-size: 0.9rem;
}
.status-bar {
padding: 8px 16px;
font-size: 0.8rem;
2025-09-26 09:41:29 +00:00
}
}
2025-09-27 02:41:29 +00:00
@media (max-width: 480px) {
.setup-content {
padding: 40px 16px 16px;
}
.setup-title {
font-size: 1.8rem;
}
.setup-subtitle {
font-size: 0.9rem;
}
.setup-icon {
font-size: 2.5rem;
}
.setup-input {
height: 40px;
padding: 10px 16px;
font-size: 0.85rem;
}
.setup-button {
height: 40px;
font-size: 0.85rem;
}
.terms-label {
font-size: 0.8rem;
}
.footer-text {
font-size: 0.8rem;
}
2025-09-26 09:41:29 +00:00
}
2025-09-27 02:41:29 +00:00
/* Dark mode adjustments */
@media (prefers-color-scheme: dark) {
.background-image {
background: linear-gradient(135deg,
#1e293b 0%,
#334155 25%,
#475569 50%,
#64748b 75%,
#94a3b8 100%);
}
.glass-layer {
background: rgba(0, 0, 0, 0.1);
}
2025-09-26 09:41:29 +00:00
}
</style>