Explorar el Código

feat(portrait): 亲密度详情整卡可点击下钻

- 点击范围从红色数字扩大到整个行为卡片,数字仅保留视觉提示
- 仅描述中含数字的卡片可点,附带 role/tabindex 与 Enter/空格键盘支持
- 补充悬停、按下的整卡反馈与 focus-visible 焦点环
cc hace 2 semanas
padre
commit
9814e4c62a

+ 49 - 2
ai-electron/frontend/src/case/views/dm/components/IntimacyPanel.vue

@@ -69,7 +69,16 @@
           </div>
 
           <div v-if="activeRelation?.details.length" class="intimacy-detail__list">
-            <div v-for="detail in activeRelation.details" :key="detail.key" class="detail-item">
+            <div
+              v-for="detail in activeRelation.details"
+              :key="detail.key"
+              class="detail-item"
+              :class="{ 'detail-item--clickable': isDetailClickable(detail) }"
+              :role="isDetailClickable(detail) ? 'button' : undefined"
+              :tabindex="isDetailClickable(detail) ? 0 : undefined"
+              @click="handleDetailActivate(detail)"
+              @keydown="handleDetailKeydown($event, detail)"
+            >
               <span class="detail-dot" :style="{ backgroundColor: detail.color }"></span>
               <div class="detail-main">
                 <div class="detail-title">
@@ -81,7 +90,6 @@
                     v-for="(seg, segIndex) in parseDescriptionSegments(detail.description)"
                     :key="segIndex"
                     :class="{ 'detail-value--clickable': seg.clickable }"
-                    @click="seg.clickable && handleJumpToAnalysis(detail)"
                     >{{ seg.text }}</span
                   >
                 </div>
@@ -403,6 +411,21 @@
     return segments;
   };
 
+  /** 描述里带数字才说明这项行为可以下钻,整卡才给可点样式,避免无可跳转目标也显示手型 */
+  const isDetailClickable = (detail: DetailViewItem) => /\d/.test(detail.description || '');
+
+  const handleDetailActivate = (detail: DetailViewItem) => {
+    if (isDetailClickable(detail)) handleJumpToAnalysis(detail);
+  };
+
+  /** 整卡当按钮用时的键盘可达性:Enter / 空格等同点击 */
+  const handleDetailKeydown = (event: KeyboardEvent, detail: DetailViewItem) => {
+    if (event.key !== 'Enter' && event.key !== ' ') return;
+    if (!isDetailClickable(detail)) return;
+    event.preventDefault();
+    handleJumpToAnalysis(detail);
+  };
+
   const handleJumpToAnalysis = (detail: DetailViewItem) => {
     const personName = selectedPersonName.value;
     const otherName = activeRelation.value?.otherName || '';
@@ -1380,6 +1403,30 @@
       box-sizing: border-box;
     }
 
+    /* 整卡可点:红色数字只是提示,点击范围覆盖整个行为卡片 */
+    .detail-item--clickable {
+      cursor: pointer;
+      transition:
+        background-color 0.15s ease-out,
+        border-color 0.15s ease-out,
+        box-shadow 0.15s ease-out;
+
+      &:hover {
+        background: #f8faff;
+        border-color: fade(#2a50ec, 35%);
+        box-shadow: 0 2px 8px fade(#2a50ec, 10%);
+      }
+
+      &:active {
+        background: #f1f5ff;
+      }
+
+      &:focus-visible {
+        outline: 2px solid fade(#2a50ec, 40%);
+        outline-offset: 1px;
+      }
+    }
+
     .detail-dot {
       width: 6px;
       height: 6px;