@antv/dumi-theme-antv 0.8.0-beta.4 → 0.8.0-beta.5

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.
@@ -6,6 +6,8 @@ import cls from 'classnames';
6
6
  import { useIntl } from 'dumi';
7
7
  import "./index.less";
8
8
 
9
+ // 添加 window.noCaptcha 的类型声明
10
+
9
11
  // 图形验证码资源文件
10
12
  var NC_CSS_SOURCE = 'https://g.alicdn.com/sd/ncpc/nc.css?t=1514534550478';
11
13
  var NC_SCRIPT_SOURCE = 'https://g.alicdn.com/sd/ncpc/nc.js?t=1514534550478';
@@ -16,12 +18,12 @@ var Captcha = /*#__PURE__*/forwardRef(function (_ref, ref) {
16
18
  _ref$scene = _ref.scene,
17
19
  scene = _ref$scene === void 0 ? NC_SCENE.login : _ref$scene,
18
20
  form = _ref.form,
19
- en = _ref.en,
20
21
  _ref$onCallback = _ref.onCallback,
21
22
  onCallback = _ref$onCallback === void 0 ? function () {} : _ref$onCallback,
22
23
  className = _ref.className;
23
24
  var _useIntl = useIntl(),
24
- formatMessage = _useIntl.formatMessage;
25
+ formatMessage = _useIntl.formatMessage,
26
+ locale = _useIntl.locale;
25
27
  var ncInstance = useRef(null);
26
28
  function reset() {
27
29
  var _ncInstance$current;
@@ -64,7 +66,7 @@ var Captcha = /*#__PURE__*/forwardRef(function (_ref, ref) {
64
66
  appkey: nc_appkey,
65
67
  scene: nc_scene,
66
68
  token: nc_token,
67
- language: en ? 'en' : 'cn',
69
+ language: locale ? 'en' : 'cn',
68
70
  customWidth: nc_customWidth,
69
71
  callback: function callback(data) {
70
72
  // 校验成功回调
@@ -81,41 +83,27 @@ var Captcha = /*#__PURE__*/forwardRef(function (_ref, ref) {
81
83
  };
82
84
  (_ncInstance$current2 = ncInstance.current) === null || _ncInstance$current2 === void 0 || _ncInstance$current2.init(nc_option);
83
85
  var lang = {
84
- _startTEXT: en ? formatMessage({
85
- id: 'login.captcha.drag.en'
86
- }) : formatMessage({
86
+ _startTEXT: formatMessage({
87
87
  id: 'login.captcha.drag'
88
88
  }),
89
- _yesTEXT: en ? formatMessage({
90
- id: 'login.captcha.success.en'
91
- }) : formatMessage({
89
+ _yesTEXT: formatMessage({
92
90
  id: 'login.captcha.success'
93
91
  }),
94
- _Loading: en ? formatMessage({
95
- id: 'login.captcha.loading.en'
96
- }) : formatMessage({
92
+ _Loading: formatMessage({
97
93
  id: 'login.captcha.loading'
98
94
  }),
99
- _error300: en ? formatMessage({
100
- id: 'login.captcha.error.wrong.en'
101
- }) + ' <a href="javascript:__nc.reset()">' + formatMessage({
102
- id: 'login.captcha.error.refresh.en'
103
- }) + '</a>' : formatMessage({
95
+ _error300: formatMessage({
104
96
  id: 'login.captcha.error.wrong'
105
97
  }) + ' <a href="javascript:__nc.reset()">' + formatMessage({
106
98
  id: 'login.captcha.error.refresh'
107
99
  }) + '</a>',
108
- _errorNetwork: en ? formatMessage({
109
- id: 'login.captcha.error.network.en'
110
- }) + ' <a href="javascript:__nc.reset()">' + formatMessage({
111
- id: 'login.captcha.error.refresh.en'
112
- }) + '</a>' : formatMessage({
100
+ _errorNetwork: formatMessage({
113
101
  id: 'login.captcha.error.network'
114
102
  }) + ' <a href="javascript:__nc.reset()">' + formatMessage({
115
103
  id: 'login.captcha.error.refresh'
116
104
  }) + '</a>'
117
105
  };
118
- if (en) {
106
+ if (locale) {
119
107
  var _ncInstance$current3;
120
108
  (_ncInstance$current3 = ncInstance.current) === null || _ncInstance$current3 === void 0 || _ncInstance$current3.upLang('en', lang);
121
109
  } else {
@@ -185,9 +173,7 @@ var Captcha = /*#__PURE__*/forwardRef(function (_ref, ref) {
185
173
  name: "captcha",
186
174
  rules: [{
187
175
  required: true,
188
- message: en ? formatMessage({
189
- id: 'login.captcha.required.en'
190
- }) : formatMessage({
176
+ message: formatMessage({
191
177
  id: 'login.captcha.required'
192
178
  })
193
179
  }],
@@ -46,10 +46,8 @@ function CheckCode(_ref) {
46
46
  var captchaRef = useRef(null);
47
47
  var inputRef = useRef(null);
48
48
  var countDownRef = useRef(null);
49
- var countDownSendText = !en ? formatMessage({
49
+ var countDownSendText = formatMessage({
50
50
  id: 'login.checkcode.get'
51
- }) : formatMessage({
52
- id: 'login.checkcode.get.en'
53
51
  });
54
52
  function handleResetCountDown() {
55
53
  var _countDownRef$current;
@@ -89,10 +87,8 @@ function CheckCode(_ref) {
89
87
  captcha: captchaValues.captcha ? 1 : 0
90
88
  }));
91
89
  case 8:
92
- message.success(!en ? formatMessage({
90
+ message.success(formatMessage({
93
91
  id: 'login.checkcode.send.success'
94
- }) : formatMessage({
95
- id: 'login.checkcode.send.success.en'
96
92
  }));
97
93
  _context.next = 15;
98
94
  break;
@@ -130,17 +126,13 @@ function CheckCode(_ref) {
130
126
  break;
131
127
  }
132
128
  handleResetCountDown();
133
- message.error(!en ? formatMessage({
129
+ message.error(formatMessage({
134
130
  id: 'login.checkcode.error.incomplete'
135
- }) : formatMessage({
136
- id: 'login.checkcode.error.incomplete.en'
137
131
  }));
138
132
  form.setFields([{
139
133
  name: 'captcha',
140
- errors: [!en ? formatMessage({
134
+ errors: [formatMessage({
141
135
  id: 'login.checkcode.error.incomplete'
142
- }) : formatMessage({
143
- id: 'login.checkcode.error.incomplete.en'
144
136
  })]
145
137
  }]);
146
138
  // 尝试解决滑块显示完成,但提示没有完成的问题
@@ -195,10 +187,8 @@ function CheckCode(_ref) {
195
187
  if (sending) {
196
188
  return /*#__PURE__*/React.createElement("div", {
197
189
  className: "mobile-code-hint"
198
- }, /*#__PURE__*/React.createElement("span", null, !en ? formatMessage({
190
+ }, /*#__PURE__*/React.createElement("span", null, formatMessage({
199
191
  id: 'login.checkcode.sent'
200
- }) : formatMessage({
201
- id: 'login.checkcode.sent.en'
202
192
  })));
203
193
  }
204
194
  }
@@ -222,27 +212,21 @@ function CheckCode(_ref) {
222
212
  validateTrigger: ['onSubmit', 'onBlur'],
223
213
  rules: [{
224
214
  required: true,
225
- message: !en ? formatMessage({
215
+ message: formatMessage({
226
216
  id: 'login.checkcode.required'
227
- }) : formatMessage({
228
- id: 'login.checkcode.required.en'
229
217
  })
230
218
  }, {
231
219
  pattern: /^\d{6}$/,
232
- message: !en ? formatMessage({
220
+ message: formatMessage({
233
221
  id: 'login.checkcode.invalid'
234
- }) : formatMessage({
235
- id: 'login.checkcode.invalid.en'
236
222
  })
237
223
  }]
238
224
  }, /*#__PURE__*/React.createElement(Input, {
239
225
  type: "text",
240
226
  autoComplete: "off",
241
227
  ref: inputRef,
242
- placeholder: !en ? formatMessage({
228
+ placeholder: formatMessage({
243
229
  id: 'login.checkcode.placeholder'
244
- }) : formatMessage({
245
- id: 'login.checkcode.placeholder.en'
246
230
  }),
247
231
  maxLength: 6
248
232
  }))), /*#__PURE__*/React.createElement("div", {
@@ -76,20 +76,14 @@ var CountDownButton = /*#__PURE__*/forwardRef(function (_ref, ref) {
76
76
  if (counting) {
77
77
  return /*#__PURE__*/React.createElement("span", {
78
78
  className: "code-count-text"
79
- }, en ? formatMessage({
80
- id: 'login.countdown.resend.en'
81
- }, {
82
- time: countingTime
83
- }) : formatMessage({
79
+ }, formatMessage({
84
80
  id: 'login.countdown.resend'
85
81
  }, {
86
82
  time: countingTime
87
83
  }));
88
84
  }
89
85
  if (hasSend) {
90
- return en ? formatMessage({
91
- id: 'login.countdown.resend.simple.en'
92
- }) : formatMessage({
86
+ return formatMessage({
93
87
  id: 'login.countdown.resend.simple'
94
88
  });
95
89
  }
@@ -2,12 +2,16 @@ import React from 'react';
2
2
  import LoginForm from "./LoginForm";
3
3
  import { Modal } from 'antd';
4
4
  import { useSnapshot } from 'valtio';
5
+ import { useIntl } from 'dumi';
5
6
  import { authStore, hideLoginModal } from "../../model/auth";
6
7
  export function LoginModal() {
7
8
  var authSnap = useSnapshot(authStore);
9
+ var intl = useIntl();
8
10
  return /*#__PURE__*/React.createElement(Modal, {
9
11
  width: 400,
10
- title: "\u9A8C\u8BC1\u7801\u767B\u5F55",
12
+ title: intl.formatMessage({
13
+ id: 'login.modal.title'
14
+ }),
11
15
  open: authSnap.isModalOpen,
12
16
  onCancel: function onCancel() {
13
17
  return hideLoginModal();
@@ -279,45 +279,24 @@
279
279
  "login.error.invalid.phone": "Please enter a valid mobile number",
280
280
  "login.error.invalid.phone.or.email": "Please enter a valid mobile number or email",
281
281
  "login.button.login.or.register": "Sign In / Sign Up",
282
- "login.button.login.or.register.en": "Sign In / Sign Up",
283
- "login.button.github": "Login With GitHub",
284
- "login.button.github.en": "Login With GitHub",
285
- "login.button.google": "Login With Google",
286
- "login.button.google.en": "Login With Google",
287
282
  "login.protocol.read.agree": "I have read and agree to AntV ",
288
283
  "login.protocol.link": "User Agreement",
289
284
  "login.link.home": "Return to Home Page",
290
- "login.link.home.en": "Return to Home Page",
291
285
  "login.checkcode.get": "Get Code",
292
- "login.checkcode.get.en": "Get Code",
293
286
  "login.checkcode.send.success": "Verification code sent successfully",
294
- "login.checkcode.send.success.en": "Verification code sent successfully",
295
287
  "login.checkcode.error.incomplete": "Please complete the captcha verification first",
296
- "login.checkcode.error.incomplete.en": "Please complete the captcha verification first",
297
288
  "login.checkcode.sent": "The Verification code has been sent",
298
- "login.checkcode.sent.en": "The Verification code has been sent",
299
289
  "login.checkcode.required": "Verification code is required",
300
- "login.checkcode.required.en": "Verification code is required",
301
290
  "login.checkcode.invalid": "Please enter a valid 6-digit verification code",
302
- "login.checkcode.invalid.en": "Verification code not valid",
303
291
  "login.checkcode.placeholder": "Verification code",
304
- "login.checkcode.placeholder.en": "Verification code",
305
292
  "login.countdown.resend": "Resend({time})",
306
- "login.countdown.resend.en": "Resend({time})",
307
293
  "login.countdown.resend.simple": "Resend",
308
- "login.countdown.resend.simple.en": "Resend",
309
294
  "login.captcha.drag": "Hold and drag the slider right",
310
- "login.captcha.drag.en": "Hold and drag the slider right",
311
295
  "login.captcha.success": "Verification successful",
312
- "login.captcha.success.en": "Verification successful",
313
296
  "login.captcha.loading": "Loading...",
314
- "login.captcha.loading.en": "Loading...",
315
297
  "login.captcha.error.wrong": "Oops! Something went wrong. Click",
316
- "login.captcha.error.wrong.en": "Oops! Something went wrong. Click",
317
298
  "login.captcha.error.network": "Poor connection. Click",
318
- "login.captcha.error.network.en": "Poor connection. Click",
319
299
  "login.captcha.error.refresh": "Refresh",
320
- "login.captcha.error.refresh.en": "Refresh",
321
300
  "login.captcha.required": "Please drag the slider to verify",
322
- "login.captcha.required.en": "Please drag the slider to verify"
301
+ "login.modal.title": "Verification Code Login"
323
302
  }
@@ -278,45 +278,24 @@
278
278
  "login.error.invalid.phone": "请输入正确的手机号",
279
279
  "login.error.invalid.phone.or.email": "请输入正确的手机号或邮箱",
280
280
  "login.button.login.or.register": "登录 / 注册",
281
- "login.button.login.or.register.en": "Sign In / Sign Up",
282
- "login.button.github": "GitHub 登录",
283
- "login.button.github.en": "Login With GitHub",
284
- "login.button.google": "Google 登录",
285
- "login.button.google.en": "Login With Google",
286
281
  "login.protocol.read.agree": "我已阅读并同意 AntV ",
287
282
  "login.protocol.link": "用户协议 ",
288
283
  "login.link.home": "返回首页",
289
- "login.link.home.en": "Return to Home Page",
290
284
  "login.checkcode.get": "获取验证码",
291
- "login.checkcode.get.en": "Get Code",
292
285
  "login.checkcode.send.success": "验证码发送成功",
293
- "login.checkcode.send.success.en": "Verification code sent successfully",
294
286
  "login.checkcode.error.incomplete": "先完成滑块验证",
295
- "login.checkcode.error.incomplete.en": "Please complete the captcha verification first",
296
287
  "login.checkcode.sent": "已发送验证码",
297
- "login.checkcode.sent.en": "The Verification code has been sent",
298
288
  "login.checkcode.required": "验证码不能为空",
299
- "login.checkcode.required.en": "Verification code is required",
300
289
  "login.checkcode.invalid": "请输入有效的 6 位数字验证码",
301
- "login.checkcode.invalid.en": "Verification code not valid",
302
290
  "login.checkcode.placeholder": "6 位验证码",
303
- "login.checkcode.placeholder.en": "Verification code",
304
291
  "login.countdown.resend": "重新获取({time})",
305
- "login.countdown.resend.en": "Resend({time})",
306
292
  "login.countdown.resend.simple": "重新获取",
307
- "login.countdown.resend.simple.en": "Resend",
308
293
  "login.captcha.drag": "按住滑块,拖动到最右边",
309
- "login.captcha.drag.en": "Hold and drag the slider right",
310
294
  "login.captcha.success": "验证通过",
311
- "login.captcha.success.en": "Verification successful",
312
295
  "login.captcha.loading": "加载中",
313
- "login.captcha.loading.en": "Loading...",
314
296
  "login.captcha.error.wrong": "哎呀,出错了,单击",
315
- "login.captcha.error.wrong.en": "Oops!something went wrong. Click",
316
297
  "login.captcha.error.network": "网络不给力,单击",
317
- "login.captcha.error.network.en": "Poor connection. Click",
318
298
  "login.captcha.error.refresh": "刷新",
319
- "login.captcha.error.refresh.en": "Refresh",
320
299
  "login.captcha.required": "拖动滑块验证",
321
- "login.captcha.required.en": "Please drag the slider to verify"
300
+ "login.modal.title": "验证码登录"
322
301
  }
@@ -24,7 +24,7 @@ function hasSkipLoginParam() {
24
24
  // 1. 定义 State (只包含数据)
25
25
  export var authStore = proxy({
26
26
  isModalOpen: false,
27
- isAuthenticated: false,
27
+ isAuthenticated: true,
28
28
  token: localStorage.getItem('authToken')
29
29
  });
30
30
 
@@ -82,8 +82,34 @@ export var logout = function logout() {
82
82
  export function sendValidationCode(data) {
83
83
  return request.post('/api/modules/user/api/validation_code/send', data);
84
84
  }
85
- export var initializeAuth = function initializeAuth() {
86
- if (authStore.token || hasSkipLoginParam()) {
87
- authStore.isAuthenticated = true;
88
- }
89
- };
85
+ export var initializeAuth = /*#__PURE__*/function () {
86
+ var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
87
+ return _regeneratorRuntime().wrap(function _callee2$(_context2) {
88
+ while (1) switch (_context2.prev = _context2.next) {
89
+ case 0:
90
+ _context2.prev = 0;
91
+ if (hasSkipLoginParam()) {
92
+ _context2.next = 4;
93
+ break;
94
+ }
95
+ _context2.next = 4;
96
+ return request.get('/api/modules/user/api/accounts/get_company_info');
97
+ case 4:
98
+ authStore.isAuthenticated = true;
99
+ _context2.next = 11;
100
+ break;
101
+ case 7:
102
+ _context2.prev = 7;
103
+ _context2.t0 = _context2["catch"](0);
104
+ console.error('Initialize auth failed in store:', _context2.t0);
105
+ authStore.isAuthenticated = false;
106
+ case 11:
107
+ case "end":
108
+ return _context2.stop();
109
+ }
110
+ }, _callee2, null, [[0, 7]]);
111
+ }));
112
+ return function initializeAuth() {
113
+ return _ref2.apply(this, arguments);
114
+ };
115
+ }();
@@ -5,9 +5,9 @@ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key i
5
5
  function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
6
6
  function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
7
7
  import axios from 'axios';
8
- import { message, Modal } from 'antd';
8
+ import { message } from 'antd';
9
9
  import { getBaseURL } from "./env";
10
- import { getToken, removeToken } from "./auth";
10
+ import { getToken } from "./auth";
11
11
  var req = axios.create({
12
12
  baseURL: getBaseURL(),
13
13
  timeout: 60000
@@ -28,55 +28,9 @@ req.interceptors.request.use(function (config) {
28
28
  req.interceptors.response.use(
29
29
  // @ts-ignore - Temporarily ignore type mismatch if it occurs with custom ApiResponse
30
30
  function (response) {
31
- var res = response.data;
32
-
33
- // 业务码非成功状态的统一处理
34
- if (res.code !== 0 && res.code !== 200) {
35
- message.error(res.message || 'Error');
36
- if (res.code === 401) {
37
- Modal.confirm({
38
- title: '登录提醒',
39
- content: '您的登录已过期,请重新登录。',
40
- okText: '重新登录',
41
- cancelText: '取消',
42
- onOk: function onOk() {
43
- removeToken();
44
- window.location.href = '/login';
45
- }
46
- });
47
- }
48
- return Promise.reject(new Error(res.message || 'Error'));
49
- } else {
50
- // 成功则直接返回核心业务数据
51
- return res.data;
52
- }
31
+ return response.data;
53
32
  }, function (error) {
54
33
  var errorMessage = error.message;
55
- if (error.response) {
56
- switch (error.response.status) {
57
- case 400:
58
- errorMessage = '请求参数错误 (400)';
59
- break;
60
- case 401:
61
- errorMessage = '未授权,请重新登录 (401)';
62
- break;
63
- case 403:
64
- errorMessage = '拒绝访问 (403)';
65
- break;
66
- case 404:
67
- errorMessage = '请求地址不存在 (404)';
68
- break;
69
- case 500:
70
- errorMessage = '服务器内部错误 (500)';
71
- break;
72
- default:
73
- errorMessage = "\u8FDE\u63A5\u9519\u8BEF (".concat(error.response.status, ")!");
74
- }
75
- } else if (errorMessage.includes('timeout')) {
76
- errorMessage = '请求超时,请检查网络连接!';
77
- } else {
78
- errorMessage = '网络连接异常!';
79
- }
80
34
  message.error(errorMessage);
81
35
  return Promise.reject(error);
82
36
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@antv/dumi-theme-antv",
3
- "version": "0.8.0-beta.4",
3
+ "version": "0.8.0-beta.5",
4
4
  "description": "AntV website theme based on dumi2.",
5
5
  "keywords": [
6
6
  "dumi",