Introduction/API Usage
Init Component
Dynamically mount chat component using the init method
Use the init method to dynamically mount the chat component to any DOM container, suitable for all scenarios requiring dynamic chat interface creation.
Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
| container | string | 'body' | CSS selector for mount container |
| config | ChatConfig | - | Configuration options |
Return Value
Returns Vue component instance for subsequent operations.
ChatConfig Options
Props
| 属性名 | 类型 | 默认值 | 说明 |
|---|---|---|---|
| container | string | 'body' | Mount container selector |
| apiConfig | ApiConfig | - | HTTP request config, extends AxiosRequestConfig |
| theme | 'light' | 'dark' | 'light' | Theme mode |
| user | UserInfo | {} | User info |
| logoUrl | string | '' | Logo image URL |
| logoTitle | string | '' | Logo title text |
| isOverlay | boolean | false | Overlay mode: true-use width/height as floating panel, false-fill container |
| isSidePanelOverlay | boolean | true | Whether sidebar uses overlay mode (overlay content area) |
| width | string | number | 400 | Width (only when isOverlay is true) |
| height | string | number | '640' | Height (only when isOverlay is true) |
| isOpen | boolean | - | Whether panel is open |
| onOpenChange | (isOpen: boolean) => void | - | Panel open state change callback |
| showCloseButton | boolean | true | Show close button |
| showOverlayButton | boolean | true | Show overlay toggle button |
| onOverlayChange | (isOverlay: boolean) => void | - | Overlay toggle callback (triggered when user clicks overlay button) |
| showToggleButton | boolean | true | Show floating toggle button |
| maxAppLen | number | 4 | Max application display count |
| currentApplication | Application | - | Currently selected application |
| currentApplicationId | string | - | Currently selected application ID (higher priority than currentApplication) |
| currentConversation | ChatConversation | - | Currently selected conversation |
| currentConversationId | string | - | Currently selected conversation ID (higher priority than currentConversation) |
| aiWarningText | string | 'AI generated content' | AI warning text |
| languageOptions | LanguageOption[] | zh/en | Language options list |
| sideI18n | SideI18n | - | Sidebar i18n text |
| chatI18n | ChatI18n | - | Chat i18n text |
| chatItemI18n | ChatItemI18n | - | ChatItem i18n text |
| senderI18n | SenderI18n | - | Sender i18n text |
i18n Configuration
sideI18n
chatI18n
chatItemI18n
senderI18n
API Mode Configuration
Configure API paths via apiConfig, the component will automatically fetch data via HTTP requests. apiConfig extends AxiosRequestConfig, allowing configuration of baseURL, headers, timeout and other Axios request parameters:
Mode Description
Fill Container Mode
Component fills the entire container, suitable for standalone pages:
Overlay Mode
Component displays as a floating panel with fixed dimensions, suitable for embedding in existing pages: