This commit is contained in:
caozehui
2025-03-26 15:42:40 +08:00
parent 39f4cfa670
commit b75ecb8c66
4 changed files with 32 additions and 29 deletions

View File

@@ -1,51 +1,52 @@
import type { Login } from '@/api/user/interface/user' import type {Login} from '@/api/user/interface/user'
import { ADMIN as rePrefix } from '@/api/system/config/serviceName' import {ADMIN as rePrefix} from '@/api/system/config/serviceName'
import http from '@/api' import http from '@/api'
import type { Dict } from '@/api/interface' import type {Dict} from '@/api/interface'
/** /**
* @name 登录模块 * @name 登录模块
*/ */
// 用户登录 // 用户登录
export const loginApi = (params: { username: string; password: string }) => { export const loginApi = (params: { username: string; password: string,checked: boolean }) => {
return http.post<Login.ResLogin>(`${rePrefix}/login`, params, { loading: false }) return http.post<Login.ResLogin>(`${rePrefix}/login`, params, {loading: false})
// return http.post<Login.ResLogin>(`/Register1`, params, { loading: false }) // return http.post<Login.ResLogin>(`/Register1`, params, { loading: false })
} }
// 获取菜单列表 // 获取菜单列表
export const getAuthMenuListApi = () => { export const getAuthMenuListApi = () => {
return http.get<Menu.MenuOptions[]>(`/sysFunction/getMenu`, {}, { loading: false }) return http.get<Menu.MenuOptions[]>(`/sysFunction/getMenu`, {}, {loading: false})
// return http.post<Menu.MenuOptions[]>(`/Register2`, {}, { loading: false }) // return http.post<Menu.MenuOptions[]>(`/Register2`, {}, { loading: false })
} }
// 获取按钮权限 // 获取按钮权限
export const getAuthButtonListApi = () => { export const getAuthButtonListApi = () => {
return http.get<Login.ResAuthButtons>(`/sysFunction/getButton`, {}, { loading: false }) return http.get<Login.ResAuthButtons>(`/sysFunction/getButton`, {}, {loading: false})
// return http.post<Login.ResAuthButtons>(`/Register3`, {}, { loading: false }) // return http.post<Login.ResAuthButtons>(`/Register3`, {}, { loading: false })
} }
// 用户退出登录 // 用户退出登录
export const logoutApi = () => { export const logoutApi = () => {
return http.post(`${rePrefix}/logout`) return http.post(`${rePrefix}/logout`)
} }
//获取下拉框列表 //获取下拉框列表
export const getDictList = () =>{ export const getDictList = () => {
return http.get<Dict>('/dictData/dictDataCache') return http.get<Dict>('/dictData/dictDataCache')
} }
//token刷新 //token刷新
export const refreshToken = () => { export const refreshToken = () => {
return http.get<Login.ResLogin>(`${rePrefix}/refreshToken`, return http.get<Login.ResLogin>(`${rePrefix}/refreshToken`,
{}, {},
{ loading: false } {loading: false}
) )
} }
//获取场景 //获取场景
export const getCurrentScene = () => { export const getCurrentScene = () => {
return http.get('/sysTestConfig/getCurrentScene', {}, { loading: false }) return http.get('/sysTestConfig/getCurrentScene', {}, {loading: false})
} }
/** /**
* 获取RSA公钥 * 获取RSA公钥
*/ */
export const getPublicKey = () => { export const getPublicKey = (username: string, checked: boolean) => {
return http.get('/admin/getPublicKey', {}, { loading: false }) return http.get(`/admin/getPublicKey?username=${username}&checked=${checked}`, {}, {loading: false})
} }

View File

@@ -8,7 +8,7 @@
<!-- :requestApi="getRoleList" --> <!-- :requestApi="getRoleList" -->
<!-- 表格 header 按钮 --> <!-- 表格 header 按钮 -->
<template #tableHeader='scope'> <template #tableHeader='scope'>
<el-button v-auth.role="'add'" type='primary' :icon='CirclePlus' @click="openDrawer('新增角色')">新增</el-button> <el-button v-auth.role="'add'" type='primary' :icon='CirclePlus' @click="openDrawer('add')">新增</el-button>
<el-button v-auth.role="'delete'" type='danger' :icon='Delete' plain :disabled='!scope.isSelected' <el-button v-auth.role="'delete'" type='danger' :icon='Delete' plain :disabled='!scope.isSelected'
@click='batchDelete(scope.selectedListIds)'> @click='batchDelete(scope.selectedListIds)'>
删除 删除
@@ -16,7 +16,7 @@
</template> </template>
<!-- 表格操作 --> <!-- 表格操作 -->
<template #operation='scope'> <template #operation='scope'>
<el-button v-auth.role="'edit'" type='primary' link :icon='EditPen' @click="openDrawer('编辑角色', scope.row)">编辑</el-button> <el-button v-auth.role="'edit'" type='primary' link :icon='EditPen' @click="openDrawer('edit', scope.row)">编辑</el-button>
<el-button v-auth.role="'delete'" v-if="scope.row.type !== 0 && scope.row.type !== 1" type='primary' link :icon='Delete' @click='deleteAccount(scope.row)'>删除</el-button> <el-button v-auth.role="'delete'" v-if="scope.row.type !== 0 && scope.row.type !== 1" type='primary' link :icon='Delete' @click='deleteAccount(scope.row)'>删除</el-button>
<el-button v-auth.role="'SetPermissions'" type='primary' link :icon='Share' @click="openDrawer('设置权限', scope.row)">设置权限</el-button> <el-button v-auth.role="'SetPermissions'" type='primary' link :icon='Share' @click="openDrawer('设置权限', scope.row)">设置权限</el-button>
</template> </template>

View File

@@ -105,10 +105,18 @@ const login = (formEl: FormInstance | undefined) => {
if (!valid) return if (!valid) return
loading.value = true loading.value = true
try { 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.执行登录接口 // 1.执行登录接口
const {data} = await loginApi({ const {data} = await loginApi({
username: forge.util.encode64(loginForm.username), 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) { if (loginForm.checked) {
localStorage.setItem("loginInfo", JSON.stringify({ localStorage.setItem("loginInfo", JSON.stringify({
@@ -184,12 +192,6 @@ onBeforeMount(async () => {
loginForm.checked = true 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))));
}
}) })
</script> </script>

View File

@@ -227,7 +227,7 @@ const columns = reactive<ColumnProps<Plan.ReqPlan>[]>([
{ {
prop: 'errorSysId', prop: 'errorSysId',
label: '误差体系', label: '误差体系',
width: 200, width: 240,
render: scope => { render: scope => {
return ( return (
<el-link type='primary' link onClick={() => showData(scope.row)}> <el-link type='primary' link onClick={() => showData(scope.row)}>