feat: application assess (#3312)

This commit is contained in:
shaohuzhang1 2025-06-19 17:25:46 +08:00 committed by GitHub
parent 046e1c72d6
commit e02d417af9
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
7 changed files with 110 additions and 24 deletions

View File

@ -33,6 +33,8 @@ class AccessTokenEditSerializer(serializers.Serializer):
label=_("Whitelist")),
show_source = serializers.BooleanField(required=False,
label=_("Whether to display knowledge sources"))
show_exec = serializers.BooleanField(required=False,
label=_("Display execution details"))
language = serializers.CharField(required=False, allow_blank=True, allow_null=True,
label=_("language"))
authentication = serializers.BooleanField(default=False, label="Do you need authentication")
@ -60,6 +62,8 @@ class AccessTokenSerializer(serializers.Serializer):
application_access_token.white_list = instance.get('white_list')
if 'show_source' in instance and instance.get('show_source') is not None:
application_access_token.show_source = instance.get('show_source')
if 'show_exec' in instance and instance.get('show_exec') is not None:
application_access_token.show_exec = instance.get('show_exec')
if 'language' in instance and instance.get('language') is not None:
application_access_token.language = instance.get('language')
if 'language' not in instance or instance.get('language') is None:

View File

@ -8349,3 +8349,15 @@ msgstr ""
msgid "Application Access"
msgstr ""
msgid "Display execution details"
msgstr ""
msgid "LOCAL"
msgstr "Account login"
msgid "CAS"
msgstr "CAS"
msgid "LDAP"
msgstr "LDAP"

View File

@ -8475,3 +8475,15 @@ msgstr "更新外观设置"
msgid "Application Access"
msgstr "应用接入"
msgid "Display execution details"
msgstr "是否显示执行详情"
msgid "LOCAL"
msgstr "账号登录"
msgid "CAS"
msgstr "CAS"
msgid "LDAP"
msgstr "LDAP"

View File

@ -8475,3 +8475,15 @@ msgstr "更新外觀設置"
msgid "Application Access"
msgstr "應用介入"
msgid "Display execution details"
msgstr "是否顯示執行詳情"
msgid "LOCAL"
msgstr "帳號登入"
msgid "CAS"
msgstr "CAS"
msgid "LDAP"
msgstr "LDAP"

View File

@ -92,6 +92,18 @@ const getAccessToken: (application_id: string, loading?: Ref<boolean>) => Promis
) => {
return get(`${prefix.value}/${application_id}/access_token`, undefined, loading)
}
/**
*
* @param application_id id
* @param loading
* @returns
*/
const getApplicationSetting: (
application_id: string,
loading?: Ref<boolean>,
) => Promise<Result<any>> = (application_id, loading) => {
return get(`${prefix.value}/${application_id}/setting`, undefined, loading)
}
/**
* AccessToken
@ -167,7 +179,14 @@ const open: (application_id: string, loading?: Ref<boolean>) => Promise<Result<s
const chat: (chat_id: string, data: any) => Promise<any> = (chat_id, data) => {
return postStream(`/api/chat_message/${chat_id}`, data)
}
/**
*
* @param loading
* @returns
*/
const getChatUserAuthType: (loading?: Ref<boolean>) => Promise<any> = (loading) => {
return get(`/chat_user/auth/types`, {}, loading)
}
export default {
getAllApplication,
getApplication,
@ -182,4 +201,6 @@ export default {
getStatistics,
open,
chat,
getChatUserAuthType,
getApplicationSetting,
}

View File

@ -331,7 +331,13 @@ function openDisplaySettingDialog() {
currentDisplaySettingDialog.value = DisplaySettingDialog
}
nextTick(() => {
if (currentDisplaySettingDialog.value == XPackDisplaySettingDialog) {
applicationApi.getApplicationSetting(id).then((ok) => {
DisplaySettingDialogRef.value?.open(ok.data, detail.value)
})
} else {
DisplaySettingDialogRef.value?.open(accessToken.value, detail.value)
}
})
}

View File

@ -30,8 +30,16 @@
<el-form-item :label="$t('views.applicationOverview.appInfo.LimitDialog.authentication')">
<el-switch size="small" v-model="form.authentication" @change="firstGeneration"></el-switch>
</el-form-item>
<el-radio-group v-if="form.authentication" v-model="form.method" class="card__radio">
<el-card shadow="never" class="mb-16" :class="form.method === 'replace' ? 'active' : ''">
<el-radio-group
v-if="form.authentication"
v-model="form.authentication_value.type"
class="card__radio"
>
<el-card
shadow="never"
class="mb-16"
:class="form.authentication_value.type === 'password' ? 'active' : ''"
>
<el-radio value="replace" size="large">
<p class="mb-4 lighter">
{{ $t('views.applicationOverview.appInfo.LimitDialog.authenticationValue') }}
@ -40,7 +48,7 @@
<el-form-item class="ml-24">
<el-input
class="authentication-append-input"
v-model="form.authentication_value"
v-model="form.authentication_value.password_value"
readonly
style="width: 268px"
>
@ -69,9 +77,12 @@
</el-input>
</el-form-item>
</el-card>
<el-card shadow="never" class="mb-16" :class="form.method === 'complete' ? 'active' : ''">
<el-radio value="complete" size="large">
<el-card
shadow="never"
class="mb-16"
:class="form.authentication_value.type === 'login' ? 'active' : ''"
>
<el-radio value="login" size="large">
<p class="mb-16 lighter">
{{ $t('views.system.authentication.title') }}
<el-button type="primary" link @click="router.push({ path: '' })">
@ -88,18 +99,14 @@
trigger: 'change',
},
]"
prop="checkList"
prop="authentication_value.login_value"
class="ml-24 border-t"
style="padding-top: 16px"
>
<el-checkbox-group v-model="form.checkList">
<el-checkbox label="账号登录" value="账号登录" />
<el-checkbox label="LDAP" value="LDAP" />
<el-checkbox label="OIDC" value="OIDC" />
<el-checkbox label="CAS" value="CAS" />
<el-checkbox label="企业微信" value="企业微信" />
<el-checkbox label="钉钉" value="钉钉" />
<el-checkbox label="飞书" value="飞书" />
<el-checkbox-group v-model="form.authentication_value.login_value">
<template v-for="t in auth_list" :key="t.value">
<el-checkbox :label="t.label" :value="t.value" />
</template>
</el-checkbox-group>
</el-form-item>
</el-card>
@ -146,13 +153,13 @@ const {
} = route
const emit = defineEmits(['refresh'])
const auth_list = ref<Array<{ label: string; value: string }>>([])
const limitFormRef = ref()
const form = ref<any>({
access_num: 0,
white_active: true,
white_list: '',
authentication_value: '',
authentication_value: {},
authentication: false,
})
@ -168,7 +175,16 @@ watch(dialogVisible, (bool) => {
}
}
})
watch(
() => form.authentication,
(b) => {
if (b) {
applicationApi.getChatUserAuthType().then((ok) => {
auth_list.value = ok.data
})
}
},
)
const open = (data: any) => {
form.value.access_num = data.access_num
form.value.white_active = data.white_active
@ -176,6 +192,9 @@ const open = (data: any) => {
form.value.authentication_value = data.authentication_value
form.value.authentication = data.authentication
dialogVisible.value = true
applicationApi.getChatUserAuthType().then((ok) => {
auth_list.value = ok.data
})
}
const submit = async (formEl: FormInstance | undefined) => {
@ -207,7 +226,7 @@ function generateAuthenticationValue(length: number = 10) {
.join('')
}
function refreshAuthentication() {
form.value.authentication_value = generateAuthenticationValue()
form.value.authentication_value.password_value = generateAuthenticationValue()
}
function firstGeneration() {