增加地面,增加放置区域筛选逻辑

This commit is contained in:
2026-05-21 09:56:13 +08:00
parent b5b70251e2
commit c504fca3de
10 changed files with 377 additions and 35 deletions

View File

@ -123,29 +123,19 @@ export class AppDropZone {
'右': ['右', 'right', 'you']
};
// 匹配墙面名称(支持精确匹配和模糊匹配)
// 匹配墙面名称(精确匹配)
const matchWallName = (wallName: string): number | null => {
// 1. 优先精确匹配完整墙面名称
// 例如:wall.name = "80全铁3x6_前1"divisions 中有 "前1"
for (const [configName, divisionValue] of Object.entries(divisionsMap)) {
if (wallName.includes(configName)) {
return divisionValue;
}
}
// 2. 如果精确匹配失败,尝试方向模糊匹配(兼容旧版)
const lowerName = wallName.toLowerCase();
for (const [direction, keywords] of Object.entries(directionKeywords)) {
for (const keyword of keywords) {
if (lowerName.includes(keyword.toLowerCase()) || wallName.includes(keyword)) {
// 检查 divisionsMap 中是否有该方向的配置
if (divisionsMap[direction] !== undefined) {
return divisionsMap[direction];
}
}
}
// 提取墙面名称的最后部分(最后一个下划线之后)
// 例如:"SW10000070_10x20星空篷_前1" → "前1"
const wallShortName = wallName.split('_').pop() || wallName;
// 精确匹配提取出的简短名称
if (divisionsMap[wallShortName] !== undefined) {
console.log(`墙面 "${wallName}" 通过简短名称 "${wallShortName}" 精确匹配到分割数: ${divisionsMap[wallShortName]}`);
return divisionsMap[wallShortName];
}
console.log(`墙面 "${wallName}" 未匹配到任何分割数配置`);
return null;
};