This commit is contained in:
rex
2026-01-01 16:36:12 +08:00
parent a41bf16972
commit bec0684e70
9 changed files with 142 additions and 50 deletions

26
.gitignore vendored Normal file
View File

@@ -0,0 +1,26 @@
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
pnpm-debug.log*
lerna-debug.log*
node_modules
dist
dist-ssr
*.local
# Editor directories and files
.vscode/*
!.vscode/extensions.json
.idea
.DS_Store
*.suo
*.ntvs*
*.njsproj
*.sln
*.sw?
*.zip

1
.npmrc Normal file
View File

@@ -0,0 +1 @@
registry=https://registry.npmmirror.com

View File

@@ -18,7 +18,7 @@
"dependencies": {
"@heroui/react": "2.8.3",
"@heroui/theme": "2.4.21",
"@mujian/js-sdk": "0.0.6-beta.56",
"@mujian/js-sdk": "0.0.6-beta.59",
"@tailwindcss/vite": "4.1.12",
"ahooks": "3.9.5",
"axios": "1.11.0",

33
pnpm-lock.yaml generated
View File

@@ -15,8 +15,8 @@ importers:
specifier: 2.4.21
version: 2.4.21(tailwindcss@4.1.12)
'@mujian/js-sdk':
specifier: 0.0.6-beta.56
version: 0.0.6-beta.56(react-dom@19.1.1(react@19.1.1))(react@19.1.1)
specifier: 0.0.6-beta.59
version: 0.0.6-beta.59(react-dom@19.1.1(react@19.1.1))(react@19.1.1)
'@tailwindcss/vite':
specifier: 4.1.12
version: 4.1.12(vite@7.1.2(@types/node@22.13.9)(jiti@2.5.1)(lightningcss@1.30.1))
@@ -212,24 +212,28 @@ packages:
engines: {node: '>=14.21.3'}
cpu: [arm64]
os: [linux]
libc: [musl]
'@biomejs/cli-linux-arm64@2.3.10':
resolution: {integrity: sha512-hhPw2V3/EpHKsileVOFynuWiKRgFEV48cLe0eA+G2wO4SzlwEhLEB9LhlSrVeu2mtSn205W283LkX7Fh48CaxA==}
engines: {node: '>=14.21.3'}
cpu: [arm64]
os: [linux]
libc: [glibc]
'@biomejs/cli-linux-x64-musl@2.3.10':
resolution: {integrity: sha512-QTfHZQh62SDFdYc2nfmZFuTm5yYb4eO1zwfB+90YxUumRCR171tS1GoTX5OD0wrv4UsziMPmrePMtkTnNyYG3g==}
engines: {node: '>=14.21.3'}
cpu: [x64]
os: [linux]
libc: [musl]
'@biomejs/cli-linux-x64@2.3.10':
resolution: {integrity: sha512-wwAkWD1MR95u+J4LkWP74/vGz+tRrIQvr8kfMMJY8KOQ8+HMVleREOcPYsQX82S7uueco60L58Wc6M1I9WA9Dw==}
engines: {node: '>=14.21.3'}
cpu: [x64]
os: [linux]
libc: [glibc]
'@biomejs/cli-win32-arm64@2.3.10':
resolution: {integrity: sha512-o7lYc9n+CfRbHvkjPhm8s9FgbKdYZu5HCcGVMItLjz93EhgJ8AM44W+QckDqLA9MKDNFrR8nPbO4b73VC5kGGQ==}
@@ -1004,8 +1008,8 @@ packages:
engines: {node: '>=18.0.0'}
hasBin: true
'@mujian/js-sdk@0.0.6-beta.56':
resolution: {integrity: sha512-53EiPggGe51KEVQzCNgqVzDdGltiGD1b6WO4A5nZJ53Oc5oO4OrW6/BQ3x2spNuefDaXkDp2Rhv3O0eK9VH+Vw==}
'@mujian/js-sdk@0.0.6-beta.59':
resolution: {integrity: sha512-KI9+PhnqRpfbzp+D2ZTWTekKXvRacStLF1o4t8zkV+xw5prsMZNzMDZfLNqcNpuTI57zA1vDqYbE2xz9a0eUnw==}
peerDependencies:
react: ~19.1.1
react-dom: ~19.1.1
@@ -1528,56 +1532,67 @@ packages:
resolution: {integrity: sha512-OVSQgEZDVLnTbMq5NBs6xkmz3AADByCWI4RdKSFNlDsYXdFtlxS59J+w+LippJe8KcmeSSM3ba+GlsM9+WwC1w==}
cpu: [arm]
os: [linux]
libc: [glibc]
'@rollup/rollup-linux-arm-musleabihf@4.49.0':
resolution: {integrity: sha512-ZnfSFA7fDUHNa4P3VwAcfaBLakCbYaxCk0jUnS3dTou9P95kwoOLAMlT3WmEJDBCSrOEFFV0Y1HXiwfLYJuLlA==}
cpu: [arm]
os: [linux]
libc: [musl]
'@rollup/rollup-linux-arm64-gnu@4.49.0':
resolution: {integrity: sha512-Z81u+gfrobVK2iV7GqZCBfEB1y6+I61AH466lNK+xy1jfqFLiQ9Qv716WUM5fxFrYxwC7ziVdZRU9qvGHkYIJg==}
cpu: [arm64]
os: [linux]
libc: [glibc]
'@rollup/rollup-linux-arm64-musl@4.49.0':
resolution: {integrity: sha512-zoAwS0KCXSnTp9NH/h9aamBAIve0DXeYpll85shf9NJ0URjSTzzS+Z9evmolN+ICfD3v8skKUPyk2PO0uGdFqg==}
cpu: [arm64]
os: [linux]
libc: [musl]
'@rollup/rollup-linux-loongarch64-gnu@4.49.0':
resolution: {integrity: sha512-2QyUyQQ1ZtwZGiq0nvODL+vLJBtciItC3/5cYN8ncDQcv5avrt2MbKt1XU/vFAJlLta5KujqyHdYtdag4YEjYQ==}
cpu: [loong64]
os: [linux]
libc: [glibc]
'@rollup/rollup-linux-ppc64-gnu@4.49.0':
resolution: {integrity: sha512-k9aEmOWt+mrMuD3skjVJSSxHckJp+SiFzFG+v8JLXbc/xi9hv2icSkR3U7uQzqy+/QbbYY7iNB9eDTwrELo14g==}
cpu: [ppc64]
os: [linux]
libc: [glibc]
'@rollup/rollup-linux-riscv64-gnu@4.49.0':
resolution: {integrity: sha512-rDKRFFIWJ/zJn6uk2IdYLc09Z7zkE5IFIOWqpuU0o6ZpHcdniAyWkwSUWE/Z25N/wNDmFHHMzin84qW7Wzkjsw==}
cpu: [riscv64]
os: [linux]
libc: [glibc]
'@rollup/rollup-linux-riscv64-musl@4.49.0':
resolution: {integrity: sha512-FkkhIY/hYFVnOzz1WeV3S9Bd1h0hda/gRqvZCMpHWDHdiIHn6pqsY3b5eSbvGccWHMQ1uUzgZTKS4oGpykf8Tw==}
cpu: [riscv64]
os: [linux]
libc: [musl]
'@rollup/rollup-linux-s390x-gnu@4.49.0':
resolution: {integrity: sha512-gRf5c+A7QiOG3UwLyOOtyJMD31JJhMjBvpfhAitPAoqZFcOeK3Kc1Veg1z/trmt+2P6F/biT02fU19GGTS529A==}
cpu: [s390x]
os: [linux]
libc: [glibc]
'@rollup/rollup-linux-x64-gnu@4.49.0':
resolution: {integrity: sha512-BR7+blScdLW1h/2hB/2oXM+dhTmpW3rQt1DeSiCP9mc2NMMkqVgjIN3DDsNpKmezffGC9R8XKVOLmBkRUcK/sA==}
cpu: [x64]
os: [linux]
libc: [glibc]
'@rollup/rollup-linux-x64-musl@4.49.0':
resolution: {integrity: sha512-hDMOAe+6nX3V5ei1I7Au3wcr9h3ktKzDvF2ne5ovX8RZiAHEtX1A5SNNk4zt1Qt77CmnbqT+upb/umzoPMWiPg==}
cpu: [x64]
os: [linux]
libc: [musl]
'@rollup/rollup-win32-arm64-msvc@4.49.0':
resolution: {integrity: sha512-wkNRzfiIGaElC9kXUT+HLx17z7D0jl+9tGYRKwd8r7cUqTL7GYAvgUY++U2hK6Ar7z5Z6IRRoWC8kQxpmM7TDA==}
@@ -1635,24 +1650,28 @@ packages:
engines: {node: '>= 10'}
cpu: [arm64]
os: [linux]
libc: [glibc]
'@tailwindcss/oxide-linux-arm64-musl@4.1.12':
resolution: {integrity: sha512-V8pAM3s8gsrXcCv6kCHSuwyb/gPsd863iT+v1PGXC4fSL/OJqsKhfK//v8P+w9ThKIoqNbEnsZqNy+WDnwQqCA==}
engines: {node: '>= 10'}
cpu: [arm64]
os: [linux]
libc: [musl]
'@tailwindcss/oxide-linux-x64-gnu@4.1.12':
resolution: {integrity: sha512-xYfqYLjvm2UQ3TZggTGrwxjYaLB62b1Wiysw/YE3Yqbh86sOMoTn0feF98PonP7LtjsWOWcXEbGqDL7zv0uW8Q==}
engines: {node: '>= 10'}
cpu: [x64]
os: [linux]
libc: [glibc]
'@tailwindcss/oxide-linux-x64-musl@4.1.12':
resolution: {integrity: sha512-ha0pHPamN+fWZY7GCzz5rKunlv9L5R8kdh+YNvP5awe3LtuXb5nRi/H27GeL2U+TdhDOptU7T6Is7mdwh5Ar3A==}
engines: {node: '>= 10'}
cpu: [x64]
os: [linux]
libc: [musl]
'@tailwindcss/oxide-wasm32-wasi@4.1.12':
resolution: {integrity: sha512-4tSyu3dW+ktzdEpuk6g49KdEangu3eCYoqPhWNsZgUhyegEda3M9rG0/j1GV/JjVVsj+lG7jWAyrTlLzd/WEBg==}
@@ -2204,24 +2223,28 @@ packages:
engines: {node: '>= 12.0.0'}
cpu: [arm64]
os: [linux]
libc: [glibc]
lightningcss-linux-arm64-musl@1.30.1:
resolution: {integrity: sha512-jmUQVx4331m6LIX+0wUhBbmMX7TCfjF5FoOH6SD1CttzuYlGNVpA7QnrmLxrsub43ClTINfGSYyHe2HWeLl5CQ==}
engines: {node: '>= 12.0.0'}
cpu: [arm64]
os: [linux]
libc: [musl]
lightningcss-linux-x64-gnu@1.30.1:
resolution: {integrity: sha512-piWx3z4wN8J8z3+O5kO74+yr6ze/dKmPnI7vLqfSqI8bccaTGY5xiSGVIJBDd5K5BHlvVLpUB3S2YCfelyJ1bw==}
engines: {node: '>= 12.0.0'}
cpu: [x64]
os: [linux]
libc: [glibc]
lightningcss-linux-x64-musl@1.30.1:
resolution: {integrity: sha512-rRomAK7eIkL+tHY0YPxbc5Dra2gXlI63HL+v1Pdi1a3sC+tJTcFrHX+E86sulgAXeI7rSzDYhPSeHHjqFhqfeQ==}
engines: {node: '>= 12.0.0'}
cpu: [x64]
os: [linux]
libc: [musl]
lightningcss-win32-arm64-msvc@1.30.1:
resolution: {integrity: sha512-mSL4rqPi4iXq5YVqzSsJgMVFENoa4nGTT/GjO2c0Yl9OuQfPsIfncvLrEW6RbbB24WtZ3xP/2CCmI3tNkNV4oA==}
@@ -4211,7 +4234,7 @@ snapshots:
transitivePeerDependencies:
- supports-color
'@mujian/js-sdk@0.0.6-beta.56(react-dom@19.1.1(react@19.1.1))(react@19.1.1)':
'@mujian/js-sdk@0.0.6-beta.59(react-dom@19.1.1(react@19.1.1))(react@19.1.1)':
dependencies:
'@adobe/css-tools': 4.4.4
ahooks: 3.9.5(react-dom@19.1.1(react@19.1.1))(react@19.1.1)

View File

@@ -7,12 +7,14 @@ import {
DropdownMenu,
DropdownTrigger,
} from '@heroui/react';
import { type Message as BaseMessage } from '@mujian/js-sdk/react';
import { ChevronLeftIcon, ChevronRightIcon, Ellipsis } from 'lucide-react';
import React from 'react';
import { mjChatCls } from '@/utils/cls';
import { useMessageActions } from './useMessageActions';
export type LastMessageActionsProps = {
message: BaseMessage;
isUser: boolean;
isLastMsg: boolean;
isFirstMsg: boolean;
@@ -30,6 +32,7 @@ export type LastMessageActionsProps = {
};
export const MessageActions = ({
// message,
isUser,
isLastMsg,
isFirstMsg,
@@ -94,10 +97,12 @@ export const MessageActions = ({
</DropdownTrigger>
<DropdownMenu
items={dropdownItems}
className={mjChatCls(
['msg-actions-dropdown-menu'],
'text-[initial]',
)}
className={mjChatCls(['msg-actions-dropdown-menu'], 'text-white')}
// disabledKeys={
// message.id.startsWith('not_saved')
// ? ['edit', 'regenerate', 'continue']
// : []
// }
>
{(item) => (
<DropdownItem

View File

@@ -26,6 +26,7 @@ export type MessageBubbleProps = {
};
export const MessageBubble = ({
// message,
isUser,
isEditing,
editedMessage,
@@ -68,7 +69,7 @@ export const MessageBubble = ({
<DropdownTrigger>
<div
className={mjChatCls(
['msg-edit-trigger'],
['msg-edit-trigger', 'msg-content'],
cn(
'h-full rounded-xl dark:prose-invert text-blue-100 p-4 bg-black/50',
{
@@ -83,10 +84,12 @@ export const MessageBubble = ({
</DropdownTrigger>
<DropdownMenu
items={dropdownItems}
className={mjChatCls(
['msg-edit-dropdown-menu'],
'text-[initial]',
)}
className={mjChatCls(['msg-edit-dropdown-menu'], 'text-white')}
// disabledKeys={
// message.id.startsWith('not_saved')
// ? ['edit', 'regenerate', 'continue']
// : []
// }
>
{(item) => (
<DropdownItem
@@ -107,9 +110,9 @@ export const MessageBubble = ({
</DropdownMenu>
</Dropdown>
) : (
// <div className={mjChatCls(['msg-content-wrapper'], "py-4")}>
<MdRenderer content={currentMessage} />
// </div>
<div className={mjChatCls(['msg-content'], 'py-4')}>
<MdRenderer content={currentMessage} />
</div>
)
) : (
<MessageEditArea

View File

@@ -122,7 +122,7 @@ export const MessageItem = React.memo((props: MessageItemProps) => {
addToast({
color: 'success',
description: '复制成功',
timeout: 1500,
timeout: 2000,
});
} catch (error) {
console.error(error);
@@ -216,6 +216,7 @@ export const MessageItem = React.memo((props: MessageItemProps) => {
}}
/>
<MessageActions
message={message}
isUser={isUser}
isLastMsg={Boolean(isLastMsg)}
isFirstMsg={Boolean(isFirstMsg)}

View File

@@ -81,35 +81,37 @@ export const QuickReply = (props: QuickReplyProps) => {
}}
onMouseDown={onmousedown}
>
{quickReplies.map((qr, index) => (
<Chip
key={index}
className={mjChatCls(
['input-quickreply-chip', `input-quickreply-chip-${index + 1}`],
'bg-white/15 text-default shrink-0 cursor-pointer',
)}
classNames={{
base: mjChatCls([
'input-quickreply-chip-base',
`input-quickreply-chip-${index + 1}-base`,
]),
content: mjChatCls([
'input-quickreply-chip-content',
`input-quickreply-chip-${index + 1}-content`,
]),
}}
radius="full"
variant="light"
onClick={() => {
const isClick = Date.now() - lastDragTime.current > 50;
if (isClick && qr.message) {
onSend(qr.message);
}
}}
>
{qr.label}
</Chip>
))}
{quickReplies
.filter((qr) => !qr.isHidden)
.map((qr, index) => (
<Chip
key={index}
className={mjChatCls(
['input-quickreply-chip', `input-quickreply-chip-${index + 1}`],
'bg-white/15 text-default shrink-0 cursor-pointer',
)}
classNames={{
base: mjChatCls([
'input-quickreply-chip-base',
`input-quickreply-chip-${index + 1}-base`,
]),
content: mjChatCls([
'input-quickreply-chip-content',
`input-quickreply-chip-${index + 1}-content`,
]),
}}
radius="full"
variant="light"
onClick={() => {
const isClick = Date.now() - lastDragTime.current > 50;
if (isClick && qr.message) {
onSend(qr.message);
}
}}
>
{qr.label}
</Chip>
))}
</ScrollShadow>
);
};

View File

@@ -170,9 +170,24 @@ export const Chat = () => {
? error.message
: '哎呀,发生了未知错误,刷新页面再试试吧~');
const toastStyle = `
.toast-region {
margin-top: ${paddingTop}px;
}`;
return (
<div className={mjChatCls(['container'], 'size-full relative')}>
<ToastProvider placement="top-center" toastProps={{ color: 'danger' }} />
<style> {toastStyle} </style>
<ToastProvider
placement="top-center"
toastProps={{ color: 'danger' }}
disableAnimation={true}
regionProps={{
classNames: {
base: 'toast-region',
},
}}
/>
<div
className={mjChatCls(
['container-background'],
@@ -195,7 +210,10 @@ export const Chat = () => {
>
<ScrollShadow
hideScrollBar
className={mjChatCls(['container-content-scroll-shadow'], 'h-full pb-2')}
className={mjChatCls(
['container-content-scroll-shadow'],
'h-full pb-2',
)}
size={20}
>
<MessageList
@@ -210,6 +228,19 @@ export const Chat = () => {
onRegenerate={regenerate}
onNeedMore={loadMoreMessage}
/>
{status !== 'streaming' &&
messages.some((m) => m.id.startsWith('not_saved')) && (
<Alert
hideIcon
title="最近一次保存消息失败,请刷新页面后重试"
className="opacity-30"
classNames={{
mainWrapper: 'min-h-4 ml-0 text-white',
}}
color="default"
variant="bordered"
/>
)}
{errorMessage && (
<Alert
hideIcon