feat: Implement comprehensive wiki feature for knowledge bases
This commit introduces the complete wiki feature for WeKnora, enabling AI-powered wiki page generation and management. The implementation includes: **Backend Changes:** - Wiki data model: WikiPage type with support for multiple page types (Summary, Entity, Concept, Index, Log) - Database schema: wiki_pages table with full migration support - WikiPageService: CRUD operations and page management - WikiPageRepository: GORM-based persistence layer - Wiki ingest pipeline: Automated generation of wiki pages from knowledge documents * Summary page generation using LLM * Entity and concept extraction in a single LLM call * Synthesis opportunity detection * Index page rebuilding * Log page maintenance - Wiki boost feature: Enhance chat retrieval with wiki context - Wiki linting: Maintenance and validation utilities - Agent wiki tools: Enable agents to query and interact with wiki pages - Wiki prompts: Comprehensive LLM prompt templates for all wiki generation tasks - Language support: Reuse existing middleware language infrastructure for LLM prompts **Frontend Changes:** - Wiki browser UI: View all wiki pages with filtering and search - Wiki API client: Knowledge base wiki management endpoints - Knowledge base editor: Configure wiki settings (language, auto-ingest, synthesis model) - i18n updates: Support for English, Korean, Russian, and Chinese interfaces **Configuration:** - Container DI: Wire up all wiki services - Router: Register wiki API endpoints - Task handling: Support async wiki ingest tasks **Testing:** - Unit tests for wiki page types - Service layer tests - Endpoint tests for wiki operations - Integration tests with LLM mocking **Documentation:** - Language refactoring analysis and guides - Implementation completion reports - Quick reference guides for developers **Key Features:** ✅ LLM-powered wiki page generation from documents ✅ Multi-language support (9+ languages) ✅ Automatic extraction of entities and concepts ✅ Synthesis opportunity detection ✅ Index and log page maintenance ✅ Progressive wiki building across multiple documents ✅ Agent-based wiki interaction ✅ Chat retrieval enhancement with wiki context ✅ Full frontend UI for wiki browsing Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -30,6 +30,7 @@ import {
|
||||
reparseKnowledge,
|
||||
} from "@/api/knowledge-base/index";
|
||||
import FAQEntryManager from './components/FAQEntryManager.vue';
|
||||
import WikiBrowser from './wiki/WikiBrowser.vue';
|
||||
import { listMoveTargets, moveKnowledge, getKnowledgeMoveProgress } from '@/api/knowledge-base';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { formatStringDate, kbFileTypeVerification } from '@/utils';
|
||||
@@ -44,6 +45,7 @@ const uploading = ref(false);
|
||||
const kbLoading = ref(false);
|
||||
const docListLoading = ref(true);
|
||||
const isFAQ = computed(() => (kbInfo.value?.type || '') === 'faq');
|
||||
const isWiki = computed(() => (kbInfo.value?.type || '') === 'wiki');
|
||||
const missingStorageEngine = computed(() => {
|
||||
if (!kbInfo.value || isFAQ.value) return false
|
||||
const spc = kbInfo.value.storage_provider_config
|
||||
@@ -1530,7 +1532,12 @@ async function createNewSession(value: string): Promise<void> {
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<template v-if="!isFAQ">
|
||||
<template v-if="isWiki">
|
||||
<div class="wiki-manager-wrapper" style="padding: 0;">
|
||||
<WikiBrowser v-if="kbId" :knowledge-base-id="kbId" />
|
||||
</div>
|
||||
</template>
|
||||
<template v-else-if="!isFAQ">
|
||||
<div class="knowledge-layout">
|
||||
<div class="document-header">
|
||||
<div class="document-header-title">
|
||||
|
||||
@@ -49,6 +49,7 @@
|
||||
>
|
||||
<t-radio-button value="document">{{ $t('knowledgeEditor.basic.typeDocument') }}</t-radio-button>
|
||||
<t-radio-button value="faq">{{ $t('knowledgeEditor.basic.typeFAQ') }}</t-radio-button>
|
||||
<t-radio-button value="wiki">{{ $t('knowledgeEditor.basic.typeWiki') }}</t-radio-button>
|
||||
</t-radio-group>
|
||||
<p class="form-tip">{{ $t('knowledgeEditor.basic.typeDescription') }}</p>
|
||||
</div>
|
||||
@@ -120,8 +121,49 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Wiki 配置 -->
|
||||
<div v-if="isWiki && formData" v-show="currentSection === 'wiki'" class="section">
|
||||
<div class="section-content">
|
||||
<div class="section-header">
|
||||
<h3 class="section-title">{{ $t('knowledgeEditor.wiki.title') }}</h3>
|
||||
<p class="section-desc">{{ $t('knowledgeEditor.wiki.description') }}</p>
|
||||
</div>
|
||||
<div class="section-body">
|
||||
<div class="form-item">
|
||||
<label class="form-label">{{ $t('knowledgeEditor.wiki.autoIngestLabel') }}</label>
|
||||
<t-switch v-model="formData.wikiConfig.autoIngest" size="medium" />
|
||||
<p class="form-tip">{{ $t('knowledgeEditor.wiki.autoIngestTip') }}</p>
|
||||
</div>
|
||||
<div class="form-item">
|
||||
<label class="form-label">{{ $t('knowledgeEditor.wiki.synthesisModelLabel') }}</label>
|
||||
<ModelSelector
|
||||
model-type="LLM"
|
||||
:selected-model-id="formData.wikiConfig.synthesisModelId"
|
||||
:all-models="allModels"
|
||||
@update:selected-model-id="(val: string) => { if (formData) formData.wikiConfig.synthesisModelId = val }"
|
||||
:placeholder="$t('knowledgeEditor.wiki.synthesisModelPlaceholder')"
|
||||
/>
|
||||
<p class="form-tip">{{ $t('knowledgeEditor.wiki.synthesisModelTip') }}</p>
|
||||
</div>
|
||||
<div class="form-item">
|
||||
<label class="form-label">{{ $t('knowledgeEditor.wiki.languageLabel') }}</label>
|
||||
<t-radio-group v-model="formData.wikiConfig.wikiLanguage">
|
||||
<t-radio-button value="auto">Auto</t-radio-button>
|
||||
<t-radio-button value="zh">中文</t-radio-button>
|
||||
<t-radio-button value="en">English</t-radio-button>
|
||||
</t-radio-group>
|
||||
</div>
|
||||
<div class="form-item">
|
||||
<label class="form-label">{{ $t('knowledgeEditor.wiki.maxPagesLabel') }}</label>
|
||||
<t-input-number v-model="formData.wikiConfig.maxPagesPerIngest" :min="0" :max="50" />
|
||||
<p class="form-tip">{{ $t('knowledgeEditor.wiki.maxPagesTip') }}</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 解析引擎 -->
|
||||
<div v-if="!isFAQ && formData" v-show="currentSection === 'parser'" class="section">
|
||||
<div v-if="!isFAQ && !isWiki && formData" v-show="currentSection === 'parser'" class="section">
|
||||
<KBParserSettings
|
||||
:parser-engine-rules="formData.chunkingConfig.parserEngineRules"
|
||||
@update:parser-engine-rules="handleParserEngineRulesUpdate"
|
||||
@@ -129,7 +171,7 @@
|
||||
</div>
|
||||
|
||||
<!-- 存储引擎 -->
|
||||
<div v-if="!isFAQ && formData" v-show="currentSection === 'storage'" class="section">
|
||||
<div v-if="!isFAQ && !isWiki && formData" v-show="currentSection === 'storage'" class="section">
|
||||
<KBStorageSettings
|
||||
:storage-provider="formData.storageProvider"
|
||||
:has-files="mode === 'edit' && hasFiles"
|
||||
@@ -138,7 +180,7 @@
|
||||
</div>
|
||||
|
||||
<!-- 分块设置 -->
|
||||
<div v-if="!isFAQ" v-show="currentSection === 'chunking'" class="section">
|
||||
<div v-if="!isFAQ && !isWiki" v-show="currentSection === 'chunking'" class="section">
|
||||
<KBChunkingSettings
|
||||
v-if="formData"
|
||||
:config="formData.chunkingConfig"
|
||||
@@ -147,7 +189,7 @@
|
||||
</div>
|
||||
|
||||
<!-- 图谱设置 -->
|
||||
<div v-if="!isFAQ" v-show="currentSection === 'graph'" class="section">
|
||||
<div v-if="!isFAQ && !isWiki" v-show="currentSection === 'graph'" class="section">
|
||||
<GraphSettings
|
||||
v-if="formData"
|
||||
:graph-extract="formData.nodeExtractConfig"
|
||||
@@ -158,7 +200,7 @@
|
||||
</div>
|
||||
|
||||
<!-- 多模态配置 -->
|
||||
<div v-if="!isFAQ" v-show="currentSection === 'multimodal'" class="section">
|
||||
<div v-if="!isFAQ && !isWiki" v-show="currentSection === 'multimodal'" class="section">
|
||||
<div v-if="formData" class="kb-multimodal-settings">
|
||||
<div class="section-header">
|
||||
<h2>{{ $t('knowledgeEditor.multimodal.title') }}</h2>
|
||||
@@ -202,8 +244,8 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 音视频语音识别(ASR)设置 -->
|
||||
<div v-if="!isFAQ" v-show="currentSection === 'asr'" class="section">
|
||||
<!-- 音频处理(ASR)设置 -->
|
||||
<div v-if="!isFAQ && !isWiki" v-show="currentSection === 'asr'" class="section">
|
||||
<div v-if="formData" class="kb-multimodal-settings">
|
||||
<div class="section-header">
|
||||
<h2>{{ $t('knowledgeEditor.asr.title') }}</h2>
|
||||
@@ -247,7 +289,7 @@
|
||||
</div>
|
||||
|
||||
<!-- 高级设置 -->
|
||||
<div v-if="!isFAQ" v-show="currentSection === 'advanced'" class="section">
|
||||
<div v-if="!isFAQ && !isWiki" v-show="currentSection === 'advanced'" class="section">
|
||||
<KBAdvancedSettings
|
||||
ref="advancedSettingsRef"
|
||||
v-if="formData"
|
||||
@@ -313,7 +355,7 @@ const props = defineProps<{
|
||||
visible: boolean
|
||||
mode: 'create' | 'edit'
|
||||
kbId?: string
|
||||
initialType?: 'document' | 'faq'
|
||||
initialType?: 'document' | 'faq' | 'wiki'
|
||||
}>()
|
||||
|
||||
// Emits
|
||||
@@ -337,6 +379,8 @@ const navItems = computed(() => {
|
||||
]
|
||||
if (formData.value?.type === 'faq') {
|
||||
items.push({ key: 'faq', icon: 'help-circle', label: t('knowledgeEditor.sidebar.faq') })
|
||||
} else if (formData.value?.type === 'wiki') {
|
||||
items.push({ key: 'wiki', icon: 'catalog', label: t('knowledgeEditor.sidebar.wiki') })
|
||||
} else {
|
||||
items.push(
|
||||
{ key: 'parser', icon: 'file-search', label: t('settings.parserEngine') },
|
||||
@@ -364,6 +408,7 @@ const advancedSettingsRef = ref<InstanceType<typeof KBAdvancedSettings>>()
|
||||
// 表单数据
|
||||
const formData = ref<any>(null)
|
||||
const isFAQ = computed(() => formData.value?.type === 'faq')
|
||||
const isWiki = computed(() => formData.value?.type === 'wiki')
|
||||
|
||||
watch(
|
||||
() => formData.value?.type,
|
||||
@@ -376,14 +421,21 @@ watch(
|
||||
if (!['basic', 'models', 'faq'].includes(currentSection.value)) {
|
||||
currentSection.value = 'faq'
|
||||
}
|
||||
} else if (oldType === 'faq' && currentSection.value === 'faq') {
|
||||
} else if (newType === 'wiki') {
|
||||
if (!formData.value.wikiConfig) {
|
||||
formData.value.wikiConfig = { autoIngest: true, synthesisModelId: '', wikiLanguage: 'auto', maxPagesPerIngest: 0 }
|
||||
}
|
||||
if (!['basic', 'models', 'wiki'].includes(currentSection.value)) {
|
||||
currentSection.value = 'wiki'
|
||||
}
|
||||
} else if ((oldType === 'faq' && currentSection.value === 'faq') || (oldType === 'wiki' && currentSection.value === 'wiki')) {
|
||||
currentSection.value = 'basic'
|
||||
}
|
||||
}
|
||||
)
|
||||
|
||||
// 初始化表单数据
|
||||
const initFormData = (type: 'document' | 'faq' = 'document') => {
|
||||
const initFormData = (type: 'document' | 'faq' | 'wiki' = 'document') => {
|
||||
return {
|
||||
type,
|
||||
name: '',
|
||||
@@ -433,6 +485,12 @@ const initFormData = (type: 'document' | 'faq' = 'document') => {
|
||||
enabled: true,
|
||||
questionCount: 3
|
||||
},
|
||||
wikiConfig: {
|
||||
autoIngest: true,
|
||||
synthesisModelId: '',
|
||||
wikiLanguage: 'auto',
|
||||
maxPagesPerIngest: 0,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
@@ -468,7 +526,7 @@ const loadKBData = async () => {
|
||||
hasFiles.value = (filesResult as any)?.total > 0
|
||||
|
||||
// 设置表单数据
|
||||
const kbType = (kb.type as 'document' | 'faq') || 'document'
|
||||
const kbType = (kb.type as 'document' | 'faq' | 'wiki') || 'document'
|
||||
formData.value = {
|
||||
type: kbType,
|
||||
name: kb.name || '',
|
||||
@@ -514,6 +572,12 @@ const loadKBData = async () => {
|
||||
enabled: kb.question_generation_config?.enabled || false,
|
||||
questionCount: kb.question_generation_config?.question_count || 3
|
||||
},
|
||||
wikiConfig: {
|
||||
autoIngest: kb.wiki_config?.auto_ingest ?? true,
|
||||
synthesisModelId: kb.wiki_config?.synthesis_model_id || '',
|
||||
wikiLanguage: kb.wiki_config?.wiki_language || 'auto',
|
||||
maxPagesPerIngest: kb.wiki_config?.max_pages_per_ingest || 0,
|
||||
},
|
||||
}
|
||||
initialStorageProvider.value = formData.value.storageProvider
|
||||
} catch (error) {
|
||||
@@ -698,6 +762,15 @@ const buildSubmitData = () => {
|
||||
}
|
||||
}
|
||||
|
||||
if (formData.value.type === 'wiki') {
|
||||
data.wiki_config = {
|
||||
auto_ingest: formData.value.wikiConfig?.autoIngest ?? true,
|
||||
synthesis_model_id: formData.value.wikiConfig?.synthesisModelId || '',
|
||||
wiki_language: formData.value.wikiConfig?.wikiLanguage || 'auto',
|
||||
max_pages_per_ingest: formData.value.wikiConfig?.maxPagesPerIngest || 0,
|
||||
}
|
||||
}
|
||||
|
||||
return data
|
||||
}
|
||||
|
||||
@@ -756,7 +829,7 @@ const doSubmit = async () => {
|
||||
throw new Error(t('knowledgeEditor.messages.missingId'))
|
||||
}
|
||||
|
||||
// 1. 更新基本信息(名称、描述)和 FAQ 配置
|
||||
// 1. 更新基本信息(名称、描述)和 FAQ/Wiki 配置
|
||||
const updateConfig: any = {}
|
||||
if (formData.value.type === 'faq' && formData.value.faqConfig) {
|
||||
updateConfig.faq_config = {
|
||||
@@ -764,6 +837,14 @@ const doSubmit = async () => {
|
||||
question_index_mode: formData.value.faqConfig.questionIndexMode || 'separate'
|
||||
}
|
||||
}
|
||||
if (formData.value.type === 'wiki' && formData.value.wikiConfig) {
|
||||
updateConfig.wiki_config = {
|
||||
auto_ingest: formData.value.wikiConfig.autoIngest ?? true,
|
||||
synthesis_model_id: formData.value.wikiConfig.synthesisModelId || '',
|
||||
wiki_language: formData.value.wikiConfig.wikiLanguage || 'auto',
|
||||
max_pages_per_ingest: formData.value.wikiConfig.maxPagesPerIngest || 0,
|
||||
}
|
||||
}
|
||||
await updateKnowledgeBase(props.kbId, {
|
||||
name: data.name,
|
||||
description: data.description,
|
||||
|
||||
@@ -0,0 +1,427 @@
|
||||
<template>
|
||||
<div class="wiki-browser">
|
||||
<!-- Header -->
|
||||
<div class="wiki-header">
|
||||
<div class="wiki-header-left">
|
||||
<h2>Wiki Browser</h2>
|
||||
<span class="wiki-stats-badge" v-if="stats">
|
||||
{{ stats.total_pages }} pages · {{ stats.total_links }} links
|
||||
</span>
|
||||
</div>
|
||||
<div class="wiki-header-actions">
|
||||
<input
|
||||
v-model="searchQuery"
|
||||
placeholder="Search wiki pages..."
|
||||
class="wiki-search-input"
|
||||
@keyup.enter="doSearch"
|
||||
/>
|
||||
<select v-model="filterType" class="wiki-filter-select" @change="loadPages">
|
||||
<option value="">All Types</option>
|
||||
<option value="summary">Summaries</option>
|
||||
<option value="entity">Entities</option>
|
||||
<option value="concept">Concepts</option>
|
||||
<option value="synthesis">Synthesis</option>
|
||||
<option value="comparison">Comparisons</option>
|
||||
</select>
|
||||
<button class="wiki-btn wiki-btn-secondary" @click="activeTab = 'graph'">
|
||||
Graph View
|
||||
</button>
|
||||
<button class="wiki-btn wiki-btn-secondary" @click="runLint">
|
||||
Health Check
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Tabs -->
|
||||
<div class="wiki-tabs">
|
||||
<button
|
||||
:class="['wiki-tab', { active: activeTab === 'pages' }]"
|
||||
@click="activeTab = 'pages'"
|
||||
>Pages</button>
|
||||
<button
|
||||
:class="['wiki-tab', { active: activeTab === 'graph' }]"
|
||||
@click="activeTab = 'graph'; loadGraph()"
|
||||
>Graph</button>
|
||||
<button
|
||||
:class="['wiki-tab', { active: activeTab === 'viewer' }]"
|
||||
@click="activeTab = 'viewer'"
|
||||
v-if="selectedPage"
|
||||
>{{ selectedPage.title }}</button>
|
||||
</div>
|
||||
|
||||
<!-- Pages List -->
|
||||
<div v-if="activeTab === 'pages'" class="wiki-pages-list">
|
||||
<div
|
||||
v-for="page in pages"
|
||||
:key="page.id"
|
||||
class="wiki-page-card"
|
||||
@click="selectPage(page)"
|
||||
>
|
||||
<div class="wiki-page-card-header">
|
||||
<span :class="['wiki-type-badge', `type-${page.page_type}`]">
|
||||
{{ page.page_type }}
|
||||
</span>
|
||||
<span class="wiki-page-title">{{ page.title }}</span>
|
||||
<span class="wiki-page-version">v{{ page.version }}</span>
|
||||
</div>
|
||||
<div class="wiki-page-summary">{{ page.summary }}</div>
|
||||
<div class="wiki-page-meta">
|
||||
<span>[[{{ page.slug }}]]</span>
|
||||
<span>{{ formatDate(page.updated_at) }}</span>
|
||||
<span v-if="page.out_links?.length">{{ page.out_links.length }} links</span>
|
||||
</div>
|
||||
</div>
|
||||
<div v-if="pages.length === 0" class="wiki-empty">
|
||||
No wiki pages yet. Upload documents to start building the wiki.
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Page Viewer -->
|
||||
<div v-if="activeTab === 'viewer' && selectedPage" class="wiki-page-viewer">
|
||||
<div class="wiki-viewer-header">
|
||||
<h3>{{ selectedPage.title }}</h3>
|
||||
<div class="wiki-viewer-meta">
|
||||
<span :class="['wiki-type-badge', `type-${selectedPage.page_type}`]">
|
||||
{{ selectedPage.page_type }}
|
||||
</span>
|
||||
<span>Version {{ selectedPage.version }}</span>
|
||||
<span>Updated {{ formatDate(selectedPage.updated_at) }}</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="wiki-viewer-links" v-if="selectedPage.in_links?.length || selectedPage.out_links?.length">
|
||||
<div v-if="selectedPage.out_links?.length">
|
||||
<strong>Links to:</strong>
|
||||
<a
|
||||
v-for="link in selectedPage.out_links"
|
||||
:key="link"
|
||||
href="#"
|
||||
class="wiki-link"
|
||||
@click.prevent="navigateToSlug(link)"
|
||||
>[[{{ link }}]]</a>
|
||||
</div>
|
||||
<div v-if="selectedPage.in_links?.length">
|
||||
<strong>Linked from:</strong>
|
||||
<a
|
||||
v-for="link in selectedPage.in_links"
|
||||
:key="link"
|
||||
href="#"
|
||||
class="wiki-link"
|
||||
@click.prevent="navigateToSlug(link)"
|
||||
>[[{{ link }}]]</a>
|
||||
</div>
|
||||
</div>
|
||||
<div class="wiki-viewer-content" v-html="renderedContent"></div>
|
||||
</div>
|
||||
|
||||
<!-- Graph View -->
|
||||
<div v-if="activeTab === 'graph'" class="wiki-graph-container">
|
||||
<div ref="graphRef" class="wiki-graph-canvas"></div>
|
||||
<div v-if="!graphData" class="wiki-empty">Loading graph...</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { ref, computed, onMounted, watch } from 'vue'
|
||||
import {
|
||||
listWikiPages,
|
||||
getWikiPage,
|
||||
getWikiGraph,
|
||||
getWikiStats,
|
||||
searchWikiPages,
|
||||
type WikiPage,
|
||||
type WikiGraphData,
|
||||
type WikiStats,
|
||||
} from '@/api/wiki'
|
||||
|
||||
const props = defineProps<{
|
||||
knowledgeBaseId: string
|
||||
}>()
|
||||
|
||||
const pages = ref<WikiPage[]>([])
|
||||
const selectedPage = ref<WikiPage | null>(null)
|
||||
const stats = ref<WikiStats | null>(null)
|
||||
const graphData = ref<WikiGraphData | null>(null)
|
||||
const activeTab = ref<'pages' | 'viewer' | 'graph'>('pages')
|
||||
const searchQuery = ref('')
|
||||
const filterType = ref('')
|
||||
const graphRef = ref<HTMLElement | null>(null)
|
||||
|
||||
// Simple markdown-to-HTML rendering (replace wiki links with clickable ones)
|
||||
const renderedContent = computed(() => {
|
||||
if (!selectedPage.value) return ''
|
||||
let html = selectedPage.value.content
|
||||
// Convert [[slug]] to clickable links
|
||||
html = html.replace(/\[\[([^\]]+)\]\]/g, (_, slug) => {
|
||||
return `<a href="#" class="wiki-link" data-slug="${slug}">[[${slug}]]</a>`
|
||||
})
|
||||
// Basic markdown headers
|
||||
html = html.replace(/^### (.+)$/gm, '<h3>$1</h3>')
|
||||
html = html.replace(/^## (.+)$/gm, '<h2>$1</h2>')
|
||||
html = html.replace(/^# (.+)$/gm, '<h1>$1</h1>')
|
||||
// Bold and italic
|
||||
html = html.replace(/\*\*(.+?)\*\*/g, '<strong>$1</strong>')
|
||||
html = html.replace(/\*(.+?)\*/g, '<em>$1</em>')
|
||||
// Line breaks
|
||||
html = html.replace(/\n\n/g, '</p><p>')
|
||||
html = html.replace(/\n/g, '<br>')
|
||||
return `<p>${html}</p>`
|
||||
})
|
||||
|
||||
async function loadPages() {
|
||||
try {
|
||||
const params: any = { page: 1, page_size: 50 }
|
||||
if (filterType.value) params.page_type = filterType.value
|
||||
const res = await listWikiPages(props.knowledgeBaseId, params)
|
||||
pages.value = (res as any).data?.pages || (res as any).pages || []
|
||||
} catch (e) {
|
||||
console.error('Failed to load wiki pages:', e)
|
||||
}
|
||||
}
|
||||
|
||||
async function loadStats() {
|
||||
try {
|
||||
const res = await getWikiStats(props.knowledgeBaseId)
|
||||
stats.value = (res as any).data || res as any
|
||||
} catch (e) {
|
||||
console.error('Failed to load wiki stats:', e)
|
||||
}
|
||||
}
|
||||
|
||||
async function loadGraph() {
|
||||
try {
|
||||
const res = await getWikiGraph(props.knowledgeBaseId)
|
||||
graphData.value = (res as any).data || res as any
|
||||
} catch (e) {
|
||||
console.error('Failed to load wiki graph:', e)
|
||||
}
|
||||
}
|
||||
|
||||
async function selectPage(page: WikiPage) {
|
||||
try {
|
||||
const res = await getWikiPage(props.knowledgeBaseId, page.slug)
|
||||
selectedPage.value = (res as any).data || res as any
|
||||
activeTab.value = 'viewer'
|
||||
} catch (e) {
|
||||
console.error('Failed to load wiki page:', e)
|
||||
}
|
||||
}
|
||||
|
||||
async function navigateToSlug(slug: string) {
|
||||
try {
|
||||
const res = await getWikiPage(props.knowledgeBaseId, slug)
|
||||
selectedPage.value = (res as any).data || res as any
|
||||
activeTab.value = 'viewer'
|
||||
} catch (e) {
|
||||
console.error(`Failed to navigate to ${slug}:`, e)
|
||||
}
|
||||
}
|
||||
|
||||
async function doSearch() {
|
||||
if (!searchQuery.value.trim()) {
|
||||
loadPages()
|
||||
return
|
||||
}
|
||||
try {
|
||||
const res = await searchWikiPages(props.knowledgeBaseId, searchQuery.value)
|
||||
pages.value = (res as any).data?.pages || (res as any).pages || []
|
||||
} catch (e) {
|
||||
console.error('Wiki search failed:', e)
|
||||
}
|
||||
}
|
||||
|
||||
function runLint() {
|
||||
// Open stats/lint view
|
||||
loadStats()
|
||||
alert(`Wiki Health:\nTotal pages: ${stats.value?.total_pages || 0}\nOrphan pages: ${stats.value?.orphan_count || 0}\nTotal links: ${stats.value?.total_links || 0}`)
|
||||
}
|
||||
|
||||
function formatDate(dateStr: string) {
|
||||
if (!dateStr) return ''
|
||||
return new Date(dateStr).toLocaleDateString()
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
loadPages()
|
||||
loadStats()
|
||||
})
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.wiki-browser {
|
||||
padding: 16px;
|
||||
}
|
||||
.wiki-header {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
margin-bottom: 16px;
|
||||
}
|
||||
.wiki-header-left {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 12px;
|
||||
}
|
||||
.wiki-header-left h2 {
|
||||
margin: 0;
|
||||
font-size: 20px;
|
||||
}
|
||||
.wiki-stats-badge {
|
||||
background: #f0f0f0;
|
||||
padding: 4px 8px;
|
||||
border-radius: 12px;
|
||||
font-size: 12px;
|
||||
color: #666;
|
||||
}
|
||||
.wiki-header-actions {
|
||||
display: flex;
|
||||
gap: 8px;
|
||||
align-items: center;
|
||||
}
|
||||
.wiki-search-input {
|
||||
padding: 6px 12px;
|
||||
border: 1px solid #ddd;
|
||||
border-radius: 6px;
|
||||
width: 200px;
|
||||
}
|
||||
.wiki-filter-select {
|
||||
padding: 6px 8px;
|
||||
border: 1px solid #ddd;
|
||||
border-radius: 6px;
|
||||
}
|
||||
.wiki-btn {
|
||||
padding: 6px 12px;
|
||||
border: 1px solid #ddd;
|
||||
border-radius: 6px;
|
||||
cursor: pointer;
|
||||
background: white;
|
||||
}
|
||||
.wiki-btn:hover {
|
||||
background: #f5f5f5;
|
||||
}
|
||||
.wiki-btn-secondary {
|
||||
color: #666;
|
||||
}
|
||||
.wiki-tabs {
|
||||
display: flex;
|
||||
gap: 4px;
|
||||
border-bottom: 1px solid #eee;
|
||||
margin-bottom: 16px;
|
||||
}
|
||||
.wiki-tab {
|
||||
padding: 8px 16px;
|
||||
border: none;
|
||||
background: none;
|
||||
cursor: pointer;
|
||||
border-bottom: 2px solid transparent;
|
||||
color: #666;
|
||||
}
|
||||
.wiki-tab.active {
|
||||
color: #1a73e8;
|
||||
border-bottom-color: #1a73e8;
|
||||
}
|
||||
.wiki-page-card {
|
||||
padding: 12px 16px;
|
||||
border: 1px solid #eee;
|
||||
border-radius: 8px;
|
||||
margin-bottom: 8px;
|
||||
cursor: pointer;
|
||||
transition: border-color 0.2s;
|
||||
}
|
||||
.wiki-page-card:hover {
|
||||
border-color: #1a73e8;
|
||||
}
|
||||
.wiki-page-card-header {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
margin-bottom: 4px;
|
||||
}
|
||||
.wiki-type-badge {
|
||||
padding: 2px 8px;
|
||||
border-radius: 10px;
|
||||
font-size: 11px;
|
||||
font-weight: 500;
|
||||
}
|
||||
.type-summary { background: #e3f2fd; color: #1565c0; }
|
||||
.type-entity { background: #e8f5e9; color: #2e7d32; }
|
||||
.type-concept { background: #fff3e0; color: #e65100; }
|
||||
.type-synthesis { background: #f3e5f5; color: #6a1b9a; }
|
||||
.type-comparison { background: #fce4ec; color: #c62828; }
|
||||
.type-index { background: #f5f5f5; color: #616161; }
|
||||
.type-log { background: #f5f5f5; color: #616161; }
|
||||
.wiki-page-title {
|
||||
font-weight: 600;
|
||||
flex: 1;
|
||||
}
|
||||
.wiki-page-version {
|
||||
font-size: 12px;
|
||||
color: #999;
|
||||
}
|
||||
.wiki-page-summary {
|
||||
color: #666;
|
||||
font-size: 13px;
|
||||
margin-bottom: 4px;
|
||||
}
|
||||
.wiki-page-meta {
|
||||
display: flex;
|
||||
gap: 16px;
|
||||
font-size: 12px;
|
||||
color: #999;
|
||||
}
|
||||
.wiki-empty {
|
||||
text-align: center;
|
||||
padding: 40px;
|
||||
color: #999;
|
||||
}
|
||||
.wiki-page-viewer {
|
||||
max-width: 800px;
|
||||
}
|
||||
.wiki-viewer-header {
|
||||
margin-bottom: 16px;
|
||||
}
|
||||
.wiki-viewer-header h3 {
|
||||
margin: 0 0 8px;
|
||||
}
|
||||
.wiki-viewer-meta {
|
||||
display: flex;
|
||||
gap: 12px;
|
||||
font-size: 13px;
|
||||
color: #666;
|
||||
align-items: center;
|
||||
}
|
||||
.wiki-viewer-links {
|
||||
padding: 12px;
|
||||
background: #f8f9fa;
|
||||
border-radius: 6px;
|
||||
margin-bottom: 16px;
|
||||
font-size: 13px;
|
||||
}
|
||||
.wiki-viewer-links > div {
|
||||
margin-bottom: 4px;
|
||||
}
|
||||
.wiki-link {
|
||||
color: #1a73e8;
|
||||
text-decoration: none;
|
||||
margin-left: 8px;
|
||||
}
|
||||
.wiki-link:hover {
|
||||
text-decoration: underline;
|
||||
}
|
||||
.wiki-viewer-content {
|
||||
line-height: 1.7;
|
||||
}
|
||||
.wiki-viewer-content :deep(h1) { font-size: 24px; margin-top: 24px; }
|
||||
.wiki-viewer-content :deep(h2) { font-size: 20px; margin-top: 20px; }
|
||||
.wiki-viewer-content :deep(h3) { font-size: 16px; margin-top: 16px; }
|
||||
.wiki-graph-container {
|
||||
height: 500px;
|
||||
border: 1px solid #eee;
|
||||
border-radius: 8px;
|
||||
position: relative;
|
||||
}
|
||||
.wiki-graph-canvas {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
}
|
||||
</style>
|
||||
Reference in New Issue
Block a user