feat: implement Lite edition support by filtering menu items and adjusting UI elements, enhancing user experience for Lite users

This commit is contained in:
wizardchen
2026-04-11 13:06:21 +08:00
committed by lyingbug
parent 92bf52721c
commit 98ff0761ed
7 changed files with 124 additions and 28 deletions
+7 -5
View File
@@ -89,11 +89,13 @@
</svg>
</span>
</div>
<div class="menu-divider"></div>
<div class="menu-item danger" @click="handleLogout">
<t-icon name="logout" class="menu-icon" />
<span>{{ $t('auth.logout') }}</span>
</div>
<template v-if="!authStore.isLiteMode">
<div class="menu-divider"></div>
<div class="menu-item danger" @click="handleLogout">
<t-icon name="logout" class="menu-icon" />
<span>{{ $t('auth.logout') }}</span>
</div>
</template>
</div>
</Transition>
</div>
+17 -15
View File
@@ -4,7 +4,7 @@
<div class="logo_row" v-if="!uiStore.sidebarCollapsed">
<div class="logo_box" @click="router.push('/platform/knowledge-bases')" style="cursor: pointer;">
<img class="logo" src="@/assets/img/weknora.png" alt="">
<span v-if="isLiteEdition" class="lite-badge">Lite</span>
<sup v-if="isLiteEdition" class="lite-badge">Lite</sup>
</div>
<div class="sidebar-toggle"
@click="uiStore.toggleSidebar"
@@ -157,7 +157,7 @@ const submenuscrollContainer = ref(null);
const totalPages = computed(() => Math.ceil(total.value / page_size.value));
const hasMore = computed(() => currentPage.value < totalPages.value);
type MenuItem = { title: string; icon: string; path: string; childrenPath?: string; children?: any[] };
const { menuArr } = storeToRefs(usemenuStore);
const { menuArr, visibleMenuArr } = storeToRefs(usemenuStore);
let activeSubmenu = ref<string>('');
const isLiteEdition = ref(false);
@@ -253,15 +253,15 @@ const getIconActiveState = (itemPath: string) => {
};
};
// 分离上下两部分菜单
// 分离上下两部分菜单(使用 visibleMenuArr 以便 lite 模式过滤 logout)
const topMenuItems = computed<MenuItem[]>(() => {
return (menuArr.value as unknown as MenuItem[]).filter((item: MenuItem) =>
return (visibleMenuArr.value as unknown as MenuItem[]).filter((item: MenuItem) =>
item.path === 'knowledge-bases' || item.path === 'knowledge-search' || item.path === 'agents' || item.path === 'organizations' || item.path === 'creatChat'
);
});
const bottomMenuItems = computed<MenuItem[]>(() => {
return (menuArr.value as unknown as MenuItem[]).filter((item: MenuItem) => {
return (visibleMenuArr.value as unknown as MenuItem[]).filter((item: MenuItem) => {
if (item.path === 'knowledge-bases' || item.path === 'knowledge-search' || item.path === 'agents' || item.path === 'organizations' || item.path === 'creatChat') {
return false;
}
@@ -542,8 +542,12 @@ onMounted(async () => {
currentSecondpath.value = `chat/${route.params.chatid}`;
}
isLiteEdition.value = authStore.isLiteMode
getSystemInfo().then(res => {
isLiteEdition.value = res.data?.edition === 'lite'
if (res.data?.edition === 'lite') {
isLiteEdition.value = true
authStore.setLiteMode(true)
}
}).catch(() => {})
// 初始化知识库信息
@@ -844,22 +848,20 @@ const onDragHandleMouseDown = (e: MouseEvent) => {
flex: 1;
min-width: 0;
overflow: hidden;
.logo{
width: 134px;
height: auto;
}
.lite-badge {
margin-left: 4px;
padding: 1px 6px;
font-size: 11px;
margin-left: 2px;
align-self: flex-start;
margin-top: 2px;
font-size: 9px;
font-weight: 600;
line-height: 18px;
color: #07c05f;
background: #07c05f1a;
border: 1px solid #07c05f40;
border-radius: 4px;
letter-spacing: 0.5px;
color: var(--td-text-color-placeholder);
user-select: none;
white-space: nowrap;
}
}
+1
View File
@@ -160,6 +160,7 @@ router.beforeEach(async (to, from, next) => {
const response = await autoSetup()
if (response.success) {
persistLoginResponse(authStore, response)
authStore.setLiteMode(true)
next(to.fullPath)
return
}
+15 -1
View File
@@ -15,6 +15,7 @@ export const useAuthStore = defineStore('auth', () => {
const selectedTenantId = ref<number | null>(null)
const selectedTenantName = ref<string | null>(null)
const allTenants = ref<TenantInfoFromAPI[]>([])
const isLiteMode = ref(false)
// 计算属性
const isLoggedIn = computed(() => {
@@ -102,6 +103,14 @@ export const useAuthStore = defineStore('auth', () => {
return selectedTenantId.value
}
const setLiteMode = (value: boolean) => {
isLiteMode.value = value
if (value) {
localStorage.setItem('weknora_lite_mode', 'true')
} else {
localStorage.removeItem('weknora_lite_mode')
}
}
const logout = () => {
// 清空状态
@@ -124,7 +133,8 @@ export const useAuthStore = defineStore('auth', () => {
localStorage.removeItem('weknora_current_kb')
localStorage.removeItem('weknora_selected_tenant_id')
localStorage.removeItem('weknora_selected_tenant_name')
localStorage.removeItem('weknora_lite_mode')
isLiteMode.value = false
}
const initFromStorage = () => {
@@ -192,6 +202,8 @@ export const useAuthStore = defineStore('auth', () => {
selectedTenantName.value = null
}
}
isLiteMode.value = localStorage.getItem('weknora_lite_mode') === 'true'
}
// 初始化时从localStorage恢复状态
@@ -216,6 +228,7 @@ export const useAuthStore = defineStore('auth', () => {
currentUserId,
canAccessAllTenants,
effectiveTenantId,
isLiteMode,
// 方法
setUser,
@@ -227,6 +240,7 @@ export const useAuthStore = defineStore('auth', () => {
setSelectedTenant,
setAllTenants,
getSelectedTenant,
setLiteMode,
logout,
initFromStorage
}
+13 -1
View File
@@ -1,6 +1,7 @@
import { reactive, ref, watch } from 'vue'
import { reactive, ref, computed, watch } from 'vue'
import { defineStore } from 'pinia'
import i18n from '@/i18n'
import { useAuthStore } from '@/stores/auth'
type MenuChild = Record<string, any>
@@ -57,6 +58,16 @@ export const useMenuStore = defineStore('menuStore', () => {
}
)
const liteHiddenPaths = new Set(['logout', 'organizations'])
const visibleMenuArr = computed(() => {
const authStore = useAuthStore()
if (authStore.isLiteMode) {
return menuArr.filter(item => !liteHiddenPaths.has(item.path))
}
return menuArr
})
const chatMenuIndex = menuArr.findIndex(item => item.path === 'creatChat')
const clearMenuArr = () => {
@@ -118,6 +129,7 @@ export const useMenuStore = defineStore('menuStore', () => {
return {
menuArr,
visibleMenuArr,
isFirstSession,
firstQuery,
firstMentionedItems,
+1
View File
@@ -678,6 +678,7 @@ onMounted(async () => {
try {
const response = await autoSetup()
if (response.success) {
authStore.setLiteMode(true)
await persistLoginResponse(response)
return
}
+70 -6
View File
@@ -40,6 +40,11 @@
</div>
</div>
</div>
<transition name="scroll-btn-fade">
<div v-show="userHasScrolledUp" class="scroll-to-bottom-btn" @click="onClickScrollToBottom">
<t-icon name="chevron-down" size="20px" />
</div>
</transition>
<div style="min-height: 115px; margin: 16px auto 4px;width: 100%;max-width: 800px;">
<InputField
ref="inputFieldRef"
@@ -101,6 +106,15 @@ const loading = ref(false);
let fullContent = ref('')
let userquery = ref('')
const scrollContainer = ref(null)
const userHasScrolledUp = ref(false)
const SCROLL_BOTTOM_THRESHOLD = 80
const isNearBottom = () => {
if (!scrollContainer.value) return true;
const { scrollTop, scrollHeight, clientHeight } = scrollContainer.value;
return scrollHeight - scrollTop - clientHeight < SCROLL_BOTTOM_THRESHOLD;
}
const handleKBEditorSuccess = (kbId) => {
navigateToKnowledgeBaseList(kbId)
}
@@ -202,6 +216,7 @@ watch([() => route.params], (newvalue) => {
loading.value = false;
isReplying.value = false;
currentAssistantMessageId.value = '';
userHasScrolledUp.value = false;
checkmenuTitle(session_id.value)
let data = {
@@ -212,13 +227,18 @@ watch([() => route.params], (newvalue) => {
getmsgList(data);
}
});
const scrollToBottom = () => {
const scrollToBottom = (force = false) => {
if (!force && userHasScrolledUp.value) return;
nextTick(() => {
if (scrollContainer.value) {
scrollContainer.value.scrollTop = scrollContainer.value.scrollHeight;
}
})
}
const onClickScrollToBottom = () => {
userHasScrolledUp.value = false;
scrollToBottom(true);
}
const debounce = (fn, delay) => {
let timer
return (...args) => {
@@ -239,7 +259,11 @@ const onChatScrollTop = () => {
getmsgList(data, true, scrollHeight);
}
}
const handleScroll = debounce(onChatScrollTop, 500);
const debouncedScrollTop = debounce(onChatScrollTop, 500);
const handleScroll = () => {
userHasScrolledUp.value = !isNearBottom();
debouncedScrollTop();
};
const getmsgList = (data, isScrollType = false, scrollHeight) => {
getMessageList(data).then(res => {
@@ -381,7 +405,7 @@ const handleMsgList = async (data, isScrollType = false, newScrollHeight) => {
}
messagesList.unshift(item);
if (isFirstEnter.value) {
scrollToBottom();
scrollToBottom(true);
} else if (isScrollType) {
nextTick(() => {
const { scrollHeight } = scrollContainer.value;
@@ -443,7 +467,8 @@ const sendMsg = async (value, modelId = '', mentionedItems = [], imageFiles = []
// 将@提及的知识库和文件信息存入用户消息
messagesList.push({ content: value, role: 'user', mentioned_items: mentionedItems, images: userImages, channel: 'web' });
scrollToBottom();
userHasScrolledUp.value = false;
scrollToBottom(true);
// Get agent mode status from settings store
const agentEnabled = useSettingsStoreInstance.isAgentEnabled;
@@ -605,7 +630,7 @@ onChunk((data) => {
};
messagesList.push(existingMessage);
loading.value = false; // 消息已创建,关闭 loading
scrollToBottom();
scrollToBottom(true);
}
existingMessage.knowledge_references = data.knowledge_references || data.data?.references || [];
@@ -707,7 +732,7 @@ const handleAgentChunk = (data) => {
};
messagesList.push(newMsg);
loading.value = false; // 消息已创建,关闭 loading
scrollToBottom();
scrollToBottom(true);
// Don't return - continue to process the current event data
message = newMsg;
}
@@ -1147,6 +1172,45 @@ onBeforeRouteUpdate((to, from, next) => {
}
}
.scroll-to-bottom-btn {
position: absolute;
left: 50%;
transform: translateX(-50%);
bottom: 140px;
z-index: 10;
width: 36px;
height: 36px;
border-radius: 50%;
background: var(--td-bg-color-container);
border: 1px solid var(--td-component-stroke);
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
display: flex;
align-items: center;
justify-content: center;
cursor: pointer;
color: var(--td-text-color-secondary);
transition: all 0.2s ease;
&:hover {
background: var(--td-bg-color-container-hover);
color: var(--td-text-color-primary);
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}
&:active {
transform: translateX(-50%) scale(0.92);
}
}
.scroll-btn-fade-enter-active,
.scroll-btn-fade-leave-active {
transition: opacity 0.2s ease, transform 0.2s ease;
}
.scroll-btn-fade-enter-from,
.scroll-btn-fade-leave-to {
opacity: 0;
transform: translateX(-50%) translateY(8px);
}
.agent-mode-indicator {
display: flex;