tntd 1.4.4 → 1.4.7
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/components/Layout/HeaderActions.js +90 -128
- package/components/LoadingButton/index.js +11 -15
- package/components/QueryListScene/QueryForm.js +7 -4
- package/dist/stats.json +4990 -4990
- package/dist/tntd.js +1 -1
- package/es/Layout/HeaderActions.js +10 -10
- package/es/LoadingButton/index.js +20 -10
- package/es/QueryListScene/QueryForm.js +6 -3
- package/lib/ArrayInput/icon.js +27 -31
- package/lib/ArrayInput/index.js +211 -298
- package/lib/AuthContext.js +2 -13
- package/lib/Columns/index.js +71 -100
- package/lib/DevelopmentLogin/LoginModal.js +79 -141
- package/lib/DevelopmentLogin/index.js +28 -55
- package/lib/Ellipsis/Svg/CopySVG.js +23 -71
- package/lib/Ellipsis/Svg/TickSVG.js +17 -49
- package/lib/Ellipsis/index.js +148 -154
- package/lib/Handle/index.js +72 -109
- package/lib/Icon/fonts/iconfont.js +1 -43
- package/lib/Icon/iconList.js +119 -8
- package/lib/Icon/index.js +13 -45
- package/lib/Img/Contain.js +49 -81
- package/lib/Img/Cover.js +88 -136
- package/lib/Img/index.js +36 -89
- package/lib/Layout/ActionsContext.js +2 -11
- package/lib/Layout/AppList.js +262 -256
- package/lib/Layout/Application.js +119 -135
- package/lib/Layout/Avatar.js +137 -137
- package/lib/Layout/CompatibleLanguage.js +214 -195
- package/lib/Layout/EnterpriseLayout/Avatar.js +156 -168
- package/lib/Layout/EnterpriseLayout/Language.js +75 -100
- package/lib/Layout/EnterpriseLayout/Theme.js +96 -94
- package/lib/Layout/EnterpriseLayout/index.js +32 -45
- package/lib/Layout/GlobalNavigation/NavigationPopup.js +335 -407
- package/lib/Layout/GlobalNavigation/index.js +110 -158
- package/lib/Layout/Header.js +165 -116
- package/lib/Layout/HeaderActions.js +132 -129
- package/lib/Layout/HeaderNavs.js +90 -113
- package/lib/Layout/HeaderTabs.js +312 -278
- package/lib/Layout/Iconfont.js +2 -15
- package/lib/Layout/Language.js +63 -102
- package/lib/Layout/Layout.js +272 -261
- package/lib/Layout/Logo.js +132 -87
- package/lib/Layout/OrgAppList.js +440 -319
- package/lib/Layout/SideMenu.js +429 -343
- package/lib/Layout/Theme.js +95 -124
- package/lib/Layout/checkAuth.js +21 -35
- package/lib/Layout/createActions.js +38 -51
- package/lib/Layout/images/index.js +33 -41
- package/lib/Layout/index.js +110 -161
- package/lib/Layout/paaslayout/CompactSideMenu.js +200 -178
- package/lib/Layout/paaslayout/Header.js +84 -90
- package/lib/Layout/paaslayout/Logo.js +27 -32
- package/lib/Layout/paaslayout/SideMenu.js +161 -174
- package/lib/Layout/paaslayout/index.js +240 -261
- package/lib/Layout/storage.js +20 -78
- package/lib/Layout/utils.js +93 -143
- package/lib/LoadingButton/index.js +25 -57
- package/lib/Modal/index.js +83 -108
- package/lib/Page/Box.js +56 -81
- package/lib/Page/index.js +151 -173
- package/lib/Page/utils.js +12 -30
- package/lib/QueryForm/Field/Checkbox.js +11 -33
- package/lib/QueryForm/Field/Select.js +63 -99
- package/lib/QueryForm/Field/SelectInput.js +69 -114
- package/lib/QueryForm/Field/fieldsMap.js +30 -52
- package/lib/QueryForm/Field/index.js +76 -158
- package/lib/QueryForm/createActions.js +50 -65
- package/lib/QueryForm/index.js +304 -383
- package/lib/QueryForm/useForm.js +6 -17
- package/lib/QueryListScene/List.js +290 -366
- package/lib/QueryListScene/QueryForm.js +93 -158
- package/lib/QueryListScene/QueryListScene.js +33 -87
- package/lib/QueryListScene/Title.js +10 -20
- package/lib/QueryListScene/Toolbar.js +8 -31
- package/lib/QueryListScene/createActions.js +64 -79
- package/lib/QueryListScene/index.js +23 -40
- package/lib/QueryListScene/useActions.js +6 -17
- package/lib/Select/DropDownWrap.js +60 -124
- package/lib/Select/index.js +425 -561
- package/lib/Table/ResizableTable/index.js +77 -121
- package/lib/Table/index.js +19 -51
- package/lib/Title/index.js +34 -52
- package/lib/index.js +19 -159
- package/lib/locale.js +48 -63
- package/package.json +1 -1
- package/lib/Layout/EnterpriseLayout/Header.js +0 -113
- package/lib/Layout/EnterpriseLayout/HeaderActions.js +0 -104
|
@@ -1,174 +1,162 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
var _styledComponents = _interopRequireWildcard(require("styled-components"));
|
|
23
|
-
|
|
24
|
-
var _deleteAllCookies = _interopRequireDefault(require("delete-all-cookies"));
|
|
25
|
-
|
|
26
|
-
var _lodash = require("lodash");
|
|
27
|
-
|
|
28
|
-
var _images = _interopRequireDefault(require("../images"));
|
|
29
|
-
|
|
30
|
-
var _Language = _interopRequireDefault(require("./Language"));
|
|
31
|
-
|
|
32
|
-
var _Theme = _interopRequireDefault(require("./Theme"));
|
|
33
|
-
|
|
34
|
-
function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function _getRequireWildcardCache() { return cache; }; return cache; }
|
|
35
|
-
|
|
36
|
-
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
37
|
-
|
|
38
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
39
|
-
|
|
40
|
-
function _templateObject3() {
|
|
41
|
-
var data = _taggedTemplateLiteral(["\n width: 330px;\n z-index: 1;\n background-color: #fff;\n border-radius: 4px;\n box-shadow: 0px 0px 6px 0px rgba(0,0,0,0.1);\n .isInIframe & {\n display: none;\n }\n\n .user-info-body {\n padding: 20px 15px;\n line-height: 16px;\n list-style: none;\n margin: 0;\n .user-info-body-username {\n margin-top: 0px;\n font-family: PingFangSC-Regular;\n font-weight: normal;\n font-size: 14px;\n color: ", ";\n line-height: 14px;\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n }\n .user-info-body-account {\n margin-top: 0px;\n font-family: PingFangSC-Regular;\n font-size: 12px;\n color: #8B919E;\n margin-bottom: 14px;\n line-height: 14px;\n margin-left: 10px;\n }\n }\n .user-info-footer {\n border-top: ", ";\n background-color: #fff;\n height: 36px;\n line-height: 36px;\n padding: 0 15px;\n font-size: 12px;\n color: ", ";\n a{\n flex: 1;\n text-align:center;\n color: ", ";\n }\n }\n"]);
|
|
42
|
-
|
|
43
|
-
_templateObject3 = function _templateObject3() {
|
|
44
|
-
return data;
|
|
45
|
-
};
|
|
46
|
-
|
|
47
|
-
return data;
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
function _templateObject2() {
|
|
51
|
-
var data = _taggedTemplateLiteral(["\n .tnt-layout-personal-popover {\n .ant-popover-inner-content {\n padding: 0;\n }\n }\n"]);
|
|
52
|
-
|
|
53
|
-
_templateObject2 = function _templateObject2() {
|
|
54
|
-
return data;
|
|
55
|
-
};
|
|
56
|
-
|
|
57
|
-
return data;
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
function _templateObject() {
|
|
61
|
-
var data = _taggedTemplateLiteral(["\n margin-right: 0;\n font-size: 0;\n img {\n width: 26px;\n height: 26px;\n border-radius: 50%;\n cursor: pointer;\n .large-size & {\n width: 32px;\n height: 32px;\n }\n }\n"]);
|
|
62
|
-
|
|
63
|
-
_templateObject = function _templateObject() {
|
|
64
|
-
return data;
|
|
65
|
-
};
|
|
66
|
-
|
|
67
|
-
return data;
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); }
|
|
71
|
-
|
|
72
|
-
var Avatar = _styledComponents["default"].li(_templateObject());
|
|
73
|
-
|
|
74
|
-
var GlobalStyle = (0, _styledComponents.createGlobalStyle)(_templateObject2());
|
|
75
|
-
|
|
76
|
-
var UserInfoWrapper = _styledComponents["default"].div(_templateObject3(), function (props) {
|
|
77
|
-
return "".concat(props.theme.primaryTextColor);
|
|
78
|
-
}, function (props) {
|
|
79
|
-
return "1px solid ".concat(props.theme.dividerColor);
|
|
80
|
-
}, function (props) {
|
|
81
|
-
return "".concat(props.theme.primaryColor);
|
|
82
|
-
}, function (props) {
|
|
83
|
-
return "".concat(props.theme.primaryColor);
|
|
84
|
-
});
|
|
85
|
-
|
|
86
|
-
var UserInfoContent = function UserInfoContent(props) {
|
|
87
|
-
var userInfo = props.userInfo,
|
|
88
|
-
_props$config = props.config,
|
|
89
|
-
config = _props$config === void 0 ? {} : _props$config,
|
|
90
|
-
onLogout = props.onLogout,
|
|
91
|
-
_props$onChangePasswo = props.onChangePassword,
|
|
92
|
-
onChangePassword = _props$onChangePasswo === void 0 ? function () {
|
|
93
|
-
return true;
|
|
94
|
-
} : _props$onChangePasswo,
|
|
95
|
-
_props$onPersonalSett = props.onPersonalSetting,
|
|
96
|
-
onPersonalSetting = _props$onPersonalSett === void 0 ? function () {
|
|
97
|
-
return true;
|
|
98
|
-
} : _props$onPersonalSett,
|
|
99
|
-
onLanguageChange = props.onLanguageChange,
|
|
100
|
-
onThemeChange = props.onThemeChange;
|
|
101
|
-
|
|
102
|
-
var _ref = config || {},
|
|
103
|
-
_ref$language = _ref.language,
|
|
104
|
-
language = _ref$language === void 0 ? true : _ref$language;
|
|
105
|
-
|
|
106
|
-
return React.createElement(UserInfoWrapper, {
|
|
107
|
-
className: "user-info-setting-wrap"
|
|
108
|
-
}, React.createElement("ul", {
|
|
109
|
-
className: "user-info-body"
|
|
110
|
-
}, React.createElement("li", {
|
|
111
|
-
className: "user-info-body-username"
|
|
112
|
-
}, userInfo.userName || '暂无昵称', React.createElement("span", {
|
|
113
|
-
className: "user-info-body-account"
|
|
114
|
-
}, userInfo.account)), language && React.createElement(_Language["default"], {
|
|
115
|
-
language: userInfo.lang,
|
|
116
|
-
onChange: onLanguageChange
|
|
117
|
-
}), React.createElement(_Theme["default"], {
|
|
118
|
-
theme: userInfo.theme,
|
|
119
|
-
onChange: onThemeChange
|
|
120
|
-
})), React.createElement(_row["default"], {
|
|
121
|
-
className: "user-info-footer",
|
|
122
|
-
type: "flex",
|
|
123
|
-
justify: "space-between",
|
|
124
|
-
align: "middle"
|
|
125
|
-
}, React.createElement("a", {
|
|
126
|
-
onClick: onPersonalSetting,
|
|
127
|
-
href: "/bridge/userCenter?currentTab=1"
|
|
128
|
-
}, "\u4E2A\u4EBA\u8BBE\u7F6E"), React.createElement(_divider["default"], {
|
|
129
|
-
type: "vertical"
|
|
130
|
-
}), React.createElement("a", {
|
|
131
|
-
onClick: onChangePassword,
|
|
132
|
-
href: "/bridge/userCenter?currentTab=2"
|
|
133
|
-
}, "\u4FEE\u6539\u5BC6\u7801"), React.createElement(_divider["default"], {
|
|
134
|
-
type: "vertical"
|
|
135
|
-
}), React.createElement("a", {
|
|
136
|
-
className: "user-info-footer-signout",
|
|
137
|
-
onClick: function onClick() {
|
|
138
|
-
if (onLogout) {
|
|
139
|
-
onLogout();
|
|
140
|
-
(0, _deleteAllCookies["default"])(window)();
|
|
141
|
-
} else {
|
|
142
|
-
(0, _deleteAllCookies["default"])(window)();
|
|
143
|
-
window.location.href = "/user/login?callbackUrl=".concat(window.encodeURI(location.href));
|
|
144
|
-
}
|
|
1
|
+
import styled, { createGlobalStyle } from 'styled-components';
|
|
2
|
+
import { Popover, Row, Divider } from 'antd';
|
|
3
|
+
import deleteAllCookiesFactory from 'delete-all-cookies';
|
|
4
|
+
import { get } from 'lodash';
|
|
5
|
+
import images from '../images';
|
|
6
|
+
import Language from './Language';
|
|
7
|
+
import Theme from './Theme';
|
|
8
|
+
|
|
9
|
+
const Avatar = styled.li`
|
|
10
|
+
margin-right: 0;
|
|
11
|
+
font-size: 0;
|
|
12
|
+
img {
|
|
13
|
+
width: 26px;
|
|
14
|
+
height: 26px;
|
|
15
|
+
border-radius: 50%;
|
|
16
|
+
cursor: pointer;
|
|
17
|
+
.large-size & {
|
|
18
|
+
width: 32px;
|
|
19
|
+
height: 32px;
|
|
20
|
+
}
|
|
145
21
|
}
|
|
146
|
-
|
|
147
|
-
};
|
|
148
|
-
|
|
149
|
-
var _default = function _default(props) {
|
|
150
|
-
var _images$empty2;
|
|
22
|
+
`;
|
|
151
23
|
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
24
|
+
const GlobalStyle = createGlobalStyle`
|
|
25
|
+
.tnt-layout-personal-popover {
|
|
26
|
+
.ant-popover-inner-content {
|
|
27
|
+
padding: 0;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
`;
|
|
31
|
+
|
|
32
|
+
const UserInfoWrapper = styled.div`
|
|
33
|
+
width: 330px;
|
|
34
|
+
z-index: 1;
|
|
35
|
+
background-color: #fff;
|
|
36
|
+
border-radius: 4px;
|
|
37
|
+
box-shadow: 0px 0px 6px 0px rgba(0,0,0,0.1);
|
|
38
|
+
.isInIframe & {
|
|
39
|
+
display: none;
|
|
40
|
+
}
|
|
165
41
|
|
|
166
|
-
|
|
167
|
-
|
|
42
|
+
.user-info-body {
|
|
43
|
+
padding: 20px 15px;
|
|
44
|
+
line-height: 16px;
|
|
45
|
+
list-style: none;
|
|
46
|
+
margin: 0;
|
|
47
|
+
.user-info-body-username {
|
|
48
|
+
margin-top: 0px;
|
|
49
|
+
font-family: PingFangSC-Regular;
|
|
50
|
+
font-weight: normal;
|
|
51
|
+
font-size: 14px;
|
|
52
|
+
color: ${props => `${props.theme.primaryTextColor}`};
|
|
53
|
+
line-height: 14px;
|
|
54
|
+
overflow: hidden;
|
|
55
|
+
text-overflow: ellipsis;
|
|
56
|
+
white-space: nowrap;
|
|
57
|
+
}
|
|
58
|
+
.user-info-body-account {
|
|
59
|
+
margin-top: 0px;
|
|
60
|
+
font-family: PingFangSC-Regular;
|
|
61
|
+
font-size: 12px;
|
|
62
|
+
color: #8B919E;
|
|
63
|
+
margin-bottom: 14px;
|
|
64
|
+
line-height: 14px;
|
|
65
|
+
margin-left: 10px;
|
|
66
|
+
}
|
|
168
67
|
}
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
68
|
+
.user-info-footer {
|
|
69
|
+
border-top: ${props => `1px solid ${props.theme.dividerColor}`};
|
|
70
|
+
background-color: #fff;
|
|
71
|
+
height: 36px;
|
|
72
|
+
line-height: 36px;
|
|
73
|
+
padding: 0 15px;
|
|
74
|
+
font-size: 12px;
|
|
75
|
+
color: ${props => `${props.theme.primaryColor}`};
|
|
76
|
+
a{
|
|
77
|
+
flex: 1;
|
|
78
|
+
text-align:center;
|
|
79
|
+
color: ${props => `${props.theme.primaryColor}`};
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
`;
|
|
83
|
+
|
|
84
|
+
const UserInfoContent = props => {
|
|
85
|
+
const { userInfo, config={}, onLogout, onChangePassword = () => true, onPersonalSetting = () => true, onLanguageChange, onThemeChange } = props;
|
|
86
|
+
const {
|
|
87
|
+
language = true,
|
|
88
|
+
} = config || {};
|
|
89
|
+
return (
|
|
90
|
+
<UserInfoWrapper className="user-info-setting-wrap">
|
|
91
|
+
<ul className="user-info-body">
|
|
92
|
+
<li className="user-info-body-username">
|
|
93
|
+
{userInfo.userName || '暂无昵称'}
|
|
94
|
+
<span className="user-info-body-account">{userInfo.account}</span>
|
|
95
|
+
</li>
|
|
96
|
+
{
|
|
97
|
+
language &&
|
|
98
|
+
<Language
|
|
99
|
+
language={userInfo.lang}
|
|
100
|
+
onChange={onLanguageChange}
|
|
101
|
+
/>
|
|
102
|
+
}
|
|
103
|
+
<Theme
|
|
104
|
+
theme={userInfo.theme}
|
|
105
|
+
onChange={onThemeChange}
|
|
106
|
+
/>
|
|
107
|
+
</ul>
|
|
108
|
+
<Row className="user-info-footer" type="flex" justify="space-between" align="middle">
|
|
109
|
+
<a onClick={onPersonalSetting} href="/bridge/userCenter?currentTab=1">个人设置</a>
|
|
110
|
+
<Divider type="vertical"/>
|
|
111
|
+
<a onClick={onChangePassword} href="/bridge/userCenter?currentTab=2">修改密码</a>
|
|
112
|
+
<Divider type="vertical"/>
|
|
113
|
+
<a
|
|
114
|
+
className="user-info-footer-signout"
|
|
115
|
+
onClick={() => {
|
|
116
|
+
if (onLogout) {
|
|
117
|
+
onLogout();
|
|
118
|
+
deleteAllCookiesFactory(window)();
|
|
119
|
+
} else {
|
|
120
|
+
deleteAllCookiesFactory(window)();
|
|
121
|
+
window.location.href = `/user/login?callbackUrl=${window.encodeURI(location.href)}`;
|
|
122
|
+
}
|
|
123
|
+
}}
|
|
124
|
+
>退出登录</a>
|
|
125
|
+
</Row>
|
|
126
|
+
</UserInfoWrapper>
|
|
127
|
+
);
|
|
172
128
|
};
|
|
173
129
|
|
|
174
|
-
|
|
130
|
+
export default props => {
|
|
131
|
+
const {
|
|
132
|
+
userInfo = {}
|
|
133
|
+
} = props;
|
|
134
|
+
const { avatar } = userInfo;
|
|
135
|
+
|
|
136
|
+
return (
|
|
137
|
+
<Avatar>
|
|
138
|
+
<Popover
|
|
139
|
+
popupClassName="tnt-layout-personal-popover"
|
|
140
|
+
placement="bottomRight"
|
|
141
|
+
title={null}
|
|
142
|
+
content={<UserInfoContent {...props} />}
|
|
143
|
+
trigger="click"
|
|
144
|
+
>
|
|
145
|
+
{
|
|
146
|
+
avatar ? (
|
|
147
|
+
<img
|
|
148
|
+
src={avatar.indexOf('base64') > 0 ? avatar : get(images[avatar], 'default', images[avatar])}
|
|
149
|
+
onError={e => {
|
|
150
|
+
e.target.onerror = null;
|
|
151
|
+
e.target.src = images.empty?.default || images.empty;
|
|
152
|
+
}}
|
|
153
|
+
/>
|
|
154
|
+
) : (
|
|
155
|
+
<img src={images.empty?.default || images.empty} />
|
|
156
|
+
)
|
|
157
|
+
}
|
|
158
|
+
</Popover>
|
|
159
|
+
<GlobalStyle />
|
|
160
|
+
</Avatar>
|
|
161
|
+
);
|
|
162
|
+
};
|
|
@@ -1,105 +1,80 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
var _lodash = require("lodash");
|
|
15
|
-
|
|
16
|
-
var _Iconfont = _interopRequireDefault(require("../Iconfont"));
|
|
17
|
-
|
|
18
|
-
var _storage = require("../storage");
|
|
19
|
-
|
|
20
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
21
|
-
|
|
22
|
-
function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function _getRequireWildcardCache() { return cache; }; return cache; }
|
|
23
|
-
|
|
24
|
-
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
25
|
-
|
|
26
|
-
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _nonIterableRest(); }
|
|
27
|
-
|
|
28
|
-
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance"); }
|
|
29
|
-
|
|
30
|
-
function _iterableToArrayLimit(arr, i) { if (!(Symbol.iterator in Object(arr) || Object.prototype.toString.call(arr) === "[object Arguments]")) { return; } var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
|
|
31
|
-
|
|
32
|
-
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
33
|
-
|
|
34
|
-
function _templateObject() {
|
|
35
|
-
var data = _taggedTemplateLiteral(["\n display:inline-block;\n padding: 0 10px;\n height: 32px;\n line-height: 32px;\n text-align: center;\n background: #FFFFFF;\n border: 1px solid #E1E6EE;\n border-radius: 2px;\n font-family: PingFangSC-Regular;\n color: #17233D;\n font-size: ", ";\n cursor: pointer;\n margin-top: 8px;\n\n .tnt-icon {\n font-size: ", ";\n margin-right: 4px;\n }\n\n span {\n position: relative;\n font-size: ", ";\n top: ", ";\n font-family: auto;\n }\n\n .isInIframe & {\n display: none;\n }\n"]);
|
|
36
|
-
|
|
37
|
-
_templateObject = function _templateObject() {
|
|
38
|
-
return data;
|
|
39
|
-
};
|
|
40
|
-
|
|
41
|
-
return data;
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); }
|
|
45
|
-
|
|
46
|
-
var languages = [{
|
|
47
|
-
value: 'cn',
|
|
48
|
-
name: '中文'
|
|
49
|
-
}, {
|
|
50
|
-
value: 'en',
|
|
51
|
-
name: 'EN '
|
|
52
|
-
}];
|
|
53
|
-
var languagesMap = languages.reduce(function (acc, cur) {
|
|
54
|
-
acc[cur.value] = cur;
|
|
55
|
-
return acc;
|
|
1
|
+
import { useState } from 'react';
|
|
2
|
+
import styled, { withTheme } from 'styled-components';
|
|
3
|
+
import { get } from 'lodash';
|
|
4
|
+
import Iconfont from '../Iconfont';
|
|
5
|
+
import { setLanguageStore, getLanguageStore } from '../storage';
|
|
6
|
+
|
|
7
|
+
const languages = [
|
|
8
|
+
{ value: 'cn', name: '中文' },
|
|
9
|
+
{ value: 'en', name: 'EN ' }
|
|
10
|
+
];
|
|
11
|
+
const languagesMap = languages.reduce((acc, cur) => {
|
|
12
|
+
acc[cur.value] = cur;
|
|
13
|
+
return acc;
|
|
56
14
|
}, {});
|
|
57
15
|
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
var lang = (0, _storage.getLanguageStore)() || props.language;
|
|
77
|
-
|
|
78
|
-
if (!languagesMap[lang]) {
|
|
79
|
-
lang = (0, _lodash.get)(languages, '0.value');
|
|
16
|
+
const Language = styled.li`
|
|
17
|
+
display:inline-block;
|
|
18
|
+
padding: 0 10px;
|
|
19
|
+
height: 32px;
|
|
20
|
+
line-height: 32px;
|
|
21
|
+
text-align: center;
|
|
22
|
+
background: #FFFFFF;
|
|
23
|
+
border: 1px solid #E1E6EE;
|
|
24
|
+
border-radius: 2px;
|
|
25
|
+
font-family: PingFangSC-Regular;
|
|
26
|
+
color: #17233D;
|
|
27
|
+
font-size: ${({ theme: { size } }) => size === 'large' ? '14px' : '12px'};
|
|
28
|
+
cursor: pointer;
|
|
29
|
+
margin-top: 8px;
|
|
30
|
+
|
|
31
|
+
.tnt-icon {
|
|
32
|
+
font-size: ${({ theme: { size } }) => size === 'large' ? '24px' : '20px'};
|
|
33
|
+
margin-right: 4px;
|
|
80
34
|
}
|
|
81
35
|
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
language = _useState2$ === void 0 ? 'cn' : _useState2$,
|
|
89
|
-
setLanguage = _useState2[1];
|
|
90
|
-
|
|
91
|
-
var switchLanguage = function switchLanguage() {
|
|
92
|
-
var lang = language === 'cn' ? 'en' : 'cn';
|
|
93
|
-
setLanguage(lang);
|
|
94
|
-
(0, _storage.setLanguageStore)(lang);
|
|
95
|
-
onChange && onChange(lang);
|
|
96
|
-
};
|
|
97
|
-
|
|
98
|
-
return React.createElement(Language, {
|
|
99
|
-
onClick: switchLanguage
|
|
100
|
-
}, React.createElement(_Iconfont["default"], {
|
|
101
|
-
type: "flag-".concat(language)
|
|
102
|
-
}), React.createElement("span", null, (0, _lodash.get)(languagesMap[language], 'name')));
|
|
103
|
-
});
|
|
36
|
+
span {
|
|
37
|
+
position: relative;
|
|
38
|
+
font-size: ${({ theme: { size } }) => size === 'large' ? '14px' : '12px'};
|
|
39
|
+
top: ${({ theme: { size } }) => size === 'large' ? '-3px' : '-2px'};
|
|
40
|
+
font-family: auto;
|
|
41
|
+
}
|
|
104
42
|
|
|
105
|
-
|
|
43
|
+
.isInIframe & {
|
|
44
|
+
display: none;
|
|
45
|
+
}
|
|
46
|
+
`;
|
|
47
|
+
|
|
48
|
+
export default withTheme(
|
|
49
|
+
props => {
|
|
50
|
+
const {
|
|
51
|
+
onChange
|
|
52
|
+
} = props;
|
|
53
|
+
const getLanguage = () => {
|
|
54
|
+
let lang = getLanguageStore() || props.language;
|
|
55
|
+
|
|
56
|
+
if (!languagesMap[lang]) {
|
|
57
|
+
lang = get(languages, '0.value');
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
return lang;
|
|
61
|
+
};
|
|
62
|
+
const [language = 'cn', setLanguage] = useState(getLanguage());
|
|
63
|
+
const switchLanguage = () => {
|
|
64
|
+
const lang = language === 'cn' ? 'en' : 'cn';
|
|
65
|
+
|
|
66
|
+
setLanguage(lang);
|
|
67
|
+
setLanguageStore(lang);
|
|
68
|
+
onChange && onChange(lang);
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
return (
|
|
72
|
+
<Language onClick={switchLanguage}>
|
|
73
|
+
<Iconfont type={`flag-${language}`} />
|
|
74
|
+
<span>
|
|
75
|
+
{get(languagesMap[language], 'name')}
|
|
76
|
+
</span>
|
|
77
|
+
</Language>
|
|
78
|
+
);
|
|
79
|
+
}
|
|
80
|
+
);
|