EntityDetailDrawer.vue 8.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208
  1. <template>
  2. <Transition name="entity-drawer">
  3. <aside v-if="store.open" class="entity-drawer" :class="`is-${side}`" role="dialog" aria-modal="false" aria-label="实体详情" data-entity-detail-drawer>
  4. <header class="entity-drawer__head">
  5. <div class="entity-drawer__heading">
  6. <span class="entity-drawer__eyebrow">{{ view.subtitle || '实体详情' }}</span>
  7. <h2>{{ view.title }}</h2>
  8. </div>
  9. <button type="button" class="entity-drawer__close" aria-label="关闭详情" @click="store.close">×</button>
  10. </header>
  11. <!-- 维护者 2026-10-29:等级不在这里重复 —— 它作为带色的指标卡出现在摘要区。 -->
  12. <div v-if="view.status || view.categoryText" class="entity-drawer__badges">
  13. <span v-if="view.categoryText" class="entity-drawer__badge" data-entity-category>{{ view.categoryText }}</span>
  14. <!-- 防护目标的「状态」就是风险等级:抬头写「风险等级」,颜色跟 risk_color,文字始终可读。 -->
  15. <span v-if="view.status" class="entity-drawer__badge entity-drawer__status" :data-tone="view.tone" data-entity-status>
  16. <em v-if="view.statusCaption" class="entity-drawer__status-caption">{{ view.statusCaption }}</em>{{ view.status }}
  17. </span>
  18. <!-- 等级/优先级与状态并排:状态定位置,等级给风险语义。 -->
  19. <span v-if="view.levelLabel" class="entity-drawer__badge entity-drawer__level" :data-tone="view.levelTone" data-entity-level>{{ view.levelLabel }}</span>
  20. </div>
  21. <p v-if="store.loading" class="entity-drawer__hint" data-entity-detail-loading>正在更新详情…</p>
  22. <p v-if="store.error" class="entity-drawer__hint is-error" data-entity-detail-error>
  23. 详情暂未取到,已保留列表摘要。
  24. <button type="button" @click="store.retry">重试</button>
  25. </p>
  26. <div class="entity-drawer__body"><EntityDetailSections :detail="store.detail" @locate-device="(code) => emit('locate-device', code)" @focus-network="(code) => emit('focus-network', code)" /></div>
  27. </aside>
  28. </Transition>
  29. </template>
  30. <script setup>
  31. import { computed } from 'vue'
  32. import { entityDetailView } from '../domain/entityDetail.js'
  33. import { useEntityDetailStore } from '../stores/entityDetailStore.js'
  34. import EntityDetailSections from './EntityDetailSections.vue'
  35. defineProps({ side: { type: String, default: 'right' } })
  36. const emit = defineEmits(['locate-device', 'focus-network'])
  37. const store = useEntityDetailStore()
  38. const view = computed(() => entityDetailView(store.detail))
  39. </script>
  40. <style scoped>
  41. .entity-drawer,
  42. .entity-drawer * {
  43. box-sizing: border-box;
  44. }
  45. /* 与两侧业务面板同一套磨砂语言(CockpitPanel):同一组 token + 同样的 blur/saturate。
  46. 尺寸/位置仍由外壳决定(只贴来源侧、只占一张图),这里只管"看起来像同一套面板"。 */
  47. .entity-drawer {
  48. position: absolute;
  49. z-index: 42;
  50. top: calc(12 * var(--u, 1px));
  51. bottom: calc(12 * var(--u, 1px));
  52. width: min(calc(360 * var(--u, 1px)), 42%);
  53. display: grid;
  54. grid-template-rows: auto auto auto minmax(0, 1fr);
  55. gap: calc(6 * var(--u, 1px));
  56. padding: calc(7 * var(--u, 1px)) calc(8 * var(--u, 1px));
  57. border: 1px solid var(--panel-line, rgba(1, 171, 234, 0.35));
  58. border-radius: calc(4 * var(--u, 1px));
  59. background: linear-gradient(
  60. 180deg,
  61. var(--panel-top, rgba(2, 9, 27, 0.28)) 0%,
  62. var(--panel-mid, rgba(0, 53, 156, 0.2)) 26%,
  63. var(--panel-bot, rgba(0, 15, 52, 0.38)) 100%
  64. );
  65. backdrop-filter: blur(16px) saturate(115%);
  66. -webkit-backdrop-filter: blur(16px) saturate(115%);
  67. box-shadow: inset 0 1px 0 rgba(1, 171, 234, 0.14), var(--shadow, 0 18px 44px rgba(0, 0, 0, 0.55));
  68. color: var(--text, #d7ecff);
  69. }
  70. .entity-drawer.is-left { left: calc(var(--rail-w) + 12 * var(--u, 1px)); }
  71. .entity-drawer.is-right { right: calc(var(--rail-w) + 12 * var(--u, 1px)); }
  72. .entity-drawer__head {
  73. display: flex;
  74. align-items: flex-start;
  75. gap: calc(8 * var(--u, 1px));
  76. padding-bottom: calc(6 * var(--u, 1px));
  77. border-bottom: 1px solid var(--panel-line, rgba(1, 171, 234, 0.22));
  78. }
  79. .entity-drawer__heading {
  80. flex: 1;
  81. min-width: 0;
  82. }
  83. .entity-drawer__eyebrow {
  84. display: block;
  85. color: var(--cyan-hi, #35d8ff);
  86. font-size: var(--fs-caption, 10.5px);
  87. letter-spacing: 0.08em;
  88. }
  89. .entity-drawer h2 {
  90. margin: calc(2 * var(--u, 1px)) 0 0;
  91. color: var(--text-strong, #eaf6ff);
  92. font-size: var(--fs-body, 13px);
  93. line-height: 1.35;
  94. /* 标题/编码不截断成省略号:放不下就折行。 */
  95. overflow-wrap: anywhere;
  96. }
  97. .entity-drawer__close {
  98. width: calc(22 * var(--u, 1px));
  99. height: calc(22 * var(--u, 1px));
  100. padding: 0;
  101. border: 1px solid rgba(1, 171, 234, 0.35);
  102. border-radius: 50%;
  103. background: rgba(0, 20, 72, 0.5);
  104. color: var(--text-2, #88b7e8);
  105. font: inherit;
  106. cursor: pointer;
  107. }
  108. .entity-drawer__close:hover,
  109. .entity-drawer__close:focus-visible {
  110. border-color: var(--cyan-hi, #00b8ff);
  111. color: var(--text-strong, #eaf6ff);
  112. }
  113. /* 类别与状态:类别是身份(中文+英文码),状态带语义色 —— 两者都不只靠颜色区分。 */
  114. .entity-drawer__badges {
  115. display: flex;
  116. flex-wrap: wrap;
  117. gap: calc(4 * var(--u, 1px));
  118. justify-self: start;
  119. }
  120. .entity-drawer__level { font-weight: 700; }
  121. .entity-drawer__badge {
  122. padding: 1px calc(7 * var(--u, 1px));
  123. border: 1px solid rgba(1, 171, 234, 0.3);
  124. border-radius: calc(10 * var(--u, 1px));
  125. color: var(--text-2, #88b7e8);
  126. font-size: var(--fs-caption, 10.5px);
  127. }
  128. .entity-drawer__level[data-tone='lv1'],
  129. .entity-drawer__status[data-tone='lv1'] { border-color: rgba(255, 59, 82, 0.55); color: #ffc2c9; }
  130. .entity-drawer__level[data-tone='lv2'],
  131. .entity-drawer__status[data-tone='lv2'] { border-color: rgba(255, 176, 32, 0.55); color: #ffdc91; }
  132. .entity-drawer__level[data-tone='lv3'],
  133. .entity-drawer__status[data-tone='lv3'] { border-color: rgba(1, 171, 234, 0.55); color: #b7e4ff; }
  134. .entity-drawer__level[data-tone='lv4'],
  135. .entity-drawer__status[data-tone='lv4'] { border-color: rgba(53, 219, 146, 0.5); color: #b8f2d4; }
  136. /* 已处置=紫(与列表卡同一套状态色)、未知=中性灰;等级四档不含这两档。 */
  137. /* 风险颜色(risk_color 字典):红 / 橙 / 黄 / 蓝四档。文字仍是中文,颜色不是唯一线索。 */
  138. .entity-drawer__status[data-tone='risk-1'] { border-color: rgba(255, 59, 82, 0.6); color: #ffc2c9; background: rgba(255, 59, 82, 0.12); }
  139. .entity-drawer__status[data-tone='risk-2'] { border-color: rgba(255, 138, 32, 0.6); color: #ffd8a8; background: rgba(255, 138, 32, 0.12); }
  140. .entity-drawer__status[data-tone='risk-3'] { border-color: rgba(255, 214, 32, 0.6); color: #ffeeb0; background: rgba(255, 214, 32, 0.12); }
  141. .entity-drawer__status[data-tone='risk-4'] { border-color: rgba(1, 171, 234, 0.6); color: #b7e4ff; background: rgba(1, 171, 234, 0.12); }
  142. /* 徽标抬头(「风险等级」):小一号、弱化,不抢风险等级本身。 */
  143. .entity-drawer__status-caption { margin-right: 4px; font-style: normal; font-weight: 400; opacity: 0.72; }
  144. .entity-drawer__status[data-tone='handled'] { border-color: rgba(169, 112, 255, 0.6); color: #dcc9ff; }
  145. .entity-drawer__status[data-tone='neutral'] { border-color: rgba(86, 128, 176, 0.5); color: #c4d5e8; }
  146. .entity-drawer__hint {
  147. margin: 0;
  148. color: var(--muted, #5680b0);
  149. font-size: var(--fs-caption, 10.5px);
  150. }
  151. .entity-drawer__hint.is-error { color: #ffc2c9; }
  152. .entity-drawer__hint button {
  153. margin-left: calc(6 * var(--u, 1px));
  154. border: 0;
  155. background: none;
  156. color: var(--cyan-hi, #35d8ff);
  157. font: inherit;
  158. cursor: pointer;
  159. }
  160. .entity-drawer__body {
  161. min-height: 0;
  162. overflow-y: auto;
  163. overflow-x: hidden;
  164. padding-right: 2px;
  165. }
  166. .entity-drawer-enter-active,
  167. .entity-drawer-leave-active {
  168. transition: transform 0.18s ease, opacity 0.18s ease;
  169. }
  170. .entity-drawer-enter-from,
  171. .entity-drawer-leave-to {
  172. transform: translateX(20px);
  173. opacity: 0;
  174. }
  175. @media (max-width: 680px) {
  176. .entity-drawer,
  177. .entity-drawer.is-left,
  178. .entity-drawer.is-right {
  179. top: auto;
  180. left: 8px;
  181. right: 8px;
  182. bottom: 8px;
  183. width: auto;
  184. max-height: 72vh;
  185. }
  186. }
  187. </style>