cmvr-visual/frontend/src/views/LoginView.vue

14 lines
2.5 KiB
Vue
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<script setup lang="ts">
import { ref } from 'vue'
import { useRoute, useRouter } from 'vue-router'
import { ElMessage } from 'element-plus'
import { ArrowRight, Lock, User } from '@element-plus/icons-vue'
import { useAuthStore } from '../stores/auth'
import { errorMessage } from '../api'
const auth=useAuthStore(),route=useRoute(),router=useRouter(),username=ref(''),password=ref(''),busy=ref(false),error=ref('')
async function login(){if(busy.value)return;if(!username.value.trim()||!password.value){error.value='请输入账号和密码';return}busy.value=true;error.value='';try{await auth.login(username.value.trim(),password.value);const target=route.query.redirect;await router.replace(typeof target==='string'&&target.startsWith('/')&&!target.startsWith('//')?target:'/create/image')}catch(caught){error.value=errorMessage(caught)}finally{busy.value=false}}
</script>
<template>
<main class="login-page"><div class="login-art"><img src="/inspiration/qwen-image.png" alt="本地 Qwen-Image 模型生成的红釉茶壶验收样例"/><div class="login-art-overlay"/><a class="login-brand" href="/"><span class="brand-glyph">V</span><strong>CMVR<span>VISUAL STUDIO</span></strong></a><div class="login-art-copy"><span class="eyebrow">FROM A SPARK TO A SCENE</span><h1>灵感有形,<br/>创作无界。</h1><p>把想法交给画面。<br/>在自己的工作空间,创造下一种可能。</p><span class="sample-label">本地模型验收样例 · Qwen-Image</span></div></div><section class="login-form-section"><div class="login-form-box"><span class="eyebrow">WELCOME TO YOUR STUDIO</span><h2>回到创作的地方。</h2><p>登录你的 CMVR Visual 工作空间</p><el-form @submit.prevent="login" label-position="top"><el-form-item label="账号"><el-input v-model="username" :prefix-icon="User" placeholder="输入你的账号" autocomplete="username" size="large" /></el-form-item><el-form-item label="密码"><el-input v-model="password" :prefix-icon="Lock" type="password" placeholder="输入密码" autocomplete="current-password" show-password size="large" @keyup.enter="login"/></el-form-item><div v-if="error" class="login-error" role="alert">{{ error }}</div><el-button type="primary" size="large" :loading="busy" class="login-submit" native-type="submit">进入工作空间<el-icon><ArrowRight /></el-icon></el-button></el-form><p class="login-help">账号由工作空间管理员创建。<br/>素材与任务仅在登录后的个人空间内展示。</p></div><footer>CMVR VISUAL · LOCAL CREATIVE WORKSPACE</footer></section></main>
</template>