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" 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"
> >

View File

@ -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':

View File

@ -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: ''
} }

View File

@ -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) {