From b75ecb8c66a3d246e33e034d38efa89568d78627 Mon Sep 17 00:00:00 2001 From: caozehui <2427765068@qq.com> Date: Wed, 26 Mar 2025 15:42:40 +0800 Subject: [PATCH] =?UTF-8?q?=E5=BE=AE=E8=B0=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- frontend/src/api/user/login/index.ts | 39 ++++++++++--------- frontend/src/views/authority/role/index.vue | 4 +- .../src/views/login/components/LoginForm.vue | 16 ++++---- frontend/src/views/plan/planList/index.vue | 2 +- 4 files changed, 32 insertions(+), 29 deletions(-) diff --git a/frontend/src/api/user/login/index.ts b/frontend/src/api/user/login/index.ts index fea5e77..d590da5 100644 --- a/frontend/src/api/user/login/index.ts +++ b/frontend/src/api/user/login/index.ts @@ -1,51 +1,52 @@ -import type { Login } from '@/api/user/interface/user' -import { ADMIN as rePrefix } from '@/api/system/config/serviceName' +import type {Login} from '@/api/user/interface/user' +import {ADMIN as rePrefix} from '@/api/system/config/serviceName' import http from '@/api' -import type { Dict } from '@/api/interface' +import type {Dict} from '@/api/interface' + /** * @name 登录模块 */ // 用户登录 -export const loginApi = (params: { username: string; password: string }) => { - return http.post(`${rePrefix}/login`, params, { loading: false }) - // return http.post(`/Register1`, params, { loading: false }) +export const loginApi = (params: { username: string; password: string,checked: boolean }) => { + return http.post(`${rePrefix}/login`, params, {loading: false}) + // return http.post(`/Register1`, params, { loading: false }) } // 获取菜单列表 export const getAuthMenuListApi = () => { - return http.get(`/sysFunction/getMenu`, {}, { loading: false }) - // return http.post(`/Register2`, {}, { loading: false }) + return http.get(`/sysFunction/getMenu`, {}, {loading: false}) + // return http.post(`/Register2`, {}, { loading: false }) } // 获取按钮权限 export const getAuthButtonListApi = () => { - return http.get(`/sysFunction/getButton`, {}, { loading: false }) - // return http.post(`/Register3`, {}, { loading: false }) + return http.get(`/sysFunction/getButton`, {}, {loading: false}) + // return http.post(`/Register3`, {}, { loading: false }) } // 用户退出登录 export const logoutApi = () => { - return http.post(`${rePrefix}/logout`) + return http.post(`${rePrefix}/logout`) } //获取下拉框列表 -export const getDictList = () =>{ - return http.get('/dictData/dictDataCache') +export const getDictList = () => { + return http.get('/dictData/dictDataCache') } //token刷新 export const refreshToken = () => { - return http.get(`${rePrefix}/refreshToken`, - {}, - { loading: false } + return http.get(`${rePrefix}/refreshToken`, + {}, + {loading: false} ) } //获取场景 export const getCurrentScene = () => { - return http.get('/sysTestConfig/getCurrentScene', {}, { loading: false }) + return http.get('/sysTestConfig/getCurrentScene', {}, {loading: false}) } /** * 获取RSA公钥 */ -export const getPublicKey = () => { - return http.get('/admin/getPublicKey', {}, { loading: false }) +export const getPublicKey = (username: string, checked: boolean) => { + return http.get(`/admin/getPublicKey?username=${username}&checked=${checked}`, {}, {loading: false}) } diff --git a/frontend/src/views/authority/role/index.vue b/frontend/src/views/authority/role/index.vue index c66d68d..a4a3b06 100644 --- a/frontend/src/views/authority/role/index.vue +++ b/frontend/src/views/authority/role/index.vue @@ -8,7 +8,7 @@ diff --git a/frontend/src/views/login/components/LoginForm.vue b/frontend/src/views/login/components/LoginForm.vue index 8492365..7a7a35b 100644 --- a/frontend/src/views/login/components/LoginForm.vue +++ b/frontend/src/views/login/components/LoginForm.vue @@ -105,10 +105,18 @@ const login = (formEl: FormInstance | undefined) => { if (!valid) return loading.value = true try { + if (!isAutoLogin.value) { + let {data: publicKeyBase64}: { data: string } = await getPublicKey(loginForm.username, loginForm.checked) + //将base64格式的公钥转换为Forge可以使用的格式 + const publicKeyDer = forge.util.decode64(publicKeyBase64); + publicKey = forge.pki.publicKeyFromPem(forge.pki.publicKeyToPem(forge.pki.publicKeyFromAsn1(forge.asn1.fromDer(publicKeyDer)))); + } + // 1.执行登录接口 const {data} = await loginApi({ username: forge.util.encode64(loginForm.username), - password: isAutoLogin.value ? loginForm.password : encryptPassword(loginForm.password) + password: isAutoLogin.value ? loginForm.password : encryptPassword(loginForm.password), + checked: loginForm.checked }) if (loginForm.checked) { localStorage.setItem("loginInfo", JSON.stringify({ @@ -184,12 +192,6 @@ onBeforeMount(async () => { loginForm.checked = true } } - if (!isAutoLogin.value) { - let {data: publicKeyBase64}:{data:string} = await getPublicKey() - //将base64格式的公钥转换为Forge可以使用的格式 - const publicKeyDer = forge.util.decode64(publicKeyBase64); - publicKey = forge.pki.publicKeyFromPem(forge.pki.publicKeyToPem(forge.pki.publicKeyFromAsn1(forge.asn1.fromDer(publicKeyDer)))); - } }) diff --git a/frontend/src/views/plan/planList/index.vue b/frontend/src/views/plan/planList/index.vue index f710da7..fa0ddbb 100644 --- a/frontend/src/views/plan/planList/index.vue +++ b/frontend/src/views/plan/planList/index.vue @@ -227,7 +227,7 @@ const columns = reactive[]>([ { prop: 'errorSysId', label: '误差体系', - width: 200, + width: 240, render: scope => { return ( showData(scope.row)}>