Skip to content

Commit

Permalink
✨ 完善注册流程,现在注册成功之后会跳转到欢迎页面。
Browse files Browse the repository at this point in the history
✨
1. 完善注册流程,现在注册成功之后会跳转到欢迎页面。
2. 已经登录应该无法重复登录了,因为为登录按钮添加了软锁(但注册功能并没有软锁)
3. 修复点击视频页收藏按钮会唤起登录窗口的问题,现在未登录用户点击收藏会唤起登录窗口,而已登录用户会出现错误提示。
  • Loading branch information
cfdxkk committed May 19, 2024
1 parent 3a9da3d commit 3d6bdfd
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 51 deletions.
101 changes: 52 additions & 49 deletions components/Login/LoginWindow.vue
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,30 @@
isTryingLogin.value = false;
}
/**
* 用户注册,其一
*/
const PASSWORD_HINT_DO_NOT_ALLOW_INCLUDES_PASSWORD = "密码提示中不允许包含密码本身"; // TODO: 使用多语言
const checkAndJumpNextPage = async () => {
if (email.value && password.value) {
if (password.value && passwordHint.value && passwordHint.value.includes(password.value)) { // 判断密码提示中是否包含密码自身
useToast(PASSWORD_HINT_DO_NOT_ALLOW_INCLUDES_PASSWORD, "error");
return;
}
const userExistsCheckRequest: UserExistsCheckRequestDto = { email: email.value };
try {
const userExistsCheckResponse = await api.user.userExistsCheck(userExistsCheckRequest);
if (userExistsCheckResponse.success && !userExistsCheckResponse.exists)
currentPage.value = "register2";
else
useToast("该邮箱已注册,请更换", "error", 5000); // TODO: 使用多语言
} catch (error) {
useToast("注册失败", "error"); // TODO: 使用多语言
}
} else
useToast("请输入用户名和密码", "error"); // TODO: 使用多语言
};
/**
* 用户注册,其二。
*/
Expand All @@ -84,13 +108,16 @@
try {
isTryingRegistration.value = true;
const registrationResponse = await api.user.registration(userRegistrationRequest);
isTryingRegistration.value = false;
if (registrationResponse.success) { // 如果注册成功,则关闭页面,并且回退到登录页面
open.value = false;
currentPage.value = "login";
if (registrationResponse.success) { // 如果注册成功
await api.user.getSelfUserInfo(); // 根据获取到的用户 UID 和 Token 获取用户数据,相当于自动登录
open.value = false; // 关闭登录页
currentPage.value = "login"; // 将登录页设为登录窗口默认页
navigate("/welcome"); // 跳转到欢迎页面
} else
useToast("注册失败,请稍后再试", "error"); // TODO: 使用多语言
isTryingRegistration.value = false; // 停止注册按钮加载动画
} catch (error) {
useToast("注册失败,请稍后再试", "error"); // TODO: 使用多语言
}
Expand All @@ -103,10 +130,10 @@
* 重置密码。
*/
async function resetPassword() {
const oapiClient = useMap();
const oldPassword = ""; // Should we get this?
await oapiClient.resetPassword(oldPassword, password.value);
open.value = false;
// const oapiClient = useMap();
// const oldPassword = ""; // Should we get this?
// await oapiClient.resetPassword(oldPassword, password.value);
// open.value = false;
}
/**
Expand All @@ -122,30 +149,6 @@
open.value = false;
}
/**
* 用户注册,其一
*/
const PASSWORD_HINT_DO_NOT_ALLOW_INCLUDES_PASSWORD = "密码提示中不允许包含密码本身"; // TODO: 使用多语言
const checkAndJumpNextPage = async () => {
if (email.value && password.value) {
if (password.value && passwordHint.value && passwordHint.value.includes(password.value)) { // 判断密码提示中是否包含密码自身
useToast(PASSWORD_HINT_DO_NOT_ALLOW_INCLUDES_PASSWORD, "error");
return;
}
const userExistsCheckRequest: UserExistsCheckRequestDto = { email: email.value };
try {
const userExistsCheckResponse = await api.user.userExistsCheck(userExistsCheckRequest);
if (userExistsCheckResponse.success && !userExistsCheckResponse.exists)
currentPage.value = "register2";
else
useToast("该邮箱已注册,请更换", "error", 5000); // TODO: 使用多语言
} catch (error) {
useToast("注册失败", "error"); // TODO: 使用多语言
}
} else
useToast("请输入用户名和密码", "error"); // TODO: 使用多语言
};
const passwordHintInvalidText = ref<string | boolean>();
/**
Expand Down Expand Up @@ -201,7 +204,7 @@
autoComplete="current-password"
/>
<div class="button login-button-placeholder">
<Button class="button login-button button-block" :loading="isTryingLogin" :disabled="isTryingLogin" @click="loginUser">Link Start!</Button>
<Button class="button login-button button-block" :loading="isTryingLogin" :disabled="isTryingLogin || selfUserInfoStore.isLogined" @click="loginUser">Link Start!</Button>
</div>
</div>
<div class="action margin-left-inset margin-right-inset">
Expand Down Expand Up @@ -371,8 +374,8 @@
width: $width;
height: $height;
overflow: clip;
transition: all $transition-ease $enter-duration;
clip-path: circle(100% at var(--avatar-center));
transition: all $transition-ease $enter-duration;
* {
transition: all $transition-ease $enter-duration;
Expand All @@ -389,8 +392,8 @@
&.v-enter-from,
&.v-leave-to {
opacity: 0;
translate: 0 6rem;
opacity: 0;
}
@media #{$narrow-screen} {
Expand All @@ -410,11 +413,11 @@
#{$parent-selector} &#{$specified-page} {
$move-distance: $width * 0.5;
translate: if($direction == left, -$move-distance, $move-distance);
opacity: 0;
pointer-events: none;
transition: all $transition-ease $enter-duration;
animation: none !important;
pointer-events: none;
translate: if($direction == left, -$move-distance, $move-distance);
}
}
Expand Down Expand Up @@ -469,9 +472,9 @@
> * {
left: 0;
translate: $width * -0.25 0;
opacity: 0;
pointer-events: none;
translate: $width * -0.25 0;
@media #{$narrow-screen} {
translate: $width * -0.5 0;
Expand Down Expand Up @@ -643,6 +646,7 @@
@include absolute-center-sized;
$thickness: 1px; // 加号符号粗细的一半。
background-color: c(main-bg);
scale: 0;
clip-path:
polygon(
calc(50% - $thickness) 0,
Expand All @@ -658,7 +662,6 @@
calc(50% + $thickness) calc(50% - $thickness),
calc(50% + $thickness) 0
);
scale: 0;
}
.avatar {
Expand Down Expand Up @@ -690,8 +693,8 @@
top: 50%;
left: 48%;
display: none;
font-weight: bold;
font-size: 38px;
font-weight: bold;
}
.burst {
Expand All @@ -705,17 +708,17 @@
}
.stripes {
rotate: -33deg;
translate: 0 180px;
rotate: -33deg;
.line {
@include oval;
position: absolute;
width: 872px;
height: 40px;
background-color: c(accent-20);
opacity: 0;
translate: 913px;
opacity: 0;
&:nth-child(1) {
margin-top: -110px;
Expand Down Expand Up @@ -745,8 +748,8 @@
}
.login-button {
animation: login-animation-button 600ms $ease-login-button forwards;
pointer-events: none;
animation: login-animation-button 600ms $ease-login-button forwards;
@media #{$narrow-screen} {
animation-name: login-animation-button-narrow;
Expand Down Expand Up @@ -872,18 +875,18 @@
@keyframes name-move {
0% {
opacity: 0;
translate: 200px;
opacity: 0;
}
1% {
opacity: 1;
translate: 200px;
opacity: 1;
}
100% {
opacity: 1;
translate: 0;
opacity: 1;
}
}
Expand All @@ -906,13 +909,13 @@
@keyframes stripes {
from {
opacity: 1;
translate: 913px;
opacity: 1;
}
to {
opacity: 1;
translate: -670px;
opacity: 1;
}
}
Expand All @@ -931,8 +934,8 @@
@keyframes move-avatar-to-corner {
to {
scale: calc(40px / $avatar-size);
translate: calc(59px - 50dvw) var(--corner-y);
scale: calc(40px / $avatar-size);
}
}
</style>
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
settings: PlayerVideoSettings;
}>();
const selfUserInfoStore = useSelfUserInfoStore();
const sendDanmaku = defineModel<DanmakuComment[]>("sendDanmaku");
const insertDanmaku = defineModel<DanmakuListItem[]>("insertDanmaku");
Expand All @@ -29,7 +30,10 @@
* 收藏视频。
*/
function favorite() {
useEvent("app:requestLogin");
if (selfUserInfoStore.isLogined)
useToast("抱歉,收藏功能正在制作中,请稍等~", "warning", 5000); // TODO: 使用多语言 // DELETE 请在收藏功能完成后删除该提示
else
useEvent("app:requestLogin");
}
/**
Expand Down Expand Up @@ -228,8 +232,8 @@
grid-row: 1 / -1;
.watching-number {
font-weight: 500;
font-size: 24px;
font-weight: 500;
}
}
}
Expand Down

0 comments on commit 3d6bdfd

Please sign in to comment.