-
+
-
+
-
+
@@ -40,6 +50,33 @@
diff --git a/open-isle-cli/src/views/SignupPageView.vue b/open-isle-cli/src/views/SignupPageView.vue
index 544e34940..7f8b2c4cb 100644
--- a/open-isle-cli/src/views/SignupPageView.vue
+++ b/open-isle-cli/src/views/SignupPageView.vue
@@ -10,25 +10,45 @@
登录
-
+
-
+
-
+
-
+
-
+
@@ -39,9 +59,14 @@
验证邮箱
-
+
-
+
@@ -62,11 +87,56 @@ export default {
data() {
return {
- emailStep: 1,
+ emailStep: 0,
+ email: '',
+ username: '',
+ password: '',
+ nickname: '',
+ code: ''
}
},
-
-
+ methods: {
+ async sendVerification() {
+ try {
+ const res = await fetch('/api/auth/register', {
+ method: 'POST',
+ headers: { 'Content-Type': 'application/json' },
+ body: JSON.stringify({
+ username: this.username,
+ email: this.email,
+ password: this.password
+ })
+ })
+ const data = await res.json()
+ if (res.ok) {
+ this.emailStep = 1
+ alert('验证码已发送,请查看邮箱')
+ } else {
+ alert(data.error || '发送失败')
+ }
+ } catch (e) {
+ alert('发送失败')
+ }
+ },
+ async verifyCode() {
+ try {
+ const res = await fetch('/api/auth/verify', {
+ method: 'POST',
+ headers: { 'Content-Type': 'application/json' },
+ body: JSON.stringify({ username: this.username, code: this.code })
+ })
+ const data = await res.json()
+ if (res.ok) {
+ alert('注册成功,请登录')
+ this.$router.push('/login')
+ } else {
+ alert(data.error || '注册失败')
+ }
+ } catch (e) {
+ alert('注册失败')
+ }
+ }
+ }
}
注册