refactor: Update tenant ID handling across the application
This commit is contained in:
@@ -233,6 +233,9 @@ const isInCreatChat = computed<boolean>(() => {
|
||||
return route.name === 'globalCreatChat' || route.name === 'kbCreatChat';
|
||||
});
|
||||
|
||||
// 是否在对话详情页
|
||||
const isInChatDetail = computed<boolean>(() => route.name === 'chat');
|
||||
|
||||
// 统一的菜单项激活状态判断
|
||||
const isMenuItemActive = (itemPath: string): boolean => {
|
||||
const currentRoute = route.name;
|
||||
@@ -301,11 +304,16 @@ const handleFaqSelectionChanged = ((event: CustomEvent<{ count: number; enabledC
|
||||
selectedFaqDisabledCount.value = event.detail?.disabledCount || 0
|
||||
}) as EventListener
|
||||
|
||||
const showKbActions = computed(() => (isInKnowledgeBase.value && !!currentKbInfo.value) || isInKnowledgeBaseList.value || isInCreatChat.value)
|
||||
const showKbActions = computed(() =>
|
||||
(isInKnowledgeBase.value && !!currentKbInfo.value) ||
|
||||
isInKnowledgeBaseList.value ||
|
||||
isInCreatChat.value ||
|
||||
isInChatDetail.value
|
||||
)
|
||||
const currentKbType = computed(() => currentKbInfo.value?.type || 'document')
|
||||
const showDocActions = computed(() => showKbActions.value && isInKnowledgeBase.value && currentKbType.value !== 'faq')
|
||||
const showFaqActions = computed(() => showKbActions.value && isInKnowledgeBase.value && currentKbType.value === 'faq')
|
||||
const showCreateKbAction = computed(() => showKbActions.value && (isInKnowledgeBaseList.value || isInCreatChat.value))
|
||||
const showCreateKbAction = computed(() => showKbActions.value && (isInKnowledgeBaseList.value || isInCreatChat.value || isInChatDetail.value))
|
||||
|
||||
// 时间分组函数
|
||||
const getTimeCategory = (dateStr: string): string => {
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
import { useRouter } from 'vue-router'
|
||||
|
||||
/**
|
||||
* Provides a shared navigation helper for knowledge-base creation success.
|
||||
* Redirects to the knowledge-base list page and highlights the newly created KB.
|
||||
*/
|
||||
export const useKnowledgeBaseCreationNavigation = () => {
|
||||
const router = useRouter()
|
||||
|
||||
const navigateToKnowledgeBaseList = (kbId: string) => {
|
||||
if (!kbId) return
|
||||
router.push({
|
||||
path: '/platform/knowledge-bases',
|
||||
query: { highlightKbId: kbId },
|
||||
})
|
||||
}
|
||||
|
||||
return {
|
||||
navigateToKnowledgeBaseList,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -31,6 +31,14 @@
|
||||
></InputField>
|
||||
</div>
|
||||
</div>
|
||||
<KnowledgeBaseEditorModal
|
||||
:visible="uiStore.showKBEditorModal"
|
||||
:mode="uiStore.kbEditorMode"
|
||||
:kb-id="uiStore.currentKBId || undefined"
|
||||
:initial-type="uiStore.kbEditorType"
|
||||
@update:visible="(val) => val ? null : uiStore.closeKBEditor()"
|
||||
@success="handleKBEditorSuccess"
|
||||
/>
|
||||
</template>
|
||||
<script setup>
|
||||
import { storeToRefs } from 'pinia';
|
||||
@@ -45,8 +53,13 @@ import { useMenuStore } from '@/stores/menu';
|
||||
import { useSettingsStore } from '@/stores/settings';
|
||||
import { MessagePlugin } from 'tdesign-vue-next';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { useUIStore } from '@/stores/ui';
|
||||
import KnowledgeBaseEditorModal from '@/views/knowledge/KnowledgeBaseEditorModal.vue';
|
||||
import { useKnowledgeBaseCreationNavigation } from '@/hooks/useKnowledgeBaseCreationNavigation';
|
||||
const usemenuStore = useMenuStore();
|
||||
const useSettingsStoreInstance = useSettingsStore();
|
||||
const uiStore = useUIStore();
|
||||
const { navigateToKnowledgeBaseList } = useKnowledgeBaseCreationNavigation();
|
||||
const { t } = useI18n();
|
||||
const { menuArr, isFirstSession, firstQuery } = storeToRefs(usemenuStore);
|
||||
const { output, onChunk, isStreaming, isLoading, error, startStream, stopStream } = useStream();
|
||||
@@ -66,6 +79,9 @@ const loading = ref(false);
|
||||
let fullContent = ref('')
|
||||
let userquery = ref('')
|
||||
const scrollContainer = ref(null)
|
||||
const handleKBEditorSuccess = (kbId) => {
|
||||
navigateToKnowledgeBaseList(kbId)
|
||||
}
|
||||
|
||||
const getUserQuery = (index) => {
|
||||
if (index <= 0) {
|
||||
|
||||
@@ -29,6 +29,7 @@ import { useRoute, useRouter } from 'vue-router';
|
||||
import { MessagePlugin } from 'tdesign-vue-next';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import KnowledgeBaseEditorModal from '@/views/knowledge/KnowledgeBaseEditorModal.vue';
|
||||
import { useKnowledgeBaseCreationNavigation } from '@/hooks/useKnowledgeBaseCreationNavigation';
|
||||
|
||||
const router = useRouter();
|
||||
const route = useRoute();
|
||||
@@ -36,6 +37,7 @@ const usemenuStore = useMenuStore();
|
||||
const settingsStore = useSettingsStore();
|
||||
const uiStore = useUIStore();
|
||||
const { t } = useI18n();
|
||||
const { navigateToKnowledgeBaseList } = useKnowledgeBaseCreationNavigation();
|
||||
|
||||
const sendMsg = (value: string) => {
|
||||
createNewSession(value);
|
||||
@@ -93,12 +95,7 @@ const navigateToSession = async (sessionId: string, value: string) => {
|
||||
}
|
||||
|
||||
const handleKBEditorSuccess = (kbId: string) => {
|
||||
console.log('[creatChat] knowledge base created successfully:', kbId)
|
||||
// 创建成功后跳转到知识库列表页面,并高亮新创建的知识库
|
||||
router.push({
|
||||
path: '/platform/knowledge-bases',
|
||||
query: { highlightKbId: kbId }
|
||||
})
|
||||
navigateToKnowledgeBaseList(kbId)
|
||||
}
|
||||
|
||||
</script>
|
||||
|
||||
Reference in New Issue
Block a user