tntd 1.4.5 → 1.4.8

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.
@@ -1,16 +1,16 @@
1
- import styled, { withTheme } from 'styled-components';
2
- import { Divider } from 'antd';
3
- import GlobalNavigation from './GlobalNavigation';
4
- import Language from './Language';
5
- import Theme from './Theme';
6
- import LanguageTheme from './CompatibleLanguage';
7
- import Application from './Application';
8
- import Avatar from './Avatar';
1
+ import styled, { withTheme } from "styled-components";
2
+ import { Divider } from "antd";
3
+ import GlobalNavigation from "./GlobalNavigation";
4
+ import Language from "./Language";
5
+ import Theme from "./Theme";
6
+ import LanguageTheme from "./CompatibleLanguage";
7
+ import Application from "./Application";
8
+ import Avatar from "./Avatar";
9
9
 
10
10
  const Actions = styled.ul`
11
11
  list-style: none;
12
12
  display: inline-block;
13
- line-height: ${props => `${props.theme.headerHeight}px`};
13
+ line-height: ${(props) => `${props.theme.headerHeight}px`};
14
14
  margin: 0 0 0 20px;
15
15
  .hasHeaderTabs & {
16
16
  margin: 0;
@@ -29,7 +29,7 @@ const Actions = styled.ul`
29
29
  cursor: pointer;
30
30
  font-size: 20px;
31
31
  margin: 0 7.5px;
32
- color: ${props => `${props.theme.headerActionsColor}`};
32
+ color: ${(props) => `${props.theme.headerActionsColor}`};
33
33
  .large-size & {
34
34
  margin: 0 10px;
35
35
  }
@@ -39,7 +39,7 @@ const Actions = styled.ul`
39
39
  &:last-of-type {
40
40
  margin-right: 0;
41
41
  }
42
- .hasHeaderTabs &{
42
+ .hasHeaderTabs & {
43
43
  color: #455064;
44
44
  }
45
45
  // 删除色系区分 统一色调
@@ -52,123 +52,85 @@ const Actions = styled.ul`
52
52
  }
53
53
  `;
54
54
 
55
- export default withTheme(
56
- props => {
57
- const {
58
- config: {
59
- theme = true,
60
- avatar = true,
61
- language = true,
62
- application = false,
63
- globalNavigation = false
64
- } = {},
65
- theme: {
66
- compatible
67
- },
68
- userInfo = {},
69
- menus,
70
- apps,
71
- extraActions,
72
- headerRef,
73
- onLanguageChange,
74
- onThemeChange,
75
- onApplicationChange,
76
- onAppChange,
77
- onCollapseChange,
78
- onPersonalSetting,
79
- onChangePassword,
80
- onLogout,
81
- onLogoClick,
82
- AvatarCustom,
83
- ...rest
84
- } = props;
55
+ export default withTheme((props) => {
56
+ const {
57
+ config: {
58
+ theme = true,
59
+ avatar = true,
60
+ language = true,
61
+ application = false,
62
+ globalNavigation = false,
63
+ } = {},
64
+ theme: { compatible },
65
+ userInfo = {},
66
+ menus,
67
+ apps,
68
+ extraActions,
69
+ headerRef,
70
+ onLanguageChange,
71
+ onThemeChange,
72
+ onApplicationChange,
73
+ onAppChange,
74
+ onCollapseChange,
75
+ onPersonalSetting,
76
+ onChangePassword,
77
+ onLogout,
78
+ onLogoClick,
79
+ AvatarCustom,
80
+ ...rest
81
+ } = props;
85
82
 
86
- return (
87
- <Actions {...rest}>
88
- {extraActions}
89
- {
90
- globalNavigation && (
91
- <GlobalNavigation
92
- headerRef={headerRef}
93
- menus={menus}
83
+ return (
84
+ <Actions {...rest}>
85
+ {extraActions}
86
+ {globalNavigation && <GlobalNavigation headerRef={headerRef} menus={menus} />}
87
+ {!compatible ? (
88
+ <>
89
+ {language && <Language language={userInfo.lang} onChange={onLanguageChange} />}
90
+ {theme && <Theme theme={userInfo.theme} onChange={onThemeChange} />}
91
+ </>
92
+ ) : (
93
+ <LanguageTheme
94
+ config={props.config}
95
+ language={userInfo.lang}
96
+ theme={userInfo.theme}
97
+ onLanguageChange={onLanguageChange}
98
+ onThemeChange={onThemeChange}
99
+ />
100
+ )}
101
+ {application && (
102
+ <Application language={userInfo.lang} apps={apps} onChange={onApplicationChange} />
103
+ )}
104
+ {avatar && (
105
+ <>
106
+ <Divider type="vertical" />
107
+ {AvatarCustom ? (
108
+ <AvatarCustom
109
+ userInfo={userInfo}
110
+ onPersonalSetting={onPersonalSetting}
111
+ onChangePassword={onChangePassword}
112
+ onLogout={onLogout}
113
+ onThemeChange={onThemeChange}
114
+ config={{
115
+ theme,
116
+ language,
117
+ }}
94
118
  />
95
- )
96
- }
97
- {
98
- !AvatarCustom &&
99
- (
100
- !compatible ? (
101
- <>
102
- {
103
- language && (
104
- <Language
105
- language={userInfo.lang}
106
- onChange={onLanguageChange}
107
- />
108
- )
109
- }
110
- {
111
- theme && (
112
- <Theme
113
- theme={userInfo.theme}
114
- onChange={onThemeChange}
115
- />
116
- )
117
- }
118
- </>
119
- ) : (
120
- <LanguageTheme
121
- config={props.config}
122
- language={userInfo.lang}
123
- theme={userInfo.theme}
124
- onLanguageChange={onLanguageChange}
125
- onThemeChange={onThemeChange}
126
- />
127
- )
128
- )
129
- }
130
- {
131
- application && (
132
- <Application
133
- language={userInfo.lang}
134
- apps={apps}
135
- onChange={onApplicationChange}
119
+ ) : (
120
+ <Avatar
121
+ userInfo={userInfo}
122
+ onPersonalSetting={onPersonalSetting}
123
+ onChangePassword={onChangePassword}
124
+ onLogout={onLogout}
125
+ onThemeChange={onThemeChange}
126
+ config={{
127
+ theme,
128
+ language,
129
+ }}
136
130
  />
137
- )
138
- }
139
- {
140
- avatar && (
141
- <>
142
- <Divider type="vertical" />
143
- {
144
- AvatarCustom ?
145
- <AvatarCustom
146
- userInfo={userInfo}
147
- onPersonalSetting={onPersonalSetting}
148
- onChangePassword={onChangePassword}
149
- onLogout={onLogout}
150
- onThemeChange={onThemeChange}
151
- config={{
152
- theme,
153
- language
154
- }}
155
- /> :
156
- <Avatar
157
- userInfo={userInfo}
158
- onPersonalSetting={onPersonalSetting}
159
- onChangePassword={onChangePassword}
160
- onLogout={onLogout}
161
- onThemeChange={onThemeChange}
162
- config={{
163
- theme,
164
- language
165
- }}
166
- />
167
- }
168
- </>
169
- )
170
- }
171
- </Actions>
172
- );
173
- }
174
- );
131
+ )}
132
+ </>
133
+ )}
134
+ </Actions>
135
+ );
136
+ });
@@ -1,30 +1,26 @@
1
- import { useState, useEffect } from 'react';
2
- import { Button } from 'antd';
1
+ import { useState, useEffect } from "react";
2
+ import { Button } from "antd";
3
3
 
4
- export default props => {
5
- const [loading, setLoading] = useState(props.loading);
6
- const onClick = evt => {
4
+ export default ({ loadingText, loading: pLoading, onClick, children, ...otherProps }) => {
5
+ const [loading, setLoading] = useState(pLoading);
6
+ const doClick = (evt) => {
7
7
  if (!loading) {
8
8
  setLoading(true);
9
- const returnVal = props.onClick && props.onClick(evt, () => setLoading(false));
9
+ const returnVal = onClick && onClick(evt, () => setLoading(false));
10
10
 
11
11
  if (returnVal instanceof Promise) {
12
- returnVal.then(
13
- () => setLoading(false)
14
- ).catch(
15
- () => setLoading(false)
16
- );
12
+ returnVal.then(() => setLoading(false)).catch(() => setLoading(false));
17
13
  }
18
14
  }
19
15
  };
20
16
 
21
17
  useEffect(() => {
22
- setLoading(props.loading);
23
- }, [props.loading]);
18
+ setLoading(pLoading);
19
+ }, [pLoading]);
24
20
 
25
21
  return (
26
- <Button {...props} loading={loading} onClick={onClick}>
27
- {loading ? (props.loadingText || props.children) : props.children}
22
+ <Button {...otherProps} loading={loading} onClick={doClick}>
23
+ {loading ? loadingText || children : children}
28
24
  </Button>
29
25
  );
30
26
  };
@@ -52,7 +52,7 @@ export default class QueryForm extends React.PureComponent {
52
52
  }
53
53
  }
54
54
 
55
- onSearch = async() => {
55
+ onSearch = () => {
56
56
  const {
57
57
  onSearch,
58
58
  actions
@@ -60,9 +60,12 @@ export default class QueryForm extends React.PureComponent {
60
60
  const values = actions.getFormData();
61
61
  const params = { ...values, current: 1 };
62
62
 
63
- await actions.setData('formData', values); // memory 与 url解析setForm时 监听事件异步
64
- onSearch && onSearch(params);
65
- actions.emit('search', params);
63
+ // memory 与 url解析setForm时 监听事件异步
64
+ actions.setData('formData', values);
65
+ Promise.resolve().then(()=>{
66
+ onSearch && onSearch(params);
67
+ actions.emit('search', params);
68
+ });
66
69
  };
67
70
 
68
71
  onReset = () => {