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 checkable
@check="onCheck" @check="onCheck"
:height="600" :height="600"
:showLine="{ showLeafIcon: false }"
:show-icon="true"
> >
<template #title="{ name, key }"> <template #title="{ name, key }">
<span <span

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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