refactor(chat + workspace): chat和workspace重构,子路由、懒加载等

This commit is contained in:
sophie committed 2026-06-10 16:39:05 +08:00
1 parent 0a647a0b79
commit 1f1f7236b0
57 files changed
+4356 -3798

No files matched your search

@@ -0,0 +1,71 @@
<script setup lang="ts">
/**
* features/workspace/views/WorkspaceLayout.vue
* 工作台布局壳:初始化 composable、侧边栏、子路由出口与全局弹窗。
*/
import { provide } from 'vue';
import { LayoutGrid, Bot, User } from 'lucide-vue-next';
import { WORKSPACE_PATHS } from '../constants/routes';
import { useWorkspace } from '../composables/useWorkspace';
import { WORKSPACE_KEY } from '../composables/workspace.context';
import WorkspaceSidebar from '../components/WorkspaceSidebar.vue';
import WorkspaceModals from '../components/WorkspaceModals.vue';
const ws = useWorkspace();
provide(WORKSPACE_KEY, ws);
const mobileTabs = [
{ key: 'applications', path: WORKSPACE_PATHS.applications, icon: LayoutGrid, labelKey: 'workspace.mobileTabs.applications' },
{ key: 'history', path: WORKSPACE_PATHS.history, icon: Bot, labelKey: 'workspace.mobileTabs.history' },
{ key: 'profile', path: WORKSPACE_PATHS.profile, icon: User, labelKey: 'workspace.mobileTabs.me' },
] as const;
</script>
<template>
<div class="page-shell min-h-screen font-sans animate-fade-in">
<div v-if="ws.isLoading" class="animate-pulse p-8 space-y-8">
<div class="h-48 bg-surface-strong rounded-2xl"></div>
</div>
<div v-else>
<header v-if="ws.isMobile" class="sticky top-0 z-30 flex items-center justify-between border-b border-default bg-surface px-4 py-2.5">
<div class="flex items-center gap-2">
<button
type="button"
@click="ws.navigateToGeneralChat"
class="flex h-7 w-7 items-center justify-center rounded-lg bg-gradient-to-br from-brand-500 via-brand-600 to-purple-600 text-xs font-bold text-white shadow-sm shadow-brand-500/20"
:title="$t('workspace.nav.backToChat')"
>
返
</button>
<span class="text-sm font-semibold text-primary">{{ ws.mobileTabTitle }}</span>
</div>
</header>
<div class="grid min-h-screen gap-0 lg:grid-cols-[232px_minmax(0,1fr)]">
<WorkspaceSidebar v-if="!ws.isMobile" />
<section class="ws-main" :class="ws.isMobile ? 'pb-20' : ''">
<RouterView />
</section>
</div>
<nav v-if="ws.isMobile" class="fixed bottom-0 left-0 right-0 z-40 border-t border-default bg-surface safe-bottom">
<div class="flex h-14 items-center justify-around">
<RouterLink
v-for="tab in mobileTabs"
:key="tab.key"
:to="tab.path"
class="flex flex-1 flex-col items-center justify-center gap-0.5 py-1 transition-colors"
:class="ws.mobileTabActive === tab.key ? 'text-brand-600' : 'text-muted'"
>
<component :is="tab.icon" class="h-5 w-5" />
<span class="text-[10px] font-medium">{{ $t(tab.labelKey) }}</span>
</RouterLink>
</div>
</nav>
</div>
<WorkspaceModals />
</div>
</template>