From bec0684e70ec6009808e9e3d810cac54a62efcce Mon Sep 17 00:00:00 2001 From: rex Date: Thu, 1 Jan 2026 16:36:12 +0800 Subject: [PATCH] 0.4.0 --- .gitignore | 26 ++++++++ .npmrc | 1 + package.json | 2 +- pnpm-lock.yaml | 33 ++++++++-- .../MessageItem/components/MessageActions.tsx | 13 ++-- .../MessageItem/components/MessageBubble.tsx | 19 +++--- src/pages/chat/MessageItem/index.tsx | 3 +- src/pages/chat/QuickReply.tsx | 60 ++++++++++--------- src/pages/chat/index.tsx | 35 ++++++++++- 9 files changed, 142 insertions(+), 50 deletions(-) create mode 100644 .gitignore create mode 100644 .npmrc diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..a63274b --- /dev/null +++ b/.gitignore @@ -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 \ No newline at end of file diff --git a/.npmrc b/.npmrc new file mode 100644 index 0000000..7f082f2 --- /dev/null +++ b/.npmrc @@ -0,0 +1 @@ +registry=https://registry.npmmirror.com \ No newline at end of file diff --git a/package.json b/package.json index 552ebb5..c076e57 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index dfcb0b1..02330d9 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -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) diff --git a/src/pages/chat/MessageItem/components/MessageActions.tsx b/src/pages/chat/MessageItem/components/MessageActions.tsx index 6541673..acfcac7 100644 --- a/src/pages/chat/MessageItem/components/MessageActions.tsx +++ b/src/pages/chat/MessageItem/components/MessageActions.tsx @@ -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 = ({ {(item) => (
{(item) => ( ) : ( - //
- - //
+
+ +
) ) : ( { addToast({ color: 'success', description: '复制成功', - timeout: 1500, + timeout: 2000, }); } catch (error) { console.error(error); @@ -216,6 +216,7 @@ export const MessageItem = React.memo((props: MessageItemProps) => { }} /> { }} onMouseDown={onmousedown} > - {quickReplies.map((qr, index) => ( - { - const isClick = Date.now() - lastDragTime.current > 50; - if (isClick && qr.message) { - onSend(qr.message); - } - }} - > - {qr.label} - - ))} + {quickReplies + .filter((qr) => !qr.isHidden) + .map((qr, index) => ( + { + const isClick = Date.now() - lastDragTime.current > 50; + if (isClick && qr.message) { + onSend(qr.message); + } + }} + > + {qr.label} + + ))} ); }; diff --git a/src/pages/chat/index.tsx b/src/pages/chat/index.tsx index b5c6cd0..fd990a4 100644 --- a/src/pages/chat/index.tsx +++ b/src/pages/chat/index.tsx @@ -170,9 +170,24 @@ export const Chat = () => { ? error.message : '哎呀,发生了未知错误,刷新页面再试试吧~'); + const toastStyle = ` + .toast-region { + margin-top: ${paddingTop}px; + }`; + return (
- + +
{ > { onRegenerate={regenerate} onNeedMore={loadMoreMessage} /> + {status !== 'streaming' && + messages.some((m) => m.id.startsWith('not_saved')) && ( + + )} {errorMessage && (