From 2642714bb440c5bae8da059ec79d5ec0986962d9 Mon Sep 17 00:00:00 2001 From: LokerL Date: Wed, 20 Nov 2024 11:37:39 +0800 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20feat:=20=E6=B7=BB=E5=8A=A0=E5=8D=95?= =?UTF-8?q?=E7=82=B9=E7=99=BB=E5=BD=95=E5=8A=9F=E8=83=BD-=E5=89=8D?= =?UTF-8?q?=E7=AB=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ruoyi-ui/src/api/login.js | 10 ++++++- ruoyi-ui/src/permission.js | 2 +- ruoyi-ui/src/router/index.js | 5 ++++ ruoyi-ui/src/store/modules/user.js | 20 ++++++++++++-- ruoyi-ui/src/views/login-sso.vue | 43 ++++++++++++++++++++++++++++++ 5 files changed, 76 insertions(+), 4 deletions(-) create mode 100644 ruoyi-ui/src/views/login-sso.vue diff --git a/ruoyi-ui/src/api/login.js b/ruoyi-ui/src/api/login.js index 7b7388f..85e9b82 100644 --- a/ruoyi-ui/src/api/login.js +++ b/ruoyi-ui/src/api/login.js @@ -57,4 +57,12 @@ export function getCodeImg() { method: 'get', timeout: 20000 }) -} \ No newline at end of file +} + +export function getAccountName(data) { + return request({ + url: '/getAccountName', + method: 'get', + params: data + }) +} diff --git a/ruoyi-ui/src/permission.js b/ruoyi-ui/src/permission.js index c568979..5abf76a 100644 --- a/ruoyi-ui/src/permission.js +++ b/ruoyi-ui/src/permission.js @@ -8,7 +8,7 @@ import { isRelogin } from '@/utils/request' NProgress.configure({ showSpinner: false }) -const whiteList = ['/login', '/register'] +const whiteList = ['/login', '/register', '/LoginSso'] router.beforeEach((to, from, next) => { NProgress.start() diff --git a/ruoyi-ui/src/router/index.js b/ruoyi-ui/src/router/index.js index ac5ed9c..6219c15 100644 --- a/ruoyi-ui/src/router/index.js +++ b/ruoyi-ui/src/router/index.js @@ -46,6 +46,11 @@ export const constantRoutes = [ component: () => import('@/views/login'), hidden: true }, + { + path: '/LoginSso', + component: () => import('@/views/login-sso'), + hidden: true + }, { path: '/register', component: () => import('@/views/register'), diff --git a/ruoyi-ui/src/store/modules/user.js b/ruoyi-ui/src/store/modules/user.js index b16798c..d24810a 100644 --- a/ruoyi-ui/src/store/modules/user.js +++ b/ruoyi-ui/src/store/modules/user.js @@ -1,6 +1,6 @@ -import { login, logout, getInfo } from '@/api/login' +import { login, logout, getInfo, getAccountName } from '@/api/login' import { getToken, setToken, removeToken } from '@/utils/auth' -import {encrypt, decrypt} from '@/utils/secret' +import {encrypt, decrypt} from '@/utils/secret' const user = { state: { token: getToken(), @@ -95,6 +95,22 @@ const user = { removeToken() resolve() }) + }, + + LoginSso({ commit }, code) { + return new Promise((resolve, reject) => { + getAccountName({"code": code}).then((res) => { + if (res.code == 200) { + setToken(res.token) + commit('SET_TOKEN', res.token) + resolve() + } else { + reject(res) + } + }).catch(error => { + reject(error) + }) + }) } } } diff --git a/ruoyi-ui/src/views/login-sso.vue b/ruoyi-ui/src/views/login-sso.vue new file mode 100644 index 0000000..4221c3f --- /dev/null +++ b/ruoyi-ui/src/views/login-sso.vue @@ -0,0 +1,43 @@ + +​ +