ADP-Chat-Client
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.

ADPChatComponent.init(container?: string, config?: ChatConfig)

Parameters

ParameterTypeDefaultDescription
containerstring'body'CSS selector for mount container
configChatConfig-Configuration options

Return Value

Returns Vue component instance for subsequent operations.

ChatConfig Options

Props

属性名类型默认值说明
containerstring'body'Mount container selector
apiConfigApiConfig-HTTP request config, extends AxiosRequestConfig
theme'light' | 'dark''light'Theme mode
userUserInfo{}User info
logoUrlstring''Logo image URL
logoTitlestring''Logo title text
isOverlaybooleanfalseOverlay mode: true-use width/height as floating panel, false-fill container
isSidePanelOverlaybooleantrueWhether sidebar uses overlay mode (overlay content area)
widthstring | number400Width (only when isOverlay is true)
heightstring | number'640'Height (only when isOverlay is true)
isOpenboolean-Whether panel is open
onOpenChange(isOpen: boolean) => void-Panel open state change callback
showCloseButtonbooleantrueShow close button
showOverlayButtonbooleantrueShow overlay toggle button
onOverlayChange(isOverlay: boolean) => void-Overlay toggle callback (triggered when user clicks overlay button)
showToggleButtonbooleantrueShow floating toggle button
maxAppLennumber4Max application display count
currentApplicationApplication-Currently selected application
currentApplicationIdstring-Currently selected application ID (higher priority than currentApplication)
currentConversationChatConversation-Currently selected conversation
currentConversationIdstring-Currently selected conversation ID (higher priority than currentConversation)
aiWarningTextstring'AI generated content'AI warning text
languageOptionsLanguageOption[]zh/enLanguage options list
sideI18nSideI18n-Sidebar i18n text
chatI18nChatI18n-Chat i18n text
chatItemI18nChatItemI18n-ChatItem i18n text
senderI18nSenderI18n-Sender i18n text

i18n Configuration

sideI18n

{
  more?: string           // More
  collapse?: string       // Collapse
  today?: string          // Today
  recent?: string         // Recent
  switchTheme?: string    // Switch Theme
  selectLanguage?: string // Select Language
  logout?: string         // Logout
}

chatI18n

{
  loading?: string            // Loading
  thinking?: string           // Thinking
  checkAll?: string           // Select All
  shareFor?: string           // Share to
  copyUrl?: string            // Copy Link
  cancelShare?: string        // Cancel Share
  sendError?: string          // Send Failed
  networkError?: string       // Network Error
  createConversation?: string // New Chat
}

chatItemI18n

{
  thinking?: string             // Thinking
  deepThinkingFinished?: string // Deep thinking finished
  deepThinkingExpand?: string   // Expand deep thinking
  copy?: string                 // Copy
  replay?: string               // Regenerate
  share?: string                // Share
  good?: string                 // Like
  bad?: string                  // Dislike
  thxForGood?: string           // Thanks for liking
  thxForBad?: string            // Thanks for feedback
  references?: string           // References
}

senderI18n

{
  placeholder?: string       // Input placeholder
  placeholderMobile?: string // Mobile input placeholder
  uploadImg?: string         // Upload image
  startRecord?: string       // Start recording
  stopRecord?: string        // Stop recording
  answering?: string         // Answering
  notSupport?: string        // Not supported
  uploadError?: string       // Upload failed
  recordTooLong?: string     // Recording too long
}

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:

ADPChatComponent.init('#chat-container', {
  apiConfig: {
    // Axios request config
    baseURL: 'https://api.example.com',
    timeout: 30000,
    headers: {
      'Authorization': 'Bearer token'
    }
  }
})

Mode Description

Fill Container Mode

Component fills the entire container, suitable for standalone pages:

ADPChatComponent.init('#chat-container', {
  isOverlay: false
})

Overlay Mode

Component displays as a floating panel with fixed dimensions, suitable for embedding in existing pages:

ADPChatComponent.init('#chat-container', {
  isOverlay: true,
  width: 400,
  height: 640
})

Unmount Component

// Unmount component from specified container
ADPChatComponent.unmount('#chat-container')

Type Definitions

UserInfo

interface UserInfo {
  avatarUrl?: string   // Avatar URL
  avatarName?: string  // Avatar display name
  name?: string        // Username
}

LanguageOption

interface LanguageOption {
  key: string    // Language identifier, e.g., 'en-US'
  value: string  // Display name, e.g., 'English'
}

Application

interface Application {
  ApplicationId: string
  Name: string
  Avatar: string
  Greeting: string
  OpeningQuestions: string[]
}

ChatConversation

interface ChatConversation {
  Id: string
  AccountId: string
  Title: string
  LastActiveAt: number
  CreatedAt: number
  ApplicationId: string
}

On this page