2026-04-11 15:59:14 +08:00
|
|
|
<script setup lang="ts">
|
2026-04-16 08:38:18 +08:00
|
|
|
import type { Attachment } from '@/stores/hermes/chat'
|
|
|
|
|
import { useChatStore } from '@/stores/hermes/chat'
|
2026-04-22 16:14:50 +08:00
|
|
|
import { useAppStore } from '@/stores/hermes/app'
|
|
|
|
|
import { useProfilesStore } from '@/stores/hermes/profiles'
|
|
|
|
|
import { fetchContextLength } from '@/api/hermes/sessions'
|
2026-05-06 15:05:44 +08:00
|
|
|
import { setModelContext } from '@/api/hermes/model-context'
|
|
|
|
|
import { NButton, NTooltip, NSwitch, NModal, NInputNumber, useMessage } from 'naive-ui'
|
2026-04-22 16:14:50 +08:00
|
|
|
import { computed, ref, onMounted, watch } from 'vue'
|
2026-04-13 17:48:47 +08:00
|
|
|
import { useI18n } from 'vue-i18n'
|
2026-04-11 15:59:14 +08:00
|
|
|
|
|
|
|
|
const chatStore = useChatStore()
|
2026-04-13 15:15:14 +08:00
|
|
|
const { t } = useI18n()
|
2026-05-06 15:05:44 +08:00
|
|
|
const message = useMessage()
|
2026-04-11 15:59:14 +08:00
|
|
|
const inputText = ref('')
|
|
|
|
|
const textareaRef = ref<HTMLTextAreaElement>()
|
2026-04-11 18:54:46 +08:00
|
|
|
const fileInputRef = ref<HTMLInputElement>()
|
|
|
|
|
const attachments = ref<Attachment[]>([])
|
2026-04-12 23:23:50 +08:00
|
|
|
const isDragging = ref(false)
|
|
|
|
|
const dragCounter = ref(0)
|
2026-04-13 17:48:47 +08:00
|
|
|
const isComposing = ref(false)
|
2026-04-11 18:54:46 +08:00
|
|
|
|
2026-05-02 13:26:57 +08:00
|
|
|
// 自动播放语音开关
|
|
|
|
|
const autoPlaySpeech = ref(false)
|
|
|
|
|
|
|
|
|
|
// 从 localStorage 读取设置
|
|
|
|
|
onMounted(() => {
|
|
|
|
|
const saved = localStorage.getItem('autoPlaySpeech')
|
|
|
|
|
if (saved !== null) {
|
|
|
|
|
autoPlaySpeech.value = saved === 'true'
|
|
|
|
|
// 同步到 chat store
|
|
|
|
|
chatStore.setAutoPlaySpeech(autoPlaySpeech.value)
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
// 监听变化并保存
|
|
|
|
|
watch(autoPlaySpeech, (value) => {
|
|
|
|
|
localStorage.setItem('autoPlaySpeech', String(value))
|
|
|
|
|
// 通知 chat store
|
|
|
|
|
chatStore.setAutoPlaySpeech(value)
|
|
|
|
|
})
|
|
|
|
|
|
2026-04-11 18:54:46 +08:00
|
|
|
const canSend = computed(() => inputText.value.trim() || attachments.value.length > 0)
|
2026-04-11 15:59:14 +08:00
|
|
|
|
2026-04-22 16:14:50 +08:00
|
|
|
// --- Context info ---
|
|
|
|
|
|
|
|
|
|
const contextLength = ref(200000)
|
|
|
|
|
const FALLBACK_CONTEXT = 200000
|
|
|
|
|
|
2026-05-06 15:05:44 +08:00
|
|
|
// Context length editing
|
|
|
|
|
const showContextEditModal = ref(false)
|
|
|
|
|
const editingContextLimit = ref(200000)
|
|
|
|
|
const isSavingContextLimit = ref(false)
|
|
|
|
|
|
|
|
|
|
async function handleEditContextLimit() {
|
|
|
|
|
editingContextLimit.value = contextLength.value
|
|
|
|
|
showContextEditModal.value = true
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
async function saveContextLimit() {
|
|
|
|
|
if (!editingContextLimit.value || editingContextLimit.value <= 0) {
|
|
|
|
|
message.error(t('chat.contextEditInvalid'))
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
isSavingContextLimit.value = true
|
|
|
|
|
try {
|
|
|
|
|
const appStore = useAppStore()
|
|
|
|
|
const provider = appStore.selectedProvider || ''
|
|
|
|
|
const model = appStore.selectedModel || ''
|
|
|
|
|
|
|
|
|
|
if (!provider || !model) {
|
|
|
|
|
message.error(t('chat.contextEditFailed'))
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
await setModelContext(provider, model, editingContextLimit.value)
|
|
|
|
|
contextLength.value = editingContextLimit.value
|
|
|
|
|
showContextEditModal.value = false
|
|
|
|
|
message.success(t('chat.contextEditSuccess'))
|
|
|
|
|
} catch (err: any) {
|
|
|
|
|
message.error(`${t('chat.contextEditFailed')}: ${err.message || ''}`)
|
|
|
|
|
} finally {
|
|
|
|
|
isSavingContextLimit.value = false
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2026-04-22 16:14:50 +08:00
|
|
|
async function loadContextLength() {
|
|
|
|
|
try {
|
|
|
|
|
const profile = useProfilesStore().activeProfileName || undefined
|
|
|
|
|
contextLength.value = await fetchContextLength(profile)
|
|
|
|
|
} catch {
|
|
|
|
|
contextLength.value = FALLBACK_CONTEXT
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
onMounted(loadContextLength)
|
|
|
|
|
watch(() => useProfilesStore().activeProfileName, loadContextLength)
|
|
|
|
|
watch(() => useAppStore().selectedModel, loadContextLength)
|
|
|
|
|
|
|
|
|
|
const totalTokens = computed(() => {
|
|
|
|
|
const input = chatStore.activeSession?.inputTokens ?? 0
|
|
|
|
|
const output = chatStore.activeSession?.outputTokens ?? 0
|
|
|
|
|
return input + output
|
|
|
|
|
})
|
|
|
|
|
|
2026-04-25 14:23:37 +08:00
|
|
|
const remainingTokens = computed(() => Math.max(0, contextLength.value - totalTokens.value))
|
2026-04-22 16:14:50 +08:00
|
|
|
|
|
|
|
|
const usagePercent = computed(() =>
|
|
|
|
|
Math.min((totalTokens.value / contextLength.value) * 100, 100),
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
function formatTokens(n: number): string {
|
|
|
|
|
if (n >= 1000000) return (n / 1000000).toFixed(1) + 'M'
|
|
|
|
|
if (n >= 1000) return (n / 1000).toFixed(1) + 'k'
|
|
|
|
|
return String(n)
|
|
|
|
|
}
|
2026-04-12 23:23:50 +08:00
|
|
|
|
|
|
|
|
// --- File attachment helpers ---
|
|
|
|
|
|
|
|
|
|
function addFile(file: File) {
|
|
|
|
|
if (attachments.value.find(a => a.name === file.name)) return
|
|
|
|
|
const id = Date.now().toString(36) + Math.random().toString(36).slice(2, 8)
|
|
|
|
|
const url = URL.createObjectURL(file)
|
|
|
|
|
attachments.value.push({
|
|
|
|
|
id,
|
|
|
|
|
name: file.name,
|
|
|
|
|
type: file.type,
|
|
|
|
|
size: file.size,
|
|
|
|
|
url,
|
|
|
|
|
file,
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
2026-04-11 21:33:04 +08:00
|
|
|
function handleAttachClick() {
|
|
|
|
|
fileInputRef.value?.click()
|
|
|
|
|
}
|
|
|
|
|
|
2026-04-12 23:23:50 +08:00
|
|
|
function handleFileChange(e: Event) {
|
|
|
|
|
const input = e.target as HTMLInputElement
|
|
|
|
|
if (!input.files) return
|
|
|
|
|
for (const file of input.files) addFile(file)
|
|
|
|
|
input.value = ''
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// --- Paste image ---
|
|
|
|
|
|
|
|
|
|
function handlePaste(e: ClipboardEvent) {
|
|
|
|
|
const items = Array.from(e.clipboardData?.items || [])
|
|
|
|
|
const imageItems = items.filter(i => i.type.startsWith('image/'))
|
|
|
|
|
if (!imageItems.length) return
|
|
|
|
|
e.preventDefault()
|
|
|
|
|
for (const item of imageItems) {
|
|
|
|
|
const blob = item.getAsFile()
|
|
|
|
|
if (!blob) continue
|
|
|
|
|
const ext = item.type.split('/')[1] || 'png'
|
|
|
|
|
const file = new File([blob], `pasted-${Date.now()}.${ext}`, { type: item.type })
|
|
|
|
|
addFile(file)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// --- Drag and drop ---
|
|
|
|
|
|
|
|
|
|
function handleDragOver(e: DragEvent) {
|
|
|
|
|
e.preventDefault()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function handleDragEnter(e: DragEvent) {
|
|
|
|
|
e.preventDefault()
|
|
|
|
|
if (e.dataTransfer?.types.includes('Files')) {
|
|
|
|
|
dragCounter.value++
|
|
|
|
|
isDragging.value = true
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function handleDragLeave() {
|
|
|
|
|
dragCounter.value--
|
|
|
|
|
if (dragCounter.value <= 0) {
|
|
|
|
|
dragCounter.value = 0
|
|
|
|
|
isDragging.value = false
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function handleDrop(e: DragEvent) {
|
|
|
|
|
e.preventDefault()
|
|
|
|
|
dragCounter.value = 0
|
|
|
|
|
isDragging.value = false
|
|
|
|
|
const files = Array.from(e.dataTransfer?.files || [])
|
|
|
|
|
if (!files.length) return
|
|
|
|
|
for (const file of files) addFile(file)
|
|
|
|
|
textareaRef.value?.focus()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// --- Send ---
|
|
|
|
|
|
2026-04-11 15:59:14 +08:00
|
|
|
function handleSend() {
|
|
|
|
|
const text = inputText.value.trim()
|
2026-05-09 08:36:13 +08:00
|
|
|
if (!text && attachments.value.length === 0) return
|
2026-04-11 15:59:14 +08:00
|
|
|
|
2026-04-11 18:54:46 +08:00
|
|
|
chatStore.sendMessage(text, attachments.value.length > 0 ? attachments.value : undefined)
|
2026-04-11 15:59:14 +08:00
|
|
|
inputText.value = ''
|
2026-04-11 18:54:46 +08:00
|
|
|
attachments.value = []
|
2026-04-11 15:59:14 +08:00
|
|
|
|
|
|
|
|
if (textareaRef.value) {
|
|
|
|
|
textareaRef.value.style.height = 'auto'
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2026-04-13 17:48:47 +08:00
|
|
|
function handleCompositionStart() {
|
|
|
|
|
isComposing.value = true
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function handleCompositionEnd() {
|
|
|
|
|
requestAnimationFrame(() => {
|
|
|
|
|
isComposing.value = false
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function isImeEnter(e: KeyboardEvent): boolean {
|
|
|
|
|
return isComposing.value || e.isComposing || e.keyCode === 229
|
|
|
|
|
}
|
|
|
|
|
|
2026-04-11 15:59:14 +08:00
|
|
|
function handleKeydown(e: KeyboardEvent) {
|
2026-04-13 17:48:47 +08:00
|
|
|
if (e.key !== 'Enter' || e.shiftKey) return
|
|
|
|
|
if (isImeEnter(e)) return
|
|
|
|
|
|
|
|
|
|
e.preventDefault()
|
|
|
|
|
handleSend()
|
2026-04-11 15:59:14 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function handleInput(e: Event) {
|
|
|
|
|
const el = e.target as HTMLTextAreaElement
|
|
|
|
|
el.style.height = 'auto'
|
|
|
|
|
el.style.height = Math.min(el.scrollHeight, 100) + 'px'
|
|
|
|
|
}
|
2026-04-11 18:54:46 +08:00
|
|
|
|
|
|
|
|
function removeAttachment(id: string) {
|
|
|
|
|
const idx = attachments.value.findIndex(a => a.id === id)
|
|
|
|
|
if (idx !== -1) {
|
|
|
|
|
URL.revokeObjectURL(attachments.value[idx].url)
|
|
|
|
|
attachments.value.splice(idx, 1)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function formatSize(bytes: number): string {
|
|
|
|
|
if (bytes < 1024) return bytes + ' B'
|
|
|
|
|
if (bytes < 1024 * 1024) return (bytes / 1024).toFixed(1) + ' KB'
|
|
|
|
|
return (bytes / (1024 * 1024)).toFixed(1) + ' MB'
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function isImage(type: string): boolean {
|
|
|
|
|
return type.startsWith('image/')
|
|
|
|
|
}
|
2026-04-11 15:59:14 +08:00
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
<template>
|
|
|
|
|
<div class="chat-input-area">
|
2026-05-02 13:26:57 +08:00
|
|
|
<!-- Top bar: attach + auto play speech + context info -->
|
2026-04-22 16:14:50 +08:00
|
|
|
<div class="input-top-bar">
|
|
|
|
|
<NTooltip trigger="hover">
|
|
|
|
|
<template #trigger>
|
|
|
|
|
<NButton quaternary size="tiny" @click="handleAttachClick" circle>
|
|
|
|
|
<template #icon>
|
|
|
|
|
<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5"><path d="M21.44 11.05l-9.19 9.19a6 6 0 0 1-8.49-8.49l9.19-9.19a4 4 0 0 1 5.66 5.66l-9.2 9.19a2 2 0 0 1-2.83-2.83l8.49-8.48"/></svg>
|
|
|
|
|
</template>
|
|
|
|
|
</NButton>
|
|
|
|
|
</template>
|
|
|
|
|
{{ t('chat.attachFiles') }}
|
|
|
|
|
</NTooltip>
|
2026-05-02 13:26:57 +08:00
|
|
|
|
|
|
|
|
<div class="auto-play-speech-switch">
|
|
|
|
|
<NTooltip trigger="hover">
|
|
|
|
|
<template #trigger>
|
|
|
|
|
<div class="switch-label">
|
|
|
|
|
<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
|
|
|
|
|
<polygon points="5 3 19 12 5 21 5 3"/>
|
|
|
|
|
</svg>
|
|
|
|
|
</div>
|
|
|
|
|
</template>
|
|
|
|
|
{{ t('chat.autoPlaySpeech') }}
|
|
|
|
|
</NTooltip>
|
|
|
|
|
<NSwitch
|
|
|
|
|
size="small"
|
|
|
|
|
v-model:value="autoPlaySpeech"
|
|
|
|
|
:round="false"
|
|
|
|
|
/>
|
|
|
|
|
</div>
|
|
|
|
|
|
2026-04-22 16:14:50 +08:00
|
|
|
<span v-if="totalTokens > 0" class="context-info" :class="{ 'context-warning': usagePercent > 80 }">
|
2026-05-06 15:05:44 +08:00
|
|
|
{{ formatTokens(totalTokens) }} /
|
|
|
|
|
<NTooltip trigger="hover">
|
|
|
|
|
<template #trigger>
|
|
|
|
|
<span class="context-limit-editable" @click="handleEditContextLimit">
|
|
|
|
|
{{ formatTokens(contextLength) }}
|
|
|
|
|
</span>
|
|
|
|
|
</template>
|
|
|
|
|
<span>{{ t('chat.contextClickToEdit') }}</span>
|
|
|
|
|
</NTooltip>
|
|
|
|
|
· {{ t('chat.contextRemaining') }} {{ formatTokens(remainingTokens) }}
|
2026-04-22 16:14:50 +08:00
|
|
|
</span>
|
|
|
|
|
<div v-if="totalTokens > 0" class="context-bar">
|
|
|
|
|
<div
|
|
|
|
|
class="context-bar-fill"
|
|
|
|
|
:class="{
|
|
|
|
|
'context-bar-warn': usagePercent > 60 && usagePercent <= 80,
|
|
|
|
|
'context-bar-danger': usagePercent > 80,
|
|
|
|
|
}"
|
|
|
|
|
:style="{ width: `${usagePercent}%` }"
|
|
|
|
|
/>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
|
2026-04-11 18:54:46 +08:00
|
|
|
<!-- Attachment previews -->
|
|
|
|
|
<div v-if="attachments.length > 0" class="attachment-previews">
|
|
|
|
|
<div
|
|
|
|
|
v-for="att in attachments"
|
|
|
|
|
:key="att.id"
|
|
|
|
|
class="attachment-preview"
|
|
|
|
|
:class="{ image: isImage(att.type) }"
|
|
|
|
|
>
|
|
|
|
|
<template v-if="isImage(att.type)">
|
|
|
|
|
<img :src="att.url" :alt="att.name" class="attachment-thumb" />
|
|
|
|
|
</template>
|
|
|
|
|
<template v-else>
|
|
|
|
|
<div class="attachment-file">
|
|
|
|
|
<svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5"><path d="M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"/><polyline points="14 2 14 8 20 8"/></svg>
|
|
|
|
|
<span class="file-name">{{ att.name }}</span>
|
|
|
|
|
<span class="file-size">{{ formatSize(att.size) }}</span>
|
|
|
|
|
</div>
|
|
|
|
|
</template>
|
|
|
|
|
<button class="attachment-remove" @click="removeAttachment(att.id)">
|
|
|
|
|
<svg width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><line x1="18" y1="6" x2="6" y2="18"/><line x1="6" y1="6" x2="18" y2="18"/></svg>
|
|
|
|
|
</button>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
|
2026-04-12 23:23:50 +08:00
|
|
|
<div
|
|
|
|
|
class="input-wrapper"
|
|
|
|
|
:class="{ 'drag-over': isDragging }"
|
|
|
|
|
@dragover="handleDragOver"
|
|
|
|
|
@dragenter="handleDragEnter"
|
|
|
|
|
@dragleave="handleDragLeave"
|
|
|
|
|
@drop="handleDrop"
|
|
|
|
|
>
|
2026-04-11 18:54:46 +08:00
|
|
|
<input
|
|
|
|
|
ref="fileInputRef"
|
|
|
|
|
type="file"
|
|
|
|
|
multiple
|
|
|
|
|
class="file-input-hidden"
|
|
|
|
|
@change="handleFileChange"
|
|
|
|
|
/>
|
2026-04-11 15:59:14 +08:00
|
|
|
<textarea
|
|
|
|
|
ref="textareaRef"
|
|
|
|
|
v-model="inputText"
|
|
|
|
|
class="input-textarea"
|
2026-04-13 15:15:14 +08:00
|
|
|
:placeholder="t('chat.inputPlaceholder')"
|
2026-04-11 15:59:14 +08:00
|
|
|
rows="1"
|
|
|
|
|
@keydown="handleKeydown"
|
2026-04-13 17:48:47 +08:00
|
|
|
@compositionstart="handleCompositionStart"
|
|
|
|
|
@compositionend="handleCompositionEnd"
|
2026-04-11 15:59:14 +08:00
|
|
|
@input="handleInput"
|
2026-04-12 23:23:50 +08:00
|
|
|
@paste="handlePaste"
|
2026-04-11 15:59:14 +08:00
|
|
|
></textarea>
|
|
|
|
|
<div class="input-actions">
|
|
|
|
|
<NButton
|
|
|
|
|
v-if="chatStore.isStreaming"
|
|
|
|
|
size="small"
|
|
|
|
|
type="error"
|
2026-05-05 13:03:14 +08:00
|
|
|
:disabled="chatStore.isAborting"
|
2026-04-11 15:59:14 +08:00
|
|
|
@click="chatStore.stopStreaming()"
|
|
|
|
|
>
|
2026-04-13 15:15:14 +08:00
|
|
|
{{ t('chat.stop') }}
|
2026-04-11 15:59:14 +08:00
|
|
|
</NButton>
|
|
|
|
|
<NButton
|
|
|
|
|
size="small"
|
|
|
|
|
type="primary"
|
2026-05-07 10:34:58 +08:00
|
|
|
:disabled="!canSend"
|
2026-04-11 15:59:14 +08:00
|
|
|
@click="handleSend"
|
|
|
|
|
>
|
|
|
|
|
<template #icon>
|
|
|
|
|
<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><line x1="22" y1="2" x2="11" y2="13"/><polygon points="22 2 15 22 11 13 2 9 22 2"/></svg>
|
|
|
|
|
</template>
|
2026-04-13 15:15:14 +08:00
|
|
|
{{ t('chat.send') }}
|
2026-04-11 15:59:14 +08:00
|
|
|
</NButton>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
2026-05-06 15:05:44 +08:00
|
|
|
|
|
|
|
|
<!-- Context Length Edit Modal -->
|
|
|
|
|
<NModal
|
|
|
|
|
v-model:show="showContextEditModal"
|
|
|
|
|
:title="t('chat.contextEditTitle')"
|
|
|
|
|
:mask-closable="true"
|
|
|
|
|
preset="card"
|
|
|
|
|
style="width: 400px"
|
|
|
|
|
>
|
|
|
|
|
<div class="context-edit-content">
|
|
|
|
|
<p style="margin-bottom: 16px; color: #666;">
|
|
|
|
|
{{ t('chat.contextEditDesc') }}
|
|
|
|
|
</p>
|
|
|
|
|
<NInputNumber
|
|
|
|
|
v-model:value="editingContextLimit"
|
|
|
|
|
:min="1000"
|
|
|
|
|
:max="10000000"
|
|
|
|
|
:step="1000"
|
|
|
|
|
:show-button="false"
|
|
|
|
|
:placeholder="t('chat.contextEditPlaceholder')"
|
|
|
|
|
style="width: 100%"
|
|
|
|
|
>
|
|
|
|
|
<template #suffix>
|
|
|
|
|
<span style="color: #999;">tokens</span>
|
|
|
|
|
</template>
|
|
|
|
|
</NInputNumber>
|
|
|
|
|
<div style="margin-top: 12px; font-size: 12px; color: #999;">
|
|
|
|
|
{{ t('chat.contextEditHint') }}
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
<template #footer>
|
|
|
|
|
<div style="display: flex; justify-content: flex-end; gap: 8px;">
|
|
|
|
|
<NButton @click="showContextEditModal = false" :disabled="isSavingContextLimit">
|
|
|
|
|
{{ t('chat.contextEditCancel') }}
|
|
|
|
|
</NButton>
|
|
|
|
|
<NButton type="primary" @click="saveContextLimit" :loading="isSavingContextLimit">
|
|
|
|
|
{{ t('chat.contextEditSave') }}
|
|
|
|
|
</NButton>
|
|
|
|
|
</div>
|
|
|
|
|
</template>
|
|
|
|
|
</NModal>
|
2026-04-11 15:59:14 +08:00
|
|
|
</div>
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
<style scoped lang="scss">
|
|
|
|
|
@use '@/styles/variables' as *;
|
|
|
|
|
|
|
|
|
|
.chat-input-area {
|
|
|
|
|
padding: 12px 20px 16px;
|
|
|
|
|
border-top: 1px solid $border-color;
|
|
|
|
|
flex-shrink: 0;
|
|
|
|
|
}
|
|
|
|
|
|
2026-04-22 16:14:50 +08:00
|
|
|
.input-top-bar {
|
|
|
|
|
display: flex;
|
|
|
|
|
align-items: center;
|
|
|
|
|
gap: 8px;
|
|
|
|
|
padding: 0 0 6px;
|
|
|
|
|
}
|
|
|
|
|
|
2026-05-02 13:26:57 +08:00
|
|
|
.auto-play-speech-switch {
|
|
|
|
|
display: flex;
|
|
|
|
|
align-items: center;
|
|
|
|
|
gap: 6px;
|
|
|
|
|
padding: 0 8px;
|
|
|
|
|
border-left: 1px solid $border-light;
|
|
|
|
|
margin-left: 4px;
|
|
|
|
|
|
|
|
|
|
.switch-label {
|
|
|
|
|
display: flex;
|
|
|
|
|
align-items: center;
|
|
|
|
|
color: $text-muted;
|
|
|
|
|
font-size: 12px;
|
|
|
|
|
|
|
|
|
|
svg {
|
|
|
|
|
opacity: 0.7;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2026-04-22 16:14:50 +08:00
|
|
|
.context-info {
|
|
|
|
|
font-size: 11px;
|
|
|
|
|
color: $text-muted;
|
|
|
|
|
|
|
|
|
|
&.context-warning {
|
|
|
|
|
color: #e8a735;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2026-05-06 15:05:44 +08:00
|
|
|
.context-limit-editable {
|
|
|
|
|
cursor: pointer;
|
|
|
|
|
border-bottom: 1px dashed transparent;
|
|
|
|
|
transition: all 0.2s ease;
|
|
|
|
|
padding: 0 2px;
|
|
|
|
|
|
|
|
|
|
&:hover {
|
|
|
|
|
border-bottom-color: $text-muted;
|
|
|
|
|
background: rgba(128, 128, 128, 0.1);
|
|
|
|
|
border-radius: 2px;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2026-04-22 16:14:50 +08:00
|
|
|
.context-bar {
|
|
|
|
|
width: 60px;
|
|
|
|
|
height: 4px;
|
|
|
|
|
background: rgba(128, 128, 128, 0.2);
|
|
|
|
|
border-radius: 2px;
|
|
|
|
|
overflow: hidden;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.context-bar-fill {
|
|
|
|
|
height: 100%;
|
|
|
|
|
background: linear-gradient(90deg, rgba(128, 128, 128, 0.3), rgba(128, 128, 128, 0.6));
|
|
|
|
|
border-radius: 2px;
|
|
|
|
|
transition: width 0.3s ease;
|
|
|
|
|
|
|
|
|
|
&.context-bar-warn {
|
|
|
|
|
background: linear-gradient(90deg, #c98a1a, #e8a735);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
&.context-bar-danger {
|
|
|
|
|
background: linear-gradient(90deg, #c43a2a, #e85d4a);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2026-04-11 18:54:46 +08:00
|
|
|
.attachment-previews {
|
|
|
|
|
display: flex;
|
|
|
|
|
flex-wrap: wrap;
|
|
|
|
|
gap: 8px;
|
|
|
|
|
padding: 0 0 10px;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.attachment-preview {
|
|
|
|
|
position: relative;
|
|
|
|
|
border-radius: $radius-sm;
|
|
|
|
|
overflow: hidden;
|
|
|
|
|
background-color: $bg-secondary;
|
|
|
|
|
border: 1px solid $border-color;
|
|
|
|
|
|
|
|
|
|
&.image {
|
|
|
|
|
width: 64px;
|
|
|
|
|
height: 64px;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.attachment-thumb {
|
|
|
|
|
width: 100%;
|
|
|
|
|
height: 100%;
|
|
|
|
|
object-fit: cover;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.attachment-file {
|
|
|
|
|
display: flex;
|
|
|
|
|
flex-direction: column;
|
|
|
|
|
align-items: center;
|
|
|
|
|
justify-content: center;
|
|
|
|
|
gap: 2px;
|
|
|
|
|
padding: 8px 12px;
|
|
|
|
|
min-width: 80px;
|
|
|
|
|
max-width: 140px;
|
|
|
|
|
color: $text-secondary;
|
|
|
|
|
|
|
|
|
|
.file-name {
|
|
|
|
|
font-size: 11px;
|
|
|
|
|
white-space: nowrap;
|
|
|
|
|
overflow: hidden;
|
|
|
|
|
text-overflow: ellipsis;
|
|
|
|
|
max-width: 100%;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.file-size {
|
|
|
|
|
font-size: 10px;
|
|
|
|
|
color: $text-muted;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.attachment-remove {
|
|
|
|
|
position: absolute;
|
|
|
|
|
top: 2px;
|
|
|
|
|
right: 2px;
|
|
|
|
|
width: 18px;
|
|
|
|
|
height: 18px;
|
|
|
|
|
border-radius: 50%;
|
|
|
|
|
border: none;
|
|
|
|
|
background: rgba(0, 0, 0, 0.5);
|
2026-04-16 23:13:04 +08:00
|
|
|
color: var(--text-on-overlay);
|
2026-04-11 18:54:46 +08:00
|
|
|
display: flex;
|
|
|
|
|
align-items: center;
|
|
|
|
|
justify-content: center;
|
|
|
|
|
cursor: pointer;
|
|
|
|
|
opacity: 0;
|
|
|
|
|
transition: opacity $transition-fast;
|
|
|
|
|
|
|
|
|
|
.attachment-preview:hover & {
|
|
|
|
|
opacity: 1;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.file-input-hidden {
|
|
|
|
|
display: none;
|
|
|
|
|
}
|
|
|
|
|
|
2026-04-11 15:59:14 +08:00
|
|
|
.input-wrapper {
|
|
|
|
|
display: flex;
|
|
|
|
|
align-items: center;
|
|
|
|
|
gap: 10px;
|
|
|
|
|
background-color: $bg-input;
|
|
|
|
|
border: 1px solid $border-color;
|
|
|
|
|
border-radius: $radius-md;
|
|
|
|
|
padding: 10px 12px;
|
2026-04-17 08:37:57 +08:00
|
|
|
transition: border-color $transition-fast, background-color $transition-fast;
|
2026-04-11 15:59:14 +08:00
|
|
|
|
|
|
|
|
&:focus-within {
|
|
|
|
|
border-color: $accent-primary;
|
|
|
|
|
}
|
2026-04-17 08:37:57 +08:00
|
|
|
|
|
|
|
|
.dark & {
|
|
|
|
|
background-color: #333333;
|
|
|
|
|
}
|
2026-04-11 15:59:14 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.input-textarea {
|
|
|
|
|
flex: 1;
|
|
|
|
|
background: none;
|
|
|
|
|
border: none;
|
|
|
|
|
outline: none;
|
|
|
|
|
color: $text-primary;
|
|
|
|
|
font-family: $font-ui;
|
|
|
|
|
font-size: 14px;
|
|
|
|
|
line-height: 1.5;
|
|
|
|
|
resize: none;
|
|
|
|
|
max-height: 100px;
|
|
|
|
|
min-height: 20px;
|
|
|
|
|
overflow-y: auto;
|
|
|
|
|
|
|
|
|
|
&::placeholder {
|
|
|
|
|
color: $text-muted;
|
2026-04-15 10:28:53 +08:00
|
|
|
white-space: nowrap;
|
|
|
|
|
overflow: hidden;
|
|
|
|
|
text-overflow: ellipsis;
|
2026-04-11 15:59:14 +08:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.input-actions {
|
|
|
|
|
display: flex;
|
|
|
|
|
gap: 6px;
|
|
|
|
|
flex-shrink: 0;
|
|
|
|
|
align-items: center;
|
|
|
|
|
}
|
2026-04-12 23:23:50 +08:00
|
|
|
|
|
|
|
|
// Drag-over state
|
|
|
|
|
.input-wrapper.drag-over {
|
2026-04-16 23:13:04 +08:00
|
|
|
border-color: var(--accent-info);
|
2026-04-12 23:23:50 +08:00
|
|
|
border-style: dashed;
|
2026-04-16 23:13:04 +08:00
|
|
|
background-color: rgba(var(--accent-info-rgb), 0.04);
|
2026-04-12 23:23:50 +08:00
|
|
|
}
|
2026-04-11 15:59:14 +08:00
|
|
|
</style>
|