diff --git a/AccountCenter/snapshot.png b/AccountCenter/snapshot.png index bf623b530c0cebd03cf4a9c01c09a2cfb8bcfa5a..5a6b334d9e1b2e8200714b5d0742debbaea8e22e 100644 Binary files a/AccountCenter/snapshot.png and b/AccountCenter/snapshot.png differ diff --git a/AccountCenter/src/_mock.ts b/AccountCenter/src/_mock.ts index 7b3740d68f9bf04556087bc4d424084ca8ae64b1..5083e62a597d08103a4554bfb002e6a87a122223 100644 --- a/AccountCenter/src/_mock.ts +++ b/AccountCenter/src/_mock.ts @@ -166,7 +166,7 @@ function fakeList(count: number): ListItemDataType[] { function getFakeList(req: { query: any }, res: { json: (arg0: ListItemDataType[]) => void }) { const params = req.query; - const count = params.count * 1 || 20; + const count = params.count * 1 || 5; const result = fakeList(count); return res.json(result); diff --git a/AccountSettings/snapshot.png b/AccountSettings/snapshot.png index 17671e8069b0262e851c55ca5e7aed262b0ecbb0..3a3f1e46210dd940b67111e014b971dda13dbae3 100644 Binary files a/AccountSettings/snapshot.png and b/AccountSettings/snapshot.png differ diff --git a/DashboardAnalysis/snapshot.png b/DashboardAnalysis/snapshot.png index 889f2f2c319e2d5bd36a059e06a97c1786893382..48732bd5090bc8b1442372f7a5a0860009b367ba 100644 Binary files a/DashboardAnalysis/snapshot.png and b/DashboardAnalysis/snapshot.png differ diff --git a/DashboardMonitor/snapshot.png b/DashboardMonitor/snapshot.png index 76aac1cfbcf33d26e8b57329aca1e3ebcc6a4378..e36d3a86cd2443c3af9abe18d0e886e37f0674cb 100644 Binary files a/DashboardMonitor/snapshot.png and b/DashboardMonitor/snapshot.png differ diff --git a/DashboardWorkplace/snapshot.png b/DashboardWorkplace/snapshot.png index d6fc28801a9701ff45d8e6a1a857bb020591bebc..75be5cce65cca5e14d4858e43b6dda90eec6f300 100644 Binary files a/DashboardWorkplace/snapshot.png and b/DashboardWorkplace/snapshot.png differ diff --git a/EditorFlow/README.md b/EditorFlow/README.md index bfcf96e84194ede04440463bb8ed73e95a458232..dbe392756c54bae40fc229bd1f421d008d729768 100644 --- a/EditorFlow/README.md +++ b/EditorFlow/README.md @@ -7,6 +7,9 @@ flow ```sh umi block add ant-design-pro/flow ``` +## SNAPSHOT + +![SNAPSHOT](./snapshot.png) ## LICENSE diff --git a/EditorFlow/snapshot.png b/EditorFlow/snapshot.png new file mode 100644 index 0000000000000000000000000000000000000000..73b10897f67f9339cb4d58d4733771d2f9e0a505 Binary files /dev/null and b/EditorFlow/snapshot.png differ diff --git a/EditorKoni/README.md b/EditorKoni/README.md index bfcf96e84194ede04440463bb8ed73e95a458232..dbe392756c54bae40fc229bd1f421d008d729768 100644 --- a/EditorKoni/README.md +++ b/EditorKoni/README.md @@ -7,6 +7,9 @@ flow ```sh umi block add ant-design-pro/flow ``` +## SNAPSHOT + +![SNAPSHOT](./snapshot.png) ## LICENSE diff --git a/EditorKoni/snapshot.png b/EditorKoni/snapshot.png new file mode 100644 index 0000000000000000000000000000000000000000..e3d77db22582adbf81b85cc13e4dc5ab9cfe2a34 Binary files /dev/null and b/EditorKoni/snapshot.png differ diff --git a/EditorMind/README.md b/EditorMind/README.md index bfcf96e84194ede04440463bb8ed73e95a458232..dbe392756c54bae40fc229bd1f421d008d729768 100644 --- a/EditorMind/README.md +++ b/EditorMind/README.md @@ -7,6 +7,9 @@ flow ```sh umi block add ant-design-pro/flow ``` +## SNAPSHOT + +![SNAPSHOT](./snapshot.png) ## LICENSE diff --git a/EditorMind/snapshot.png b/EditorMind/snapshot.png new file mode 100644 index 0000000000000000000000000000000000000000..de8025c3f224e614b90c78335f263584ca720c83 Binary files /dev/null and b/EditorMind/snapshot.png differ diff --git a/Exception403/snapshot.png b/Exception403/snapshot.png index f6f79016db8a3a1da8511fa22f473593f068345c..fcbbed6b9ef36409ca62543c990c52fdf072430c 100644 Binary files a/Exception403/snapshot.png and b/Exception403/snapshot.png differ diff --git a/Exception404/snapshot.png b/Exception404/snapshot.png index ac7d7717f9d5a326d5cfba53cc34e649a785ab89..fbc6b0ea020fe4915465910c36075d0f6be6b4b0 100644 Binary files a/Exception404/snapshot.png and b/Exception404/snapshot.png differ diff --git a/Exception500/snapshot.png b/Exception500/snapshot.png index 3e56d8a230f3740e5f256f347d6c3f88f65c762d..b11b797bf30429f480549ab1adc3f5ae55e5e1da 100644 Binary files a/Exception500/snapshot.png and b/Exception500/snapshot.png differ diff --git a/FormAdvancedForm/snapshot.png b/FormAdvancedForm/snapshot.png index 3145c2c85824f4e982e7318a0b1b18da29aad3dc..f9fdb7c01cc2b66976ac83e8ba4454e513f070b3 100644 Binary files a/FormAdvancedForm/snapshot.png and b/FormAdvancedForm/snapshot.png differ diff --git a/FormBasicForm/snapshot.png b/FormBasicForm/snapshot.png index cc8e7dda8c055e289f0d4d960fee19d4b757b94e..e0dd2406e519b78eabdf9c2c841ba4b447973da7 100644 Binary files a/FormBasicForm/snapshot.png and b/FormBasicForm/snapshot.png differ diff --git a/FormStepForm/snapshot.png b/FormStepForm/snapshot.png index 9e8494927524542efb42d3a9da68f121ec95be4b..22d5f8db953062b7beaba628018faa6a33d9924f 100644 Binary files a/FormStepForm/snapshot.png and b/FormStepForm/snapshot.png differ diff --git a/ListBasicList/snapshot.png b/ListBasicList/snapshot.png index 0523b205e5a316a42e13f174a8128e08d0744e7f..46c3487ef21ea8da881d0e8b0cfb916ebc47cd48 100644 Binary files a/ListBasicList/snapshot.png and b/ListBasicList/snapshot.png differ diff --git a/ListCardList/snapshot.png b/ListCardList/snapshot.png index 0523b205e5a316a42e13f174a8128e08d0744e7f..c54315be37ecdd8dc2138c30580684a9b4d9c0f0 100644 Binary files a/ListCardList/snapshot.png and b/ListCardList/snapshot.png differ diff --git a/ListSearch/README.md b/ListSearch/README.md index e94db35282afe8382d096264358bdcebf70fa2e4..020a45ea29cdd320ae800b0dd5552f885e129d70 100644 --- a/ListSearch/README.md +++ b/ListSearch/README.md @@ -8,6 +8,10 @@ SearchList umi block add ant-design-pro/searchlist ``` +## SNAPSHOT + +![SNAPSHOT](./snapshot.png) + ## LICENSE MIT diff --git a/ListSearch/snapshot.png b/ListSearch/snapshot.png new file mode 100644 index 0000000000000000000000000000000000000000..7ac436507278f0af33f23ce03c530a61faa15467 Binary files /dev/null and b/ListSearch/snapshot.png differ diff --git a/ListSearchApplications/snapshot.png b/ListSearchApplications/snapshot.png index 9a2682ceafeb76d5d12edac5ed56e9e445a19938..23f4dc3e0c24611bff4c4b132e08c72decc8b8b9 100644 Binary files a/ListSearchApplications/snapshot.png and b/ListSearchApplications/snapshot.png differ diff --git a/ListSearchArticles/snapshot.png b/ListSearchArticles/snapshot.png index d1e0e4fa4c0bb8851cac33e2b54988ff2ae934e9..2e9cb56e927ae828cf7ec98875b23ed13e7d2371 100644 Binary files a/ListSearchArticles/snapshot.png and b/ListSearchArticles/snapshot.png differ diff --git a/ListSearchProjects/snapshot.png b/ListSearchProjects/snapshot.png index 85f06103963c8571256fb33fa0b464c354eef2f1..b24efcc8dab89e53eaedaa638aed14840a78139a 100644 Binary files a/ListSearchProjects/snapshot.png and b/ListSearchProjects/snapshot.png differ diff --git a/ListTableList/snapshot.png b/ListTableList/snapshot.png index 1a9c39b28f4276b035801b71b231ef2bd1bd8c72..1e76f3bdb1dc35c57cf6804cbd0d20bd6d59c9c6 100644 Binary files a/ListTableList/snapshot.png and b/ListTableList/snapshot.png differ diff --git a/ProfileAdvanced/snapshot.png b/ProfileAdvanced/snapshot.png index fedef2fffebbdff52852038e54872ffbb27a6abf..4ed56a213565af00073800ed20a7480ce81e5152 100644 Binary files a/ProfileAdvanced/snapshot.png and b/ProfileAdvanced/snapshot.png differ diff --git a/ProfileBasic/snapshot.png b/ProfileBasic/snapshot.png index b8edd4692395449a53a7500243e9ee76228198fd..7bffa712698ee7b873aeb9af0159f56b622b21f8 100644 Binary files a/ProfileBasic/snapshot.png and b/ProfileBasic/snapshot.png differ diff --git a/ResultFail/snapshot.png b/ResultFail/snapshot.png index a48cfcdae3c84749601a711bcd410327cbf25a55..c32e44b1ee697c9f09ba2d3bf1d4ca448bcd57b1 100644 Binary files a/ResultFail/snapshot.png and b/ResultFail/snapshot.png differ diff --git a/ResultSuccess/snapshot.png b/ResultSuccess/snapshot.png index 6438d53e807fbfaf8fb21aebb9ca7025a8984e5a..449574f04547901eebd14a96f04bd67898446f75 100644 Binary files a/ResultSuccess/snapshot.png and b/ResultSuccess/snapshot.png differ diff --git a/UserLogin/snapshot.png b/UserLogin/snapshot.png index cce5e4240ec03ea5367c3cbf3a2870f6f8d57668..da812e96a5528adeb81d7fd0e64e321bb85d36ba 100644 Binary files a/UserLogin/snapshot.png and b/UserLogin/snapshot.png differ diff --git a/UserRegister/snapshot.png b/UserRegister/snapshot.png index 125867c69f2122406009dfdb8af12b725b78f7d1..40cc328b83f2a0f9068465e59f0d30dcf994d472 100644 Binary files a/UserRegister/snapshot.png and b/UserRegister/snapshot.png differ diff --git a/UserRegisterResult/snapshot.png b/UserRegisterResult/snapshot.png index 8192b3f48bb710c65e388bb869d99d5b1e869eda..77ddca16fc2585759d07d62d36d0f6e7704a827e 100644 Binary files a/UserRegisterResult/snapshot.png and b/UserRegisterResult/snapshot.png differ diff --git a/_scripts/screenshot.js b/_scripts/screenshot.js new file mode 100644 index 0000000000000000000000000000000000000000..25e94f3d9ceb1573a2b1052787383f04e8061822 --- /dev/null +++ b/_scripts/screenshot.js @@ -0,0 +1,135 @@ +/* eslint-disable eslint-comments/disable-enable-pair */ +/* eslint-disable @typescript-eslint/no-var-requires */ +/* eslint-disable eslint-comments/no-unlimited-disable */ +const { spawn } = require('child_process'); +const puppeteer = require('puppeteer'); +const { join, dirname } = require('path'); +const fs = require('fs'); +const getNpmRegistry = require('getnpmregistry'); +const execa = require('execa'); + +const env = Object.create(process.env); +env.BROWSER = 'none'; +env.TEST = true; +env.COMPRESS = 'none'; +env.PROGRESS = 'none'; +env.BLOCK_PAGES_LAYOUT = 'blankLayout'; + +let browser; + +const startServer = async path => { + let once = false; + return new Promise(resolve => { + env.PAGES_PATH = path + '/src'; + console.log(path); + const startServer = spawn(/^win/.test(process.platform) ? 'npm.cmd' : 'npm', ['run', 'start'], { + env, + }); + + console.log('Starting development server'); + startServer.stdout.on('data', data => { + console.log(data.toString()); + // hack code , wait umi + if (!once && data.toString().indexOf('Compiled successfully') >= 0) { + // eslint-disable-next-line + once = true; + return resolve(startServer); + } + }); + }); +}; + +const autoScroll = page => { + return page.evaluate(() => { + return new Promise((resolve, reject) => { + var totalHeight = 0; + var distance = 100; + var timer = setInterval(() => { + var scrollHeight = document.body.scrollHeight; + window.scrollBy(0, distance); + totalHeight += distance; + if (totalHeight >= scrollHeight) { + clearInterval(timer); + resolve(); + } + }, 100); + }); + }); +}; + +const getImage = async (page, path) => { + const server = await startServer(path); + + await page.reload('http://127.0.0.1:8000'); + + await page.setViewport({ + width: 1440, + height: 800, + }); + + await autoScroll(page); + + await page.screenshot({ + path: join(path, 'snapshot.png'), + fullPage: true, + }); + + server.kill(); +}; + +const openBrowser = async () => { + browser = await puppeteer.launch({ + headless: false, + args: [ + '--disable-gpu', + '--disable-dev-shm-usage', + '--no-first-run', + '--no-zygote', + '--no-sandbox', + ], + }); + const page = await browser.newPage(); + page.goto('http://127.0.0.1:8000'); + return page; +}; + +const getAllFile = async () => { + const cwd = join(__dirname, '../'); + const files = fs.readdirSync(cwd); + return files.filter(path => { + const itemPath = join(cwd, path); + const stat = fs.statSync(itemPath); + if (path.includes('.') || path.includes('_') || path.includes('node_modules')) { + return false; + } + if (stat.isDirectory()) { + return true; + } + return false; + }); +}; + +getAllFile().then(async dirList => { + const registry = await getNpmRegistry(); + const page = await openBrowser(); + const loopGetImage = async index => { + try { + console.log('install ' + dirList[index] + ' dependencies'); + await execa('yarn', ['install', `--registry=${registry}`], { + cwd: join(__dirname, '../' + dirList[index]), + }); + await getImage(page, dirList[index]); + + if (dirList.length > index) { + console.log('Screenshot ' + dirList[index]); + + return loopGetImage(index + 1); + } + } catch (error) { + console.log(error); + } + return Promise.resolve(true); + }; + await loopGetImage(0); + browser.close(); +}); diff --git a/package.json b/package.json index 376b21b4968c9c756e08360ebbfbab19f3f14796..89465884a804864100410f6c93e5836a5207cb91 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,8 @@ { "private": true, "scripts": { - "dev": "cross-env PAGES_PATH='DashboardAnalysis/src' umi dev", + "dev": "cross-env PAGES_PATH='AccountCenter/src' umi dev", + "start": "umi dev", "lint": "npm run lint:ts && npm run lint:style && npm run lint:prettier", "lint-staged": "lint-staged", "lint-staged:ts": "tslint", @@ -31,11 +32,17 @@ "numeral": "^2.0.6", "react-dom": "^16.8.6" }, + "optionalDependencies": { + "puppeteer": "^1.17.0" + }, "devDependencies": { "@types/classnames": "^2.2.7", "@types/numeral": "^0.0.25", "babel-eslint": "^10.0.1", "check-prettier": "^1.0.3", + "cross-port-killer": "^1.1.1", + "execa": "^1.0.0", + "getnpmregistry": "^1.0.1", "glob": "^7.1.3", "husky": "^2.2.0", "lint-staged": "^8.1.0", @@ -51,9 +58,9 @@ "tslint-config-prettier": "^1.17.0", "tslint-eslint-rules": "^5.4.0", "tslint-react": "^3.6.0", - "typescript": "^3.4.5", + "typescript": "^3.5.1", "umi": "^2.6.17", - "umi-plugin-block-dev": "^2.0.2", + "umi-plugin-block-dev": "^2.1.11", "umi-plugin-react": "^1.7.6", "umi-request": "^1.0.0" },