修改手机端样式

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

@@ -15,7 +15,7 @@ const isDarkTheme = computed(() => appliedTheme.value === 'dark');
const buttonClass = computed(() =>
props.floating
? 'fixed bottom-5 right-5 z-[70] h-11 w-11 rounded-full bg-white/90 dark:bg-slate-900/90 backdrop-blur-md shadow-lg border border-slate-200 dark:border-slate-700 text-slate-600 dark:text-slate-300 hover:text-slate-900 dark:hover:text-slate-100 hover:shadow-xl flex items-center justify-center transition-all'
: 'h-9 w-9 rounded-full bg-white/80 dark:bg-slate-900/80 backdrop-blur-md shadow-sm border border-slate-200 dark:border-slate-700 text-slate-600 dark:text-slate-300 hover:text-slate-900 dark:hover:text-slate-100 hover:shadow-md flex items-center justify-center transition-all'
: 'h-8 w-8 md:h-9 md:w-9 rounded-full bg-white/80 dark:bg-slate-900/80 backdrop-blur-md shadow-sm border border-slate-200 dark:border-slate-700 text-slate-600 dark:text-slate-300 hover:text-slate-900 dark:hover:text-slate-100 hover:shadow-md flex items-center justify-center transition-all'
);
</script>
@@ -26,7 +26,7 @@ const buttonClass = computed(() =>
:title="isDarkTheme ? (t('theme.switchToLight') || 'Switch to light mode') : (t('theme.switchToDark') || 'Switch to dark mode')"
:aria-label="isDarkTheme ? (t('theme.switchToLight') || 'Switch to light mode') : (t('theme.switchToDark') || 'Switch to dark mode')"
>
<Sun v-if="isDarkTheme" class="w-5 h-5" />
<Moon v-else class="w-5 h-5" />
<Sun v-if="isDarkTheme" class="w-4 h-4 md:w-5 md:h-5" />
<Moon v-else class="w-4 h-4 md:w-5 md:h-5" />
</button>
</template>
+24
View File
@@ -78,6 +78,12 @@ const messages = {
},
workspace: {
title: 'AI Workspace',
brandTitle: 'Hexin AI Workspace',
languageLabel: 'Language',
languageOptionEn: 'English',
languageOptionZhCN: 'Chinese (Simplified)',
languageOptionZhTW: 'Chinese (Traditional)',
languageOptionTh: 'Thai',
userTitle: '{username}\'s AI Workspace',
subtitle: 'Choose an agent or click a quick question to start',
search: 'Search agents...',
@@ -762,6 +768,12 @@ const messages = {
},
workspace: {
title: 'AI 工作台',
brandTitle: '和信AI工作台',
languageLabel: '语言',
languageOptionEn: '英文',
languageOptionZhCN: '简体中文',
languageOptionZhTW: '繁體中文',
languageOptionTh: '泰语',
userTitle: '{username} 的 AI 工作台',
subtitle: '选择一个助手,或点击常用问题快速开始',
search: '搜索应用...',
@@ -1425,6 +1437,12 @@ const messages = {
},
workspace: {
title: 'AI 工作台',
brandTitle: '和信AI工作台',
languageLabel: '語言',
languageOptionEn: '英文',
languageOptionZhCN: '簡體中文',
languageOptionZhTW: '繁體中文',
languageOptionTh: '泰語',
userTitle: '{username} 的 AI 工作台',
subtitle: '選擇一個助手,或點擊常用問題快速開始',
search: '搜索應用...',
@@ -2088,6 +2106,12 @@ const messages = {
},
workspace: {
title: 'พื้นที่ทำงาน AI',
brandTitle: 'Hexin AI Workspace',
languageLabel: 'ภาษา',
languageOptionEn: 'อังกฤษ',
languageOptionZhCN: 'จีน (ตัวย่อ)',
languageOptionZhTW: 'จีน (ตัวเต็ม)',
languageOptionTh: 'ไทย',
userTitle: 'พื้นที่ทำงาน AI ของ {username}',
subtitle: 'เลือกผู้ช่วยหรือคลิกคำถามด่วนเพื่อเริ่ม',
search: 'ค้นหาตัวแทน...',
+21
View File
@@ -101,6 +101,27 @@
@apply bg-white rounded-2xl border border-slate-100 shadow-soft hover:shadow-lg transition-all duration-300;
}
/* Mobile-first layout tokens for consistent spacing and density. */
.page-shell-mobile {
@apply px-3 md:px-8;
}
.section-gap-mobile {
@apply mb-3 md:mb-8;
}
.card-mobile-compact {
@apply p-3 sm:p-5;
}
.icon-box-mobile {
@apply w-8 h-8 sm:w-10 sm:h-10;
}
.icon-glyph-mobile {
@apply w-4 h-4 sm:w-6 sm:h-6;
}
.badge {
@apply px-2.5 py-0.5 rounded-full text-xs font-medium border;
}
+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
+63 -47
View File
@@ -1,10 +1,10 @@
<script setup lang="ts">
/**
* WorkspaceView.vue
* 鏂囦欢鐢ㄩ€旓細鐢ㄦ埛宸ヤ綔鍙帮紝鏀寔鑷畾涔夊竷灞€銆佹敹钘忋€佸祵鍏?Agent
* 寮曠敤鏂囦欢锛歷ue, vue-router, lucide-vue-next, 鍚庣 /api/user 鎺ュ彛
* 文件用途:用户工作台,支持自定义布局、收藏、嵌入 Agent
* 引用文件:vue, vue-router, lucide-vue-next, 后端 /api/user 接口
*/
import { ref, onMounted, computed, watch } from 'vue';
import { ref, onMounted, onBeforeUnmount, computed, watch } from 'vue';
import { useRouter } from 'vue-router';
import { useI18n } from 'vue-i18n';
import { config } from '../config';
@@ -532,6 +532,15 @@ const handleRegister = async () => {
// Header Dropdown State
const showUserDropdown = ref(false);
const userMenuRef = ref<HTMLElement | null>(null);
const handleDocumentPointerDown = (event: MouseEvent | TouchEvent) => {
if (!showUserDropdown.value) return;
const target = event.target as Node | null;
if (!target) return;
if (userMenuRef.value?.contains(target)) return;
showUserDropdown.value = false;
};
const handleLogout = () => {
localStorage.removeItem('hxops_user');
@@ -688,6 +697,8 @@ const openAnnouncement = (ann: Announcement) => {
};
onMounted(async () => {
document.addEventListener('mousedown', handleDocumentPointerDown);
document.addEventListener('touchstart', handleDocumentPointerDown, { passive: true });
loadLanguagePreference();
fetchAnnouncements();
const handledWecom = await tryWecomCallbackLogin();
@@ -702,6 +713,11 @@ onMounted(async () => {
isLoading.value = false;
}
});
onBeforeUnmount(() => {
document.removeEventListener('mousedown', handleDocumentPointerDown);
document.removeEventListener('touchstart', handleDocumentPointerDown);
});
</script>
<template>
@@ -718,47 +734,39 @@ onMounted(async () => {
</div>
<!-- Header (Logged In) -->
<header v-if="isLoggedIn" class="sticky top-0 z-30 bg-white/80 dark:bg-slate-900/80 backdrop-blur-md border-b border-gray-100 dark:border-slate-700 px-4 md:px-8 py-4 mb-8 transition-all duration-300">
<div class="max-w-7xl mx-auto flex flex-col md:flex-row justify-between items-center gap-4">
<div class="flex items-center gap-3">
<div class="w-10 h-10 bg-gradient-to-br from-brand-500 to-brand-700 rounded-xl flex items-center justify-center text-white shadow-lg shadow-brand-500/30">
<Bot class="w-6 h-6" />
<header v-if="isLoggedIn" class="sticky top-0 z-30 bg-white/80 dark:bg-slate-900/80 backdrop-blur-md border-b border-gray-100 dark:border-slate-700 page-shell-mobile py-2.5 md:py-4 section-gap-mobile transition-all duration-300">
<div class="max-w-7xl mx-auto flex flex-wrap md:flex-nowrap justify-between items-start md:items-center gap-2 md:gap-4">
<div class="flex items-center gap-2 md:gap-3 min-w-0 flex-1">
<div class="w-8 h-8 md:w-10 md:h-10 bg-gradient-to-br from-brand-500 to-brand-700 rounded-xl flex items-center justify-center text-white shadow-lg shadow-brand-500/30 shrink-0">
<Bot class="w-4 h-4 md:w-6 md:h-6" />
</div>
<div>
<h1 class="text-xl font-bold text-slate-900 dark:text-slate-100 tracking-tight">
{{ currentUser ? $t('workspace.userTitle', { username: currentUser.username }) : $t('workspace.title') }}
<div class="min-w-0">
<h1 class="text-lg md:text-xl font-bold text-[#1b2b49] dark:text-slate-100 tracking-tight leading-tight truncate">
{{ $t('workspace.brandTitle') }}
</h1>
<p class="text-slate-500 dark:text-slate-400 text-xs font-medium">{{ $t('workspace.subtitle') }}</p>
</div>
</div>
<div class="flex items-center gap-4">
<!-- 已登录页将主题与语言切换放入头部右侧,避免不同分辨率下被遮挡 -->
<div class="flex items-center gap-2 md:gap-4 shrink-0">
<!-- Keep header actions minimal on mobile; language switch is in the profile dropdown. -->
<div class="flex items-center gap-2">
<ThemeToggleButton />
<select v-model="locale" class="bg-white/80 dark:bg-slate-900/80 backdrop-blur-md shadow-sm border border-slate-200 dark:border-slate-700 text-xs font-medium text-slate-600 dark:text-slate-300 hover:text-slate-800 dark:hover:text-slate-100 cursor-pointer outline-none rounded-full px-3 py-1.5 transition-all hover:shadow-md">
<option value="en">English</option>
<option value="zh-CN">简体中文</option>
<option value="zh-TW">繁體中文</option>
<option value="th">ไทย</option>
</select>
</div>
<!-- User Profile Dropdown -->
<div class="relative">
<button @click="showUserDropdown = !showUserDropdown" class="flex items-center gap-3 pl-3 pr-2 py-1.5 rounded-full hover:bg-slate-50 dark:hover:bg-slate-800 transition-colors border border-transparent hover:border-slate-200 dark:hover:border-slate-700">
<div ref="userMenuRef" class="relative">
<button @click="showUserDropdown = !showUserDropdown" class="flex items-center gap-2 md:gap-3 pl-2 md:pl-3 pr-1.5 md:pr-2 py-1 md:py-1.5 rounded-full hover:bg-slate-50 dark:hover:bg-slate-800 transition-colors border border-transparent hover:border-slate-200 dark:hover:border-slate-700">
<div class="text-right hidden sm:block">
<div class="text-sm font-bold text-slate-900 dark:text-slate-100 leading-tight">{{ currentUser?.username }}</div>
<div class="text-[10px] font-medium text-slate-500 dark:text-slate-400 uppercase tracking-wide">{{ currentUser?.role }}</div>
</div>
<div class="w-9 h-9 bg-brand-100 rounded-full flex items-center justify-center text-brand-600 font-bold border-2 border-white shadow-sm">
<div class="w-8 h-8 md:w-9 md:h-9 bg-brand-100 rounded-full flex items-center justify-center text-brand-600 font-bold border-2 border-white shadow-sm">
{{ (currentUser?.username || 'U').charAt(0).toUpperCase() }}
</div>
</button>
<!-- Dropdown Menu -->
<div v-if="showUserDropdown"
class="absolute right-0 top-full mt-2 w-48 bg-white dark:bg-slate-900 rounded-xl shadow-xl border border-slate-100 dark:border-slate-700 py-1 z-50 animate-fade-in"
@click.away="showUserDropdown = false">
class="absolute right-0 top-full mt-2 w-56 bg-white dark:bg-slate-900 rounded-xl shadow-xl border border-slate-100 dark:border-slate-700 py-1 z-50 animate-fade-in">
<div class="px-4 py-3 border-b border-slate-50 dark:border-slate-700 md:hidden">
<div class="text-sm font-bold text-slate-900 dark:text-slate-100">{{ currentUser?.username }}</div>
<div class="text-xs text-slate-500 dark:text-slate-400">{{ currentUser?.role }}</div>
@@ -773,7 +781,16 @@ onMounted(async () => {
<Settings class="w-4 h-4" />
{{ $t('admin.title') }}
</button>
<div class="px-4 pt-2 pb-3 border-t border-slate-50 dark:border-slate-700 mt-1">
<label class="block text-[11px] font-semibold text-slate-500 dark:text-slate-400 mb-1.5 uppercase tracking-wide">{{ $t('workspace.languageLabel') }}</label>
<select v-model="locale" class="w-full bg-white dark:bg-slate-900 border border-slate-200 dark:border-slate-700 text-xs font-medium text-slate-700 dark:text-slate-300 rounded-lg px-2.5 py-2 outline-none focus:ring-2 focus:ring-brand-500/20 focus:border-brand-500">
<option value="en">{{ $t('workspace.languageOptionEn') }}</option>
<option value="zh-CN">{{ $t('workspace.languageOptionZhCN') }}</option>
<option value="zh-TW">{{ $t('workspace.languageOptionZhTW') }}</option>
<option value="th">{{ $t('workspace.languageOptionTh') }}</option>
</select>
</div>
<div class="border-t border-slate-50 dark:border-slate-700 my-1"></div>
<button @click="handleLogout" class="w-full text-left px-4 py-2 text-sm text-red-600 hover:bg-red-50 flex items-center gap-2">
@@ -786,7 +803,7 @@ onMounted(async () => {
</div>
</header>
<main class="max-w-7xl mx-auto px-4 md:px-8 pb-12">
<main class="max-w-7xl mx-auto page-shell-mobile pb-12">
<div v-if="isLoading" class="animate-pulse space-y-8">
<div class="h-48 bg-gray-200 rounded-2xl"></div>
<div class="grid grid-cols-1 md:grid-cols-3 gap-6">
@@ -942,7 +959,7 @@ onMounted(async () => {
<div class="md:pl-6">
<!-- Header -->
<div class="flex justify-between items-center mb-6">
<h2 class="text-xl font-bold text-slate-800 flex items-center gap-2.5 cursor-pointer select-none" @click="toggleSectionCollapse(section)">
<h2 class="text-lg md:text-xl font-semibold text-[#1b2b49] flex items-center gap-2.5 cursor-pointer select-none" @click="toggleSectionCollapse(section)">
<div class="p-2 rounded-lg" :class="{
'bg-emerald-50 text-emerald-600': section.id === 'announcements',
'bg-yellow-50 text-yellow-600': section.id === 'favorites',
@@ -984,15 +1001,15 @@ onMounted(async () => {
<!-- Content: Favorites -->
<div v-if="section.id === 'favorites'">
<div v-if="favoriteAgents.length === 0" class="text-slate-400 text-sm italic py-4 bg-slate-50 rounded-xl text-center border border-dashed border-slate-200">{{ $t('workspace.noFavorites') }}</div>
<div class="grid grid-cols-1 md:grid-cols-3 lg:grid-cols-4 gap-6">
<div class="grid grid-cols-2 md:grid-cols-3 lg:grid-cols-4 gap-3 sm:gap-6">
<div v-for="agent in favoriteAgents" :key="agent.id" @click="navigateToChat(agent.id)"
class="card p-5 cursor-pointer relative group/card hover:-translate-y-1 hover:shadow-lg hover:border-brand-200 bg-gradient-to-br from-white to-slate-50/50">
<div class="w-12 h-12 bg-brand-100 rounded-xl flex items-center justify-center text-brand-600 mb-4 shadow-sm group-hover/card:scale-110 transition-transform duration-300">
<img v-if="agent.icon_url" :src="agent.icon_url" class="w-7 h-7" />
<Bot v-else class="w-7 h-7" />
class="card p-4 sm:p-5 cursor-pointer relative group/card hover:-translate-y-1 hover:shadow-lg hover:border-brand-200 bg-gradient-to-br from-white to-slate-50/50">
<div class="w-8 h-8 sm:w-12 sm:h-12 bg-brand-100 rounded-xl flex items-center justify-center text-brand-600 mb-3 sm:mb-4 shadow-sm group-hover/card:scale-110 transition-transform duration-300">
<img v-if="agent.icon_url" :src="agent.icon_url" class="w-5 h-5 sm:w-7 sm:h-7" />
<Bot v-else class="w-5 h-5 sm:w-7 sm:h-7" />
</div>
<div class="font-bold text-slate-900 mb-1 group-hover/card:text-brand-700 transition-colors">{{ agent.name }}</div>
<div class="text-xs text-slate-500 truncate">{{ agent.description }}</div>
<div class="text-[15px] sm:text-base font-semibold text-[#1b2b49] mb-1 group-hover/card:text-brand-700 transition-colors truncate">{{ agent.name }}</div>
<div class="text-[13px] sm:text-xs text-[#8fa1b8] truncate">{{ agent.description }}</div>
<button @click.stop="toggleFavorite(agent.id)" class="absolute top-3 right-3 text-yellow-400 hover:text-yellow-500 hover:scale-110 transition-all opacity-0 group-hover/card:opacity-100">
<Star class="w-5 h-5 fill-current" />
</button>
@@ -1076,23 +1093,21 @@ onMounted(async () => {
<div class="mb-6">
<input v-model="searchQuery" type="text" :placeholder="$t('workspace.search')" class="input-field max-w-md shadow-sm" />
</div>
<div class="grid grid-cols-1 md:grid-cols-3 lg:grid-cols-4 gap-6">
<div v-for="agent in otherAgents" :key="agent.id"
class="card p-5 cursor-pointer relative group/card hover:-translate-y-1 hover:border-brand-200">
<div class="flex items-start justify-between mb-4">
<div class="w-10 h-10 bg-slate-50 rounded-xl flex items-center justify-center text-slate-500 group-hover/card:bg-brand-50 group-hover/card:text-brand-600 transition-colors">
<img v-if="agent.icon_url" :src="agent.icon_url" class="w-6 h-6" />
<Bot v-else class="w-6 h-6" />
<div class="grid grid-cols-2 md:grid-cols-3 lg:grid-cols-4 gap-3 sm:gap-6">
<div v-for="agent in otherAgents" :key="agent.id"
@click="navigateToChat(agent.id)"
class="card card-mobile-compact cursor-pointer relative group/card hover:-translate-y-1 hover:border-brand-200">
<div class="flex items-start justify-between mb-2 sm:mb-4">
<div class="w-8 h-8 sm:w-10 sm:h-10 bg-slate-50 rounded-xl flex items-center justify-center text-slate-500 group-hover/card:bg-brand-50 group-hover/card:text-brand-600 transition-colors">
<img v-if="agent.icon_url" :src="agent.icon_url" class="w-4 h-4 sm:w-6 sm:h-6" />
<Bot v-else class="w-4 h-4 sm:w-6 sm:h-6" />
</div>
<button @click.stop="toggleFavorite(agent.id)" class="text-slate-200 hover:text-yellow-400 transition-colors">
<Star class="w-5 h-5" :class="{ 'fill-yellow-400 text-yellow-400': favoriteAgentIds.includes(agent.id) }" />
</button>
</div>
<h3 class="font-bold text-slate-900 mb-1 group-hover/card:text-brand-700 transition-colors">{{ agent.name }}</h3>
<p class="text-xs text-slate-500 line-clamp-2 h-8 leading-relaxed">{{ agent.description }}</p>
<button @click="navigateToChat(agent.id)" class="mt-5 w-full py-2 bg-slate-50 text-slate-600 text-xs font-bold rounded-xl hover:bg-brand-600 hover:text-white transition-all duration-300">
{{ $t('workspace.startChatShort') }}
</button>
<h3 class="text-[15px] sm:text-base font-semibold text-[#1b2b49] mb-1 group-hover/card:text-brand-700 transition-colors line-clamp-1 sm:line-clamp-2 leading-tight">{{ agent.name }}</h3>
<p class="text-[13px] sm:text-xs text-[#8fa1b8] line-clamp-1 sm:line-clamp-2 h-4 sm:h-8 leading-relaxed">{{ agent.description }}</p>
</div>
</div>
</div>
@@ -1176,3 +1191,4 @@ onMounted(async () => {
<style scoped>
/* Scoped styles removed in favor of global utilities in style.css */
</style>