Merge remote-tracking branch 'origin/dev' into dev

This commit is contained in:
cherishsince 2024-05-18 22:03:00 +08:00
commit 264cad5301
3 changed files with 49 additions and 48 deletions

View File

@ -71,9 +71,9 @@ export const useFormCreateDesigner = async (designer: Ref) => {
*/ */
const buildSystemMenu = () => { const buildSystemMenu = () => {
// 移除自带的下拉选择器组件,使用 currencySelectRule 替代 // 移除自带的下拉选择器组件,使用 currencySelectRule 替代
designer.value?.removeMenuItem('select') // designer.value?.removeMenuItem('select')
designer.value?.removeMenuItem('radio') // designer.value?.removeMenuItem('radio')
designer.value?.removeMenuItem('checkbox') // designer.value?.removeMenuItem('checkbox')
const components = [userSelectRule, deptSelectRule, dictSelectRule, apiSelectRule0] const components = [userSelectRule, deptSelectRule, dictSelectRule, apiSelectRule0]
const menu: Menu = { const menu: Menu = {
name: 'system', name: 'system',

View File

@ -48,13 +48,29 @@
</el-radio-group> </el-radio-group>
</el-form-item> </el-form-item>
<el-form-item label="温度参数" prop="temperature"> <el-form-item label="温度参数" prop="temperature">
<el-input v-model="formData.temperature" placeholder="请输入温度参数" /> <el-input-number
v-model="formData.temperature"
placeholder="请输入温度参数"
:min="0"
:max="2"
:precision="2"
/>
</el-form-item> </el-form-item>
<el-form-item label="回复数 Token 数" prop="maxTokens"> <el-form-item label="回复数 Token 数" prop="maxTokens">
<el-input v-model="formData.maxTokens" placeholder="请输入回复数 Token 数" /> <el-input-number
v-model="formData.maxTokens"
placeholder="请输入回复数 Token 数"
:min="0"
:max="4096"
/>
</el-form-item> </el-form-item>
<el-form-item label="上下文数量" prop="maxContexts"> <el-form-item label="上下文数量" prop="maxContexts">
<el-input v-model="formData.maxContexts" placeholder="请输入上下文数量" /> <el-input-number
v-model="formData.maxContexts"
placeholder="请输入上下文数量"
:min="0"
:max="20"
/>
</el-form-item> </el-form-item>
</el-form> </el-form>
<template #footer> <template #footer>

View File

@ -32,9 +32,6 @@
<el-form-item label="角色设定" prop="systemMessage"> <el-form-item label="角色设定" prop="systemMessage">
<el-input type="textarea" v-model="formData.systemMessage" placeholder="请输入角色设定" /> <el-input type="textarea" v-model="formData.systemMessage" placeholder="请输入角色设定" />
</el-form-item> </el-form-item>
<el-form-item label="欢迎语👏🏻" prop="welcomeMessage" v-if="isUser(formType)">
<el-input type="textarea" v-model="formData.welcomeMessage" placeholder="请输入欢迎语"/>
</el-form-item>
<el-form-item label="是否公开" prop="publicStatus" v-if="!isUser(formType)"> <el-form-item label="是否公开" prop="publicStatus" v-if="!isUser(formType)">
<el-radio-group v-model="formData.publicStatus"> <el-radio-group v-model="formData.publicStatus">
<el-radio <el-radio
@ -92,20 +89,20 @@ const formData = ref({
sort: undefined, sort: undefined,
description: undefined, description: undefined,
systemMessage: undefined, systemMessage: undefined,
welcomeMessage: undefined,
publicStatus: true, publicStatus: true,
status: CommonStatusEnum.ENABLE status: CommonStatusEnum.ENABLE
}) })
//
const isUser = (type: string) => {
return (type === 'my-create' || type === 'my-update')
}
const formRules = ref() // reactive(formRulesObj) const formRules = ref() // reactive(formRulesObj)
const formRef = ref() // Ref const formRef = ref() // Ref
const chatModelList = ref([] as ChatModelVO[]) // const chatModelList = ref([] as ChatModelVO[]) //
/** 是否【我】自己创建,私有角色 */
// TODO @fan computed
const isUser = (type: string) => {
return type === 'my-create' || type === 'my-update'
}
// TODO @fan使 formRules
const getFormRules = async (type: string) => { const getFormRules = async (type: string) => {
let formRulesObj = { let formRulesObj = {
name: [{ required: true, message: '角色名称不能为空', trigger: 'blur' }], name: [{ required: true, message: '角色名称不能为空', trigger: 'blur' }],
@ -114,22 +111,14 @@ const getFormRules = async (type: string) => {
sort: [{ required: true, message: '角色排序不能为空', trigger: 'blur' }], sort: [{ required: true, message: '角色排序不能为空', trigger: 'blur' }],
description: [{ required: true, message: '角色描述不能为空', trigger: 'blur' }], description: [{ required: true, message: '角色描述不能为空', trigger: 'blur' }],
systemMessage: [{ required: true, message: '角色设定不能为空', trigger: 'blur' }], systemMessage: [{ required: true, message: '角色设定不能为空', trigger: 'blur' }],
// welcomeMessage: [{ required: true, message: '', trigger: 'blur' }],
publicStatus: [{ required: true, message: '是否公开不能为空', trigger: 'blur' }] publicStatus: [{ required: true, message: '是否公开不能为空', trigger: 'blur' }]
} }
if (isUser(type)) {
formRulesObj['welcomeMessage'] = [{
required: true,
message: '欢迎语不能为空',
trigger: 'blur'
}]
}
formRules.value = reactive(formRulesObj) formRules.value = reactive(formRulesObj)
} }
/** 打开弹窗 */ /** 打开弹窗 */
// TODO @fantitle type title
const open = async (type: string, id?: number, title?: string) => { const open = async (type: string, id?: number, title?: string) => {
dialogVisible.value = true dialogVisible.value = true
dialogTitle.value = title || t('action.' + type) dialogTitle.value = title || t('action.' + type)
@ -159,10 +148,8 @@ const submitForm = async () => {
formLoading.value = true formLoading.value = true
try { try {
const data = formData.value as unknown as ChatRoleVO const data = formData.value as unknown as ChatRoleVO
// tip: my-createmy-update chat // tip: my-createmy-update chat
// tip: createelse // tip: createelse
if (formType.value === 'my-create') { if (formType.value === 'my-create') {
await ChatRoleApi.createMy(data) await ChatRoleApi.createMy(data)
message.success(t('common.createSuccess')) message.success(t('common.createSuccess'))
@ -184,7 +171,6 @@ const submitForm = async () => {
} }
} }
/** 重置表单 */ /** 重置表单 */
const resetForm = () => { const resetForm = () => {
formData.value = { formData.value = {
@ -196,7 +182,6 @@ const resetForm = () => {
sort: undefined, sort: undefined,
description: undefined, description: undefined,
systemMessage: undefined, systemMessage: undefined,
welcomeMessage: undefined,
publicStatus: true, publicStatus: true,
status: CommonStatusEnum.ENABLE status: CommonStatusEnum.ENABLE
} }