feat ui设计稿bug修复
This commit is contained in:
@@ -2,30 +2,45 @@
|
||||
import { onBeforeUnmount, ref } from 'vue'
|
||||
import { useRouter } from 'vue-router'
|
||||
import { ElMessage } from 'element-plus'
|
||||
import { PasswordStrength } from '@/components'
|
||||
import { PasswordStrength, SmsCodeInput } from '@/components'
|
||||
import { useUserStore } from '@/stores/modules/user'
|
||||
import { isPhone, isValidPassword } from '@/utils/validate'
|
||||
|
||||
const router = useRouter()
|
||||
const userStore = useUserStore()
|
||||
|
||||
const username = ref('')
|
||||
const phone = ref('')
|
||||
const phoneCode = ref('')
|
||||
const password = ref('')
|
||||
const confirmPassword = ref('')
|
||||
const agree = ref(false)
|
||||
|
||||
let redirectTimer: number | null = null
|
||||
|
||||
async function onGetCode(): Promise<void> {
|
||||
if (!isPhone(phone.value)) {
|
||||
ElMessage.warning('手机号格式不正确')
|
||||
return
|
||||
}
|
||||
try {
|
||||
await userStore.sendSmsCode(phone.value)
|
||||
}
|
||||
catch {
|
||||
// 失败提示已由 store 统一弹出,此处仅避免未处理的 rejection
|
||||
}
|
||||
}
|
||||
|
||||
async function onRegister(): Promise<void> {
|
||||
if (!username.value.trim()) {
|
||||
ElMessage.warning('请输入账号')
|
||||
if (!isPhone(phone.value)) {
|
||||
ElMessage.warning('手机号格式不正确')
|
||||
return
|
||||
}
|
||||
if (username.value.trim().length < 2 || username.value.trim().length > 30) {
|
||||
ElMessage.warning('账号长度应为2-30位')
|
||||
if (!/^\d{6}$/.test(phoneCode.value)) {
|
||||
ElMessage.warning('请输入6位验证码')
|
||||
return
|
||||
}
|
||||
if (password.value.length < 5 || password.value.length > 30) {
|
||||
ElMessage.warning('密码长度应为5-30位')
|
||||
if (!isValidPassword(password.value)) {
|
||||
ElMessage.warning('密码长度应为6-20位')
|
||||
return
|
||||
}
|
||||
if (password.value !== confirmPassword.value) {
|
||||
@@ -37,7 +52,7 @@ async function onRegister(): Promise<void> {
|
||||
return
|
||||
}
|
||||
const ok = await userStore.register({
|
||||
username: username.value.trim(),
|
||||
username: phone.value,
|
||||
password: password.value,
|
||||
confirmPassword: confirmPassword.value,
|
||||
})
|
||||
@@ -54,63 +69,88 @@ onBeforeUnmount(() => {
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="auth-page">
|
||||
<div class="auth-page register">
|
||||
<aside class="auth-page__brand">
|
||||
<div class="auth-page__brand-inner">
|
||||
<p class="auth-page__logo">
|
||||
虫子智造研发一体化平台
|
||||
</p>
|
||||
<p class="auth-page__slogan">
|
||||
安全 · 高效 · 可控
|
||||
</p>
|
||||
<RouterLink class="auth-page__guest" to="/">
|
||||
游客模式 →
|
||||
</RouterLink>
|
||||
</div>
|
||||
<h1 class="auth-page__logo">
|
||||
虫子智造研发<br>一体化平台
|
||||
</h1>
|
||||
<p class="auth-page__key">
|
||||
chongzizhizaoyanfayitihuaPINGTAI
|
||||
</p>
|
||||
<p class="auth-page__slogan">
|
||||
安全 · 高效 · 可控
|
||||
</p>
|
||||
</aside>
|
||||
|
||||
<RouterLink class="auth-page__guest" to="/">
|
||||
游客模式
|
||||
</RouterLink>
|
||||
|
||||
<main class="auth-page__main">
|
||||
<div class="auth-page__card">
|
||||
<h1 class="auth-page__title">
|
||||
注册账号
|
||||
</h1>
|
||||
<h2 class="auth-page__title">
|
||||
创建账号
|
||||
</h2>
|
||||
<p class="auth-page__subtitle">
|
||||
注册后即可开始使用全部功能
|
||||
</p>
|
||||
|
||||
<form class="auth-page__form" @submit.prevent="onRegister">
|
||||
<input
|
||||
v-model="username"
|
||||
class="auth-page__input"
|
||||
type="text"
|
||||
placeholder="请输入账号(2-30位)"
|
||||
maxlength="30"
|
||||
autocomplete="username"
|
||||
>
|
||||
<div class="auth-page__pwd-wrap">
|
||||
<form class="register__form" @submit.prevent="onRegister">
|
||||
<div class="register__field">
|
||||
<label class="register__label" for="reg-phone">手机号</label>
|
||||
<input
|
||||
id="reg-phone"
|
||||
v-model="phone"
|
||||
class="register__input"
|
||||
type="text"
|
||||
placeholder="请输入手机号"
|
||||
maxlength="11"
|
||||
autocomplete="tel"
|
||||
>
|
||||
</div>
|
||||
|
||||
<div class="register__field">
|
||||
<label class="register__label" for="reg-code">验证码</label>
|
||||
<SmsCodeInput id="reg-code" v-model:code="phoneCode" @get-code="onGetCode" />
|
||||
</div>
|
||||
|
||||
<div class="register__field">
|
||||
<label class="register__label" for="reg-password">设置密码</label>
|
||||
<input
|
||||
id="reg-password"
|
||||
v-model="password"
|
||||
class="auth-page__input"
|
||||
class="register__input"
|
||||
type="password"
|
||||
placeholder="设置密码(5-30位)"
|
||||
placeholder="请设置6-20位密码"
|
||||
autocomplete="new-password"
|
||||
>
|
||||
<!-- 设计稿:密码框下 15 高密码强度条 + 15 高提示行 -->
|
||||
<PasswordStrength :password="password" />
|
||||
</div>
|
||||
<input
|
||||
v-model="confirmPassword"
|
||||
class="auth-page__input"
|
||||
type="password"
|
||||
placeholder="确认密码"
|
||||
autocomplete="new-password"
|
||||
>
|
||||
<label class="auth-page__agree">
|
||||
|
||||
<div class="register__field">
|
||||
<label class="register__label" for="reg-confirm">确认密码</label>
|
||||
<input
|
||||
id="reg-confirm"
|
||||
v-model="confirmPassword"
|
||||
class="register__input"
|
||||
type="password"
|
||||
placeholder="请设置6-20位密码"
|
||||
autocomplete="new-password"
|
||||
>
|
||||
</div>
|
||||
|
||||
<label class="register__agree">
|
||||
<input v-model="agree" type="checkbox">
|
||||
<span>已阅读并同意<em>《用户协议》</em>和<em>《隐私政策》</em></span>
|
||||
</label>
|
||||
<button class="auth-page__submit" type="submit">
|
||||
注 册
|
||||
|
||||
<button class="register__submit" type="submit">
|
||||
注册
|
||||
</button>
|
||||
</form>
|
||||
|
||||
<p class="auth-page__switch">
|
||||
<p class="register__switch">
|
||||
已有账号?<RouterLink class="auth-page__link" to="/login">立即登录</RouterLink>
|
||||
</p>
|
||||
</div>
|
||||
@@ -119,112 +159,45 @@ onBeforeUnmount(() => {
|
||||
</template>
|
||||
|
||||
<style lang="less" scoped>
|
||||
.auth-page {
|
||||
position: relative;
|
||||
display: flex;
|
||||
min-height: 100vh;
|
||||
// 设计稿:右侧表单区为纯白底,无卡片描边/阴影
|
||||
background: @white;
|
||||
|
||||
&__brand {
|
||||
// 设计稿:左侧品牌渐变面板约占 786/1920 ≈ 41%
|
||||
flex: 0 0 41%;
|
||||
.flex(row, flex-start, stretch);
|
||||
background: linear-gradient(135deg, @auth-gradient-from 0%, @auth-gradient-to 100%);
|
||||
color: @white;
|
||||
}
|
||||
|
||||
&__brand-inner {
|
||||
.flex(column, space-between, flex-start);
|
||||
width: 100%;
|
||||
// 设计稿:文字列起点 x=257 ≈ 面板宽 32.7%;主标距顶 ≈ 28%、标语底边距底 ≈ 30%
|
||||
padding: 26vh 48px 30vh 32%;
|
||||
}
|
||||
|
||||
&__logo {
|
||||
font-size: 31px;
|
||||
font-weight: 700;
|
||||
letter-spacing: 2px;
|
||||
line-height: 1.45;
|
||||
// 设计稿文本框 432 设计px:定宽让 11 字在「虫子智造研发 / 一体化平台」处折行
|
||||
max-width: 200px;
|
||||
}
|
||||
|
||||
&__slogan {
|
||||
font-size: 17px;
|
||||
font-weight: 600;
|
||||
letter-spacing: 8px;
|
||||
}
|
||||
|
||||
// 设计稿:「游客模式」为右上角白底上的深色纯文本,无边框
|
||||
&__guest {
|
||||
position: absolute;
|
||||
top: 18px;
|
||||
right: 16px;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
border: none;
|
||||
border-radius: 0;
|
||||
color: @heading-color;
|
||||
font-size: 11px;
|
||||
text-decoration: none;
|
||||
transition: color 0.2s;
|
||||
|
||||
&:hover {
|
||||
background: transparent;
|
||||
color: @primary-strong;
|
||||
}
|
||||
}
|
||||
|
||||
&__main {
|
||||
flex: 1;
|
||||
.flex(row, center, center);
|
||||
padding: @spacing-xl;
|
||||
}
|
||||
|
||||
&__card {
|
||||
.flex(column, flex-start);
|
||||
// 设计稿:表单列宽 688 设计px ≈ 530px,标题/输入/按钮纵向节奏 ≈ 41px
|
||||
gap: 41px;
|
||||
width: 100%;
|
||||
max-width: 530px;
|
||||
padding: 0;
|
||||
border-radius: 0;
|
||||
background: transparent;
|
||||
box-shadow: none;
|
||||
}
|
||||
|
||||
// 设计稿:标题(34 设计px ≈ 26px)到首个输入框 ≈ 62px
|
||||
&__title {
|
||||
margin-bottom: 21px;
|
||||
font-size: 26px;
|
||||
font-weight: 700;
|
||||
color: @heading-color;
|
||||
}
|
||||
// 设计稿(注册账号):表单列起点 x999(--auth-form-x 982 + 17)、垂直顶 268
|
||||
.register {
|
||||
--auth-form-x: 982px;
|
||||
--auth-form-y: 268px;
|
||||
|
||||
&__form {
|
||||
.flex(column, flex-start);
|
||||
gap: @spacing-lg;
|
||||
width: 100%;
|
||||
.flex(column, flex-start, stretch);
|
||||
// 副标题底 342 → 首个标签 368 = 26(副标题行盒 17 + 外边距 12 → 实际需补 38)
|
||||
margin: 38px 0 0 17px;
|
||||
width: 680px;
|
||||
}
|
||||
|
||||
// 设置密码 → 密码强度条 ≈ 9px,强度条 → 提示 ≈ 9px(组件内)
|
||||
&__pwd-wrap {
|
||||
.flex(column, flex-start);
|
||||
gap: 9px;
|
||||
width: 100%;
|
||||
&__field {
|
||||
.flex(column, flex-start, stretch);
|
||||
gap: 8px;
|
||||
width: 680px;
|
||||
}
|
||||
|
||||
// 设计稿:手机号框底 430 → 验证码标签 450 = 20;验证码框底 514 → 设置密码标签 532 = 18
|
||||
&__field + &__field {
|
||||
margin-top: 18px;
|
||||
}
|
||||
|
||||
&__label {
|
||||
font-size: 13px; // 设计稿 13/500 #1F2937
|
||||
font-weight: 500;
|
||||
line-height: 17px;
|
||||
color: #1f2937;
|
||||
}
|
||||
|
||||
// 设计稿:输入框 40 设计px ≈ 32px 高、13 设计px 字号(可读下限 11px)、白底浅描边
|
||||
&__input {
|
||||
width: 100%;
|
||||
height: 32px;
|
||||
height: 39px;
|
||||
padding: 0 12px;
|
||||
border: 1px solid @border-color;
|
||||
border-radius: 6px;
|
||||
border: 1px solid #dde1e7;
|
||||
border-radius: @radius-sm;
|
||||
background: @white;
|
||||
font-size: 11px;
|
||||
color: @heading-color;
|
||||
font-size: 13px;
|
||||
color: #1f2937;
|
||||
outline: none;
|
||||
transition: border-color 0.2s;
|
||||
box-sizing: border-box;
|
||||
@@ -234,40 +207,46 @@ onBeforeUnmount(() => {
|
||||
}
|
||||
|
||||
&::placeholder {
|
||||
color: @heading-color;
|
||||
color: #1f2937;
|
||||
}
|
||||
}
|
||||
|
||||
// 设计稿:协议行 @(999,748)
|
||||
&__agree {
|
||||
.flex(row, flex-start);
|
||||
gap: @spacing-xs;
|
||||
font-size: 11px;
|
||||
color: @text-color-secondary;
|
||||
.flex(row, flex-start, center);
|
||||
gap: 8px;
|
||||
margin-top: 22px;
|
||||
font-size: 12px;
|
||||
font-weight: 400;
|
||||
line-height: 16px;
|
||||
color: #6b7280;
|
||||
cursor: pointer;
|
||||
|
||||
input {
|
||||
margin-top: 1px;
|
||||
flex-shrink: 0;
|
||||
width: 16px;
|
||||
height: 16px;
|
||||
margin: 0;
|
||||
accent-color: @primary-strong;
|
||||
}
|
||||
|
||||
// 设计稿:《用户协议》《隐私政策》为强调蓝,其余为次级灰
|
||||
em {
|
||||
font-style: normal;
|
||||
color: @primary-strong;
|
||||
}
|
||||
}
|
||||
|
||||
// 设计稿:注册按钮 44 设计px ≈ 34px 高、#024FFF 实底
|
||||
// 设计稿:注册按钮 680×46 @y782、#024FFF 实底、文字 15/500
|
||||
&__submit {
|
||||
width: 100%;
|
||||
height: 34px;
|
||||
height: 46px;
|
||||
margin-top: 18px;
|
||||
border: none;
|
||||
border-radius: 6px;
|
||||
border-radius: @radius-sm;
|
||||
background: @primary-strong;
|
||||
color: @white;
|
||||
font-size: 12px;
|
||||
font-size: 15px;
|
||||
font-weight: 500;
|
||||
letter-spacing: 2px;
|
||||
cursor: pointer;
|
||||
transition: background 0.2s;
|
||||
|
||||
@@ -276,20 +255,22 @@ onBeforeUnmount(() => {
|
||||
}
|
||||
}
|
||||
|
||||
// 设计稿:按钮 → 底部切换链接仅约 13px
|
||||
// 设计稿:按钮底 828 → 切换行 844 = 16
|
||||
&__switch {
|
||||
margin-top: -26px;
|
||||
text-align: center;
|
||||
font-size: 11px;
|
||||
color: @text-color-secondary;
|
||||
align-self: center;
|
||||
margin: 16px 0 0;
|
||||
font-size: 12px;
|
||||
font-weight: 400;
|
||||
line-height: 16px;
|
||||
color: #6b7280;
|
||||
}
|
||||
|
||||
&__link {
|
||||
color: @primary-strong;
|
||||
|
||||
&:hover {
|
||||
color: @primary-hover;
|
||||
}
|
||||
&__subtitle {
|
||||
margin: 12px 0 0;
|
||||
font-size: 13px; // 设计稿 13/400 #6B7280
|
||||
font-weight: 400;
|
||||
line-height: 17px;
|
||||
color: #6b7280;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
||||
Reference in New Issue
Block a user