@ahooks.js/dumi-theme-antd 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +38 -0
- package/dist/builtins/Alert/index.d.ts +6 -0
- package/dist/builtins/Alert/index.js +25 -0
- package/dist/builtins/BashOSPlatform/index.d.ts +8 -0
- package/dist/builtins/BashOSPlatform/index.js +57 -0
- package/dist/builtins/BashOSPlatform/linux.d.ts +7 -0
- package/dist/builtins/BashOSPlatform/linux.js +60 -0
- package/dist/builtins/BashOSPlatform/macos.d.ts +7 -0
- package/dist/builtins/BashOSPlatform/macos.js +22 -0
- package/dist/builtins/BashOSPlatform/windows.d.ts +7 -0
- package/dist/builtins/BashOSPlatform/windows.js +20 -0
- package/dist/builtins/HomeBaseLayout/components/Features/index.d.ts +3 -0
- package/dist/builtins/HomeBaseLayout/components/Features/index.js +78 -0
- package/dist/builtins/HomeBaseLayout/components/Group.d.ts +19 -0
- package/dist/builtins/HomeBaseLayout/components/Group.js +89 -0
- package/dist/builtins/HomeBaseLayout/index.d.ts +3 -0
- package/dist/builtins/HomeBaseLayout/index.js +202 -0
- package/dist/builtins/ImagePreview/index.d.ts +3 -0
- package/dist/builtins/ImagePreview/index.js +105 -0
- package/dist/builtins/InstallDependencies/icons.d.ts +10 -0
- package/dist/builtins/InstallDependencies/icons.js +131 -0
- package/dist/builtins/InstallDependencies/index.d.ts +9 -0
- package/dist/builtins/InstallDependencies/index.js +58 -0
- package/dist/common/CommonHelmet.d.ts +2 -0
- package/dist/common/CommonHelmet.js +27 -0
- package/dist/common/EditLink.d.ts +2 -0
- package/dist/common/EditLink.js +24 -0
- package/dist/common/GlobalStyles.d.ts +2 -0
- package/dist/common/GlobalStyles.js +7 -0
- package/dist/common/LastUpdated.d.ts +5 -0
- package/dist/common/LastUpdated.js +53 -0
- package/dist/common/Loading/index.d.ts +3 -0
- package/dist/common/Loading/index.js +56 -0
- package/dist/common/PrevAndNext.d.ts +3 -0
- package/dist/common/PrevAndNext.js +88 -0
- package/dist/common/ThemeSwitch/ThemeIcon.d.ts +5 -0
- package/dist/common/ThemeSwitch/ThemeIcon.js +24 -0
- package/dist/common/ThemeSwitch/index.d.ts +8 -0
- package/dist/common/ThemeSwitch/index.js +45 -0
- package/dist/common/styles/Common.d.ts +2 -0
- package/dist/common/styles/Common.js +10 -0
- package/dist/common/styles/DumiDefaultStyleOverride.d.ts +2 -0
- package/dist/common/styles/DumiDefaultStyleOverride.js +12 -0
- package/dist/common/styles/HeadingAnchor.d.ts +2 -0
- package/dist/common/styles/HeadingAnchor.js +17 -0
- package/dist/common/styles/Highlight.d.ts +2 -0
- package/dist/common/styles/Highlight.js +10 -0
- package/dist/common/styles/Markdown.d.ts +2 -0
- package/dist/common/styles/Markdown.js +13 -0
- package/dist/common/styles/PreviewImage.d.ts +2 -0
- package/dist/common/styles/PreviewImage.js +10 -0
- package/dist/common/styles/Reset.d.ts +2 -0
- package/dist/common/styles/Reset.js +17 -0
- package/dist/common/styles/Responsive.d.ts +2 -0
- package/dist/common/styles/Responsive.js +10 -0
- package/dist/common/styles/SearchBar.d.ts +2 -0
- package/dist/common/styles/SearchBar.js +11 -0
- package/dist/common/styles/index.d.ts +9 -0
- package/dist/common/styles/index.js +9 -0
- package/dist/hooks/useAdditionalThemeConfig.d.ts +3 -0
- package/dist/hooks/useAdditionalThemeConfig.js +9 -0
- package/dist/hooks/useLocaleValue.d.ts +1 -0
- package/dist/hooks/useLocaleValue.js +10 -0
- package/dist/hooks/useMenu.d.ts +8 -0
- package/dist/hooks/useMenu.js +260 -0
- package/dist/hooks/useSiteToken.d.ts +21 -0
- package/dist/hooks/useSiteToken.js +41 -0
- package/dist/hooks/uselocale.d.ts +5 -0
- package/dist/hooks/uselocale.js +7 -0
- package/dist/icons/LTRIcon.d.ts +5 -0
- package/dist/icons/LTRIcon.js +18 -0
- package/dist/icons/RTLIcon.d.ts +5 -0
- package/dist/icons/RTLIcon.js +18 -0
- package/dist/index.d.ts +11 -0
- package/dist/index.js +13 -0
- package/dist/layouts/DocLayout/index.d.ts +4 -0
- package/dist/layouts/DocLayout/index.js +92 -0
- package/dist/layouts/GlobalLayout.d.ts +3 -0
- package/dist/layouts/GlobalLayout.js +153 -0
- package/dist/layouts/HomePageLayout/index.d.ts +3 -0
- package/dist/layouts/HomePageLayout/index.js +7 -0
- package/dist/layouts/SidebarLayout/index.d.ts +3 -0
- package/dist/layouts/SidebarLayout/index.js +28 -0
- package/dist/locales/en-US.json +9 -0
- package/dist/locales/zh-CN.json +9 -0
- package/dist/plugin/index.d.ts +3 -0
- package/dist/plugin/index.js +30 -0
- package/dist/plugin.d.ts +4 -0
- package/dist/plugin.js +117 -0
- package/dist/slots/Content/index.d.ts +5 -0
- package/dist/slots/Content/index.js +159 -0
- package/dist/slots/Footer/index.d.ts +3 -0
- package/dist/slots/Footer/index.js +61 -0
- package/dist/slots/Header/HeaderExtral.d.ts +3 -0
- package/dist/slots/Header/HeaderExtral.js +34 -0
- package/dist/slots/Header/Logo.d.ts +2 -0
- package/dist/slots/Header/Logo.js +46 -0
- package/dist/slots/Header/More.d.ts +6 -0
- package/dist/slots/Header/More.js +32 -0
- package/dist/slots/Header/Navigation.d.ts +6 -0
- package/dist/slots/Header/Navigation.js +140 -0
- package/dist/slots/Header/SwitchBtn.d.ts +11 -0
- package/dist/slots/Header/SwitchBtn.js +85 -0
- package/dist/slots/Header/index.d.ts +4 -0
- package/dist/slots/Header/index.js +187 -0
- package/dist/slots/LangSwitch/index.d.ts +3 -0
- package/dist/slots/LangSwitch/index.js +89 -0
- package/dist/slots/NotFound/index.d.ts +9 -0
- package/dist/slots/NotFound/index.js +25 -0
- package/dist/slots/RtlSwitch/index.d.ts +3 -0
- package/dist/slots/RtlSwitch/index.js +53 -0
- package/dist/slots/Sidebar/index.d.ts +4 -0
- package/dist/slots/Sidebar/index.js +128 -0
- package/dist/slots/SiteContext.d.ts +10 -0
- package/dist/slots/SiteContext.js +8 -0
- package/dist/static/style.d.ts +1 -0
- package/dist/static/style.js +1 -0
- package/dist/styles/variables.less +1 -0
- package/dist/types.d.ts +105 -0
- package/dist/types.js +1 -0
- package/dist/utils.d.ts +10 -0
- package/dist/utils.js +18 -0
- package/package.json +108 -0
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
|
+
import Icon from '@ant-design/icons';
|
|
3
|
+
import React from 'react';
|
|
4
|
+
import { jsx as ___EmotionJSX } from "@emotion/react";
|
|
5
|
+
var SVGIcon = function SVGIcon() {
|
|
6
|
+
return ___EmotionJSX("svg", {
|
|
7
|
+
viewBox: "0 0 1024 1024",
|
|
8
|
+
fill: "currentColor"
|
|
9
|
+
}, ___EmotionJSX("path", {
|
|
10
|
+
d: "M256 64l512 0 0 128-128 0 0 768-128 0 0-768-128 0 0 768-128 0 0-448c-123.712 0-224-100.288-224-224s100.288-224 224-224zM960 896l-256-224 256-224z"
|
|
11
|
+
}));
|
|
12
|
+
};
|
|
13
|
+
var RTLIcon = function RTLIcon(props) {
|
|
14
|
+
return ___EmotionJSX(Icon, _extends({
|
|
15
|
+
component: SVGIcon
|
|
16
|
+
}, props));
|
|
17
|
+
};
|
|
18
|
+
export default RTLIcon;
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import Footer from './slots/Footer';
|
|
2
|
+
import type { IAllThemeConfig } from './types';
|
|
3
|
+
import Loading from './common/Loading';
|
|
4
|
+
import HomeBaseLayout from './builtins/HomeBaseLayout';
|
|
5
|
+
/**
|
|
6
|
+
* @description provider declaration of config files
|
|
7
|
+
* @param {ThemeConfig} config theme config
|
|
8
|
+
* @returns {ThemeConfig}
|
|
9
|
+
*/
|
|
10
|
+
export declare function defineThemeConfig(config: IAllThemeConfig): IAllThemeConfig;
|
|
11
|
+
export { Loading, Footer, HomeBaseLayout };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import Footer from "dumi/theme/slots/Footer";
|
|
2
|
+
import Loading from "./common/Loading";
|
|
3
|
+
import HomeBaseLayout from "./builtins/HomeBaseLayout";
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* @description provider declaration of config files
|
|
7
|
+
* @param {ThemeConfig} config theme config
|
|
8
|
+
* @returns {ThemeConfig}
|
|
9
|
+
*/
|
|
10
|
+
export function defineThemeConfig(config) {
|
|
11
|
+
return config;
|
|
12
|
+
}
|
|
13
|
+
export { Loading, Footer, HomeBaseLayout };
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
function _EMOTION_STRINGIFIED_CSS_ERROR__() { return "You have tried to stringify object returned from `css` function. It isn't supposed to be used directly (e.g. as value of the `className` prop), but rather handed to emotion so it can handle it (e.g. as value of `css` prop)."; }
|
|
2
|
+
import { css } from '@emotion/react';
|
|
3
|
+
import { Helmet, Outlet, useLocale, useLocation, useOutlet, useRouteMeta, useSiteData } from 'dumi';
|
|
4
|
+
import React, { useEffect, useContext, useMemo } from 'react';
|
|
5
|
+
import classNames from 'classnames';
|
|
6
|
+
import GlobalStyles from "../../common/GlobalStyles";
|
|
7
|
+
import useLocaleValue from "../../hooks/useLocaleValue";
|
|
8
|
+
import Footer from "dumi/theme/slots/Footer";
|
|
9
|
+
import Header from "dumi/theme/slots/Header";
|
|
10
|
+
import Homepage from "../HomePageLayout";
|
|
11
|
+
import SidebarLayout from "../SidebarLayout";
|
|
12
|
+
import SiteContext from "dumi/theme/slots/SiteContext";
|
|
13
|
+
import "../../static/style";
|
|
14
|
+
import { jsx as ___EmotionJSX } from "@emotion/react";
|
|
15
|
+
var _ref = process.env.NODE_ENV === "production" ? {
|
|
16
|
+
name: "zyllbl",
|
|
17
|
+
styles: "display:flex;flex-direction:column;height:100vh"
|
|
18
|
+
} : {
|
|
19
|
+
name: "1dj3qmt-layoutWrap",
|
|
20
|
+
styles: "display:flex;flex-direction:column;height:100vh;label:layoutWrap;",
|
|
21
|
+
map: "/*# s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AgIHtjb250ZW50fVxuICAgIDwvZGl2PlxuICApO1xufTtcblxuZXhwb3J0IGRlZmF1bHQgRG9jTGF5b3V0O1xuIl19 */",
|
|
22
|
+
toString: _EMOTION_STRINGIFIED_CSS_ERROR__
|
|
23
|
+
};
|
|
24
|
+
var useStyles = function useStyles() {
|
|
25
|
+
return {
|
|
26
|
+
layoutWrap: _ref
|
|
27
|
+
};
|
|
28
|
+
};
|
|
29
|
+
var DocLayout = function DocLayout() {
|
|
30
|
+
var _routeMeta$frontmatte2;
|
|
31
|
+
var outlet = useOutlet();
|
|
32
|
+
var locale = useLocale();
|
|
33
|
+
var location = useLocation();
|
|
34
|
+
var styles = useStyles();
|
|
35
|
+
var routeMeta = useRouteMeta();
|
|
36
|
+
var title = useLocaleValue('title');
|
|
37
|
+
var description = useLocaleValue('description');
|
|
38
|
+
var pathname = location.pathname,
|
|
39
|
+
hash = location.hash;
|
|
40
|
+
var _useSiteData = useSiteData(),
|
|
41
|
+
loading = _useSiteData.loading;
|
|
42
|
+
var _useContext = useContext(SiteContext),
|
|
43
|
+
direction = _useContext.direction;
|
|
44
|
+
var is404Home = useMemo(function () {
|
|
45
|
+
return pathname.startsWith('/index') && routeMeta.texts.length === 0;
|
|
46
|
+
}, [pathname, routeMeta]);
|
|
47
|
+
var content = useMemo(function () {
|
|
48
|
+
var _routeMeta$frontmatte;
|
|
49
|
+
if (['', '/'].some(function (path) {
|
|
50
|
+
return path === pathname;
|
|
51
|
+
}) || ['/index'].some(function (path) {
|
|
52
|
+
return pathname.startsWith(path);
|
|
53
|
+
})) {
|
|
54
|
+
return ___EmotionJSX(React.Fragment, null, outlet && !is404Home ? outlet : ___EmotionJSX(Homepage, null), ___EmotionJSX(Footer, null));
|
|
55
|
+
}
|
|
56
|
+
return ((_routeMeta$frontmatte = routeMeta.frontmatter) === null || _routeMeta$frontmatte === void 0 ? void 0 : _routeMeta$frontmatte.sidebar) === false ? ___EmotionJSX("div", null, ___EmotionJSX(Outlet, null), ___EmotionJSX(Footer, null)) : ___EmotionJSX(SidebarLayout, null, ___EmotionJSX(Outlet, null));
|
|
57
|
+
}, [(_routeMeta$frontmatte2 = routeMeta.frontmatter) === null || _routeMeta$frontmatte2 === void 0 ? void 0 : _routeMeta$frontmatte2.sidebar, outlet, pathname, is404Home]);
|
|
58
|
+
|
|
59
|
+
// handle hash change or visit page hash from Link component, and jump after async chunk loaded
|
|
60
|
+
useEffect(function () {
|
|
61
|
+
var _document$getElementB;
|
|
62
|
+
var id = hash.replace('#', '');
|
|
63
|
+
if (id) (_document$getElementB = document.getElementById(decodeURIComponent(id))) === null || _document$getElementB === void 0 ? void 0 : _document$getElementB.scrollIntoView();
|
|
64
|
+
}, [loading, hash]);
|
|
65
|
+
return ___EmotionJSX("div", {
|
|
66
|
+
css: styles.layoutWrap
|
|
67
|
+
}, ___EmotionJSX(Helmet, {
|
|
68
|
+
encodeSpecialCharacters: false
|
|
69
|
+
}, ___EmotionJSX("html", {
|
|
70
|
+
lang: locale.id,
|
|
71
|
+
"data-direction": direction,
|
|
72
|
+
className: classNames(['dumi-theme-antd-root', {
|
|
73
|
+
rtl: direction === 'rtl'
|
|
74
|
+
}])
|
|
75
|
+
}), ___EmotionJSX("title", null, "".concat(title || 'dumi-theme-antd').concat(description ? "-".concat(description) : '')), ___EmotionJSX("link", {
|
|
76
|
+
sizes: "144x144",
|
|
77
|
+
href: "https://gw.alipayobjects.com/zos/antfincdn/UmVnt3t4T0/antd.png"
|
|
78
|
+
}), ___EmotionJSX("meta", {
|
|
79
|
+
name: "description",
|
|
80
|
+
content: description
|
|
81
|
+
}), ___EmotionJSX("meta", {
|
|
82
|
+
property: "og:title",
|
|
83
|
+
content: title
|
|
84
|
+
}), ___EmotionJSX("meta", {
|
|
85
|
+
property: "og:type",
|
|
86
|
+
content: "website"
|
|
87
|
+
}), ___EmotionJSX("meta", {
|
|
88
|
+
property: "og:image",
|
|
89
|
+
content: "https://gw.alipayobjects.com/zos/rmsportal/rlpTLlbMzTNYuZGGCVYM.png"
|
|
90
|
+
})), ___EmotionJSX(GlobalStyles, null), ___EmotionJSX(Header, null), content);
|
|
91
|
+
};
|
|
92
|
+
export default DocLayout;
|
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
|
2
|
+
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
3
|
+
import { createCache, legacyNotSelectorLinter, logicalPropertiesLinter, parentSelectorLinter, StyleProvider, extractStyle } from '@ant-design/cssinjs';
|
|
4
|
+
import { ConfigProvider, theme as antdTheme } from 'antd';
|
|
5
|
+
import { Outlet, usePrefersColor, useServerInsertedHTML } from 'dumi';
|
|
6
|
+
import React, { useCallback, useEffect, useMemo, useState } from 'react';
|
|
7
|
+
import useAdditionalThemeConfig from "../hooks/useAdditionalThemeConfig";
|
|
8
|
+
import ThemeSwitch from "../common/ThemeSwitch";
|
|
9
|
+
import SiteContext from "dumi/theme/slots/SiteContext";
|
|
10
|
+
import { jsx as ___EmotionJSX } from "@emotion/react";
|
|
11
|
+
var RESPONSIVE_MOBILE = 768;
|
|
12
|
+
var SITE_STATE_LOCALSTORAGE_KEY = 'dumi-theme-antd-site-state';
|
|
13
|
+
var defaultSiteState = {
|
|
14
|
+
theme: ['light'],
|
|
15
|
+
isMobile: false,
|
|
16
|
+
direction: 'ltr'
|
|
17
|
+
};
|
|
18
|
+
var getAlgorithm = function getAlgorithm() {
|
|
19
|
+
var themes = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
|
|
20
|
+
return themes.map(function (theme) {
|
|
21
|
+
if (theme === 'dark') {
|
|
22
|
+
return antdTheme.darkAlgorithm;
|
|
23
|
+
}
|
|
24
|
+
if (theme === 'compact') {
|
|
25
|
+
return antdTheme.compactAlgorithm;
|
|
26
|
+
}
|
|
27
|
+
return antdTheme.defaultAlgorithm;
|
|
28
|
+
});
|
|
29
|
+
};
|
|
30
|
+
var isThemeDark = function isThemeDark() {
|
|
31
|
+
return window.matchMedia('(prefers-color-scheme: dark)').matches;
|
|
32
|
+
};
|
|
33
|
+
var getSiteState = function getSiteState(siteState) {
|
|
34
|
+
var localSiteState = siteState;
|
|
35
|
+
var isDark = isThemeDark(); // 系统默认主题
|
|
36
|
+
var theme = (localSiteState === null || localSiteState === void 0 ? void 0 : localSiteState.theme) || [];
|
|
37
|
+
var isAutoTheme = theme.filter(function (item) {
|
|
38
|
+
return item === 'auto';
|
|
39
|
+
}).length > 0;
|
|
40
|
+
if (isAutoTheme) {
|
|
41
|
+
var nextTheme = theme.filter(function (item) {
|
|
42
|
+
return item !== 'auto';
|
|
43
|
+
});
|
|
44
|
+
nextTheme.push(isDark ? 'dark' : 'light');
|
|
45
|
+
localSiteState.theme = nextTheme;
|
|
46
|
+
}
|
|
47
|
+
return Object.assign(defaultSiteState, localSiteState);
|
|
48
|
+
};
|
|
49
|
+
var GlobalLayout = function GlobalLayout() {
|
|
50
|
+
var _usePrefersColor = usePrefersColor(),
|
|
51
|
+
_usePrefersColor2 = _slicedToArray(_usePrefersColor, 3),
|
|
52
|
+
setPrefersColor = _usePrefersColor2[2];
|
|
53
|
+
var _useAdditionalThemeCo = useAdditionalThemeConfig(),
|
|
54
|
+
configTheme = _useAdditionalThemeCo.theme,
|
|
55
|
+
ssr = _useAdditionalThemeCo.ssr,
|
|
56
|
+
prefersColor = _useAdditionalThemeCo.prefersColor;
|
|
57
|
+
var _useState = useState(defaultSiteState),
|
|
58
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
59
|
+
_useState2$ = _useState2[0],
|
|
60
|
+
theme = _useState2$.theme,
|
|
61
|
+
isMobile = _useState2$.isMobile,
|
|
62
|
+
direction = _useState2$.direction,
|
|
63
|
+
setSiteState = _useState2[1];
|
|
64
|
+
|
|
65
|
+
// 基于 localStorage 实现
|
|
66
|
+
var updateSiteConfig = useCallback(function (props) {
|
|
67
|
+
try {
|
|
68
|
+
var localSiteState = JSON.parse(window.localStorage.getItem(SITE_STATE_LOCALSTORAGE_KEY) || '{}');
|
|
69
|
+
var nextLocalSiteState = Object.assign(localSiteState, props);
|
|
70
|
+
window.localStorage.setItem(SITE_STATE_LOCALSTORAGE_KEY, JSON.stringify(nextLocalSiteState));
|
|
71
|
+
setSiteState(function (prev) {
|
|
72
|
+
return _objectSpread(_objectSpread({}, prev), props);
|
|
73
|
+
});
|
|
74
|
+
} catch (error) {
|
|
75
|
+
// eslint-disable-next-line no-console
|
|
76
|
+
console.error(error);
|
|
77
|
+
}
|
|
78
|
+
}, []);
|
|
79
|
+
var updateMobileMode = useCallback(function () {
|
|
80
|
+
updateSiteConfig({
|
|
81
|
+
isMobile: window.innerWidth < RESPONSIVE_MOBILE
|
|
82
|
+
});
|
|
83
|
+
}, [updateSiteConfig]);
|
|
84
|
+
useEffect(function () {
|
|
85
|
+
try {
|
|
86
|
+
var localSiteState = JSON.parse(window.localStorage.getItem(SITE_STATE_LOCALSTORAGE_KEY) || '{}');
|
|
87
|
+
// 首次设置主题样式
|
|
88
|
+
if (!(localSiteState !== null && localSiteState !== void 0 && localSiteState.theme)) {
|
|
89
|
+
localSiteState.theme = [prefersColor.default];
|
|
90
|
+
}
|
|
91
|
+
var siteConfig = getSiteState(localSiteState);
|
|
92
|
+
updateSiteConfig(siteConfig);
|
|
93
|
+
} catch (error) {
|
|
94
|
+
// eslint-disable-next-line no-console
|
|
95
|
+
console.error(error);
|
|
96
|
+
}
|
|
97
|
+
}, [prefersColor, updateSiteConfig]);
|
|
98
|
+
useEffect(function () {
|
|
99
|
+
updateMobileMode();
|
|
100
|
+
// set data-prefers-color
|
|
101
|
+
setPrefersColor(theme.indexOf('dark') > -1 ? 'dark' : 'light');
|
|
102
|
+
window.addEventListener('resize', updateMobileMode);
|
|
103
|
+
return function () {
|
|
104
|
+
window.removeEventListener('resize', updateMobileMode);
|
|
105
|
+
};
|
|
106
|
+
}, [theme, updateMobileMode, setPrefersColor]);
|
|
107
|
+
var siteContextValue = useMemo(function () {
|
|
108
|
+
return {
|
|
109
|
+
direction: direction,
|
|
110
|
+
isMobile: isMobile,
|
|
111
|
+
theme: theme,
|
|
112
|
+
updateSiteConfig: updateSiteConfig
|
|
113
|
+
};
|
|
114
|
+
}, [isMobile, theme, direction, updateSiteConfig]);
|
|
115
|
+
var _React$useState = React.useState(function () {
|
|
116
|
+
return ssr ? createCache() : [null];
|
|
117
|
+
}),
|
|
118
|
+
_React$useState2 = _slicedToArray(_React$useState, 1),
|
|
119
|
+
styleCache = _React$useState2[0];
|
|
120
|
+
useServerInsertedHTML(function () {
|
|
121
|
+
var styleText = extractStyle(styleCache, true);
|
|
122
|
+
return ___EmotionJSX("style", {
|
|
123
|
+
"data-type": "antd-cssinjs",
|
|
124
|
+
dangerouslySetInnerHTML: {
|
|
125
|
+
__html: styleText
|
|
126
|
+
}
|
|
127
|
+
});
|
|
128
|
+
});
|
|
129
|
+
var BaseGlobalLayoutJSX = ___EmotionJSX(SiteContext.Provider, {
|
|
130
|
+
value: siteContextValue
|
|
131
|
+
}, ___EmotionJSX(ConfigProvider, {
|
|
132
|
+
theme: _objectSpread(_objectSpread({}, configTheme), {}, {
|
|
133
|
+
algorithm: getAlgorithm(theme)
|
|
134
|
+
})
|
|
135
|
+
}, ___EmotionJSX(Outlet, null), prefersColor.switch && ___EmotionJSX(ThemeSwitch, {
|
|
136
|
+
value: theme,
|
|
137
|
+
onChange: function onChange(nextTheme) {
|
|
138
|
+
return updateSiteConfig({
|
|
139
|
+
theme: nextTheme
|
|
140
|
+
});
|
|
141
|
+
}
|
|
142
|
+
})));
|
|
143
|
+
var SSRGlobalLayoutJSX = ___EmotionJSX(StyleProvider, {
|
|
144
|
+
cache: styleCache,
|
|
145
|
+
linters: [logicalPropertiesLinter, legacyNotSelectorLinter, parentSelectorLinter]
|
|
146
|
+
}, BaseGlobalLayoutJSX);
|
|
147
|
+
if (ssr) {
|
|
148
|
+
global.styleCache = styleCache;
|
|
149
|
+
return SSRGlobalLayoutJSX;
|
|
150
|
+
}
|
|
151
|
+
return BaseGlobalLayoutJSX;
|
|
152
|
+
};
|
|
153
|
+
export default GlobalLayout;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import HomeBaseLayout from "../../builtins/HomeBaseLayout";
|
|
3
|
+
import { jsx as ___EmotionJSX } from "@emotion/react";
|
|
4
|
+
var HomePageLayout = function HomePageLayout() {
|
|
5
|
+
return ___EmotionJSX(HomeBaseLayout, null);
|
|
6
|
+
};
|
|
7
|
+
export default HomePageLayout;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
function _EMOTION_STRINGIFIED_CSS_ERROR__() { return "You have tried to stringify object returned from `css` function. It isn't supposed to be used directly (e.g. as value of the `className` prop), but rather handed to emotion so it can handle it (e.g. as value of `css` prop)."; }
|
|
2
|
+
import { css } from '@emotion/react';
|
|
3
|
+
import CommonHelmet from "../../common/CommonHelmet";
|
|
4
|
+
import Content from "dumi/theme/slots/Content";
|
|
5
|
+
import Sidebar from "dumi/theme/slots/Sidebar";
|
|
6
|
+
import { jsx as ___EmotionJSX } from "@emotion/react";
|
|
7
|
+
var _ref = process.env.NODE_ENV === "production" ? {
|
|
8
|
+
name: "18q6uyv",
|
|
9
|
+
styles: "display:flex;flex:1;margin-top:40px"
|
|
10
|
+
} : {
|
|
11
|
+
name: "10hxsxx-mainWrap",
|
|
12
|
+
styles: "display:flex;flex:1;margin-top:40px;label:mainWrap;",
|
|
13
|
+
map: "/*# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImluZGV4LnRzeCJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFRaUIiLCJmaWxlIjoiaW5kZXgudHN4Iiwic291cmNlc0NvbnRlbnQiOlsiaW1wb3J0IHsgY3NzIH0gZnJvbSAnQGVtb3Rpb24vcmVhY3QnO1xuaW1wb3J0IHR5cGUgeyBGQywgUHJvcHNXaXRoQ2hpbGRyZW4gfSBmcm9tICdyZWFjdCc7XG5pbXBvcnQgQ29tbW9uSGVsbWV0IGZyb20gJy4uLy4uL2NvbW1vbi9Db21tb25IZWxtZXQnO1xuaW1wb3J0IENvbnRlbnQgZnJvbSAnLi4vLi4vc2xvdHMvQ29udGVudCc7XG5pbXBvcnQgU2lkZWJhciBmcm9tICcuLi8uLi9zbG90cy9TaWRlYmFyJztcblxuY29uc3QgdXNlU3R5bGUgPSAoKSA9PiB7XG4gIHJldHVybiB7XG4gICAgbWFpbldyYXA6IGNzc2BcbiAgICAgIGRpc3BsYXk6IGZsZXg7XG4gICAgICBmbGV4OiAxO1xuICAgICAgbWFyZ2luLXRvcDogNDBweDtcbiAgICBgXG4gIH07XG59O1xuXG5jb25zdCBTaWRlYmFyTGF5b3V0OiBGQzxQcm9wc1dpdGhDaGlsZHJlbj4gPSAoeyBjaGlsZHJlbiB9KSA9PiB7XG4gIGNvbnN0IHN0eWxlID0gdXNlU3R5bGUoKTtcbiAgcmV0dXJuIChcbiAgICA8bWFpbiBjc3M9e3N0eWxlLm1haW5XcmFwfT5cbiAgICAgIDxDb21tb25IZWxtZXQgLz5cbiAgICAgIDxTaWRlYmFyIC8+XG4gICAgICA8Q29udGVudD57Y2hpbGRyZW59PC9Db250ZW50PlxuICAgIDwvbWFpbj5cbiAgKTtcbn07XG5cbmV4cG9ydCBkZWZhdWx0IFNpZGViYXJMYXlvdXQ7XG4iXX0= */",
|
|
14
|
+
toString: _EMOTION_STRINGIFIED_CSS_ERROR__
|
|
15
|
+
};
|
|
16
|
+
var useStyle = function useStyle() {
|
|
17
|
+
return {
|
|
18
|
+
mainWrap: _ref
|
|
19
|
+
};
|
|
20
|
+
};
|
|
21
|
+
var SidebarLayout = function SidebarLayout(_ref2) {
|
|
22
|
+
var children = _ref2.children;
|
|
23
|
+
var style = useStyle();
|
|
24
|
+
return ___EmotionJSX("main", {
|
|
25
|
+
css: style.mainWrap
|
|
26
|
+
}, ___EmotionJSX(CommonHelmet, null), ___EmotionJSX(Sidebar, null), ___EmotionJSX(Content, null, children));
|
|
27
|
+
};
|
|
28
|
+
export default SidebarLayout;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
{
|
|
2
|
+
"app.not-found.back-home": "Back to home page",
|
|
3
|
+
"app.not-found.subTitle": "Sorry, the page you visited does not exist.",
|
|
4
|
+
"app.theme.switch.dark": "Dark theme",
|
|
5
|
+
"app.theme.switch.compact": "Compact theme",
|
|
6
|
+
"app.header.menu.more": "More",
|
|
7
|
+
"app.footer.last.updated": "Last updated: ",
|
|
8
|
+
"app.footer.actions.edit": "Improve this documentation"
|
|
9
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
{
|
|
2
|
+
"app.not-found.back-home": "返回首页",
|
|
3
|
+
"app.not-found.subTitle": "你访问的页面貌似不存在?",
|
|
4
|
+
"app.theme.switch.dark": "暗黑主题",
|
|
5
|
+
"app.theme.switch.compact": "紧凑主题",
|
|
6
|
+
"app.header.menu.more": "更多",
|
|
7
|
+
"app.footer.last.updated": "最后更新时间:",
|
|
8
|
+
"app.footer.actions.edit": "帮助改进此文档"
|
|
9
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
+
};
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
|
|
19
|
+
// src/plugin/index.ts
|
|
20
|
+
var plugin_exports = {};
|
|
21
|
+
__export(plugin_exports, {
|
|
22
|
+
default: () => plugin_default
|
|
23
|
+
});
|
|
24
|
+
module.exports = __toCommonJS(plugin_exports);
|
|
25
|
+
var plugin_default = (api) => {
|
|
26
|
+
api.describe({
|
|
27
|
+
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
28
|
+
key: `dumi-theme:${require("../../package.json").name}`
|
|
29
|
+
});
|
|
30
|
+
};
|
package/dist/plugin.d.ts
ADDED
package/dist/plugin.js
ADDED
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from))
|
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
21
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
22
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
23
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
24
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
25
|
+
mod
|
|
26
|
+
));
|
|
27
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
28
|
+
|
|
29
|
+
// src/plugin.ts
|
|
30
|
+
var plugin_exports = {};
|
|
31
|
+
__export(plugin_exports, {
|
|
32
|
+
default: () => plugin_default,
|
|
33
|
+
getHash: () => getHash
|
|
34
|
+
});
|
|
35
|
+
module.exports = __toCommonJS(plugin_exports);
|
|
36
|
+
var import_fs = __toESM(require("fs"));
|
|
37
|
+
var import_path = __toESM(require("path"));
|
|
38
|
+
var import_crypto = require("crypto");
|
|
39
|
+
var import_create_instance = __toESM(require("@emotion/server/create-instance"));
|
|
40
|
+
var import_css = require("@emotion/css");
|
|
41
|
+
function extractEmotionStyle(html) {
|
|
42
|
+
if (html === void 0) {
|
|
43
|
+
throw new Error("did you forget to return html from renderToString?");
|
|
44
|
+
}
|
|
45
|
+
const { extractCritical } = (0, import_create_instance.default)(import_css.cache);
|
|
46
|
+
const { ids, css } = extractCritical(html);
|
|
47
|
+
if (!css)
|
|
48
|
+
return [];
|
|
49
|
+
return [
|
|
50
|
+
{
|
|
51
|
+
key: import_css.cache.key,
|
|
52
|
+
ids,
|
|
53
|
+
css,
|
|
54
|
+
tag: `<style data-emotion="${import_css.cache.key} ${ids.join(" ")}">${css}</style>`
|
|
55
|
+
}
|
|
56
|
+
];
|
|
57
|
+
}
|
|
58
|
+
var getHash = (str, length = 8) => (0, import_crypto.createHash)("md5").update(str).digest("hex").slice(0, length);
|
|
59
|
+
var dumiThemeUmiPlugin = (api) => {
|
|
60
|
+
const writeCSSFile = (key, hashKey, cssString) => {
|
|
61
|
+
const fileName = `style-${key}.${getHash(hashKey)}.css`;
|
|
62
|
+
const filePath = import_path.default.join(api.paths.absOutputPath, fileName);
|
|
63
|
+
if (!import_fs.default.existsSync(filePath)) {
|
|
64
|
+
import_fs.default.writeFileSync(filePath, cssString, "utf8");
|
|
65
|
+
}
|
|
66
|
+
return fileName;
|
|
67
|
+
};
|
|
68
|
+
const addLinkStyle = (html, cssFile, prepend = false) => {
|
|
69
|
+
const prefix = api.userConfig.publicPath || api.config.publicPath;
|
|
70
|
+
if (prepend) {
|
|
71
|
+
return html.replace("<head>", `<head><link rel="stylesheet" href="${prefix + cssFile}">`);
|
|
72
|
+
}
|
|
73
|
+
return html.replace("</head>", `<link rel="stylesheet" href="${prefix + cssFile}"></head>`);
|
|
74
|
+
};
|
|
75
|
+
api.modifyConfig((memo) => {
|
|
76
|
+
memo.themeConfig.ssr = memo.ssr;
|
|
77
|
+
return memo;
|
|
78
|
+
});
|
|
79
|
+
api.modifyExportHTMLFiles((files) => {
|
|
80
|
+
var _a;
|
|
81
|
+
if ((_a = api.config) == null ? void 0 : _a.ssr) {
|
|
82
|
+
const nextFiles = files.filter((f) => !f.path.includes(":")).map((file) => {
|
|
83
|
+
let globalStyles = "";
|
|
84
|
+
file.content = file.content.replace(
|
|
85
|
+
/<style (data-emotion|data-sandpack)[\S\s]+?<\/style>/g,
|
|
86
|
+
(s) => {
|
|
87
|
+
globalStyles += s;
|
|
88
|
+
return "";
|
|
89
|
+
}
|
|
90
|
+
);
|
|
91
|
+
file.content = file.content.replace("</head>", `${globalStyles}</head>`);
|
|
92
|
+
const styles = extractEmotionStyle(file.content);
|
|
93
|
+
styles.forEach((result) => {
|
|
94
|
+
const cssFile2 = writeCSSFile(result.key, result.ids.join(""), result.css);
|
|
95
|
+
file.content = addLinkStyle(file.content, cssFile2);
|
|
96
|
+
});
|
|
97
|
+
const matchRegex = /<style data-type="antd-cssinjs">(.*?)<\/style>/;
|
|
98
|
+
const matchList = file.content.match(matchRegex) || [];
|
|
99
|
+
let antdStyle = "";
|
|
100
|
+
matchList.forEach((text) => {
|
|
101
|
+
file.content = file.content.replace(text, "");
|
|
102
|
+
antdStyle += text.replace(matchRegex, "$1");
|
|
103
|
+
});
|
|
104
|
+
const cssFile = writeCSSFile("antd", antdStyle, antdStyle);
|
|
105
|
+
file.content = addLinkStyle(file.content, cssFile, true);
|
|
106
|
+
return file;
|
|
107
|
+
});
|
|
108
|
+
return nextFiles;
|
|
109
|
+
}
|
|
110
|
+
return files;
|
|
111
|
+
});
|
|
112
|
+
};
|
|
113
|
+
var plugin_default = dumiThemeUmiPlugin;
|
|
114
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
115
|
+
0 && (module.exports = {
|
|
116
|
+
getHash
|
|
117
|
+
});
|