From aae6bb75059718ca4ae0b3361a1a7ea48faca87e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=B8=89=E4=B8=AA=E4=B8=89?= <2029364173@qq.com> Date: Tue, 20 Jun 2023 04:12:49 +0000 Subject: [PATCH] =?UTF-8?q?!16=20=E6=89=A9=E5=B1=95=E7=AC=AC=E4=B8=89?= =?UTF-8?q?=E6=96=B9=E7=99=BB=E5=BD=95=E6=8E=88=E6=9D=83=E5=8A=9F=E8=83=BD?= =?UTF-8?q?=20*=20add=20=E7=AC=AC=E4=B8=89=E6=96=B9=E6=8E=88=E6=9D=83=20*?= =?UTF-8?q?=20add=20=E7=AC=AC=E4=B8=89=E6=96=B9=E6=8E=88=E6=9D=83=E7=99=BB?= =?UTF-8?q?=E5=BD=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 1 + src/api/login.ts | 18 ++ src/api/system/social/auth.ts | 33 ++++ src/assets/icons/svg/gitee.svg | 1 + src/layout/components/socialLogin/index.vue | 36 ++++ src/permission.ts | 2 +- src/router/index.ts | 5 + src/views/login.vue | 181 +++++++++++-------- src/views/system/user/profile/index.vue | 16 +- src/views/system/user/profile/thirdParty.vue | 140 ++++++++++++++ 10 files changed, 359 insertions(+), 74 deletions(-) create mode 100644 src/api/system/social/auth.ts create mode 100644 src/assets/icons/svg/gitee.svg create mode 100644 src/layout/components/socialLogin/index.vue create mode 100644 src/views/system/user/profile/thirdParty.vue diff --git a/.gitignore b/.gitignore index 79e7fd9..40df474 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ .DS_Store +.history node_modules/ dist/ npm-debug.log* diff --git a/src/api/login.ts b/src/api/login.ts index b95a0c0..48b62d1 100644 --- a/src/api/login.ts +++ b/src/api/login.ts @@ -60,6 +60,24 @@ export function getCodeImg(): AxiosPromise { timeout: 20000 }); } +/** + * 第三方登录 + * @param source 第三方登录类型 + * */ +export function socialLogin(source: string, code: any, state: any): AxiosPromise { + const data = { + code, + state + }; + return request({ + url: '/auth/social-login/' + source, + method: 'get', + headers: { + isToken: true + }, + params: data + }); +} // 获取用户详细信息 export function getInfo(): AxiosPromise { diff --git a/src/api/system/social/auth.ts b/src/api/system/social/auth.ts new file mode 100644 index 0000000..b1f2106 --- /dev/null +++ b/src/api/system/social/auth.ts @@ -0,0 +1,33 @@ +import request from '@/utils/request'; + +// 绑定账号 +export function authBinding(source: string) { + return request({ + url: '/auth/binding/' + source, + method: 'get', + headers: { + isToken: true + } + }); +} + +// 解绑账号 +export function authUnlock(authId: string) { + return request({ + url: '/auth/unlock/' + authId, + method: 'delete', + headers: { + isToken: true + } + }); +} +//获取授权列表 +export function getAuthList() { + return request({ + url: '/system/social/list', + method: 'get', + headers: { + isToken: true + } + }); +} diff --git a/src/assets/icons/svg/gitee.svg b/src/assets/icons/svg/gitee.svg new file mode 100644 index 0000000..6324608 --- /dev/null +++ b/src/assets/icons/svg/gitee.svg @@ -0,0 +1 @@ + diff --git a/src/layout/components/socialLogin/index.vue b/src/layout/components/socialLogin/index.vue new file mode 100644 index 0000000..e125c12 --- /dev/null +++ b/src/layout/components/socialLogin/index.vue @@ -0,0 +1,36 @@ + + + diff --git a/src/permission.ts b/src/permission.ts index 4713383..c2743eb 100644 --- a/src/permission.ts +++ b/src/permission.ts @@ -10,7 +10,7 @@ import useSettingsStore from '@/store/modules/settings'; import usePermissionStore from '@/store/modules/permission'; NProgress.configure({ showSpinner: false }); -const whiteList = ['/login', '/register']; +const whiteList = ['/login', '/register', '/social-login']; router.beforeEach(async (to, from, next) => { NProgress.start(); diff --git a/src/router/index.ts b/src/router/index.ts index 9540ab2..33e3e5e 100644 --- a/src/router/index.ts +++ b/src/router/index.ts @@ -37,6 +37,11 @@ export const constantRoutes: RouteOption[] = [ } ] }, + { + path: '/social-login', + hidden: true, + component: () => import('@/layout/components/socialLogin/index.vue') + }, { path: '/login', component: () => import('@/views/login.vue'), diff --git a/src/views/login.vue b/src/views/login.vue index 9559f9b..af98f01 100644 --- a/src/views/login.vue +++ b/src/views/login.vue @@ -4,7 +4,7 @@

RuoYi-Vue-Plus多租户管理系统

- + @@ -36,6 +36,20 @@ 立即注册 +
+ + + + + + + + + + + + +