refactor: 优化代码

This commit is contained in:
wxg0103 2024-10-28 19:07:59 +08:00
parent 80415c9372
commit 0147a3efd0
4 changed files with 16 additions and 8 deletions

View File

@ -5,7 +5,7 @@
v-model="dialogVisible"
:close-on-click-modal="false"
:close-on-press-escape="false"
destroy-on-close
:destroy-on-close="true"
align-center
class="display-setting-dialog"
>

View File

@ -1,6 +1,6 @@
template
<template>
<el-drawer v-model="visible" size="60%" :append-to-body="true" destroy-on-close>
<el-drawer v-model="visible" size="60%" :append-to-body="true" :destroy-on-close="true">
<template #header>
<div class="flex align-center" style="margin-left: -8px">
<h4>{{ currentPlatform.name + '设置' }}</h4>
@ -112,11 +112,13 @@ const open = async (platform: Platform) => {
// callback_url
let defaultCallbackUrl = window.location.origin
// callback_url
switch (platform.key) {
case 'wecom':
case 'dingtalk':
if (currentPlatform.config.agent_id) {
currentPlatform.config.corp_id = currentPlatform.config.agent_id
delete currentPlatform.config.agent_id
}
currentPlatform.config.callback_url = defaultCallbackUrl
break
case 'lark':

View File

@ -130,8 +130,8 @@ function createPlatform(key: string, name: string): Platform {
}
const config = {
...(key === 'dingtalk' ? { corp_id: '' } : {}),
...(key === 'wecom' ? { corp_id: '', agent_id: '' } : { app_key: '' }),
...(key === 'dingtalk' ? { agent_id: '' } : {}),
app_secret: '',
callback_url: ''
}

View File

@ -13,6 +13,7 @@ import { useRouter } from 'vue-router'
import { useScriptTag } from '@vueuse/core'
import { defineProps, onMounted, ref } from 'vue'
import useStore from '@/stores'
import { MsgError } from '@/utils/message'
// DTFrameLogin QRLogin
declare global {
@ -65,6 +66,7 @@ const props = defineProps<{
config: {
app_secret: string
app_key: string
agent_id?: string
}
}>()
@ -82,8 +84,10 @@ const initActive = async () => {
const data = {
appKey: props.config.app_key,
appSecret: props.config.app_secret
appSecret: props.config.app_secret,
agent_id: props.config.agent_id
}
console.log(props.config)
const redirectUri = encodeURIComponent(window.location.origin)
@ -99,7 +103,9 @@ const initActive = async () => {
scope: 'openid',
response_type: 'code',
state: 'fit2cloud-ding-qr',
prompt: 'consent'
prompt: 'consent',
exclusiveLogin: 'true',
exclusiveCorpId: 'ding7fd29779c8cf3e0224f2f5cc6abecb85'
},
(loginResult) => {
const authCode = loginResult.authCode
@ -108,7 +114,7 @@ const initActive = async () => {
})
},
(errorMsg: string) => {
console.error(errorMsg)
MsgError(errorMsg)
}
)
} catch (error) {