diff --git a/components/Default/Header.vue b/components/Default/Header.vue
index d38dc4f..3239354 100644
--- a/components/Default/Header.vue
+++ b/components/Default/Header.vue
@@ -24,11 +24,12 @@
游戏服务器
-->
- 论坛
- 托管
+ 论坛
+ 托管
- 登录
- 注册
+ 登录
+ 注册
+ 注销
@@ -36,9 +37,13 @@
diff --git a/pages/user/logout.ts b/pages/user/logout.ts
new file mode 100644
index 0000000..53ac5c8
--- /dev/null
+++ b/pages/user/logout.ts
@@ -0,0 +1,9 @@
+const auth = useCookie("auth");
+$fetch("/api/user/logout", {
+ method: "POST",
+ body: {
+ auth: auth.value,
+ },
+});
+auth.value = undefined;
+navigateTo("/");
diff --git a/pages/register/index.vue b/pages/user/register/index.vue
similarity index 85%
rename from pages/register/index.vue
rename to pages/user/register/index.vue
index ff7ff7e..ca1f6f6 100644
--- a/pages/register/index.vue
+++ b/pages/user/register/index.vue
@@ -17,6 +17,7 @@
view="tabs"
:model-value="form"
@update:model-value="form = $event"
+ @success="RegSuccess"
validate-on="change"
style="padding: 5%"
>
@@ -31,18 +32,14 @@
rules="required|min:3|max:64"
@input="Check()"
/>
-
@@ -95,7 +92,6 @@
>
已阅读并同意《用户协议》
- 希望获取最新资讯
{
if (!res.phone) {
- phone$.value.messageBag.append("手机号已经注册");
+ username$.value.messageBag.append("手机号已经注册");
canSubmit.value = true;
+ return 0;
} else {
+ username$.value.messageBag.clear("errors");
canSubmit.value = false;
}
if (!res.username) {
username$.value.messageBag.append("昵称已存在");
canSubmit.value = true;
} else {
+ username$.value.messageBag.clear("errors");
canSubmit.value = false;
}
});
@@ -170,10 +169,10 @@ function Send() {
Check();
if (!canSubmit.value) {
- $fetch("/api/test/sms", {
+ $fetch("/api/reg/sms", {
method: "POST",
body: {
- phone: form.value.phone.replace("+86", ""),
+ phone: form.value.phone,
},
}).then((res) => {
switch (res.code) {
@@ -199,7 +198,7 @@ function Send() {
}
function CheckCode() {
if (!code$.value.invalid) {
- $fetch("/api/test/code", {
+ $fetch("/api/reg/code", {
method: "POST",
body: {
phone: form.value.phone.replace("+86", ""),
@@ -217,7 +216,7 @@ function CheckCode() {
ElMessage({ message: res.msg, type: "success" });
codeBtnRef.value.disabled = true;
codeBtnRef.value.text = "已验证";
- phoneChecked.value = ture;
+ phoneChecked.value = true;
break;
case 2:
ElMessage({ message: res.msg, type: "warning" });
@@ -231,6 +230,14 @@ function CheckCode() {
});
}
}
+function RegSuccess(response: { data: { code: number; msg: string } }, form$) {
+ if (response.data.code == 1) {
+ ElMessage({ message: response.data.msg, type: "success" });
+ navigateTo("/user/login");
+ } else {
+ ElMessage({ message: response.data.msg, type: "warning" });
+ }
+}