listpage-next 0.0.269 → 0.0.271

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.
@@ -5,10 +5,12 @@ function setupBaseUrl(HttpClient) {
5
5
  const host = server?.host || location.hostname;
6
6
  const port = server?.port || location.port;
7
7
  if (config?.baseURL) {
8
- if (config.baseURL.startsWith('/')) return `${protocol}//${host}:${port}${config.baseURL}`;
9
- return config.baseURL;
8
+ let baseURL = config?.baseURL;
9
+ if (!baseURL.endsWith('/')) baseURL += '/';
10
+ if (baseURL.startsWith('/')) baseURL = `${protocol}//${host}:${port}${baseURL}`;
11
+ return baseURL;
10
12
  }
11
- return `${protocol}//${host}:${port}${server?.publicPath}`;
13
+ return `${protocol}//${host}:${port}${server?.publicPath || ''}${server?.publicPath?.endsWith('/') ? '' : '/'}`;
12
14
  };
13
15
  }
14
16
  function mergeServerConfig(server) {
@@ -60,8 +60,8 @@ function setupClient(HttpClient) {
60
60
  data: error.response.data
61
61
  };
62
62
  notification.error({
63
- message: error.code,
64
- description: error.message
63
+ message: apiError.code,
64
+ description: apiError.message
65
65
  });
66
66
  return Promise.reject(apiError);
67
67
  }
@@ -75,6 +75,7 @@ function setupClient(HttpClient) {
75
75
  };
76
76
  HttpClient.prototype.sse = async function(url, data) {
77
77
  const baseUrl = this.getBaseURL();
78
+ if (url.startsWith('/')) url = url.slice(1);
78
79
  const uri = new URL(url, baseUrl);
79
80
  let headers = this.getHeaders();
80
81
  headers.Authorization = `Bearer ${this.getToken()}`;
@@ -32,6 +32,7 @@ const ChatInput = (props)=>{
32
32
  className: className,
33
33
  children: [
34
34
  /*#__PURE__*/ jsx(ChatInputContent, {
35
+ onClick: ()=>ref.current?.commands.focus(),
35
36
  children: /*#__PURE__*/ jsx(EditorContent, {
36
37
  placeholder: placeholder,
37
38
  editorRef: ref,
@@ -10,6 +10,7 @@ export interface ConversationDropdownMenuProps<T extends BaseConversation = Base
10
10
  }>;
11
11
  onSelect?: (item: T) => void;
12
12
  onDelete?: (item: T) => void | Promise<void>;
13
+ onUpdate?: (title: string, item: T) => void | Promise<void>;
13
14
  activeKey?: string;
14
15
  }
15
16
  export declare const ConversationDropdownMenu: <T extends BaseConversation = any>(props: ConversationDropdownMenuProps<T>) => import("react/jsx-runtime").JSX.Element;
@@ -1,12 +1,14 @@
1
- import { jsx, jsxs } from "react/jsx-runtime";
2
- import { DeleteOutlined, HistoryOutlined } from "@ant-design/icons";
3
- import { PageLoading } from "../../../../components/index.js";
1
+ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
2
+ import { DeleteOutlined, EditOutlined, HistoryOutlined } from "@ant-design/icons";
3
+ import { PageLoading, PageModal } from "../../../../components/index.js";
4
4
  import { useRequest } from "ahooks";
5
- import { Button, Dropdown, Tooltip } from "antd";
5
+ import { Button, Dropdown, Input, Tooltip } from "antd";
6
+ import { useEffect, useState } from "react";
6
7
  import styled_components from "styled-components";
7
8
  import { getConversationsGroup } from "./utils.js";
8
9
  const ConversationDropdownMenu = (props)=>{
9
- const { request, onSelect, onDelete, activeKey } = props;
10
+ const { request, onSelect, onDelete, activeKey, onUpdate } = props;
11
+ const [editingItem, setEditingItem] = useState(null);
10
12
  const { data, run: refresh, loading, mutate } = useRequest(()=>request(), {
11
13
  manual: true
12
14
  });
@@ -17,21 +19,35 @@ const ConversationDropdownMenu = (props)=>{
17
19
  /*#__PURE__*/ jsx("span", {
18
20
  children: item.title || item
19
21
  }),
20
- /*#__PURE__*/ jsx(Button, {
21
- type: "text",
22
- size: "small",
23
- danger: true,
24
- icon: /*#__PURE__*/ jsx(DeleteOutlined, {}),
25
- onClick: async (e)=>{
26
- e.preventDefault();
27
- e.stopPropagation();
28
- await onDelete?.(item);
29
- const list = (data?.list ?? []).filter((x)=>x.id !== item.id);
30
- mutate?.({
31
- list
32
- });
33
- },
34
- className: "delete-btn"
22
+ /*#__PURE__*/ jsxs("div", {
23
+ className: "action-btns",
24
+ children: [
25
+ Boolean(onUpdate) && /*#__PURE__*/ jsx(Button, {
26
+ type: "text",
27
+ size: "small",
28
+ icon: /*#__PURE__*/ jsx(EditOutlined, {}),
29
+ onClick: (e)=>{
30
+ e.preventDefault();
31
+ e.stopPropagation();
32
+ setEditingItem(item);
33
+ }
34
+ }),
35
+ /*#__PURE__*/ jsx(Button, {
36
+ type: "text",
37
+ size: "small",
38
+ danger: true,
39
+ icon: /*#__PURE__*/ jsx(DeleteOutlined, {}),
40
+ onClick: async (e)=>{
41
+ e.preventDefault();
42
+ e.stopPropagation();
43
+ await onDelete?.(item);
44
+ const list = (data?.list ?? []).filter((x)=>x.id !== item.id);
45
+ mutate?.({
46
+ list
47
+ });
48
+ }
49
+ })
50
+ ]
35
51
  })
36
52
  ]
37
53
  }),
@@ -53,35 +69,73 @@ const ConversationDropdownMenu = (props)=>{
53
69
  type: 'divider'
54
70
  });
55
71
  });
56
- return /*#__PURE__*/ jsx(Tooltip, {
57
- title: "历史会话",
58
- children: /*#__PURE__*/ jsx(Dropdown, {
59
- trigger: [
60
- 'click'
61
- ],
62
- menu: {
63
- items: menus,
64
- activeKey
65
- },
66
- popupRender: (originNode)=>{
67
- if (loading || !data?.list?.length) {
68
- const content = loading ? /*#__PURE__*/ jsx(PageLoading, {}) : '暂无历史会话';
69
- return /*#__PURE__*/ jsx(MenuPanelContainer, {
70
- children: /*#__PURE__*/ jsx(DefaultPanelContainer, {
71
- children: content
72
+ return /*#__PURE__*/ jsxs(Fragment, {
73
+ children: [
74
+ /*#__PURE__*/ jsx(Tooltip, {
75
+ title: "历史会话",
76
+ children: /*#__PURE__*/ jsx(Dropdown, {
77
+ trigger: [
78
+ 'click'
79
+ ],
80
+ menu: {
81
+ items: menus,
82
+ activeKey
83
+ },
84
+ popupRender: (originNode)=>{
85
+ if (loading || !data?.list?.length) {
86
+ const content = loading ? /*#__PURE__*/ jsx(PageLoading, {}) : '暂无历史会话';
87
+ return /*#__PURE__*/ jsx(MenuPanelContainer, {
88
+ children: /*#__PURE__*/ jsx(DefaultPanelContainer, {
89
+ children: content
90
+ })
91
+ });
92
+ }
93
+ return /*#__PURE__*/ jsx(MenuPanelContainer, {
94
+ children: originNode
95
+ });
96
+ },
97
+ children: /*#__PURE__*/ jsx(Button, {
98
+ onClick: refresh,
99
+ type: "text",
100
+ icon: /*#__PURE__*/ jsx(HistoryOutlined, {
101
+ size: 16
72
102
  })
73
- });
74
- }
75
- return /*#__PURE__*/ jsx(MenuPanelContainer, {
76
- children: originNode
77
- });
78
- },
79
- children: /*#__PURE__*/ jsx(Button, {
80
- onClick: refresh,
81
- type: "text",
82
- icon: /*#__PURE__*/ jsx(HistoryOutlined, {
83
- size: 16
103
+ })
84
104
  })
105
+ }),
106
+ /*#__PURE__*/ jsx(EditModal, {
107
+ visible: !!editingItem,
108
+ record: editingItem,
109
+ onOk: (newTitle)=>{
110
+ onUpdate?.(newTitle, editingItem);
111
+ setEditingItem(null);
112
+ },
113
+ onClose: ()=>setEditingItem(null)
114
+ })
115
+ ]
116
+ });
117
+ };
118
+ const EditModal = ({ record, visible, onOk, onClose })=>{
119
+ const [editTitle, setEditTitle] = useState('');
120
+ useEffect(()=>{
121
+ setEditTitle(record?.title || '');
122
+ }, [
123
+ record
124
+ ]);
125
+ return /*#__PURE__*/ jsx(PageModal, {
126
+ title: "编辑会话标题",
127
+ open: visible,
128
+ actionPosition: "bottom",
129
+ onOk: async ()=>onOk?.(editTitle),
130
+ onCancel: onClose,
131
+ children: /*#__PURE__*/ jsx("div", {
132
+ style: {
133
+ padding: 24
134
+ },
135
+ children: /*#__PURE__*/ jsx(Input, {
136
+ value: editTitle,
137
+ onChange: (e)=>setEditTitle(e.target.value),
138
+ placeholder: "请输入新标题"
85
139
  })
86
140
  })
87
141
  });
@@ -106,12 +160,14 @@ const MenuItemLabel = styled_components.div`
106
160
  justify-content: space-between;
107
161
  gap: 8px;
108
162
  width: 100%;
109
- .delete-btn {
163
+ .action-btns {
110
164
  opacity: 0;
111
165
  visibility: hidden;
112
166
  transition: opacity 0.2s ease;
167
+ display: flex;
168
+ gap: 4px;
113
169
  }
114
- &:hover .delete-btn {
170
+ &:hover .action-btns {
115
171
  opacity: 1;
116
172
  visibility: visible;
117
173
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "listpage-next",
3
- "version": "0.0.269",
3
+ "version": "0.0.271",
4
4
  "description": "A React component library for creating filter forms with Ant Design",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",