From 21cbb63052c450f531da087ff8d6c9b775931cf2 Mon Sep 17 00:00:00 2001 From: LokerL Date: Mon, 25 Nov 2024 15:11:39 +0800 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20feat:=20=E6=B7=BB=E5=8A=A0=E6=96=B0?= =?UTF-8?q?=E5=8D=95=E7=82=B9=E7=99=BB=E5=BD=95=E5=8A=9F=E8=83=BD=EF=BC=9B?= =?UTF-8?q?=E6=96=B0=E5=A2=9EsingleSign=E6=8E=A5=E5=8F=A3=E5=8F=8A?= =?UTF-8?q?=E7=9B=B8=E5=85=B3=E8=B7=AF=E7=94=B1=E5=92=8C=E8=A7=86=E5=9B=BE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ruoyi-ui/src/api/login.js | 12 ++++++++++++ ruoyi-ui/src/permission.js | 2 +- ruoyi-ui/src/router/index.js | 5 +++++ ruoyi-ui/src/store/modules/user.js | 17 ++++++++++++++++- ruoyi-ui/src/views/single-sign.vue | 27 +++++++++++++++++++++++++++ 5 files changed, 61 insertions(+), 2 deletions(-) create mode 100644 ruoyi-ui/src/views/single-sign.vue diff --git a/ruoyi-ui/src/api/login.js b/ruoyi-ui/src/api/login.js index af2a88c..53de8a9 100644 --- a/ruoyi-ui/src/api/login.js +++ b/ruoyi-ui/src/api/login.js @@ -19,6 +19,18 @@ export function login(username, password, code, uuid) { }) } +export function singleSign(username, password) { + return request({ + url: '/singleSign', + headers: { + isToken: false, + repeatSubmit: false + }, + method: 'post', + data: { username, password } + }) +} + // 注册方法 export function register(data) { return request({ diff --git a/ruoyi-ui/src/permission.js b/ruoyi-ui/src/permission.js index 228d79d..23ba4a3 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', '/LoginSso', '/LoginRedirect'] +const whiteList = ['/login', '/register', '/LoginSso', '/LoginRedirect', '/SingleSign'] router.beforeEach((to, from, next) => { NProgress.start() diff --git a/ruoyi-ui/src/router/index.js b/ruoyi-ui/src/router/index.js index 0e16abd..7fe43c1 100644 --- a/ruoyi-ui/src/router/index.js +++ b/ruoyi-ui/src/router/index.js @@ -51,6 +51,11 @@ export const constantRoutes = [ component: () => import('@/views/login-sso'), hidden: true }, + { + path: '/SingleSign', + component: () => import('@/views/single-sign'), + hidden: true + }, { path: '/LoginRedirect', component: () => import('@/views/login-redirect'), diff --git a/ruoyi-ui/src/store/modules/user.js b/ruoyi-ui/src/store/modules/user.js index d24810a..b32e9ef 100644 --- a/ruoyi-ui/src/store/modules/user.js +++ b/ruoyi-ui/src/store/modules/user.js @@ -1,4 +1,4 @@ -import { login, logout, getInfo, getAccountName } from '@/api/login' +import { login, logout, getInfo, getAccountName, singleSign } from '@/api/login' import { getToken, setToken, removeToken } from '@/utils/auth' import {encrypt, decrypt} from '@/utils/secret' const user = { @@ -51,6 +51,21 @@ const user = { }) }, + SingleSign({ commit }, userInfo) { + const username = userInfo.username.trim(); + const password = userInfo.password; + let encodePs = encrypt(password)//加密 + return new Promise((resolve, reject) => { + singleSign(username, encodePs).then(res => { + setToken(res.token) + commit('SET_TOKEN', res.token) + resolve() + }).catch(error => { + reject(error) + }) + }) + }, + // 获取用户信息 GetInfo({ commit, state }) { return new Promise((resolve, reject) => { diff --git a/ruoyi-ui/src/views/single-sign.vue b/ruoyi-ui/src/views/single-sign.vue new file mode 100644 index 0000000..0a973ea --- /dev/null +++ b/ruoyi-ui/src/views/single-sign.vue @@ -0,0 +1,27 @@ + +​ +