@topthink/chat 1.3.28 → 1.3.29

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/es/index.js +1 -1
  2. package/package.json +2 -2
package/es/index.js CHANGED
@@ -128,7 +128,7 @@ import{jsx as e,jsxs as t,Fragment as r}from"react/jsx-runtime";import{styled as
128
128
  &:hover {
129
129
  background-color: var(--bs-secondary-bg-subtle);
130
130
  }
131
- `;function Te(){const{request:n,reset:i,conversationId:o}=Re(),[s,a]=z(!1),[l,c]=z(""),[d,u]=z(""),m=h(e=>{u(e)},500);return q(()=>{m(l)},[l]),t(r,{children:[e(De,{tooltip:"历史记录",placement:"top",onClick:()=>a(!0),children:e("i",{className:"bi bi-clock-history"})}),e(p,{show:s,onHide:()=>{a(!1)},placement:"end",headerAs:He,header:t(r,{children:[e("span",{children:"聊天历史记录"}),e(Je,{children:e(J,{type:"search",placeholder:"搜索聊天记录...",value:l,onChange:e=>c(e.target.value),autoFocus:!0})})]}),bodyAs:Oe,children:s&&e(_e,{children:e(Ue,{useWindow:!1,source:e=>n({url:"/conversation",params:{...e,...d&&{keyword:d}}}),render:({data:s,loading:l,setData:c})=>s.length||l?t(r,{children:[s.map((s,l)=>{const d=o===s.id;return t(D,{children:[l>0&&e("hr",{className:"mx-2 my-2"}),t(Be,{children:[d&&e(_,{bg:"secondary",children:"当前"}),e("span",{className:"overflow-hidden text-truncate flex-fill",onClick:()=>{i(s),a(!1)},children:s.title||"未命名对话"}),t(H,{align:"end",children:[e(H.Toggle,{size:"sm",className:"no-caret",as:De,children:e("i",{className:"bi bi-three-dots-vertical"})}),t(H.Menu,{children:[e(g,{buttonProps:{as:H.Item},text:t(r,{children:[e("i",{className:"bi bi-pencil me-2"}),"重命名"]}),modalProps:{header:"编辑对话名称"},schema:{type:"object",properties:{title:{type:"string"}}},uiSchema:{title:{"ui:label":!1,"ui:autofocus":!0}},formData:{title:s.title},onRequest:e=>n({url:`/conversation/${s.id}`,method:"PUT",data:e}),onSuccess:(e,t)=>{c(e=>{const r=e.findIndex(e=>e.id===s.id);-1!==r&&Object.assign(e[r],t)})}}),t(f,{as:H.Item,confirm:"确定要删除吗?",onRequest:()=>n({url:`/conversation/${s.id}`,method:"DELETE"}),onSuccess:()=>{c(e=>{const t=e.findIndex(e=>e.id===s.id);-1!==t&&e.splice(t,1)}),d&&i()},children:[e("i",{className:"bi bi-trash3 me-2"}),"删除"]})]})]})]})]},s.id)}),l&&e(b,{wrap:!0})]}):e("div",{className:"text-muted text-center py-5",children:d?"未找到匹配的聊天记录":"暂无对话记录"})},d)})})]})}const Oe=n.div`
131
+ `;function Te(){const{request:n,reset:i,conversationId:o}=Re(),[s,a]=z(!1),[l,d]=z(""),[m,v]=z(""),[y,x]=z(),w=h(e=>{v(e)},500);return q(()=>{w(l)},[l]),t(r,{children:[e(De,{tooltip:"历史记录",placement:"top",onClick:()=>a(!0),children:e("i",{className:"bi bi-clock-history"})}),e(p,{show:s,onHide:()=>{a(!1)},placement:"end",headerAs:He,header:t(r,{children:[e("span",{children:"聊天历史记录"}),e(Je,{children:e(J,{type:"search",placeholder:"搜索聊天记录...",value:l,onChange:e=>d(e.target.value),autoFocus:!0})})]}),bodyAs:Oe,children:s&&e(_e,{children:e(Ue,{useWindow:!1,source:e=>n({url:"/conversation",params:{...e,...m&&{keyword:m}}}),render:({data:s,loading:l,setData:d})=>s.length||l?t(r,{children:[s.map((s,l)=>{const m=o===s.id,h=y===s.id;return t(D,{children:[l>0&&e("hr",{className:"mx-2 my-2"}),t(Be,{children:[m&&e(_,{bg:"secondary",children:"当前"}),h&&e(U,{animation:"border",size:"sm"}),e("span",{className:"overflow-hidden text-truncate flex-fill",onClick:()=>(async e=>{if(!y){if(e.messages)return i(e),void a(!1);try{x(e.id);const t=await n({url:`/conversation/${e.id}`});i(t),a(!1)}catch(e){u.error(c(e)?e.message:"加载对话失败",{preventDuplicate:!0})}finally{x(void 0)}}})(s),children:s.title||"未命名对话"}),t(H,{align:"end",children:[e(H.Toggle,{size:"sm",className:"no-caret",as:De,children:e("i",{className:"bi bi-three-dots-vertical"})}),t(H.Menu,{children:[e(g,{buttonProps:{as:H.Item},text:t(r,{children:[e("i",{className:"bi bi-pencil me-2"}),"重命名"]}),modalProps:{header:"编辑对话名称"},schema:{type:"object",properties:{title:{type:"string"}}},uiSchema:{title:{"ui:label":!1,"ui:autofocus":!0}},formData:{title:s.title},onRequest:e=>n({url:`/conversation/${s.id}`,method:"PUT",data:e}),onSuccess:(e,t)=>{d(e=>{const r=e.findIndex(e=>e.id===s.id);-1!==r&&Object.assign(e[r],t)})}}),t(f,{as:H.Item,confirm:"确定要删除吗?",onRequest:()=>n({url:`/conversation/${s.id}`,method:"DELETE"}),onSuccess:()=>{d(e=>{const t=e.findIndex(e=>e.id===s.id);-1!==t&&e.splice(t,1)}),m&&i()},children:[e("i",{className:"bi bi-trash3 me-2"}),"删除"]})]})]})]})]},s.id)}),l&&e(b,{wrap:!0})]}):e("div",{className:"text-muted text-center py-5",children:m?"未找到匹配的聊天记录":"暂无对话记录"})},m)})})]})}const Oe=n.div`
132
132
  padding: 0;
133
133
  overflow: hidden;
134
134
  `,Be=n.div`
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@topthink/chat",
3
- "version": "1.3.28",
3
+ "version": "1.3.29",
4
4
  "scripts": {
5
5
  "prebuild": "rimraf es types",
6
6
  "build": "rollup -c --environment NODE_ENV:production",
@@ -71,5 +71,5 @@
71
71
  },
72
72
  "author": "yunwuxin <tzzhangyajun@qq.com> (https://github.com/yunwuxin)",
73
73
  "license": "MIT",
74
- "gitHead": "b9643c5b713484852c3c87495d58d63217dd7ecc"
74
+ "gitHead": "4a92d71c029c4360c7fc7a0b63c114d2ad2be71e"
75
75
  }