fix: 修复管理端前端类型校验问题

- 修正知识库与 Bot 设置页相关组件的类型定义和空值处理

- 补齐工作流与公开聊天页的前端类型约束和动态导入类型

- 收敛本次改动文件的局部格式与样式规范,确保 pnpm check:type 通过
This commit is contained in:
2026-04-05 20:36:25 +08:00
parent b5dd427920
commit bb72e19c84
15 changed files with 361 additions and 244 deletions

View File

@@ -83,21 +83,32 @@ const mdLevels = [1, 2, 3, 4, 5, 6];
const formMap = reactive<Record<string, StrategyConfig>>({});
function createDefaultStrategyConfig(item?: AnalyzeItem): StrategyConfig {
return {
chunkSize: item?.strategyConfig?.chunkSize ?? 512,
mdSplitterLevel: item?.strategyConfig?.mdSplitterLevel ?? 2,
overlapSize: item?.strategyConfig?.overlapSize ?? 128,
regex: item?.strategyConfig?.regex ?? '',
rowsPerChunk: item?.strategyConfig?.rowsPerChunk ?? 1,
strategyCode:
item?.strategyConfig?.strategyCode ||
item?.analysis?.recommendedStrategyCode ||
'AUTO',
};
}
function getStrategyForm(filePath: string, item?: AnalyzeItem): StrategyConfig {
if (!formMap[filePath]) {
formMap[filePath] = createDefaultStrategyConfig(item);
}
return formMap[filePath]!;
}
watch(
() => props.analysisItems,
(items) => {
for (const item of items || []) {
formMap[item.filePath] = {
chunkSize: item.strategyConfig?.chunkSize ?? 512,
mdSplitterLevel: item.strategyConfig?.mdSplitterLevel ?? 2,
overlapSize: item.strategyConfig?.overlapSize ?? 128,
regex: item.strategyConfig?.regex ?? '',
rowsPerChunk: item.strategyConfig?.rowsPerChunk ?? 1,
strategyCode:
item.strategyConfig?.strategyCode ||
item.analysis?.recommendedStrategyCode ||
'AUTO',
};
formMap[item.filePath] = createDefaultStrategyConfig(item);
}
},
{ immediate: true },
@@ -111,7 +122,7 @@ defineExpose({
fileName: item.fileName,
filePath: item.filePath,
strategyConfig: {
...formMap[item.filePath],
...getStrategyForm(item.filePath, item),
},
}));
},
@@ -199,7 +210,7 @@ function showLengthSettings(strategyCode?: string) {
<ElCol :span="12">
<ElForm
:model="formMap[item.filePath]"
:model="getStrategyForm(item.filePath, item)"
label-position="top"
class="strategy-form"
>
@@ -207,7 +218,7 @@ function showLengthSettings(strategyCode?: string) {
:label="$t('documentCollection.importDoc.strategySelection')"
>
<ElSelect
v-model="formMap[item.filePath].strategyCode"
v-model="getStrategyForm(item.filePath, item).strategyCode"
class="w-full"
>
<ElOption
@@ -220,11 +231,15 @@ function showLengthSettings(strategyCode?: string) {
</ElFormItem>
<ElFormItem
v-if="showLengthSettings(formMap[item.filePath].strategyCode)"
v-if="
showLengthSettings(
getStrategyForm(item.filePath, item).strategyCode,
)
"
:label="$t('documentCollection.splitterDoc.chunkSize')"
>
<ElSlider
v-model="formMap[item.filePath].chunkSize"
v-model="getStrategyForm(item.filePath, item).chunkSize"
:max="2048"
:min="128"
show-input
@@ -233,13 +248,14 @@ function showLengthSettings(strategyCode?: string) {
<ElFormItem
v-if="
formMap[item.filePath].strategyCode === 'PARAGRAPH_LENGTH' ||
formMap[item.filePath].strategyCode === 'AUTO'
getStrategyForm(item.filePath, item).strategyCode ===
'PARAGRAPH_LENGTH' ||
getStrategyForm(item.filePath, item).strategyCode === 'AUTO'
"
:label="$t('documentCollection.splitterDoc.overlapSize')"
>
<ElSlider
v-model="formMap[item.filePath].overlapSize"
v-model="getStrategyForm(item.filePath, item).overlapSize"
:max="512"
:min="0"
show-input
@@ -248,12 +264,13 @@ function showLengthSettings(strategyCode?: string) {
<ElFormItem
v-if="
formMap[item.filePath].strategyCode === 'MARKDOWN_SECTION'
getStrategyForm(item.filePath, item).strategyCode ===
'MARKDOWN_SECTION'
"
:label="$t('documentCollection.splitterDoc.mdSplitterLevel')"
>
<ElSelect
v-model="formMap[item.filePath].mdSplitterLevel"
v-model="getStrategyForm(item.filePath, item).mdSplitterLevel"
class="w-full"
>
<ElOption
@@ -266,10 +283,13 @@ function showLengthSettings(strategyCode?: string) {
</ElFormItem>
<ElFormItem
v-if="formMap[item.filePath].strategyCode === 'CUSTOM_REGEX'"
v-if="
getStrategyForm(item.filePath, item).strategyCode ===
'CUSTOM_REGEX'
"
:label="$t('documentCollection.splitterDoc.regex')"
>
<ElInput v-model="formMap[item.filePath].regex" />
<ElInput v-model="getStrategyForm(item.filePath, item).regex" />
</ElFormItem>
</ElForm>
</ElCol>