增加主题及企微
This commit is contained in:
1 parent
42e29fd747
commit
20271ada61
35 files changed
+2424
-523
No files matched your search
+175
-170
@@ -18,6 +18,7 @@ import { marked } from 'marked';
|
||||
import { useRoute, useRouter } from 'vue-router';
|
||||
import { config } from '../config';
|
||||
import FilePreviewModal from '../components/FilePreviewModal.vue';
|
||||
import ThemeToggleButton from '../components/ThemeToggleButton.vue';
|
||||
|
||||
const { t, locale } = useI18n();
|
||||
|
||||
@@ -432,143 +433,153 @@ const submitFeedback = async () => {
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="flex h-screen bg-white font-sans text-slate-800">
|
||||
<!-- Sidebar (History) -->
|
||||
<!-- Mobile Overlay -->
|
||||
<div
|
||||
v-if="isSidebarOpen"
|
||||
class="fixed inset-0 bg-slate-900/50 z-40 md:hidden backdrop-blur-sm transition-opacity"
|
||||
<div class="relative flex h-screen overflow-hidden bg-slate-50 text-slate-800 dark:bg-slate-950 dark:text-slate-100">
|
||||
<div class="pointer-events-none absolute inset-0">
|
||||
<div class="absolute -top-24 -left-20 h-80 w-80 rounded-full bg-cyan-300/30 blur-3xl dark:bg-cyan-500/18"></div>
|
||||
<div class="absolute right-0 top-20 h-72 w-72 rounded-full bg-blue-300/25 blur-3xl dark:bg-indigo-500/20"></div>
|
||||
<div class="absolute bottom-0 left-1/3 h-64 w-64 rounded-full bg-sky-200/25 blur-3xl dark:bg-blue-600/18"></div>
|
||||
</div>
|
||||
|
||||
<div
|
||||
v-if="isSidebarOpen"
|
||||
class="fixed inset-0 z-40 bg-slate-900/55 backdrop-blur-sm transition-opacity md:hidden"
|
||||
@click="isSidebarOpen = false"
|
||||
></div>
|
||||
|
||||
<aside
|
||||
class="w-72 bg-slate-50 border-r border-slate-200 flex flex-col fixed inset-y-0 left-0 z-50 transition-transform duration-300 ease-in-out md:relative md:translate-x-0 shadow-xl md:shadow-none"
|
||||
<aside
|
||||
class="glass-panel fixed inset-y-0 left-0 z-50 flex w-80 flex-col border-r transition-transform duration-300 ease-in-out md:relative md:translate-x-0"
|
||||
:class="isSidebarOpen ? 'translate-x-0' : '-translate-x-full'"
|
||||
>
|
||||
<div class="p-4 flex items-center justify-between">
|
||||
<button @click="router.push('/workspace')" class="p-2 hover:bg-white hover:shadow-sm rounded-xl transition-all text-slate-500 hover:text-slate-900" title="Back to Workspace">
|
||||
<ArrowLeft class="w-5 h-5" />
|
||||
</button>
|
||||
<span class="font-bold text-slate-700 tracking-tight">{{ $t('chat.history') }}</span>
|
||||
<button class="p-2 hover:bg-brand-100 hover:text-brand-600 rounded-xl transition-all text-slate-500" title="New Chat" @click="startNewChat(); isSidebarOpen = false;">
|
||||
<Plus class="w-5 h-5" />
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<div class="px-3 pb-2">
|
||||
<button @click="startNewChat(); isSidebarOpen = false;" class="w-full py-2.5 px-4 bg-brand-600 hover:bg-brand-700 text-white rounded-xl font-medium shadow-lg shadow-brand-500/20 transition-all flex items-center justify-center gap-2 mb-2">
|
||||
<Plus class="w-4 h-4" /> {{ $t('chat.newChat') }}
|
||||
<div class="border-b border-slate-200/70 p-4 dark:border-slate-700/70">
|
||||
<div class="flex items-center justify-between">
|
||||
<button @click="router.push('/workspace')" class="rounded-xl p-2 text-slate-500 transition-all hover:bg-white/80 hover:text-slate-900 dark:text-slate-300 dark:hover:bg-slate-800/80 dark:hover:text-slate-100" title="Back to Workspace">
|
||||
<ArrowLeft class="h-5 w-5" />
|
||||
</button>
|
||||
<span class="text-sm font-semibold uppercase tracking-[0.14em] text-slate-500 dark:text-slate-300">{{ $t('chat.history') }}</span>
|
||||
<ThemeToggleButton />
|
||||
</div>
|
||||
<button @click="startNewChat(); isSidebarOpen = false;" class="mt-4 flex w-full items-center justify-center gap-2 rounded-2xl bg-gradient-to-r from-cyan-600 to-blue-600 px-4 py-3 text-sm font-semibold text-white shadow-lg shadow-cyan-500/30 transition-all hover:from-cyan-500 hover:to-blue-500">
|
||||
<Plus class="h-4 w-4" /> {{ $t('chat.newChat') }}
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<div class="flex-1 overflow-y-auto px-3 space-y-1 scrollbar-thin">
|
||||
<div v-if="history.length === 0" class="text-center text-slate-400 text-sm py-8 italic">{{ $t('chat.noHistory') }}</div>
|
||||
<div class="flex-1 space-y-1 overflow-y-auto px-3 py-3 scrollbar-thin">
|
||||
<div v-if="history.length === 0" class="py-10 text-center text-sm italic text-slate-400">{{ $t('chat.noHistory') }}</div>
|
||||
<button
|
||||
v-for="item in history"
|
||||
:key="item.conversation_id"
|
||||
class="w-full text-left px-4 py-3 rounded-xl text-sm text-slate-600 hover:bg-white hover:shadow-sm truncate transition-all border border-transparent hover:border-slate-100"
|
||||
:class="conversationId === item.conversation_id ? 'bg-white shadow-sm border-slate-100 text-brand-600 font-medium ring-1 ring-brand-500/10' : ''"
|
||||
class="w-full truncate rounded-xl border px-4 py-3 text-left text-sm transition-all"
|
||||
:class="conversationId === item.conversation_id
|
||||
? 'border-cyan-300/70 bg-cyan-50/80 font-semibold text-cyan-700 shadow-sm dark:border-cyan-500/30 dark:bg-cyan-500/10 dark:text-cyan-200'
|
||||
: 'border-transparent bg-white/50 text-slate-600 hover:border-slate-200 hover:bg-white/90 hover:text-slate-900 dark:bg-slate-900/30 dark:text-slate-300 dark:hover:border-slate-700 dark:hover:bg-slate-800/70 dark:hover:text-slate-100'"
|
||||
@click="loadConversation(item.conversation_id); isSidebarOpen = false;"
|
||||
>
|
||||
{{ item.title || $t('chat.newChat') }}
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<!-- Language Selector & Agent Info -->
|
||||
<div class="p-4 border-t border-slate-200 bg-slate-50 space-y-3">
|
||||
<select
|
||||
v-model="locale"
|
||||
class="w-full bg-white border border-slate-200 rounded-xl px-3 py-2 text-sm shadow-sm outline-none focus:ring-2 focus:ring-brand-500/20 focus:border-brand-500 transition-all cursor-pointer"
|
||||
>
|
||||
<option value="en">English</option>
|
||||
<option value="zh-CN">简体中文</option>
|
||||
<option value="zh-TW">繁體中文</option>
|
||||
<option value="th">ไทย</option>
|
||||
</select>
|
||||
<div class="flex items-center justify-center gap-2 text-xs text-slate-400 font-mono bg-slate-100 py-1.5 rounded-lg">
|
||||
<span class="w-1.5 h-1.5 rounded-full bg-green-500"></span>
|
||||
{{ $t('chat.agentId') }} {{ agentId }}
|
||||
</div>
|
||||
|
||||
<div class="space-y-3 border-t border-slate-200/70 bg-white/35 p-4 dark:border-slate-700/70 dark:bg-slate-900/35">
|
||||
<select
|
||||
v-model="locale"
|
||||
class="w-full rounded-xl border border-slate-200 bg-white/90 px-3 py-2 text-sm shadow-sm outline-none transition-all focus:border-cyan-500 focus:ring-2 focus:ring-cyan-500/20 dark:border-slate-700 dark:bg-slate-900/80"
|
||||
>
|
||||
<option value="en">English</option>
|
||||
<option value="zh-CN">简体中文</option>
|
||||
<option value="zh-TW">繁體中文</option>
|
||||
<option value="th">ไทย</option>
|
||||
</select>
|
||||
<div class="flex items-center justify-center gap-2 rounded-lg bg-slate-100/90 py-1.5 font-mono text-xs text-slate-500 dark:bg-slate-800/85 dark:text-slate-300">
|
||||
<span class="h-1.5 w-1.5 rounded-full bg-emerald-500"></span>
|
||||
{{ $t('chat.agentId') }} {{ agentId }}
|
||||
</div>
|
||||
</div>
|
||||
</aside>
|
||||
|
||||
<!-- Main Chat Area -->
|
||||
<div class="flex-1 flex flex-col h-full relative w-full md:w-auto overflow-hidden bg-white">
|
||||
<!-- Mobile Header -->
|
||||
<header class="md:hidden bg-white/80 backdrop-blur-md border-b border-slate-100 px-4 py-3 flex items-center justify-between shrink-0 z-30 sticky top-0">
|
||||
<div class="relative z-10 flex h-full w-full flex-1 flex-col overflow-hidden">
|
||||
<header class="sticky top-0 z-30 flex shrink-0 items-center justify-between border-b border-slate-200/70 bg-white/70 px-4 py-3 backdrop-blur-xl dark:border-slate-700/70 dark:bg-slate-950/65 md:px-6">
|
||||
<div class="flex items-center gap-3">
|
||||
<button @click="router.push('/workspace')" class="p-2 hover:bg-slate-50 rounded-lg transition-colors">
|
||||
<ArrowLeft class="w-5 h-5 text-slate-600" />
|
||||
<button @click="isSidebarOpen = !isSidebarOpen" class="rounded-lg p-2 transition-colors hover:bg-slate-100 dark:hover:bg-slate-800 md:hidden">
|
||||
<Menu class="h-5 w-5 text-slate-600 dark:text-slate-300" />
|
||||
</button>
|
||||
<span class="font-bold text-slate-900 truncate max-w-[200px]">{{ currentAgent?.name || $t('chat.defaultTitle') }}</span>
|
||||
<button @click="router.push('/workspace')" class="hidden rounded-lg p-2 transition-colors hover:bg-slate-100 dark:hover:bg-slate-800 md:inline-flex">
|
||||
<ArrowLeft class="h-5 w-5 text-slate-600 dark:text-slate-300" />
|
||||
</button>
|
||||
<div>
|
||||
<p class="font-semibold tracking-tight text-slate-900 dark:text-slate-100">{{ currentAgent?.name || $t('chat.defaultTitle') }}</p>
|
||||
<p class="text-xs text-slate-500 dark:text-slate-400">HXOPS AI Assistant</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="flex items-center gap-2">
|
||||
<button @click="startNewChat" class="hidden items-center gap-1 rounded-xl border border-slate-200 bg-white/80 px-3 py-2 text-xs font-semibold text-slate-600 transition-colors hover:border-cyan-300 hover:text-cyan-700 dark:border-slate-700 dark:bg-slate-900/70 dark:text-slate-200 dark:hover:border-cyan-500/40 dark:hover:text-cyan-200 md:flex">
|
||||
<Plus class="h-4 w-4" />
|
||||
{{ $t('chat.newChat') }}
|
||||
</button>
|
||||
<ThemeToggleButton />
|
||||
</div>
|
||||
<button @click="isSidebarOpen = !isSidebarOpen" class="p-2 hover:bg-slate-50 rounded-lg transition-colors">
|
||||
<Menu class="w-6 h-6 text-slate-600" />
|
||||
</button>
|
||||
</header>
|
||||
|
||||
<!-- Chat Content -->
|
||||
<div v-if="!currentAgent" class="flex-1 flex flex-col items-center justify-center space-y-4">
|
||||
<Loader2 class="w-10 h-10 animate-spin text-brand-500" />
|
||||
<p class="text-slate-400 text-sm animate-pulse">{{ $t('chat.loadingAgent') }}</p>
|
||||
<div v-if="!currentAgent" class="flex flex-1 flex-col items-center justify-center space-y-4">
|
||||
<Loader2 class="h-10 w-10 animate-spin text-cyan-500" />
|
||||
<p class="text-sm animate-pulse text-slate-500 dark:text-slate-300">{{ $t('chat.loadingAgent') }}</p>
|
||||
</div>
|
||||
|
||||
<div v-else-if="currentAgent.type === 'iframe'" class="flex-1 w-full h-full bg-white relative">
|
||||
<iframe
|
||||
:src="currentAgent.extra_config?.iframe_url"
|
||||
class="w-full h-full border-0"
|
||||
<div v-else-if="currentAgent.type === 'iframe'" class="relative h-full w-full flex-1">
|
||||
<iframe
|
||||
:src="currentAgent.extra_config?.iframe_url"
|
||||
class="h-full w-full border-0 bg-white dark:bg-slate-950"
|
||||
allow="microphone; camera; clipboard-read; clipboard-write"
|
||||
></iframe>
|
||||
</div>
|
||||
|
||||
<template v-else>
|
||||
<main class="flex-1 overflow-y-auto p-4 md:p-8 space-y-8 scroll-smooth scrollbar-thin">
|
||||
<div v-if="messages.length === 0" class="flex flex-col items-center justify-center h-full text-slate-400 pb-20">
|
||||
<div class="w-20 h-20 bg-gradient-to-br from-brand-500 to-brand-700 rounded-3xl flex items-center justify-center mb-8 shadow-xl shadow-brand-500/20 animate-fade-in">
|
||||
<Bot class="text-white w-10 h-10" />
|
||||
<main class="flex-1 space-y-8 overflow-y-auto p-4 scrollbar-thin md:p-8">
|
||||
<div v-if="messages.length === 0" class="flex h-full flex-col items-center justify-center pb-20 text-slate-400">
|
||||
<div class="mb-8 flex h-24 w-24 items-center justify-center rounded-3xl bg-gradient-to-br from-cyan-500 via-blue-600 to-indigo-600 shadow-2xl shadow-cyan-500/30">
|
||||
<Bot class="h-10 w-10 text-white" />
|
||||
</div>
|
||||
<h2 class="text-3xl font-bold text-slate-900 mb-3 tracking-tight">{{ $t('chat.welcome.title') }}</h2>
|
||||
<p class="text-slate-500 text-lg max-w-md text-center leading-relaxed">{{ $t('chat.welcome.subtitle') }}</p>
|
||||
|
||||
<div class="grid grid-cols-1 md:grid-cols-2 gap-4 mt-12 w-full max-w-2xl">
|
||||
<button v-for="suggestion in (currentAgent.suggested_questions && currentAgent.suggested_questions.length > 0 ? currentAgent.suggested_questions : [
|
||||
$t('chat.suggestions.whatCanYouDo'),
|
||||
$t('chat.suggestions.helpWriteReport'),
|
||||
$t('chat.suggestions.analyzeData'),
|
||||
$t('chat.suggestions.creativeWriting')
|
||||
])"
|
||||
:key="suggestion"
|
||||
@click="input = suggestion; handleSend()"
|
||||
class="p-4 bg-white border border-slate-200 rounded-xl hover:border-brand-400 hover:shadow-md hover:text-brand-700 text-slate-600 text-sm font-medium transition-all text-left">
|
||||
{{ suggestion }}
|
||||
</button>
|
||||
<h2 class="mb-3 text-center text-3xl font-bold tracking-tight text-slate-900 dark:text-slate-100">{{ $t('chat.welcome.title') }}</h2>
|
||||
<p class="max-w-xl text-center text-base leading-relaxed text-slate-500 dark:text-slate-300">{{ $t('chat.welcome.subtitle') }}</p>
|
||||
|
||||
<div class="mt-12 grid w-full max-w-3xl grid-cols-1 gap-4 md:grid-cols-2">
|
||||
<button v-for="suggestion in (currentAgent.suggested_questions && currentAgent.suggested_questions.length > 0 ? currentAgent.suggested_questions : [
|
||||
$t('chat.suggestions.whatCanYouDo'),
|
||||
$t('chat.suggestions.helpWriteReport'),
|
||||
$t('chat.suggestions.analyzeData'),
|
||||
$t('chat.suggestions.creativeWriting')
|
||||
])"
|
||||
:key="suggestion"
|
||||
@click="input = suggestion; handleSend()"
|
||||
class="rounded-2xl border border-slate-200 bg-white/90 p-4 text-left text-sm font-semibold text-slate-600 shadow-sm transition-all hover:-translate-y-0.5 hover:border-cyan-300 hover:text-cyan-700 hover:shadow-lg dark:border-slate-700 dark:bg-slate-900/70 dark:text-slate-200 dark:hover:border-cyan-500/40 dark:hover:text-cyan-200"
|
||||
>
|
||||
{{ suggestion }}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div
|
||||
v-for="(msg, index) in messages"
|
||||
<div
|
||||
v-for="(msg, index) in messages"
|
||||
:key="index"
|
||||
class="flex gap-4 max-w-4xl mx-auto group animate-slide-up"
|
||||
class="group mx-auto flex max-w-5xl gap-4 animate-slide-up"
|
||||
:class="msg.role === 'user' ? 'justify-end' : ''"
|
||||
>
|
||||
<!-- Bot Avatar -->
|
||||
<div v-if="msg.role === 'assistant'" class="w-10 h-10 rounded-xl bg-gradient-to-br from-brand-500 to-brand-700 flex items-center justify-center shrink-0 shadow-sm mt-1">
|
||||
<Bot class="text-white w-6 h-6" />
|
||||
<div v-if="msg.role === 'assistant'" class="mt-1 flex h-10 w-10 shrink-0 items-center justify-center rounded-xl bg-gradient-to-br from-cyan-500 to-blue-600 shadow-md shadow-cyan-500/30">
|
||||
<Bot class="h-5 w-5 text-white" />
|
||||
</div>
|
||||
|
||||
<!-- Message Bubble -->
|
||||
<div class="flex flex-col max-w-[85%] md:max-w-[75%]">
|
||||
<div
|
||||
class="py-3.5 px-6 rounded-2xl shadow-sm leading-relaxed text-[15px]"
|
||||
:class="msg.role === 'user' ? 'bg-brand-600 text-white rounded-tr-sm shadow-brand-500/20' : 'bg-white border border-slate-100 text-slate-800 rounded-tl-sm shadow-slate-200/50'"
|
||||
<div class="flex max-w-[88%] flex-col md:max-w-[74%]">
|
||||
<div
|
||||
class="rounded-2xl px-6 py-4 text-[15px] leading-relaxed shadow-md"
|
||||
:class="msg.role === 'user'
|
||||
? 'rounded-tr-md border border-cyan-400/20 bg-gradient-to-br from-cyan-600 via-blue-600 to-indigo-600 text-white shadow-cyan-500/35'
|
||||
: 'rounded-tl-md border border-slate-200 bg-white/95 text-slate-800 shadow-slate-300/30 dark:border-slate-700 dark:bg-slate-900/85 dark:text-slate-100'"
|
||||
>
|
||||
<div
|
||||
<div
|
||||
v-if="msg.role === 'user'"
|
||||
class="whitespace-pre-wrap prose prose-sm max-w-none text-white prose-invert"
|
||||
class="prose prose-sm max-w-none whitespace-pre-wrap text-white prose-invert"
|
||||
>{{ msg.content }}</div>
|
||||
<div
|
||||
<div
|
||||
v-else
|
||||
class="prose prose-sm max-w-none text-slate-800 prose-headings:font-bold prose-a:text-brand-600 prose-code:bg-slate-100 prose-code:text-brand-600 prose-code:px-1 prose-code:rounded prose-pre:bg-slate-800 prose-pre:text-slate-100"
|
||||
class="prose prose-sm max-w-none text-slate-800 dark:text-slate-100 prose-a:text-cyan-600 dark:prose-a:text-cyan-300 prose-code:rounded prose-code:bg-slate-100 prose-code:px-1 prose-code:text-cyan-700 dark:prose-code:bg-slate-800 dark:prose-code:text-cyan-300 prose-pre:border prose-pre:border-slate-700 prose-pre:bg-slate-900 prose-pre:text-slate-100"
|
||||
v-html="renderMarkdown(msg.content)"
|
||||
></div>
|
||||
</div>
|
||||
@@ -577,15 +588,12 @@ const submitFeedback = async () => {
|
||||
v-if="msg.role === 'assistant' && ((msg.retriever_resources && msg.retriever_resources.length > 0) || (msg.attribution_parts && msg.attribution_parts.length > 0) || getMessageLinks(msg).length > 0)"
|
||||
class="mt-2 space-y-2"
|
||||
>
|
||||
<div
|
||||
v-if="getMessageLinks(msg).length > 0"
|
||||
class="flex flex-wrap gap-2"
|
||||
>
|
||||
<div v-if="getMessageLinks(msg).length > 0" class="flex flex-wrap gap-2">
|
||||
<button
|
||||
v-for="(file, linkIndex) in getMessageLinks(msg)"
|
||||
:key="`src-link-top-${linkIndex}-${file.url}`"
|
||||
@click="openPreview(file)"
|
||||
class="text-xs px-2.5 py-1.5 rounded-lg bg-brand-50 border border-brand-200 text-brand-700 hover:bg-brand-100 transition-colors break-all"
|
||||
class="break-all rounded-lg border border-cyan-200 bg-cyan-50 px-2.5 py-1.5 text-xs text-cyan-700 transition-colors hover:bg-cyan-100 dark:border-cyan-500/30 dark:bg-cyan-500/10 dark:text-cyan-200 dark:hover:bg-cyan-500/20"
|
||||
>
|
||||
{{ file.name }}
|
||||
</button>
|
||||
@@ -593,137 +601,135 @@ const submitFeedback = async () => {
|
||||
|
||||
<details
|
||||
v-if="msg.retriever_resources && msg.retriever_resources.length > 0"
|
||||
class="bg-slate-50 border border-slate-200 rounded-xl px-4 py-3"
|
||||
class="rounded-xl border border-slate-200 bg-slate-50/90 px-4 py-3 dark:border-slate-700 dark:bg-slate-800/65"
|
||||
>
|
||||
<summary class="cursor-pointer text-xs font-semibold tracking-wide text-slate-600 uppercase">
|
||||
<summary class="cursor-pointer text-xs font-semibold uppercase tracking-wide text-slate-600 dark:text-slate-300">
|
||||
源文档 ({{ msg.retriever_resources.length }})
|
||||
</summary>
|
||||
<div class="mt-3 space-y-2">
|
||||
<div
|
||||
v-for="(doc, docIndex) in msg.retriever_resources"
|
||||
:key="`${doc.document_name || 'doc'}-${doc.segment_id || docIndex}`"
|
||||
class="bg-white border border-slate-200 rounded-lg p-3"
|
||||
class="rounded-lg border border-slate-200 bg-white p-3 dark:border-slate-700 dark:bg-slate-900"
|
||||
>
|
||||
<div class="text-sm font-semibold text-slate-800 break-all">{{ getSourceTitle(doc) }}</div>
|
||||
<div v-if="getSourceMeta(doc)" class="text-xs text-slate-500 mt-1">{{ getSourceMeta(doc) }}</div>
|
||||
<div v-if="getSourceBrief(doc)" class="text-xs text-slate-600 mt-2 whitespace-pre-wrap break-all">{{ getSourceBrief(doc) }}</div>
|
||||
<div class="break-all text-sm font-semibold text-slate-800 dark:text-slate-100">{{ getSourceTitle(doc) }}</div>
|
||||
<div v-if="getSourceMeta(doc)" class="mt-1 text-xs text-slate-500 dark:text-slate-400">{{ getSourceMeta(doc) }}</div>
|
||||
<div v-if="getSourceBrief(doc)" class="mt-2 whitespace-pre-wrap break-all text-xs text-slate-600 dark:text-slate-300">{{ getSourceBrief(doc) }}</div>
|
||||
</div>
|
||||
</div>
|
||||
</details>
|
||||
|
||||
<details
|
||||
v-if="msg.attribution_parts && msg.attribution_parts.length > 0"
|
||||
class="bg-slate-50 border border-slate-200 rounded-xl px-4 py-3"
|
||||
class="rounded-xl border border-slate-200 bg-slate-50/90 px-4 py-3 dark:border-slate-700 dark:bg-slate-800/65"
|
||||
open
|
||||
>
|
||||
<summary class="cursor-pointer text-xs font-semibold tracking-wide text-slate-600 uppercase">
|
||||
<summary class="cursor-pointer text-xs font-semibold uppercase tracking-wide text-slate-600 dark:text-slate-300">
|
||||
生成内容归属部分
|
||||
</summary>
|
||||
<ul class="mt-3 space-y-2">
|
||||
<li
|
||||
v-for="(part, partIndex) in msg.attribution_parts"
|
||||
:key="`attr-${partIndex}`"
|
||||
class="text-xs text-slate-700 bg-white border border-slate-200 rounded-lg p-3 whitespace-pre-wrap break-all"
|
||||
class="rounded-lg border border-slate-200 bg-white p-3 text-xs text-slate-700 dark:border-slate-700 dark:bg-slate-900 dark:text-slate-300"
|
||||
>
|
||||
{{ part }}
|
||||
</li>
|
||||
</ul>
|
||||
</details>
|
||||
</div>
|
||||
|
||||
<!-- Message Actions -->
|
||||
<div
|
||||
class="flex items-center gap-1 mt-1 opacity-0 group-hover:opacity-100 transition-opacity"
|
||||
:class="msg.role === 'user' ? 'justify-end text-slate-400' : 'justify-start text-slate-400'"
|
||||
|
||||
<div
|
||||
class="mt-1 flex items-center gap-1 opacity-0 transition-opacity group-hover:opacity-100"
|
||||
:class="msg.role === 'user' ? 'justify-end text-slate-500' : 'justify-start text-slate-500'"
|
||||
>
|
||||
<button
|
||||
@click="copyToClipboard(msg.content, index)"
|
||||
class="p-1 hover:bg-slate-100 rounded text-xs flex items-center gap-1 transition-colors"
|
||||
<button
|
||||
@click="copyToClipboard(msg.content, index)"
|
||||
class="rounded-md p-1.5 text-xs transition-colors hover:bg-slate-100 dark:hover:bg-slate-800"
|
||||
:title="$t('chat.actions.copy')"
|
||||
>
|
||||
<Check v-if="copiedIndex === index" class="w-3.5 h-3.5 text-green-500" />
|
||||
<Copy v-else class="w-3.5 h-3.5" />
|
||||
<Check v-if="copiedIndex === index" class="h-3.5 w-3.5 text-emerald-500" />
|
||||
<Copy v-else class="h-3.5 w-3.5" />
|
||||
</button>
|
||||
|
||||
|
||||
<template v-if="msg.role === 'user'">
|
||||
<button
|
||||
@click="input = msg.content"
|
||||
class="p-1 hover:bg-slate-100 rounded text-xs transition-colors"
|
||||
<button
|
||||
@click="input = msg.content"
|
||||
class="rounded-md p-1.5 text-xs transition-colors hover:bg-slate-100 dark:hover:bg-slate-800"
|
||||
:title="$t('chat.actions.edit')"
|
||||
>
|
||||
<Edit2 class="w-3.5 h-3.5" />
|
||||
<Edit2 class="h-3.5 w-3.5" />
|
||||
</button>
|
||||
<button
|
||||
@click="handleSend(msg.content)"
|
||||
class="p-1 hover:bg-slate-100 rounded text-xs transition-colors"
|
||||
<button
|
||||
@click="handleSend(msg.content)"
|
||||
class="rounded-md p-1.5 text-xs transition-colors hover:bg-slate-100 dark:hover:bg-slate-800"
|
||||
:title="$t('chat.actions.resend')"
|
||||
>
|
||||
<RotateCw class="w-3.5 h-3.5" />
|
||||
<RotateCw class="h-3.5 w-3.5" />
|
||||
</button>
|
||||
</template>
|
||||
|
||||
|
||||
<template v-else>
|
||||
<button
|
||||
<button
|
||||
v-if="index === messages.length - 1 && !isThinking"
|
||||
@click="regenerate"
|
||||
class="p-1 hover:bg-slate-100 rounded text-xs transition-colors"
|
||||
@click="regenerate"
|
||||
class="rounded-md p-1.5 text-xs transition-colors hover:bg-slate-100 dark:hover:bg-slate-800"
|
||||
:title="$t('chat.actions.regenerate')"
|
||||
>
|
||||
<RotateCw class="w-3.5 h-3.5" />
|
||||
<RotateCw class="h-3.5 w-3.5" />
|
||||
</button>
|
||||
</template>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- User Avatar -->
|
||||
<div v-if="msg.role === 'user'" class="w-10 h-10 rounded-xl bg-slate-200 flex items-center justify-center shrink-0 shadow-sm mt-1">
|
||||
<User class="text-slate-500 w-6 h-6" />
|
||||
<div v-if="msg.role === 'user'" class="mt-1 flex h-10 w-10 shrink-0 items-center justify-center rounded-xl border border-slate-200 bg-white shadow-sm dark:border-slate-700 dark:bg-slate-900">
|
||||
<User class="h-5 w-5 text-slate-500 dark:text-slate-300" />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Loading -->
|
||||
<div v-if="isThinking" class="flex gap-4 max-w-4xl mx-auto animate-pulse">
|
||||
<div class="w-10 h-10 rounded-xl bg-gradient-to-br from-brand-500 to-brand-700 flex items-center justify-center shrink-0 shadow-sm mt-1">
|
||||
<Bot class="text-white w-6 h-6" />
|
||||
</div>
|
||||
<div class="py-3 px-5 bg-white border border-slate-100 rounded-2xl rounded-tl-sm shadow-sm flex items-center gap-3">
|
||||
<div class="flex gap-1">
|
||||
<span class="w-2 h-2 bg-brand-400 rounded-full animate-bounce"></span>
|
||||
<span class="w-2 h-2 bg-brand-400 rounded-full animate-bounce delay-75"></span>
|
||||
<span class="w-2 h-2 bg-brand-400 rounded-full animate-bounce delay-150"></span>
|
||||
</div>
|
||||
<span class="text-slate-400 text-sm font-medium">{{ $t('chat.thinking') }}</span>
|
||||
</div>
|
||||
|
||||
<div v-if="isThinking" class="mx-auto flex max-w-5xl gap-4">
|
||||
<div class="mt-1 flex h-10 w-10 shrink-0 items-center justify-center rounded-xl bg-gradient-to-br from-cyan-500 to-blue-600 shadow-md shadow-cyan-500/30">
|
||||
<Bot class="h-5 w-5 text-white" />
|
||||
</div>
|
||||
<div class="flex items-center gap-3 rounded-2xl rounded-tl-md border border-slate-200 bg-white/95 px-5 py-3 shadow-md dark:border-slate-700 dark:bg-slate-900/85">
|
||||
<div class="flex gap-1">
|
||||
<span class="h-2 w-2 animate-bounce rounded-full bg-cyan-400"></span>
|
||||
<span class="h-2 w-2 animate-bounce rounded-full bg-cyan-400 delay-75"></span>
|
||||
<span class="h-2 w-2 animate-bounce rounded-full bg-cyan-400 delay-150"></span>
|
||||
</div>
|
||||
<span class="text-sm font-medium text-slate-500 dark:text-slate-300">{{ $t('chat.thinking') }}</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Feedback -->
|
||||
<div
|
||||
v-if="enableFeedback && messages.length > 0 && !isThinking"
|
||||
class="max-w-4xl mx-auto mt-8 pt-8 border-t border-slate-100"
|
||||
class="mx-auto mt-8 max-w-5xl border-t border-slate-200/80 pt-8 dark:border-slate-700/70"
|
||||
>
|
||||
<div class="flex flex-col items-center gap-4 bg-slate-50 p-6 rounded-2xl border border-slate-100">
|
||||
<span class="text-sm font-medium text-slate-500">{{ $t('chat.rate') }}</span>
|
||||
<div class="glass-panel flex flex-col items-center gap-4 rounded-2xl p-6">
|
||||
<span class="text-sm font-medium text-slate-600 dark:text-slate-300">{{ $t('chat.rate') }}</span>
|
||||
<div class="flex gap-3">
|
||||
<button
|
||||
v-for="n in 5"
|
||||
:key="n"
|
||||
class="w-10 h-10 rounded-full flex items-center justify-center transition-all duration-200"
|
||||
:class="rating && n <= rating ? 'bg-yellow-400 text-white scale-110 shadow-md shadow-yellow-400/30' : 'bg-white border border-slate-200 text-slate-400 hover:border-yellow-400 hover:text-yellow-400'"
|
||||
class="flex h-10 w-10 items-center justify-center rounded-full border transition-all duration-200"
|
||||
:class="rating && n <= rating
|
||||
? 'scale-110 border-yellow-300 bg-yellow-400 text-white shadow-lg shadow-yellow-400/35'
|
||||
: 'border-slate-200 bg-white text-slate-500 hover:border-yellow-400 hover:text-yellow-500 dark:border-slate-700 dark:bg-slate-900 dark:text-slate-300'"
|
||||
@click="rating = n"
|
||||
>
|
||||
<Star v-if="rating && n <= rating" class="w-5 h-5 fill-current" />
|
||||
<Star v-if="rating && n <= rating" class="h-5 w-5 fill-current" />
|
||||
<span v-else class="text-sm font-bold">{{ n }}</span>
|
||||
</button>
|
||||
</div>
|
||||
<div v-if="rating" class="w-full max-w-lg flex gap-3 mt-2 animate-fade-in">
|
||||
<div v-if="rating" class="mt-2 flex w-full max-w-lg gap-3 animate-fade-in">
|
||||
<input
|
||||
v-model="feedbackComment"
|
||||
type="text"
|
||||
class="flex-1 input-field py-2 text-sm"
|
||||
class="input-field flex-1 py-2 text-sm"
|
||||
:placeholder="$t('chat.feedback.commentPlaceholder')"
|
||||
/>
|
||||
<button
|
||||
class="px-6 py-2 bg-brand-600 text-white text-sm font-bold rounded-xl hover:bg-brand-700 disabled:opacity-50 transition-colors shadow-lg shadow-brand-500/30"
|
||||
class="rounded-xl bg-gradient-to-r from-cyan-600 to-blue-600 px-6 py-2 text-sm font-bold text-white shadow-lg shadow-cyan-500/35 transition-opacity hover:opacity-90 disabled:opacity-50"
|
||||
:disabled="feedbackSubmitted"
|
||||
@click="submitFeedback"
|
||||
>
|
||||
@@ -732,31 +738,30 @@ const submitFeedback = async () => {
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="h-24"></div> <!-- Spacer for fixed footer -->
|
||||
<div class="h-6 md:h-8"></div>
|
||||
</main>
|
||||
|
||||
<!-- Input Area -->
|
||||
<footer class="p-4 md:p-6 bg-white/80 backdrop-blur-xl border-t border-slate-100 absolute bottom-0 left-0 right-0 z-20">
|
||||
<div class="max-w-4xl mx-auto relative">
|
||||
<div class="relative bg-white rounded-2xl border border-slate-200 shadow-lg shadow-slate-200/50 focus-within:ring-2 focus-within:ring-brand-500/20 focus-within:border-brand-500 transition-all duration-300">
|
||||
<textarea
|
||||
<footer class="safe-bottom-lg sticky bottom-0 z-20 border-t border-slate-200/80 bg-white/70 p-4 backdrop-blur-xl dark:border-slate-700/70 dark:bg-slate-950/65 md:p-6">
|
||||
<div class="relative mx-auto max-w-5xl">
|
||||
<div class="relative rounded-2xl border border-slate-200 bg-white/95 shadow-xl shadow-slate-300/25 transition-all duration-300 focus-within:border-cyan-500 focus-within:ring-2 focus-within:ring-cyan-500/25 dark:border-slate-700 dark:bg-slate-900/88 dark:shadow-none">
|
||||
<textarea
|
||||
v-model="input"
|
||||
@keydown.enter.prevent="handleSend"
|
||||
rows="1"
|
||||
:placeholder="$t('chat.placeholder')"
|
||||
class="w-full pl-5 pr-14 py-4 bg-transparent resize-none focus:outline-none text-slate-800 placeholder-slate-400 text-[15px] leading-relaxed"
|
||||
style="min-height: 56px; max-height: 200px;"
|
||||
class="w-full resize-none bg-transparent py-4 pl-5 pr-14 text-[15px] leading-relaxed text-slate-800 placeholder-slate-400 focus:outline-none dark:text-slate-100 dark:placeholder-slate-500"
|
||||
style="min-height: 56px; max-height: 220px;"
|
||||
:disabled="isThinking"
|
||||
></textarea>
|
||||
<button
|
||||
<button
|
||||
@click="handleSend"
|
||||
:disabled="!input.trim() || isThinking"
|
||||
class="absolute right-2 bottom-2 p-2.5 bg-brand-600 text-white rounded-xl hover:bg-brand-700 disabled:opacity-50 disabled:cursor-not-allowed transition-all shadow-md shadow-brand-500/20 active:scale-95"
|
||||
class="absolute bottom-2 right-2 rounded-xl bg-gradient-to-r from-cyan-600 to-blue-600 p-2.5 text-white shadow-lg shadow-cyan-500/30 transition-all hover:opacity-90 disabled:cursor-not-allowed disabled:opacity-50 active:scale-95"
|
||||
>
|
||||
<Send class="w-5 h-5" />
|
||||
<Send class="h-5 w-5" />
|
||||
</button>
|
||||
</div>
|
||||
<div class="text-center mt-3 text-xs font-medium text-slate-400">
|
||||
<div class="mt-3 text-center text-xs font-medium text-slate-500 dark:text-slate-400">
|
||||
{{ $t('chat.disclaimer') }}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
Reference in new issue
Block a user