fix(knowledge-base): 优化知识库页面,重构后端job队列
This commit is contained in:
1 parent
7e4a2037d8
commit
b476b58a91
38 files changed
+992
-428
No files matched your search
@@ -6,11 +6,15 @@
|
||||
import { inject } from 'vue';
|
||||
import { useRoute } from 'vue-router';
|
||||
import {
|
||||
LayoutGrid, Bot, FileText, User, LogOut, Edit, Megaphone, Clock, Package,
|
||||
LayoutGrid, Bot, FileText, User, LogOut, Edit, Megaphone, Clock, Package, PanelLeftClose, PanelLeftOpen,
|
||||
} from 'lucide-vue-next';
|
||||
import { WORKSPACE_PATHS } from '../constants/routes';
|
||||
import { WORKSPACE_KEY } from '../composables/workspace.context';
|
||||
|
||||
defineProps<{
|
||||
collapsed?: boolean;
|
||||
}>();
|
||||
|
||||
const ws = inject(WORKSPACE_KEY)! as any;
|
||||
const route = useRoute();
|
||||
|
||||
@@ -30,54 +34,97 @@ function isActive(match: readonly string[]) {
|
||||
|
||||
<template>
|
||||
<aside class="lg:sticky lg:top-0 lg:h-screen">
|
||||
<div class="flex h-full flex-col border-r border-default bg-surface px-5 py-6 shadow-sm">
|
||||
<div class="border-b border-subtle pb-6">
|
||||
<div class="flex items-center gap-3">
|
||||
<div class="flex h-12 w-12 items-center justify-center rounded-2xl bg-gradient-to-br from-brand-500 via-brand-600 to-purple-600 text-white shadow-lg shadow-brand-500/25">
|
||||
<Bot class="h-6 w-6" />
|
||||
<div
|
||||
class="flex h-full flex-col border-r border-default bg-surface shadow-sm transition-all duration-200"
|
||||
:class="collapsed ? 'px-3 py-4' : 'px-4 py-4'"
|
||||
>
|
||||
<template v-if="collapsed">
|
||||
<button
|
||||
type="button"
|
||||
class="mb-6 inline-flex h-10 w-full items-center justify-center rounded-xl text-muted transition-colors hover:bg-surface-soft hover:text-secondary"
|
||||
:title="$t('workspace.expandSidebar')"
|
||||
@click="ws.toggleSidebarCollapsed"
|
||||
>
|
||||
<PanelLeftOpen class="h-5 w-5" />
|
||||
</button>
|
||||
</template>
|
||||
|
||||
<div class="border-b border-subtle pb-4">
|
||||
<div class="flex items-center gap-3" :class="collapsed ? 'justify-center' : ''">
|
||||
<div class="flex h-10 w-10 shrink-0 items-center justify-center rounded-full bg-gradient-to-br from-brand-500 via-brand-600 to-sky-600 text-sm font-bold text-white shadow-sm shadow-brand-500/25">
|
||||
AI
|
||||
</div>
|
||||
<div class="min-w-0">
|
||||
<div class="text-2xl font-extrabold tracking-tight text-primary">{{ $t('workspace.brandTitle') }}</div>
|
||||
<div class="truncate text-xs font-medium text-muted">
|
||||
<div v-if="!collapsed" class="min-w-0 flex-1">
|
||||
<div class="truncate text-lg font-bold text-primary">{{ $t('workspace.brandTitle') }}</div>
|
||||
<div class="mt-1 truncate text-[11px] text-muted">
|
||||
{{ ws.currentUser?.username }} / {{ ws.currentUser?.role }}
|
||||
</div>
|
||||
</div>
|
||||
<button
|
||||
v-if="!collapsed"
|
||||
type="button"
|
||||
class="ml-2 inline-flex h-9 w-9 shrink-0 items-center justify-center rounded-xl text-muted transition-colors hover:bg-surface-soft hover:text-secondary"
|
||||
:title="$t('workspace.collapseSidebar')"
|
||||
@click="ws.toggleSidebarCollapsed"
|
||||
>
|
||||
<PanelLeftClose class="h-5 w-5" />
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="flex-1 py-6">
|
||||
<div class="flex-1 py-4">
|
||||
<nav class="space-y-2">
|
||||
<RouterLink
|
||||
v-for="item in linkItems"
|
||||
:key="item.path"
|
||||
:to="item.path"
|
||||
class="ws-nav-btn"
|
||||
:class="{ 'ws-nav-btn--active': isActive(item.match) }"
|
||||
:class="[
|
||||
{ 'ws-nav-btn--active': isActive(item.match) },
|
||||
collapsed ? 'justify-center px-0' : '',
|
||||
]"
|
||||
:title="$t(item.labelKey)"
|
||||
>
|
||||
<component :is="item.icon" class="h-4 w-4" />
|
||||
<span>{{ $t(item.labelKey) }}</span>
|
||||
<component :is="item.icon" class="h-[18px] w-[18px]" />
|
||||
<span v-if="!collapsed">{{ $t(item.labelKey) }}</span>
|
||||
</RouterLink>
|
||||
<button
|
||||
type="button"
|
||||
class="ws-nav-btn w-full"
|
||||
:class="{ 'ws-nav-btn--active': isActive(['workspace-knowledge-base']) }"
|
||||
:class="[
|
||||
{ 'ws-nav-btn--active': isActive(['workspace-knowledge-base', 'workspace-knowledge-base-group']) },
|
||||
collapsed ? 'justify-center px-0' : '',
|
||||
]"
|
||||
:title="$t('workspace.nav.knowledgeBase')"
|
||||
@click="ws.navigateToKnowledgeBase"
|
||||
>
|
||||
<FileText class="h-4 w-4" />
|
||||
<span>{{ $t('workspace.nav.knowledgeBase') }}</span>
|
||||
<FileText class="h-[18px] w-[18px]" />
|
||||
<span v-if="!collapsed">{{ $t('workspace.nav.knowledgeBase') }}</span>
|
||||
</button>
|
||||
</nav>
|
||||
</div>
|
||||
|
||||
<div class="border-t border-subtle pt-6">
|
||||
<div class="border-t border-subtle pt-4">
|
||||
<div class="space-y-2">
|
||||
<button type="button" @click="ws.navigateToGeneralChat" class="ws-nav-btn">
|
||||
<Bot class="h-4 w-4" />
|
||||
<span>{{ $t('workspace.nav.backToChat') }}</span>
|
||||
<button
|
||||
type="button"
|
||||
@click="ws.navigateToGeneralChat"
|
||||
class="ws-nav-btn"
|
||||
:class="collapsed ? 'justify-center px-0' : ''"
|
||||
:title="$t('workspace.nav.backToChat')"
|
||||
>
|
||||
<Bot class="h-[18px] w-[18px]" />
|
||||
<span v-if="!collapsed">{{ $t('workspace.nav.backToChat') }}</span>
|
||||
</button>
|
||||
<button type="button" @click="ws.handleLogout" class="ws-nav-btn ws-nav-btn--danger">
|
||||
<LogOut class="h-4 w-4" />
|
||||
<span>{{ $t('workspace.nav.logout') }}</span>
|
||||
<button
|
||||
type="button"
|
||||
@click="ws.handleLogout"
|
||||
class="ws-nav-btn ws-nav-btn--danger"
|
||||
:class="collapsed ? 'justify-center px-0' : ''"
|
||||
:title="$t('workspace.nav.logout')"
|
||||
>
|
||||
<LogOut class="h-[18px] w-[18px]" />
|
||||
<span v-if="!collapsed">{{ $t('workspace.nav.logout') }}</span>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -30,6 +30,7 @@ export function useWorkspace() {
|
||||
const deps = { t, locale, msg, router, route, setThemePreference, appliedTheme };
|
||||
const isLoading = ref(true);
|
||||
const currentUser = ref<WorkspaceUser | null>(null);
|
||||
const isSidebarCollapsed = ref(false);
|
||||
|
||||
const sessionRef: { handleLogout?: () => void } = {};
|
||||
const home = useWorkspaceHome(deps, {
|
||||
@@ -65,6 +66,7 @@ export function useWorkspace() {
|
||||
onMounted(async () => {
|
||||
window.addEventListener('hxops:logout', session.onAuthLogout);
|
||||
localeApi.loadLanguagePreference();
|
||||
isSidebarCollapsed.value = localStorage.getItem('hxops.workspace.sidebarCollapsed') === 'true';
|
||||
|
||||
session.loadAuthUser();
|
||||
if (!session.isLoggedIn.value) {
|
||||
@@ -88,6 +90,11 @@ export function useWorkspace() {
|
||||
window.removeEventListener('hxops:logout', session.onAuthLogout);
|
||||
});
|
||||
|
||||
const toggleSidebarCollapsed = () => {
|
||||
isSidebarCollapsed.value = !isSidebarCollapsed.value;
|
||||
localStorage.setItem('hxops.workspace.sidebarCollapsed', String(isSidebarCollapsed.value));
|
||||
};
|
||||
|
||||
return reactive({
|
||||
config,
|
||||
msg,
|
||||
@@ -95,6 +102,8 @@ export function useWorkspace() {
|
||||
route,
|
||||
isMobile,
|
||||
isLoading,
|
||||
isSidebarCollapsed,
|
||||
toggleSidebarCollapsed,
|
||||
...localeApi,
|
||||
...session,
|
||||
...home,
|
||||
|
||||
@@ -17,6 +17,7 @@ const ROUTE_NAME_TO_SIDEBAR: Record<string, WorkspaceSidebarItem> = {
|
||||
'workspace-applications': 'applications',
|
||||
'workspace-updates': 'updates',
|
||||
'workspace-knowledge-base': 'knowledge_base',
|
||||
'workspace-knowledge-base-group': 'knowledge_base',
|
||||
'workspace-schedule-runs': 'schedule_runs',
|
||||
'workspace-shipping-notice': 'shipping_notice',
|
||||
'workspace-feedback': 'feedback',
|
||||
@@ -173,7 +174,7 @@ export function useWorkspaceNavigation(deps: WorkspaceDeps, options: NavigationO
|
||||
if (name === 'workspace-schedule-runs') {
|
||||
await loadWorkspaceScheduleRuns();
|
||||
}
|
||||
if (name === 'workspace-knowledge-base' && !hasKnowledgeBaseAccess.value) {
|
||||
if (['workspace-knowledge-base', 'workspace-knowledge-base-group'].includes(name) && !hasKnowledgeBaseAccess.value) {
|
||||
showKnowledgeBaseAccessDenied();
|
||||
await router.replace(WORKSPACE_PATHS.applications);
|
||||
}
|
||||
|
||||
@@ -42,8 +42,11 @@ const mobileTabs = [
|
||||
</div>
|
||||
</header>
|
||||
|
||||
<div class="grid min-h-screen gap-0 lg:grid-cols-[232px_minmax(0,1fr)]">
|
||||
<WorkspaceSidebar v-if="!ws.isMobile" />
|
||||
<div
|
||||
class="grid min-h-screen gap-0 transition-[grid-template-columns] duration-200"
|
||||
:class="ws.isMobile ? '' : (ws.isSidebarCollapsed ? 'lg:grid-cols-[72px_minmax(0,1fr)]' : 'lg:grid-cols-[320px_minmax(0,1fr)]')"
|
||||
>
|
||||
<WorkspaceSidebar v-if="!ws.isMobile" :collapsed="ws.isSidebarCollapsed" />
|
||||
|
||||
<section class="ws-main" :class="ws.isMobile ? 'pb-20' : ''">
|
||||
<RouterView />
|
||||
|
||||
Reference in new issue
Block a user