| | |
| | | }, []); |
| | | return stepList; |
| | | }; |
| | | |
| | | export const formatShowTimeYear = (str: string) => { |
| | | const date = moment(str); |
| | | const now = moment(); |
| | | const diffDays = now.diff(date, 'days'); |
| | | |
| | | if (diffDays === 0) { |
| | | return `今天 ${date.format('HH:mm:ss')}`; |
| | | } else if (diffDays === 1) { |
| | | return `昨天 ${date.format('HH:mm:ss')}`; |
| | | } else if (diffDays === 2) { |
| | | return `前天 ${date.format('HH:mm:ss')}`; |
| | | } |
| | | |
| | | if (date.year() === now.year()) { |
| | | return date.format('MM月DD日 HH:mm:ss'); |
| | | } else { |
| | | return date.format('YYYY年MM月DD日 HH:mm:ss'); |
| | | } |
| | | }; |
| | | /** |
| | | * 滚动加载数据 |
| | | * @returns |
| | |
| | | history_id: historyId, |
| | | }); |
| | | }; |
| | | const formatShowTimeYear = computed(() => { |
| | | return (str) => { |
| | | return moment(str).format('MM月DD日 HH:mm:ss'); |
| | | }; |
| | | }); |
| | | |
| | | |
| | | |
| | | /** |
| | | * 更新加载索引 |
| | |
| | | |
| | | const mapUser = userItemIdMap.get(item.answer?.history_id); |
| | | |
| | | const answerTime = formatShowTimeYear.value(mapUser?.create_time); |
| | | const answerTime = formatShowTimeYear(mapUser?.create_time); |
| | | tmpMessageList.splice( |
| | | insertIndex, |
| | | 0, |
| | |
| | | role: RoleEnum.assistant, |
| | | content: parseAnswerContent(item?.answer), |
| | | state: item.answer_state, |
| | | sectionAId: mapUser?.section_a_id, |
| | | createTime: answerTime, |
| | | isStopMsg: false, |
| | | stepGroup: (item?.answer?.reports ?? []).map((item) => ({ |
| | |
| | | messageList.value.unshift(...tmpMessageList); |
| | | }; |
| | | |
| | | /** |
| | | * 加载分享数据 |
| | | */ |
| | | const loadShareData = async () => { |
| | | const res = await getShareChatJsonByPost({ |
| | | share_id: router.currentRoute.value.query.id as string, |
| | | }); |
| | | |
| | | const msgValue = res?.values; |
| | | if (!msgValue) { |
| | | messageList.value = []; |
| | | return; |
| | | } |
| | | const userMsg: ChatMessage = { |
| | | historyId: msgValue.history_id, |
| | | role: RoleEnum.user, |
| | | content: { |
| | | type: AnswerType.Text, |
| | | values: msgValue.question, |
| | | }, |
| | | isChecked: false, |
| | | }; |
| | | |
| | | const assistantMsg: ChatMessage = { |
| | | historyId: msgValue.history_id, |
| | | role: RoleEnum.assistant, |
| | | content: parseAnswerContent(msgValue), |
| | | stepGroup: (msgValue?.reports ?? []).map((item) => ({ |
| | | value: convertProcessToStep(item?.exec_process), |
| | | isShow: false, |
| | | })), |
| | | isStopMsg: false, |
| | | |
| | | conclusion: msgValue.conclusion ?? [], |
| | | isChecked: false, |
| | | }; |
| | | messageList.value = [userMsg, assistantMsg]; |
| | | }; |
| | | |
| | | |
| | | /** |
| | | * 加载滚动范围数据 |
| | | */ |
| | | const loadRangeData = async (lastEnd = nextUserMsgEndIndex) => { |
| | | if (isSharePage.value) { |
| | | await loadShareData(); |
| | | return; |
| | | } |
| | | |
| | | const res = await QueryHistoryDetail({ |
| | | history_group_id: unref(historyGroupId), |
| | | last_end: lastEnd, |