更新模型类型字段名称,统一为 modelType,以提高代码一致性和可读性。涉及多个组件和接口的相应调整,确保功能正常。

This commit is contained in:
2026-05-12 16:43:46 +08:00
parent 75cc91a4fb
commit 77aaeebf1d
5 changed files with 41 additions and 33 deletions

View File

@@ -4,7 +4,7 @@ export interface ModelModuleListParams {
pageNum?: number; pageNum?: number;
pageSize?: number; pageSize?: number;
modelName?: string; modelName?: string;
modelsType?: number | string; modelType?: number | string;
} }
export interface ModelFormItem { export interface ModelFormItem {
@@ -23,7 +23,7 @@ export interface ModelFormEntry {
export interface ModelTypeListItem { export interface ModelTypeListItem {
id?: number | string; id?: number | string;
typeId?: number | string; typeId?: number | string;
modelsType?: number | string; modelType?: number | string;
name?: string; name?: string;
typeName?: string; typeName?: string;
label?: string; label?: string;
@@ -55,7 +55,7 @@ export function normalizeModelTypeOptions(res: { data?: unknown }): Array<{ id:
const arr: ModelTypeListItem[] = Array.isArray(raw) ? raw : ((raw as { list?: ModelTypeListItem[] })?.list ?? []); const arr: ModelTypeListItem[] = Array.isArray(raw) ? raw : ((raw as { list?: ModelTypeListItem[] })?.list ?? []);
return arr return arr
.map((item) => { .map((item) => {
const id = item.id ?? item.typeId ?? item.modelsType; const id = item.id ?? item.typeId ?? item.modelType;
const label = item.name ?? item.typeName ?? item.label ?? (id != null && id !== '' ? String(id) : ''); const label = item.name ?? item.typeName ?? item.label ?? (id != null && id !== '' ? String(id) : '');
return { id: id as number | string, label: label || String(id) }; return { id: id as number | string, label: label || String(id) };
}) })
@@ -73,7 +73,7 @@ export interface ModelModuleItem {
isDeleted?: boolean; isDeleted?: boolean;
modelName: string; modelName: string;
/** 模型类型 ID与 listType 返回项对应 */ /** 模型类型 ID与 listType 返回项对应 */
modelsType?: number | string; modelType?: number | string;
baseUrl: string; baseUrl: string;
route?: string; route?: string;
httpMethod: string; httpMethod: string;
@@ -110,7 +110,7 @@ export interface ModelModuleListResponse {
export interface CreateModelParams { export interface CreateModelParams {
modelName: string; modelName: string;
/** 与 listType 返回的类型 id 一致,可能为数字或字符串 */ /** 与 listType 返回的类型 id 一致,可能为数字或字符串 */
modelsType: number | string; modelType: number | string;
baseUrl: string; baseUrl: string;
httpMethod?: string; httpMethod?: string;
headMsg?: string; headMsg?: string;

View File

@@ -23,7 +23,7 @@
@click="handleSelectModel(model)" @click="handleSelectModel(model)"
> >
<div class="model-card-header"> <div class="model-card-header">
<div class="model-type">{{ getModelTypeName(model.modelsType) }}</div> <div class="model-type">{{ getModelTypeName(model.modelType) }}</div>
<div class="model-badges"> <div class="model-badges">
<el-tag v-if="!model.apiKey" type="warning" size="small">内置模型</el-tag> <el-tag v-if="!model.apiKey" type="warning" size="small">内置模型</el-tag>
<el-icon v-if="selectedModel?.id === model.id" class="check-icon" color="#67c23a"><CircleCheck /></el-icon> <el-icon v-if="selectedModel?.id === model.id" class="check-icon" color="#67c23a"><CircleCheck /></el-icon>
@@ -101,7 +101,7 @@ interface ModelItem {
id: string; id: string;
tenantId?: number; tenantId?: number;
modelName: string; modelName: string;
modelsType: number; modelType: number;
baseUrl: string; baseUrl: string;
route: string; route: string;
httpMethod: string; httpMethod: string;
@@ -264,7 +264,7 @@ const handleCreatePrivateModel = async () => {
const systemModel = systemModelToClone.value; const systemModel = systemModelToClone.value;
const createParams = { const createParams = {
modelName: apiKeyForm.modelName, modelName: apiKeyForm.modelName,
modelsType: systemModel.modelsType, modelType: systemModel.modelType,
baseUrl: systemModel.baseUrl, baseUrl: systemModel.baseUrl,
httpMethod: systemModel.httpMethod || 'POST', httpMethod: systemModel.httpMethod || 'POST',
headMsg: systemModel.headMsg || '', headMsg: systemModel.headMsg || '',

View File

@@ -445,7 +445,12 @@
<div class="workflow-list-vertical" v-loading="workflowListLoading"> <div class="workflow-list-vertical" v-loading="workflowListLoading">
<el-empty v-if="!workflowListLoading && templateWorkflowList.length === 0" description="暂无模板" :image-size="60" /> <el-empty v-if="!workflowListLoading && templateWorkflowList.length === 0" description="暂无模板" :image-size="60" />
<div v-else class="workflow-list-scroll"> <div v-else class="workflow-list-scroll">
<div v-for="workflow in templateWorkflowList" :key="workflow.id" class="workflow-item" @click="isSuperAdmin ? editWorkflow(workflow) : useWorkflow(workflow)"> <div
v-for="workflow in templateWorkflowList"
:key="workflow.id"
class="workflow-item"
@click="isSuperAdmin ? editWorkflow(workflow) : useWorkflow(workflow)"
>
<div class="workflow-item-content"> <div class="workflow-item-content">
<div class="workflow-item-name">{{ workflow.flowName || workflow.flowTemplateName }}</div> <div class="workflow-item-name">{{ workflow.flowName || workflow.flowTemplateName }}</div>
<div class="workflow-item-desc">{{ workflow.description || '暂无描述' }}</div> <div class="workflow-item-desc">{{ workflow.description || '暂无描述' }}</div>
@@ -520,12 +525,14 @@
v-for="model in filteredChatModels" v-for="model in filteredChatModels"
:key="model.id" :key="model.id"
class="chat-model-card" class="chat-model-card"
:class="{ selected: selectedChatModel?.id === model.id }" :class="{ selected: selectedChatModel?.id === model.id, 'is-chat-model': model.isChatModel === 1 }"
@click="selectedChatModel = model" @click="selectedChatModel = model"
> >
<div class="chat-model-name">{{ model.modelName }}</div> <div class="chat-model-name">{{ model.modelName }}</div>
<div class="chat-model-url">{{ model.baseUrl }}</div> <div class="chat-model-url">{{ model.baseUrl }}</div>
<el-icon v-if="selectedChatModel?.id === model.id" class="check-icon" color="#67c23a"><CircleCheck /></el-icon> <el-icon v-if="selectedChatModel?.id === model.id || model.isChatModel === 1" class="check-icon" color="#67c23a"
><CircleCheck
/></el-icon>
</div> </div>
</div> </div>
</div> </div>
@@ -1010,7 +1017,7 @@ const fetchChatModelList = async () => {
const res: any = await getModelModuleList({ const res: any = await getModelModuleList({
pageNum: chatModelPagination.pageNum, pageNum: chatModelPagination.pageNum,
pageSize: chatModelPagination.pageSize, pageSize: chatModelPagination.pageSize,
modelsType: 1, // 传递 modelsType=1 给后端,获取推理模型 modelType: 1, // 传递 modelType=1 给后端,获取推理模型
modelName: chatModelSearchKeyword.value || undefined, modelName: chatModelSearchKeyword.value || undefined,
}); });
chatModelList.value = res.data?.list || []; chatModelList.value = res.data?.list || [];
@@ -2385,7 +2392,7 @@ onMounted(async () => {
initLogicFlow(); initLogicFlow();
await getNodeLibrary(); await getNodeLibrary();
await fetchWorkflowList(); await fetchWorkflowList();
// 获取当前用户角色 // 获取当前用户角色
try { try {
const res: any = await checkIsSuperAdmin(); const res: any = await checkIsSuperAdmin();
@@ -3562,7 +3569,8 @@ onBeforeUnmount(() => {
box-shadow: 0 4px 12px rgba(59, 130, 246, 0.2); box-shadow: 0 4px 12px rgba(59, 130, 246, 0.2);
transform: translateY(-2px); transform: translateY(-2px);
} }
.chat-model-card.selected { .chat-model-card.selected,
.chat-model-card.is-chat-model {
border-color: #67c23a; border-color: #67c23a;
background: linear-gradient(135deg, #f0f9ff 0%, #e0f2fe 100%); background: linear-gradient(135deg, #f0f9ff 0%, #e0f2fe 100%);
box-shadow: 0 4px 12px rgba(103, 194, 58, 0.2); box-shadow: 0 4px 12px rgba(103, 194, 58, 0.2);

View File

@@ -17,8 +17,8 @@
</el-form-item> </el-form-item>
</el-col> </el-col>
<el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12" class="mb20"> <el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12" class="mb20">
<el-form-item label="模型类型" prop="modelsType"> <el-form-item label="模型类型" prop="modelType">
<el-select v-model="state.ruleForm.modelsType" placeholder="请选择模型类型" clearable style="width: 100%"> <el-select v-model="state.ruleForm.modelType" placeholder="请选择模型类型" clearable style="width: 100%">
<el-option v-for="t in modelTypeOptions" :key="String(t.id)" :label="t.label" :value="typeOptionValue(t.id)"></el-option> <el-option v-for="t in modelTypeOptions" :key="String(t.id)" :label="t.label" :value="typeOptionValue(t.id)"></el-option>
</el-select> </el-select>
</el-form-item> </el-form-item>
@@ -279,7 +279,7 @@ const state = reactive({
ruleForm: { ruleForm: {
id: '', id: '',
modelName: '', modelName: '',
modelsType: null as number | string | null, modelType: null as number | string | null,
baseUrl: '', baseUrl: '',
httpMethod: 'POST', httpMethod: 'POST',
headMsg: '', headMsg: '',
@@ -299,7 +299,7 @@ const state = reactive({
}, },
rules: { rules: {
modelName: [{ required: true, message: '请输入模型名称', trigger: 'blur' }], modelName: [{ required: true, message: '请输入模型名称', trigger: 'blur' }],
modelsType: [ modelType: [
{ {
validator: (_rule: unknown, value: unknown, callback: (e?: Error) => void) => { validator: (_rule: unknown, value: unknown, callback: (e?: Error) => void) => {
if (value === null || value === undefined || value === '') { if (value === null || value === undefined || value === '') {
@@ -528,7 +528,7 @@ const fillFormFromDetailRow = (row: Record<string, unknown>) => {
state.ruleForm = { state.ruleForm = {
id: row.id as string, id: row.id as string,
modelName: String(row.modelName ?? ''), modelName: String(row.modelName ?? ''),
modelsType: row.modelsType !== undefined && row.modelsType !== null ? typeOptionValue(row.modelsType as number | string) : null, modelType: row.modelType !== undefined && row.modelType !== null ? typeOptionValue(row.modelType as number | string) : null,
baseUrl: String(row.baseUrl ?? ''), baseUrl: String(row.baseUrl ?? ''),
httpMethod: String(row.httpMethod || 'POST'), httpMethod: String(row.httpMethod || 'POST'),
headMsg: String(row.headMsg || ''), headMsg: String(row.headMsg || ''),
@@ -605,7 +605,7 @@ const openDialog = async (type: string, row?: Record<string, unknown>) => {
state.ruleForm = { state.ruleForm = {
id: '', id: '',
modelName: '', modelName: '',
modelsType: null, modelType: null,
baseUrl: '', baseUrl: '',
httpMethod: 'POST', httpMethod: 'POST',
headMsg: '', headMsg: '',
@@ -659,7 +659,7 @@ const onSubmit = () => {
const responseBody = responseBodyField ? { [responseBodyField.key.trim()]: responseBodyField.value } : {}; const responseBody = responseBodyField ? { [responseBodyField.key.trim()]: responseBodyField.value } : {};
const submitData = { const submitData = {
modelName: state.ruleForm.modelName, modelName: state.ruleForm.modelName,
modelsType: state.ruleForm.modelsType as number | string, modelType: state.ruleForm.modelType as number | string,
baseUrl: state.ruleForm.baseUrl, baseUrl: state.ruleForm.baseUrl,
httpMethod: state.ruleForm.httpMethod || 'POST', httpMethod: state.ruleForm.httpMethod || 'POST',
headMsg: state.ruleForm.headMsg, headMsg: state.ruleForm.headMsg,

View File

@@ -32,7 +32,7 @@
<el-table-column prop="modelName" label="模型名称" show-overflow-tooltip></el-table-column> <el-table-column prop="modelName" label="模型名称" show-overflow-tooltip></el-table-column>
<el-table-column label="模型类型" width="120" show-overflow-tooltip> <el-table-column label="模型类型" width="120" show-overflow-tooltip>
<template #default="{ row }"> <template #default="{ row }">
{{ resolveModelTypeLabel(row.modelsType) }} {{ resolveModelTypeLabel(row.modelType) }}
</template> </template>
</el-table-column> </el-table-column>
<!-- <el-table-column prop="baseUrl" label="模型服务地址" show-overflow-tooltip width="200"></el-table-column> --> <!-- <el-table-column prop="baseUrl" label="模型服务地址" show-overflow-tooltip width="200"></el-table-column> -->
@@ -59,7 +59,7 @@
<!-- 非管理员才显示会话模型按钮 --> <!-- 非管理员才显示会话模型按钮 -->
<template v-if="!isSuperAdmin"> <template v-if="!isSuperAdmin">
<el-button <el-button
v-if="isInferenceModel(scope.row.modelsType) && Number(scope.row.isChatModel) !== 1" v-if="isInferenceModel(scope.row.modelType) && Number(scope.row.isChatModel) !== 1"
size="small" size="small"
text text
type="warning" type="warning"
@@ -68,7 +68,7 @@
设为会话模型 设为会话模型
</el-button> </el-button>
<el-tag <el-tag
v-if="isInferenceModel(scope.row.modelsType) && Number(scope.row.isChatModel) === 1" v-if="isInferenceModel(scope.row.modelType) && Number(scope.row.isChatModel) === 1"
type="success" type="success"
effect="dark" effect="dark"
size="default" size="default"
@@ -181,13 +181,13 @@ const checkAdminStatus = async () => {
}; };
// 判断是否为推理模型(只有推理模型才能设置为会话模型) // 判断是否为推理模型(只有推理模型才能设置为会话模型)
const isInferenceModel = (modelsType: number | string | undefined | null) => { const isInferenceModel = (modelType: number | string | undefined | null) => {
if (modelsType === undefined || modelsType === null || modelsType === '') { if (modelType === undefined || modelType === null || modelType === '') {
return false; return false;
} }
// 查找模型类型标签,判断是否为"推理模型" // 查找模型类型标签,判断是否为"推理模型"
const typeInfo = state.modelTypes.find((t) => String(t.id) === String(modelsType)); const typeInfo = state.modelTypes.find((t) => String(t.id) === String(modelType));
return typeInfo?.label === '推理模型' || String(modelsType) === '1'; return typeInfo?.label === '推理模型' || String(modelType) === '1';
}; };
// 设置为会话模型 // 设置为会话模型
@@ -227,7 +227,7 @@ const handleCreatePrivateModelAndSetChat = async () => {
const systemModel = systemModelToClone.value; const systemModel = systemModelToClone.value;
const createParams = { const createParams = {
modelName: apiKeyForm.modelName, modelName: apiKeyForm.modelName,
modelsType: systemModel.modelsType, modelType: systemModel.modelType,
baseUrl: systemModel.baseUrl, baseUrl: systemModel.baseUrl,
httpMethod: systemModel.httpMethod || 'POST', httpMethod: systemModel.httpMethod || 'POST',
headMsg: systemModel.headMsg || '', headMsg: systemModel.headMsg || '',
@@ -266,12 +266,12 @@ const handleCreatePrivateModelAndSetChat = async () => {
} }
}; };
const resolveModelTypeLabel = (modelsType: number | string | undefined | null) => { const resolveModelTypeLabel = (modelType: number | string | undefined | null) => {
if (modelsType === undefined || modelsType === null || modelsType === '') { if (modelType === undefined || modelType === null || modelType === '') {
return '—'; return '—';
} }
const hit = state.modelTypes.find((t) => String(t.id) === String(modelsType)); const hit = state.modelTypes.find((t) => String(t.id) === String(modelType));
return hit?.label ?? String(modelsType); return hit?.label ?? String(modelType);
}; };
const loadModelTypes = async () => { const loadModelTypes = async () => {