refactor: reuse global aliyun moderation config
This commit is contained in:
@@ -14,16 +14,13 @@
|
||||
placeholder="请输入服务商"
|
||||
/>
|
||||
</n-form-item>
|
||||
<n-form-item label="端点">
|
||||
<n-form-item v-if="!isModeration" label="端点">
|
||||
<n-input v-model:value="formValue.endpoint" placeholder="请输入服务端点" />
|
||||
</n-form-item>
|
||||
<n-form-item label="启用">
|
||||
<n-switch v-model:value="enabledValue" />
|
||||
</n-form-item>
|
||||
<template v-if="isModeration">
|
||||
<n-form-item label="地域"
|
||||
><n-input v-model:value="moderationConfig.region_id"
|
||||
/></n-form-item>
|
||||
<n-form-item label="昵称服务"
|
||||
><n-input v-model:value="moderationConfig.nickname_service"
|
||||
/></n-form-item>
|
||||
@@ -40,20 +37,6 @@
|
||||
></n-radio-group
|
||||
></n-form-item
|
||||
>
|
||||
<n-form-item label="AccessKey ID"
|
||||
><n-input
|
||||
v-model:value="moderationSecret.access_key_id"
|
||||
type="password"
|
||||
show-password-on="click"
|
||||
placeholder="留空保持原值"
|
||||
/></n-form-item>
|
||||
<n-form-item label="AccessKey Secret"
|
||||
><n-input
|
||||
v-model:value="moderationSecret.access_key_secret"
|
||||
type="password"
|
||||
show-password-on="click"
|
||||
placeholder="留空保持原值"
|
||||
/></n-form-item>
|
||||
</template>
|
||||
<n-form-item v-else label="普通配置">
|
||||
<n-input
|
||||
@@ -109,13 +92,11 @@
|
||||
});
|
||||
const isModeration = computed(() => formValue.value.service === 'moderation');
|
||||
const moderationConfig = ref<any>({
|
||||
region_id: 'cn-shanghai',
|
||||
nickname_service: 'nickname_detection_pro',
|
||||
chat_service: 'chat_detection_pro',
|
||||
timeout_ms: 1500,
|
||||
failure_mode: 'allow',
|
||||
});
|
||||
const moderationSecret = ref<any>({ access_key_id: '', access_key_secret: '' });
|
||||
|
||||
function closeForm() {
|
||||
showModal.value = false;
|
||||
@@ -138,9 +119,7 @@
|
||||
? moderationConfig.value
|
||||
: parseJson(formValue.value.configJson || '{}', '普通配置') || {};
|
||||
const secretJson = isModeration.value
|
||||
? moderationSecret.value.access_key_id || moderationSecret.value.access_key_secret
|
||||
? moderationSecret.value
|
||||
: null
|
||||
? null
|
||||
: parseJson(formValue.value.secretJson, '敏感配置');
|
||||
await Update({
|
||||
tenantId: formValue.value.tenantId,
|
||||
@@ -167,12 +146,11 @@
|
||||
if (!formValue.value.configJson) formValue.value.configJson = '{}';
|
||||
if (formValue.value.service === 'moderation') {
|
||||
formValue.value.provider = 'aliyun_green';
|
||||
formValue.value.endpoint ||= 'green-cip.cn-shanghai.aliyuncs.com';
|
||||
formValue.value.endpoint = '';
|
||||
moderationConfig.value = {
|
||||
...moderationConfig.value,
|
||||
...(parseJson(formValue.value.configJson, '普通配置') || {}),
|
||||
};
|
||||
moderationSecret.value = { access_key_id: '', access_key_secret: '' };
|
||||
}
|
||||
showModal.value = true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user