@myun/gimi-chat 0.0.8 → 0.0.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (89) hide show
  1. package/dist/apis/useApi.d.ts +2 -0
  2. package/dist/apis/useApi.js +50 -2
  3. package/dist/components/ai-chat-dialogue/index.js +135 -181
  4. package/dist/components/ai-correction/index.js +25 -38
  5. package/dist/components/ai-loading/index.js +8 -12
  6. package/dist/components/answer-item/index.d.ts +3 -0
  7. package/dist/components/answer-item/index.js +126 -135
  8. package/dist/components/ask-card/index.js +33 -42
  9. package/dist/components/chat-input/extension/index.d.ts +2 -0
  10. package/dist/components/chat-input/extension/index.js +2 -0
  11. package/dist/components/chat-input/extension/keydown/index.d.ts +3 -0
  12. package/dist/components/chat-input/extension/keydown/index.js +37 -0
  13. package/dist/components/chat-input/extension/title-slot/Component.d.ts +4 -0
  14. package/dist/components/chat-input/extension/title-slot/Component.js +18 -0
  15. package/dist/components/chat-input/extension/title-slot/index.d.ts +3 -0
  16. package/dist/components/chat-input/extension/title-slot/index.js +47 -0
  17. package/dist/components/chat-input/extension/title-slot/index.less +22 -0
  18. package/dist/components/chat-input/index.d.ts +4 -0
  19. package/dist/components/chat-input/index.js +144 -145
  20. package/dist/components/chat-input/index.module.css +7 -0
  21. package/dist/components/chat-voice/VoiceCommunication.js +21 -23
  22. package/dist/components/chat-voice/VoiceRecord.js +21 -24
  23. package/dist/components/conversation-delete/index.js +8 -10
  24. package/dist/components/dots-loading/index.js +7 -10
  25. package/dist/components/empty/index.js +7 -12
  26. package/dist/components/excel-components/ExcelCard.js +3 -7
  27. package/dist/components/excel-components/ExcelExcuting.js +43 -60
  28. package/dist/components/excel-components/ExcelFailCard.js +10 -15
  29. package/dist/components/excel-components/ExcelSuccessCard.d.ts +5 -1
  30. package/dist/components/excel-components/ExcelSuccessCard.js +13 -6
  31. package/dist/components/file-card/fileCardSidebar.js +17 -23
  32. package/dist/components/file-card/index.d.ts +3 -0
  33. package/dist/components/file-card/index.js +59 -69
  34. package/dist/components/file-card/index.module.css +1 -1
  35. package/dist/components/file-preview/index.js +62 -37
  36. package/dist/components/file-preview/index.module.css +33 -0
  37. package/dist/components/file-upload/index.js +7 -10
  38. package/dist/components/file-upload/uploadV1.js +27 -33
  39. package/dist/components/gimi-sidebar/index.js +13 -20
  40. package/dist/components/header/index.js +11 -18
  41. package/dist/components/iconfont-com/index.js +33 -12
  42. package/dist/components/index.d.ts +1 -1
  43. package/dist/components/index.js +1 -1
  44. package/dist/components/knowledge-trace/KnowledgeIconComponent.js +22 -28
  45. package/dist/components/knowledge-trace/classList.js +28 -37
  46. package/dist/components/knowledge-trace/documentList.js +27 -36
  47. package/dist/components/knowledge-trace/index.js +21 -28
  48. package/dist/components/knowledge-trace/videoList.js +36 -46
  49. package/dist/components/lottie-img/index.js +8 -10
  50. package/dist/components/message-actions/CopyButton.d.ts +1 -1
  51. package/dist/components/message-actions/CopyButton.js +22 -25
  52. package/dist/components/message-actions/LikeButton.js +22 -25
  53. package/dist/components/message-actions/RegenerateButton.js +18 -21
  54. package/dist/components/message-actions/UnLikeButton.js +22 -25
  55. package/dist/components/message-actions/VoicePlay.js +22 -25
  56. package/dist/components/message-list/index.js +83 -87
  57. package/dist/components/no-microphone-root/index.js +29 -39
  58. package/dist/components/preset-agent-content/index.d.ts +1 -0
  59. package/dist/components/preset-agent-content/index.js +27 -20
  60. package/dist/components/quoted-content/index.d.ts +3 -0
  61. package/dist/components/quoted-content/index.js +271 -163
  62. package/dist/components/quoted-content/index.module.css +20 -0
  63. package/dist/components/reasoning-content/index.d.ts +3 -2
  64. package/dist/components/reasoning-content/index.js +50 -61
  65. package/dist/components/reference-content/index.js +62 -71
  66. package/dist/components/reference-content/index.module.css +1 -0
  67. package/dist/components/search-result/index.d.ts +7 -0
  68. package/dist/components/search-result/index.js +182 -0
  69. package/dist/components/search-result/index.module.css +235 -0
  70. package/dist/components/templates/CommonChat.js +75 -79
  71. package/dist/components/templates/GimiChatComponent.js +6 -13
  72. package/dist/components/templates/demo/demo.js +109 -103
  73. package/dist/components/upload-list/index.js +41 -56
  74. package/dist/components/voice-bars/index.js +19 -22
  75. package/dist/components/voice-check-dialog/index.js +17 -24
  76. package/dist/components/voice-recording/index.js +42 -57
  77. package/dist/components/work-flow-content/demo.js +1 -2
  78. package/dist/components/work-flow-content/index.js +8 -11
  79. package/dist/hooks/useChatActions.d.ts +1 -1
  80. package/dist/hooks/useChatActions.js +3 -1
  81. package/dist/hooks/useCommonChatAPI.d.ts +2 -1
  82. package/dist/hooks/useCommonChatAPI.js +10 -8
  83. package/dist/hooks/useQuoted.d.ts +12 -0
  84. package/dist/hooks/useQuoted.js +202 -0
  85. package/dist/utils/aes.d.ts +21 -0
  86. package/dist/utils/aes.js +61 -0
  87. package/dist/utils/chatInputUtil.d.ts +1 -1
  88. package/dist/utils/chatInputUtil.js +4 -3
  89. package/package.json +1 -1
@@ -1,5 +1,6 @@
1
1
  import React from 'react';
2
- declare const useCommonChatAPI: (containerRef: React.RefObject<HTMLDivElement>, businessType: string, stopTTSByText?: () => void, isPlaying?: boolean, agentId?: number) => {
2
+ import { IChatMessageItem } from "../interfaces/chatMessage";
3
+ declare const useCommonChatAPI: (containerRef: React.RefObject<HTMLDivElement>, businessType: string, stopTTSByText?: () => void, isPlaying?: boolean, agentId?: number, onConversationCreated?: ((conversationId: number) => void) | undefined, onSendEnd?: ((message: IChatMessageItem) => void) | undefined) => {
3
4
  headerValue: string;
4
5
  getHeaderValue: (conversationId: number) => Promise<void>;
5
6
  msgLoading: boolean;
@@ -32,7 +32,7 @@ import { useChatRecommend } from "./useChatRecommend";
32
32
  import { set, cloneDeep } from 'lodash';
33
33
  import { FileStatus } from "../interfaces/fileInterface";
34
34
  import useChatHistory from "./useChatHistory";
35
- var useCommonChatAPI = function useCommonChatAPI(containerRef, businessType, stopTTSByText, isPlaying, agentId) {
35
+ var useCommonChatAPI = function useCommonChatAPI(containerRef, businessType, stopTTSByText, isPlaying, agentId, onConversationCreated, onSendEnd) {
36
36
  var _useApi = useApi(),
37
37
  getMessageTitle = _useApi.getMessageTitle,
38
38
  stopStreamOut = _useApi.stopStreamOut,
@@ -173,7 +173,7 @@ var useCommonChatAPI = function useCommonChatAPI(containerRef, businessType, sto
173
173
 
174
174
  var startAICorrection = React.useCallback( /*#__PURE__*/function () {
175
175
  var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(answerId, questionId) {
176
- var res, _res$result, _res$result2, message, aiChat;
176
+ var res, _res$result, _res$result2, _message, aiChat;
177
177
  return _regeneratorRuntime().wrap(function _callee$(_context) {
178
178
  while (1) switch (_context.prev = _context.next) {
179
179
  case 0:
@@ -185,10 +185,10 @@ var useCommonChatAPI = function useCommonChatAPI(containerRef, businessType, sto
185
185
  case 2:
186
186
  res = _context.sent;
187
187
  if (res.status === 0) {
188
- message = createUserChat((_res$result = res.result) === null || _res$result === void 0 ? void 0 : _res$result.title, '');
188
+ _message = createUserChat((_res$result = res.result) === null || _res$result === void 0 ? void 0 : _res$result.title, '');
189
189
  aiChat = createAiChat({});
190
190
  dispatch(setMessageList({
191
- messageList: [message, aiChat]
191
+ messageList: [_message, aiChat]
192
192
  }));
193
193
  dispatch(setAgentDetail({
194
194
  agentDetail: {
@@ -607,6 +607,7 @@ var useCommonChatAPI = function useCommonChatAPI(containerRef, businessType, sto
607
607
  dispatch(setMessageList({
608
608
  messageList: newMessageList
609
609
  }));
610
+ onSendEnd === null || onSendEnd === void 0 || onSendEnd(newMessageList[newMessageList.length - 1]);
610
611
  if (type === 'ask' || type === 'skill') {
611
612
  scrollBottomForce();
612
613
  }
@@ -615,19 +616,19 @@ var useCommonChatAPI = function useCommonChatAPI(containerRef, businessType, sto
615
616
  // 获取最新的agent详情,防止redux异步更新
616
617
  agentDetail = agentInfo || agentObjRef.current;
617
618
  if (!((agentDetail === null || agentDetail === void 0 ? void 0 : agentDetail.isEnableRelated) === 1 && (type === 'end' || type === 'COMPLETED'))) {
618
- _context8.next = 10;
619
+ _context8.next = 11;
619
620
  break;
620
621
  }
621
- _context8.next = 10;
622
+ _context8.next = 11;
622
623
  return getRecommendList(newMessageList, lastId, statusRef.current);
623
- case 10:
624
+ case 11:
624
625
  if (valueRef.current) {
625
626
  setStatus(1);
626
627
  } else {
627
628
  setStatus(0);
628
629
  }
629
630
  setMsgLoading(false);
630
- case 12:
631
+ case 13:
631
632
  case "end":
632
633
  return _context8.stop();
633
634
  }
@@ -987,6 +988,7 @@ var useCommonChatAPI = function useCommonChatAPI(containerRef, businessType, sto
987
988
  dispatch(setConversationId({
988
989
  conversationId: res.result
989
990
  }));
991
+ onConversationCreated === null || onConversationCreated === void 0 || onConversationCreated(res.result);
990
992
  getHeaderValue(res.result);
991
993
  // eslint-disable-next-line @typescript-eslint/no-use-before-define
992
994
  handleSend(value, agentObjRef.current, false, res.result);
@@ -0,0 +1,12 @@
1
+ export declare type KonwledgeType = 'video' | 'course';
2
+ declare const useQuotedService: ({ type, searchValue, showmodel }: {
3
+ type: KonwledgeType;
4
+ searchValue: any;
5
+ showmodel: boolean;
6
+ }) => {
7
+ isLoading: boolean;
8
+ totalPage: number;
9
+ resource: any[];
10
+ getVideoResource: () => Promise<void>;
11
+ };
12
+ export default useQuotedService;
@@ -0,0 +1,202 @@
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 _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
4
+ function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
5
+ function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
6
+ function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
7
+ 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); } }
8
+ 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); }); }; }
9
+ 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; }
10
+ 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; }
11
+ 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; }
12
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
13
+ 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); }
14
+ function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
15
+ 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."); }
16
+ 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); }
17
+ 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; }
18
+ 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; } }
19
+ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
20
+ import useApi from "../apis/useApi";
21
+ import { useEffect, useRef, useState } from 'react';
22
+ var useQuotedService = function useQuotedService(_ref) {
23
+ var type = _ref.type,
24
+ searchValue = _ref.searchValue,
25
+ showmodel = _ref.showmodel;
26
+ var _useState = useState(false),
27
+ _useState2 = _slicedToArray(_useState, 2),
28
+ isLoading = _useState2[0],
29
+ setIsloading = _useState2[1];
30
+ var _useState3 = useState(0),
31
+ _useState4 = _slicedToArray(_useState3, 2),
32
+ totalPage = _useState4[0],
33
+ setTotalPage = _useState4[1]; // 总页数
34
+ var _useState5 = useState([]),
35
+ _useState6 = _slicedToArray(_useState5, 2),
36
+ resource = _useState6[0],
37
+ setResource = _useState6[1];
38
+ var latestTypeRef = useRef(null);
39
+ var _useApi = useApi(),
40
+ getReferenceVideoList = _useApi.getReferenceVideoList,
41
+ getReferenceCourseList = _useApi.getReferenceCourseList;
42
+
43
+ //处理数据 统一设置key
44
+ var handleData = function handleData(data) {
45
+ return data.map(function (item) {
46
+ return _objectSpread(_objectSpread({}, item), {}, {
47
+ id: item.productId || item.teachModelId,
48
+ name: item.productName || item.teachModelName
49
+ });
50
+ });
51
+ };
52
+ var getVideoResource = /*#__PURE__*/function () {
53
+ var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
54
+ var params, res, resData;
55
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
56
+ while (1) switch (_context.prev = _context.next) {
57
+ case 0:
58
+ _context.prev = 0;
59
+ params = {
60
+ pageIndex: searchValue.pageIndex || 1,
61
+ pageSize: searchValue.pageSize || 20,
62
+ where: {
63
+ teachModelName: searchValue.inputValue || ''
64
+ }
65
+ };
66
+ _context.next = 4;
67
+ return getReferenceVideoList(params);
68
+ case 4:
69
+ res = _context.sent;
70
+ if (!(res.status === 0 && res.result)) {
71
+ _context.next = 13;
72
+ break;
73
+ }
74
+ resData = handleData(res.result.data || []);
75
+ if (!(latestTypeRef.current !== 'video')) {
76
+ _context.next = 9;
77
+ break;
78
+ }
79
+ return _context.abrupt("return");
80
+ case 9:
81
+ if (res.result.page === 1 || res.result.page === 0) {
82
+ setResource(resData || []);
83
+ } else {
84
+ setResource([].concat(_toConsumableArray(resource), _toConsumableArray(resData)));
85
+ }
86
+ setTotalPage(res.result.totalPage);
87
+ _context.next = 14;
88
+ break;
89
+ case 13:
90
+ setResource([]);
91
+ case 14:
92
+ _context.next = 19;
93
+ break;
94
+ case 16:
95
+ _context.prev = 16;
96
+ _context.t0 = _context["catch"](0);
97
+ setResource([]);
98
+ case 19:
99
+ case "end":
100
+ return _context.stop();
101
+ }
102
+ }, _callee, null, [[0, 16]]);
103
+ }));
104
+ return function getVideoResource() {
105
+ return _ref2.apply(this, arguments);
106
+ };
107
+ }();
108
+ var getCourseResource = /*#__PURE__*/function () {
109
+ var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
110
+ var params, res, resData;
111
+ return _regeneratorRuntime().wrap(function _callee2$(_context2) {
112
+ while (1) switch (_context2.prev = _context2.next) {
113
+ case 0:
114
+ _context2.prev = 0;
115
+ params = {
116
+ pageIndex: searchValue.pageIndex || 1,
117
+ pageSize: searchValue.pageSize || 20,
118
+ where: {
119
+ productName: searchValue.inputValue || ''
120
+ }
121
+ };
122
+ _context2.next = 4;
123
+ return getReferenceCourseList(params);
124
+ case 4:
125
+ res = _context2.sent;
126
+ if (!(latestTypeRef.current !== 'course')) {
127
+ _context2.next = 7;
128
+ break;
129
+ }
130
+ return _context2.abrupt("return");
131
+ case 7:
132
+ if (res.status === 0 && res.result) {
133
+ resData = handleData(res.result.data || []);
134
+ if (res.result.page === 1 || res.result.page === 0) {
135
+ setResource(resData || []);
136
+ } else {
137
+ setResource([].concat(_toConsumableArray(resource), _toConsumableArray(resData)));
138
+ }
139
+ setTotalPage(res.result.totalPage);
140
+ } else {
141
+ setResource([]);
142
+ }
143
+ _context2.next = 13;
144
+ break;
145
+ case 10:
146
+ _context2.prev = 10;
147
+ _context2.t0 = _context2["catch"](0);
148
+ setResource([]);
149
+ case 13:
150
+ case "end":
151
+ return _context2.stop();
152
+ }
153
+ }, _callee2, null, [[0, 10]]);
154
+ }));
155
+ return function getCourseResource() {
156
+ return _ref3.apply(this, arguments);
157
+ };
158
+ }();
159
+ useEffect(function () {
160
+ latestTypeRef.current = type;
161
+ var getData = /*#__PURE__*/function () {
162
+ var _ref4 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {
163
+ var api;
164
+ return _regeneratorRuntime().wrap(function _callee3$(_context3) {
165
+ while (1) switch (_context3.prev = _context3.next) {
166
+ case 0:
167
+ setIsloading(true);
168
+ _context3.prev = 1;
169
+ api = type === 'video' ? getVideoResource : getCourseResource;
170
+ _context3.next = 5;
171
+ return api();
172
+ case 5:
173
+ setIsloading(false);
174
+ _context3.next = 11;
175
+ break;
176
+ case 8:
177
+ _context3.prev = 8;
178
+ _context3.t0 = _context3["catch"](1);
179
+ console.error(_context3.t0);
180
+ case 11:
181
+ case "end":
182
+ return _context3.stop();
183
+ }
184
+ }, _callee3, null, [[1, 8]]);
185
+ }));
186
+ return function getData() {
187
+ return _ref4.apply(this, arguments);
188
+ };
189
+ }();
190
+ if (showmodel) {
191
+ getData();
192
+ }
193
+ ;
194
+ }, [searchValue, type, showmodel]);
195
+ return {
196
+ isLoading: isLoading,
197
+ totalPage: totalPage,
198
+ resource: resource,
199
+ getVideoResource: getVideoResource
200
+ };
201
+ };
202
+ export default useQuotedService;
@@ -0,0 +1,21 @@
1
+ /**
2
+ * AES-ECB 加密(Hex 输出)
3
+ * @param {string} word - 待加密文本
4
+ * @param {string} secretKey - 密钥(默认值)
5
+ * @returns {string} Hex 格式密文(无特殊符号)
6
+ */
7
+ export declare function aesEncrypt(word: string, secretKey?: string): any;
8
+ /**
9
+ * AES-ECB 加密(Base64 输出)
10
+ * @param {string} word - 待加密文本
11
+ * @param {string} secretKey - 密钥(默认值)
12
+ * @returns {string} Base64 格式密文(无特殊符号)
13
+ */
14
+ export declare function aesBase64Encrypt(word: string, secretKey?: string): any;
15
+ /**
16
+ * AES-ECB 解密(Hex 输入)
17
+ * @param {string} hexCiphertext - Hex 格式密文
18
+ * @param {string} AES_KEY - 密钥(默认值)
19
+ * @returns {string|number} 解密后的原文(根据需求返回字符串或数字)
20
+ */
21
+ export declare function aesDecode(hexCiphertext: string, AES_KEY?: string): any;
@@ -0,0 +1,61 @@
1
+ import CryptoJS from 'crypto-js';
2
+
3
+ /**
4
+ * AES-ECB 加密(Hex 输出)
5
+ * @param {string} word - 待加密文本
6
+ * @param {string} secretKey - 密钥(默认值)
7
+ * @returns {string} Hex 格式密文(无特殊符号)
8
+ */
9
+ export function aesEncrypt(word) {
10
+ var secretKey = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'hNfpWalgRLQ7oGmY';
11
+ var key = CryptoJS.enc.Utf8.parse(secretKey);
12
+ var srcs = CryptoJS.enc.Utf8.parse(word);
13
+ var encrypted = CryptoJS.AES.encrypt(srcs, key, {
14
+ mode: CryptoJS.mode.ECB,
15
+ padding: CryptoJS.pad.Pkcs7
16
+ });
17
+ // 直接返回 Hex 格式(无需再次 toString)
18
+ return encrypted.ciphertext.toString(CryptoJS.enc.Hex);
19
+ }
20
+
21
+ /**
22
+ * AES-ECB 加密(Base64 输出)
23
+ * @param {string} word - 待加密文本
24
+ * @param {string} secretKey - 密钥(默认值)
25
+ * @returns {string} Base64 格式密文(无特殊符号)
26
+ */
27
+ export function aesBase64Encrypt(word) {
28
+ var secretKey = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'hNfpWalgRLQ7oGmY';
29
+ var key = CryptoJS.enc.Utf8.parse(secretKey);
30
+ var srcs = CryptoJS.enc.Utf8.parse(word);
31
+ var encrypted = CryptoJS.AES.encrypt(srcs, key, {
32
+ mode: CryptoJS.mode.ECB,
33
+ padding: CryptoJS.pad.Pkcs7
34
+ });
35
+ return encrypted.toString();
36
+ }
37
+
38
+ /**
39
+ * AES-ECB 解密(Hex 输入)
40
+ * @param {string} hexCiphertext - Hex 格式密文
41
+ * @param {string} AES_KEY - 密钥(默认值)
42
+ * @returns {string|number} 解密后的原文(根据需求返回字符串或数字)
43
+ */
44
+ export function aesDecode(hexCiphertext) {
45
+ var AES_KEY = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'hNfpWalgRLQ7oGmY';
46
+ var key = CryptoJS.enc.Utf8.parse(AES_KEY);
47
+
48
+ // 将 Hex 字符串转换为 CryptoJS 的 WordArray
49
+ var ciphertext = CryptoJS.enc.Hex.parse(hexCiphertext);
50
+ var cipherParams = CryptoJS.lib.CipherParams.create({
51
+ ciphertext: ciphertext
52
+ });
53
+ var decrypt = CryptoJS.AES.decrypt(cipherParams, key, {
54
+ mode: CryptoJS.mode.ECB,
55
+ padding: CryptoJS.pad.Pkcs7
56
+ });
57
+ var decryptedStr = CryptoJS.enc.Utf8.stringify(decrypt);
58
+
59
+ // 根据需求返回字符串或数字
60
+ return Number.isNaN(Number(decryptedStr)) ? decryptedStr : Number(decryptedStr);
61
+ }
@@ -15,5 +15,5 @@
15
15
  * // 我要生成一个<input-slot placeholder="[模板名称,如PVM模板]" />,用于<input-slot placeholder="[使用场景,如分析增长力]" />。数据如下:
16
16
  * // <input-slot placeholder="[直接输入或上传数据进行建模]" />
17
17
  */
18
- export declare const transformToInputSlots: (templateString: string) => string;
18
+ export declare const transformToInputSlots: (templateString: string, titleSlot: string) => string;
19
19
  export declare const debounce: <T extends (...args: any[]) => any>(func: T, wait: number) => (...args: Parameters<T>) => void;
@@ -15,7 +15,7 @@
15
15
  * // 我要生成一个<input-slot placeholder="[模板名称,如PVM模板]" />,用于<input-slot placeholder="[使用场景,如分析增长力]" />。数据如下:
16
16
  * // <input-slot placeholder="[直接输入或上传数据进行建模]" />
17
17
  */
18
- export var transformToInputSlots = function transformToInputSlots(templateString) {
18
+ export var transformToInputSlots = function transformToInputSlots(templateString, titleSlot) {
19
19
  // 1. 定义正则表达式
20
20
  var placeholderRegex = /\{\{(.*?)\}\}/g;
21
21
  // 2. 使用 replace 方法,并传入一个替换函数
@@ -23,10 +23,11 @@ export var transformToInputSlots = function transformToInputSlots(templateString
23
23
  var resultString = templateString.replace(placeholderRegex, function (match, capturedContent) {
24
24
  // match 参数是完整匹配的子串,例如: "{{模板名称,如PVM模板}}"
25
25
  // capturedContent 参数是捕获组(.*?)匹配到的内容,例如: "模板名称,如PVM模板"
26
- return "<input-slot placeholder=\"[".concat(capturedContent, "]\"></input-slot>");
26
+ return "<input-slot placeholder=\"[".concat(capturedContent, "]\"></input-slot> ");
27
27
  });
28
+ var titleSlotTemplate = titleSlot ? "<title-slot>".concat(titleSlot, "</title-slot>") : '';
28
29
  // 3. 返回最终结果
29
- return resultString;
30
+ return titleSlotTemplate + resultString;
30
31
  };
31
32
  export var debounce = function debounce(func, wait) {
32
33
  var timeoutId = null;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@myun/gimi-chat",
3
- "version": "0.0.8",
3
+ "version": "0.0.9",
4
4
  "description": "> TODO: description",
5
5
  "homepage": "",
6
6
  "license": "ISC",