| 29 | } |
| 30 | |
| 31 | async function snapshot(browser, themePath) { |
| 32 | let themeName = path.basename(themePath, '.js'); |
| 33 | let code = fs.readFileSync(themePath, 'utf-8'); |
| 34 | |
| 35 | let page = await browser.newPage(); |
| 36 | await page.evaluateOnNewDocument(code); |
| 37 | await page.setViewport({ width: 1200, height: 1200 }); |
| 38 | try { |
| 39 | await page.goto('http://localhost/echarts/theme/tool/thumb.html#' + themeName); |
| 40 | await wait(200); |
| 41 | await page.screenshot({ path: __dirname + '/../thumb/' + themeName + '.png' }); |
| 42 | } |
| 43 | catch (e) { |
| 44 | console.log(e); |
| 45 | } |
| 46 | await page.close(); |
| 47 | |
| 48 | console.log('Updated ' + themeName); |
| 49 | } |
| 50 | |
| 51 | glob('../*.js', async function (err, themePathList) { |
| 52 | |