|
4 | 4 | */ |
5 | 5 |
|
6 | 6 | import type { VNode, Component } from 'vue' |
| 7 | +import type { InputMode, SubmitTrigger, AutoSize } from '../sender/types/base' |
| 8 | +import type { SpeechConfig } from '../sender-actions/voice-button/speech.types' |
7 | 9 |
|
8 | 10 | // 主题类型 |
9 | 11 | export type ThemeType = 'light' | 'dark' |
10 | 12 |
|
11 | | -// 输入模式类型 |
12 | | -export type InputMode = 'single' | 'multiple' |
13 | | - |
14 | | -// 提交触发方式 |
15 | | -export type SubmitTrigger = 'enter' | 'ctrlEnter' | 'shiftEnter' |
16 | | - |
17 | | -// 语音回调函数集合 |
18 | | -export interface SpeechCallbacks { |
19 | | - onStart: () => void |
20 | | - onInterim: (transcript: string) => void |
21 | | - onFinal: (transcript: string) => void |
22 | | - onEnd: (transcript?: string) => void |
23 | | - onError: (error: Error) => void |
24 | | -} |
25 | | - |
26 | | -// 语音处理器接口 |
27 | | -export interface SpeechHandler { |
28 | | - start: (callbacks: SpeechCallbacks) => Promise<void> | void |
29 | | - stop: () => Promise<void> | void |
30 | | - isSupported: () => boolean |
31 | | -} |
32 | | - |
33 | | -// 语音识别配置 |
34 | | -export interface SpeechConfig { |
35 | | - customHandler?: SpeechHandler |
36 | | - lang?: string |
37 | | - continuous?: boolean |
38 | | - interimResults?: boolean |
39 | | - autoReplace?: boolean |
40 | | - onVoiceButtonClick?: (isRecording: boolean, preventDefault: () => void) => void | Promise<void> |
41 | | -} |
42 | | - |
43 | | -export type AutoSize = boolean | { minRows: number; maxRows: number } |
44 | | - |
45 | 13 | export type TooltipRender = () => VNode | string |
46 | 14 |
|
47 | 15 | export interface ControlState { |
@@ -78,6 +46,11 @@ export interface ButtonGroupConfig { |
78 | 46 | voice?: VoiceButtonConfig |
79 | 47 | } |
80 | 48 |
|
| 49 | +// ============================================ |
| 50 | +// 建议项相关类型(旧版兼容层专用) |
| 51 | +// 注意:这些类型与新版 sender 的 SuggestionItem 不同,仅用于兼容旧版 API |
| 52 | +// ============================================ |
| 53 | + |
81 | 54 | // 高亮片段类型 |
82 | 55 | export interface SuggestionTextPart { |
83 | 56 | text: string |
@@ -138,21 +111,27 @@ export type SenderEmits = { |
138 | 111 | (e: 'files-selected', files: File[]): void |
139 | 112 | } |
140 | 113 |
|
141 | | -// UserItem 相关类型 |
142 | | -export interface TextItem { |
| 114 | +// ============================================ |
| 115 | +// UserItem 相关类型(旧版兼容层专用) |
| 116 | +// 注意:这些类型与新版 sender 的 TemplateItem 不同,仅用于兼容旧版 API |
| 117 | +// ============================================ |
| 118 | + |
| 119 | +export interface CompatTextItem { |
143 | 120 | id: string |
144 | 121 | type: 'text' |
145 | 122 | content: string |
146 | 123 | } |
147 | 124 |
|
148 | | -export interface TemplateItem { |
| 125 | +export interface CompatTemplateItem { |
149 | 126 | id: string |
150 | 127 | type: 'template' | 'block' |
151 | 128 | content: string |
152 | 129 | } |
153 | 130 |
|
154 | | -export type UserTextItem = Omit<TextItem, 'id'> & { id?: TextItem['id'] } |
| 131 | +export type UserTextItem = Omit<CompatTextItem, 'id'> & { id?: CompatTextItem['id'] } |
155 | 132 |
|
156 | | -export type UserTemplateItem = Omit<Pick<TemplateItem, 'type' | 'content'>, 'id'> & { id?: TemplateItem['id'] } |
| 133 | +export type UserTemplateItem = Omit<Pick<CompatTemplateItem, 'type' | 'content'>, 'id'> & { |
| 134 | + id?: CompatTemplateItem['id'] |
| 135 | +} |
157 | 136 |
|
158 | 137 | export type UserItem = UserTextItem | UserTemplateItem |
0 commit comments