| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081 |
- /**
- * 登录后按询价模块截图,供桌面用户手册使用。
- */
- import { chromium } from 'playwright-core'
- import { mkdirSync } from 'node:fs'
- import { join } from 'node:path'
- const base = process.env.DEMO_URL || 'http://localhost:5173'
- const dir = process.env.SHOT_DIR || 'C:\\Users\\Liumouren\\Desktop\\勤务系统2.0用户手册图'
- mkdirSync(dir, { recursive: true })
- const browser = await chromium.launch({
- executablePath: 'C:\\Program Files\\Google\\Chrome\\Application\\chrome.exe',
- headless: true,
- })
- const page = await browser.newPage({ viewport: { width: 1440, height: 900 } })
- async function shot(name, path, wait = 900) {
- await page.goto(base + path, { waitUntil: 'domcontentloaded', timeout: 60000 })
- await page.waitForTimeout(wait)
- await page.screenshot({ path: join(dir, `${name}.png`) })
- console.log('ok', name)
- }
- async function enter(account) {
- await page.goto(base + '/login', { waitUntil: 'domcontentloaded', timeout: 60000 })
- await page.waitForSelector(`[data-testid="login-${account}"]`, { timeout: 25000 })
- await page.waitForTimeout(1800)
- await page.click(`[data-testid="login-${account}"]`)
- await page.waitForTimeout(2200)
- }
- try {
- await shot('00-home', '/', 700)
- await enter('linqm')
- await shot('01-login-hq', '/login', 400)
- await shot('02-workbench', '/admin/workbench', 1400)
- await shot('03-people', '/admin/master?tab=people')
- await shot('04-sites', '/admin/master?tab=sites')
- await shot('05-contracts', '/admin/master?tab=contracts')
- await shot('06-train', '/admin/master?tab=train')
- await shot('07-schedule', '/admin/duty?tab=schedule')
- await shot('08-attend', '/admin/duty?tab=attend')
- await shot('09-ot', '/admin/duty?tab=ot')
- await shot('10-split', '/admin/duty?tab=split')
- await shot('11-ident', '/admin/duty?tab=ident')
- await shot('12-field', '/admin/field')
- await shot('13-notice', '/admin/collab?tab=notice')
- await shot('14-event', '/admin/collab?tab=event')
- await shot('15-alarm', '/admin/collab?tab=alarm')
- await shot('16-perform', '/admin/collab?tab=perform')
- await shot('17-alert', '/admin/collab?tab=alert')
- await shot('18-ledger', '/admin/finance?tab=ledger')
- await shot('19-board', '/admin/finance?tab=board')
- await shot('20-staffing', '/admin/finance?tab=staffing')
- await shot('21-supplier', '/admin/finance?tab=supplier')
- await shot('22-users', '/admin/users')
- await shot('23-perms', '/admin/perms', 1100)
- await shot('24-screen-duty', '/screen/duty', 2000)
- await shot('25-screen-prod', '/screen/productivity', 1800)
- await shot('26-screen-op', '/screen/operation', 1800)
- await shot('27-mp-hq', '/mp/punch', 1200)
- const out = page.locator('button.out')
- if (await out.count()) await out.click()
- await enter('zhoujh')
- await shot('28-branch-workbench', '/admin/workbench', 1400)
- if (await page.locator('button.out').count()) await page.locator('button.out').click()
- await enter('sunting')
- await shot('29-mp-punch', '/mp/punch', 1400)
- await shot('30-mp-shift', '/mp/shift', 900)
- await shot('31-mp-inbox', '/mp/inbox', 900)
- await shot('32-mp-mine', '/mp/mine', 900)
- } catch (err) {
- console.error(err)
- await page.screenshot({ path: join(dir, 'zz-error.png') }).catch(() => {})
- process.exitCode = 1
- } finally {
- await browser.close()
- }
|