137 lines
5.7 KiB
Vue
137 lines
5.7 KiB
Vue
<template>
|
|
<!-- sub2api AuthLayout 范式:渐变背景+光斑 blur+网格纹理+品牌区+card-glass 登录卡(B 方案内联简化,无 OAuth/2FA) -->
|
|
<div class="relative flex min-h-screen items-center justify-center overflow-hidden p-4">
|
|
<div
|
|
class="absolute inset-0 bg-gradient-to-br from-gray-50 via-primary-50/30 to-gray-100 dark:from-dark-950 dark:via-dark-900 dark:to-dark-950"
|
|
></div>
|
|
|
|
<div class="pointer-events-none absolute inset-0 overflow-hidden">
|
|
<div class="absolute -right-40 -top-40 h-80 w-80 rounded-full bg-primary-400/20 blur-3xl"></div>
|
|
<div class="absolute -bottom-40 -left-40 h-80 w-80 rounded-full bg-primary-500/15 blur-3xl"></div>
|
|
<div class="absolute left-1/2 top-1/2 h-96 w-96 -translate-x-1/2 -translate-y-1/2 rounded-full bg-primary-300/10 blur-3xl"></div>
|
|
<div
|
|
class="absolute inset-0 bg-[linear-gradient(rgba(20,184,166,0.03)_1px,transparent_1px),linear-gradient(90deg,rgba(20,184,166,0.03)_1px,transparent_1px)] bg-[size:64px_64px]"
|
|
></div>
|
|
</div>
|
|
|
|
<div class="relative z-10 w-full max-w-md">
|
|
<div class="mb-8 text-center">
|
|
<div
|
|
class="mx-auto mb-4 flex h-16 w-16 items-center justify-center rounded-2xl bg-gradient-to-br from-primary-500 to-primary-600 text-white shadow-lg shadow-primary-500/30"
|
|
>
|
|
<svg class="h-8 w-8"><use href="#i-logo" /></svg>
|
|
</div>
|
|
<h1 class="text-gradient mb-2 text-3xl font-bold">go-sms</h1>
|
|
<p class="text-sm text-gray-500 dark:text-dark-400">汇网综合业务支撑平台</p>
|
|
</div>
|
|
|
|
<div class="card-glass rounded-2xl p-8 shadow-glass">
|
|
<div class="space-y-6">
|
|
<div class="text-center">
|
|
<h2 class="text-2xl font-bold text-gray-900 dark:text-white">欢迎回来</h2>
|
|
<p class="mt-2 text-sm text-gray-500 dark:text-dark-400">登录管理台</p>
|
|
</div>
|
|
|
|
<div
|
|
v-if="errorMessage"
|
|
class="flex items-start gap-2 rounded-xl border-l-4 border-red-500 bg-red-50 px-3 py-2.5 text-sm text-red-700 dark:border-red-400 dark:bg-red-950/40 dark:text-red-300"
|
|
>
|
|
<svg class="mt-0.5 h-4 w-4 flex-shrink-0"><use href="#i-warn" /></svg>
|
|
<span>{{ errorMessage }}</span>
|
|
</div>
|
|
|
|
<form class="space-y-5" @submit.prevent="handleLogin">
|
|
<div>
|
|
<label for="username" class="input-label">用户名</label>
|
|
<div class="relative">
|
|
<div class="pointer-events-none absolute inset-y-0 left-0 flex items-center pl-3.5">
|
|
<svg class="h-4 w-4 text-gray-400 dark:text-dark-500"><use href="#i-users" /></svg>
|
|
</div>
|
|
<input
|
|
id="username"
|
|
v-model="username"
|
|
type="text"
|
|
required
|
|
autofocus
|
|
autocomplete="username"
|
|
placeholder="请输入用户名"
|
|
class="input pl-11"
|
|
/>
|
|
</div>
|
|
</div>
|
|
|
|
<div>
|
|
<label for="password" class="input-label">密码</label>
|
|
<div class="relative">
|
|
<div class="pointer-events-none absolute inset-y-0 left-0 flex items-center pl-3.5">
|
|
<svg class="h-4 w-4 text-gray-400 dark:text-dark-500"><use href="#i-set" /></svg>
|
|
</div>
|
|
<input
|
|
id="password"
|
|
v-model="password"
|
|
:type="showPassword ? 'text' : 'password'"
|
|
required
|
|
autocomplete="current-password"
|
|
placeholder="请输入密码"
|
|
class="input pl-11 pr-14"
|
|
/>
|
|
<button
|
|
type="button"
|
|
class="absolute inset-y-0 right-0 flex items-center pr-3.5 text-xs text-gray-400 transition-colors hover:text-gray-600 dark:hover:text-dark-300"
|
|
@click="showPassword = !showPassword"
|
|
>
|
|
{{ showPassword ? '隐藏' : '显示' }}
|
|
</button>
|
|
</div>
|
|
</div>
|
|
|
|
<button type="submit" class="btn btn-primary w-full" :disabled="loading">
|
|
<svg v-if="loading" class="spinner -ml-1 mr-2 h-4 w-4 text-white" viewBox="0 0 24 24">
|
|
<circle class="opacity-25" cx="12" cy="12" r="10" stroke="currentColor" stroke-width="4" fill="none" />
|
|
<path class="opacity-75" fill="currentColor" d="M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z" />
|
|
</svg>
|
|
{{ loading ? '登录中…' : '登 录' }}
|
|
</button>
|
|
</form>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="mt-8 text-center text-xs text-gray-400 dark:text-dark-500">
|
|
© {{ year }} go-sms. All rights reserved.
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</template>
|
|
|
|
<script setup lang="ts">
|
|
import { ref } from 'vue'
|
|
import { useRoute, useRouter } from 'vue-router'
|
|
import { useUserStore } from '@/stores/user'
|
|
|
|
const route = useRoute()
|
|
const router = useRouter()
|
|
const user = useUserStore()
|
|
|
|
const username = ref('')
|
|
const password = ref('')
|
|
const showPassword = ref(false)
|
|
const loading = ref(false)
|
|
const errorMessage = ref('')
|
|
const year = new Date().getFullYear()
|
|
|
|
async function handleLogin() {
|
|
if (!username.value || !password.value) return
|
|
loading.value = true
|
|
errorMessage.value = ''
|
|
try {
|
|
await user.login(username.value, password.value)
|
|
const redirect = typeof route.query.redirect === 'string' ? route.query.redirect : '/home'
|
|
router.push(redirect)
|
|
} catch (e) {
|
|
errorMessage.value = e instanceof Error ? e.message : '登录失败,请稍后重试'
|
|
} finally {
|
|
loading.value = false
|
|
}
|
|
}
|
|
</script>
|