refactor: 优化代码
This commit is contained in:
parent
80415c9372
commit
0147a3efd0
@ -5,7 +5,7 @@
|
|||||||
v-model="dialogVisible"
|
v-model="dialogVisible"
|
||||||
:close-on-click-modal="false"
|
:close-on-click-modal="false"
|
||||||
:close-on-press-escape="false"
|
:close-on-press-escape="false"
|
||||||
destroy-on-close
|
:destroy-on-close="true"
|
||||||
align-center
|
align-center
|
||||||
class="display-setting-dialog"
|
class="display-setting-dialog"
|
||||||
>
|
>
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
template
|
template
|
||||||
<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>
|
<template #header>
|
||||||
<div class="flex align-center" style="margin-left: -8px">
|
<div class="flex align-center" style="margin-left: -8px">
|
||||||
<h4>{{ currentPlatform.name + '设置' }}</h4>
|
<h4>{{ currentPlatform.name + '设置' }}</h4>
|
||||||
@ -112,11 +112,13 @@ const open = async (platform: Platform) => {
|
|||||||
|
|
||||||
// 设置默认的 callback_url
|
// 设置默认的 callback_url
|
||||||
let defaultCallbackUrl = window.location.origin
|
let defaultCallbackUrl = window.location.origin
|
||||||
|
|
||||||
// 根据平台设置特定的 callback_url
|
|
||||||
switch (platform.key) {
|
switch (platform.key) {
|
||||||
case 'wecom':
|
case 'wecom':
|
||||||
case 'dingtalk':
|
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
|
currentPlatform.config.callback_url = defaultCallbackUrl
|
||||||
break
|
break
|
||||||
case 'lark':
|
case 'lark':
|
||||||
|
|||||||
@ -130,8 +130,8 @@ function createPlatform(key: string, name: string): Platform {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const config = {
|
const config = {
|
||||||
|
...(key === 'dingtalk' ? { corp_id: '' } : {}),
|
||||||
...(key === 'wecom' ? { corp_id: '', agent_id: '' } : { app_key: '' }),
|
...(key === 'wecom' ? { corp_id: '', agent_id: '' } : { app_key: '' }),
|
||||||
...(key === 'dingtalk' ? { agent_id: '' } : {}),
|
|
||||||
app_secret: '',
|
app_secret: '',
|
||||||
callback_url: ''
|
callback_url: ''
|
||||||
}
|
}
|
||||||
|
|||||||
@ -13,6 +13,7 @@ import { useRouter } from 'vue-router'
|
|||||||
import { useScriptTag } from '@vueuse/core'
|
import { useScriptTag } from '@vueuse/core'
|
||||||
import { defineProps, onMounted, ref } from 'vue'
|
import { defineProps, onMounted, ref } from 'vue'
|
||||||
import useStore from '@/stores'
|
import useStore from '@/stores'
|
||||||
|
import { MsgError } from '@/utils/message'
|
||||||
|
|
||||||
// 声明 DTFrameLogin 和 QRLogin 的类型
|
// 声明 DTFrameLogin 和 QRLogin 的类型
|
||||||
declare global {
|
declare global {
|
||||||
@ -65,6 +66,7 @@ const props = defineProps<{
|
|||||||
config: {
|
config: {
|
||||||
app_secret: string
|
app_secret: string
|
||||||
app_key: string
|
app_key: string
|
||||||
|
agent_id?: string
|
||||||
}
|
}
|
||||||
}>()
|
}>()
|
||||||
|
|
||||||
@ -82,8 +84,10 @@ const initActive = async () => {
|
|||||||
|
|
||||||
const data = {
|
const data = {
|
||||||
appKey: props.config.app_key,
|
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)
|
const redirectUri = encodeURIComponent(window.location.origin)
|
||||||
|
|
||||||
@ -99,7 +103,9 @@ const initActive = async () => {
|
|||||||
scope: 'openid',
|
scope: 'openid',
|
||||||
response_type: 'code',
|
response_type: 'code',
|
||||||
state: 'fit2cloud-ding-qr',
|
state: 'fit2cloud-ding-qr',
|
||||||
prompt: 'consent'
|
prompt: 'consent',
|
||||||
|
exclusiveLogin: 'true',
|
||||||
|
exclusiveCorpId: 'ding7fd29779c8cf3e0224f2f5cc6abecb85'
|
||||||
},
|
},
|
||||||
(loginResult) => {
|
(loginResult) => {
|
||||||
const authCode = loginResult.authCode
|
const authCode = loginResult.authCode
|
||||||
@ -108,7 +114,7 @@ const initActive = async () => {
|
|||||||
})
|
})
|
||||||
},
|
},
|
||||||
(errorMsg: string) => {
|
(errorMsg: string) => {
|
||||||
console.error(errorMsg)
|
MsgError(errorMsg)
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user