From e2dec2a190e0b009f6c682217ab21e54bdb08f1f Mon Sep 17 00:00:00 2001
From: ljw <84855512@qq.com>
Date: Wed, 30 Oct 2024 19:37:38 +0800
Subject: [PATCH 1/3] up
---
src/views/user/composables/index.js | 3 +++
1 file changed, 3 insertions(+)
diff --git a/src/views/user/composables/index.js b/src/views/user/composables/index.js
index abbd6c3..61831aa 100644
--- a/src/views/user/composables/index.js
+++ b/src/views/user/composables/index.js
@@ -91,6 +91,9 @@ export function useDel () {
}
const res = remove({ id }).catch(_ => false)
+ if (res) {
+ ElMessage.success(T('OperationSuccess'))
+ }
return res
}
return {
From 31dbe5c8e29cd7ebbc1b2d518dcacebc1286ee25 Mon Sep 17 00:00:00 2001
From: ljw <84855512@qq.com>
Date: Thu, 31 Oct 2024 14:02:34 +0800
Subject: [PATCH 2/3] up oauth
---
src/router/index.js | 2 ++
src/views/login/login.vue | 24 +++++++-----------------
src/views/oauth/bind.vue | 15 +++++++++++----
3 files changed, 20 insertions(+), 21 deletions(-)
diff --git a/src/router/index.js b/src/router/index.js
index e4fb363..fec2c67 100644
--- a/src/router/index.js
+++ b/src/router/index.js
@@ -15,11 +15,13 @@ const constantRoutes = [
},
{
path: '/oauth/:code',
+ meta: { title: 'OauthLogin' },
component: () => import('@/views/oauth/login.vue'),
hidden: true,
},
{
path: '/oauth/bind/:code',
+ meta: { title: 'OauthBind' },
component: () => import('@/views/oauth/bind.vue'),
hidden: true,
},
diff --git a/src/views/login/login.vue b/src/views/login/login.vue
index 6ab558b..09e0a6f 100644
--- a/src/views/login/login.vue
+++ b/src/views/login/login.vue
@@ -26,7 +26,7 @@
- {{ T(option.name) }}
+ {{ T(option.name) }}
@@ -105,21 +105,9 @@ const getProviderImage = (provider) => {
const loadLoginOptions = async () => {
try {
- const res = await loginOptions().catch(() => []);
- if (!Array.isArray(res) || !res.length) return console.warn('No valid response received');
-
- const jsonPart = res[0].split('/')[1];
- if (!jsonPart) return console.error('Invalid input string:', res[0]);
-
- // const ops = JSON.parse(jsonPart).map(option => ({ name: option.name }));
- // 不确定怎么处理webauth,不显示
- // 解析 JSON,并过滤掉 "webauth" 类型的选项
- const ops = JSON.parse(jsonPart)
- .filter(option => option.name !== "webauth") // 排除 "webauth" 类型的选项
- .map(option => ({ name: option.name })); // 创建新的对象数组
- if (!ops.length) return;
-
- options.push(...ops);
+ 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 }))); // 创建新的对象数组
} catch (error) {
console.error('Error loading login options:', error.message);
}
@@ -141,6 +129,7 @@ onMounted(async () => {
loadLoginOptions(); // 组件挂载后调用登录选项加载函数
}
});
+
\ No newline at end of file
+
diff --git a/src/views/oauth/bind.vue b/src/views/oauth/bind.vue
index 3e25c90..b87aba0 100644
--- a/src/views/oauth/bind.vue
+++ b/src/views/oauth/bind.vue
@@ -49,10 +49,17 @@
const res = await bindConfirm({ code }).catch(_ => false)
if (res) {
resStatus.value = 1
- ElMessage.success(T('OperationSuccessAndCloseAfter3Seconds'))
- setTimeout(_ => {
- out()
- }, 3000)
+ if (res.data.device_type === 'webadmin') {
+ ElMessage.success(T('OperationSuccess'))
+ //后台登录
+ router.push('/')
+ } else {
+ ElMessage.success(T('OperationSuccessAndCloseAfter3Seconds'))
+ setTimeout(_ => {
+ out()
+ }, 3000)
+ }
+
}
}
const out = () => {
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 3/3] 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')
+}