fix: 白屏
All checks were successful
构建并部署前端到测试环境 / deploy (push) Successful in 2m0s

This commit is contained in:
luo
2026-10-31 13:02:18 +08:00
parent 1a1ec485a5
commit 2f4eed917e
4 changed files with 74 additions and 23 deletions

View File

@@ -0,0 +1,51 @@
import test from 'node:test'
import assert from 'node:assert/strict'
import { readFileSync } from 'node:fs'
import { compileTemplate, parse } from '@vue/compiler-sfc'
const pages = [
['asset-information', 'div', 'PollingStateDialog', 'pollingStateTarget'],
['device-list', 'ArtTableFullScreen', 'PollingBatchDialog', 'pollingBatchIds'],
['iot-card-management', 'ArtTableFullScreen', 'PollingBatchDialog', 'pollingBatchIds']
]
for (const [page, rootTag, dialogTag, dialogState] of pages) {
test(`${page} keeps its polling dialog inside one transition-compatible page root`, () => {
const filename = `src/views/asset-management/${page}/index.vue`
const { descriptor, errors } = parse(readFileSync(filename, 'utf8'), { filename })
assert.deepEqual(errors, [])
const roots = descriptor.template.ast.children.filter((node) => node.type === 1)
assert.equal(roots.length, 1, 'sibling polling dialogs turn the page into a Fragment')
assert.equal(roots[0].tag, rootTag, 'preserve the existing page/layout root')
const dialog = roots[0].children.find((node) => node.type === 1 && node.tag === dialogTag)
assert.ok(dialog, 'the polling dialog must remain available inside the page root')
const condition = dialog.props.find((prop) => prop.type === 7 && prop.name === 'if')
assert.equal(condition?.exp.content, dialogState)
const close = dialog.props.find(
(prop) => prop.type === 7 && prop.name === 'on' && prop.arg?.content === 'close'
)
assert.equal(close?.exp.content, `${dialogState} = null`)
// In production, a Fragment root never completes Transition's out-in leave,
// leaving KeepAlive on a comment placeholder for every subsequent route.
const compiled = compileTemplate({
source: descriptor.template.content,
filename,
id: page,
isProd: true,
compilerOptions: { expressionPlugins: ['typescript'] }
})
assert.deepEqual(compiled.errors, [])
assert.equal(compiled.ast.codegenNode.type, 13, 'the page must compile to a single VNode')
assert.equal(typeof compiled.ast.codegenNode.tag, 'string', 'never compile a Fragment root')
})
}
test('the table page layout provides a native element root for route transitions', () => {
const filename = 'src/components/core/tables/ArtTableFullScreen.vue'
const { descriptor } = parse(readFileSync(filename, 'utf8'), { filename })
const roots = descriptor.template.ast.children.filter((node) => node.type === 1)
assert.equal(roots.length, 1)
assert.equal(roots[0].tag, 'div')
})

View File

@@ -188,14 +188,14 @@
:confirm-loading="speedTierSubmitting"
@confirm="handleSpeedTierConfirm"
/>
<PollingStateDialog
v-if="pollingStateTarget"
:key="pollingStateTarget.cardId"
:card-id="pollingStateTarget.cardId"
:permission="pollingStatePermission"
@close="pollingStateTarget = null"
/>
</div>
<PollingStateDialog
v-if="pollingStateTarget"
:key="pollingStateTarget.cardId"
:card-id="pollingStateTarget.cardId"
:permission="pollingStatePermission"
@close="pollingStateTarget = null"
/>
</template>
<script setup lang="ts">

View File

@@ -976,15 +976,15 @@
/>
</ElCard>
</div>
<PollingBatchDialog
v-if="pollingBatchIds"
target="device"
:ids="pollingBatchIds"
:permission="SCHEDULER_PERMISSIONS.deviceBatch"
@close="pollingBatchIds = null"
@done="getTableData"
/>
</ArtTableFullScreen>
<PollingBatchDialog
v-if="pollingBatchIds"
target="device"
:ids="pollingBatchIds"
:permission="SCHEDULER_PERMISSIONS.deviceBatch"
@close="pollingBatchIds = null"
@done="getTableData"
/>
</template>
<script setup lang="ts">

View File

@@ -1036,15 +1036,15 @@
/>
</ElCard>
</div>
<PollingBatchDialog
v-if="pollingBatchIds"
target="iot_card"
:ids="pollingBatchIds"
:permission="SCHEDULER_PERMISSIONS.cardBatch"
@close="pollingBatchIds = null"
@done="getTableData"
/>
</ArtTableFullScreen>
<PollingBatchDialog
v-if="pollingBatchIds"
target="iot_card"
:ids="pollingBatchIds"
:permission="SCHEDULER_PERMISSIONS.cardBatch"
@close="pollingBatchIds = null"
@done="getTableData"
/>
</template>
<script setup lang="ts">