@myun/gimi-chat 0.2.5 → 0.2.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -14,6 +14,10 @@ var AskCard = function AskCard(_ref) {
14
14
  moduleInfo = _ref.moduleInfo,
15
15
  handleClickAskList = _ref.handleClickAskList,
16
16
  onAskCardCallback = _ref.onAskCardCallback;
17
+ var _React$useState = React.useState(false),
18
+ _React$useState2 = _slicedToArray(_React$useState, 2),
19
+ disabled = _React$useState2[0],
20
+ setDisabled = _React$useState2[1];
17
21
  var _React$useMemo = React.useMemo(function () {
18
22
  var _detailInfo$questionC;
19
23
  var detailInfo = moduleInfo.data.results.askShowInfo;
@@ -32,16 +36,20 @@ var AskCard = function AskCard(_ref) {
32
36
  optionsList: optionsList,
33
37
  questionContent: questionContent
34
38
  };
35
- }, [moduleInfo, handleClickAskList]),
39
+ }, [moduleInfo]),
36
40
  detailInfo = _React$useMemo.detailInfo,
37
41
  optionsList = _React$useMemo.optionsList,
38
42
  questionContent = _React$useMemo.questionContent;
43
+ React.useEffect(function () {
44
+ setDisabled(Boolean(detailInfo.answerType === 0 || item.selectValue));
45
+ }, [detailInfo.answerType, item.selectValue]);
46
+ var onAskItemClick = function onAskItemClick(moduleInfo, option, key, value) {
47
+ setDisabled(true);
48
+ handleClickAskList(moduleInfo, option, key, value);
49
+ };
39
50
  var optionRender = function optionRender(v) {
40
51
  return /*#__PURE__*/React.createElement("span", null, v.value ? v.value : v.key);
41
52
  };
42
- console.log('AskCard, itemSelectValue:', item.selectValue);
43
- console.log('AskCard, disabled:', detailInfo.answerType === 0 || item.selectValue);
44
- console.log('Askcard, style:', classNames(styles.askItem, detailInfo.answerType === 0 || item.selectValue ? styles.disablebox : ''));
45
53
  return /*#__PURE__*/React.createElement("div", {
46
54
  className: styles.askList
47
55
  }, /*#__PURE__*/React.createElement("div", {
@@ -56,10 +64,10 @@ var AskCard = function AskCard(_ref) {
56
64
  id: item.id
57
65
  })), detailInfo.answerType === 1 && (optionsList === null || optionsList === void 0 ? void 0 : optionsList.map(function (v) {
58
66
  return /*#__PURE__*/React.createElement("div", {
59
- className: classNames(styles.askItem, detailInfo.answerType === 0 || item.selectValue ? styles.disablebox : ''),
67
+ className: classNames(styles.askItem, disabled ? styles.disablebox : ''),
60
68
  key: v.key,
61
69
  onClick: function onClick() {
62
- return handleClickAskList(moduleInfo, 'click', v.key, v.value || v.key);
70
+ return onAskItemClick(moduleInfo, 'click', v.key, v.value || v.key);
63
71
  }
64
72
  }, optionRender(v));
65
73
  })), detailInfo.uploadFile && detailInfo.answerType === 0 && /*#__PURE__*/React.createElement("div", {
@@ -194,7 +194,6 @@ var useChatActions = function useChatActions(showCopyId, inputModelRef, handleSe
194
194
  selectValue: key
195
195
  });
196
196
  });
197
- console.log('Fun: handleClickAskList, newMessageList:', newMessageList);
198
197
  dispatch(setMessageList({
199
198
  messageList: newMessageList
200
199
  }));
@@ -1111,6 +1111,17 @@ var useCommonChatAPI = function useCommonChatAPI(containerRef, platform, stopTTS
1111
1111
  setHeaderValue('');
1112
1112
  }
1113
1113
  }, [resetKey]);
1114
+ var fillInputModel = React.useCallback(function (value, messageList) {
1115
+ if ((messageList === null || messageList === void 0 ? void 0 : messageList.length) > 0 && value && messageList[messageList.length - 1].moduleType === 'ask') {
1116
+ var targetChatItem = _toConsumableArray(messageList).reverse().find(function (item) {
1117
+ return item.role === 1;
1118
+ });
1119
+ if (!targetChatItem || !targetChatItem.moduleInfo) return;
1120
+ var moduleInfo = targetChatItem.moduleInfo;
1121
+ var _inputModel = _defineProperty({}, "".concat(moduleInfo.id, ".input"), value || '');
1122
+ inputModelRef.current = _inputModel;
1123
+ }
1124
+ }, []);
1114
1125
  var handleSend = React.useCallback( /*#__PURE__*/function () {
1115
1126
  var _ref17 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee16(val) {
1116
1127
  var agent,
@@ -1152,14 +1163,16 @@ var useCommonChatAPI = function useCommonChatAPI(containerRef, platform, stopTTS
1152
1163
  Toast.error('AI正在输出中,请稍后');
1153
1164
  return _context16.abrupt("return");
1154
1165
  case 12:
1166
+ // 设置inputModel
1167
+ fillInputModel(value, messageListRef.current);
1155
1168
  fileValidationMsg = fileValidation(fileListRef.current);
1156
1169
  if (!fileValidationMsg) {
1157
- _context16.next = 16;
1170
+ _context16.next = 17;
1158
1171
  break;
1159
1172
  }
1160
1173
  Toast.error(fileValidationMsg);
1161
1174
  return _context16.abrupt("return");
1162
- case 16:
1175
+ case 17:
1163
1176
  if (isPlaying) {
1164
1177
  // 点击发送按钮时,先停止播放
1165
1178
  stopTTSByText === null || stopTTSByText === void 0 || stopTTSByText();
@@ -1191,7 +1204,7 @@ var useCommonChatAPI = function useCommonChatAPI(containerRef, platform, stopTTS
1191
1204
  // 系统自动上传,直接开始会话,不更新列表
1192
1205
  startChat([].concat(_toConsumableArray(prevChatList), [userChat]), isSystemAuto, conversationId);
1193
1206
  }
1194
- case 23:
1207
+ case 24:
1195
1208
  case "end":
1196
1209
  return _context16.stop();
1197
1210
  }