feat(embed): add widget, visitor chat, and management UI (#1657)
Add embed.html entrypoint, floating widget SDK, secure-mode snippets, management panel with preview, visitor chat composables, citation rendering, and integration docs for subdomain and server-side token exchange.
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,325 @@
|
||||
<template>
|
||||
<t-drawer
|
||||
:visible="visible"
|
||||
:header="title || $t('embedPublish.preview')"
|
||||
size="720px"
|
||||
:footer="false"
|
||||
class="embed-preview-drawer"
|
||||
@close="emit('update:visible', false)"
|
||||
>
|
||||
<div class="preview-body">
|
||||
<template v-if="mode === 'iframe'">
|
||||
<p class="preview-hint">{{ $t('embedPublish.previewIframeHint') }}</p>
|
||||
<div class="device-frame">
|
||||
<div class="device-frame__chrome">
|
||||
<span class="device-frame__dot" />
|
||||
<span class="device-frame__dot" />
|
||||
<span class="device-frame__dot" />
|
||||
<span class="device-frame__url">{{ previewUrlLabel }}</span>
|
||||
</div>
|
||||
<div class="device-frame__screen">
|
||||
<t-loading v-if="!iframeSrc || !iframeReady" size="small" :text="$t('embedPublish.previewLoading')" />
|
||||
<iframe
|
||||
v-else
|
||||
:key="iframeSrc"
|
||||
:src="iframeSrc"
|
||||
class="preview-iframe"
|
||||
allow="clipboard-write"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<template v-else>
|
||||
<p class="preview-hint">{{ $t('embedPublish.previewWidgetHint') }}</p>
|
||||
<div class="widget-shell" :class="`pos-${position}`">
|
||||
<div class="widget-mock-page">
|
||||
<div class="widget-mock-page__title">{{ $t('embedPublish.previewMockPage') }}</div>
|
||||
<div class="widget-mock-page__line" />
|
||||
<div class="widget-mock-page__line widget-mock-page__line--short" />
|
||||
</div>
|
||||
<button
|
||||
type="button"
|
||||
class="widget-launcher"
|
||||
:style="{ background: primaryColor || 'var(--td-brand-color)' }"
|
||||
:aria-label="widgetOpen ? $t('common.close') : $t('embedPublish.preview')"
|
||||
@click="widgetOpen = !widgetOpen"
|
||||
>
|
||||
<t-icon :name="widgetOpen ? 'close' : 'chat'" />
|
||||
</button>
|
||||
<transition name="widget-panel">
|
||||
<div v-show="widgetOpen" class="widget-panel">
|
||||
<iframe
|
||||
v-if="iframeSrc && iframeReady"
|
||||
:key="`widget-${iframeSrc}`"
|
||||
:src="iframeSrc"
|
||||
class="preview-iframe"
|
||||
:title="title || $t('embedPublish.preview')"
|
||||
allow="clipboard-write"
|
||||
/>
|
||||
</div>
|
||||
</transition>
|
||||
</div>
|
||||
</template>
|
||||
</div>
|
||||
</t-drawer>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { computed, nextTick, ref, watch } from 'vue'
|
||||
import { buildEmbedURL, type WidgetPosition } from '@/api/embed'
|
||||
|
||||
const props = defineProps<{
|
||||
visible: boolean
|
||||
channelId: string
|
||||
token: string
|
||||
mode?: 'iframe' | 'widget'
|
||||
title?: string
|
||||
primaryColor?: string
|
||||
position?: WidgetPosition
|
||||
/**
|
||||
* Bumped by the parent every time a preview is (re)opened. Folded into the
|
||||
* iframe URL so the embed page fully reloads and re-fetches the latest saved
|
||||
* config — otherwise re-previewing after an edit shows stale content until a
|
||||
* full page refresh.
|
||||
*/
|
||||
refreshKey?: number
|
||||
/** Channel default locale — passed in the iframe URL so the first paint uses the right language. */
|
||||
locale?: string
|
||||
}>()
|
||||
|
||||
const emit = defineEmits<{
|
||||
(e: 'update:visible', value: boolean): void
|
||||
}>()
|
||||
|
||||
const mode = computed(() => props.mode || 'iframe')
|
||||
const widgetOpen = ref(true)
|
||||
/** Defer iframe until the drawer has laid out — avoids embed autosize measuring a 0-size frame. */
|
||||
const iframeReady = ref(false)
|
||||
|
||||
const iframeSrc = computed(() => {
|
||||
if (!props.channelId || !props.token) return ''
|
||||
return buildEmbedURL(props.channelId, props.token, {
|
||||
locale: props.locale,
|
||||
refreshKey: props.refreshKey,
|
||||
})
|
||||
})
|
||||
|
||||
const previewUrlLabel = computed(() => {
|
||||
if (!props.channelId) return ''
|
||||
try {
|
||||
return new URL(buildEmbedURL(props.channelId)).pathname
|
||||
} catch {
|
||||
return `/embed/${props.channelId}`
|
||||
}
|
||||
})
|
||||
|
||||
watch(() => props.visible, async (open) => {
|
||||
if (open) {
|
||||
widgetOpen.value = true
|
||||
iframeReady.value = false
|
||||
await nextTick()
|
||||
iframeReady.value = true
|
||||
} else {
|
||||
iframeReady.value = false
|
||||
}
|
||||
}, { immediate: true })
|
||||
</script>
|
||||
|
||||
<style scoped lang="less">
|
||||
.preview-body {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
height: 100%;
|
||||
gap: 14px;
|
||||
}
|
||||
|
||||
.preview-hint {
|
||||
flex-shrink: 0;
|
||||
margin: 0;
|
||||
padding: 10px 12px;
|
||||
border-radius: 8px;
|
||||
font-size: 13px;
|
||||
line-height: 1.55;
|
||||
color: var(--td-text-color-secondary);
|
||||
background: var(--td-bg-color-secondarycontainer);
|
||||
border: 1px solid var(--td-component-stroke);
|
||||
}
|
||||
|
||||
.device-frame {
|
||||
flex: 1;
|
||||
min-height: 0;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
border: 1px solid var(--td-component-stroke);
|
||||
border-radius: 12px;
|
||||
overflow: hidden;
|
||||
background: var(--td-bg-color-container);
|
||||
box-shadow: 0 8px 24px rgba(15, 23, 42, 0.06);
|
||||
|
||||
&__chrome {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 6px;
|
||||
padding: 10px 14px;
|
||||
background: var(--td-bg-color-secondarycontainer);
|
||||
border-bottom: 1px solid var(--td-component-stroke);
|
||||
}
|
||||
|
||||
&__dot {
|
||||
width: 8px;
|
||||
height: 8px;
|
||||
border-radius: 50%;
|
||||
background: var(--td-component-stroke);
|
||||
|
||||
&:nth-child(1) { background: #ff5f57; }
|
||||
&:nth-child(2) { background: #febc2e; }
|
||||
&:nth-child(3) { background: #28c840; }
|
||||
}
|
||||
|
||||
&__url {
|
||||
flex: 1;
|
||||
margin-left: 8px;
|
||||
padding: 4px 10px;
|
||||
border-radius: 6px;
|
||||
font-size: 12px;
|
||||
color: var(--td-text-color-placeholder);
|
||||
background: var(--td-bg-color-container);
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
&__screen {
|
||||
flex: 1;
|
||||
min-height: 420px;
|
||||
background: #f5f7fa;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
}
|
||||
}
|
||||
|
||||
.preview-iframe {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
border: none;
|
||||
background: #fff;
|
||||
display: block;
|
||||
}
|
||||
|
||||
.widget-shell {
|
||||
position: relative;
|
||||
flex: 1;
|
||||
min-height: 480px;
|
||||
border: 1px solid var(--td-component-stroke);
|
||||
border-radius: 12px;
|
||||
overflow: hidden;
|
||||
background: linear-gradient(180deg, #f8fafc 0%, #eef2f7 100%);
|
||||
box-shadow: 0 8px 24px rgba(15, 23, 42, 0.06);
|
||||
}
|
||||
|
||||
.widget-mock-page {
|
||||
padding: 28px 32px;
|
||||
|
||||
&__title {
|
||||
font-size: 14px;
|
||||
font-weight: 600;
|
||||
color: var(--td-text-color-placeholder);
|
||||
margin-bottom: 16px;
|
||||
}
|
||||
|
||||
&__line {
|
||||
height: 10px;
|
||||
border-radius: 5px;
|
||||
background: rgba(0, 0, 0, 0.06);
|
||||
margin-bottom: 10px;
|
||||
max-width: 72%;
|
||||
|
||||
&--short {
|
||||
max-width: 48%;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.widget-launcher {
|
||||
position: absolute;
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
width: 48px;
|
||||
height: 48px;
|
||||
border: none;
|
||||
border-radius: 50%;
|
||||
color: #fff;
|
||||
font-size: 20px;
|
||||
cursor: pointer;
|
||||
box-shadow: 0 4px 16px rgba(0, 0, 0, 0.18);
|
||||
z-index: 3;
|
||||
transition: transform 0.15s ease;
|
||||
|
||||
&:hover {
|
||||
transform: scale(1.04);
|
||||
}
|
||||
}
|
||||
|
||||
.widget-panel {
|
||||
position: absolute;
|
||||
width: 380px;
|
||||
max-width: calc(100% - 32px);
|
||||
height: 500px;
|
||||
max-height: calc(100% - 88px);
|
||||
border-radius: 12px;
|
||||
overflow: hidden;
|
||||
background: #fff;
|
||||
box-shadow: 0 12px 40px rgba(15, 23, 42, 0.18);
|
||||
z-index: 2;
|
||||
border: 1px solid var(--td-component-stroke);
|
||||
}
|
||||
|
||||
.widget-panel-enter-active,
|
||||
.widget-panel-leave-active {
|
||||
transition: opacity 0.18s ease, transform 0.18s ease;
|
||||
}
|
||||
|
||||
.widget-panel-enter-from,
|
||||
.widget-panel-leave-to {
|
||||
opacity: 0;
|
||||
transform: translateY(8px) scale(0.98);
|
||||
}
|
||||
|
||||
.pos-bottom-right {
|
||||
.widget-launcher { right: 20px; bottom: 20px; }
|
||||
.widget-panel { right: 20px; bottom: 80px; }
|
||||
}
|
||||
|
||||
.pos-bottom-left {
|
||||
.widget-launcher { left: 20px; bottom: 20px; }
|
||||
.widget-panel { left: 20px; bottom: 80px; }
|
||||
}
|
||||
|
||||
.pos-top-right {
|
||||
.widget-launcher { right: 20px; top: 20px; }
|
||||
.widget-panel { right: 20px; top: 80px; }
|
||||
}
|
||||
|
||||
.pos-top-left {
|
||||
.widget-launcher { left: 20px; top: 20px; }
|
||||
.widget-panel { left: 20px; top: 80px; }
|
||||
}
|
||||
</style>
|
||||
|
||||
<!--
|
||||
Non-scoped: make the drawer body a full-height flex host so the device frame
|
||||
/ widget shell can grow to fill the available space instead of sitting as a
|
||||
fixed-height island. Namespaced under .embed-preview-drawer.
|
||||
-->
|
||||
<style lang="less">
|
||||
.embed-preview-drawer {
|
||||
.t-drawer__body {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
padding: 16px 18px;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,471 @@
|
||||
<template>
|
||||
<div class="embed-input-box" :class="{ 'is-replying': isReplying }">
|
||||
<div v-if="uploadedAttachments.length" class="embed-input-box__files">
|
||||
<div v-for="(att, index) in uploadedAttachments" :key="`${att.file.name}-${index}`" class="embed-file-chip">
|
||||
<t-icon name="file" size="14px" />
|
||||
<span class="embed-file-chip__name">{{ att.file.name }}</span>
|
||||
<button type="button" class="embed-file-chip__remove" @click="removeAttachment(index)">
|
||||
<t-icon name="close" size="12px" />
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
<div v-if="uploadedImages.length" class="embed-input-box__images">
|
||||
<div v-for="(img, index) in uploadedImages" :key="img.preview" class="embed-image-thumb">
|
||||
<img :src="img.preview" :alt="img.file.name" />
|
||||
<button type="button" class="embed-image-thumb__remove" @click="removeImage(index)">
|
||||
<t-icon name="close" size="12px" />
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
<t-textarea
|
||||
v-if="textareaReady"
|
||||
ref="textareaRef"
|
||||
v-model="query"
|
||||
class="embed-input-box__textarea"
|
||||
:class="{ 'has-images': uploadedImages.length > 0 }"
|
||||
:placeholder="t('input.placeholder')"
|
||||
:autosize="{ minRows: 2, maxRows: 6 }"
|
||||
@keydown="onKeydown"
|
||||
@compositionstart="isComposing = true"
|
||||
@compositionend="isComposing = false"
|
||||
/>
|
||||
<input
|
||||
ref="imageInputRef"
|
||||
type="file"
|
||||
accept="image/jpeg,image/png,image/gif,image/webp"
|
||||
multiple
|
||||
class="embed-hidden-file-input"
|
||||
@change="handleImageSelect"
|
||||
/>
|
||||
<input
|
||||
ref="fileInputRef"
|
||||
type="file"
|
||||
accept=".pdf,.doc,.docx,.txt,.md,.csv,.xlsx,.xls,.ppt,.pptx,application/pdf,text/plain"
|
||||
multiple
|
||||
class="embed-hidden-file-input"
|
||||
@change="handleFileSelect"
|
||||
/>
|
||||
<div class="embed-input-box__bar">
|
||||
<div v-if="showWebSearchToggle || showFileUploadToggle" class="embed-input-box__controls">
|
||||
<t-tooltip v-if="showWebSearchToggle" placement="top">
|
||||
<template #content>
|
||||
{{ webSearchEnabled ? t('input.webSearch.toggleOff') : t('input.webSearch.toggleOn') }}
|
||||
</template>
|
||||
<button
|
||||
type="button"
|
||||
class="embed-control-btn embed-websearch-btn"
|
||||
:class="{ active: webSearchEnabled }"
|
||||
:aria-label="t('input.webSearch.label')"
|
||||
@click="toggleWebSearch"
|
||||
>
|
||||
<svg width="18" height="18" viewBox="0 0 18 18" fill="none" aria-hidden="true">
|
||||
<circle cx="9" cy="9" r="7" stroke="currentColor" stroke-width="1.2" fill="none" />
|
||||
<path d="M 9 2 A 3.5 7 0 0 0 9 16" stroke="currentColor" stroke-width="1.2" fill="none" />
|
||||
<path d="M 9 2 A 3.5 7 0 0 1 9 16" stroke="currentColor" stroke-width="1.2" fill="none" />
|
||||
<line x1="2.94" y1="5.5" x2="15.06" y2="5.5" stroke="currentColor" stroke-width="1.2" stroke-linecap="round" />
|
||||
<line x1="2.94" y1="12.5" x2="15.06" y2="12.5" stroke="currentColor" stroke-width="1.2" stroke-linecap="round" />
|
||||
</svg>
|
||||
</button>
|
||||
</t-tooltip>
|
||||
<t-tooltip v-if="showFileUploadToggle" placement="top" :content="t('input.imageUpload.tooltip')">
|
||||
<button
|
||||
type="button"
|
||||
class="embed-control-btn embed-image-btn"
|
||||
:class="{ active: uploadedImages.length > 0 }"
|
||||
:aria-label="t('input.imageUpload.label')"
|
||||
@click="triggerImageUpload"
|
||||
>
|
||||
<t-icon name="image" size="18px" />
|
||||
</button>
|
||||
</t-tooltip>
|
||||
<t-tooltip v-if="showFileUploadToggle" placement="top" :content="t('input.fileUpload.tooltip')">
|
||||
<button
|
||||
type="button"
|
||||
class="embed-control-btn embed-file-btn"
|
||||
:class="{ active: uploadedAttachments.length > 0 }"
|
||||
:aria-label="t('input.fileUpload.label')"
|
||||
@click="triggerFileUpload"
|
||||
>
|
||||
<t-icon name="attach" size="18px" />
|
||||
</button>
|
||||
</t-tooltip>
|
||||
</div>
|
||||
<div class="embed-input-box__actions">
|
||||
<t-tooltip v-if="isReplying" :content="t('input.stopGeneration')" placement="top">
|
||||
<button type="button" class="embed-stop-btn" @click="emit('stop-generation')">
|
||||
<svg width="16" height="16" viewBox="0 0 16 16" fill="currentColor" aria-hidden="true">
|
||||
<rect x="5" y="5" width="6" height="6" rx="1" />
|
||||
</svg>
|
||||
</button>
|
||||
</t-tooltip>
|
||||
<button
|
||||
v-else
|
||||
type="button"
|
||||
class="embed-send-btn"
|
||||
:class="{ disabled: !canSend }"
|
||||
:aria-label="t('input.send')"
|
||||
@click="submit"
|
||||
>
|
||||
<img src="@/assets/img/sending-aircraft.svg" :alt="t('input.send')" />
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { computed, nextTick, onMounted, onUnmounted, ref } from 'vue'
|
||||
import { useI18n } from 'vue-i18n'
|
||||
import { embedToast } from '@/utils/embedToast'
|
||||
import { isEmbedImageFile } from '@/utils/embedFile'
|
||||
|
||||
const props = defineProps<{
|
||||
isReplying: boolean
|
||||
showWebSearchToggle?: boolean
|
||||
webSearchEnabled?: boolean
|
||||
showFileUploadToggle?: boolean
|
||||
}>()
|
||||
|
||||
const emit = defineEmits<{
|
||||
(e: 'send-msg', query: string, imageFiles: File[], attachmentFiles: File[]): void
|
||||
(e: 'stop-generation'): void
|
||||
(e: 'update:webSearchEnabled', value: boolean): void
|
||||
}>()
|
||||
|
||||
const { t } = useI18n()
|
||||
const query = ref('')
|
||||
const isComposing = ref(false)
|
||||
const textareaReady = ref(false)
|
||||
const textareaRef = ref<{ $el?: HTMLElement } | HTMLTextAreaElement | null>(null)
|
||||
|
||||
const getTextareaEl = (): HTMLTextAreaElement | null => {
|
||||
const el = textareaRef.value
|
||||
if (!el) return null
|
||||
if (el instanceof HTMLTextAreaElement) return el
|
||||
const inner = el.$el?.querySelector?.('textarea')
|
||||
return inner instanceof HTMLTextAreaElement ? inner : null
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
nextTick(() => {
|
||||
textareaReady.value = true
|
||||
})
|
||||
})
|
||||
const imageInputRef = ref<HTMLInputElement | null>(null)
|
||||
const fileInputRef = ref<HTMLInputElement | null>(null)
|
||||
const uploadedImages = ref<Array<{ file: File; preview: string }>>([])
|
||||
const uploadedAttachments = ref<Array<{ file: File }>>([])
|
||||
|
||||
const canSend = computed(() =>
|
||||
query.value.trim().length > 0 || uploadedImages.value.length > 0 || uploadedAttachments.value.length > 0)
|
||||
|
||||
const toggleWebSearch = () => {
|
||||
const next = !props.webSearchEnabled
|
||||
emit('update:webSearchEnabled', next)
|
||||
embedToast(next ? t('input.messages.webSearchEnabled') : t('input.messages.webSearchDisabled'))
|
||||
}
|
||||
|
||||
const triggerImageUpload = () => {
|
||||
imageInputRef.value?.click()
|
||||
}
|
||||
|
||||
const triggerFileUpload = () => {
|
||||
fileInputRef.value?.click()
|
||||
}
|
||||
|
||||
const addImageFiles = (files: File[]) => {
|
||||
const allowed = ['image/jpeg', 'image/png', 'image/gif', 'image/webp']
|
||||
const maxSize = 10 * 1024 * 1024
|
||||
for (const file of files) {
|
||||
if (!isEmbedImageFile(file)) continue
|
||||
if (uploadedImages.value.length >= 5) {
|
||||
embedToast(t('chat.imageTooMany'))
|
||||
break
|
||||
}
|
||||
if (!allowed.includes(file.type)) {
|
||||
embedToast(t('chat.imageTypeSizeError'))
|
||||
continue
|
||||
}
|
||||
if (file.size > maxSize) {
|
||||
embedToast(t('chat.imageTypeSizeError'))
|
||||
continue
|
||||
}
|
||||
uploadedImages.value.push({ file, preview: URL.createObjectURL(file) })
|
||||
}
|
||||
}
|
||||
|
||||
const handleImageSelect = (event: Event) => {
|
||||
const input = event.target as HTMLInputElement
|
||||
if (!input.files) return
|
||||
addImageFiles(Array.from(input.files))
|
||||
input.value = ''
|
||||
}
|
||||
|
||||
const addAttachmentFiles = (files: File[]) => {
|
||||
const maxSize = 20 * 1024 * 1024
|
||||
for (const file of files) {
|
||||
if (isEmbedImageFile(file)) continue
|
||||
if (uploadedAttachments.value.length >= 5) {
|
||||
embedToast(t('input.fileUpload.tooMany'))
|
||||
break
|
||||
}
|
||||
if (file.size > maxSize) {
|
||||
embedToast(t('input.fileUpload.tooLarge'))
|
||||
continue
|
||||
}
|
||||
uploadedAttachments.value.push({ file })
|
||||
}
|
||||
}
|
||||
|
||||
const handleFileSelect = (event: Event) => {
|
||||
const input = event.target as HTMLInputElement
|
||||
if (!input.files) return
|
||||
addAttachmentFiles(Array.from(input.files))
|
||||
input.value = ''
|
||||
}
|
||||
|
||||
const removeAttachment = (index: number) => {
|
||||
uploadedAttachments.value.splice(index, 1)
|
||||
}
|
||||
|
||||
const removeImage = (index: number) => {
|
||||
const removed = uploadedImages.value.splice(index, 1)
|
||||
if (removed.length > 0) URL.revokeObjectURL(removed[0].preview)
|
||||
}
|
||||
|
||||
const submit = () => {
|
||||
if (props.isReplying || !canSend.value) return
|
||||
const val = query.value.trim()
|
||||
const imageFiles = uploadedImages.value.map((img) => img.file)
|
||||
const attachmentFiles = uploadedAttachments.value.map((att) => att.file)
|
||||
const textarea = getTextareaEl()
|
||||
if (textarea) textarea.blur()
|
||||
emit('send-msg', val, imageFiles, attachmentFiles)
|
||||
if (getTextareaEl()) query.value = ''
|
||||
uploadedImages.value.forEach((img) => URL.revokeObjectURL(img.preview))
|
||||
uploadedImages.value = []
|
||||
uploadedAttachments.value = []
|
||||
}
|
||||
|
||||
const onKeydown = (_val: string, ctx: { e: KeyboardEvent }) => {
|
||||
const e = ctx?.e
|
||||
if (!e || e.keyCode !== 13) return
|
||||
if (isComposing.value) return
|
||||
if (e.shiftKey || e.ctrlKey) return
|
||||
e.preventDefault()
|
||||
submit()
|
||||
}
|
||||
|
||||
onUnmounted(() => {
|
||||
uploadedImages.value.forEach((img) => URL.revokeObjectURL(img.preview))
|
||||
})
|
||||
</script>
|
||||
|
||||
<style scoped lang="less">
|
||||
.embed-input-box {
|
||||
position: relative;
|
||||
width: 100%;
|
||||
max-width: 800px;
|
||||
margin: 0 auto;
|
||||
background: var(--td-bg-color-container, #fff);
|
||||
border-radius: 12px;
|
||||
border: 0.5px solid var(--td-component-border, #e7e7e7);
|
||||
box-shadow: 0 6px 6px rgba(0, 0, 0, 0.04), 0 12px 12px -1px rgba(0, 0, 0, 0.08);
|
||||
transition: border-color 0.15s ease;
|
||||
|
||||
&:focus-within {
|
||||
border-color: var(--embed-primary, var(--td-brand-color, #07c05f));
|
||||
}
|
||||
|
||||
&__files {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 8px;
|
||||
padding: 12px 16px 0;
|
||||
}
|
||||
|
||||
&__images {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 8px;
|
||||
padding: 12px 16px 0;
|
||||
}
|
||||
|
||||
&__textarea {
|
||||
width: 100%;
|
||||
|
||||
:deep(.t-textarea__inner) {
|
||||
border: none;
|
||||
box-shadow: none;
|
||||
background: transparent;
|
||||
padding: 14px 16px 52px;
|
||||
font-size: 14px;
|
||||
line-height: 1.5;
|
||||
resize: none;
|
||||
}
|
||||
|
||||
&.has-images :deep(.t-textarea__inner) {
|
||||
padding-top: 8px;
|
||||
}
|
||||
}
|
||||
|
||||
&__bar {
|
||||
position: absolute;
|
||||
left: 12px;
|
||||
right: 12px;
|
||||
bottom: 12px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: 8px;
|
||||
pointer-events: none;
|
||||
|
||||
> * {
|
||||
pointer-events: auto;
|
||||
}
|
||||
}
|
||||
|
||||
&__controls {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 6px;
|
||||
}
|
||||
|
||||
&__actions {
|
||||
margin-left: auto;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
}
|
||||
}
|
||||
|
||||
.embed-hidden-file-input {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.embed-file-chip {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 6px;
|
||||
max-width: 220px;
|
||||
padding: 6px 10px;
|
||||
border-radius: 8px;
|
||||
background: var(--td-bg-color-secondarycontainer, #f3f3f3);
|
||||
font-size: 12px;
|
||||
|
||||
&__name {
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
&__remove {
|
||||
border: none;
|
||||
background: transparent;
|
||||
cursor: pointer;
|
||||
padding: 0;
|
||||
color: var(--td-text-color-placeholder);
|
||||
}
|
||||
}
|
||||
|
||||
.embed-image-thumb {
|
||||
position: relative;
|
||||
width: 56px;
|
||||
height: 56px;
|
||||
border-radius: 8px;
|
||||
overflow: hidden;
|
||||
border: 1px solid var(--td-component-border, #e7e7e7);
|
||||
|
||||
img {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
object-fit: cover;
|
||||
}
|
||||
|
||||
&__remove {
|
||||
position: absolute;
|
||||
top: 2px;
|
||||
right: 2px;
|
||||
width: 18px;
|
||||
height: 18px;
|
||||
border: none;
|
||||
border-radius: 50%;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
cursor: pointer;
|
||||
color: #fff;
|
||||
background: rgba(0, 0, 0, 0.55);
|
||||
}
|
||||
}
|
||||
|
||||
.embed-control-btn {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
width: 28px;
|
||||
height: 28px;
|
||||
padding: 0;
|
||||
border: none;
|
||||
border-radius: 6px;
|
||||
cursor: pointer;
|
||||
color: var(--td-text-color-secondary);
|
||||
background: transparent;
|
||||
transition: color 0.15s ease, background 0.15s ease;
|
||||
|
||||
&:hover {
|
||||
background: var(--td-bg-color-secondarycontainer);
|
||||
color: var(--td-text-color-primary);
|
||||
}
|
||||
|
||||
&.active {
|
||||
color: var(--embed-primary, var(--td-brand-color, #07c05f));
|
||||
background: color-mix(in srgb, var(--embed-primary, #07c05f) 12%, transparent);
|
||||
}
|
||||
}
|
||||
|
||||
.embed-send-btn {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
width: 28px;
|
||||
height: 28px;
|
||||
padding: 0;
|
||||
border: none;
|
||||
border-radius: 6px;
|
||||
cursor: pointer;
|
||||
background: var(--embed-primary, var(--td-brand-color, #07c05f));
|
||||
transition: background 0.15s ease, opacity 0.15s ease;
|
||||
|
||||
&:hover:not(.disabled) {
|
||||
filter: brightness(0.94);
|
||||
}
|
||||
|
||||
&.disabled {
|
||||
cursor: not-allowed;
|
||||
opacity: 0.45;
|
||||
}
|
||||
|
||||
img {
|
||||
width: 16px;
|
||||
height: 16px;
|
||||
}
|
||||
}
|
||||
|
||||
.embed-stop-btn {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
width: 28px;
|
||||
height: 28px;
|
||||
padding: 0;
|
||||
border: none;
|
||||
border-radius: 6px;
|
||||
cursor: pointer;
|
||||
color: var(--td-text-color-secondary);
|
||||
background: var(--td-bg-color-secondarycontainer);
|
||||
|
||||
&:hover {
|
||||
background: var(--td-bg-color-component-hover);
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -1,88 +1,75 @@
|
||||
<template>
|
||||
<div class="section-content">
|
||||
<!-- Channel list header -->
|
||||
<div class="im-panel">
|
||||
<div class="channels-section">
|
||||
<div class="channels-header">
|
||||
<span class="channels-title">{{ $t('agentEditor.im.addChannel') }}</span>
|
||||
<span class="channels-title">{{ $t('agentEditor.im.channelsTitle') }}</span>
|
||||
<span class="channels-count">{{ channels.length }}</span>
|
||||
</div>
|
||||
|
||||
<div v-if="loading" class="channels-loading">
|
||||
<t-loading size="small" />
|
||||
<span>{{ $t('common.loading') }}</span>
|
||||
</div>
|
||||
<t-loading :loading="loading" size="small" class="channels-loading-wrap">
|
||||
<div v-if="!loading && channels.length === 0" class="channels-empty">
|
||||
<t-empty :description="$t('agentEditor.im.empty')" />
|
||||
</div>
|
||||
|
||||
<div v-else-if="channels.length === 0" class="channels-empty">
|
||||
<t-icon name="chat-message" class="empty-icon" />
|
||||
<span>{{ $t('agentEditor.im.empty') }}</span>
|
||||
</div>
|
||||
|
||||
<div v-else class="channels-list">
|
||||
<div v-for="channel in channels" :key="channel.id" class="channel-item">
|
||||
<div class="channel-item-header">
|
||||
<div class="channel-info-top">
|
||||
<div class="channel-main">
|
||||
<span class="platform-badge" :class="channel.platform">
|
||||
{{ platformLabel(channel.platform) }}
|
||||
</span>
|
||||
<span class="channel-name">{{ channel.name || $t('agentEditor.im.unnamed') }}</span>
|
||||
</div>
|
||||
<div v-else-if="!loading" class="channel-grid">
|
||||
<button
|
||||
v-for="channel in channels"
|
||||
:key="channel.id"
|
||||
type="button"
|
||||
class="channel-card channel-card--clickable"
|
||||
@click="openDrawer(channel)"
|
||||
>
|
||||
<div class="channel-card__badge">
|
||||
<t-icon name="chat-message" size="18px" />
|
||||
</div>
|
||||
<div class="channel-actions">
|
||||
<div class="channel-card__body">
|
||||
<div class="channel-card__header">
|
||||
<h3 class="channel-card__title">{{ channel.name || $t('agentEditor.im.unnamed') }}</h3>
|
||||
<t-tag v-if="!channel.enabled" size="small" variant="light" theme="warning">
|
||||
{{ $t('agentEditor.im.disabled') }}
|
||||
</t-tag>
|
||||
</div>
|
||||
<p class="channel-card__subtitle">{{ channelSummary(channel) }}</p>
|
||||
</div>
|
||||
<div v-if="authStore.hasRole('admin')" class="channel-card__actions" @click.stop>
|
||||
<t-switch
|
||||
:value="channel.enabled"
|
||||
size="small"
|
||||
:disabled="!authStore.hasRole('admin')"
|
||||
@change="handleToggle(channel)"
|
||||
@change="() => handleToggle(channel)"
|
||||
/>
|
||||
<t-dropdown
|
||||
v-if="authStore.hasRole('admin')"
|
||||
trigger="click"
|
||||
placement="bottom-right"
|
||||
:options="[
|
||||
{ content: $t('common.edit'), value: 'edit', onClick: () => editChannel(channel) },
|
||||
{ content: $t('common.delete'), value: 'delete', theme: 'error' }
|
||||
]"
|
||||
@click="(data) => data.value === 'delete' && handleDelete(channel.id)"
|
||||
:options="channelMenuOptions"
|
||||
@click="(data) => data.value === 'delete' && confirmDelete(channel.id)"
|
||||
>
|
||||
<t-button variant="text" theme="default" size="small">
|
||||
<t-icon name="more" />
|
||||
<t-button
|
||||
variant="text"
|
||||
shape="square"
|
||||
size="small"
|
||||
class="channel-card__more"
|
||||
@click.stop
|
||||
>
|
||||
<template #icon><t-icon name="ellipsis" /></template>
|
||||
</t-button>
|
||||
</t-dropdown>
|
||||
</div>
|
||||
</div>
|
||||
<div class="channel-info">
|
||||
<div class="channel-meta">
|
||||
<span class="meta-tag">
|
||||
<t-icon name="link" class="meta-icon" />
|
||||
{{ channel.mode }}
|
||||
</span>
|
||||
<span class="meta-tag">
|
||||
<t-icon name="play-circle" class="meta-icon" />
|
||||
{{ channel.output_mode === 'stream' ? $t('agentEditor.im.outputStream') : $t('agentEditor.im.outputFull') }}
|
||||
</span>
|
||||
<span v-if="channel.session_mode === 'thread'" class="meta-tag">
|
||||
<t-icon name="chat" class="meta-icon" />
|
||||
{{ $t('agentEditor.im.sessionModeThread') }}
|
||||
</span>
|
||||
</div>
|
||||
<div v-if="channel.mode === 'webhook'" class="callback-url-row">
|
||||
<span class="url-label">{{ $t('agentEditor.im.callbackUrl') }}:</span>
|
||||
<code class="url-value">{{ getCallbackUrl(channel) }}</code>
|
||||
<t-button theme="default" size="small" variant="text" @click="copyUrl(channel)">
|
||||
<t-icon name="file-copy" />
|
||||
</t-button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</button>
|
||||
|
||||
<!-- Add button -->
|
||||
<t-button v-if="authStore.hasRole('admin')" theme="default" variant="dashed" block @click="showCreateDialog = true" class="add-btn">
|
||||
<t-icon name="add" />
|
||||
{{ $t('agentEditor.im.addChannel') }}
|
||||
</t-button>
|
||||
<button
|
||||
v-if="authStore.hasRole('admin')"
|
||||
type="button"
|
||||
class="channel-card channel-card--add"
|
||||
@click="openCreate"
|
||||
>
|
||||
<span class="channel-card--add__icon" aria-hidden="true">
|
||||
<t-icon name="add" />
|
||||
</span>
|
||||
<span class="channel-card--add__label">{{ $t('agentEditor.im.addChannel') }}</span>
|
||||
</button>
|
||||
</div>
|
||||
</t-loading>
|
||||
</div>
|
||||
|
||||
<!-- Create/Edit drawer -->
|
||||
<t-drawer
|
||||
@@ -140,6 +127,21 @@
|
||||
<p v-else class="form-hint">{{ $t('agentEditor.im.modeHint') }}</p>
|
||||
</div>
|
||||
|
||||
<!-- Callback URL (webhook mode, edit only) -->
|
||||
<div v-if="editingChannel && formData.mode === 'webhook'" class="form-item">
|
||||
<label class="form-label">{{ $t('agentEditor.im.callbackUrl') }}</label>
|
||||
<div class="callback-url-control">
|
||||
<t-input
|
||||
:model-value="getCallbackUrl(editingChannel)"
|
||||
readonly
|
||||
class="mono-text-input callback-url-input"
|
||||
/>
|
||||
<t-button size="small" variant="text" :title="$t('common.copy')" @click="copyUrl(editingChannel)">
|
||||
<t-icon name="file-copy" />
|
||||
</t-button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Output mode (hidden for WeChat) -->
|
||||
<div v-if="formData.platform !== 'wechat'" class="form-item">
|
||||
<label class="form-label">{{ $t('agentEditor.im.outputMode') }}</label>
|
||||
@@ -424,7 +426,7 @@
|
||||
<script setup lang="ts">
|
||||
import { ref, onMounted, watch, onUnmounted, computed } from 'vue';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { MessagePlugin } from 'tdesign-vue-next';
|
||||
import { DialogPlugin, MessagePlugin } from 'tdesign-vue-next';
|
||||
import {
|
||||
listIMChannels, createIMChannel, updateIMChannel, deleteIMChannel, toggleIMChannel,
|
||||
getWeChatQRCode, pollWeChatQRCodeStatus,
|
||||
@@ -469,6 +471,22 @@ const formData = ref({
|
||||
credentials: defaultCredentials(),
|
||||
});
|
||||
|
||||
const channelMenuOptions = computed(() => ([
|
||||
{ content: t('common.delete'), value: 'delete', theme: 'error' },
|
||||
]));
|
||||
|
||||
const channelSummary = (channel: IMChannel) => {
|
||||
const parts = [
|
||||
platformLabel(channel.platform),
|
||||
channel.mode,
|
||||
channel.output_mode === 'stream' ? t('agentEditor.im.outputStream') : t('agentEditor.im.outputFull'),
|
||||
];
|
||||
if (channel.session_mode === 'thread') {
|
||||
parts.push(t('agentEditor.im.sessionModeThread'));
|
||||
}
|
||||
return parts.join(' · ');
|
||||
};
|
||||
|
||||
function platformLabel(platform: string): string {
|
||||
const key = `agentEditor.im.${platform}`;
|
||||
return t(key);
|
||||
@@ -632,6 +650,29 @@ async function copyUrl(channel: IMChannel) {
|
||||
}
|
||||
}
|
||||
|
||||
function openCreate() {
|
||||
resetForm();
|
||||
showCreateDialog.value = true;
|
||||
}
|
||||
|
||||
function openDrawer(channel: IMChannel) {
|
||||
editChannel(channel);
|
||||
}
|
||||
|
||||
function confirmDelete(id: string) {
|
||||
const dialog = DialogPlugin.confirm({
|
||||
header: t('common.delete'),
|
||||
body: t('agentEditor.im.deleteConfirm'),
|
||||
confirmBtn: { content: t('common.delete'), theme: 'danger' },
|
||||
cancelBtn: t('common.cancel'),
|
||||
onConfirm: async () => {
|
||||
dialog.destroy();
|
||||
await handleDelete(id);
|
||||
},
|
||||
onClose: () => dialog.destroy(),
|
||||
});
|
||||
}
|
||||
|
||||
function editChannel(channel: IMChannel) {
|
||||
editingChannel.value = channel;
|
||||
formData.value = {
|
||||
@@ -732,22 +773,16 @@ onUnmounted(() => {
|
||||
</script>
|
||||
|
||||
<style scoped lang="less">
|
||||
.section-content {
|
||||
.im-panel {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 16px;
|
||||
}
|
||||
|
||||
// --- Channel list section (matches AgentShareSettings pattern) ---
|
||||
.channels-section {
|
||||
margin-bottom: 8px;
|
||||
}
|
||||
|
||||
.channels-header {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
margin-bottom: 16px;
|
||||
margin-bottom: 12px;
|
||||
|
||||
.channels-title {
|
||||
font-size: 14px;
|
||||
@@ -764,83 +799,164 @@ onUnmounted(() => {
|
||||
}
|
||||
}
|
||||
|
||||
.channels-loading {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
gap: 8px;
|
||||
padding: 32px;
|
||||
color: var(--td-text-color-disabled);
|
||||
font-size: 14px;
|
||||
.channels-loading-wrap {
|
||||
min-height: 80px;
|
||||
}
|
||||
|
||||
.channels-empty {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
gap: 12px;
|
||||
padding: 40px 20px;
|
||||
background: var(--td-bg-color-secondarycontainer);
|
||||
border-radius: 8px;
|
||||
color: var(--td-text-color-disabled);
|
||||
|
||||
.empty-icon {
|
||||
font-size: 32px;
|
||||
opacity: 0.5;
|
||||
}
|
||||
padding: 32px 0;
|
||||
}
|
||||
|
||||
.channels-list {
|
||||
.channel-grid {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
|
||||
gap: 16px;
|
||||
max-height: 400px;
|
||||
overflow-y: auto;
|
||||
gap: 12px;
|
||||
}
|
||||
|
||||
.channel-item {
|
||||
.channel-card {
|
||||
position: relative;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 16px;
|
||||
padding: 16px;
|
||||
background: var(--td-bg-color-container);
|
||||
border: 1px solid var(--td-component-stroke);
|
||||
border-radius: 8px;
|
||||
transition: all 0.2s cubic-bezier(0.38, 0, 0.24, 1);
|
||||
box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
|
||||
|
||||
&:hover {
|
||||
border-color: var(--td-brand-color);
|
||||
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
|
||||
}
|
||||
}
|
||||
|
||||
.channel-item-header {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: flex-start;
|
||||
gap: 12px;
|
||||
}
|
||||
padding: 14px 16px;
|
||||
border: 1px solid var(--td-component-stroke);
|
||||
border-radius: 10px;
|
||||
background: var(--td-bg-color-container);
|
||||
text-align: left;
|
||||
font: inherit;
|
||||
color: inherit;
|
||||
transition: border-color 0.18s ease, box-shadow 0.18s ease;
|
||||
|
||||
.channel-info {
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 8px;
|
||||
}
|
||||
&--clickable {
|
||||
cursor: pointer;
|
||||
width: 100%;
|
||||
|
||||
.channel-info-top {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 12px;
|
||||
}
|
||||
&:hover,
|
||||
&:focus-visible {
|
||||
border-color: var(--td-brand-color-3, var(--td-brand-color));
|
||||
box-shadow: 0 4px 14px rgba(15, 23, 42, 0.06);
|
||||
outline: none;
|
||||
}
|
||||
|
||||
.channel-main {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
&:focus-visible {
|
||||
outline: 2px solid var(--td-brand-color);
|
||||
outline-offset: 2px;
|
||||
}
|
||||
}
|
||||
|
||||
&--add {
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
gap: 8px;
|
||||
min-height: 68px;
|
||||
border-style: dashed;
|
||||
background: transparent;
|
||||
color: var(--td-text-color-placeholder);
|
||||
cursor: pointer;
|
||||
width: 100%;
|
||||
|
||||
&:hover,
|
||||
&:focus-visible {
|
||||
color: var(--td-brand-color);
|
||||
border-color: var(--td-brand-color);
|
||||
background: color-mix(in srgb, var(--td-brand-color) 6%, transparent);
|
||||
box-shadow: none;
|
||||
}
|
||||
|
||||
&__icon {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
width: 32px;
|
||||
height: 32px;
|
||||
border-radius: 8px;
|
||||
background: color-mix(in srgb, var(--td-brand-color) 10%, transparent);
|
||||
color: var(--td-brand-color);
|
||||
font-size: 18px;
|
||||
}
|
||||
|
||||
&__label {
|
||||
font-size: 13px;
|
||||
font-weight: 500;
|
||||
line-height: 1.4;
|
||||
}
|
||||
}
|
||||
|
||||
&__badge {
|
||||
flex-shrink: 0;
|
||||
width: 36px;
|
||||
height: 36px;
|
||||
border-radius: 9px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
background: color-mix(in srgb, var(--td-brand-color) 10%, transparent);
|
||||
color: var(--td-brand-color);
|
||||
}
|
||||
|
||||
&__body {
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
&__header {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 6px;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
&__title {
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
margin: 0;
|
||||
font-size: 14px;
|
||||
font-weight: 600;
|
||||
line-height: 1.4;
|
||||
color: var(--td-text-color-primary);
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
&__subtitle {
|
||||
margin: 2px 0 0;
|
||||
font-size: 12px;
|
||||
line-height: 1.5;
|
||||
color: var(--td-text-color-secondary);
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
&__actions {
|
||||
flex-shrink: 0;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 2px;
|
||||
padding-top: 2px;
|
||||
}
|
||||
|
||||
&__more {
|
||||
flex-shrink: 0;
|
||||
padding: 2px;
|
||||
opacity: 0;
|
||||
color: var(--td-text-color-placeholder);
|
||||
transition: opacity 0.15s ease;
|
||||
|
||||
&:hover,
|
||||
&:focus-visible {
|
||||
background: var(--td-bg-color-secondarycontainer);
|
||||
color: var(--td-text-color-primary);
|
||||
}
|
||||
}
|
||||
|
||||
&:hover .channel-card__more,
|
||||
&:focus-within .channel-card__more,
|
||||
&__actions:focus-within .channel-card__more {
|
||||
opacity: 1;
|
||||
}
|
||||
}
|
||||
|
||||
.platform-badge {
|
||||
@@ -887,75 +1003,20 @@ onUnmounted(() => {
|
||||
}
|
||||
}
|
||||
|
||||
.channel-name {
|
||||
font-size: 14px;
|
||||
font-weight: 500;
|
||||
color: var(--td-text-color-primary);
|
||||
}
|
||||
|
||||
.channel-meta {
|
||||
.callback-url-control {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 6px;
|
||||
gap: 4px;
|
||||
}
|
||||
|
||||
.callback-url-input {
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.mono-text-input :deep(input) {
|
||||
font-family: var(--app-font-family-mono, ui-monospace, SFMono-Regular, Menlo, monospace);
|
||||
font-size: 12px;
|
||||
color: var(--td-text-color-placeholder);
|
||||
|
||||
.meta-tag {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 3px;
|
||||
padding: 2px 6px;
|
||||
background: var(--td-bg-color-secondarycontainer);
|
||||
border-radius: 4px;
|
||||
}
|
||||
|
||||
.meta-icon {
|
||||
font-size: 12px;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
}
|
||||
|
||||
.callback-url-row {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
font-size: 12px;
|
||||
padding-top: 4px;
|
||||
border-top: 1px dashed var(--td-component-stroke);
|
||||
|
||||
.url-label {
|
||||
color: var(--td-text-color-secondary);
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.url-value {
|
||||
background: var(--td-bg-color-container);
|
||||
padding: 2px 8px;
|
||||
border-radius: 4px;
|
||||
font-size: 11px;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
}
|
||||
}
|
||||
|
||||
.channel-actions {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 6px;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.add-btn {
|
||||
margin-top: 4px;
|
||||
|
||||
:deep(.t-button__text) {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 4px;
|
||||
}
|
||||
}
|
||||
|
||||
.drawer-form {
|
||||
|
||||
@@ -1483,6 +1483,9 @@ let resizeHandler: (() => void) | null = null;
|
||||
let scrollHandler: (() => void) | null = null;
|
||||
|
||||
onMounted(() => {
|
||||
// Embed 渠道由宿主注入 agent/KB,勿拉取需 JWT 的平台资源
|
||||
if (props.embeddedMode) return;
|
||||
|
||||
// 并行拉取;若 platform 已预取且缓存未过期则直接复用
|
||||
initChatModelSelection();
|
||||
void Promise.all([
|
||||
@@ -1592,6 +1595,16 @@ const createSession = async (val: string) => {
|
||||
if (props.isReplying) {
|
||||
return MessagePlugin.error(t('input.messages.replying'));
|
||||
}
|
||||
|
||||
// Embed 渠道由后端绑定 agent/KB,勿走平台侧 agent 列表与就绪校验
|
||||
if (props.embeddedMode) {
|
||||
const textarea = getTextareaEl();
|
||||
if (textarea) textarea.blur();
|
||||
emit('send-msg', val, selectedModelId.value || '', [], [], []);
|
||||
clearvalue();
|
||||
return;
|
||||
}
|
||||
|
||||
// 发送前校验当前选中的智能体(含默认快速问答)是否已配置完成
|
||||
const agentToCheck = selectedAgent.value;
|
||||
let actualAgent = agentToCheck;
|
||||
@@ -2092,7 +2105,7 @@ defineExpose({
|
||||
|
||||
</script>
|
||||
<template>
|
||||
<div class="answers-input" @drop="onDrop" @dragover="onDragOver">
|
||||
<div class="answers-input" :class="{ 'is-embedded': embeddedMode }" @drop="onDrop" @dragover="onDragOver">
|
||||
<!-- Hidden file input for image upload -->
|
||||
<input ref="imageInputRef" type="file" accept="image/jpeg,image/png,image/gif,image/webp" multiple
|
||||
style="display:none" @change="handleImageSelect" />
|
||||
@@ -2136,17 +2149,9 @@ defineExpose({
|
||||
<t-textarea ref="textareaRef" v-model="query" :placeholder="inputPlaceholder" name="description" :autosize="true"
|
||||
@keydown="onKeydown" @input="onInput" @compositionstart="onCompositionStart" @compositionend="onCompositionEnd"
|
||||
@paste="onPaste" />
|
||||
</div>
|
||||
|
||||
<!-- Mention Selector -->
|
||||
<Teleport to="body">
|
||||
<MentionSelector :visible="showMention" :style="mentionStyle" :items="mentionItems" :hasMore="mentionHasMore"
|
||||
:loading="mentionLoading" :emptyHint="mentionEmptyHint" v-model:activeIndex="mentionActiveIndex"
|
||||
@select="onMentionSelect" @loadMore="loadMoreMentionItems" />
|
||||
</Teleport>
|
||||
|
||||
<!-- 控制栏 -->
|
||||
<div class="control-bar">
|
||||
<!-- 控制栏(放在 rich-input-container 内,相对输入框边框定位) -->
|
||||
<div class="control-bar" :class="{ 'is-embedded': embeddedMode }">
|
||||
<!-- 左侧控制按钮 -->
|
||||
<div class="control-left" v-if="!embeddedMode">
|
||||
<!-- Agent 模式切换按钮 -->
|
||||
@@ -2335,8 +2340,16 @@ defineExpose({
|
||||
<img src="../assets/img/sending-aircraft.svg" :alt="$t('input.send')" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Mention Selector -->
|
||||
<Teleport to="body">
|
||||
<MentionSelector :visible="showMention" :style="mentionStyle" :items="mentionItems" :hasMore="mentionHasMore"
|
||||
:loading="mentionLoading" :emptyHint="mentionEmptyHint" v-model:activeIndex="mentionActiveIndex"
|
||||
@select="onMentionSelect" @loadMore="loadMoreMentionItems" />
|
||||
</Teleport>
|
||||
|
||||
<!-- 知识库选择下拉(使用 Teleport 传送到 body,避免父容器定位影响) -->
|
||||
<Teleport to="body">
|
||||
<KnowledgeBaseSelector v-model:visible="showKbSelector" :anchorEl="atButtonRef" @close="showKbSelector = false" />
|
||||
@@ -2358,6 +2371,18 @@ const getImgSrc = (url: string) => {
|
||||
width: 100%;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
|
||||
&.is-embedded {
|
||||
position: relative;
|
||||
bottom: auto;
|
||||
left: auto;
|
||||
transform: none;
|
||||
z-index: auto;
|
||||
|
||||
.rich-input-container {
|
||||
max-width: 100%;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* 富文本输入框容器 */
|
||||
@@ -2597,6 +2622,10 @@ const getImgSrc = (url: string) => {
|
||||
background: linear-gradient(to bottom, rgba(255, 255, 255, 0) 0%, var(--td-bg-color-container, #fff) 40%, var(--td-bg-color-container, #fff) 100%);
|
||||
pointer-events: auto;
|
||||
padding-top: 8px;
|
||||
|
||||
&.is-embedded {
|
||||
justify-content: flex-end;
|
||||
}
|
||||
}
|
||||
|
||||
.control-left {
|
||||
|
||||
Reference in New Issue
Block a user