@ibiz-template-plugin/ai-chat 0.0.6 → 0.0.8
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.
- package/dist/index.es.js +2083 -1026
- package/dist/index.legacy.js +1 -1
- package/dist/polyfills.legacy.js +1 -1
- package/dist/style.css +1 -1
- package/dist/types/components/chat-container/chat-container.d.ts +94 -7
- package/dist/types/components/chat-message-item/chat-message-item.d.ts +8 -1
- package/dist/types/components/chat-message-item/error-message/error-message.d.ts +8 -0
- package/dist/types/components/chat-message-item/markdown-message/markdown-message.d.ts +8 -0
- package/dist/types/components/chat-message-item/user-message/user-message.d.ts +8 -0
- package/dist/types/components/chat-messages/chat-messages.d.ts +8 -0
- package/dist/types/components/chat-toolbar/chat-toolbar.d.ts +41 -0
- package/dist/types/components/chat-topic-item/chat-topic-item.d.ts +9 -0
- package/dist/types/components/chat-topics/chat-topics.d.ts +12 -0
- package/dist/types/components/popup/popup.d.ts +15 -0
- package/dist/types/constants/index.d.ts +17 -1
- package/dist/types/controller/ai-chat/ai-chat.controller.d.ts +48 -0
- package/dist/types/controller/ai-topic/ai-topic.controller.d.ts +96 -0
- package/dist/types/controller/chat/chat.controller.d.ts +76 -5
- package/dist/types/controller/index.d.ts +1 -0
- package/dist/types/entity/chart-topic/chart-topic.d.ts +20 -0
- package/dist/types/entity/index.d.ts +1 -0
- package/dist/types/icons/ai-svg.d.ts +1 -0
- package/dist/types/icons/audio-svg.d.ts +1 -0
- package/dist/types/icons/index.d.ts +8 -0
- package/dist/types/icons/link-svg.d.ts +3 -0
- package/dist/types/icons/minimize-svg.d.ts +1 -0
- package/dist/types/icons/more-svg.d.ts +4 -0
- package/dist/types/icons/new-dialogue.d.ts +1 -0
- package/dist/types/icons/recording-svg.d.ts +1 -0
- package/dist/types/icons/remove-svg.d.ts +1 -0
- package/dist/types/index.d.ts +1 -0
- package/dist/types/interface/i-chat-options/i-chat-options.d.ts +104 -25
- package/dist/types/interface/i-chat-toolbar-item/i-chat-toolbar-item.d.ts +53 -0
- package/dist/types/interface/i-config-service/i-config-service.d.ts +27 -0
- package/dist/types/interface/i-container-options/i-container-options.d.ts +45 -0
- package/dist/types/interface/i-topic-options/i-topic-options.d.ts +102 -0
- package/dist/types/interface/index.d.ts +4 -1
- package/dist/types/utils/index.d.ts +1 -0
- package/dist/types/utils/util/indexdb-util.d.ts +91 -0
- package/package.json +5 -3
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { VNode } from 'preact';
|
|
2
|
+
/**
|
|
3
|
+
* 聊天自定义工具栏项接口
|
|
4
|
+
*
|
|
5
|
+
* @export
|
|
6
|
+
* @interface IChatToolbarItem
|
|
7
|
+
*/
|
|
8
|
+
export interface IChatToolbarItem {
|
|
9
|
+
/**
|
|
10
|
+
* 标题
|
|
11
|
+
*
|
|
12
|
+
* @memberof IChatToolbarItem
|
|
13
|
+
*/
|
|
14
|
+
label?: string | VNode | ((h: Function) => VNode);
|
|
15
|
+
/**
|
|
16
|
+
* 提示信息
|
|
17
|
+
*
|
|
18
|
+
* @type {string}
|
|
19
|
+
* @memberof IChatToolbarItem
|
|
20
|
+
*/
|
|
21
|
+
title?: string;
|
|
22
|
+
/**
|
|
23
|
+
* 图标
|
|
24
|
+
*
|
|
25
|
+
* @memberof IChatToolbarItem
|
|
26
|
+
*/
|
|
27
|
+
icon?: string | VNode | ((h: Function) => VNode);
|
|
28
|
+
/**
|
|
29
|
+
* 是否禁用
|
|
30
|
+
*
|
|
31
|
+
* @memberof IChatToolbarItem
|
|
32
|
+
*/
|
|
33
|
+
disabled?: boolean | ((data: object) => boolean);
|
|
34
|
+
/**
|
|
35
|
+
* 是否隐藏
|
|
36
|
+
*
|
|
37
|
+
* @memberof IChatToolbarItem
|
|
38
|
+
*/
|
|
39
|
+
hidden?: boolean | ((data: object) => boolean);
|
|
40
|
+
/**
|
|
41
|
+
* 自定义类名
|
|
42
|
+
*
|
|
43
|
+
* @type {string}
|
|
44
|
+
* @memberof IChatToolbarItem
|
|
45
|
+
*/
|
|
46
|
+
customClass?: string;
|
|
47
|
+
/**
|
|
48
|
+
* 行为项点击
|
|
49
|
+
*
|
|
50
|
+
* @memberof IChatToolbarItem
|
|
51
|
+
*/
|
|
52
|
+
onClick?: (e: MouseEvent, context: object, params: object, data?: object) => void;
|
|
53
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
export interface IConfigService {
|
|
2
|
+
/**
|
|
3
|
+
* 保存配置
|
|
4
|
+
*
|
|
5
|
+
* @author tony001
|
|
6
|
+
* @date 2025-02-23 16:02:33
|
|
7
|
+
* @param {object} data
|
|
8
|
+
* @return {*} {Promise<boolean>}
|
|
9
|
+
*/
|
|
10
|
+
save(data: object): Promise<boolean>;
|
|
11
|
+
/**
|
|
12
|
+
* 重置配置
|
|
13
|
+
*
|
|
14
|
+
* @author tony001
|
|
15
|
+
* @date 2025-02-23 16:02:48
|
|
16
|
+
* @return {*} {Promise<boolean>}
|
|
17
|
+
*/
|
|
18
|
+
reset(): Promise<boolean>;
|
|
19
|
+
/**
|
|
20
|
+
* 加载配置
|
|
21
|
+
*
|
|
22
|
+
* @author tony001
|
|
23
|
+
* @date 2025-02-23 16:02:57
|
|
24
|
+
* @return {*} {Promise<object>}
|
|
25
|
+
*/
|
|
26
|
+
load(): Promise<object>;
|
|
27
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { IChatContainerOptions } from '../i-chat-container/i-chat-container';
|
|
2
|
+
import { IChatOptions } from '../i-chat-options/i-chat-options';
|
|
3
|
+
import { ITopicOptions } from '../i-topic-options/i-topic-options';
|
|
4
|
+
/**
|
|
5
|
+
* ai容器配置参数
|
|
6
|
+
*
|
|
7
|
+
* @author tony001
|
|
8
|
+
* @date 2025-02-24 11:02:46
|
|
9
|
+
* @export
|
|
10
|
+
* @interface IContainerOptions
|
|
11
|
+
*/
|
|
12
|
+
export interface IContainerOptions {
|
|
13
|
+
/**
|
|
14
|
+
* 模式,细分为默认模式(聊天框)和话题模式(支持多话题切换),聊天框为默认模式
|
|
15
|
+
*
|
|
16
|
+
* @author tony001
|
|
17
|
+
* @date 2025-02-20 14:02:36
|
|
18
|
+
* @type {('DEFAULT' | 'TOPIC')}
|
|
19
|
+
*/
|
|
20
|
+
mode?: 'DEFAULT' | 'TOPIC';
|
|
21
|
+
/**
|
|
22
|
+
* 话题参数(话题模式必填)
|
|
23
|
+
*
|
|
24
|
+
* @author tony001
|
|
25
|
+
* @date 2025-02-20 15:02:02
|
|
26
|
+
* @type {ITopicOptions}
|
|
27
|
+
*/
|
|
28
|
+
topicOptions?: ITopicOptions;
|
|
29
|
+
/**
|
|
30
|
+
* 聊天窗口配置参数
|
|
31
|
+
*
|
|
32
|
+
* @author tony001
|
|
33
|
+
* @date 2025-02-24 11:02:53
|
|
34
|
+
* @type {IChatOptions}
|
|
35
|
+
*/
|
|
36
|
+
chatOptions: IChatOptions;
|
|
37
|
+
/**
|
|
38
|
+
* ai容器呈现
|
|
39
|
+
*
|
|
40
|
+
* @author chitanda
|
|
41
|
+
* @date 2023-10-15 19:10:44
|
|
42
|
+
* @type {IChatContainerOptions}
|
|
43
|
+
*/
|
|
44
|
+
containerOptions?: IChatContainerOptions;
|
|
45
|
+
}
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import { IChat } from '../i-chat-options/i-chat-options';
|
|
2
|
+
import { IConfigService } from '../i-config-service/i-config-service';
|
|
3
|
+
/**
|
|
4
|
+
* 话题数据
|
|
5
|
+
*
|
|
6
|
+
* @author tony001
|
|
7
|
+
* @date 2025-02-23 17:02:34
|
|
8
|
+
* @export
|
|
9
|
+
* @interface ITopic
|
|
10
|
+
*/
|
|
11
|
+
export interface ITopic {
|
|
12
|
+
/**
|
|
13
|
+
* 应用标识
|
|
14
|
+
*
|
|
15
|
+
* @author tony001
|
|
16
|
+
* @date 2025-02-20 18:02:07
|
|
17
|
+
* @type {string}
|
|
18
|
+
*/
|
|
19
|
+
appid: string;
|
|
20
|
+
/**
|
|
21
|
+
* 话题标识
|
|
22
|
+
*
|
|
23
|
+
* @author tony001
|
|
24
|
+
* @date 2025-02-20 15:02:01
|
|
25
|
+
* @type {string}
|
|
26
|
+
*/
|
|
27
|
+
id: string;
|
|
28
|
+
/**
|
|
29
|
+
* 话题类型
|
|
30
|
+
*
|
|
31
|
+
* @author tony001
|
|
32
|
+
* @date 2025-02-20 18:02:00
|
|
33
|
+
* @type {string}
|
|
34
|
+
*/
|
|
35
|
+
type: string;
|
|
36
|
+
/**
|
|
37
|
+
* 话题标题
|
|
38
|
+
*
|
|
39
|
+
* @author tony001
|
|
40
|
+
* @date 2025-02-20 15:02:57
|
|
41
|
+
* @type {string}
|
|
42
|
+
*/
|
|
43
|
+
caption?: string;
|
|
44
|
+
/**
|
|
45
|
+
* 话题主数据url,用于跳转主数据界面
|
|
46
|
+
*
|
|
47
|
+
* @author tony001
|
|
48
|
+
* @date 2025-02-20 15:02:08
|
|
49
|
+
* @type {string}
|
|
50
|
+
*/
|
|
51
|
+
url?: string;
|
|
52
|
+
/**
|
|
53
|
+
* 上下文
|
|
54
|
+
*
|
|
55
|
+
* @author tony001
|
|
56
|
+
* @date 2025-02-24 11:02:59
|
|
57
|
+
* @type {IChat}
|
|
58
|
+
*/
|
|
59
|
+
aiChat?: IChat;
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* 话题参数
|
|
63
|
+
*
|
|
64
|
+
* @author tony001
|
|
65
|
+
* @date 2025-02-20 15:02:46
|
|
66
|
+
* @export
|
|
67
|
+
* @interface ITopicOptions
|
|
68
|
+
*/
|
|
69
|
+
export interface ITopicOptions extends ITopic {
|
|
70
|
+
/**
|
|
71
|
+
* 删除之前
|
|
72
|
+
*
|
|
73
|
+
* @author tony001
|
|
74
|
+
* @date 2025-02-24 16:02:35
|
|
75
|
+
* @param {object} context
|
|
76
|
+
* @param {object} params
|
|
77
|
+
* @param {ITopic} data
|
|
78
|
+
* @param {MouseEvent} event
|
|
79
|
+
* @return {*} {Promise<boolean>}
|
|
80
|
+
*/
|
|
81
|
+
beforeDelete?(context: object, params: object, data: ITopic, event: MouseEvent): Promise<boolean>;
|
|
82
|
+
/**
|
|
83
|
+
* 话题行为
|
|
84
|
+
*
|
|
85
|
+
* @author tony001
|
|
86
|
+
* @date 2025-02-24 16:02:04
|
|
87
|
+
* @param { string} action
|
|
88
|
+
* @param {object} context
|
|
89
|
+
* @param {object} params
|
|
90
|
+
* @param {ITopic} data
|
|
91
|
+
* @param {MouseEvent} event
|
|
92
|
+
* @return {*} {Promise<boolean>}
|
|
93
|
+
*/
|
|
94
|
+
action?(action: string, context: object, params: object, data: ITopic, event: MouseEvent): Promise<boolean>;
|
|
95
|
+
/**
|
|
96
|
+
* 存储服务构造器
|
|
97
|
+
*
|
|
98
|
+
* @author tony001
|
|
99
|
+
* @date 2025-02-23 16:02:46
|
|
100
|
+
*/
|
|
101
|
+
configService: (appid: string, storageType: string, subType: string) => IConfigService;
|
|
102
|
+
}
|
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
export type { IChatMessage } from './i-chat-message/i-chat-message';
|
|
2
|
-
export type { IChatOptions } from './i-chat-options/i-chat-options';
|
|
2
|
+
export type { IChat, IChatOptions } from './i-chat-options/i-chat-options';
|
|
3
3
|
export type { IMessageItemProvider } from './i-message-item-provider/i-message-item-provider';
|
|
4
4
|
export type { IPortalAsyncAction } from './i-portal-async-action/i-portal-async-action';
|
|
5
|
+
export type { IChatToolbarItem } from './i-chat-toolbar-item/i-chat-toolbar-item';
|
|
6
|
+
export type { ITopic, ITopicOptions } from './i-topic-options/i-topic-options';
|
|
7
|
+
export type { IContainerOptions } from './i-container-options/i-container-options';
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
export declare class IndexedDBUtil {
|
|
2
|
+
static version: number;
|
|
3
|
+
static db: IDBDatabase | null;
|
|
4
|
+
static lastLink: IDBDatabase;
|
|
5
|
+
/**
|
|
6
|
+
* 检查数据库是否存在
|
|
7
|
+
*
|
|
8
|
+
* @param {string} storeName
|
|
9
|
+
* @return {*} {Promise<boolean>}
|
|
10
|
+
* @memberof IndexedDBUtil
|
|
11
|
+
*/
|
|
12
|
+
static checkDataBaseExists(storeName: string): Promise<boolean>;
|
|
13
|
+
/**
|
|
14
|
+
* 删除数据库
|
|
15
|
+
*
|
|
16
|
+
* @return {*} {Promise<void>}
|
|
17
|
+
* @memberof IndexedDBUtil
|
|
18
|
+
*/
|
|
19
|
+
static deleteDatabase(storeName: string): Promise<boolean>;
|
|
20
|
+
/**
|
|
21
|
+
* 检查是否存在某个库以及库内是否存在某个表
|
|
22
|
+
*
|
|
23
|
+
* @param {string} storeName
|
|
24
|
+
* @param {string} tableName
|
|
25
|
+
* @return {*}
|
|
26
|
+
* @memberof IndexedDBUtil
|
|
27
|
+
*/
|
|
28
|
+
static checkTableExists(storeName: string, tableName: string): Promise<boolean>;
|
|
29
|
+
/**
|
|
30
|
+
* 创建表
|
|
31
|
+
*
|
|
32
|
+
* @param {string} storeName 库名称
|
|
33
|
+
* @param {(string | null)} keyPath 表主键
|
|
34
|
+
* @param {boolean} [useAutoIncrement=false] 是否使用自增
|
|
35
|
+
* @return {*} {Promise<void>}
|
|
36
|
+
* @memberof IndexedDBUtil
|
|
37
|
+
*/
|
|
38
|
+
static createTable(storeName: string, tableName: string, keyPath: string | null, useAutoIncrement?: boolean): Promise<boolean>;
|
|
39
|
+
/**
|
|
40
|
+
* 删除表
|
|
41
|
+
*
|
|
42
|
+
* @param {string} storeName 表名称
|
|
43
|
+
* @return {*} {Promise<void>}
|
|
44
|
+
* @memberof IndexedDBUtil
|
|
45
|
+
*/
|
|
46
|
+
static deleteTable(storeName: string, tableName: string): Promise<boolean>;
|
|
47
|
+
/**
|
|
48
|
+
* 新增数据
|
|
49
|
+
*
|
|
50
|
+
* @param {string} storeName 表名称
|
|
51
|
+
* @param {*} data 新增数据
|
|
52
|
+
* @return {*} {Promise<void>}
|
|
53
|
+
* @memberof IndexedDBUtil
|
|
54
|
+
*/
|
|
55
|
+
static addData(storeName: string, tableName: string, data: object): Promise<object | null>;
|
|
56
|
+
/**
|
|
57
|
+
* 删除数据
|
|
58
|
+
*
|
|
59
|
+
* @param {string} storeName 表名称
|
|
60
|
+
* @param {IDBValidKey} key 数据键
|
|
61
|
+
* @return {*} {Promise<void>}
|
|
62
|
+
* @memberof IndexedDBUtil
|
|
63
|
+
*/
|
|
64
|
+
static deleteData(storeName: string, tableName: string, key: IDBValidKey): Promise<boolean>;
|
|
65
|
+
/**
|
|
66
|
+
* 修改数据
|
|
67
|
+
*
|
|
68
|
+
* @param {string} storeName 表名称
|
|
69
|
+
* @param {*} data 需要修改的数据
|
|
70
|
+
* @return {*} {Promise<void>}
|
|
71
|
+
* @memberof IndexedDBUtil
|
|
72
|
+
*/
|
|
73
|
+
static updateData(storeName: string, tableName: string, data: object): Promise<object>;
|
|
74
|
+
/**
|
|
75
|
+
* 读取单条数据
|
|
76
|
+
*
|
|
77
|
+
* @param {string} storeName 表名称
|
|
78
|
+
* @param {IDBValidKey} key 数据主键
|
|
79
|
+
* @return {*} {Promise<any>}
|
|
80
|
+
* @memberof IndexedDBUtil
|
|
81
|
+
*/
|
|
82
|
+
static getData(storeName: string, tableName: string, key: IDBValidKey): Promise<object>;
|
|
83
|
+
/**
|
|
84
|
+
* 读取所有数据
|
|
85
|
+
*
|
|
86
|
+
* @param {string} storeName 表名称
|
|
87
|
+
* @return {*} {Promise<any[]>}
|
|
88
|
+
* @memberof IndexedDBUtil
|
|
89
|
+
*/
|
|
90
|
+
static getAllData(storeName: string, tableName: string): Promise<object[]>;
|
|
91
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ibiz-template-plugin/ai-chat",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.8",
|
|
4
4
|
"description": "使用 rollup 编译 vue 组件或者 jsx",
|
|
5
5
|
"main": "dist/index.es.js",
|
|
6
6
|
"module": "dist/index.es.js",
|
|
@@ -22,7 +22,8 @@
|
|
|
22
22
|
"publish:next": "npm run build && npm publish --access public --tag=next --registry=https://registry.npmjs.org/",
|
|
23
23
|
"publish:dev": "npm run build && npm publish --access public --tag=dev --registry=https://registry.npmjs.org/",
|
|
24
24
|
"publish:beta": "npm run build && npm publish --access public --tag=beta --registry=https://registry.npmjs.org/",
|
|
25
|
-
"publish:npm": "npm run build && npm publish --access public --registry=https://registry.npmjs.org/"
|
|
25
|
+
"publish:npm": "npm run build && npm publish --access public --registry=https://registry.npmjs.org/",
|
|
26
|
+
"publish:local": "npm run build && npm publish --access public --registry=http://172.16.240.221:8081/repository/local/"
|
|
26
27
|
},
|
|
27
28
|
"dependencies": {
|
|
28
29
|
"@ibiz-template/scss-utils": "^0.0.2",
|
|
@@ -32,7 +33,8 @@
|
|
|
32
33
|
"interactjs": "^1.10.19",
|
|
33
34
|
"path-browserify": "^1.0.1",
|
|
34
35
|
"preact": "^10.18.1",
|
|
35
|
-
"react-tabs": "^6.0.2"
|
|
36
|
+
"react-tabs": "^6.0.2",
|
|
37
|
+
"vite-plugin-libcss": "^1.1.1"
|
|
36
38
|
},
|
|
37
39
|
"devDependencies": {
|
|
38
40
|
"@commitlint/cli": "^18.2.0",
|