Files
EasyFlow/easyflow-ui-admin/packages/effects/common-ui/src/ui/authentication/register.vue
陈子默 7e7c236c2a fix: 修复管理端前端 lint 与构建问题
- 收敛 easyflow-ui-admin 的 lint、格式和类型问题

- 修正 demo 页面与管理端前端构建失败点

- 验证 pnpm lint 与 pnpm build 均已通过
2026-04-05 21:39:13 +08:00

141 lines
2.9 KiB
Vue

<script setup lang="ts">
import type { Recordable } from '@easyflow/types';
import type { EasyFlowFormSchema } from '@easyflow-core/form-ui';
import { computed, reactive } from 'vue';
import { useRouter } from 'vue-router';
import { $t } from '@easyflow/locales';
import { useEasyFlowForm } from '@easyflow-core/form-ui';
import { EasyFlowButton } from '@easyflow-core/shadcn-ui';
import Title from './auth-title.vue';
interface Props {
formSchema?: EasyFlowFormSchema[];
/**
* @zh_CN 是否处于加载处理状态
*/
loading?: boolean;
/**
* @zh_CN 登录路径
*/
loginPath?: string;
/**
* @zh_CN 标题
*/
title?: string;
/**
* @zh_CN 描述
*/
subTitle?: string;
/**
* @zh_CN 按钮文本
*/
submitButtonText?: string;
}
defineOptions({
name: 'RegisterForm',
});
const props = withDefaults(defineProps<Props>(), {
formSchema: () => [],
loading: false,
loginPath: '/auth/login',
submitButtonText: '',
subTitle: '',
title: '',
});
const emit = defineEmits<{
submit: [Recordable<any>];
}>();
const [Form, formApi] = useEasyFlowForm(
reactive({
commonConfig: {
hideLabel: true,
hideRequiredMark: true,
},
schema: computed(() => props.formSchema),
showDefaultActions: false,
}),
);
const router = useRouter();
async function handleSubmit() {
const { valid } = await formApi.validate();
const values = await formApi.getValues();
if (valid) {
emit('submit', values as { password: string; username: string });
}
}
function goToLogin() {
router.push(props.loginPath);
}
defineExpose({
getFormApi: () => formApi,
});
</script>
<template>
<div class="auth-register">
<Title>
<slot name="title">
{{ title || $t('authentication.createAnAccount') }}
</slot>
<template #desc>
<slot name="subTitle">
{{ subTitle || $t('authentication.signUpSubtitle') }}
</slot>
</template>
</Title>
<div class="auth-form-group">
<Form />
</div>
<EasyFlowButton
:class="{
'cursor-wait': loading,
}"
:loading="loading"
aria-label="register"
class="mt-6 h-11 w-full rounded-xl text-base font-medium"
@click="handleSubmit"
>
<slot name="submitButtonText">
{{ submitButtonText || $t('authentication.signUp') }}
</slot>
</EasyFlowButton>
<div class="mt-5 text-center text-sm text-[hsl(var(--text-muted))]">
{{ $t('authentication.alreadyHaveAccount') }}
<button class="auth-inline-action" type="button" @click="goToLogin()">
{{ $t('authentication.goToLogin') }}
</button>
</div>
</div>
</template>
<style scoped>
.auth-form-group :deep(.easyflow-form-ui + .easyflow-form-ui) {
margin-top: 0.95rem;
}
.auth-inline-action {
font-size: 0.92rem;
font-weight: 500;
color: hsl(var(--nav-item-active-foreground));
transition: opacity 0.18s ease;
}
.auth-inline-action:hover {
opacity: 0.76;
}
</style>