@antv/dumi-theme-antv 0.8.0-beta.2 → 0.8.0-beta.21

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.
Files changed (88) hide show
  1. package/dist/builtins/Playground/index.module.less +0 -1
  2. package/dist/components/AI/HomeDialog/AntVBanner/index.module.less +2 -2
  3. package/dist/components/AI/HomeDialog/ModeSelector/ModeSelectorDropdown.js +42 -0
  4. package/dist/components/AI/HomeDialog/ModeSelector/index.module.less +39 -22
  5. package/dist/components/AI/HomeDialog/PromptTextarea/ChooseLib/index.js +12 -4
  6. package/dist/components/AI/HomeDialog/PromptTextarea/ChooseLib/index.module.less +0 -1
  7. package/dist/components/AI/HomeDialog/PromptTextarea/DatasourceCard/index.module.less +3 -3
  8. package/dist/components/AI/HomeDialog/PromptTextarea/index.js +38 -36
  9. package/dist/components/AI/HomeDialog/PromptTextarea/index.module.less +8 -8
  10. package/dist/components/AI/HomeDialog/RecommendCase/Card.js +14 -11
  11. package/dist/components/AI/HomeDialog/RecommendCase/card.module.less +3 -3
  12. package/dist/components/AI/HomeDialog/RecommendCase/index.js +73 -24
  13. package/dist/components/AI/HomeDialog/RecommendCase/index.module.less +4 -2
  14. package/dist/components/AI/HomeDialog/RecommendCase/recommend.json +41 -17
  15. package/dist/components/AI/HomeDialog/index.js +21 -33
  16. package/dist/components/AI/constant.js +4 -2
  17. package/dist/components/Login/Captcha/index.js +185 -0
  18. package/dist/components/Login/Captcha/index.less +91 -0
  19. package/dist/components/Login/CheckCode/index.js +244 -0
  20. package/dist/components/Login/CheckCode/index.less +137 -0
  21. package/dist/components/Login/CountDownButton/index.js +109 -0
  22. package/dist/components/Login/CountDownButton/index.less +8 -0
  23. package/dist/components/Login/LoginForm.js +239 -0
  24. package/dist/components/Login/LoginForm.less +409 -0
  25. package/dist/components/Login/index.js +24 -0
  26. package/dist/components/Login/openAuthWindow.js +54 -0
  27. package/dist/components/Login/types.js +5 -0
  28. package/dist/components/Login/utils.js +47 -0
  29. package/dist/hooks/useProducts.js +22 -1
  30. package/dist/layouts/DocLayout.js +2 -1
  31. package/dist/layouts/GlobalLayout/index.js +11 -4
  32. package/dist/locales/en.json +43 -2
  33. package/dist/locales/zh.json +43 -2
  34. package/dist/model/AIChat.js +93 -6
  35. package/dist/model/auth.js +147 -0
  36. package/dist/pages/AIPlayground/components/ConversationsMenu/index.js +15 -7
  37. package/dist/pages/AIPlayground/components/ConversationsMenu/index.module.less +2 -0
  38. package/dist/pages/AIPlayground/components/MarkdownComponent/MarkdownCodeBlock.js +26 -17
  39. package/dist/pages/AIPlayground/components/MarkdownComponent/MarkdownCodeBlock.module.less +1 -2
  40. package/dist/pages/AIPlayground/components/MarkdownComponent/index.js +7 -4
  41. package/dist/pages/AIPlayground/components/MsgBox/index.js +266 -149
  42. package/dist/pages/AIPlayground/components/MsgBox/index.module.less +3 -2
  43. package/dist/pages/AIPlayground/components/MsgBox/useAutoScroll.js +46 -0
  44. package/dist/pages/AIPlayground/components/SessionLayout/index.js +41 -12
  45. package/dist/pages/AIPlayground/components/SessionLayout/index.module.less +4 -4
  46. package/dist/pages/AIPlayground/components/TaskBox/generateCode.js +129 -8
  47. package/dist/pages/AIPlayground/components/TaskBox/index.js +92 -55
  48. package/dist/pages/AIPlayground/components/TaskBox/index.module.less +1 -0
  49. package/dist/pages/AIPlayground/index.js +4 -1
  50. package/dist/pages/AIPlayground/index.module.less +5 -0
  51. package/dist/pages/Examples/components/Accouncement/index.module.less +1 -1
  52. package/dist/pages/Examples/index.module.less +11 -11
  53. package/dist/pages/Index/components/Cases/index.module.less +8 -8
  54. package/dist/pages/Index/components/Companies/index.module.less +4 -3
  55. package/dist/pages/Index/components/Features/FeatureCard.module.less +4 -5
  56. package/dist/pages/Index/components/Features/index.module.less +5 -5
  57. package/dist/pages/Index/components/_.less +9 -9
  58. package/dist/slots/Banner/Notification.module.less +8 -8
  59. package/dist/slots/Banner/index.module.less +10 -9
  60. package/dist/slots/CodeEditor/Toolbar.js +7 -25
  61. package/dist/slots/CodeEditor/index.js +34 -12
  62. package/dist/slots/CodeEditor/index.module.less +3 -1
  63. package/dist/slots/CodeEditor/utils.js +2 -1
  64. package/dist/slots/CodePreview/index.module.less +0 -3
  65. package/dist/slots/CodeRunner/index.js +23 -11
  66. package/dist/slots/ContentTable/index.module.less +2 -1
  67. package/dist/slots/Detail/News.module.less +9 -9
  68. package/dist/slots/Detail/index.js +2 -1
  69. package/dist/slots/Detail/index.module.less +11 -14
  70. package/dist/slots/ExampleSider/index.module.less +3 -4
  71. package/dist/slots/Footer/index.module.less +2 -2
  72. package/dist/slots/Header/Products/Product.module.less +2 -2
  73. package/dist/slots/Header/Search/SearchResult.js +20 -8
  74. package/dist/slots/Header/Search/SearchResult.module.less +1 -0
  75. package/dist/slots/Header/index.js +51 -25
  76. package/dist/slots/Header/index.module.less +13 -5
  77. package/dist/slots/LiveExample/index.module.less +1 -1
  78. package/dist/slots/Loading/index.module.less +30 -28
  79. package/dist/slots/ManualContent/index.module.less +14 -17
  80. package/dist/slots/_.less +9 -9
  81. package/dist/static/user.svg +3 -0
  82. package/dist/typings.d.ts +6 -0
  83. package/dist/utils/analytics.js +16 -0
  84. package/dist/utils/env.js +63 -0
  85. package/dist/utils/index.js +7 -0
  86. package/dist/utils/request.js +42 -0
  87. package/package.json +9 -5
  88. package/dist/static/SearchAiIcon.svg +0 -14
@@ -0,0 +1,244 @@
1
+ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
2
+ function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = "function" == typeof Symbol ? Symbol : {}, a = i.iterator || "@@iterator", c = i.asyncIterator || "@@asyncIterator", u = i.toStringTag || "@@toStringTag"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, ""); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, "_invoke", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: "normal", arg: t.call(e, r) }; } catch (t) { return { type: "throw", arg: t }; } } e.wrap = wrap; var h = "suspendedStart", l = "suspendedYield", f = "executing", s = "completed", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { ["next", "throw", "return"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if ("throw" !== c.type) { var u = c.arg, h = u.value; return h && "object" == _typeof(h) && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) { invoke("next", t, i, a); }, function (t) { invoke("throw", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke("throw", t, i, a); }); } a(c.arg); } var r; o(this, "_invoke", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error("Generator is already running"); if (o === s) { if ("throw" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else "return" === n.method && n.abrupt("return", n.arg); o = f; var p = tryCatch(e, r, n); if ("normal" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } "throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, "throw" === n && e.iterator.return && (r.method = "return", r.arg = t, maybeInvokeDelegate(e, r), "throw" === r.method) || "return" !== n && (r.method = "throw", r.arg = new TypeError("The iterator does not provide a '" + n + "' method")), y; var i = tryCatch(o, e.iterator, r.arg); if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, "return" !== r.method && (r.method = "next", r.arg = t), r.delegate = null, y) : a : (r.method = "throw", r.arg = new TypeError("iterator result is not an object"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = "normal", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: "root" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || "" === e) { var r = e[a]; if (r) return r.call(e); if ("function" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + " is not iterable"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) { var e = "function" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () { return this; }), define(g, "toString", function () { return "[object Generator]"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) "t" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if ("throw" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if ("root" === i.tryLoc) return handle("end"); if (i.tryLoc <= this.prev) { var c = n.call(i, "catchLoc"), u = n.call(i, "finallyLoc"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error("try statement without catch or finally"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) { var i = o; break; } } i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if ("throw" === t.type) throw t.arg; return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, catch: function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if ("throw" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, "next" === this.method && (this.arg = t), y; } }, e; }
3
+ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
4
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
5
+ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
6
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
7
+ 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); }
8
+ function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
9
+ function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
10
+ function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
11
+ function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
12
+ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
13
+ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
14
+ function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
15
+ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
16
+ import { useRef, useState } from 'react';
17
+ import { Form, Input, message } from 'antd';
18
+ import CountDownButton from "../CountDownButton";
19
+ import cls from 'classnames';
20
+ import Captcha from "../Captcha";
21
+ import { useIntl } from 'dumi';
22
+ import "./index.less";
23
+ import React from 'react';
24
+ import { sendValidationCode } from "../../../model/auth";
25
+ function CheckCode(_ref) {
26
+ var en = _ref.en,
27
+ form = _ref.form,
28
+ ncName = _ref.ncName,
29
+ scene = _ref.scene,
30
+ _ref$targetFieldName = _ref.targetFieldName,
31
+ targetFieldName = _ref$targetFieldName === void 0 ? 'login' : _ref$targetFieldName,
32
+ _ref$validateFailedMs = _ref.validateFailedMsg,
33
+ validateFailedMsg = _ref$validateFailedMs === void 0 ? 'Please enter your mobile number' : _ref$validateFailedMs,
34
+ handleSendCode = _ref.handleSendCode,
35
+ _ref$onSendCodeClick = _ref.onSendCodeClick,
36
+ onSendCodeClick = _ref$onSendCodeClick === void 0 ? function () {} : _ref$onSendCodeClick;
37
+ var _useIntl = useIntl(),
38
+ formatMessage = _useIntl.formatMessage,
39
+ locale = _useIntl.locale;
40
+ var _useState = useState(false),
41
+ _useState2 = _slicedToArray(_useState, 2),
42
+ sending = _useState2[0],
43
+ setSending = _useState2[1];
44
+ var captchaRef = useRef(null);
45
+ var inputRef = useRef(null);
46
+ var countDownRef = useRef(null);
47
+ var countDownSendText = formatMessage({
48
+ id: 'login.checkcode.get'
49
+ });
50
+ function handleResetCountDown() {
51
+ var _countDownRef$current;
52
+ (_countDownRef$current = countDownRef.current) === null || _countDownRef$current === void 0 || _countDownRef$current.resetCountDown();
53
+ }
54
+ function handleResetCaptcha() {
55
+ var _captchaRef$current;
56
+ (_captchaRef$current = captchaRef.current) === null || _captchaRef$current === void 0 || _captchaRef$current.resetCaptcha();
57
+ }
58
+ function onCountDownEnd() {
59
+ setSending(false);
60
+ handleResetCaptcha();
61
+ }
62
+ function sendCode(_x, _x2) {
63
+ return _sendCode.apply(this, arguments);
64
+ }
65
+ function _sendCode() {
66
+ _sendCode = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(target, captchaValues) {
67
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
68
+ while (1) switch (_context.prev = _context.next) {
69
+ case 0:
70
+ _context.prev = 0;
71
+ if (!handleSendCode) {
72
+ _context.next = 6;
73
+ break;
74
+ }
75
+ _context.next = 4;
76
+ return handleSendCode(target, captchaValues);
77
+ case 4:
78
+ _context.next = 8;
79
+ break;
80
+ case 6:
81
+ _context.next = 8;
82
+ return sendValidationCode(_objectSpread(_objectSpread({
83
+ target: target
84
+ }, captchaValues), {}, {
85
+ captcha: captchaValues.captcha ? 1 : 0
86
+ }));
87
+ case 8:
88
+ message.success(formatMessage({
89
+ id: 'login.checkcode.send.success'
90
+ }));
91
+ _context.next = 15;
92
+ break;
93
+ case 11:
94
+ _context.prev = 11;
95
+ _context.t0 = _context["catch"](0);
96
+ console.error(_context.t0);
97
+ handleResetCaptcha();
98
+ case 15:
99
+ case "end":
100
+ return _context.stop();
101
+ }
102
+ }, _callee, null, [[0, 11]]);
103
+ }));
104
+ return _sendCode.apply(this, arguments);
105
+ }
106
+ function onSendClick(_x3) {
107
+ return _onSendClick.apply(this, arguments);
108
+ }
109
+ function _onSendClick() {
110
+ _onSendClick = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(callback) {
111
+ var captchaValues, values, _target, params;
112
+ return _regeneratorRuntime().wrap(function _callee2$(_context2) {
113
+ while (1) switch (_context2.prev = _context2.next) {
114
+ case 0:
115
+ if (!(!captchaRef.current || sending)) {
116
+ _context2.next = 2;
117
+ break;
118
+ }
119
+ return _context2.abrupt("return");
120
+ case 2:
121
+ captchaValues = captchaRef.current.getCaptchaValues();
122
+ if (captchaValues.captcha) {
123
+ _context2.next = 9;
124
+ break;
125
+ }
126
+ handleResetCountDown();
127
+ message.error(formatMessage({
128
+ id: 'login.checkcode.error.incomplete'
129
+ }));
130
+ form.setFields([{
131
+ name: 'captcha',
132
+ errors: [formatMessage({
133
+ id: 'login.checkcode.error.incomplete'
134
+ })]
135
+ }]);
136
+ // 尝试解决滑块显示完成,但提示没有完成的问题
137
+ handleResetCaptcha();
138
+ return _context2.abrupt("return");
139
+ case 9:
140
+ _context2.prev = 9;
141
+ _context2.next = 12;
142
+ return form.validateFields([targetFieldName]);
143
+ case 12:
144
+ values = _context2.sent;
145
+ _target = values[targetFieldName];
146
+ if (_target) {
147
+ _context2.next = 17;
148
+ break;
149
+ }
150
+ form.setFields([{
151
+ name: targetFieldName,
152
+ errors: [validateFailedMsg]
153
+ }]);
154
+ return _context2.abrupt("return");
155
+ case 17:
156
+ params = _objectSpread(_objectSpread({}, captchaValues), {}, {
157
+ lang: locale
158
+ });
159
+ _context2.next = 20;
160
+ return sendCode(_target, params);
161
+ case 20:
162
+ callback === null || callback === void 0 || callback();
163
+ onSendCodeClick === null || onSendCodeClick === void 0 || onSendCodeClick();
164
+ _context2.next = 28;
165
+ break;
166
+ case 24:
167
+ _context2.prev = 24;
168
+ _context2.t0 = _context2["catch"](9);
169
+ handleResetCaptcha();
170
+ form.setFields([{
171
+ name: targetFieldName,
172
+ errors: [validateFailedMsg]
173
+ }]);
174
+ case 28:
175
+ case "end":
176
+ return _context2.stop();
177
+ }
178
+ }, _callee2, null, [[9, 24]]);
179
+ }));
180
+ return _onSendClick.apply(this, arguments);
181
+ }
182
+ var getFieldError = form.getFieldError;
183
+ function renderHint() {
184
+ // 重置密码时显示短信发送情况提醒
185
+ if (sending) {
186
+ return /*#__PURE__*/React.createElement("div", {
187
+ className: "mobile-code-hint"
188
+ }, /*#__PURE__*/React.createElement("span", null, formatMessage({
189
+ id: 'login.checkcode.sent'
190
+ })));
191
+ }
192
+ }
193
+ return /*#__PURE__*/React.createElement("div", {
194
+ className: cls('mobile-code', 'captcha-check-code')
195
+ }, /*#__PURE__*/React.createElement(Captcha, {
196
+ form: form,
197
+ scene: scene,
198
+ ncName: ncName,
199
+ ref: captchaRef,
200
+ en: en
201
+ }), /*#__PURE__*/React.createElement(Form.Item, {
202
+ className: "mobile-code-showtip",
203
+ help: getFieldError('code') ? getFieldError('code') : renderHint()
204
+ }, /*#__PURE__*/React.createElement("div", {
205
+ className: "mobile-code-main"
206
+ }, /*#__PURE__*/React.createElement("div", {
207
+ className: "mobile-code-field"
208
+ }, /*#__PURE__*/React.createElement(Form.Item, {
209
+ name: "code",
210
+ validateTrigger: ['onSubmit', 'onBlur'],
211
+ rules: [{
212
+ required: true,
213
+ message: formatMessage({
214
+ id: 'login.checkcode.required'
215
+ })
216
+ }, {
217
+ pattern: /^\d{6}$/,
218
+ message: formatMessage({
219
+ id: 'login.checkcode.invalid'
220
+ })
221
+ }]
222
+ }, /*#__PURE__*/React.createElement(Input, {
223
+ type: "text",
224
+ autoComplete: "off",
225
+ ref: inputRef,
226
+ placeholder: formatMessage({
227
+ id: 'login.checkcode.placeholder'
228
+ }),
229
+ maxLength: 6
230
+ }))), /*#__PURE__*/React.createElement("div", {
231
+ className: "mobile-code-getBtn"
232
+ }, /*#__PURE__*/React.createElement(CountDownButton, {
233
+ en: en,
234
+ onSendClick: onSendClick,
235
+ ref: countDownRef,
236
+ buttonProps: {
237
+ ghost: true,
238
+ htmlType: 'button'
239
+ },
240
+ sendText: countDownSendText,
241
+ onCountDownEnd: onCountDownEnd
242
+ })))));
243
+ }
244
+ export default CheckCode;
@@ -0,0 +1,137 @@
1
+ @primary-color: #873bf4;
2
+ @yuque-color-text-caption: #8c8c8c;
3
+ @yuque-color-text-body: #595959;
4
+ @yuque-grey-5: #bfbfbf;
5
+ @yuque-color-bg-tertiary: #fafafa;
6
+ @color-1: #bfbfbf;
7
+ @color: #873bf4;
8
+ @yuque-color-bg-primary-hover-light: #f5f5f5;
9
+ @yuque-color-text-link: #873bf4;
10
+
11
+ .form-pro .mobile-code .ant-legacy-form-explain {
12
+ margin-top: 8px;
13
+ text-align: left;
14
+ padding-right: 120px;
15
+ margin-bottom: 18px;
16
+ }
17
+
18
+ .verify-modal .mobile-code .ant-legacy-form-explain {
19
+ margin-top: 8px;
20
+ text-align: left;
21
+ padding-right: 120px;
22
+ }
23
+
24
+ .captcha-check-code {
25
+ margin-bottom: 22px;
26
+ }
27
+
28
+ .ant-modal-body .mobile-code .ant-legacy-form-explain {
29
+ margin-top: 8px;
30
+ text-align: left;
31
+ padding-right: 120px;
32
+ }
33
+
34
+ .verify-modal .mobile-code .mobile-code-showtip {
35
+ margin-bottom: 8px;
36
+ }
37
+
38
+ .lark-form .mobile-code .ant-legacy-form-item {
39
+ margin-bottom: 8px;
40
+ }
41
+
42
+ .mobile-code {
43
+ position: relative;
44
+ min-height: 72px;
45
+
46
+ .mobile-code-hint {
47
+ color: @yuque-color-text-caption;
48
+ }
49
+
50
+ &-pwd-link {
51
+ height: 22px;
52
+ padding-top: 1px;
53
+ text-align: left;
54
+ color: @yuque-color-text-body;
55
+ cursor: pointer;
56
+ line-height: 1.5;
57
+ margin-right: 200px;
58
+ }
59
+
60
+ &-showtip {
61
+ margin-bottom: 4px;
62
+ }
63
+
64
+ &-main {
65
+ height: 40px;
66
+ display: flex;
67
+
68
+ .mobile-code-field {
69
+ flex: 1;
70
+ margin-bottom: 8px;
71
+ }
72
+
73
+ .mobile-code-getBtn {
74
+ position: relative;
75
+ min-width: 118px;
76
+ margin-left: 14px;
77
+
78
+ .countdown-btn {
79
+ .code-send-button {
80
+ border: 1px solid @yuque-grey-5;
81
+ font-size: 14px;
82
+ letter-spacing: 0;
83
+ width: 100%;
84
+ height: 100%;
85
+
86
+ &:disabled {
87
+ background-color: @yuque-color-bg-tertiary;
88
+
89
+ .code-send-text {
90
+ .code-send-text {
91
+ color: @color-1;
92
+ }
93
+ }
94
+ }
95
+ }
96
+ }
97
+
98
+ .code-send-text {
99
+ color: @color;
100
+ font-weight: 500;
101
+ }
102
+ }
103
+ }
104
+
105
+ .mobile-code-pwd-link {
106
+ line-height: 10px;
107
+ }
108
+
109
+ &-tip {
110
+ color: @yuque-color-text-caption;
111
+ text-align: left;
112
+ }
113
+
114
+ &-swith-channel {
115
+ cursor: pointer;
116
+ color: @yuque-color-text-body;
117
+ padding-top: 8px;
118
+ padding-left: 12px;
119
+ line-height: 1.7;
120
+
121
+ &-highlight {
122
+ cursor: pointer;
123
+ color: @yuque-color-text-link;
124
+ }
125
+ }
126
+
127
+ input {
128
+ appearance: none;
129
+ }
130
+
131
+ .captcha .nc-container .nc_wrapper .nc_scale,
132
+ .captcha .nc-container #nc_1_wrapper .nc_scale {
133
+ height: 40px;
134
+ background: @yuque-color-bg-primary-hover-light;
135
+ width: auto;
136
+ }
137
+ }
@@ -0,0 +1,109 @@
1
+ function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
2
+ function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
3
+ function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
4
+ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
5
+ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
6
+ function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
7
+ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
8
+ import React, { useState, useEffect, useCallback, useRef, forwardRef, useImperativeHandle } from 'react';
9
+ import { Button } from 'antd';
10
+ import { useIntl } from 'dumi';
11
+ import "./index.less";
12
+ var DEFAULT_COUNTING_TIME = 60;
13
+ var CountDownButton = /*#__PURE__*/forwardRef(function (_ref, ref) {
14
+ var initialCounting = _ref.counting,
15
+ en = _ref.en,
16
+ sendText = _ref.sendText,
17
+ onSendClick = _ref.onSendClick,
18
+ buttonProps = _ref.buttonProps,
19
+ onCountDownEnd = _ref.onCountDownEnd;
20
+ var _useIntl = useIntl(),
21
+ formatMessage = _useIntl.formatMessage;
22
+ var _useState = useState(!!initialCounting),
23
+ _useState2 = _slicedToArray(_useState, 2),
24
+ counting = _useState2[0],
25
+ setCounting = _useState2[1];
26
+ var _useState3 = useState(DEFAULT_COUNTING_TIME),
27
+ _useState4 = _slicedToArray(_useState3, 2),
28
+ countingTime = _useState4[0],
29
+ setCountingTime = _useState4[1];
30
+ var _useState5 = useState(false),
31
+ _useState6 = _slicedToArray(_useState5, 2),
32
+ hasSend = _useState6[0],
33
+ setHasSend = _useState6[1];
34
+ var countTimer = useRef(null);
35
+ var reset = useCallback(function () {
36
+ setCounting(false);
37
+ setCountingTime(DEFAULT_COUNTING_TIME);
38
+ if (countTimer.current) {
39
+ clearInterval(countTimer.current);
40
+ countTimer.current = null;
41
+ }
42
+ }, [countTimer]);
43
+ var doCounting = useCallback(function () {
44
+ setCountingTime(DEFAULT_COUNTING_TIME);
45
+ setCounting(true);
46
+ countTimer.current = setInterval(function () {
47
+ setCountingTime(function (prevTime) {
48
+ if (prevTime === 1) {
49
+ reset();
50
+ onCountDownEnd === null || onCountDownEnd === void 0 || onCountDownEnd();
51
+ return DEFAULT_COUNTING_TIME;
52
+ }
53
+ return prevTime - 1;
54
+ });
55
+ }, 1000);
56
+ }, [reset]);
57
+ useEffect(function () {
58
+ if (initialCounting) {
59
+ doCounting();
60
+ }
61
+ return function () {
62
+ if (countTimer.current) {
63
+ clearInterval(countTimer.current);
64
+ }
65
+ };
66
+ }, [initialCounting]);
67
+ var handleSendClick = function handleSendClick() {
68
+ if (onSendClick) {
69
+ onSendClick(function () {
70
+ doCounting();
71
+ setHasSend(true);
72
+ });
73
+ }
74
+ };
75
+ var renderSendCodeTxt = function renderSendCodeTxt() {
76
+ if (counting) {
77
+ return /*#__PURE__*/React.createElement("span", {
78
+ className: "code-count-text"
79
+ }, formatMessage({
80
+ id: 'login.countdown.resend'
81
+ }, {
82
+ time: countingTime
83
+ }));
84
+ }
85
+ if (hasSend) {
86
+ return formatMessage({
87
+ id: 'login.countdown.resend.simple'
88
+ });
89
+ }
90
+ return sendText;
91
+ };
92
+ useImperativeHandle(ref, function () {
93
+ return {
94
+ resetCountDown: function resetCountDown() {
95
+ reset();
96
+ }
97
+ };
98
+ });
99
+ return /*#__PURE__*/React.createElement("span", {
100
+ className: "countdown-btn"
101
+ }, /*#__PURE__*/React.createElement(Button, _extends({
102
+ onClick: handleSendClick,
103
+ className: "code-send-button",
104
+ disabled: counting
105
+ }, buttonProps), /*#__PURE__*/React.createElement("span", {
106
+ className: "code-send-text"
107
+ }, renderSendCodeTxt())));
108
+ });
109
+ export default CountDownButton;
@@ -0,0 +1,8 @@
1
+ @primary-color: #873bf4;
2
+ @yuque-color-text-disable: #bfbfbf;
3
+
4
+ .countdown-btn {
5
+ .code-count-text {
6
+ color: @yuque-color-text-disable;
7
+ }
8
+ }