From d3031ae5d870a18770db59e96e1c8ba9880fe633 Mon Sep 17 00:00:00 2001
From: ljw <84855512@qq.com>
Date: Thu, 31 Oct 2024 15:12:46 +0800
Subject: [PATCH] add register
---
src/api/user.js | 10 ++-
src/permission.js | 2 +-
src/router/index.js | 7 +-
src/utils/i18n/en.json | 9 +++
src/utils/i18n/ko.json | 9 +++
src/utils/i18n/ru.json | 9 +++
src/utils/i18n/zh_CN.json | 12 ++-
src/views/login/login.vue | 10 ++-
src/views/register/index.vue | 147 +++++++++++++++++++++++++++++++++++
9 files changed, 209 insertions(+), 6 deletions(-)
create mode 100644 src/views/register/index.vue
diff --git a/src/api/user.js b/src/api/user.js
index 19be1f0..dabe483 100644
--- a/src/api/user.js
+++ b/src/api/user.js
@@ -79,6 +79,14 @@ export function groupUsers (data) {
return request({
url: '/user/groupUsers',
method: 'post',
- data
+ data,
+ })
+}
+
+export function register (data) {
+ return request({
+ url: '/user/register',
+ method: 'post',
+ data,
})
}
diff --git a/src/permission.js b/src/permission.js
index 7dbded1..f58b285 100644
--- a/src/permission.js
+++ b/src/permission.js
@@ -10,7 +10,7 @@ import { T } from '@/utils/i18n'
NProgress.configure({ showSpinner: false }) // NProgress Configuration
-const whiteList = ['/login']
+const whiteList = ['/login', '/register']
const routeStore = useRouteStore(pinia)
const appStore = useAppStore(pinia)
router.beforeEach(async (to, from, next) => {
diff --git a/src/router/index.js b/src/router/index.js
index fec2c67..e7945fa 100644
--- a/src/router/index.js
+++ b/src/router/index.js
@@ -7,7 +7,12 @@ const constantRoutes = [
meta: { title: 'Login' },
component: () => import('@/views/login/login.vue'),
},
-
+ {
+ path: '/register',
+ name: 'Register',
+ meta: { title: 'Register' },
+ component: () => import('@/views/register/index.vue'),
+ },
{
path: '/404',
component: () => import('@/views/error-page/404.vue'),
diff --git a/src/utils/i18n/en.json b/src/utils/i18n/en.json
index 903e744..3a032f3 100644
--- a/src/utils/i18n/en.json
+++ b/src/utils/i18n/en.json
@@ -438,5 +438,14 @@
},
"LastOnlineIp": {
"One": "Last Online Ip"
+ },
+ "ConfirmPassword": {
+ "One": "Confirm Password"
+ },
+ "PasswordNotMatchConfirmPassword": {
+ "One": "Password not match Confirm Password"
+ },
+ "ToLogin": {
+ "One": "To Login"
}
}
diff --git a/src/utils/i18n/ko.json b/src/utils/i18n/ko.json
index 4efe106..ffa3609 100644
--- a/src/utils/i18n/ko.json
+++ b/src/utils/i18n/ko.json
@@ -424,5 +424,14 @@
},
"LastOnlineIp": {
"One": "마지막 온라인 IP"
+ },
+ "ConfirmPassword": {
+ "One": "비밀번호 확인"
+ },
+ "PasswordNotMatchConfirmPassword": {
+ "One": "비밀번호가 확인 비밀번호와 일치하지 않습니다"
+ },
+ "ToLogin": {
+ "One": "로그인하려면 클릭하십시오"
}
}
diff --git a/src/utils/i18n/ru.json b/src/utils/i18n/ru.json
index 25b1f5c..1a54074 100644
--- a/src/utils/i18n/ru.json
+++ b/src/utils/i18n/ru.json
@@ -438,6 +438,15 @@
},
"LastOnlineIp": {
"One": "Последний IP онлайн"
+ },
+ "ConfirmPassword": {
+ "One": "Подтвердите пароль"
+ },
+ "PasswordNotMatchConfirmPassword": {
+ "One": "Пароль и подтверждение пароля не совпадают"
+ },
+ "ToLogin": {
+ "One": "Войти"
}
}
diff --git a/src/utils/i18n/zh_CN.json b/src/utils/i18n/zh_CN.json
index 0019fbb..b26df62 100644
--- a/src/utils/i18n/zh_CN.json
+++ b/src/utils/i18n/zh_CN.json
@@ -428,8 +428,16 @@
"LastOnlineIp": {
"One": "最后在线IP"
},
- "or login in with" :
- {
+ "or login in with": {
"One": "或使用以下登陆"
+ },
+ "ConfirmPassword": {
+ "One": "确认密码"
+ },
+ "PasswordNotMatchConfirmPassword": {
+ "One": "密码与确认密码不匹配"
+ },
+ "ToLogin": {
+ "One": "去登录"
}
}
diff --git a/src/views/login/login.vue b/src/views/login/login.vue
index 09e0a6f..5878662 100644
--- a/src/views/login/login.vue
+++ b/src/views/login/login.vue
@@ -15,6 +15,7 @@
{{ T('Login') }}
+ {{ T('Register') }}
@@ -103,11 +104,13 @@ const getProviderImage = (provider) => {
return providerImageMap[provider] || providerImageMap.default;
};
+const allowRegister = ref(false)
const loadLoginOptions = async () => {
try {
const res = await loginOptions().catch(_ => false);
if(!res || !res.data) return console.error('No valid response received');
- res.data.map(option => (options.push({ name: option }))); // 创建新的对象数组
+ res.data.ops.map(option => (options.push({ name: option }))); // 创建新的对象数组
+ allowRegister.value = res.data.register
} catch (error) {
console.error('Error loading login options:', error.message);
}
@@ -130,6 +133,9 @@ onMounted(async () => {
}
});
+const register = () => {
+ router.push('/register')
+}