feat(ui): design system upgrade — responsive layout, collapsible panels, and unified tokens

This commit is contained in:
matevip 2026-04-10 18:14:23 +08:00
parent 367dd4bed0
commit 16d22f7e6f
10 changed files with 495 additions and 98 deletions

View File

@ -5,6 +5,10 @@
<link rel="icon" href="/logo/favicon.ico" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>MateClaw - AI 助手</title>
<!-- Inter font preload -->
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap" rel="stylesheet">
</head>
<body>
<div id="app"></div>

View File

@ -4,6 +4,28 @@
CSS Variables Light / Dark theme
================================================================ */
:root {
/* font system */
--mc-font-body: 'Inter', 'Avenir Next', 'SF Pro Display', 'Segoe UI', 'PingFang SC', 'Microsoft YaHei', sans-serif;
--mc-font-mono: 'JetBrains Mono', 'Fira Code', 'SF Mono', Consolas, monospace;
/* type scale */
--mc-text-xs: 11px;
--mc-text-sm: 13px;
--mc-text-base: 15px;
--mc-text-lg: 18px;
--mc-text-xl: 24px;
--mc-text-2xl: 32px;
--mc-leading-tight: 1.25;
--mc-leading-normal: 1.5;
--mc-leading-relaxed: 1.75;
/* radius system */
--mc-radius-sm: 6px;
--mc-radius-md: 12px;
--mc-radius-lg: 16px;
--mc-radius-xl: 20px;
--mc-radius-full: 9999px;
/* brand */
--mc-primary: #d96d46;
--mc-primary-light: #ebb08f;
@ -108,6 +130,7 @@
/* Element Plus light override */
--el-color-primary: #D97757;
--el-font-family: var(--mc-font-body);
color-scheme: light;
}
@ -228,10 +251,12 @@ html, body, #app {
}
body {
font-family: 'Avenir Next', 'SF Pro Display', 'Segoe UI', 'PingFang SC', 'Microsoft YaHei', sans-serif;
font-family: var(--mc-font-body);
background-color: var(--mc-bg);
color: var(--mc-text-primary);
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
font-feature-settings: "kern" on;
transition: background-color 0.2s ease, color 0.2s ease;
background-image:
radial-gradient(circle at top left, rgba(217, 109, 70, 0.1), transparent 26%),
@ -299,7 +324,7 @@ html.dark body::before {
/* inline code */
.markdown-body code {
font-family: 'JetBrains Mono', 'Fira Code', Consolas, monospace;
font-family: var(--mc-font-mono);
font-size: 0.875rem;
}
.markdown-body :not(pre) > code {
@ -403,7 +428,7 @@ html.dark body::before {
position: relative;
border: 1px solid var(--mc-border);
background: var(--mc-surface-overlay);
backdrop-filter: blur(18px);
backdrop-filter: blur(12px) saturate(1.1);
border-radius: 28px;
box-shadow: var(--mc-shadow-soft);
}
@ -467,14 +492,34 @@ html.dark body::before {
.mc-surface-card {
border: 1px solid var(--mc-border-light);
background: linear-gradient(180deg, rgba(255, 255, 255, 0.7), rgba(255, 255, 255, 0.92));
border-radius: 22px;
border-radius: var(--mc-radius-xl);
box-shadow: var(--mc-shadow-soft);
transition: box-shadow 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}
html.dark .mc-surface-card {
background: linear-gradient(180deg, rgba(42, 32, 26, 0.86), rgba(34, 26, 22, 0.96));
}
@media (max-width: 768px) {
.mc-page-shell {
overflow-y: auto !important;
height: auto !important;
min-height: 100%;
}
.mc-page-frame {
overflow: visible !important;
height: auto !important;
min-height: auto;
}
.mc-page-inner {
height: auto !important;
min-height: auto;
}
}
@media (max-width: 900px) {
.mc-page-shell {
padding: 16px;
@ -484,10 +529,45 @@ html.dark .mc-surface-card {
padding: 18px;
}
.mc-page-frame {
border-radius: 20px;
}
.mc-page-header {
flex-direction: column;
align-items: stretch;
}
.mc-surface-card {
border-radius: 16px;
}
}
@media (max-width: 480px) {
.mc-page-shell {
padding: 8px;
}
.mc-page-inner {
padding: 12px;
}
.mc-page-frame {
border-radius: 14px;
}
.mc-page-title {
font-size: clamp(20px, 5vw, 28px);
}
.mc-surface-card {
border-radius: 12px;
}
.mc-page-header {
gap: 12px;
margin-bottom: 16px;
}
}
/* highlight.js token colors (One Dark inspired — works on dark bg) */

View File

@ -75,13 +75,15 @@ const isRunning = computed(() => props.segment.status === 'running')
<style scoped>
.seg-tool {
margin: 1px 0;
margin: 2px 0;
border-left: 3px solid var(--mc-border-light);
border-radius: 0 6px 6px 0;
transition: all 0.15s;
border-radius: 0 var(--mc-radius-sm, 6px) var(--mc-radius-sm, 6px) 0;
transition: all 0.25s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}
.seg-tool:hover {
background: var(--mc-bg-muted);
transform: translateX(2px);
box-shadow: 0 2px 8px rgba(217, 109, 70, 0.08);
}
.seg-tool.is-running {
border-left-color: var(--mc-primary);
@ -136,12 +138,15 @@ const isRunning = computed(() => props.segment.status === 'running')
.seg-tool__args {
flex: 1;
min-width: 0;
font-family: 'SF Mono', 'Menlo', 'Consolas', monospace;
font-family: var(--mc-font-mono, 'SF Mono', 'Menlo', 'Consolas', monospace);
font-size: 12px;
color: var(--mc-text-tertiary);
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
background: rgba(217, 109, 70, 0.06);
padding: 1px 5px;
border-radius: 3px;
}
.seg-tool__arrow {

View File

@ -553,7 +553,7 @@ export default {
agentContext: {
kicker: 'Context Studio',
title: 'Agent Context',
desc: 'Manage prompt files and memory for your agents',
desc: 'Manage prompt files and memory for agents',
selectAgent: 'Select Agent',
noAgent: 'Please select an agent first',
files: 'Files',

View File

@ -196,7 +196,7 @@ export default {
system: '系统',
agent: '智能体',
workspace: '工作区',
agentContext: 'Agent 上下文',
agentContext: '智能体上下文',
skills: '技能',
wiki: 'Wiki 知识库',
tools: '工具',
@ -552,10 +552,10 @@ export default {
},
agentContext: {
kicker: '上下文工作面',
title: 'Agent 上下文',
desc: '管理 Agent 的提示文件和记忆',
selectAgent: '选择 Agent',
noAgent: '请先选择一个 Agent',
title: '智能体上下文',
desc: '管理智能体的提示文件和记忆',
selectAgent: '选择智能体',
noAgent: '请先选择一个智能体',
files: '文件列表',
coreFiles: '核心文件',
coreFilesDesc: '启用的文件将按顺序拼接为 Agent 系统提示词',

View File

@ -3,12 +3,8 @@
<div class="mc-page-frame agent-context-frame">
<div class="mc-page-inner agent-context-container">
<!-- 顶部栏 -->
<div class="workspace-header">
<div class="workspace-header-copy">
<div class="mc-page-kicker">{{ t('agentContext.kicker') }}</div>
<h1 class="page-title">{{ t('agentContext.title') }}</h1>
<p class="page-desc">{{ t('agentContext.desc') }}</p>
</div>
<div class="workspace-header workspace-header--compact">
<h1 class="page-title page-title--compact">{{ t('agentContext.title') }}</h1>
<div class="header-actions mc-surface-card">
<select v-model="selectedAgentId" class="agent-select" @change="onAgentChange">
<option value="" disabled>{{ t('agentContext.selectAgent') }}</option>
@ -471,8 +467,10 @@ function formatTime(time?: string): string {
}
.workspace-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; padding-bottom: 14px; flex-shrink: 0; border-bottom: 1px solid var(--mc-border-light); }
.workspace-header--compact { align-items: center; padding-bottom: 10px; }
.workspace-header-copy { min-width: 0; }
.page-title { font-size: clamp(28px, 3vw, 40px); font-weight: 800; color: var(--mc-text-primary); letter-spacing: -0.04em; margin: 0 0 8px; }
.page-title--compact { font-size: clamp(24px, 2.5vw, 32px); font-weight: 800; letter-spacing: -0.03em; margin: 0; }
.page-desc { font-size: 15px; color: var(--mc-text-secondary); margin: 0; line-height: 1.7; max-width: 720px; }
.header-actions { display: flex; gap: 8px; align-items: center; padding: 12px; border-radius: 18px; flex-shrink: 0; }
.agent-select { padding: 10px 14px; border: 1px solid var(--mc-border); border-radius: 12px; background: var(--mc-bg-elevated); color: var(--mc-text-primary); font-size: 14px; outline: none; min-width: 240px; cursor: pointer; }

View File

@ -8,9 +8,9 @@
</Transition>
<!-- 会话侧边栏 -->
<div class="conversation-panel" :class="{ 'mobile-open': convPanelOpen }">
<div class="conversation-panel" :class="{ 'mobile-open': convPanelOpen, 'conv-collapsed': convPanelCollapsed && !isMobile }">
<div class="panel-header">
<div class="panel-header-copy">
<div v-if="!convPanelCollapsed || isMobile" class="panel-header-copy">
<div class="panel-kicker">{{ $t('nav.chat') }}</div>
<h2 class="panel-title">{{ $t('chat.conversations') }}</h2>
</div>
@ -18,12 +18,17 @@
<el-icon><Plus /></el-icon>
</button>
</div>
<!-- 折叠切换按钮 -->
<button v-if="!isMobile" class="conv-collapse-btn" @click="toggleConvPanel" :title="convPanelCollapsed ? $t('common.expandSidebar') : $t('common.collapseSidebar')">
<svg v-if="!convPanelCollapsed" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><polyline points="15 18 9 12 15 6"/></svg>
<svg v-else width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><polyline points="9 18 15 12 9 6"/></svg>
</button>
<div class="agent-selector">
<button class="agent-select-trigger" @click="agentDropdownOpen = !agentDropdownOpen" :title="`${$t('chat.selectAgent')} (⌘K)`">
<span class="agent-select-trigger__icon">{{ currentAgent?.icon || '🤖' }}</span>
<span class="agent-select-trigger__name">{{ currentAgent?.name || $t('chat.selectAgent') }}</span>
<svg class="agent-select-trigger__arrow" :class="{ open: agentDropdownOpen }" width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><polyline points="6 9 12 15 18 9"/></svg>
<span v-if="!convPanelCollapsed || isMobile" class="agent-select-trigger__name">{{ currentAgent?.name || $t('chat.selectAgent') }}</span>
<svg v-if="!convPanelCollapsed || isMobile" class="agent-select-trigger__arrow" :class="{ open: agentDropdownOpen }" width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><polyline points="6 9 12 15 18 9"/></svg>
</button>
<Transition name="fade">
<div v-if="agentDropdownOpen" class="agent-dropdown-backdrop" @click="agentDropdownOpen = false"></div>
@ -53,7 +58,7 @@
<div class="conversation-list">
<template v-for="group in groupedConversations" :key="group.label">
<div class="conv-group-title">{{ group.label }}</div>
<div v-if="!convPanelCollapsed || isMobile" class="conv-group-title">{{ group.label }}</div>
<div
v-for="conv in group.items"
:key="conv.conversationId"
@ -64,7 +69,7 @@
<div class="conv-icon">
<img :src="channelIconUrl(conv.source)" width="14" height="14" alt="" />
</div>
<div class="conv-info">
<div v-if="!convPanelCollapsed || isMobile" class="conv-info">
<input
v-if="renamingConvId === conv.conversationId"
v-model="renameText"
@ -82,7 +87,7 @@
<span>{{ formatConversationTime(conv.lastActiveTime) }}</span>
</div>
</div>
<button class="conv-delete" @click.stop="confirmDeleteConversation(conv.conversationId)" :title="$t('common.delete')">
<button v-if="!convPanelCollapsed || isMobile" class="conv-delete" @click.stop="confirmDeleteConversation(conv.conversationId)" :title="$t('common.delete')">
<el-icon><Delete /></el-icon>
</button>
</div>
@ -284,16 +289,33 @@ import { useEChartsRenderer } from '@/composables/useEChartsRenderer'
// ============ Talk Mode ============
const showTalkMode = ref(false)
// ============ ============
// ============ & ============
const isMobile = ref(false)
const convPanelOpen = ref(false)
const convPanelCollapsed = ref(localStorage.getItem('mc-conv-collapsed') === 'true')
let mobileQuery: MediaQueryList | null = null
let mediumQuery: MediaQueryList | null = null
const userExplicitConvCollapse = ref(localStorage.getItem('mc-conv-collapsed') === 'true')
function handleMobileChange(e: MediaQueryListEvent | MediaQueryList) {
isMobile.value = e.matches
if (!e.matches) convPanelOpen.value = false
}
function handleConvMediumChange(e: MediaQueryListEvent | MediaQueryList) {
if (e.matches && !userExplicitConvCollapse.value) {
convPanelCollapsed.value = true
} else if (!e.matches && !userExplicitConvCollapse.value) {
convPanelCollapsed.value = false
}
}
function toggleConvPanel() {
convPanelCollapsed.value = !convPanelCollapsed.value
userExplicitConvCollapse.value = convPanelCollapsed.value
localStorage.setItem('mc-conv-collapsed', String(convPanelCollapsed.value))
}
// ============ ============
const suggestions = computed(() => {
const agent = currentAgent.value
@ -674,6 +696,9 @@ onMounted(async () => {
mobileQuery = window.matchMedia('(max-width: 768px)')
handleMobileChange(mobileQuery)
mobileQuery.addEventListener('change', handleMobileChange)
mediumQuery = window.matchMedia('(max-width: 1200px)')
handleConvMediumChange(mediumQuery)
mediumQuery.addEventListener('change', handleConvMediumChange)
await Promise.all([loadAgents(), loadModelState(), loadConversations()])
await hydrateStateFromRoute()
})
@ -683,6 +708,7 @@ onBeforeUnmount(() => {
document.removeEventListener('click', handleCodeCopy)
disposeECharts()
mobileQuery?.removeEventListener('change', handleMobileChange)
mediumQuery?.removeEventListener('change', handleConvMediumChange)
stopChatGeneration()
// ObjectURL
revokeAllPreviewUrls()
@ -1344,6 +1370,55 @@ function handleCodeCopy(e: MouseEvent) {
display: flex;
flex-direction: column;
overflow: hidden;
transition: width 0.25s ease, min-width 0.25s ease;
}
.conversation-panel.conv-collapsed {
width: 54px;
min-width: 54px;
}
.conversation-panel.conv-collapsed .panel-header {
justify-content: center;
padding: 14px 8px 12px;
}
.conversation-panel.conv-collapsed .agent-selector {
padding: 10px 6px 12px;
}
.conversation-panel.conv-collapsed .agent-select-trigger {
justify-content: center;
padding: 8px;
}
.conversation-panel.conv-collapsed .conv-item {
justify-content: center;
padding: 10px 6px;
}
.conversation-panel.conv-collapsed .conv-icon {
margin: 0;
}
.conv-collapse-btn {
display: flex;
align-items: center;
justify-content: center;
width: 100%;
height: 28px;
border: none;
border-bottom: 1px solid var(--mc-border-light);
background: transparent;
color: var(--mc-text-tertiary);
cursor: pointer;
transition: all 0.15s;
flex-shrink: 0;
}
.conv-collapse-btn:hover {
background: var(--mc-bg-muted);
color: var(--mc-text-primary);
}
.panel-header {
@ -2003,9 +2078,20 @@ function handleCodeCopy(e: MouseEvent) {
/* ===== 移动端适配 ===== */
@media (max-width: 768px) {
.chat-console-shell {
padding: 0 !important;
height: 100dvh !important;
height: 100vh !important;
overflow: hidden !important;
min-height: 0 !important;
}
.chat-console-frame {
height: 100%;
min-height: calc(100vh - 28px);
height: 100% !important;
min-height: 0 !important;
overflow: hidden !important;
border-radius: 0;
border: none;
}
.conversation-panel {
@ -2086,5 +2172,27 @@ function handleCodeCopy(e: MouseEvent) {
}
}
@media (max-width: 480px) {
.chat-header {
padding: 6px 8px;
min-height: 44px;
}
.chat-header-right {
gap: 4px;
}
.model-select-trigger {
max-width: 120px;
height: 30px;
padding: 0 8px;
font-size: 12px;
}
.header-btn {
width: 28px;
height: 28px;
}
}
</style>

View File

@ -2,22 +2,32 @@
<div class="mc-page-shell security-shell">
<div class="mc-page-frame security-frame">
<div class="mc-page-inner security-layout">
<div class="settings-nav mc-surface-card">
<div class="settings-nav__intro">
<div class="settings-nav mc-surface-card" :class="{ 'nav-collapsed': navCollapsed }">
<div v-if="!navCollapsed" class="settings-nav__intro">
<div class="mc-page-kicker">{{ t('security.kicker') }}</div>
<h2 class="nav-title">{{ t('security.title') }}</h2>
<p class="nav-desc">{{ t('security.layoutDesc') }}</p>
</div>
<router-link
v-for="section in sections"
:key="section.id"
:to="section.path"
class="nav-item"
:class="{ active: isActive(section.path) }"
>
<span class="nav-icon" v-html="section.icon"></span>
{{ section.label }}
</router-link>
<template v-for="section in sections" :key="section.id">
<el-tooltip
:content="section.label"
placement="right"
:disabled="!navCollapsed"
>
<router-link
:to="section.path"
class="nav-item"
:class="{ active: isActive(section.path) }"
>
<span class="nav-icon" v-html="section.icon"></span>
<span v-if="!navCollapsed" class="nav-label">{{ section.label }}</span>
</router-link>
</el-tooltip>
</template>
<!-- 折叠切换按钮 -->
<button class="nav-collapse-btn" @click="toggleNav" :title="navCollapsed ? t('common.expandSidebar') : t('common.collapseSidebar')">
<svg v-if="!navCollapsed" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><polyline points="15 18 9 12 15 6"/></svg>
<svg v-else width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><polyline points="9 18 15 12 9 6"/></svg>
</button>
</div>
<div class="settings-content mc-surface-card">
@ -31,13 +41,42 @@
</template>
<script setup lang="ts">
import { computed } from 'vue'
import { computed, ref, onMounted, onBeforeUnmount } from 'vue'
import { useRoute } from 'vue-router'
import { useI18n } from 'vue-i18n'
const route = useRoute()
const { t } = useI18n()
// Settings key
const navCollapsed = ref(localStorage.getItem('mc-settings-nav-collapsed') === 'true')
const userExplicit = ref(localStorage.getItem('mc-settings-nav-collapsed') === 'true')
let mediumQuery: MediaQueryList | null = null
function toggleNav() {
navCollapsed.value = !navCollapsed.value
userExplicit.value = navCollapsed.value
localStorage.setItem('mc-settings-nav-collapsed', String(navCollapsed.value))
}
function handleMediumChange(e: MediaQueryListEvent | MediaQueryList) {
if (e.matches && !userExplicit.value) {
navCollapsed.value = true
} else if (!e.matches && !userExplicit.value) {
navCollapsed.value = false
}
}
onMounted(() => {
mediumQuery = window.matchMedia('(max-width: 1200px)')
handleMediumChange(mediumQuery)
mediumQuery.addEventListener('change', handleMediumChange)
})
onBeforeUnmount(() => {
mediumQuery?.removeEventListener('change', handleMediumChange)
})
const sections = computed(() => [
{
id: 'toolGuard',
@ -86,55 +125,91 @@ function isActive(path: string) {
}
.settings-nav {
width: 286px;
min-width: 286px;
padding: 18px 14px;
width: 210px;
min-width: 210px;
padding: 14px 10px;
overflow-y: auto;
align-self: stretch;
transition: width 0.25s ease, min-width 0.25s ease;
display: flex;
flex-direction: column;
}
.settings-nav.nav-collapsed {
width: 56px;
min-width: 56px;
padding: 12px 8px;
}
.settings-nav__intro {
padding: 6px 8px 16px;
padding: 4px 8px 10px;
border-bottom: 1px solid var(--mc-border-light);
margin-bottom: 8px;
margin-bottom: 6px;
}
.nav-title {
font-size: 28px;
font-weight: 800;
font-size: 20px;
font-weight: 700;
color: var(--mc-text-primary);
letter-spacing: -0.04em;
margin: 0 0 6px;
letter-spacing: -0.03em;
margin: 0 0 4px;
}
.nav-desc {
color: var(--mc-text-secondary);
font-size: 13px;
line-height: 1.65;
font-size: 12px;
line-height: 1.5;
}
.nav-item {
display: flex;
align-items: center;
gap: 10px;
gap: 8px;
width: 100%;
padding: 10px 12px;
padding: 8px 10px;
border: none;
background: transparent;
color: var(--mc-text-secondary);
font-size: 14px;
border-radius: 14px;
font-size: 13px;
border-radius: 10px;
cursor: pointer;
text-align: left;
text-decoration: none;
margin-bottom: 2px;
font-weight: 500;
transition: all 0.15s;
}
.nav-item:hover { background: var(--mc-bg-muted); color: var(--mc-text-primary); }
.nav-item.active { background: var(--mc-primary-bg); color: var(--mc-primary); font-weight: 600; box-shadow: inset 0 0 0 1px rgba(217, 109, 70, 0.08); }
.nav-icon { display: flex; align-items: center; flex-shrink: 0; }
.nav-collapsed .nav-item {
justify-content: center;
padding: 10px 8px;
}
.nav-collapse-btn {
display: flex;
align-items: center;
justify-content: center;
width: 100%;
height: 32px;
margin-top: auto;
border: none;
border-top: 1px solid var(--mc-border-light);
background: transparent;
color: var(--mc-text-tertiary);
cursor: pointer;
transition: all 0.15s;
flex-shrink: 0;
}
.nav-collapse-btn:hover {
background: var(--mc-bg-muted);
color: var(--mc-text-primary);
}
.settings-content {
flex: 1;
min-width: 0;
@ -159,16 +234,22 @@ function isActive(path: string) {
}
.security-layout {
flex-direction: column;
flex-direction: row;
height: auto;
}
.settings-nav {
width: 100%;
min-width: 100%;
width: 56px;
min-width: 56px;
align-self: auto;
padding: 12px 8px;
}
.settings-nav .settings-nav__intro { display: none; }
.settings-nav .nav-item { justify-content: center; padding: 10px 8px; }
.settings-nav .nav-label { display: none; }
.nav-collapse-btn { display: none; }
.settings-content {
overflow: visible;
}

View File

@ -2,24 +2,34 @@
<div class="mc-page-shell settings-shell">
<div class="mc-page-frame settings-frame">
<div class="mc-page-inner settings-layout">
<div class="settings-nav mc-surface-card">
<div class="settings-nav__intro">
<div class="settings-nav mc-surface-card" :class="{ 'nav-collapsed': navCollapsed }">
<div v-if="!navCollapsed" class="settings-nav__intro">
<div class="mc-page-kicker">{{ t('settings.kicker') }}</div>
<h2 class="nav-title">{{ t('settings.title') }}</h2>
<p class="nav-desc">{{ t('settings.layoutDesc') }}</p>
</div>
<template v-for="section in sections" :key="section.id">
<div v-if="section.isDivider" class="nav-divider">{{ section.label }}</div>
<router-link
v-else
:to="section.path"
class="nav-item"
:class="{ active: isActive(section.path) }"
<div v-if="section.isDivider && !navCollapsed" class="nav-divider">{{ section.label }}</div>
<el-tooltip
v-else-if="!section.isDivider"
:content="section.label"
placement="right"
:disabled="!navCollapsed"
>
<span class="nav-icon" v-html="section.icon"></span>
{{ section.label }}
</router-link>
<router-link
:to="section.path"
class="nav-item"
:class="{ active: isActive(section.path) }"
>
<span class="nav-icon" v-html="section.icon"></span>
<span v-if="!navCollapsed" class="nav-label">{{ section.label }}</span>
</router-link>
</el-tooltip>
</template>
<!-- 折叠切换按钮 -->
<button class="nav-collapse-btn" @click="toggleNav" :title="navCollapsed ? t('common.expandSidebar') : t('common.collapseSidebar')">
<svg v-if="!navCollapsed" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><polyline points="15 18 9 12 15 6"/></svg>
<svg v-else width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><polyline points="9 18 15 12 9 6"/></svg>
</button>
</div>
<div class="settings-content mc-surface-card">
@ -33,13 +43,42 @@
</template>
<script setup lang="ts">
import { computed } from 'vue'
import { computed, ref, onMounted, onBeforeUnmount } from 'vue'
import { useRoute } from 'vue-router'
import { useI18n } from 'vue-i18n'
const route = useRoute()
const { t } = useI18n()
//
const navCollapsed = ref(localStorage.getItem('mc-settings-nav-collapsed') === 'true')
const userExplicit = ref(localStorage.getItem('mc-settings-nav-collapsed') === 'true')
let mediumQuery: MediaQueryList | null = null
function toggleNav() {
navCollapsed.value = !navCollapsed.value
userExplicit.value = navCollapsed.value
localStorage.setItem('mc-settings-nav-collapsed', String(navCollapsed.value))
}
function handleMediumChange(e: MediaQueryListEvent | MediaQueryList) {
if (e.matches && !userExplicit.value) {
navCollapsed.value = true
} else if (!e.matches && !userExplicit.value) {
navCollapsed.value = false
}
}
onMounted(() => {
mediumQuery = window.matchMedia('(max-width: 1200px)')
handleMediumChange(mediumQuery)
mediumQuery.addEventListener('change', handleMediumChange)
})
onBeforeUnmount(() => {
mediumQuery?.removeEventListener('change', handleMediumChange)
})
const sections = computed(() => [
{
id: 'model',
@ -91,6 +130,12 @@ const sections = computed(() => [
label: t('security.sections.workspaces', 'Workspaces'),
icon: '<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><rect x="2" y="7" width="20" height="14" rx="2" ry="2"/><path d="M16 21V5a2 2 0 0 0-2-2h-4a2 2 0 0 0-2 2v16"/></svg>',
},
{
id: 'agent-context',
path: '/settings/agent-context',
label: t('nav.agentContext', '智能体上下文'),
icon: '<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><rect x="3" y="3" width="18" height="18" rx="2" ry="2"/><line x1="3" y1="9" x2="21" y2="9"/><line x1="9" y1="21" x2="9" y2="9"/></svg>',
},
{
id: 'members',
path: '/settings/members',
@ -105,12 +150,6 @@ const sections = computed(() => [
},
// Divider: Advanced
{ id: 'divider-advanced', path: '', label: t('settings.sections.advanced'), icon: '', isDivider: true },
{
id: 'agent-context',
path: '/settings/agent-context',
label: t('nav.agentContext', 'Agent Context'),
icon: '<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><rect x="3" y="3" width="18" height="18" rx="2" ry="2"/><line x1="3" y1="9" x2="21" y2="9"/><line x1="9" y1="21" x2="9" y2="9"/></svg>',
},
{
id: 'cron-jobs',
path: '/settings/cron-jobs',
@ -170,28 +209,65 @@ function isActive(path: string) {
}
.settings-nav {
width: 286px;
min-width: 286px;
padding: 18px 14px;
width: 210px;
min-width: 210px;
padding: 14px 10px;
overflow-y: auto;
align-self: stretch;
transition: width 0.25s ease, min-width 0.25s ease;
display: flex;
flex-direction: column;
}
.settings-nav.nav-collapsed {
width: 56px;
min-width: 56px;
padding: 12px 8px;
}
.settings-nav__intro {
padding: 6px 8px 16px;
padding: 4px 8px 10px;
border-bottom: 1px solid var(--mc-border-light);
margin-bottom: 8px;
margin-bottom: 6px;
}
.nav-title { font-size: 28px; font-weight: 800; color: var(--mc-text-primary); letter-spacing: -0.04em; margin: 0 0 6px; }
.nav-desc { color: var(--mc-text-secondary); font-size: 13px; line-height: 1.65; margin: 0; }
.nav-item { display: flex; align-items: center; gap: 10px; width: 100%; padding: 10px 12px; border: none; background: none; border-radius: 14px; font-size: 14px; font-weight: 500; color: var(--mc-text-secondary); cursor: pointer; transition: all 0.15s; text-align: left; text-decoration: none; }
.nav-title { font-size: 20px; font-weight: 700; color: var(--mc-text-primary); letter-spacing: -0.03em; margin: 0 0 4px; }
.nav-desc { color: var(--mc-text-secondary); font-size: 12px; line-height: 1.5; margin: 0; }
.nav-item { display: flex; align-items: center; gap: 8px; width: 100%; padding: 8px 10px; border: none; background: none; border-radius: 10px; font-size: 13px; font-weight: 500; color: var(--mc-text-secondary); cursor: pointer; transition: all 0.15s; text-align: left; text-decoration: none; }
.nav-item:hover { background: var(--mc-bg-muted); color: var(--mc-text-primary); }
.nav-item.active { background: var(--mc-primary-bg); color: var(--mc-primary); font-weight: 600; box-shadow: inset 0 0 0 1px rgba(217, 109, 70, 0.08); }
.nav-item + .nav-item { margin-top: 2px; }
.nav-collapsed .nav-item {
justify-content: center;
padding: 10px 8px;
}
.nav-icon { width: 18px; height: 18px; display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; }
.nav-icon :deep(svg) { width: 18px; height: 18px; display: block; }
.nav-divider { font-size: 11px; font-weight: 700; color: var(--mc-text-tertiary); text-transform: uppercase; letter-spacing: 0.1em; padding: 18px 8px 8px; margin-top: 4px; }
.nav-divider { font-size: 10px; font-weight: 700; color: var(--mc-text-tertiary); text-transform: uppercase; letter-spacing: 0.1em; padding: 12px 8px 4px; margin-top: 2px; }
.nav-collapse-btn {
display: flex;
align-items: center;
justify-content: center;
width: 100%;
height: 32px;
margin-top: auto;
border: none;
border-top: 1px solid var(--mc-border-light);
background: transparent;
color: var(--mc-text-tertiary);
cursor: pointer;
transition: all 0.15s;
flex-shrink: 0;
}
.nav-collapse-btn:hover {
background: var(--mc-bg-muted);
color: var(--mc-text-primary);
}
.settings-content {
flex: 1;
min-width: 0;
@ -215,8 +291,13 @@ function isActive(path: string) {
overflow: visible;
}
.settings-layout { flex-direction: column; height: auto; }
.settings-nav { width: 100%; min-width: 100%; max-height: none; align-self: auto; }
.settings-layout { flex-direction: row; height: auto; }
.settings-nav { width: 56px; min-width: 56px; max-height: none; align-self: auto; padding: 12px 8px; }
.settings-nav .settings-nav__intro { display: none; }
.settings-nav .nav-divider { display: none; }
.settings-nav .nav-item { justify-content: center; padding: 10px 8px; }
.settings-nav .nav-label { display: none; }
.nav-collapse-btn { display: none; }
.settings-content { min-height: 0; overflow: visible; }
.settings-content__inner { overflow: visible; padding-right: 0; }
}

View File

@ -13,7 +13,7 @@
<img src="/logo/mateclaw_logo_s.png" alt="MateClaw" class="logo-img" />
</div>
<transition name="fade">
<div v-if="!sidebarCollapsed" class="logo-text">
<div v-if="!effectiveCollapsed" class="logo-text">
<span class="logo-name">Mate<span class="logo-name-highlight">Claw</span></span>
<span class="logo-version">v{{ appVersion }}</span>
</div>
@ -24,7 +24,7 @@
:aria-label="sidebarToggleLabel"
@click="toggleSidebar"
>
<svg v-if="!sidebarCollapsed" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
<svg v-if="!effectiveCollapsed" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
<polyline points="15 18 9 12 15 6"/>
</svg>
<svg v-else width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
@ -34,24 +34,24 @@
</div>
<!-- 工作区切换 -->
<WorkspaceSwitcher :collapsed="sidebarCollapsed" />
<WorkspaceSwitcher :collapsed="effectiveCollapsed" />
<!-- 导航菜单 -->
<nav class="sidebar-nav">
<template v-for="group in navGroups" :key="group.key">
<div class="nav-group">
<div v-if="!sidebarCollapsed" class="nav-group-title">{{ group.label }}</div>
<div v-if="!effectiveCollapsed" class="nav-group-title">{{ group.label }}</div>
<router-link
v-for="item in group.items"
:key="item.path"
:to="item.path"
class="nav-item"
:class="{ active: isNavItemActive(item) }"
:title="sidebarCollapsed ? item.label : ''"
:title="effectiveCollapsed ? item.label : ''"
@click="onNavClick"
>
<span class="nav-icon" v-html="item.icon"></span>
<span v-if="!sidebarCollapsed" class="nav-label">{{ item.label }}</span>
<span v-if="!effectiveCollapsed" class="nav-label">{{ item.label }}</span>
</router-link>
</div>
</template>
@ -246,6 +246,9 @@ async function fetchHealthStatus() {
const isMobile = ref(false)
const mobileMenuOpen = ref(false)
let mobileQuery: MediaQueryList | null = null
// 1024px
let mediumQuery: MediaQueryList | null = null
const userExplicitCollapse = ref(localStorage.getItem('mc-sidebar-collapsed') === 'true')
function handleMobileChange(e: MediaQueryListEvent | MediaQueryList) {
isMobile.value = e.matches
@ -253,11 +256,23 @@ function handleMobileChange(e: MediaQueryListEvent | MediaQueryList) {
if (e.matches) footerPanelOpen.value = false
}
function handleMediumChange(e: MediaQueryListEvent | MediaQueryList) {
if (e.matches && !userExplicitCollapse.value) {
sidebarCollapsed.value = true
} else if (!e.matches && !userExplicitCollapse.value) {
sidebarCollapsed.value = false
}
}
onMounted(async () => {
mobileQuery = window.matchMedia('(max-width: 768px)')
handleMobileChange(mobileQuery)
mobileQuery.addEventListener('change', handleMobileChange)
mediumQuery = window.matchMedia('(max-width: 1024px)')
handleMediumChange(mediumQuery)
mediumQuery.addEventListener('change', handleMediumChange)
// Check onboarding status
if (!localStorage.getItem('mc-onboarding-done')) {
try {
@ -276,6 +291,7 @@ onMounted(async () => {
onBeforeUnmount(() => {
mobileQuery?.removeEventListener('change', handleMobileChange)
mediumQuery?.removeEventListener('change', handleMediumChange)
})
function onNavClick() {
@ -286,6 +302,7 @@ const username = computed(() => localStorage.getItem('username') || 'User')
const role = computed(() => localStorage.getItem('role') || 'user')
const userInitial = computed(() => username.value.charAt(0).toUpperCase())
const roleLabel = computed(() => role.value === 'admin' ? t('nav.roleAdmin') : t('nav.roleUser'))
const effectiveCollapsed = computed(() => sidebarCollapsed.value && !isMobile.value)
const sidebarToggleLabel = computed(() => sidebarCollapsed.value ? t('common.expandSidebar') : t('common.collapseSidebar'))
const currentLocaleValue = computed(() => currentLocale.value)
@ -380,6 +397,7 @@ const navGroups = computed(() => [
function toggleSidebar() {
sidebarCollapsed.value = !sidebarCollapsed.value
userExplicitCollapse.value = sidebarCollapsed.value
localStorage.setItem('mc-sidebar-collapsed', String(sidebarCollapsed.value))
if (!sidebarCollapsed.value) {
footerPanelOpen.value = false
@ -1121,4 +1139,26 @@ watch(() => workspaceStore.currentWorkspaceId, () => {
backdrop-filter: none;
}
}
@media (max-width: 480px) {
.mobile-topbar {
padding: 8px 10px;
margin: 0 0 8px;
border-radius: 12px;
gap: 8px;
}
.mobile-topbar-title {
font-size: 14px;
}
.mobile-menu-btn {
width: 32px;
height: 32px;
}
.main-content {
padding: 8px;
}
}
</style>