fix(area-detail-card): 添加独立计算属性 doorStatus 和 isConnected,修复因深层响应式丢失导致的区域连接状态和门状态显示不更新问题

This commit is contained in:
xudan 2025-12-05 10:01:45 +08:00
parent cb3f82b711
commit 941fef8ea6

View File

@ -20,17 +20,36 @@ const areasTick = computed<string>(() =>
.join('|'),
);
// pen
const pen = computed<MapPen | undefined>(() => {
// areasTick
void areasTick.value;
return editor.value.getPenById(props.current);
});
const area = computed<MapAreaInfo | null>(() => {
const v = pen.value?.area;
if (!v?.type) return null;
return v;
});
//
const doorStatus = computed(() => {
// areasTick
void areasTick.value;
const pen = editor.value.getPenById(props.current);
return pen?.area?.doorStatus;
});
const isConnected = computed(() => {
// areasTick
void areasTick.value;
const pen = editor.value.getPenById(props.current);
return pen?.area?.isConnected;
});
const icon = computed<string>(() => `area${area.value?.type}-detail`);
//
@ -162,7 +181,7 @@ watch(area, (newArea) => {
<a-flex :gap="8" vertical>
<a-typography-text type="secondary">{{ $t('连接状态') }}</a-typography-text>
<a-typography-text>{{
area.isConnected === true ? $t('已连接') : area.isConnected === false ? $t('未连接') : $t('无')
isConnected === true ? $t('已连接') : isConnected === false ? $t('未连接') : $t('无')
}}</a-typography-text>
</a-flex>
</a-list-item>
@ -170,7 +189,7 @@ watch(area, (newArea) => {
<a-flex :gap="8" vertical>
<a-typography-text type="secondary">{{ $t('门状态') }}</a-typography-text>
<a-typography-text>
{{ area.doorStatus === 1 ? $t('开门') : area.doorStatus === 0 ? $t('关门') : $t('无') }}
{{ doorStatus === 1 ? $t('开门') : doorStatus === 0 ? $t('关门') : $t('无') }}
</a-typography-text>
</a-flex>
</a-list-item>