component-sanzhizhou 1.0.11 → 1.0.12

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,7 +5,7 @@ import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
5
5
  import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
6
6
  import React, { useState, useEffect, useRef } from 'react';
7
7
  import { WechatOutlined, RedoOutlined, UserOutlined } from '@ant-design/icons';
8
- import { Tabs } from 'antd';
8
+ import { QRCode, Tabs } from 'antd';
9
9
  import { useRequest } from '@umijs/hooks';
10
10
  import * as AuthController from "../service/api/AuthController";
11
11
  import PageContentWarp from "../UI/PageContentWarp";
@@ -14,9 +14,9 @@ import Platform from "../lib/platform";
14
14
  import QrWs from "../AuthClient/qr/ws";
15
15
  import { getApiEnv } from "../lib/getApiUrl";
16
16
  import styles from "../AuthClient/qr/index.css";
17
- import QRCode from 'qrcode.react';
18
17
  import h5WePublicLogin from "../AuthClient/qr/h5-we-public-login";
19
18
  import Tool from "../lib/Tool";
19
+ import formatMessage from "../lib/formatMessage";
20
20
  import { jsx as _jsx } from "react/jsx-runtime";
21
21
  import { Fragment as _Fragment } from "react/jsx-runtime";
22
22
  import { jsxs as _jsxs } from "react/jsx-runtime";
@@ -143,7 +143,7 @@ var Auth = function Auth(_ref) {
143
143
  Tool.event.run("".concat(roleType || 'user', "-login-success"), _objectSpread(_objectSpread({}, userInfo), {}, {
144
144
  isLogin: true
145
145
  }));
146
- Tool.toast('登录成功');
146
+ Tool.toast(formatMessage('成功'));
147
147
  };
148
148
  var _useRequest = useRequest(function () {
149
149
  return AuthController.weMiniLoginQr({
@@ -276,7 +276,7 @@ var Auth = function Auth(_ref) {
276
276
  return /*#__PURE__*/_jsxs(styles.AuthQrLogin, {
277
277
  children: [/*#__PURE__*/_jsxs(styles.LoginForm, {
278
278
  children: [/*#__PURE__*/_jsx(styles.WebTitle, {
279
- children: "\u767B\u5F55/\u6CE8\u518C"
279
+ children: formatMessage('登录/注册')
280
280
  }), /*#__PURE__*/_jsxs(Tabs, {
281
281
  activeKey: activeKey,
282
282
  onChange: function onChange(keyName) {
@@ -284,7 +284,7 @@ var Auth = function Auth(_ref) {
284
284
  },
285
285
  children: [!((currentLoginTypeList === null || currentLoginTypeList === void 0 ? void 0 : currentLoginTypeList.length) > 0 && !currentLoginTypeList.includes('wechat')) && /*#__PURE__*/_jsx(Tabs.TabPane, {
286
286
  tab: /*#__PURE__*/_jsxs(_Fragment, {
287
- children: [/*#__PURE__*/_jsx(WechatOutlined, {}), " \u5FAE\u4FE1"]
287
+ children: [/*#__PURE__*/_jsx(WechatOutlined, {}), " ", formatMessage('微信')]
288
288
  }),
289
289
  disabled: (currentLoginTypeList === null || currentLoginTypeList === void 0 ? void 0 : currentLoginTypeList.length) > 0 && !currentLoginTypeList.includes('wechat'),
290
290
  children: /*#__PURE__*/_jsx(PageContentWarp, {
@@ -335,7 +335,7 @@ var Auth = function Auth(_ref) {
335
335
  }, "wechat"), /*#__PURE__*/_jsx(Tabs.TabPane, {
336
336
  tab: /*#__PURE__*/_jsxs("span", {
337
337
  className: "tab-icon",
338
- children: [/*#__PURE__*/_jsx(UserOutlined, {}), " \u8D26\u6237"]
338
+ children: [/*#__PURE__*/_jsx(UserOutlined, {}), " ", formatMessage('账户')]
339
339
  }),
340
340
  disabled: !currentLoginTypeList.includes('account-login') && !currentLoginTypeList.includes('account'),
341
341
  children: /*#__PURE__*/_jsx(AuthLoginReg, {
@@ -1,6 +1,9 @@
1
- import React from 'react';
1
+ import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
2
+ import React, { useState } from 'react';
2
3
  import LoginQr from "./qr";
3
4
  import Tool from "../lib/Tool";
5
+ import { ConfigProvider } from "antd";
6
+ import getLanguage from "../lib/get-language";
4
7
  import { jsx as _jsx } from "react/jsx-runtime";
5
8
  var Auth = function Auth(_ref) {
6
9
  var productType = _ref.productType,
@@ -12,19 +15,29 @@ var Auth = function Auth(_ref) {
12
15
  accountRegDisabled = _ref.accountRegDisabled,
13
16
  _ref$onSuccess = _ref.onSuccess,
14
17
  onSuccess = _ref$onSuccess === void 0 ? function () {} : _ref$onSuccess;
18
+ var _useState = useState(getLanguage()),
19
+ _useState2 = _slicedToArray(_useState, 2),
20
+ antdLocaleLanguage = _useState2[0],
21
+ setAntdLocaleLanguage = _useState2[1];
15
22
  var onLoginSuccess = function onLoginSuccess() {
16
23
  onSuccess();
17
24
  Tool.pageDialogCloseAll();
18
25
  };
19
- return /*#__PURE__*/_jsx(LoginQr, {
20
- productType: productType,
21
- clientUniqueKeyList: clientUniqueKeyList,
22
- defaultLoginType: defaultLoginType,
23
- wechatDisabled: wechatDisabled,
24
- accountDisabled: accountDisabled,
25
- accountHidden: accountHidden,
26
- accountRegDisabled: accountRegDisabled,
27
- onLoginSuccess: onLoginSuccess
26
+ return /*#__PURE__*/_jsx(ConfigProvider, {
27
+ locale: antdLocaleLanguage.locale,
28
+ direction: antdLocaleLanguage.direction
29
+ // theme={ theme }
30
+ ,
31
+ children: /*#__PURE__*/_jsx(LoginQr, {
32
+ productType: productType,
33
+ clientUniqueKeyList: clientUniqueKeyList,
34
+ defaultLoginType: defaultLoginType,
35
+ wechatDisabled: wechatDisabled,
36
+ accountDisabled: accountDisabled,
37
+ accountHidden: accountHidden,
38
+ accountRegDisabled: accountRegDisabled,
39
+ onLoginSuccess: onLoginSuccess
40
+ })
28
41
  });
29
42
  };
30
43
  export default Auth;
@@ -5,6 +5,7 @@ import { UserAddOutlined, UserOutlined } from "@ant-design/icons";
5
5
  import Reg from "./reg";
6
6
  import styles from "./login-reg.css";
7
7
  import AuthLogin from "./login";
8
+ import formatMessage from "../lib/formatMessage";
8
9
  import { jsx as _jsx } from "react/jsx-runtime";
9
10
  import { jsxs as _jsxs } from "react/jsx-runtime";
10
11
  var AuthLoginReg = function AuthLoginReg(_ref) {
@@ -33,11 +34,11 @@ var AuthLoginReg = function AuthLoginReg(_ref) {
33
34
  value: activeKey,
34
35
  children: [/*#__PURE__*/_jsxs(Radio.Button, {
35
36
  value: "login",
36
- children: [/*#__PURE__*/_jsx(UserOutlined, {}), " \u767B\u5F55"]
37
+ children: [/*#__PURE__*/_jsx(UserOutlined, {}), " ", formatMessage('登录')]
37
38
  }), /*#__PURE__*/_jsxs(Radio.Button, {
38
39
  value: "reg",
39
40
  disabled: accountRegDisabled,
40
- children: [/*#__PURE__*/_jsx(UserAddOutlined, {}), " \u6CE8\u518C"]
41
+ children: [/*#__PURE__*/_jsx(UserAddOutlined, {}), " ", formatMessage('注册')]
41
42
  })]
42
43
  })
43
44
  }), /*#__PURE__*/_jsxs(Tabs, {
@@ -47,7 +48,7 @@ var AuthLoginReg = function AuthLoginReg(_ref) {
47
48
  setActiveKey(keyName);
48
49
  },
49
50
  children: [/*#__PURE__*/_jsx(Tabs.TabPane, {
50
- tab: "\u767B\u5F55",
51
+ tab: formatMessage('登录'),
51
52
  children: /*#__PURE__*/_jsx(AuthLogin, {
52
53
  roleType: roleType,
53
54
  env: env,
@@ -60,7 +61,7 @@ var AuthLoginReg = function AuthLoginReg(_ref) {
60
61
  }
61
62
  })
62
63
  }, "login"), /*#__PURE__*/_jsx(Tabs.TabPane, {
63
- tab: "\u6CE8\u518C",
64
+ tab: formatMessage('注册'),
64
65
  children: /*#__PURE__*/_jsx(Reg, {
65
66
  env: env,
66
67
  roleType: roleType,
@@ -11,6 +11,7 @@ import { useRequest } from '@umijs/hooks';
11
11
  // import styles from "./reg.scss" ;
12
12
  import * as AuthController from "../service/api/AuthController";
13
13
  import AuthUserOffline from "./user-offline";
14
+ import formatMessage from "../lib/formatMessage";
14
15
  import { jsx as _jsx } from "react/jsx-runtime";
15
16
  import { jsxs as _jsxs } from "react/jsx-runtime";
16
17
  var formItemLayout = {
@@ -84,7 +85,7 @@ var AuthReg = function AuthReg(_ref) {
84
85
  Tool.setLocalUserInfo(_objectSpread(_objectSpread({}, data), {}, {
85
86
  isLogin: true
86
87
  }));
87
- Tool.toast('登录成功');
88
+ Tool.toast(formatMessage('成功'));
88
89
  Tool.event.run('user-info');
89
90
  Tool.event.run("".concat(roleType || 'user', "-login-success"), _objectSpread(_objectSpread({}, data), {}, {
90
91
  isLogin: true
@@ -116,12 +117,12 @@ var AuthReg = function AuthReg(_ref) {
116
117
  disabled: loading,
117
118
  autoComplete: "off",
118
119
  children: [/*#__PURE__*/_jsx(Form.Item, _objectSpread(_objectSpread({
119
- label: "\u624B\u673A\u53F7\u7801"
120
+ label: formatMessage('手机号码')
120
121
  }, formItemLayout), {}, {
121
122
  name: "accountName",
122
123
  rules: [{
123
124
  required: true,
124
- message: '请输入手机号码'
125
+ message: formatMessage('请输入')
125
126
  },
126
127
  // {
127
128
  // pattern: /^([a-z0-9]+[_\-.]?)*[a-z0-9]+@([a-z0-9]+[_\-.]?)*[a-z0-9]+\.[a-z]{2,10}$/i,
@@ -129,33 +130,37 @@ var AuthReg = function AuthReg(_ref) {
129
130
  // },
130
131
  {
131
132
  pattern: /^\s*1\d{2}\s*\d{4}\s*\d{4}\s*$/,
132
- message: '这似乎不是大陆手机号码?'
133
+ message: "".concat(formatMessage('这似乎不是中国大陆手机号码'), "\uFF1F")
133
134
  }],
134
135
  children: /*#__PURE__*/_jsx(Input, {
135
- placeholder: "\u624B\u673A\u53F7\u7801",
136
+ placeholder: formatMessage('手机号码'),
136
137
  prefix: /*#__PURE__*/_jsx(UserOutlined, {
137
138
  className: "input-prefix-icon"
138
139
  })
139
140
  })
140
141
  })), /*#__PURE__*/_jsx(Form.Item, _objectSpread(_objectSpread({}, formItemLayout), {}, {
141
- label: "\u5BC6\u7801",
142
+ label: formatMessage('密码'),
142
143
  name: "password",
143
144
  rules: [{
144
145
  required: true,
145
- message: '请输入密码!'
146
+ message: formatMessage('请输入')
146
147
  }, {
147
148
  min: 6,
148
- message: '密码最短6位哦'
149
+ message: formatMessage('最少#{maxCount}个字符', {
150
+ maxCount: 6
151
+ })
149
152
  }, {
150
153
  max: 60,
151
- message: '密码最长60位哦'
154
+ message: formatMessage('最多#{maxCount}个字符', {
155
+ maxCount: 60
156
+ })
152
157
  }],
153
158
  children: /*#__PURE__*/_jsx(Input.Password, {
154
159
  prefix: /*#__PURE__*/_jsx(LockOutlined, {
155
160
  className: "input-prefix-icon"
156
161
  }),
157
162
  type: "password",
158
- placeholder: "\u8F93\u5165\u60A8\u7684\u5BC6\u7801",
163
+ placeholder: formatMessage('请输入'),
159
164
  iconRender: function iconRender(visible) {
160
165
  return visible ? /*#__PURE__*/_jsx(EyeTwoTone, {}) : /*#__PURE__*/_jsx(EyeInvisibleOutlined, {});
161
166
  }
@@ -166,7 +171,7 @@ var AuthReg = function AuthReg(_ref) {
166
171
  loading: loading,
167
172
  htmlType: "submit",
168
173
  icon: /*#__PURE__*/_jsx(UserOutlined, {}),
169
- children: "\u767B\u5F55"
174
+ children: formatMessage('登录')
170
175
  })
171
176
  }))]
172
177
  })
@@ -4,7 +4,7 @@ import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
4
4
  import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
5
5
  import React, { useState, useEffect, useRef } from 'react';
6
6
  import { WechatOutlined, RedoOutlined, UserOutlined } from '@ant-design/icons';
7
- import { Tabs } from 'antd';
7
+ import { Tabs, QRCode } from 'antd';
8
8
  import Tool from "../../lib/Tool";
9
9
  import { useRequest } from '@umijs/hooks';
10
10
  import * as AuthController from "../../service/api/AuthController";
@@ -17,8 +17,8 @@ import styles from "./index.css";
17
17
  var reTryMaxCount = 120;
18
18
  var reTryTimeLoop = 1000; // ms
19
19
  var FromWhere = 'web';
20
- import QRCode from 'qrcode.react';
21
20
  import h5WePublicLogin from "./h5-we-public-login";
21
+ import formatMessage from "../../lib/formatMessage";
22
22
  import { jsx as _jsx } from "react/jsx-runtime";
23
23
  import { Fragment as _Fragment } from "react/jsx-runtime";
24
24
  import { jsxs as _jsxs } from "react/jsx-runtime";
@@ -135,7 +135,7 @@ var LoginQr = function LoginQr(_ref) {
135
135
  }));
136
136
  onLoginSuccess();
137
137
  Tool.event.run('login-success');
138
- Tool.toast('登录成功');
138
+ Tool.toast(formatMessage('成功'));
139
139
  };
140
140
  var _useRequest = useRequest(function () {
141
141
  return AuthController.weMiniLoginQr({
@@ -261,7 +261,7 @@ var LoginQr = function LoginQr(_ref) {
261
261
  children: /*#__PURE__*/_jsxs(styles.LoginForm, {
262
262
  children: [/*#__PURE__*/_jsx(styles.WebTitle, {
263
263
  children: /*#__PURE__*/_jsx("span", {
264
- children: "\u767B\u5F55/\u6CE8\u518C"
264
+ children: formatMessage('登录/注册')
265
265
  })
266
266
  }), /*#__PURE__*/_jsxs(Tabs, {
267
267
  activeKey: activeKey,
@@ -319,7 +319,7 @@ var LoginQr = function LoginQr(_ref) {
319
319
  }, "wechat"), !accountHidden && /*#__PURE__*/_jsx(Tabs.TabPane, {
320
320
  tab: /*#__PURE__*/_jsxs("span", {
321
321
  className: "tab-icon",
322
- children: [/*#__PURE__*/_jsx(UserOutlined, {}), "\u8D26\u6237"]
322
+ children: [/*#__PURE__*/_jsx(UserOutlined, {}), formatMessage('账户')]
323
323
  }),
324
324
  disabled: accountDisabled,
325
325
  children: /*#__PURE__*/_jsx(AuthLoginReg
@@ -8,6 +8,7 @@ import { Input, Button, Form } from 'antd';
8
8
  import Tool from "../lib/Tool";
9
9
  import { useRequest } from "@umijs/hooks";
10
10
  import * as AuthController from "../service/api/AuthController";
11
+ import formatMessage from "../lib/formatMessage";
11
12
  import { jsx as _jsx } from "react/jsx-runtime";
12
13
  import { jsxs as _jsxs } from "react/jsx-runtime";
13
14
  var formItemLayout = {
@@ -54,7 +55,7 @@ var Reg = function Reg(_ref) {
54
55
  Tool.setLocalUserInfo(_objectSpread(_objectSpread({}, data), {}, {
55
56
  isLogin: true
56
57
  }));
57
- Tool.toast('登录成功');
58
+ Tool.toast(formatMessage('成功'));
58
59
  Tool.event.run('user-info');
59
60
  Tool.event.run("".concat(roleType || 'user', "-login-success"), _objectSpread(_objectSpread({}, data), {}, {
60
61
  isLogin: true
@@ -86,63 +87,74 @@ var Reg = function Reg(_ref) {
86
87
  onFinish: onFinish,
87
88
  autoComplete: "off",
88
89
  children: [/*#__PURE__*/_jsx(Form.Item, _objectSpread(_objectSpread({
89
- label: "\u8D26\u53F7"
90
+ label: formatMessage('手机号码')
90
91
  }, formItemLayout), {}, {
91
92
  name: "accountName",
92
93
  rules: [{
93
94
  required: true,
94
- message: '请输入手机号码'
95
+ message: formatMessage('请输入')
95
96
  },
96
97
  // { min: 11, message: '最短4个字符', }
97
98
  {
98
99
  pattern: /^1\d{2}\s*\d{4}\s*\d{4}\s*$/,
99
- message: '这似乎不是大陆手机号码?'
100
+ message: formatMessage('这似乎不是中国大陆手机号码') + '?'
100
101
  }],
101
102
  children: /*#__PURE__*/_jsx(Input, {
102
- placeholder: "\u624B\u673A\u53F7\u7801",
103
+ placeholder: formatMessage('手机号码'),
103
104
  prefix: /*#__PURE__*/_jsx(UserOutlined, {
104
105
  className: "input-prefix-icon"
105
106
  })
106
107
  })
107
108
  })), /*#__PURE__*/_jsx(Form.Item, _objectSpread(_objectSpread({}, formItemLayout), {}, {
108
- label: "\u5BC6\u7801",
109
+ label: formatMessage('密码'),
109
110
  name: "password",
110
111
  rules: [{
111
112
  required: true,
112
- message: '请输入密码!'
113
+ message: formatMessage('请输入')
113
114
  }, {
114
115
  min: 6,
115
- message: '密码最短6位哦'
116
+ message: formatMessage('最少#{maxCount}个字符', {
117
+ maxCount: 6
118
+ })
116
119
  }, {
117
120
  max: 60,
118
- message: '密码最长60位哦'
121
+ message: formatMessage('最多#{maxCount}个字符', {
122
+ maxCount: 60
123
+ })
119
124
  }],
120
125
  children: /*#__PURE__*/_jsx(Input.Password, {
121
126
  prefix: /*#__PURE__*/_jsx(LockOutlined, {
122
127
  className: "input-prefix-icon"
123
128
  }),
124
129
  type: "password",
125
- placeholder: "\u8F93\u5165\u60A8\u7684\u5BC6\u7801",
130
+ placeholder: formatMessage('请输入'),
126
131
  iconRender: function iconRender(visible) {
127
132
  return visible ? /*#__PURE__*/_jsx(EyeTwoTone, {}) : /*#__PURE__*/_jsx(EyeInvisibleOutlined, {});
128
133
  }
129
134
  })
130
135
  })), /*#__PURE__*/_jsx(Form.Item, _objectSpread(_objectSpread({}, formItemLayout), {}, {
131
- label: "\u786E\u8BA4\u5BC6\u7801",
136
+ label: formatMessage('确认密码'),
132
137
  name: "inviteId",
133
138
  rules: [{
134
139
  required: true,
135
- message: '请输入推荐码'
140
+ message: formatMessage('请输入')
141
+ }, {
142
+ min: 6,
143
+ message: formatMessage('最少#{maxCount}个字符', {
144
+ maxCount: 6
145
+ })
136
146
  }, {
137
147
  max: 60,
138
- message: '密码最长60位哦'
148
+ message: formatMessage('最多#{maxCount}个字符', {
149
+ maxCount: 60
150
+ })
139
151
  }],
140
152
  children: /*#__PURE__*/_jsx(Input.Password, {
141
153
  type: "password",
142
154
  prefix: /*#__PURE__*/_jsx(LockOutlined, {
143
155
  className: "input-prefix-icon"
144
156
  }),
145
- placeholder: "\u628A\u4E0A\u9762\u7684\u5BC6\u7801\u518D\u8F93\u5165\u4E00\u6B21"
157
+ placeholder: formatMessage('再次密码')
146
158
  })
147
159
  })), /*#__PURE__*/_jsx(Form.Item, _objectSpread(_objectSpread({}, tailFormItemLayout), {}, {
148
160
  children: /*#__PURE__*/_jsx("div", {
@@ -151,7 +163,7 @@ var Reg = function Reg(_ref) {
151
163
  loading: loading,
152
164
  htmlType: "submit",
153
165
  icon: /*#__PURE__*/_jsx(UserOutlined, {}),
154
- children: "\u6CE8\u518C"
166
+ children: formatMessage('注册')
155
167
  })
156
168
  })
157
169
  }))]
package/dist/Buy/qr.js CHANGED
@@ -1,12 +1,11 @@
1
1
  import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
2
2
  import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
3
3
  import React, { useEffect, useState } from 'react';
4
- import { Result, Button, Space, Divider, Tabs } from 'antd';
4
+ import { Result, Button, Space, Divider, Tabs, QRCode } from 'antd';
5
5
  import { AlipayCircleOutlined, CloseOutlined, LoadingOutlined, PauseOutlined, WechatOutlined } from '@ant-design/icons';
6
6
  import { useRequest } from '@umijs/hooks';
7
7
  import * as TradeController from "../service/api/TradeController";
8
8
  import * as VipController from "../service/api/VipController";
9
- import QRCode from 'qrcode.react';
10
9
  import Tool from "../lib/Tool";
11
10
  import PageContentWarp from "../UI/PageContentWarp";
12
11
  import styles from "./qr.css";
@@ -162,7 +162,7 @@ declare const Tool: {
162
162
  getTitleByPath(path: string): string;
163
163
  getDirByPath(path: string): string;
164
164
  h5Pay(query: Pay.H5PayQuery): void;
165
- notification(type: "info" | "error" | "warning" | "success", message: string, description?: import("react").ReactNode, options?: import("./notification").NotificationOption): void;
165
+ notification(type: "success" | "info" | "warning" | "error", message: string, description?: import("react").ReactNode, options?: import("./notification").NotificationOption): void;
166
166
  notificationSuccess(message: string, description?: import("react").ReactNode, options?: import("./notification").NotificationOption): void;
167
167
  notificationError(message: string, description?: import("react").ReactNode, options?: import("./notification").NotificationOption): void;
168
168
  notificationWarning(message: string, description?: import("react").ReactNode, options?: import("./notification").NotificationOption): void;
package/dist/lib/Tool.js CHANGED
@@ -4,9 +4,9 @@ import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
4
4
  import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
5
5
  // @ts-nocheck
6
6
 
7
- import { Modal, message, Tooltip } from 'antd';
7
+ import { Modal, message, Tooltip, QRCode } from 'antd';
8
8
  // const JrQrcode = require('jr-qrcode');
9
- import QRCode from 'qrcode.react';
9
+
10
10
  if (!window.__events) {
11
11
  window.__events = [];
12
12
  }
@@ -0,0 +1,5 @@
1
+ interface FormatMessageData {
2
+ [name: string]: string | number;
3
+ }
4
+ declare const formatMessage: (id: string, data?: FormatMessageData, defaultMessage?: string) => string;
5
+ export default formatMessage;
@@ -0,0 +1,59 @@
1
+ import zhCN from "../locales/zh-CN.json";
2
+ import zhHK from "../locales/zh-HK.json";
3
+ import zhTW from "../locales/zh-TW.json";
4
+ import enUS from "../locales/en-US.json";
5
+ import esES from "../locales/es-ES.json";
6
+ import jaJP from "../locales/ja-JP.json";
7
+ import thTH from "../locales/th-TH.json";
8
+ import viVN from "../locales/vi-VN.json";
9
+ import deDE from "../locales/de-DE.json";
10
+ import frFR from "../locales/fr-FR.json";
11
+ import ruRU from "../locales/ru-RU.json";
12
+ import ptPT from "../locales/pt-PT.json";
13
+ import koKR from "../locales/ko-KR.json";
14
+ import itIT from "../locales/it-IT.json";
15
+ import arEG from "../locales/ar-EG.json";
16
+ import getLanguage from "./get-language";
17
+ var resources = {
18
+ 'zh-CN': zhCN,
19
+ 'zh-HK': zhHK,
20
+ 'zh-TW': zhTW,
21
+ 'en-US': enUS,
22
+ 'es-ES': esES,
23
+ 'ja-JP': jaJP,
24
+ 'th-TH': thTH,
25
+ 'vi-VN': viVN,
26
+ 'de-DE': deDE,
27
+ 'fr-FR': frFR,
28
+ 'ru-RU': ruRU,
29
+ 'pt-PT': ptPT,
30
+ 'ko-KR': koKR,
31
+ 'it-IT': itIT,
32
+ 'ar-EG': arEG
33
+ };
34
+ var formatMessage = function formatMessage(id) {
35
+ var data = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
36
+ var defaultMessage = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : '';
37
+ if (!id) {
38
+ return '';
39
+ }
40
+ var language = getLanguage();
41
+ var messages = resources[language.language] || resources['zh-CN'];
42
+ // const msg = intl.formatMessage({
43
+ // id,
44
+ // defaultMessage,
45
+ // }, {
46
+ // ...data,
47
+ // });
48
+
49
+ var text = messages[id] || id || '';
50
+ for (var dataKey in data) {
51
+ var value = data[dataKey];
52
+ text = text.replaceAll("#{".concat(dataKey, "}"), value);
53
+ }
54
+ if (!text) {
55
+ console.warn('翻译缺失:', id);
56
+ }
57
+ return text;
58
+ };
59
+ export default formatMessage;
@@ -0,0 +1,11 @@
1
+ import 'dayjs/locale/zh-cn';
2
+ import type { Locale } from "antd/lib/locale";
3
+ import { DirectionType } from "antd/es/config-provider";
4
+ interface Language {
5
+ language: string;
6
+ locale: Locale;
7
+ direction: DirectionType;
8
+ fontFamily: string | undefined;
9
+ }
10
+ declare const getLanguage: (language?: string) => Language;
11
+ export default getLanguage;
@@ -0,0 +1,69 @@
1
+ import zhCN from 'antd/locale/zh_CN';
2
+ import zhHK from 'antd/locale/zh_HK';
3
+ import zhTW from 'antd/locale/zh_TW';
4
+ import enUS from 'antd/locale/en_US';
5
+ import esES from 'antd/locale/es_ES';
6
+ import jaJP from 'antd/locale/ja_JP';
7
+ import thTH from 'antd/locale/th_TH';
8
+ import viVN from 'antd/locale/vi_VN';
9
+ import deDE from 'antd/locale/de_DE';
10
+ import frFR from 'antd/locale/fr_FR';
11
+ import ruRU from 'antd/locale/ru_RU';
12
+ import ptPT from 'antd/locale/pt_PT';
13
+ import koKR from 'antd/locale/ko_KR';
14
+ import itIT from 'antd/locale/it_IT';
15
+ import arEG from 'antd/locale/ar_EG';
16
+ import 'dayjs/locale/zh-cn';
17
+ var LanguageDict = {
18
+ 'zh-CN': zhCN,
19
+ "zh-HK": zhHK,
20
+ "zh-TW": zhTW,
21
+ "en-US": enUS,
22
+ "es-ES": esES,
23
+ "ja-JP": jaJP,
24
+ "th-TH": thTH,
25
+ "vi-VN": viVN,
26
+ "de-DE": deDE,
27
+ "fr-FR": frFR,
28
+ "ru-RU": ruRU,
29
+ "pt-PT": ptPT,
30
+ "ko-KR": koKR,
31
+ "it-IT": itIT,
32
+ "ar-EG": arEG
33
+ };
34
+ var getLanguage = function getLanguage() {
35
+ var language = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
36
+ language = language || localStorage.getItem('umi_locale') || 'zh-CN'; // ;
37
+ language = language.replace('_', '-');
38
+ var outData = {
39
+ language: language,
40
+ locale: LanguageDict[language] || enUS,
41
+ direction: undefined,
42
+ fontFamily: undefined
43
+ };
44
+ if (!LanguageDict[outData.language]) {
45
+ // 没有命中
46
+ switch (outData.language) {
47
+ case 'zh-HK':
48
+ case 'zh-TW':
49
+ language = 'zh-CN';
50
+ break;
51
+ case 'en-GB':
52
+ outData.language = 'en-US';
53
+ break;
54
+ default:
55
+ // 实在找不到,就英语
56
+ outData.language = 'en-US';
57
+ outData.locale = enUS;
58
+ }
59
+ }
60
+ if (['ar-EG'].includes(outData.language)) {
61
+ outData.direction = 'rtl';
62
+ outData.fontFamily = "Tahoma, Arial, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, 'Noto Sans', sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol', 'Noto Color Emoji' !important";
63
+ }
64
+
65
+ // setLocale( outData.language );
66
+
67
+ return outData;
68
+ };
69
+ export default getLanguage;
@@ -0,0 +1,2 @@
1
+ declare const isLanguageZh: () => boolean;
2
+ export default isLanguageZh;
@@ -0,0 +1,7 @@
1
+ import getLanguage from "./get-language";
2
+ var isLanguageZh = function isLanguageZh() {
3
+ var language = getLanguage().language;
4
+ console.log('isLanguageZh language:', language, language.indexOf('zh-') > -1);
5
+ return language.indexOf('zh-') > -1;
6
+ };
7
+ export default isLanguageZh;
@@ -7,6 +7,7 @@ import request from 'umi-request';
7
7
  import getApiUrl, { getApiEnv, getMainPort } from "./getApiUrl";
8
8
  import goAuth from "./goAuth";
9
9
  import Tool from "./Tool";
10
+ import formatMessage from "./formatMessage";
10
11
  var requestApi = /*#__PURE__*/function () {
11
12
  var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
12
13
  var _window$getClientIden, _window;
@@ -67,7 +68,7 @@ var requestApi = /*#__PURE__*/function () {
67
68
  if (result.success) {
68
69
  resolve(result.data || true);
69
70
  } else {
70
- var error = new Error((result === null || result === void 0 ? void 0 : result.message) || '发生了一些问题,请稍后重试');
71
+ var error = new Error((result === null || result === void 0 ? void 0 : result.message) || formatMessage('发生了一些问题,请稍后重试'));
71
72
  error.name = result.code;
72
73
  error.stack = result.data;
73
74
  if (['staff-not-login', 'not-login'].includes((result === null || result === void 0 ? void 0 : result.code) || '')) {
@@ -94,12 +95,12 @@ var requestApi = /*#__PURE__*/function () {
94
95
  console.log('request component shipinlv:', JSON.stringify(err), url);
95
96
  if (!((_err = err) !== null && _err !== void 0 && _err.response) && url.indexOf("http://127.0.0.1:".concat(getMainPort())) === 0) {
96
97
  err.name = "shipinlv-client-not-run";
97
- err.message = "\u8FDE\u63A5\u672C\u5730\u670D\u52A1\u5931\u8D25\uFF0C\u8BF7\u5C1D\u8BD5\u91CD\u542F\u8F6F\u4EF6";
98
+ err.message = formatMessage('连接本地服务失败,请尝试重启软件');
98
99
  reject(err);
99
100
  return;
100
101
  }
101
102
  if (['Failed to fetch', 'http error'].includes((_err2 = err) === null || _err2 === void 0 ? void 0 : _err2.message)) {
102
- err.message = '发生了一些问题,请稍后重试';
103
+ err.message = formatMessage('发生了一些问题,请稍后重试');
103
104
  }
104
105
  if (!(options !== null && options !== void 0 && options.silent)) {
105
106
  Tool.toastError(err.message);