Skip to content

Commit 645d6ed

Browse files
🌷 UI: alway set theme (#9458)
* 🌷 UI: alway set theme * 🌷 UI: support dynamic theme * merge master
1 parent a2d8f88 commit 645d6ed

File tree

13 files changed

+38
-20
lines changed

13 files changed

+38
-20
lines changed

Diff for: .github/workflows/deploy.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ jobs:
1515
run: yarn
1616

1717
- name: plugins
18-
run: yarn add umi-plugin-antd-theme umi-plugin-pro umi-plugin-setting-drawer
18+
run: yarn add umi-plugin-pro
1919

2020
- name: fetch-blocks
2121
run: yarn run pro fetch-blocks

Diff for: config/config.ts

+1-2
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,7 @@ export default defineConfig({
3838
routes,
3939
// Theme for antd: https://ant.design/docs/react/customize-theme-cn
4040
theme: {
41-
'primary-color': defaultSettings.primaryColor,
42-
'root-entry-name': 'default',
41+
'root-entry-name': 'variable',
4342
},
4443
// esbuild is father build tools
4544
// https://umijs.org/plugins/plugin-esbuild

Diff for: package.json

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "ant-design-pro",
3-
"version": "5.1.0",
3+
"version": "5.2.0",
44
"private": true,
55
"description": "An out-of-box UI solution for enterprise applications",
66
"scripts": {
@@ -57,10 +57,10 @@
5757
"@ant-design/icons": "^4.5.0",
5858
"@ant-design/pro-descriptions": "^1.9.0",
5959
"@ant-design/pro-form": "^1.43.0",
60-
"@ant-design/pro-layout": "^6.26.0",
60+
"@ant-design/pro-layout": "^6.32.0-beta.4",
6161
"@ant-design/pro-table": "^2.56.0",
62-
"@umijs/route-utils": "^2.0.3",
63-
"antd": "4.16.13",
62+
"@umijs/route-utils": "^2.0.4",
63+
"antd": "^4.17.0",
6464
"classnames": "^2.2.6",
6565
"lodash": "^4.17.11",
6666
"moment": "^2.25.3",

Diff for: src/app.tsx

+23-5
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import type { Settings as LayoutSettings } from '@ant-design/pro-layout';
2+
import { SettingDrawer } from '@ant-design/pro-layout';
23
import { PageLoading } from '@ant-design/pro-layout';
34
import type { RunTimeLayoutConfig } from 'umi';
45
import { history, Link } from 'umi';
@@ -21,6 +22,7 @@ export const initialStateConfig = {
2122
export async function getInitialState(): Promise<{
2223
settings?: Partial<LayoutSettings>;
2324
currentUser?: API.CurrentUser;
25+
loading?: boolean;
2426
fetchUserInfo?: () => Promise<API.CurrentUser | undefined>;
2527
}> {
2628
const fetchUserInfo = async () => {
@@ -48,7 +50,7 @@ export async function getInitialState(): Promise<{
4850
}
4951

5052
// ProLayout 支持的api https://procomponents.ant.design/components/layout
51-
export const layout: RunTimeLayoutConfig = ({ initialState }) => {
53+
export const layout: RunTimeLayoutConfig = ({ initialState, setInitialState }) => {
5254
return {
5355
rightContentRender: () => <RightContent />,
5456
disableContentMargin: false,
@@ -79,10 +81,26 @@ export const layout: RunTimeLayoutConfig = ({ initialState }) => {
7981
// 自定义 403 页面
8082
// unAccessible: <div>unAccessible</div>,
8183
// 增加一个 loading 的状态
82-
// childrenRender: (children) => {
83-
// if (initialState.loading) return <PageLoading />;
84-
// return children;
85-
// },
84+
childrenRender: (children, props) => {
85+
// if (initialState?.loading) return <PageLoading />;
86+
return (
87+
<>
88+
{children}
89+
{!props.location?.pathname?.includes('/login') && (
90+
<SettingDrawer
91+
enableDarkTheme
92+
settings={initialState?.settings}
93+
onSettingChange={(settings) => {
94+
setInitialState((preInitialState) => ({
95+
...preInitialState,
96+
settings,
97+
}));
98+
}}
99+
/>
100+
)}
101+
</>
102+
);
103+
},
86104
...initialState?.settings,
87105
};
88106
};

Diff for: src/components/HeaderDropdown/index.less

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
@import '~antd/es/style/themes/default.less';
1+
@import (reference) '~antd/es/style/themes/index';
22

33
.container > * {
44
background-color: @popover-bg;

Diff for: src/components/HeaderSearch/index.less

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
@import '~antd/es/style/themes/default.less';
1+
@import (reference) '~antd/es/style/themes/index';
22

33
.headerSearch {
44
display: inline-flex;

Diff for: src/components/NoticeIcon/NoticeList.less

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
@import '~antd/es/style/themes/default.less';
1+
@import (reference) '~antd/es/style/themes/index';
22

33
.list {
44
max-height: 400px;

Diff for: src/components/NoticeIcon/index.less

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
@import '~antd/es/style/themes/default.less';
1+
@import (reference) '~antd/es/style/themes/index';
22

33
.popover {
44
position: relative;

Diff for: src/components/RightContent/index.less

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
@import '~antd/es/style/themes/default.less';
1+
@import (reference) '~antd/es/style/themes/index';
22

33
@pro-header-hover-bg: rgba(0, 0, 0, 0.025);
44

Diff for: src/global.less

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
@import '~antd/es/style/themes/default.less';
1+
@import '~antd/es/style/variable.less';
22

33
html,
44
body,

Diff for: src/pages/Welcome.less

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
@import '~antd/lib/style/themes/default.less';
1+
@import (reference) '~antd/es/style/themes/index';
22

33
.pre {
44
margin: 12px 0;

Diff for: src/pages/Welcome.tsx

+1
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ const CodePreview: React.FC = ({ children }) => (
1414

1515
const Welcome: React.FC = () => {
1616
const intl = useIntl();
17+
1718
return (
1819
<PageContainer>
1920
<Card>

Diff for: src/pages/user/Login/index.less

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
@import '~antd/es/style/themes/default.less';
1+
@import (reference) '~antd/es/style/themes/index';
22

33
.container {
44
display: flex;

0 commit comments

Comments
 (0)