Files
cz-web/src/views/login/cpns/LoginForm.vue
2026-10-13 16:13:56 +08:00

156 lines
3.3 KiB
Vue

<script setup lang="ts">
import { computed } from 'vue'
interface Props {
account: string
password: string
agree: boolean
}
const props = defineProps<Props>()
const emit = defineEmits<{
'update:account': [value: string]
'update:password': [value: string]
'update:agree': [value: boolean]
submit: []
}>()
const localAccount = computed({
get: () => props.account,
set: (value: string) => emit('update:account', value),
})
const localPassword = computed({
get: () => props.password,
set: (value: string) => emit('update:password', value),
})
const localAgree = computed({
get: () => props.agree,
set: (value: boolean) => emit('update:agree', value),
})
</script>
<template>
<form class="login-form" @submit.prevent="emit('submit')">
<div class="login-form__field">
<label class="login-form__label" for="login-account">账号</label>
<input
id="login-account"
v-model="localAccount"
class="login-form__input"
type="text"
placeholder="请输入账号"
autocomplete="username"
>
</div>
<div class="login-form__field">
<label class="login-form__label" for="login-password">密码</label>
<input
id="login-password"
v-model="localPassword"
class="login-form__input"
type="password"
placeholder="请输入密码"
autocomplete="current-password"
>
</div>
<label class="login-form__agree">
<input v-model="localAgree" type="checkbox">
<span>已阅读并同意<em>《用户协议》</em>和<em>《隐私政策》</em></span>
</label>
<button class="login-form__submit" type="submit">
登录
</button>
</form>
</template>
<style lang="less" scoped>
.login-form {
.flex(column, flex-start, stretch);
gap: @spacing-lg;
width: 100%;
margin-top: @spacing-xl;
&__field {
.flex(column, flex-start, stretch);
gap: @spacing-sm;
width: 100%;
}
&__label {
font-size: @font-size-sm;
font-weight: 500;
line-height: 1.4;
color: @heading-color;
text-align: left;
}
&__input {
width: 100%;
height: 44px;
padding: 0 @spacing-base;
border: 1px solid @border-color;
border-radius: @radius-base;
background: @bg-color-light;
font-size: @font-size-base;
color: @heading-color;
outline: none;
transition: border-color 0.2s, background 0.2s;
box-sizing: border-box;
&:focus {
border-color: @primary-strong;
background: @white;
}
&::placeholder {
color: @text-color-secondary;
}
}
&__agree {
.flex(row, flex-start, center);
gap: @spacing-sm;
margin: 0;
font-size: @font-size-sm;
line-height: 1.5;
color: @text-color-secondary;
cursor: pointer;
user-select: none;
input {
flex-shrink: 0;
width: 14px;
height: 14px;
margin: 0;
accent-color: @primary-strong;
}
em {
font-style: normal;
color: @primary-strong;
}
}
&__submit {
width: 100%;
height: 44px;
margin: 0;
border: none;
border-radius: @radius-base;
background: @primary-strong;
color: @white;
font-size: @font-size-base;
font-weight: 500;
cursor: pointer;
transition: background 0.2s;
&:hover {
background: @primary-hover;
}
}
}
</style>