From 4a86455458a0ecda2fac8859801eb8591994d7aa Mon Sep 17 00:00:00 2001 From: yangbin Date: Thu, 25 Jul 2024 22:12:00 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0getOneIDToken=E6=96=B9?= =?UTF-8?q?=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api/user.js | 9 +++ src/permission.js | 5 +- src/views/callback/index.vue | 105 +++++++++++++++++------------------ 3 files changed, 63 insertions(+), 56 deletions(-) diff --git a/src/api/user.js b/src/api/user.js index f4402d8..7203a5e 100644 --- a/src/api/user.js +++ b/src/api/user.js @@ -9,6 +9,15 @@ export function login(data) { }) } +// ONEID登录功能(通过code获取对应的用户token) +export function getOneIdToken(code) { + return request({ + url: '/WRD-admin/oneIDLogin', + method: 'get', + params: { code } + }) +} + export function getInfo() { return request({ url: '/WRD-admin/sys/user/info', diff --git a/src/permission.js b/src/permission.js index 2e2d594..49ce1fd 100644 --- a/src/permission.js +++ b/src/permission.js @@ -8,7 +8,7 @@ import getPageTitle from '@/utils/get-page-title' NProgress.configure({ showSpinner: false }) // NProgress Configuration -const whiteList = ['/login'] // no redirect whitelist +const whiteList = ['/login', '/callback'] // no redirect whitelist router.beforeEach(async(to, from, next) => { // start progress bar @@ -21,7 +21,7 @@ router.beforeEach(async(to, from, next) => { const hasToken = getToken() if (hasToken) { - if (to.path === '/login') { + if (to.path === '/login' || to.path === '/callback') { // if is logged in, redirect to the home page next({ path: '/nav' }) NProgress.done() @@ -47,7 +47,6 @@ router.beforeEach(async(to, from, next) => { } } else { /* has no token*/ - if (whiteList.indexOf(to.path) !== -1) { // in the free login whitelist, go directly next() diff --git a/src/views/callback/index.vue b/src/views/callback/index.vue index 2457923..9cce19b 100644 --- a/src/views/callback/index.vue +++ b/src/views/callback/index.vue @@ -1,59 +1,58 @@ - - - - - \ No newline at end of file +} + + +