Skip to content

Commit

Permalink
update demos
Browse files Browse the repository at this point in the history
  • Loading branch information
chenshuai2144 committed Jul 12, 2022
1 parent 4c7b7d0 commit f77cfed
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 14 deletions.
15 changes: 14 additions & 1 deletion .dumi/theme/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ const DarkButton = () => {
if (!isBrowser()) {
return 'light';
}
if ((window as any).HeadlessChrome) {
return 'light';
}

return matchMedia?.('(prefers-color-scheme: dark)').matches && 'dark';
}, []);
Expand All @@ -24,6 +27,9 @@ const DarkButton = () => {
if (!isBrowser()) {
return 'light';
}
if ((window as any).HeadlessChrome) {
return 'light';
}
return localStorage.getItem('procomponents_dark_theme') || colorScheme;
}, []);

Expand All @@ -43,6 +49,9 @@ const DarkButton = () => {
if (!isBrowser()) {
return null;
}
if ((window as any).HeadlessChrome) {
return null;
}
return (
<Switch
checkedChildren="🌜"
Expand Down Expand Up @@ -76,7 +85,11 @@ const LayoutPage = ({ children, ...props }: IRouteComponentProps) => {
const context = useContext(dumiContext);
useEffect(() => {
if (!isBrowser()) {
return null;
return;
}

if ((window as any).HeadlessChrome) {
return;
}

loadJS('https://www.googletagmanager.com/gtag/js?id=G-RMBLDHGL1N', function () {
Expand Down
11 changes: 0 additions & 11 deletions .umirc.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,12 +81,6 @@ export default {
},
],
alias,
// 用于切换 antd 暗黑模式
// antd: {
// dark: true,
// },
headScripts: ['https://gw.alipayobjects.com/os/antfincdn/fdj3WlJd5c/darkreader.js'],
externals: { darkreader: 'window.DarkReader' },
resolve: {
includes: [...tailPkgList, 'docs'],
},
Expand All @@ -110,11 +104,6 @@ export default {
},
],
},
analytics: isProduction
? {
ga: 'UA-173569162-1',
}
: false,
hash: true,
targets: {
chrome: 80,
Expand Down
12 changes: 10 additions & 2 deletions scripts/ssr.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ const filterList = (filePath) => {
if (filePath.startsWith('404')) {
return false;
}
if (filePath.includes(':uuid')) {
return false;
}

if (fs.statSync(path.join(distPath, filePath)).isDirectory()) {
return true;
}
Expand Down Expand Up @@ -71,8 +75,8 @@ const loop = async () => {
// 启动浏览器
const browser = await puppeteer.launch({
// 关闭无头模式,方便我们看到这个无头浏览器执行的过程
// headless: false,
timeout: 30000, // 默认超时为30秒,设置为0则表示不设置超时
headless: false,
timeout: 300000, // 默认超时为30秒,设置为0则表示不设置超时
});

// 打开空白页面
Expand All @@ -87,6 +91,10 @@ const loop = async () => {
const scrollHeight = await page.evaluate(() => {
return document.body.scrollHeight;
});

await page.evaluateOnNewDocument(() => {
window.HeadlessChrome = true;
});
console.log('执行' + htmlPage + '页面!');
await page.setViewport({
width: 1800,
Expand Down

0 comments on commit f77cfed

Please sign in to comment.