20260820223837
This commit is contained in:
1 parent
68ac5db038
commit
45854b0570
48 files changed
+7545
-650
No files matched your search
@@ -0,0 +1,47 @@
|
||||
import { chromium } from 'playwright-core'
|
||||
|
||||
const BASE = 'http://localhost:5082'
|
||||
const browser = await chromium.launch({
|
||||
headless: true,
|
||||
executablePath: `${process.env.LOCALAPPDATA}\\ms-playwright\\chromium-1232\\chrome-win64\\chrome.exe`,
|
||||
})
|
||||
const page = await browser.newPage({ viewport: { width: 1440, height: 900 } })
|
||||
|
||||
await page.addInitScript(() => {
|
||||
sessionStorage.setItem('fms-login', JSON.stringify({ loginInfo: { token: 'dev-token', user: { id: 1, name: 'dev', account: 'g3soft' } } }))
|
||||
localStorage.setItem('fms-user', JSON.stringify({ userInfo: { orgId: 'G3HD', account: 'g3soft' } }))
|
||||
})
|
||||
await page.route('**/api/**', (route) => route.fulfill({ status: 200, contentType: 'application/json', body: JSON.stringify({ code: 0, data: null }) }))
|
||||
|
||||
await page.goto(`${BASE}/file-demo`, { waitUntil: 'networkidle', timeout: 30000 })
|
||||
await page.waitForTimeout(3000)
|
||||
|
||||
// Hook into the app: find SplitterPanel component instances and inspect what props they actually receive
|
||||
const result = await page.evaluate(async () => {
|
||||
// Vue 3 internal: traverse the root component instance to find SplitterPanel
|
||||
const rootEl = document.querySelector('#app')
|
||||
const root = rootEl?.__vue_app__?._instance
|
||||
function findPanels(instance, acc = []) {
|
||||
if (!instance) return acc
|
||||
const name = instance.type?.__name || instance.type?.name || ''
|
||||
if (name === 'SplitterPanel') {
|
||||
acc.push({
|
||||
name,
|
||||
props: instance.props ? { ...instance.props } : null,
|
||||
parentName: instance.parent?.type?.__name || instance.parent?.type?.name || '',
|
||||
})
|
||||
}
|
||||
if (instance.subTree) walkVNode(instance.subTree, acc)
|
||||
return acc
|
||||
}
|
||||
function walkVNode(vnode, acc) {
|
||||
if (!vnode) return
|
||||
if (vnode.component) findPanels(vnode.component, acc)
|
||||
if (Array.isArray(vnode.children)) vnode.children.forEach((c) => walkVNode(c, acc))
|
||||
else if (vnode.children && typeof vnode.children === 'object') walkVNode(vnode.children, acc)
|
||||
}
|
||||
return findPanels(root)
|
||||
})
|
||||
|
||||
console.log(JSON.stringify(result, null, 2))
|
||||
await browser.close()
|
||||
Reference in new issue
Block a user