修改手机端样式

This commit is contained in:
sophie committed 2026-04-15 18:15:18 +08:00
1 parent 1022abe55d
commit 2ee4e1dca7
5 files changed
+164 -102

No files matched your search

+53 -52
View File
@@ -65,14 +65,14 @@ interface SourceFileLink {
}
// 源文件展示配置(来自 config.ts)
const sourceFileConfig = {
// 是否显示整个“源文件”区域
showSourceFiles: config.workspace?.sourceFiles?.showSourceFiles !== false,
// 是否显示 MD 源文件(.md/.markdown)
showMdFiles: config.workspace?.sourceFiles?.showMdFiles !== false,
// MD 源文件是否默认展开“源文档”详情
expandMdByDefault: config.workspace?.sourceFiles?.expandMdByDefault === true,
};
// const sourceFileConfig = {
// // 是否显示整个“源文件”区域
// showSourceFiles: config.workspace?.sourceFiles?.showSourceFiles !== false,
// // 是否显示 MD 源文件(.md/.markdown)
// showMdFiles: config.workspace?.sourceFiles?.showMdFiles !== false,
// // MD 源文件是否默认展开“源文档”详情
// expandMdByDefault: config.workspace?.sourceFiles?.expandMdByDefault === true,
// };
const PREFERRED_SOURCE_EXTS = new Set([
'pdf', 'doc', 'docx', 'ppt', 'pptx', 'xls', 'xlsx', 'csv',
@@ -232,7 +232,7 @@ const getSourceLinks = (resources: any[] = []): SourceFileLink[] => {
// Skip links whose display name itself is noisy.
if (isNoisySourceName(name)) continue;
// 根据配置决定是否显示 MD 文件
if (!sourceFileConfig.showMdFiles && (isMarkdownFileName(name) || isMarkdownByUrl(url))) continue;
if ( (isMarkdownFileName(name) || isMarkdownByUrl(url))) continue;
const key = `${name}|${url}`;
if (!map.has(key)) {
map.set(key, { name, url });
@@ -245,7 +245,10 @@ const getSourceLinks = (resources: any[] = []): SourceFileLink[] => {
};
const getMessageLinks = (msg: any): SourceFileLink[] => {
if (!sourceFileConfig.showSourceFiles) return [];
// if (!sourceFileConfig.showSourceFiles) {
// console.info('showSourceFiles is false');
// return [];
// }
const map = new Map<string, SourceFileLink>();
const merge = (links: SourceFileLink[]) => {
@@ -253,7 +256,7 @@ const getMessageLinks = (msg: any): SourceFileLink[] => {
if (isChunkLikeLink(link.url)) continue;
// 文件名有效时,保留文件按钮(即便 URL 是临时签名地址)。
if (isNoisySourceName(link.name)) continue;
if (!sourceFileConfig.showMdFiles && (isMarkdownFileName(link.name) || isMarkdownByUrl(link.url))) continue;
if ( (isMarkdownFileName(link.name) || isMarkdownByUrl(link.url))) continue;
if (isMarkdownFileName(link.name)) {
const key = `${link.name}|${link.url}`;
if (!map.has(key)) map.set(key, link);
@@ -277,9 +280,9 @@ const getMessageLinks = (msg: any): SourceFileLink[] => {
};
const getDisplayRetrieverResources = (msg: any): any[] => {
if (!sourceFileConfig.showSourceFiles) return [];
// if (!sourceFileConfig.showSourceFiles) return [];
const list = Array.isArray(msg?.retriever_resources) ? msg.retriever_resources : [];
if (sourceFileConfig.showMdFiles) return list;
// if (sourceFileConfig.showMdFiles) return list;
return list.filter((doc: any) => {
const name = doc?.source_filename || doc?.document_name || doc?.title || '';
const url = doc?.source_download_url || doc?.url || doc?.file_url || doc?.document_url || '';
@@ -288,8 +291,12 @@ const getDisplayRetrieverResources = (msg: any): any[] => {
};
const shouldExpandSourceDetails = (msg: any): boolean => {
if (!sourceFileConfig.showSourceFiles) return false;
if (!sourceFileConfig.showMdFiles || !sourceFileConfig.expandMdByDefault) return false;
// if (!sourceFileConfig.showSourceFiles) {
// console.info('showSourceFiles is false');
// return false;
// }
// if (!sourceFileConfig.showMdFiles || !sourceFileConfig.expandMdByDefault) return false;
return getMessageLinks(msg).some((link) => isMarkdownFileName(link.name) || isMarkdownByUrl(link.url));
};
@@ -521,10 +528,10 @@ const submitFeedback = async () => {
></div>
<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="glass-panel fixed inset-y-0 left-0 z-50 flex w-[86vw] max-w-[300px] flex-col border-r transition-transform duration-300 ease-in-out md:relative md:w-80 md:max-w-none md:translate-x-0"
:class="isSidebarOpen ? 'translate-x-0' : '-translate-x-full'"
>
<div class="border-b border-slate-200/70 p-4 dark:border-slate-700/70">
<div class="border-b border-slate-200/70 p-3 dark:border-slate-700/70 md:p-4">
<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" />
@@ -532,40 +539,38 @@ const submitFeedback = async () => {
<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">
<button @click="startNewChat(); isSidebarOpen = false;" class="mt-3 inline-flex w-[92%] max-w-[320px] self-center items-center justify-center gap-2 rounded-xl bg-gradient-to-r from-cyan-600 to-blue-600 px-5 py-2.5 text-sm font-semibold text-white shadow-md shadow-cyan-500/25 transition-all hover:from-cyan-500 hover:to-blue-500 hover:shadow-lg hover:shadow-cyan-500/30 md:mt-4 md:w-[88%] md:max-w-none md:py-3">
<Plus class="h-4 w-4" /> {{ $t('chat.newChat') }}
</button>
</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>
<div class="flex-1 overflow-y-auto px-2.5 py-2.5 scrollbar-thin md:px-3 md:py-3">
<div v-if="history.length === 0" class="py-8 text-center text-sm italic text-slate-400 md:py-10">{{ $t('chat.noHistory') }}</div>
<div v-else class="divide-y divide-slate-200/70 dark:divide-slate-700/70">
<button
v-for="item in history"
:key="item.conversation_id"
class="w-full truncate rounded-xl border px-4 py-3 text-left text-sm transition-all"
class="w-full truncate px-2 py-3 text-left text-sm transition-colors md:px-3"
: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'"
? 'font-semibold text-cyan-700 dark:text-cyan-200'
: 'text-slate-600 hover:bg-slate-100/70 hover:text-slate-900 dark:text-slate-300 dark:hover:bg-slate-800/60 dark:hover:text-slate-100'"
@click="loadConversation(item.conversation_id); isSidebarOpen = false;"
>
{{ item.title || $t('chat.newChat') }}
</button>
</div>
</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">
<div class="space-y-2.5 border-t border-slate-200/70 bg-white/35 p-3 dark:border-slate-700/70 dark:bg-slate-900/35 md:space-y-3 md:p-4">
<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"
class="w-full rounded-xl border border-slate-200 bg-white/90 px-3 py-1.5 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 md:py-2"
>
<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>
@@ -584,7 +589,7 @@ const submitFeedback = async () => {
</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">
<button @click="startNewChat" class="inline-flex items-center gap-1 rounded-xl border border-slate-200 bg-white/80 px-2 py-1.5 text-[11px] 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:px-3 md:py-2 md:text-xs">
<Plus class="h-4 w-4" />
{{ $t('chat.newChat') }}
</button>
@@ -606,15 +611,15 @@ const submitFeedback = async () => {
</div>
<template v-else>
<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="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>
<main
class="flex-1 p-3 md:p-8"
:class="messages.length === 0 ? 'overflow-hidden md:overflow-y-auto' : 'space-y-4 overflow-y-auto scrollbar-thin md:space-y-8'"
>
<div v-if="messages.length === 0" class="flex h-full flex-col items-center justify-center py-2 text-slate-400 md:pb-16">
<h2 class="mb-2 text-center text-lg font-semibold tracking-tight text-slate-700 dark:text-slate-200 md:text-3xl md:font-bold md:text-slate-900 md:dark:text-slate-100">{{ $t('chat.welcome.title') }}</h2>
<p class="max-w-xl text-center text-sm leading-relaxed text-slate-500 dark:text-slate-300 md:text-base">{{ $t('chat.welcome.subtitle') }}</p>
<div class="mt-12 grid w-full max-w-3xl grid-cols-1 gap-4 md:grid-cols-2">
<div class="mt-5 hidden w-full max-w-md grid-cols-1 justify-items-center gap-3 md:mt-10 md:grid md:max-w-3xl md:gap-4 md:grid-cols-2 md:justify-items-stretch">
<button v-for="suggestion in (currentAgent.suggested_questions && currentAgent.suggested_questions.length > 0 ? currentAgent.suggested_questions : [
$t('chat.suggestions.whatCanYouDo'),
$t('chat.suggestions.helpWriteReport'),
@@ -623,7 +628,7 @@ const submitFeedback = async () => {
])"
: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"
class="w-full max-w-[320px] rounded-xl border border-slate-200 bg-white/90 px-4 py-3 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 md:max-w-none"
>
{{ suggestion }}
</button>
@@ -633,14 +638,13 @@ const submitFeedback = async () => {
<div
v-for="(msg, index) in messages"
:key="index"
class="group mx-auto flex max-w-5xl gap-4 animate-slide-up"
class="group mx-auto flex max-w-5xl gap-0 animate-slide-up"
:class="msg.role === 'user' ? 'justify-end' : ''"
>
<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>
<div class="flex max-w-[88%] flex-col md:max-w-[74%]">
<div
class="flex flex-col"
:class="msg.role === 'user' ? 'max-w-[88%] md:max-w-[74%]' : 'w-full'"
>
<div
class="rounded-2xl px-6 py-4 text-[15px] leading-relaxed shadow-md"
:class="msg.role === 'user'
@@ -653,13 +657,13 @@ const submitFeedback = async () => {
>{{ msg.content }}</div>
<div
v-else
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"
class="prose prose-sm max-w-none leading-7 text-slate-800 dark:text-slate-100 prose-a:text-cyan-600 dark:prose-a:text-cyan-300 prose-p:my-1 prose-li:my-0.5 prose-ol:my-2 prose-ul:my-2 prose-headings:my-2 prose-hr:my-3 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:my-3 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>
<div
v-if="sourceFileConfig.showSourceFiles && msg.role === 'assistant' && ((getDisplayRetrieverResources(msg).length > 0) || (msg.attribution_parts && msg.attribution_parts.length > 0) || getMessageLinks(msg).length > 0)"
v-if=" msg.role === 'assistant' && ((getDisplayRetrieverResources(msg).length > 0) || (msg.attribution_parts && msg.attribution_parts.length > 0) || getMessageLinks(msg).length > 0)"
class="mt-2 space-y-2"
>
<!-- 带有URL链接的源文件名称,支持预览 -->
@@ -758,9 +762,6 @@ const submitFeedback = async () => {
</div>
</div>
<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>
<div v-if="isThinking" class="mx-auto flex max-w-5xl gap-4">
@@ -814,10 +815,10 @@ const submitFeedback = async () => {
</div>
</div>
</div>
<div class="h-6 md:h-8"></div>
<div v-if="messages.length > 0" class="h-6 md:h-8"></div>
</main>
<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">
<footer class="safe-bottom sticky bottom-0 z-20 border-t border-slate-200/80 bg-white/70 p-3 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="chat-composer-shell relative overflow-hidden 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