正在显示
12 个修改的文件
包含
414 行增加
和
0 行删除
ant-design-pro/ResultSuccess/.gitignore
0 → 100644
ant-design-pro/ResultSuccess/.umirc.js
0 → 100644
1 | +import React, { PureComponent } from 'react'; | ||
2 | +import { connect } from 'dva'; | ||
3 | +import styles from './GridContent.less'; | ||
4 | + | ||
5 | +class GridContent extends PureComponent { | ||
6 | + render() { | ||
7 | + const { contentWidth, children } = this.props; | ||
8 | + let className = `${styles.main}`; | ||
9 | + if (contentWidth === 'Fixed') { | ||
10 | + className = `${styles.main} ${styles.wide}`; | ||
11 | + } | ||
12 | + return <div className={className}>{children}</div>; | ||
13 | + } | ||
14 | +} | ||
15 | + | ||
16 | +export default connect(({ setting }) => ({ | ||
17 | + contentWidth: setting.contentWidth, | ||
18 | +}))(GridContent); |
1 | +import React from 'react'; | ||
2 | +import { FormattedMessage } from 'umi/locale'; | ||
3 | +import Link from 'umi/link'; | ||
4 | +import PageHeader from 'ant-design-pro/lib/PageHeader'; | ||
5 | +import { connect } from 'dva'; | ||
6 | +import GridContent from './GridContent'; | ||
7 | +import styles from './index.less'; | ||
8 | +import MenuContext from '@/layouts/MenuContext'; | ||
9 | + | ||
10 | +const PageHeaderWrapper = ({ children, contentWidth, wrapperClassName, top, ...restProps }) => ( | ||
11 | + <div style={{ margin: '-24px -24px 0' }} className={wrapperClassName}> | ||
12 | + {top} | ||
13 | + <MenuContext.Consumer> | ||
14 | + {value => ( | ||
15 | + <PageHeader | ||
16 | + wide={contentWidth === 'Fixed'} | ||
17 | + home={<FormattedMessage id="menu.home" defaultMessage="Home" />} | ||
18 | + {...value} | ||
19 | + key="pageheader" | ||
20 | + {...restProps} | ||
21 | + linkElement={Link} | ||
22 | + itemRender={item => { | ||
23 | + if (item.locale) { | ||
24 | + return <FormattedMessage id={item.locale} defaultMessage={item.title} />; | ||
25 | + } | ||
26 | + return item.title; | ||
27 | + }} | ||
28 | + /> | ||
29 | + )} | ||
30 | + </MenuContext.Consumer> | ||
31 | + {children ? ( | ||
32 | + <div className={styles.content}> | ||
33 | + <GridContent>{children}</GridContent> | ||
34 | + </div> | ||
35 | + ) : null} | ||
36 | + </div> | ||
37 | +); | ||
38 | + | ||
39 | +export default connect(({ setting }) => ({ | ||
40 | + contentWidth: setting.contentWidth, | ||
41 | +}))(PageHeaderWrapper); |
ant-design-pro/ResultSuccess/README.md
0 → 100644
ant-design-pro/ResultSuccess/package.json
0 → 100644
1 | +{ | ||
2 | + "name": "@umi-block/resultsuccess", | ||
3 | + "version": "0.0.1", | ||
4 | + "description": "ResultSuccess", | ||
5 | + "main": "src/index.js", | ||
6 | + "scripts": { | ||
7 | + "dev": "umi dev" | ||
8 | + }, | ||
9 | + "repository": { | ||
10 | + "type": "git", | ||
11 | + "url": "https://github.com/umijs/umi-blocks/resultsuccess" | ||
12 | + }, | ||
13 | + "dependencies": { | ||
14 | + "react": "^16.6.3", | ||
15 | + "antd": "^3.10.9", | ||
16 | + "ant-design-pro": "^2.1.1", | ||
17 | + "dva": "^2.4.0" | ||
18 | + }, | ||
19 | + "devDependencies": { | ||
20 | + "umi": "^2.3.0-beta.1", | ||
21 | + "umi-plugin-react": "^1.3.0-beta.1", | ||
22 | + "umi-plugin-block-dev": "^1.0.0" | ||
23 | + }, | ||
24 | + "license": "ISC" | ||
25 | +} |
1 | +module.exports = { | ||
2 | + navTheme: 'dark', // theme for nav menu | ||
3 | + primaryColor: '#1890FF', // primary color of ant design | ||
4 | + layout: 'sidemenu', // nav menu position: sidemenu or topmenu | ||
5 | + contentWidth: 'Fluid', // layout of content: Fluid or Fixed, only works when layout is topmenu | ||
6 | + fixedHeader: false, // sticky header | ||
7 | + autoHideHeader: false, // auto hide header | ||
8 | + fixSiderbar: false, // sticky siderbar | ||
9 | +}; |
ant-design-pro/ResultSuccess/src/index.js
0 → 100644
1 | +import React, { Fragment } from 'react'; | ||
2 | +import { formatMessage, FormattedMessage } from 'umi/locale'; | ||
3 | +import { Button, Row, Col, Icon, Steps, Card } from 'antd'; | ||
4 | +import Result from 'ant-design-pro/lib/Result'; | ||
5 | +import PageHeaderWrapper from '@/components/PageHeaderWrapper'; | ||
6 | + | ||
7 | +const { Step } = Steps; | ||
8 | + | ||
9 | +const desc1 = ( | ||
10 | + <div | ||
11 | + style={{ | ||
12 | + fontSize: 12, | ||
13 | + color: 'rgba(0, 0, 0, 0.45)', | ||
14 | + position: 'relative', | ||
15 | + left: 42, | ||
16 | + textAlign: 'left', | ||
17 | + }} | ||
18 | + > | ||
19 | + <div style={{ margin: '8px 0 4px' }}> | ||
20 | + <FormattedMessage id="app.result.success.step1-operator" defaultMessage="Qu Lili" /> | ||
21 | + <Icon style={{ marginLeft: 8 }} type="dingding-o" /> | ||
22 | + </div> | ||
23 | + <div>2016-12-12 12:32</div> | ||
24 | + </div> | ||
25 | +); | ||
26 | + | ||
27 | +const desc2 = ( | ||
28 | + <div style={{ fontSize: 12, position: 'relative', left: 42, textAlign: 'left' }}> | ||
29 | + <div style={{ margin: '8px 0 4px' }}> | ||
30 | + <FormattedMessage id="app.result.success.step2-operator" defaultMessage="Zhou Maomao" /> | ||
31 | + <Icon type="dingding-o" style={{ color: '#00A0E9', marginLeft: 8 }} /> | ||
32 | + </div> | ||
33 | + <div> | ||
34 | + <a href=""> | ||
35 | + <FormattedMessage id="app.result.success.step2-extra" defaultMessage="Urge" /> | ||
36 | + </a> | ||
37 | + </div> | ||
38 | + </div> | ||
39 | +); | ||
40 | + | ||
41 | +const extra = ( | ||
42 | + <Fragment> | ||
43 | + <div | ||
44 | + style={{ | ||
45 | + fontSize: 16, | ||
46 | + color: 'rgba(0, 0, 0, 0.85)', | ||
47 | + fontWeight: '500', | ||
48 | + marginBottom: 20, | ||
49 | + }} | ||
50 | + > | ||
51 | + <FormattedMessage id="app.result.success.operate-title" defaultMessage="Project Name" /> | ||
52 | + </div> | ||
53 | + <Row style={{ marginBottom: 16 }}> | ||
54 | + <Col xs={24} sm={12} md={12} lg={12} xl={6}> | ||
55 | + <span style={{ color: 'rgba(0, 0, 0, 0.85)' }}> | ||
56 | + <FormattedMessage id="app.result.success.operate-id" defaultMessage="Project ID:" /> | ||
57 | + </span> | ||
58 | + 23421 | ||
59 | + </Col> | ||
60 | + <Col xs={24} sm={12} md={12} lg={12} xl={6}> | ||
61 | + <span style={{ color: 'rgba(0, 0, 0, 0.85)' }}> | ||
62 | + <FormattedMessage id="app.result.success.principal" defaultMessage="Principal:" /> | ||
63 | + </span> | ||
64 | + <FormattedMessage id="app.result.success.step1-operator" defaultMessage="Qu Lili" /> | ||
65 | + </Col> | ||
66 | + <Col xs={24} sm={24} md={24} lg={24} xl={12}> | ||
67 | + <span style={{ color: 'rgba(0, 0, 0, 0.85)' }}> | ||
68 | + <FormattedMessage | ||
69 | + id="app.result.success.operate-time" | ||
70 | + defaultMessage="Effective time:" | ||
71 | + /> | ||
72 | + </span> | ||
73 | + 2016-12-12 ~ 2017-12-12 | ||
74 | + </Col> | ||
75 | + </Row> | ||
76 | + <Steps style={{ marginLeft: -42, width: 'calc(100% + 84px)' }} progressDot current={1}> | ||
77 | + <Step | ||
78 | + title={ | ||
79 | + <span style={{ fontSize: 14 }}> | ||
80 | + <FormattedMessage id="app.result.success.step1-title" defaultMessage="Create project" /> | ||
81 | + </span> | ||
82 | + } | ||
83 | + description={desc1} | ||
84 | + /> | ||
85 | + <Step | ||
86 | + title={ | ||
87 | + <span style={{ fontSize: 14 }}> | ||
88 | + <FormattedMessage | ||
89 | + id="app.result.success.step2-title" | ||
90 | + defaultMessage="Departmental preliminary review" | ||
91 | + /> | ||
92 | + </span> | ||
93 | + } | ||
94 | + description={desc2} | ||
95 | + /> | ||
96 | + <Step | ||
97 | + title={ | ||
98 | + <span style={{ fontSize: 14 }}> | ||
99 | + <FormattedMessage | ||
100 | + id="app.result.success.step3-title" | ||
101 | + defaultMessage="Financial review" | ||
102 | + /> | ||
103 | + </span> | ||
104 | + } | ||
105 | + /> | ||
106 | + <Step | ||
107 | + title={ | ||
108 | + <span style={{ fontSize: 14 }}> | ||
109 | + <FormattedMessage id="app.result.success.step4-title" defaultMessage="Finish" /> | ||
110 | + </span> | ||
111 | + } | ||
112 | + /> | ||
113 | + </Steps> | ||
114 | + </Fragment> | ||
115 | +); | ||
116 | + | ||
117 | +const actions = ( | ||
118 | + <Fragment> | ||
119 | + <Button type="primary"> | ||
120 | + <FormattedMessage id="app.result.success.btn-return" defaultMessage="Back to list" /> | ||
121 | + </Button> | ||
122 | + <Button> | ||
123 | + <FormattedMessage id="app.result.success.btn-project" defaultMessage="View project" /> | ||
124 | + </Button> | ||
125 | + <Button> | ||
126 | + <FormattedMessage id="app.result.success.btn-print" defaultMessage="Print" /> | ||
127 | + </Button> | ||
128 | + </Fragment> | ||
129 | +); | ||
130 | + | ||
131 | +export default () => ( | ||
132 | + <PageHeaderWrapper> | ||
133 | + <Card bordered={false}> | ||
134 | + <Result | ||
135 | + type="success" | ||
136 | + title={formatMessage({ id: 'app.result.success.title' })} | ||
137 | + description={formatMessage({ id: 'app.result.success.description' })} | ||
138 | + extra={extra} | ||
139 | + actions={actions} | ||
140 | + style={{ marginTop: 48, marginBottom: 16 }} | ||
141 | + /> | ||
142 | + </Card> | ||
143 | + </PageHeaderWrapper> | ||
144 | +); |
1 | +import { message } from 'antd'; | ||
2 | +import defaultSettings from '../defaultSettings'; | ||
3 | + | ||
4 | +let lessNodesAppended; | ||
5 | +const updateTheme = primaryColor => { | ||
6 | + // Don't compile less in production! | ||
7 | + if (APP_TYPE !== 'site') { | ||
8 | + return; | ||
9 | + } | ||
10 | + // Determine if the component is remounted | ||
11 | + if (!primaryColor) { | ||
12 | + return; | ||
13 | + } | ||
14 | + const hideMessage = message.loading('正在编译主题!', 0); | ||
15 | + function buildIt() { | ||
16 | + if (!window.less) { | ||
17 | + return; | ||
18 | + } | ||
19 | + setTimeout(() => { | ||
20 | + window.less | ||
21 | + .modifyVars({ | ||
22 | + '@primary-color': primaryColor, | ||
23 | + }) | ||
24 | + .then(() => { | ||
25 | + hideMessage(); | ||
26 | + }) | ||
27 | + .catch(() => { | ||
28 | + message.error('Failed to update theme'); | ||
29 | + hideMessage(); | ||
30 | + }); | ||
31 | + }, 200); | ||
32 | + } | ||
33 | + if (!lessNodesAppended) { | ||
34 | + // insert less.js and color.less | ||
35 | + const lessStyleNode = document.createElement('link'); | ||
36 | + const lessConfigNode = document.createElement('script'); | ||
37 | + const lessScriptNode = document.createElement('script'); | ||
38 | + lessStyleNode.setAttribute('rel', 'stylesheet/less'); | ||
39 | + lessStyleNode.setAttribute('href', '/color.less'); | ||
40 | + lessConfigNode.innerHTML = ` | ||
41 | + window.less = { | ||
42 | + async: true, | ||
43 | + env: 'production', | ||
44 | + javascriptEnabled: true | ||
45 | + }; | ||
46 | + `; | ||
47 | + lessScriptNode.src = 'https://gw.alipayobjects.com/os/lib/less.js/3.8.1/less.min.js'; | ||
48 | + lessScriptNode.async = true; | ||
49 | + lessScriptNode.onload = () => { | ||
50 | + buildIt(); | ||
51 | + lessScriptNode.onload = null; | ||
52 | + }; | ||
53 | + document.body.appendChild(lessStyleNode); | ||
54 | + document.body.appendChild(lessConfigNode); | ||
55 | + document.body.appendChild(lessScriptNode); | ||
56 | + lessNodesAppended = true; | ||
57 | + } else { | ||
58 | + buildIt(); | ||
59 | + } | ||
60 | +}; | ||
61 | + | ||
62 | +const updateColorWeak = colorWeak => { | ||
63 | + document.body.className = colorWeak ? 'colorWeak' : ''; | ||
64 | +}; | ||
65 | + | ||
66 | +export default { | ||
67 | + namespace: 'setting', | ||
68 | + state: defaultSettings, | ||
69 | + reducers: { | ||
70 | + getSetting(state) { | ||
71 | + const setting = {}; | ||
72 | + const urlParams = new URL(window.location.href); | ||
73 | + Object.keys(state).forEach(key => { | ||
74 | + if (urlParams.searchParams.has(key)) { | ||
75 | + const value = urlParams.searchParams.get(key); | ||
76 | + setting[key] = value === '1' ? true : value; | ||
77 | + } | ||
78 | + }); | ||
79 | + const { primaryColor, colorWeak } = setting; | ||
80 | + if (state.primaryColor !== primaryColor) { | ||
81 | + updateTheme(primaryColor); | ||
82 | + } | ||
83 | + updateColorWeak(colorWeak); | ||
84 | + return { | ||
85 | + ...state, | ||
86 | + ...setting, | ||
87 | + }; | ||
88 | + }, | ||
89 | + changeSetting(state, { payload }) { | ||
90 | + const urlParams = new URL(window.location.href); | ||
91 | + Object.keys(defaultSettings).forEach(key => { | ||
92 | + if (urlParams.searchParams.has(key)) { | ||
93 | + urlParams.searchParams.delete(key); | ||
94 | + } | ||
95 | + }); | ||
96 | + Object.keys(payload).forEach(key => { | ||
97 | + if (key === 'collapse') { | ||
98 | + return; | ||
99 | + } | ||
100 | + let value = payload[key]; | ||
101 | + if (value === true) { | ||
102 | + value = 1; | ||
103 | + } | ||
104 | + if (defaultSettings[key] !== value) { | ||
105 | + urlParams.searchParams.set(key, value); | ||
106 | + } | ||
107 | + }); | ||
108 | + const { primaryColor, colorWeak, contentWidth } = payload; | ||
109 | + if (state.primaryColor !== primaryColor) { | ||
110 | + updateTheme(primaryColor); | ||
111 | + } | ||
112 | + if (state.contentWidth !== contentWidth && window.dispatchEvent) { | ||
113 | + window.dispatchEvent(new Event('resize')); | ||
114 | + } | ||
115 | + updateColorWeak(colorWeak); | ||
116 | + window.history.replaceState(null, 'setting', urlParams.href); | ||
117 | + return { | ||
118 | + ...state, | ||
119 | + ...payload, | ||
120 | + }; | ||
121 | + }, | ||
122 | + }, | ||
123 | +}; |
请
注册
或
登录
后发表评论