Commit f44fe6eb authored by Joel's avatar Joel

Merge branch 'feat/universal-chat-fe' into deploy/dev

parents ba9041ea 49783327
...@@ -10,11 +10,15 @@ import type { RefObject } from 'react' ...@@ -10,11 +10,15 @@ import type { RefObject } from 'react'
import { useEffect, useRef, useState } from 'react' import { useEffect, useRef, useState } from 'react'
// import { copyToClipboard } from "../utils"; // import { copyToClipboard } from "../utils";
// https://txtfiddle.com/~hlshwya/extract-urls-from-text // https://txtfiddle.com/~hlshwya/extract-urls-from-text
const urlRegex = /\b((https?|ftp|file):\/\/|(www|ftp)\.)[-A-Z0-9+&@#\/%?=~_|$!:,.;]*[A-Z0-9+&@#\/%=~_|$]/ig // const urlRegex = /\b((https?|ftp|file):\/\/|(www|ftp)\.)[-A-Z0-9+&@#\/%?=~_|$!:,.;]*[A-Z0-9+&@#\/%=~_|$]/ig
function highlightURL(content: string) { // function highlightURL(content: string) {
return content.replace(urlRegex, '[$&]($&)') // return content.replace(urlRegex, (url) => {
} // // fix http:// in [] will be parsed to link agin
// const res = `[${url.replace('://', '://')}](${url})`
// return res
// })
// }
export function PreCode(props: { children: any }) { export function PreCode(props: { children: any }) {
const ref = useRef<HTMLPreElement>(null) const ref = useRef<HTMLPreElement>(null)
...@@ -88,7 +92,7 @@ export function Markdown(props: { content: string }) { ...@@ -88,7 +92,7 @@ export function Markdown(props: { content: string }) {
linkTarget={'_blank'} linkTarget={'_blank'}
> >
{/* Markdown detect has problem. */} {/* Markdown detect has problem. */}
{highlightURL(props.content)} {props.content}
</ReactMarkdown> </ReactMarkdown>
</div> </div>
) )
......
...@@ -677,7 +677,7 @@ const Main: FC<IMainProps> = () => { ...@@ -677,7 +677,7 @@ const Main: FC<IMainProps> = () => {
isResponsing={isResponsing} isResponsing={isResponsing}
canStopResponsing={!!messageTaskId} canStopResponsing={!!messageTaskId}
abortResponsing={async () => { abortResponsing={async () => {
await stopChatMessageResponding(APP_ID, messageTaskId) await stopChatMessageResponding(messageTaskId)
setHasStopResponded(true) setHasStopResponded(true)
setResponsingFalse() setResponsingFalse()
}} }}
......
...@@ -25,7 +25,7 @@ export const sendChatMessage = async (body: Record<string, any>, { onData, onCom ...@@ -25,7 +25,7 @@ export const sendChatMessage = async (body: Record<string, any>, { onData, onCom
}, { onData, onCompleted, onThought, onError, getAbortController }) }, { onData, onCompleted, onThought, onError, getAbortController })
} }
export const stopChatMessageResponding = async (appId: string, taskId: string) => { export const stopChatMessageResponding = async (taskId: string) => {
return post(getUrl(`messages/${taskId}/stop`)) return post(getUrl(`messages/${taskId}/stop`))
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment