forked from hellodigua/ChatLab
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathApp.vue
More file actions
102 lines (93 loc) · 3.34 KB
/
App.vue
File metadata and controls
102 lines (93 loc) · 3.34 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
<script setup lang="ts">
import { onMounted } from 'vue'
import { storeToRefs } from 'pinia'
import { useRoute } from 'vue-router'
import { useI18n } from 'vue-i18n'
import TitleBar from '@/components/common/TitleBar.vue'
import Sidebar from '@/components/common/Sidebar.vue'
import ScreenCaptureModal from '@/components/common/ScreenCaptureModal.vue'
import { ChatRecordDrawer } from '@/components/common/ChatRecord'
import GlobalTaskBar from '@/components/AIChat/GlobalTaskBar.vue'
import { useSessionStore } from '@/stores/session'
import { useLayoutStore } from '@/stores/layout'
import { useSettingsStore } from '@/stores/settings'
import { useLLMStore } from '@/stores/llm'
const { t } = useI18n()
const sessionStore = useSessionStore()
const layoutStore = useLayoutStore()
const settingsStore = useSettingsStore()
const llmStore = useLLMStore()
const { isInitialized } = storeToRefs(sessionStore)
const route = useRoute()
const tooltip = {
delayDuration: 100,
}
// 应用启动时初始化
onMounted(async () => {
// 平台检测 - 设置 CSS 类名以驱动平台差异化样式(如标题栏安全区域高度)
const platform = navigator.platform.toLowerCase()
if (platform.includes('win')) {
document.documentElement.classList.add('platform-windows')
} else if (platform.includes('linux')) {
document.documentElement.classList.add('platform-linux')
}
// 初始化语言设置(同步 i18n 和 dayjs,异步加载脱敏规则)
await settingsStore.initLocale()
// 初始化 LLM 配置(预加载,避免首次使用时延迟)
llmStore.init()
// 从数据库加载会话列表
await sessionStore.loadSessions()
})
</script>
<template>
<UApp :tooltip="tooltip">
<!-- 自定义标题栏 - 拖拽区域 + 窗口控制按钮 -->
<TitleBar />
<div class="relative flex h-screen w-full overflow-hidden bg-gray-50 dark:bg-gray-900">
<!-- 主内容区域 -->
<template v-if="!isInitialized">
<div class="flex h-full w-full items-center justify-center">
<div class="flex flex-col items-center justify-center text-center">
<UIcon name="i-heroicons-arrow-path" class="h-8 w-8 animate-spin text-pink-500" />
<p class="mt-2 text-sm text-gray-500">{{ t('common.initializing') }}</p>
</div>
</div>
</template>
<template v-else>
<Sidebar />
<main class="relative flex-1 overflow-hidden">
<router-view v-slot="{ Component }">
<Transition name="page-fade" mode="out-in">
<component :is="Component" :key="route.path" />
</Transition>
</router-view>
</main>
</template>
</div>
<ScreenCaptureModal
:open="layoutStore.showScreenCaptureModal"
:image-data="layoutStore.screenCaptureImage"
@update:open="(v) => (v ? null : layoutStore.closeScreenCaptureModal())"
/>
<!-- 全局聊天记录查看器 -->
<ChatRecordDrawer />
<!-- 全局 AI 后台任务条:允许用户离开当前页面后仍然快速返回进行中的对话。 -->
<GlobalTaskBar />
</UApp>
</template>
<style scoped>
.page-fade-enter-active,
.page-fade-leave-active {
transition:
opacity 0.2s ease,
transform 0.2s ease;
}
.page-fade-enter-from {
opacity: 0;
transform: translateY(10px);
}
.page-fade-leave-to {
opacity: 0;
transform: translateY(-10px);
}
</style>