Przeglądaj źródła

修「振动分析」(cms) 子页面真实无数据: 照旧页 app.js:980 在选中 cms 时按需取 /api/vibcms(prop 优先用于对拍同源); 此前应用从不取该接口, 对拍工具喂数掩盖了该差异

zhouyang.xie 6 dni temu
rodzic
commit
1c103591d2

+ 17 - 2
app_frontEnd/web/src/views/Vibration.vue

@@ -6,7 +6,7 @@ import { vUnwrap } from '../lib/unwrap'
  * 该页签内部有 **5 个子视图**(旧 `FUS.sub`):matrix(判级矩阵,默认)/ loop / units / events / cms。
  * 本版只迁 **matrix**,其余如实标"迁移中";5 个子视图全过对拍后才列入 DONE。
  */
-import { computed } from 'vue'
+import {computed, ref, watch } from 'vue'
 import { t } from '../i18n/zh'
 import { FUS_SUBS, cmsHtml, eventsHtml, loopHtml, matrixHtml, unitsHtml } from '../lib/vib'
 
@@ -14,6 +14,21 @@ const props = defineProps<{ d: any; sub?: string | null; cms?: any }>()
 const emit = defineEmits<{ (e: 'sub', id: string): void }>()
 
 const sub = computed(() => props.sub || 'matrix')
+/** ★P63 照旧页 app.js:980 —— 选中 cms 子视图时**按需异步取** `/api/vibcms`(prop 优先,用于对拍同源)。
+ *  实逮:此前应用从不取该接口 ⇒ 真实打开「振动分析」时无数据(对拍工具喂数据把它掩盖了)。 */
+const cmsLocal = ref<any>(null)
+const cmsErr = ref<string>('')
+watch(sub, async (s) => {
+  if (s === 'cms' && !cmsLocal.value && !props.cms && !cmsErr.value) {
+    try {
+      const r = await fetch('/api/vibcms')
+      cmsLocal.value = await r.json()
+    } catch (e) {
+      cmsErr.value = String((e as any)?.message || e)
+    }
+  }
+}, { immediate: true })
+const cmsData = computed<any>(() => props.cms ?? cmsLocal.value)
 const F = computed<any>(() => props.d?.fus)
 
 const bodyHtml = computed(() => {
@@ -23,7 +38,7 @@ const bodyHtml = computed(() => {
   if (sub.value === 'loop') return loopHtml(f)
   if (sub.value === 'units') return unitsHtml(f, null)
   if (sub.value === 'events') return eventsHtml(f, props.d)
-  if (sub.value === 'cms') return cmsHtml(props.cms ?? null)
+  if (sub.value === 'cms') return cmsHtml(cmsData.value)
   return `<div class="panel mb"><p class="small muted">子视图「${t('fus.sub.' + sub.value)}」尚未迁移到 Vue(迁移中)。</p></div>`
 })
 </script>

+ 13 - 5
app_frontEnd/web/tools/struct_diff.mjs

@@ -89,7 +89,10 @@ async function awaitCurves(tries = 20, gapMs = 3000) {
   throw new Error('等 /api/curves 出图超时')
 }
 
-async function baseline(tab) {
+/** ★P63:`tab:sub` 形式 —— 基线点一下子视图 pill,Vue 侧把 sub 传给 renderTab。 */
+function parseTab(x) { const [tab, sub] = String(x).split(':'); return { tab, sub: sub || null } }
+
+async function baseline(tab, sub) {
   const state = {}
   if (!state.warmed) { await warmup(); state.warmed = true }
   if (tab === 'generation') { state.curves = await awaitCurves(); console.log('   [i] curves figs ' + (state.curves.figs || []).length) }
@@ -115,13 +118,17 @@ async function baseline(tab) {
     last = n
     await new Promise((r) => setTimeout(r, 700))
   }
+  if (sub) {
+    const pill = doc.querySelector(`#root [data-fsub="${sub}"]`)
+    if (pill) { pill.dispatchEvent(new dom.window.MouseEvent('click', { bubbles: true })); await new Promise((r) => setTimeout(r, sub === 'cms' ? 4000 : 1200)) }
+  }
   return { root: doc.getElementById('root'), data: state.fleet, cms: state.cms ?? null,
            curves: state.curves ?? null, apis: state.apis ?? {} }
 }
 
-async function vueSkel(tab, data, cms, curves, apis) {
+async function vueSkel(tab, sub, data, cms, curves, apis) {
   const entry = pathToFileURL(resolve(HERE, '../target/ssr/entry-server.js')).href
-  const html = await (await import(entry)).renderTab(data, tab, null, cms, curves, apis)
+  const html = await (await import(entry)).renderTab(data, tab, sub, cms, curves, apis)
   const dom = new JSDOM(`<div id="wrap">${html}</div>`)
   const wrap = dom.window.document.getElementById('wrap')
   const nav = wrap.querySelector('.wb-tabs')
@@ -131,10 +138,11 @@ async function vueSkel(tab, data, cms, curves, apis) {
 
 let bad = 0
 for (const tab of TABS) {
-  const { root, data, cms, curves, apis } = await baseline(tab)
+  const { tab: TAB, sub: SUB } = parseTab(tab)
+  const { root, data, cms, curves, apis } = await baseline(TAB, SUB)
   if (!root) { console.log(`[X] ${tab}: 基线未渲染`); bad++; continue }
   const a = skeletonIn(root)
-  const b = await vueSkel(tab, data, cms, curves, apis)
+  const b = await vueSkel(TAB, SUB, data, cms, curves, apis)
   if (a.length === b.length && a.every((x, i) => x === b[i])) {
     console.log(`[OK] ${tab} 结构一致(${a.length} 个元素)`)
   } else {

Plik diff jest za duży
+ 0 - 0
release/web/assets/index-Bw-hblff.js


+ 1 - 1
release/web/index.html

@@ -4,7 +4,7 @@
   <meta charset="utf-8" />
   <meta name="viewport" content="width=device-width, initial-scale=1" />
   <title>观澜 · 风电数据分析与决策支持</title>
-  <script type="module" crossorigin src="/web/assets/index-D7OjdfQ9.js"></script>
+  <script type="module" crossorigin src="/web/assets/index-Bw-hblff.js"></script>
   <link rel="stylesheet" crossorigin href="/web/assets/index-DFl-J_Hd.css">
 </head>
 <body>

Niektóre pliki nie zostały wyświetlone z powodu dużej ilości zmienionych plików