fix: 修复管理端前端类型校验问题
- 修正知识库与 Bot 设置页相关组件的类型定义和空值处理 - 补齐工作流与公开聊天页的前端类型约束和动态导入类型 - 收敛本次改动文件的局部格式与样式规范,确保 pnpm check:type 通过
This commit is contained in:
@@ -219,9 +219,9 @@ async function save() {
|
||||
<ElIcon
|
||||
style="
|
||||
margin-left: 4px;
|
||||
font-size: 14px;
|
||||
color: #909399;
|
||||
cursor: pointer;
|
||||
font-size: 14px;
|
||||
"
|
||||
>
|
||||
<InfoFilled />
|
||||
@@ -258,9 +258,9 @@ async function save() {
|
||||
<ElIcon
|
||||
style="
|
||||
margin-left: 4px;
|
||||
font-size: 14px;
|
||||
color: #909399;
|
||||
cursor: pointer;
|
||||
font-size: 14px;
|
||||
"
|
||||
>
|
||||
<InfoFilled />
|
||||
|
||||
@@ -301,9 +301,9 @@ defineExpose({
|
||||
<ElIcon
|
||||
style="
|
||||
margin-left: 4px;
|
||||
font-size: 14px;
|
||||
color: #909399;
|
||||
cursor: pointer;
|
||||
font-size: 14px;
|
||||
"
|
||||
>
|
||||
<InfoFilled />
|
||||
@@ -340,9 +340,9 @@ defineExpose({
|
||||
<ElIcon
|
||||
style="
|
||||
margin-left: 4px;
|
||||
font-size: 14px;
|
||||
color: #909399;
|
||||
cursor: pointer;
|
||||
font-size: 14px;
|
||||
"
|
||||
>
|
||||
<InfoFilled />
|
||||
|
||||
@@ -96,26 +96,27 @@ const handleSearch = () => {
|
||||
|
||||
<style scoped>
|
||||
.search-container {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
padding: 0 0 20px 0;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
padding: 0 0 20px;
|
||||
}
|
||||
|
||||
.search-input {
|
||||
display: flex;
|
||||
gap: 12px;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: 12px;
|
||||
}
|
||||
|
||||
.retrieval-select {
|
||||
width: 180px;
|
||||
flex-shrink: 0;
|
||||
width: 180px;
|
||||
}
|
||||
|
||||
.search-result {
|
||||
padding-top: 20px;
|
||||
flex: 1;
|
||||
padding-top: 20px;
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -168,18 +168,17 @@ const submitConfig = () => {
|
||||
|
||||
<style scoped>
|
||||
.search-config-sidebar {
|
||||
box-sizing: border-box;
|
||||
width: 60%;
|
||||
height: 100%;
|
||||
padding: 16px;
|
||||
box-sizing: border-box;
|
||||
overflow-y: auto;
|
||||
overflow-x: hidden;
|
||||
overflow: hidden auto;
|
||||
}
|
||||
|
||||
.config-header {
|
||||
padding-bottom: 8px;
|
||||
margin-bottom: 16px;
|
||||
border-bottom: 1px solid #e6e6e6;
|
||||
padding-bottom: 8px;
|
||||
}
|
||||
|
||||
.config-header h3 {
|
||||
@@ -200,19 +199,19 @@ const submitConfig = () => {
|
||||
}
|
||||
|
||||
.form-item {
|
||||
margin-bottom: 20px;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 12px;
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
|
||||
.form-item-label {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 4px;
|
||||
align-items: center;
|
||||
font-size: 14px;
|
||||
color: #606266;
|
||||
line-height: 1.4;
|
||||
color: #606266;
|
||||
}
|
||||
|
||||
.label-tooltip {
|
||||
@@ -227,8 +226,8 @@ const submitConfig = () => {
|
||||
|
||||
.form-item-content {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
align-items: center;
|
||||
width: 100%;
|
||||
margin-top: 4px;
|
||||
}
|
||||
@@ -240,19 +239,19 @@ const submitConfig = () => {
|
||||
}
|
||||
|
||||
.switch-control {
|
||||
width: auto;
|
||||
flex: none;
|
||||
width: auto;
|
||||
min-width: 80px;
|
||||
}
|
||||
|
||||
.info-icon {
|
||||
flex: none;
|
||||
flex-shrink: 0;
|
||||
width: 16px;
|
||||
height: 16px;
|
||||
font-size: 14px;
|
||||
color: #909399;
|
||||
cursor: help;
|
||||
width: 16px;
|
||||
height: 16px;
|
||||
flex-shrink: 0;
|
||||
flex: none;
|
||||
}
|
||||
|
||||
.info-icon:hover {
|
||||
@@ -278,8 +277,8 @@ const submitConfig = () => {
|
||||
}
|
||||
|
||||
:deep(.el-form-item__content) {
|
||||
width: 100%;
|
||||
box-sizing: border-box;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
:deep(.el-slider) {
|
||||
|
||||
@@ -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>
|
||||
|
||||
Reference in New Issue
Block a user