Commit 2bbb2763 by 杨明

建议截取

1 parent 5699dbc5
......@@ -182,11 +182,12 @@
text-components-button-secondary-accent-text-disabled;
}
.arrow-icon {
display: inline-block;
margin-left: 10px;
width: 8px;
height: 8px;
border-top: 1.5px solid #969BA3;
border-right: 1.5px solid #969BA3;
transform: rotate(45deg);
height: 8px;
border-top: 1.5px solid #969BA3;
border-right: 1.5px solid #969BA3;
transform: rotate(45deg);
}
}
/*
* @Author: yangming@didihu.com.cn yangming@didihu.com.cn
* @Date: 2025-04-22 09:29:17
* @LastEditors: yangming@didihu.com.cn yangming@didihu.com.cn
* @LastEditTime: 2025-05-02 12:03:38
* @FilePath: \glsk-ai-assistant\app\components\base\button\index.tsx
* @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
*/
import type { CSSProperties } from "react";
import React from "react";
import { type VariantProps, cva } from "class-variance-authority";
......@@ -73,7 +81,7 @@ const Button = React.forwardRef<HTMLButtonElement, ButtonProps>(
)}
/>
)}
{showArrow &&<span className="arrow-icon"></span>}
{showArrow && <span className="arrow-icon"></span>}
</button>
);
}
......
/*
* @Author: yangming@didihu.com.cn yangming@didihu.com.cn
* @Date: 2025-04-29 16:57:03
* @LastEditors: yangming@didihu.com.cn yangming@didihu.com.cn
* @LastEditTime: 2025-05-02 16:42:48
* @FilePath: \glsk-ai-assistant\app\components\base\button\next-button.tsx
* @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
*/
import type { CSSProperties } from "react";
import React from "react";
import { type VariantProps, cva } from "class-variance-authority";
import Spinner from "../spinner";
import classNames from "@/utils/classnames";
const buttonVariants = cva("btn disabled:btn-disabled", {
variants: {
variant: {
primary: "btn-primary",
warning: "btn-warning",
secondary: "btn-secondary",
"secondary-accent": "btn-secondary-accent",
ghost: "btn-ghost",
"ghost-accent": "btn-ghost-accent",
tertiary: "btn-tertiary",
},
size: {
small: "btn-small",
medium: "btn-medium",
large: "btn-large",
},
},
defaultVariants: {
variant: "secondary",
size: "medium",
},
});
export type ButtonProps = {
text: string;
onClick?: () => void;
};
const Button = ({ text, onClick }: ButtonProps) => {
return (
<div onClick={onClick} className="flex items-center bg-[#f5f8fc] cursor-pointer justify-between p-2 mr-1 mt-3 max-w-full shrink-0 last:mr-0">
<div className="text-[#383A3D]">{text}</div>
<div className="w-6">
<div className="arrow-icon"></div>
</div>
</div>
);
};
export default Button;
export { Button, buttonVariants };
......@@ -2,7 +2,7 @@
* @Author: yangming@didihu.com.cn yangming@didihu.com.cn
* @Date: 2025-04-22 09:29:17
* @LastEditors: yangming@didihu.com.cn yangming@didihu.com.cn
* @LastEditTime: 2025-04-22 19:06:23
* @LastEditTime: 2025-05-02 16:11:41
* @FilePath: \glsk-ai-assistant\app\components\base\chat\chat-with-history\header\index.tsx
* @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
*/
......@@ -13,7 +13,7 @@ type Props = {
};
const Header = ({ avatar, title }: Props) => {
return (
<div className="flex items-center justify-between h-12 px-8">
<div className="flex items-center justify-between h-12 px-[2vw]">
<div className=" flex items-center">
<img
src={AVATAR_AI_URL}
......
......@@ -11,6 +11,7 @@ import Loading from "@/app/components/base/loading";
import useBreakpoints, { MediaType } from "@/hooks/use-breakpoints";
import { checkOrSetAccessToken } from "@/app/components/share/utils";
import AppUnavailable from "@/app/components/base/app-unavailable";
import Confirm from "@/app/components/base/confirm";
import cn from "@/utils/classnames";
import {
AVATAR_USER_URL,
......@@ -22,6 +23,7 @@ type ChatWithHistoryProps = {
className?: string;
};
type urlProps = {
domain?: string;
no_header?: string; // 是否显示头部
avatar?: string; // 头像
business_type?: string; // 业务类型
......@@ -46,7 +48,19 @@ newInputs.queryType = "0";
const avatar: string = newInputs.avatar!;
delete newInputs.avatar;
delete newInputs.domain;
const ChatWithHistory: FC<ChatWithHistoryProps> = ({ className }) => {
const [showConfirm, setShowConfirm] = useState(false);
const handleReset = () => {
handleNewConversation();
setShowConfirm(false);
setTimeout(() => {
handleNewConversationInputsChange(newInputs);
}, 300);
};
const handleCancelConfirm = () => {
setShowConfirm(false);
};
const {
appInfoError,
appData,
......@@ -55,13 +69,10 @@ const ChatWithHistory: FC<ChatWithHistoryProps> = ({ className }) => {
chatShouldReloadKey,
isMobile,
handleNewConversation,
handleNewConversationInputsChange
handleNewConversationInputsChange,
} = useChatWithHistoryContext();
const doClear = useCallback(() => {
handleNewConversation();
setTimeout(() => {
handleNewConversationInputsChange(newInputs);
}, 300);
setShowConfirm(true);
}, [handleNewConversation]);
if (appInfoLoading) {
return <Loading type="app" />;
......@@ -70,7 +81,6 @@ const ChatWithHistory: FC<ChatWithHistoryProps> = ({ className }) => {
if (appInfoError) {
return <AppUnavailable />;
}
return (
<div
className={cn(
......@@ -79,6 +89,15 @@ const ChatWithHistory: FC<ChatWithHistoryProps> = ({ className }) => {
className
)}
>
{showConfirm && (
<Confirm
title="重置对话"
content="您确定要重置此对话吗?"
isShow
onCancel={handleCancelConfirm}
onConfirm={handleReset}
/>
)}
<div
className={cn("relative grow", isMobile && "h-[calc(100%_-_56px)] p-0")}
>
......@@ -157,7 +176,7 @@ const ChatWithHistoryWrap: FC<ChatWithHistoryWrapProps> = ({
} = useChatWithHistory(installedAppInfo);
useEffect(() => {
//新建对话
handleNewConversation()
handleNewConversation();
setTimeout(() => {
handleNewConversationInputsChange(newInputs);
}, 1000);
......
......@@ -2,46 +2,38 @@
* @Author: yangming@didihu.com.cn yangming@didihu.com.cn
* @Date: 2025-04-22 09:29:17
* @LastEditors: yangming@didihu.com.cn yangming@didihu.com.cn
* @LastEditTime: 2025-04-28 10:10:51
* @LastEditTime: 2025-05-02 16:46:21
* @FilePath: \glsk-ai-assistant\app\components\base\chat\chat\answer\suggested-questions.tsx
* @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
*/
import type { FC } from "react";
import { memo } from "react";
import { memo, useMemo } from "react";
import type { ChatItem } from "../../types";
import { useChatContext } from "../context";
import Button from "@/app/components/base/button";
import useBreakpoints, { MediaType } from "@/hooks/use-breakpoints";
import Button from "@/app/components/base/button/next-button";
import { AUTO_INPUT } from "@/app/components/base/chat/constants";
type SuggestedQuestionsProps = {
item: ChatItem;
};
const SuggestedQuestions: FC<SuggestedQuestionsProps> = ({ item }) => {
const { onSend } = useChatContext();
const media = useBreakpoints();
const isMobile = media === MediaType.mobile;
const klassName = `mr-1 mt-3 ${
isMobile ? "block overflow-hidden text-ellipsis" : ""
} max-w-full shrink-0 last:mr-0`;
const { suggestedQuestions } = item;
if (!suggestedQuestions?.length) return null;
const questionList = useMemo(() => {
const suggestedList = suggestedQuestions
.filter((q) => !!q && q.trim())
.sort(() => Math.random() - 0.5);
return suggestedList.slice(0, 3);
}, [suggestedQuestions]);
return (
<div className="flex flex-wrap">
{suggestedQuestions
.filter((q) => !!q && q.trim())
.map((question, index) => (
<Button
key={index}
variant="secondary-accent"
showArrow={true}
className={klassName}
onClick={() => onSend?.({ message: question, type: AUTO_INPUT })}
>
{question}
</Button>
))}
<div className="w-[fit-content]">
{questionList.map((question, index) => (
<Button
key={index}
text={question}
onClick={() => onSend?.({ message: question, type: AUTO_INPUT })}
></Button>
))}
</div>
);
};
......
......@@ -246,7 +246,16 @@ const Link = ({ node, ...props }: any) => {
return <abbr className="cursor-pointer underline !decoration-primary-700 decoration-dashed" onClick={() => onSend?.(hidden_text)} title={node.children[0]?.value}>{node.children[0]?.value}</abbr>
}
else {
return <a {...props} target="_blank" className="cursor-pointer underline !decoration-primary-700 decoration-dashed">{node.children[0] ? node.children[0]?.value : 'Download'}</a>
const href = node.properties?.href?.toString() || ''
const isImage = /\.(jpe?g|png|gif|webp|bmp|svg)(\?.*)?$/i.test(href)
return (
<>
{isImage ? (
Img({ src: href })
) : (<a {...props} target="_blank" className="cursor-pointer underline !decoration-primary-700 decoration-dashed">{node.children[0] ? node.children[0]?.value : 'Download'}</a>)}
</>
)
//return <a {...props} target="_blank" className="cursor-pointer underline !decoration-primary-700 decoration-dashed">{node.children[0] ? node.children[0]?.value : 'Download'}</a>
}
}
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!