fix: 树样式错乱bug修改

* fix: 登录加密

* fix: 登录加密功能

* fix: 树样式错乱bug修改
This commit is contained in:
qiaochuLei 2023-08-08 15:45:43 +08:00 committed by GitHub
parent d28fb618a2
commit f41a209cd5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 67 additions and 33 deletions

View File

@ -15,8 +15,6 @@
checkable
@check="onCheck"
:height="600"
:showLine="{ showLeafIcon: false }"
:show-icon="true"
>
<template #title="{ name, key }">
<span

View File

@ -129,8 +129,9 @@ import { TOKEN_KEY } from '@/utils/variable'
import { Form } from 'ant-design-vue'
import { applicationInfo, bindAccount } from '@/api/bind'
import { code, authLogin, userDetail } from '@/api/login'
import { code, authLogin, userDetail , authLoginConfig} from '@/api/login'
import { useSystem } from '@/store/system'
import {encrypt} from '@/utils/encrypt'
const useForm = Form.useForm;
const systemStore = useSystem();
@ -175,15 +176,17 @@ const getUrlCode = () => {
const bindUser = ref<any>({ appName: '' })
const getAppInfo = async () => {
const code = getUrlCode()
const { result } = await applicationInfo(code)
bindUser.value = result
const { result,success } = await applicationInfo(code)
bindUser.value = result || {}
if (result.applicationProvider === 'dingtalk-ent-app') {
bindUser.value.appName = '钉钉'
} else if (result.applicationProvider === 'wechat-webapp') {
bindUser.value.appName = '微信'
} else {
bindUser.value.appName = result.applicationName
if(success){
if (result?.applicationProvider === 'dingtalk-ent-app') {
bindUser.value.appName = '钉钉'
} else if (result?.applicationProvider === 'wechat-webapp') {
bindUser.value.appName = '微信'
} else {
bindUser.value.appName = result?.applicationName
}
}
}
@ -239,7 +242,11 @@ const getCode = async () => {
captcha.value.key = res.result?.key
}
const RsaConfig = reactive<any>({
enabled:false, //
publicKey:'', //rsa,使
id:'' //ID
})
/**
* 登录并绑定账户
*/
@ -252,14 +259,25 @@ const handleLoginBind = () => {
bindCode: code,
expires: 3600000
}
const resq:any = await authLoginConfig()
if(resq.status === 200){
if(resq.result?.encrypt){
RsaConfig.enabled = resq.result?.encrypt.enabled
RsaConfig.publicKey = resq.result?.encrypt.publicKey
RsaConfig.id = resq.result?.encrypt.id
}
}
if (captcha.value.base64) {
params.verifyKey = captcha.value.key
} else {
delete params.verifyCode
}
const res = await authLogin(params)
const data = {
...params,
password:RsaConfig.enabled?encrypt(params.password,RsaConfig.publicKey):params.password,
encryptId:RsaConfig.enabled?RsaConfig.id:undefined
}
const res = await authLogin(data)
console.log('res: ', res)
if (res.success) {
onlyMessage('登录成功')
@ -273,11 +291,26 @@ const handleLoginBind = () => {
})
}
const getQueryVariable = (): Map<string, string> => {
const index = window.location.href.indexOf('?')
const paramsUrl = window.location.href.substr(index + 1)
const paramsArr = paramsUrl.split('#')?.[0] || ''
const vars = paramsArr.split('&');
const maps = new Map()
for (let i = 0; i < vars.length; i++) {
const pair = vars[i].split('=');
const [key, value] = pair
maps.set(key, value)
}
return maps;
}
/**
* 绑定成功跳转至页面url的: redirect
*/
const goRedirect = () => {
const urlParams = new URLSearchParams(window.location.hash)
const urlParams = getQueryVariable();
const redirectUrl =
urlParams.get('redirect') ||
window.location.href.split('redirect=')?.[1]

View File

@ -21,8 +21,6 @@
:load-data="onLoadData"
@check="onCheck"
v-model:expandedKeys="expandedKeys"
:showLine="{ showLeafIcon: false }"
:show-icon="true"
/>
</j-card>
<div style="width: 100px">

View File

@ -21,8 +21,6 @@
:load-data="onLoadData"
@check="onCheck"
v-model:expandedKeys="expandedKeys"
:showLine="{ showLeafIcon: false }"
:show-icon="true"
/>
</j-card>
<div style="width: 100px">

View File

@ -19,8 +19,6 @@
:tree-data="dataSource"
:checkedKeys="checkedKeys"
@check="onCheck"
:showLine="{ showLeafIcon: false }"
:show-icon="true"
/>
</j-card>
<div style="width: 100px">

View File

@ -74,10 +74,11 @@
<script setup lang='ts' name='Oauth'>
import { TOKEN_KEY } from '@/utils/variable'
import { config, code, getOAuth2, initApplication, authLogin, settingDetail } from '@/api/login'
import { config, code, getOAuth2, initApplication, authLogin, settingDetail,authLoginConfig } from '@/api/login'
import { getMe_api } from '@/api/home'
import { getImage, getToken } from '@/utils/comm'
import Config from '../../../config/config'
import {encrypt} from '@/utils/encrypt'
const spinning = ref(true)
const isLogin = ref(false)
@ -193,11 +194,27 @@ const getQueryVariable = (): Map<string, string> => {
return maps;
}
const RsaConfig = reactive<any>({
enabled:false, //
publicKey:'', //rsa,使
id:'' //ID
})
const doLogin = () => {
formRef.value.validate().then( async data => {
const res = await authLogin({
const resq:any = await authLoginConfig()
if(resq.status === 200){
if(resq.result?.encrypt){
RsaConfig.enabled = resq.result?.encrypt.enabled
RsaConfig.publicKey = resq.result?.encrypt.publicKey
RsaConfig.id = resq.result?.encrypt.id
}
}
const res:any = await authLogin({
verifyKey: captcha.key,
...formModel
...formModel,
password:RsaConfig.enabled?encrypt(formModel.password,RsaConfig.publicKey):formModel.password,
encryptId:RsaConfig.enabled?RsaConfig.id:undefined
})
if (res.success) {
const token = res.result.token

View File

@ -38,8 +38,6 @@
:height='450'
:virtual='true'
@select='treeSelect'
:showLine="{ showLeafIcon: false }"
:show-icon="true"
>
<template #title="{ name, description }">
<j-space>

View File

@ -55,8 +55,6 @@
:height='450'
:virtual='true'
@select='treeSelect'
:showLine="{ showLeafIcon: false }"
:show-icon="true"
>
<template #title="{ name, description }">
<j-space>

View File

@ -33,8 +33,6 @@
:fieldNames="{ key: 'code', title: 'name' }"
@check="treeCheck"
:height="300"
:showLine="{ showLeafIcon: false }"
:show-icon="true"
>
<template #title="{ name }">
<span>{{ name }}</span>

View File

@ -21,8 +21,6 @@
:selectedKeys="selectedKeys"
@drop="onDrop"
@dragend="onDragend"
:showLine="{ showLeafIcon: false }"
:show-icon="true"
>
<template #title="row">
<div class="tree-content">