feat: implement theme synchronization and loading skeletons across various components, enhancing user experience during content loading

This commit is contained in:
wizardchen
2026-04-11 15:03:20 +08:00
committed by lyingbug
parent 1a4b7b390d
commit 6d8b47e57c
15 changed files with 441 additions and 19 deletions
+4
View File
@@ -140,6 +140,9 @@ window.open=function(url){
};
})();`
// wailsThemeSyncJS:与 index.html 首屏一致,在 DomReady 再跑一遍,覆盖 Ctrl+R 后 runtime 就绪时机
const wailsThemeSyncJS = `(function(){try{var t=localStorage.getItem('WeKnora_theme')||'light';if(t==='system')t=window.matchMedia('(prefers-color-scheme: dark)').matches?'dark':'light';var bg=t==='dark'?'#181818':'#eee';document.documentElement.setAttribute('theme-mode',t);document.documentElement.style.background=bg;document.documentElement.style.minHeight='100%';document.documentElement.style.colorScheme=t==='dark'?'dark':'light';if(document.body){document.body.style.background=bg;document.body.style.minHeight='100%';}var w=window.runtime;if(!w)return;if(t==='dark'){if(w.WindowSetDarkTheme)w.WindowSetDarkTheme();if(w.WindowSetBackgroundColour)w.WindowSetBackgroundColour(24,24,24,255);}else{if(w.WindowSetLightTheme)w.WindowSetLightTheme();if(w.WindowSetBackgroundColour)w.WindowSetBackgroundColour(238,238,238,255);}}catch(e){}})()`
func main() {
// For macOS .app bundle, the working directory is usually "/" or the MacOS folder.
// We need to change the working directory to the Resources folder where our configs are.
@@ -286,6 +289,7 @@ func main() {
StartHidden: false, // Show window on startup
OnStartup: app.startup,
OnDomReady: func(ctx context.Context) {
wailsruntime.WindowExecJS(ctx, wailsThemeSyncJS)
wailsruntime.WindowExecJS(ctx, dragHandlerJS)
// 注入真实 API 根路径(与 window.location.origin 不同);无 Go 绑定时仍可显示。
if u := strings.TrimSpace(app.backendURL); u != "" {
+50
View File
@@ -15,8 +15,58 @@
<link rel="apple-touch-icon" sizes="120x120" type="image/png" href="./public/favicon.ico"/>
</head>
<body>
<script>
(function(){
var t=localStorage.getItem('WeKnora_theme')||'light';
if(t==='system')t=window.matchMedia('(prefers-color-scheme:dark)').matches?'dark':'light';
document.documentElement.setAttribute('theme-mode',t);
/* 与 theme.css 中 --td-bg-color-page 一致,避免样式加载后整页背景从 #fff 跳到 #eee 触发重绘闪动 */
var bg=t==='dark'?'#181818':'#eee';
document.documentElement.style.background=bg;
document.documentElement.style.minHeight='100%';
document.documentElement.style.colorScheme=t==='dark'?'dark':'light';
document.body.style.background=bg;
document.body.style.minHeight='100%';
try{
var w=window.runtime;
if(w){
if(t==='dark'){
if(w.WindowSetDarkTheme)w.WindowSetDarkTheme();
if(w.WindowSetBackgroundColour)w.WindowSetBackgroundColour(24,24,24,255);
}else{
if(w.WindowSetLightTheme)w.WindowSetLightTheme();
if(w.WindowSetBackgroundColour)w.WindowSetBackgroundColour(238,238,238,255);
}
}
}catch(_){}
})();
</script>
<script>
(function(){
try {
if (localStorage.getItem('weknora_lite_mode') !== 'true') return;
var saved = sessionStorage.getItem('weknora_lite_last_path');
if (!saved || saved.indexOf('/platform/') !== 0 || saved.indexOf('/platform/organizations') === 0) return;
var path = window.location.pathname;
if (path !== '/' && path !== '/platform' && path !== '/platform/knowledge-bases') return;
var target = saved.indexOf('#') >= 0 ? saved.slice(0, saved.indexOf('#')) : saved;
if (!target) return;
var current = window.location.pathname + window.location.search;
if (target !== current) window.history.replaceState(window.history.state, '', target);
} catch (e) {}
})();
</script>
<script src="/config.js"></script>
<div id="app"></div>
<script>
(function(){
var t=localStorage.getItem('WeKnora_theme')||'light';
if(t==='system')t=window.matchMedia('(prefers-color-scheme:dark)').matches?'dark':'light';
var bg=t==='dark'?'#181818':'#eee';
var el=document.getElementById('app');
if(el){ el.style.background=bg; el.style.minHeight='100%'; }
})();
</script>
<script type="module" src="/src/main.ts"></script>
</body>
</html>
+12
View File
@@ -145,6 +145,11 @@ onMounted(() => {
</t-config-provider>
</template>
<style>
html {
/* 提示 UA 使用对应配色绘制滚动条等,减少主题切换时的额外重绘 */
color-scheme: light dark;
}
body,
html,
#app {
@@ -160,4 +165,11 @@ html,
background: var(--td-bg-color-page);
color: var(--td-text-color-primary);
}
#app {
/* 独立合成层,减轻 WebKit 全量重绘时整窗与内容的撕裂感(桌面 WebView 尤其明显) */
isolation: isolate;
transform: translateZ(0);
backface-visibility: hidden;
}
</style>
+15
View File
@@ -61,6 +61,14 @@
</div>
</t-tooltip>
<div ref="submenuscrollContainer" @scroll="handleScroll" class="submenu" v-if="item.children && !uiStore.sidebarCollapsed">
<!-- 骨架屏占位 -->
<template v-if="loading && groupedSessions.length === 0">
<div v-for="n in 5" :key="'skel-'+n" class="submenu_item_p">
<div class="submenu_item">
<t-skeleton animation="gradient" style="margin-left:18px;width:80%" :row-col="[{ width: '100%', height: '16px' }]" />
</div>
</div>
</template>
<template v-for="(group, groupIndex) in groupedSessions" :key="groupIndex">
<div class="timeline_header">{{ group.label }}</div>
<div class="submenu_item_p" v-for="(subitem, subindex) in group.items" :key="subitem.id">
@@ -1025,6 +1033,11 @@ const onDragHandleMouseDown = (e: MouseEvent) => {
margin-left: 4px;
}
@keyframes menuItemFadeIn {
from { opacity: 0; transform: translateX(-4px); }
to { opacity: 1; transform: translateX(0); }
}
.timeline_header {
font-family: "PingFang SC";
font-size: 12px;
@@ -1034,6 +1047,7 @@ const onDragHandleMouseDown = (e: MouseEvent) => {
margin-top: 8px;
line-height: 20px;
user-select: none;
animation: menuItemFadeIn 0.25s ease-out;
&:first-child {
margin-top: 4px;
@@ -1044,6 +1058,7 @@ const onDragHandleMouseDown = (e: MouseEvent) => {
height: 44px;
padding: 4px 0px 4px 0px;
box-sizing: border-box;
animation: menuItemFadeIn 0.25s ease-out;
}
+37
View File
@@ -13,9 +13,46 @@ function getSystemTheme(): 'light' | 'dark' {
return window.matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : 'light'
}
/** Wails:与原生窗口底色 / 系统深浅色一致,减轻 Ctrl+R 整窗白闪(浅色与 --td-bg-color-page #eee 对齐) */
function syncWailsNativeChrome(effective: 'light' | 'dark') {
const bg = effective === 'dark' ? '#181818' : '#eeeeee'
document.documentElement.style.background = bg
document.documentElement.style.minHeight = '100%'
document.documentElement.style.colorScheme = effective === 'dark' ? 'dark' : 'light'
if (document.body) {
document.body.style.background = bg
document.body.style.minHeight = '100%'
}
const appEl = document.getElementById('app')
if (appEl) {
appEl.style.background = bg
appEl.style.minHeight = '100%'
}
const w = (window as unknown as {
runtime?: {
WindowSetDarkTheme?: () => void
WindowSetLightTheme?: () => void
WindowSetBackgroundColour?: (r: number, g: number, b: number, a: number) => void
}
}).runtime
if (!w?.WindowSetBackgroundColour) return
try {
if (effective === 'dark') {
w.WindowSetDarkTheme?.()
w.WindowSetBackgroundColour(24, 24, 24, 255)
} else {
w.WindowSetLightTheme?.()
w.WindowSetBackgroundColour(238, 238, 238, 255)
}
} catch {
/* 非桌面壳或未注入 runtime */
}
}
function applyTheme(mode: ThemeMode) {
const effective = mode === 'system' ? getSystemTheme() : mode
document.documentElement.setAttribute('theme-mode', effective)
syncWailsNativeChrome(effective)
}
export function useTheme() {
+4 -1
View File
@@ -20,4 +20,7 @@ app.use(createPinia());
app.use(router);
app.use(i18n);
app.mount("#app");
// 等首屏路由(含导航守卫、Lite 自动登录)完成后再挂载,避免先闪默认页再跳转
router.isReady().finally(() => {
app.mount("#app");
});
+46 -4
View File
@@ -1,7 +1,27 @@
import { createRouter, createWebHistory } from 'vue-router'
import { listKnowledgeBases } from '@/api/knowledge-base'
import type { RouteLocationNormalized } from 'vue-router'
import { useAuthStore } from '@/stores/auth'
import { validateToken, autoSetup } from '@/api/auth'
import { autoSetup } from '@/api/auth'
/** Lite /桌面 WebView 硬刷新时可能只打开 `/`,用 session 记住上次页面以便恢复 */
const LITE_LAST_PATH_KEY = 'weknora_lite_last_path'
function isLiteEdition(authStore: ReturnType<typeof useAuthStore>) {
return authStore.isLiteMode || localStorage.getItem('weknora_lite_mode') === 'true'
}
function isLiteSpaDefaultEntry(to: RouteLocationNormalized) {
return (
to.path === '/' ||
to.path === '/platform' ||
to.path === '/platform/knowledge-bases' ||
to.name === 'knowledgeBaseList'
)
}
function isSafeLiteRestoreTarget(path: string) {
return path.startsWith('/platform/') && !path.startsWith('/platform/organizations')
}
const router = createRouter({
history: createWebHistory(import.meta.env.BASE_URL),
@@ -134,11 +154,26 @@ function persistLoginResponse(authStore: ReturnType<typeof useAuthStore>, respon
}
let autoSetupAttempted = false
let liteDeepLinkRestoreDone = false
// 路由守卫:检查认证状态和系统初始化状态
router.beforeEach(async (to, from, next) => {
const authStore = useAuthStore()
// Lite:硬刷新后若落在默认首页,恢复本次会话中最后访问的 /platform 子路径
if (!liteDeepLinkRestoreDone) {
liteDeepLinkRestoreDone = true
if (isLiteEdition(authStore)) {
const saved = sessionStorage.getItem(LITE_LAST_PATH_KEY)
if (saved && isSafeLiteRestoreTarget(saved) && isLiteSpaDefaultEntry(to)) {
if (saved !== to.fullPath) {
next(saved)
return
}
}
}
}
// 如果访问的是登录页面或初始化页面,直接放行
if (to.meta.requiresAuth === false || to.meta.requiresInit === false) {
// 如果已登录用户访问登录页面,重定向到知识库列表页面
@@ -174,6 +209,13 @@ router.beforeEach(async (to, from, next) => {
}
next()
});
})
router.afterEach((to) => {
if (!isLiteEdition(useAuthStore())) return
if (to.path === '/login') return
if (!to.path.startsWith('/platform')) return
sessionStorage.setItem(LITE_LAST_PATH_KEY, to.fullPath)
})
export default router
+5
View File
@@ -135,6 +135,11 @@ export const useAuthStore = defineStore('auth', () => {
localStorage.removeItem('weknora_selected_tenant_name')
localStorage.removeItem('weknora_lite_mode')
isLiteMode.value = false
try {
sessionStorage.removeItem('weknora_lite_last_path')
} catch {
/* ignore */
}
}
const initFromStorage = () => {
+30
View File
@@ -39,6 +39,23 @@
</div>
</div>
<div class="agent-list-main">
<!-- 骨架屏占位 -->
<div v-if="loading && agents.length === 0" class="agent-card-wrap">
<div v-for="n in 6" :key="'skel-'+n" class="agent-card agent-card-skeleton">
<div class="card-header">
<div class="card-header-left">
<t-skeleton animation="gradient" :row-col="[[{ width: '32px', height: '32px', type: 'circle' }, { width: '40%', height: '18px' }]]" />
</div>
</div>
<div class="card-content">
<t-skeleton animation="gradient" :row-col="[{ width: '100%', height: '14px' }, { width: '70%', height: '14px' }]" />
</div>
<div class="card-bottom">
<t-skeleton animation="gradient" :row-col="[[{ width: '60px', height: '22px', type: 'rect' }, { width: '60px', height: '22px', type: 'rect' }]]" />
</div>
</div>
</div>
<!-- 全部:我的 + 共享 -->
<div v-if="spaceSelection === 'all' && filteredAgents.length > 0" class="agent-card-wrap">
<div
@@ -1184,10 +1201,23 @@ defineExpose({
}
@keyframes contentFadeIn {
from { opacity: 0; transform: translateY(6px); }
to { opacity: 1; transform: translateY(0); }
}
.agent-card-wrap {
display: grid;
gap: 20px;
grid-template-columns: 1fr;
animation: contentFadeIn 0.32s ease-out;
}
.agent-card-skeleton {
cursor: default;
.card-header { margin-bottom: 16px; }
.card-content { flex: 1; }
.card-bottom { margin-top: auto; }
}
/* 与知识库列表卡片统一尺寸:160px 高、18px 20px 内边距、12px 圆角 */
+57 -3
View File
@@ -2,9 +2,33 @@
<div class="chat">
<div ref="scrollContainer" class="chat_scroll_box" @scroll="handleScroll">
<div class="msg_list">
<!-- 消息列表骨架屏 -->
<div v-if="historyLoading && messagesList.length === 0" class="msg-skeleton-list">
<div class="msg-skeleton msg-skeleton-user">
<t-skeleton animation="gradient" :row-col="[{ width: '45%', height: '36px', type: 'rect' }]" />
</div>
<div class="msg-skeleton msg-skeleton-bot">
<t-skeleton animation="gradient" :row-col="[{ width: '80%', height: '16px' }, { width: '100%', height: '16px' }, { width: '60%', height: '16px' }]" />
</div>
<div class="msg-skeleton msg-skeleton-user">
<t-skeleton animation="gradient" :row-col="[{ width: '35%', height: '36px', type: 'rect' }]" />
</div>
<div class="msg-skeleton msg-skeleton-bot">
<t-skeleton animation="gradient" :row-col="[{ width: '70%', height: '16px' }, { width: '90%', height: '16px' }]" />
</div>
</div>
<!-- 推荐问题卡片 - 仅在新会话(无消息)时展示 -->
<div v-if="messagesList.length === 0 && !loading" class="suggested-questions-container" :class="{ 'has-questions': suggestedQuestions.length > 0 }">
<transition name="sq-fade">
<div v-if="messagesList.length === 0 && !loading" class="suggested-questions-container" :class="{ 'has-questions': suggestedQuestions.length > 0 || suggestedQuestionsLoading }">
<!-- 骨架屏占位 -->
<div v-if="suggestedQuestionsLoading && suggestedQuestions.length === 0" class="suggested-questions-inner">
<div class="suggested-questions-title"><t-skeleton animation="gradient" :row-col="[{ width: '120px', height: '18px' }]" /></div>
<div class="suggested-questions-grid">
<div v-for="n in 6" :key="'sq-skel-'+n" class="suggested-question-card sq-card-skeleton">
<t-skeleton animation="gradient" :row-col="[{ width: '90%', height: '14px' }, { width: '60%', height: '14px' }]" />
</div>
</div>
</div>
<transition v-else appear name="sq-fade">
<div v-if="suggestedQuestions.length > 0" class="suggested-questions-inner">
<div class="suggested-questions-title">{{ t('chat.suggestedQuestions') }}</div>
<div class="suggested-questions-grid">
@@ -103,6 +127,7 @@ const scrollLock = ref(false);
const isNeedTitle = ref(false);
const isFirstEnter = ref(true);
const loading = ref(false);
const historyLoading = ref(true);
let fullContent = ref('')
let userquery = ref('')
const scrollContainer = ref(null)
@@ -212,7 +237,8 @@ watch([() => route.params], (newvalue) => {
messagesList.splice(0);
session_id.value = newvalue[0].chatid;
// 切换会话时,重置状态(加载历史消息不应显示loading)
// 切换会话时,重置状态
historyLoading.value = true;
loading.value = false;
isReplying.value = false;
currentAssistantMessageId.value = '';
@@ -271,6 +297,8 @@ const getmsgList = (data, isScrollType = false, scrollHeight) => {
created_at.value = res.data[0].created_at;
handleMsgList(res.data, isScrollType, scrollHeight);
}
}).finally(() => {
historyLoading.value = false;
})
}
@@ -1103,6 +1131,7 @@ onMounted(async () => {
checkmenuTitle(session_id.value)
if (firstQuery.value) {
scrollLock.value = true;
historyLoading.value = false;
sendMsg(firstQuery.value, firstModelId.value || '', firstMentionedItems.value || [], firstImageFiles.value || []);
usemenuStore.changeFirstQuery('', [], '', []);
} else {
@@ -1236,6 +1265,30 @@ onBeforeRouteUpdate((to, from, next) => {
}
}
@keyframes contentFadeIn {
from { opacity: 0; transform: translateY(6px); }
to { opacity: 1; transform: translateY(0); }
}
.msg-skeleton-list {
display: flex;
flex-direction: column;
gap: 20px;
max-width: 800px;
padding: 16px 0;
animation: contentFadeIn 0.3s ease-out;
}
.msg-skeleton-user {
display: flex;
justify-content: flex-end;
}
.msg-skeleton-bot {
display: flex;
flex-direction: column;
gap: 8px;
padding-left: 4px;
}
.msg_list {
display: flex;
flex-direction: column;
@@ -1308,6 +1361,7 @@ onBeforeRouteUpdate((to, from, next) => {
flex-direction: column;
align-items: center;
width: 100%;
animation: contentFadeIn 0.3s ease-out;
}
.sq-fade-enter-active,
+28 -2
View File
@@ -6,7 +6,16 @@
</div>
<!-- 推荐问题 -->
<div ref="sqContainerRef" class="suggested-questions-container">
<transition name="sq-slide-fade" mode="out-in"
<!-- 骨架屏占位 -->
<div v-if="sqLoading && suggestedQuestions.length === 0" class="suggested-questions-inner">
<div class="suggested-questions-title"><t-skeleton animation="gradient" :row-col="[{ width: '120px', height: '18px' }]" /></div>
<div class="suggested-questions-grid">
<div v-for="n in 6" :key="'sq-skel-'+n" class="suggested-question-card sq-card-skeleton">
<t-skeleton animation="gradient" :row-col="[{ width: '90%', height: '14px' }, { width: '60%', height: '14px' }]" />
</div>
</div>
</div>
<transition v-else appear name="sq-slide-fade" mode="out-in"
@before-leave="onBeforeLeave"
@after-leave="onAfterLeave"
@enter="onEnter"
@@ -69,6 +78,7 @@ const { navigateToKnowledgeBaseList } = useKnowledgeBaseCreationNavigation();
// ===== 推荐问题 =====
const suggestedQuestions = ref<SuggestedQuestion[]>([]);
const sqLoading = ref(true);
const sqCardsRevealed = ref(false);
const sqRenderKey = ref(0);
const sqContainerRef = ref<HTMLElement | null>(null);
@@ -119,7 +129,7 @@ const onQuestionsEntered = () => {
const fetchSuggestedQuestions = async () => {
const fetchId = ++suggestedQuestionsFetchId;
// 加载期间保留旧数据,不清空,避免布局抖动
if (suggestedQuestions.value.length === 0) sqLoading.value = true;
try {
const agentId = settingsStore.selectedAgentId;
if (!agentId) return;
@@ -140,6 +150,10 @@ const fetchSuggestedQuestions = async () => {
if (fetchId === suggestedQuestionsFetchId) {
suggestedQuestions.value = [];
}
} finally {
if (fetchId === suggestedQuestionsFetchId) {
sqLoading.value = false;
}
}
};
@@ -277,11 +291,17 @@ const handleKBEditorSuccess = (kbId: string) => {
transition: height 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}
@keyframes skeletonFadeIn {
from { opacity: 0; }
to { opacity: 1; }
}
.suggested-questions-inner {
display: flex;
flex-direction: column;
align-items: center;
width: 100%;
animation: skeletonFadeIn 0.3s ease-out;
}
// 容器整体过渡:淡入 + 轻微上滑
@@ -335,6 +355,12 @@ const handleKBEditorSuccess = (kbId: string) => {
background 0.2s ease,
box-shadow 0.2s ease;
&.sq-card-skeleton {
opacity: 1;
transform: none;
cursor: default;
}
&.sq-card-visible {
opacity: 1;
transform: translateY(0) scale(1);
+48 -3
View File
@@ -42,6 +42,7 @@ const uploadInputRef = ref<HTMLInputElement | null>(null);
const folderUploadInputRef = ref<HTMLInputElement | null>(null);
const uploading = ref(false);
const kbLoading = ref(false);
const docListLoading = ref(true);
const isFAQ = computed(() => (kbInfo.value?.type || '') === 'faq');
const missingStorageEngine = computed(() => {
if (!kbInfo.value || isFAQ.value) return false
@@ -566,6 +567,7 @@ const loadKnowledgeBaseInfo = async (targetKbId: string) => {
// 重置store中的标签选择状态,避免上传文档时自动带上之前选择的标签
uiStore.setSelectedTagId('');
if (!isFAQ.value) {
docListLoading.value = true;
loadKnowledgeFiles(targetKbId);
} else {
cardList.value = [];
@@ -723,6 +725,7 @@ onUnmounted(() => {
});
watch(() => cardList.value, (newValue) => {
if (isFAQ.value) return;
docListLoading.value = false;
// Auto-open document if navigated with ?knowledge_id=xxx
if (pendingKnowledgeId.value && newValue?.length) {
@@ -1758,8 +1761,22 @@ async function createNewSession(value: string): Promise<void> {
ref="knowledgeScroll"
@scroll="handleScroll"
>
<template v-if="cardList.length">
<div class="doc-card-list">
<!-- 文档骨架屏 -->
<div v-if="docListLoading && cardList.length === 0" class="doc-card-list doc-card-list-animated">
<div v-for="n in 8" :key="'doc-skel-'+n" class="knowledge-card knowledge-card-skeleton">
<div class="card-content">
<div class="card-content-nav">
<t-skeleton animation="gradient" :row-col="[{ width: '70%', height: '18px' }]" />
</div>
<t-skeleton animation="gradient" :row-col="[{ width: '100%', height: '14px' }, { width: '60%', height: '14px' }]" />
</div>
<div class="card-bottom">
<t-skeleton animation="gradient" :row-col="[[{ width: '80px', height: '14px' }, { width: '40px', height: '18px', type: 'rect' }]]" />
</div>
</div>
</div>
<template v-else-if="cardList.length">
<div class="doc-card-list doc-card-list-animated">
<!-- 现有文档卡片 -->
<div
class="knowledge-card"
@@ -1978,7 +1995,7 @@ async function createNewSession(value: string): Promise<void> {
</div>
</Teleport>
</template>
<template v-else>
<template v-else-if="!docListLoading">
<div class="doc-empty-state">
<EmptyKnowledge />
</div>
@@ -2898,6 +2915,11 @@ async function createNewSession(value: string): Promise<void> {
}
}
@keyframes contentFadeIn {
from { opacity: 0; transform: translateY(6px); }
to { opacity: 1; transform: translateY(0); }
}
.doc-card-list {
box-sizing: border-box;
display: grid;
@@ -2905,6 +2927,29 @@ async function createNewSession(value: string): Promise<void> {
gap: 14px;
align-content: flex-start;
width: 100%;
&.doc-card-list-animated {
animation: contentFadeIn 0.32s ease-out;
}
}
.knowledge-card-skeleton {
cursor: default;
.card-content { padding: 15px 17px 13px; }
.card-content-nav { margin-bottom: 14px; }
.card-bottom {
position: absolute;
bottom: 0;
left: 0;
width: 100%;
padding: 0 17px;
box-sizing: border-box;
height: 34px;
display: flex;
align-items: center;
justify-content: space-between;
border-top: 1px solid var(--td-component-stroke);
}
}
.doc-empty-state {
@@ -78,6 +78,21 @@
</div>
</div>
<!-- 骨架屏占位 -->
<div v-if="loading && kbs.length === 0" class="kb-card-wrap">
<div v-for="n in 6" :key="'skel-'+n" class="kb-card kb-card-skeleton">
<div class="card-header">
<t-skeleton animation="gradient" :row-col="[{ width: '60%', height: '20px' }]" />
</div>
<div class="card-content">
<t-skeleton animation="gradient" :row-col="[{ width: '100%', height: '14px' }, { width: '80%', height: '14px' }]" />
</div>
<div class="card-bottom">
<t-skeleton animation="gradient" :row-col="[[{ width: '28px', height: '28px', type: 'rect' }, { width: '28px', height: '28px', type: 'rect' }]]" />
</div>
</div>
</div>
<!-- 卡片网格:全部 -->
<div v-if="spaceSelection === 'all' && filteredKnowledgeBases.length > 0" class="kb-card-wrap">
<!-- 全部:我的知识库 + 共享给我的知识库 -->
@@ -1583,10 +1598,16 @@ const handleUploadFinishedEvent = (event: Event) => {
transition: width 0.2s ease;
}
@keyframes contentFadeIn {
from { opacity: 0; transform: translateY(6px); }
to { opacity: 1; transform: translateY(0); }
}
.kb-card-wrap {
display: grid;
gap: 20px;
grid-template-columns: 1fr;
animation: contentFadeIn 0.32s ease-out;
}
.kb-card {
@@ -1605,6 +1626,13 @@ const handleUploadFinishedEvent = (event: Event) => {
height: 160px;
min-height: 160px;
&.kb-card-skeleton {
cursor: default;
.card-header { margin-bottom: 16px; }
.card-content { flex: 1; }
.card-bottom { margin-top: auto; }
}
&:hover {
border-color: var(--td-brand-color);
box-shadow: 0 4px 12px rgba(7, 192, 95, 0.12);
@@ -394,9 +394,22 @@
</div>
<!-- Card List Container with Scroll -->
<div ref="scrollContainer" class="faq-scroll-container" @scroll="handleScroll">
<t-loading :loading="loading && entries.length === 0" size="medium">
<!-- FAQ 骨架屏 -->
<div v-if="loading && entries.length === 0" class="faq-skeleton-grid">
<div v-for="n in 6" :key="'faq-skel-'+n" class="faq-card faq-card-skeleton">
<div class="faq-card-header">
<t-skeleton animation="gradient" :row-col="[{ width: '80%', height: '16px' }]" />
</div>
<div class="faq-card-body">
<t-skeleton animation="gradient" :row-col="[{ width: '100%', height: '13px' }, { width: '90%', height: '13px' }, { width: '60%', height: '13px' }]" />
</div>
<div class="faq-skel-footer">
<t-skeleton animation="gradient" :row-col="[[{ width: '50px', height: '18px', type: 'rect' }, { width: '60px', height: '18px', type: 'rect' }]]" />
</div>
</div>
</div>
<!-- Card List -->
<template v-if="entries.length > 0">
<template v-else-if="entries.length > 0">
<div ref="cardListRef" class="faq-card-list">
<div
v-for="entry in entries"
@@ -614,8 +627,8 @@
</div>
</div>
</template>
<template v-else>
<div v-if="!loading" class="faq-empty-state">
<template v-else-if="!loading">
<div class="faq-empty-state">
<div class="empty-content">
<t-icon name="file-add" size="48px" class="empty-icon" />
<div class="empty-text">{{ $t('knowledgeEditor.faq.emptyTitle') }}</div>
@@ -623,7 +636,6 @@
</div>
</div>
</template>
</t-loading>
<div v-if="loadingMore" class="faq-load-more">
<t-loading size="small" :text="$t('common.loading')" />
</div>
@@ -1363,7 +1375,7 @@ const handleFaqAction = (data: { value: string }) => {
}
}
const loading = ref(false)
const loading = ref(true)
const loadingMore = ref(false)
const entries = ref<FAQEntry[]>([])
const entryStatusLoading = reactive<Record<number, boolean>>({})
@@ -4171,10 +4183,40 @@ watch(() => entries.value.map(e => ({
padding-right: 4px;
}
@keyframes contentFadeIn {
from { opacity: 0; transform: translateY(6px); }
to { opacity: 1; transform: translateY(0); }
}
.faq-skeleton-grid {
display: grid;
grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
gap: 12px;
width: 100%;
animation: contentFadeIn 0.32s ease-out;
}
.faq-card-skeleton {
cursor: default;
height: auto;
.faq-card-header {
padding-bottom: 10px;
border-bottom: 1px solid var(--td-component-stroke);
}
.faq-card-body {
padding: 8px 0;
}
.faq-skel-footer {
padding-top: 8px;
border-top: 1px solid var(--td-component-stroke);
}
}
// 卡片列表样式 - 使用绝对定位实现瀑布流,下一行补齐上一行空缺
.faq-card-list {
position: relative;
width: 100%;
animation: contentFadeIn 0.32s ease-out;
min-width: 0;
}
@@ -43,6 +43,21 @@
</div>
</div>
<div class="org-list-main">
<!-- 骨架屏占位 -->
<div v-if="loading && filteredOrganizations.length === 0" class="org-card-wrap">
<div v-for="n in 4" :key="'skel-'+n" class="org-card org-card-skeleton">
<div class="card-header">
<t-skeleton animation="gradient" :row-col="[[{ width: '36px', height: '36px', type: 'circle' }, { width: '50%', height: '20px' }]]" />
</div>
<div style="flex:1;margin-top:12px">
<t-skeleton animation="gradient" :row-col="[{ width: '100%', height: '14px' }, { width: '70%', height: '14px' }]" />
</div>
<div style="margin-top:auto">
<t-skeleton animation="gradient" :row-col="[[{ width: '60px', height: '22px', type: 'rect' }, { width: '60px', height: '22px', type: 'rect' }]]" />
</div>
</div>
</div>
<!-- 卡片网格 -->
<div v-if="filteredOrganizations.length > 0" class="org-card-wrap">
<div
@@ -1406,10 +1421,24 @@ onUnmounted(() => {
}
}
@keyframes contentFadeIn {
from { opacity: 0; transform: translateY(6px); }
to { opacity: 1; transform: translateY(0); }
}
.org-card-wrap {
display: grid;
gap: 20px;
grid-template-columns: 1fr;
animation: contentFadeIn 0.32s ease-out;
}
.org-card-skeleton {
cursor: default;
display: flex;
flex-direction: column;
height: 160px;
min-height: 160px;
}
/* 与知识库列表卡片统一尺寸:160px 高、18px 20px 内边距、12px 圆角 */