tntd 1.4.6 → 1.4.9

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.
@@ -5,8 +5,8 @@ import Cookies from 'universal-cookie';
5
5
  const cookies = new Cookies();
6
6
  // 默认
7
7
  let accountInfoDefault = {
8
- account: 'admin',
9
- password: 'Td@123456'
8
+ account: undefined,
9
+ password: undefined
10
10
  };
11
11
 
12
12
  export default ({ visible, close, signIn }) => {
@@ -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
  };
package/dist/1.tntd.js CHANGED
@@ -9,4 +9,4 @@
9
9
  object-assign
10
10
  (c) Sindre Sorhus
11
11
  @license MIT
12
- */var c=Object.getOwnPropertySymbols,u=Object.prototype.hasOwnProperty,p=Object.prototype.propertyIsEnumerable;e.exports=function(){try{if(!Object.assign)return;var e=new String("abc");if(e[5]="de","5"===Object.getOwnPropertyNames(e)[0])return;for(var t={},r=0;r<10;r++)t["_"+String.fromCharCode(r)]=r;if("0123456789"!==Object.getOwnPropertyNames(t).map(function(e){return t[e]}).join(""))return;var n={};return"abcdefghijklmnopqrst".split("").forEach(function(e){n[e]=e}),"abcdefghijklmnopqrst"!==Object.keys(Object.assign({},n)).join("")?void 0:1}catch(e){return}}()?Object.assign:function(e,t){for(var r,n=function(e){if(null==e)throw new TypeError("Object.assign cannot be called with null or undefined");return Object(e)}(e),o=1;o<arguments.length;o++){for(var i in r=Object(arguments[o]))u.call(r,i)&&(n[i]=r[i]);if(c)for(var a=c(r),s=0;s<a.length;s++)p.call(r,a[s])&&(n[a[s]]=r[a[s]])}return n}},90:function(e,t,r){"use strict";r.r(t);var p=r(0),l=r(1),o=r(88);function i(e,t){void 0===t&&(t={});var r,n=function(e){if(e&&"j"===e[0]&&":"===e[1])return e.substr(2);return e}(e);if(r=n,!(t=void 0===(t=t.doNotParse)?!r||"{"!==r[0]&&"["!==r[0]&&'"'!==r[0]:t))try{return JSON.parse(n)}catch(e){}return e}var a=r(89);function n(e,t){var r=this;this.changeListeners=[],this.HAS_DOCUMENT_COOKIE=!1,this.cookies=(t=t,"string"==typeof(e=e)?o.parse(e,t):"object"==typeof e&&null!==e?e:{}),new Promise(function(){r.HAS_DOCUMENT_COOKIE="object"==typeof document&&"string"==typeof document.cookie}).catch(function(){})}function f(t,e){var r,n=Object.keys(t);return Object.getOwnPropertySymbols&&(r=Object.getOwnPropertySymbols(t),e&&(r=r.filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})),n.push.apply(n,r)),n}function h(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function m(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){if(Symbol.iterator in Object(e)||"[object Arguments]"===Object.prototype.toString.call(e)){var r=[],n=!0,o=!1,i=void 0;try{for(var a,s=e[Symbol.iterator]();!(n=(a=s.next()).done)&&(r.push(a.value),!t||r.length!==t);n=!0);}catch(e){o=!0,i=e}finally{try{n||null==s.return||s.return()}finally{if(o)throw i}}return r}}(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance")}()}var d=new(n.prototype._updateBrowserValues=function(e){this.HAS_DOCUMENT_COOKIE&&(this.cookies=o.parse(document.cookie,e))},n.prototype._emitChange=function(e){for(var t=0;t<this.changeListeners.length;++t)this.changeListeners[t](e)},n.prototype.get=function(e,t,r){return void 0===t&&(t={}),this._updateBrowserValues(r),i(this.cookies[e],t)},n.prototype.getAll=function(e,t){void 0===e&&(e={}),this._updateBrowserValues(t);var r,n={};for(r in this.cookies)n[r]=i(this.cookies[r],e);return n},n.prototype.set=function(e,t,r){var n;"object"==typeof t&&(t=JSON.stringify(t)),this.cookies=a({},this.cookies,((n={})[e]=t,n)),this.HAS_DOCUMENT_COOKIE&&(document.cookie=o.serialize(e,t,r)),this._emitChange({name:e,value:t,options:r})},n.prototype.remove=function(e,t){var r=t=a({},t,{expires:new Date(1970,1,1,0,0,1),maxAge:0});this.cookies=a({},this.cookies),delete this.cookies[e],this.HAS_DOCUMENT_COOKIE&&(document.cookie=o.serialize(e,"",r)),this._emitChange({name:e,value:void 0,options:t})},n.prototype.addChangeListener=function(e){this.changeListeners.push(e)},n.prototype.removeChangeListener=function(e){e=this.changeListeners.indexOf(e);0<=e&&this.changeListeners.splice(e,1)},n),y={account:"admin",password:"Td@123456"};t.default=function(e){var t=e.visible,n=e.close,r=e.signIn,o=m(Object(p.useState)(!1),2),i=o[0],a=o[1],e=localStorage.getItem("accountInfo");if(e)try{y=JSON.parse(e)}catch(e){}function s(e,t){u(function(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{};e%2?f(Object(r),!0).forEach(function(e){h(t,e,r[e])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):f(Object(r)).forEach(function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))})}return t}({},c,h({},e,t.target.value)))}var o=m(Object(p.useState)(y),2),c=o[0],u=o[1],e=c.account,o=c.password;return React.createElement(l.Modal,{title:"开发者模拟登陆",visible:t,maskClosable:!1,onOk:function(){a(!0);var e=r&&r(c);e&&e.then&&e.then(function(r){l.message.success("模拟登陆成功"),localStorage.setItem("accountInfo",JSON.stringify(c)),a(!1),setTimeout(function(){var e=r||{},t=e.tdToken,e=e.userId;d.set("_td_token_",t,{path:"/"}),d.set("_uid_",e,{path:"/"}),n()},500)}).catch(function(e){throw a(!1),e})},onCancel:n,confirmLoading:i},React.createElement(l.Form,{labelCol:{span:5},wrapperCol:{span:18}},React.createElement(l.Form.Item,{label:"用户名:"},React.createElement(l.Input,{type:"text",placeholder:"请输入用户名",value:e||void 0,onChange:function(e){return s("account",e)}})),React.createElement(l.Form.Item,{label:"密码:"},React.createElement(l.Input,{type:"text",placeholder:"请输入用户名",value:o||void 0,onChange:function(e){return s("password",e)}}))))}}}]);
12
+ */var c=Object.getOwnPropertySymbols,u=Object.prototype.hasOwnProperty,p=Object.prototype.propertyIsEnumerable;e.exports=function(){try{if(!Object.assign)return;var e=new String("abc");if(e[5]="de","5"===Object.getOwnPropertyNames(e)[0])return;for(var t={},r=0;r<10;r++)t["_"+String.fromCharCode(r)]=r;if("0123456789"!==Object.getOwnPropertyNames(t).map(function(e){return t[e]}).join(""))return;var n={};return"abcdefghijklmnopqrst".split("").forEach(function(e){n[e]=e}),"abcdefghijklmnopqrst"!==Object.keys(Object.assign({},n)).join("")?void 0:1}catch(e){return}}()?Object.assign:function(e,t){for(var r,n=function(e){if(null==e)throw new TypeError("Object.assign cannot be called with null or undefined");return Object(e)}(e),o=1;o<arguments.length;o++){for(var i in r=Object(arguments[o]))u.call(r,i)&&(n[i]=r[i]);if(c)for(var a=c(r),s=0;s<a.length;s++)p.call(r,a[s])&&(n[a[s]]=r[a[s]])}return n}},90:function(e,t,r){"use strict";r.r(t);var p=r(0),l=r(1),o=r(88);function i(e,t){void 0===t&&(t={});var r,n=function(e){if(e&&"j"===e[0]&&":"===e[1])return e.substr(2);return e}(e);if(r=n,!(t=void 0===(t=t.doNotParse)?!r||"{"!==r[0]&&"["!==r[0]&&'"'!==r[0]:t))try{return JSON.parse(n)}catch(e){}return e}var a=r(89);function n(e,t){var r=this;this.changeListeners=[],this.HAS_DOCUMENT_COOKIE=!1,this.cookies=(t=t,"string"==typeof(e=e)?o.parse(e,t):"object"==typeof e&&null!==e?e:{}),new Promise(function(){r.HAS_DOCUMENT_COOKIE="object"==typeof document&&"string"==typeof document.cookie}).catch(function(){})}function f(t,e){var r,n=Object.keys(t);return Object.getOwnPropertySymbols&&(r=Object.getOwnPropertySymbols(t),e&&(r=r.filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})),n.push.apply(n,r)),n}function h(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function d(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){if(Symbol.iterator in Object(e)||"[object Arguments]"===Object.prototype.toString.call(e)){var r=[],n=!0,o=!1,i=void 0;try{for(var a,s=e[Symbol.iterator]();!(n=(a=s.next()).done)&&(r.push(a.value),!t||r.length!==t);n=!0);}catch(e){o=!0,i=e}finally{try{n||null==s.return||s.return()}finally{if(o)throw i}}return r}}(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance")}()}var m=new(n.prototype._updateBrowserValues=function(e){this.HAS_DOCUMENT_COOKIE&&(this.cookies=o.parse(document.cookie,e))},n.prototype._emitChange=function(e){for(var t=0;t<this.changeListeners.length;++t)this.changeListeners[t](e)},n.prototype.get=function(e,t,r){return void 0===t&&(t={}),this._updateBrowserValues(r),i(this.cookies[e],t)},n.prototype.getAll=function(e,t){void 0===e&&(e={}),this._updateBrowserValues(t);var r,n={};for(r in this.cookies)n[r]=i(this.cookies[r],e);return n},n.prototype.set=function(e,t,r){var n;"object"==typeof t&&(t=JSON.stringify(t)),this.cookies=a({},this.cookies,((n={})[e]=t,n)),this.HAS_DOCUMENT_COOKIE&&(document.cookie=o.serialize(e,t,r)),this._emitChange({name:e,value:t,options:r})},n.prototype.remove=function(e,t){var r=t=a({},t,{expires:new Date(1970,1,1,0,0,1),maxAge:0});this.cookies=a({},this.cookies),delete this.cookies[e],this.HAS_DOCUMENT_COOKIE&&(document.cookie=o.serialize(e,"",r)),this._emitChange({name:e,value:void 0,options:t})},n.prototype.addChangeListener=function(e){this.changeListeners.push(e)},n.prototype.removeChangeListener=function(e){e=this.changeListeners.indexOf(e);0<=e&&this.changeListeners.splice(e,1)},n),y={account:void 0,password:void 0};t.default=function(e){var t=e.visible,n=e.close,r=e.signIn,o=d(Object(p.useState)(!1),2),i=o[0],a=o[1],e=localStorage.getItem("accountInfo");if(e)try{y=JSON.parse(e)}catch(e){}function s(e,t){u(function(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{};e%2?f(Object(r),!0).forEach(function(e){h(t,e,r[e])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):f(Object(r)).forEach(function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))})}return t}({},c,h({},e,t.target.value)))}var o=d(Object(p.useState)(y),2),c=o[0],u=o[1],e=c.account,o=c.password;return React.createElement(l.Modal,{title:"开发者模拟登陆",visible:t,maskClosable:!1,onOk:function(){a(!0);var e=r&&r(c);e&&e.then&&e.then(function(r){l.message.success("模拟登陆成功"),localStorage.setItem("accountInfo",JSON.stringify(c)),a(!1),setTimeout(function(){var e=r||{},t=e.tdToken,e=e.userId;m.set("_td_token_",t,{path:"/"}),m.set("_uid_",e,{path:"/"}),n()},500)}).catch(function(e){throw a(!1),e})},onCancel:n,confirmLoading:i},React.createElement(l.Form,{labelCol:{span:5},wrapperCol:{span:18}},React.createElement(l.Form.Item,{label:"用户名:"},React.createElement(l.Input,{type:"text",placeholder:"请输入用户名",value:e||void 0,onChange:function(e){return s("account",e)}})),React.createElement(l.Form.Item,{label:"密码:"},React.createElement(l.Input,{type:"text",placeholder:"请输入用户名",value:o||void 0,onChange:function(e){return s("password",e)}}))))}}}]);