From 9253b2c1dc8f4fe83fec8e66ba79dbf00144fd43 Mon Sep 17 00:00:00 2001 From: wizardchen Date: Thu, 24 Sep 2026 18:15:15 +0800 Subject: [PATCH] fix(frontend): link docs to the public docs site instead of GitHub In-app doc links opened raw Markdown on GitHub. Point them at the deployed site (https://weknora.weixin.qq.com/docs/) instead, collected in utils/docsUrl.ts with a test that checks every linked page and anchor still exists in website-docs. The issue template's FAQ link moves too. --- .github/ISSUE_TEMPLATE/config.yml | 2 +- frontend/src/components/ModelEditorDialog.vue | 4 +- .../components/SandboxConfigEditorDrawer.vue | 3 +- frontend/src/components/UserMenu.vue | 3 +- .../src/components/modelEditorFlow.test.ts | 1 + frontend/src/utils/docsUrl.test.ts | 46 +++++++++++++++++++ frontend/src/utils/docsUrl.ts | 24 ++++++++++ .../integrations/ApiIntegrationSettings.vue | 3 +- .../IntegrationSettingsSection.vue | 3 +- .../knowledge/settings/GraphSettings.vue | 4 +- frontend/src/views/settings/ModelSettings.vue | 3 +- .../src/views/settings/SandboxSettings.vue | 3 +- frontend/src/views/settings/SystemInfo.vue | 4 +- frontend/src/views/settings/TenantMembers.vue | 3 +- 14 files changed, 92 insertions(+), 14 deletions(-) create mode 100644 frontend/src/utils/docsUrl.test.ts create mode 100644 frontend/src/utils/docsUrl.ts diff --git a/.github/ISSUE_TEMPLATE/config.yml b/.github/ISSUE_TEMPLATE/config.yml index a8d0150d..73cd1dbd 100644 --- a/.github/ISSUE_TEMPLATE/config.yml +++ b/.github/ISSUE_TEMPLATE/config.yml @@ -1,7 +1,7 @@ blank_issues_enabled: false contact_links: - name: WeKnora Documentation - url: https://github.com/Tencent/WeKnora/blob/main/website-docs/01-getting-started/05-troubleshooting.md + url: https://weknora.weixin.qq.com/docs/01-getting-started/05-troubleshooting about: Check WeKnora FAQ - name: Discussions url: https://github.com/Tencent/WeKnora/discussions diff --git a/frontend/src/components/ModelEditorDialog.vue b/frontend/src/components/ModelEditorDialog.vue index 8992c154..ed53f38a 100644 --- a/frontend/src/components/ModelEditorDialog.vue +++ b/frontend/src/components/ModelEditorDialog.vue @@ -646,6 +646,7 @@ import CredentialResource, { } from '@/components/credentials/CredentialResource.vue' import { shouldShowOllamaUnavailableTip } from '@/components/modelEditorSourceState' import { WEKNORA_CLOUD_PROVIDER, WKC_MODEL_KINDS, WKC_MODEL_NAME_BY_KIND } from '@/utils/weknoraCloudModels' +import { docsUrl } from '@/utils/docsUrl' interface CustomHeaderItem { key: string @@ -703,8 +704,7 @@ const PROTOCOL_OPTIONS = [ ] as const /** Field reference for parameters.spec.compat, per protocol and model type. */ -const COMPAT_DOC_URL = - 'https://github.com/Tencent/WeKnora/blob/main/website-docs/03-features/06-models.md#协议兼容覆盖-compat-json' +const COMPAT_DOC_URL = docsUrl('modelsCompat') /** Legacy thinking_control values still honoured by catalog.Resolve. */ const LEGACY_THINKING_CONTROL_VALUES = ['none', 'enable_thinking', 'thinking_type', 'chat_template_kwargs'] as const diff --git a/frontend/src/components/SandboxConfigEditorDrawer.vue b/frontend/src/components/SandboxConfigEditorDrawer.vue index bfb64649..a8a3ed70 100644 --- a/frontend/src/components/SandboxConfigEditorDrawer.vue +++ b/frontend/src/components/SandboxConfigEditorDrawer.vue @@ -765,6 +765,7 @@ import { useI18n } from 'vue-i18n' import SettingDrawer from '@/components/settings/SettingDrawer.vue' import SandboxBackendBadge from '@/components/settings/SandboxBackendBadge.vue' import { useDeploymentCapabilitiesStore } from '@/stores/deploymentCapabilities' +import { docsUrl } from '@/utils/docsUrl' import { checkSandboxConfig, createSandboxConfig, @@ -816,7 +817,7 @@ const isMaskedSecret = (value?: string) => value === secretPlaceholder // the sandbox account cannot write. const defaultDockerImage = 'wechatopenai/weknora-sandbox:main' -const clusterGuideUrl = 'https://github.com/Tencent/WeKnora/blob/main/website-docs/06-development/04-sandbox-deployment.md' +const clusterGuideUrl = docsUrl('sandboxDeployment') const e2bApiKeysUrl = 'https://e2b.dev/dashboard?tab=keys' const backendOptions = computed(() => { diff --git a/frontend/src/components/UserMenu.vue b/frontend/src/components/UserMenu.vue index 0b7ebf59..e377569e 100644 --- a/frontend/src/components/UserMenu.vue +++ b/frontend/src/components/UserMenu.vue @@ -215,6 +215,7 @@ import { useRoleLabel, useHomeTenant } from '@/composables/useRoleLabel' import { getRootZoom, rectToCssPx, cssViewportSize } from '@/utils/zoom' import { openNewUserGuide } from '@/config/contextualGuides' import { SETTINGS_MANAGEMENT_SHORTCUT_MIN_ROLE } from '@/config/settingsAccess' +import { docsUrl } from '@/utils/docsUrl' const { t } = useI18n() const router = useRouter() @@ -493,7 +494,7 @@ const reopenGuide = () => { const openDocs = () => { menuVisible.value = false - window.open('https://github.com/Tencent/WeKnora/tree/main/website-docs', '_blank') + window.open(docsUrl('home'), '_blank') } // 打开 GitHub diff --git a/frontend/src/components/modelEditorFlow.test.ts b/frontend/src/components/modelEditorFlow.test.ts index 46ea698e..08d0d449 100644 --- a/frontend/src/components/modelEditorFlow.test.ts +++ b/frontend/src/components/modelEditorFlow.test.ts @@ -85,6 +85,7 @@ async function fixture(options: { if (name === '@/stores/modelProviders') return { useModelProvidersStore: () => providersStore } if (name === '@/api/model') return { getWeKnoraCloudStatus: async () => ({ has_models: true, needs_reinit: false }) } if (name === '@/utils/weknoraCloudModels') return require('../utils/weknoraCloudModels.ts') + if (name === '@/utils/docsUrl') return require('../utils/docsUrl.ts') if (name === '@/stores/modelProvidersState') return require('../stores/modelProvidersState.ts') if (name === '@/utils/reasoningEffort') return require('../utils/reasoningEffort.ts') if (name === '@/utils/contextWindow') return require('../utils/contextWindow.ts') diff --git a/frontend/src/utils/docsUrl.test.ts b/frontend/src/utils/docsUrl.test.ts new file mode 100644 index 00000000..8e415f90 --- /dev/null +++ b/frontend/src/utils/docsUrl.test.ts @@ -0,0 +1,46 @@ +import { strict as assert } from 'node:assert' +import { existsSync, readFileSync } from 'node:fs' +import { dirname, resolve } from 'node:path' +import { test } from 'node:test' +import { fileURLToPath } from 'node:url' +import { DOC_PAGES, docsUrl } from './docsUrl' + +const WEBSITE_DOCS = resolve(dirname(fileURLToPath(import.meta.url)), '../../../website-docs') + +// VitePress default slugify for the headings we link to: explicit `{#id}` +// wins, otherwise lowercase with whitespace and punctuation collapsed to `-`. +function headingIds(markdown: string): Set { + const ids = new Set() + for (const line of markdown.split('\n')) { + const m = /^#{1,6}\s+(.*?)\s*$/.exec(line) + if (!m) continue + const explicit = /\{#([^}]+)\}$/.exec(m[1]) + if (explicit) { + ids.add(explicit[1]) + continue + } + ids.add( + m[1] + .toLowerCase() + .replace(/[\s~`!@#$%^&*()+=[\]{}|\\;:'",.<>/?]+/g, '-') + .replace(/^-+|-+$/g, ''), + ) + } + return ids +} + +test('every linked doc page and anchor exists in website-docs', () => { + for (const [key, target] of Object.entries(DOC_PAGES)) { + const [page, anchor] = target.split('#') + const file = resolve(WEBSITE_DOCS, page ? `${page}.md` : 'index.md') + assert.ok(existsSync(file), `${key}: ${file} not found`) + if (anchor) { + assert.ok(headingIds(readFileSync(file, 'utf8')).has(anchor), `${key}: #${anchor} not found in ${file}`) + } + } +}) + +test('docsUrl points at the public docs site', () => { + assert.equal(docsUrl('home'), 'https://weknora.weixin.qq.com/docs/') + assert.equal(docsUrl('models'), 'https://weknora.weixin.qq.com/docs/03-features/06-models') +}) diff --git a/frontend/src/utils/docsUrl.ts b/frontend/src/utils/docsUrl.ts new file mode 100644 index 00000000..06b62700 --- /dev/null +++ b/frontend/src/utils/docsUrl.ts @@ -0,0 +1,24 @@ +/** Public deployment of website-docs (VitePress, base `/docs/`). */ +export const DOCS_BASE_URL = 'https://weknora.weixin.qq.com/docs/' + +/** + * Doc pages linked from the UI, as website-docs paths without the `.md` + * suffix. docsUrl.test.ts checks each one (and its anchor) still exists. + */ +export const DOC_PAGES = { + home: '', + tenantAuth: '03-features/01-tenant-auth', + models: '03-features/06-models', + modelsCompat: '03-features/06-models#协议兼容覆盖-compat-json', + knowledgeGraph: '03-features/09-knowledge-graph', + imIntegration: '03-features/12-im-integration', + apiOverview: '04-api/01-api-overview', + troubleshootingMigrations: '01-getting-started/05-troubleshooting#database-migrations', + sandboxDeployment: '06-development/04-sandbox-deployment', +} as const + +export type DocPage = keyof typeof DOC_PAGES + +export function docsUrl(page: DocPage): string { + return DOCS_BASE_URL + DOC_PAGES[page] +} diff --git a/frontend/src/views/integrations/ApiIntegrationSettings.vue b/frontend/src/views/integrations/ApiIntegrationSettings.vue index 960400ce..eefb9c01 100644 --- a/frontend/src/views/integrations/ApiIntegrationSettings.vue +++ b/frontend/src/views/integrations/ApiIntegrationSettings.vue @@ -702,6 +702,7 @@ import { } from '@/config/apiKeyCapabilities' import { normalizeAPIKeyKnowledgeBaseIDs } from './apiKeyScope' import { consumeApiPlaygroundSSE } from './apiPlaygroundSSE' +import { docsUrl } from '@/utils/docsUrl' const { t } = useI18n() @@ -1431,7 +1432,7 @@ const saveDesktopPort = async () => { } function openApiDoc() { - window.open('https://github.com/Tencent/WeKnora/blob/main/website-docs/04-api/01-api-overview.md', '_blank') + window.open(docsUrl('apiOverview'), '_blank') } function openCreateAPIKeyDialog() { diff --git a/frontend/src/views/integrations/IntegrationSettingsSection.vue b/frontend/src/views/integrations/IntegrationSettingsSection.vue index bcc84227..1251b92a 100644 --- a/frontend/src/views/integrations/IntegrationSettingsSection.vue +++ b/frontend/src/views/integrations/IntegrationSettingsSection.vue @@ -7,7 +7,7 @@

{{ $t('agentEditor.im.description') }} { } const graphGuideUrl = - import.meta.env.VITE_KG_GUIDE_URL || - 'https://github.com/Tencent/WeKnora/blob/main/website-docs/03-features/09-knowledge-graph.md' + import.meta.env.VITE_KG_GUIDE_URL || docsUrl('knowledgeGraph') // Open guide documentation to show how to enable graph database const handleOpenGraphGuide = () => { diff --git a/frontend/src/views/settings/ModelSettings.vue b/frontend/src/views/settings/ModelSettings.vue index d48c7bb2..7219e7dc 100644 --- a/frontend/src/views/settings/ModelSettings.vue +++ b/frontend/src/views/settings/ModelSettings.vue @@ -41,7 +41,7 @@ ? 'modelSettings.builtinModels.descriptionAdmin' : 'modelSettings.builtinModels.description') }}

- {{ $t('modelSettings.builtinModels.viewGuide') }} @@ -311,6 +311,7 @@ import { useUIStore } from '@/stores/ui' import { focusKbEditorSection } from '@/config/contextualGuides' import { useChatResourcesStore } from '@/stores/chatResources' import { useModelProvidersStore } from '@/stores/modelProviders' +import { docsUrl } from '@/utils/docsUrl' import { formatContextWindow, isDefaultContextWindow, diff --git a/frontend/src/views/settings/SandboxSettings.vue b/frontend/src/views/settings/SandboxSettings.vue index e453e702..0f13f375 100644 --- a/frontend/src/views/settings/SandboxSettings.vue +++ b/frontend/src/views/settings/SandboxSettings.vue @@ -218,6 +218,7 @@ import SettingDrawer from '@/components/settings/SettingDrawer.vue' import { useConfirmDelete } from '@/components/settings/useConfirmDelete' import { getSession } from '@/api/chat/index' import { useDeploymentCapabilitiesStore } from '@/stores/deploymentCapabilities' +import { docsUrl } from '@/utils/docsUrl' import { deleteSandboxConfig, getSandboxConfigInventory, @@ -238,7 +239,7 @@ const dockerBackendEnabled = computed(() => deploymentCapabilities.isSupported('settings.sandbox.docker'), ) -const sandboxGuideUrl = 'https://github.com/Tencent/WeKnora/blob/main/website-docs/06-development/04-sandbox-deployment.md' +const sandboxGuideUrl = docsUrl('sandboxDeployment') const backendTypes = [...NAMED_SANDBOX_BACKEND_TYPES] diff --git a/frontend/src/views/settings/SystemInfo.vue b/frontend/src/views/settings/SystemInfo.vue index 97dc49ab..8e6c93c3 100644 --- a/frontend/src/views/settings/SystemInfo.vue +++ b/frontend/src/views/settings/SystemInfo.vue @@ -198,6 +198,7 @@ import { ref, computed, onMounted, onUnmounted } from 'vue' import { getSystemInfo, type SystemInfo } from '@/api/system' import { useI18n } from 'vue-i18n' +import { docsUrl } from '@/utils/docsUrl' const { t, locale } = useI18n() @@ -245,8 +246,7 @@ function formatUptime(totalSeconds: number): string { return parts.join(' ') } -const troubleshootingDocsURL = - 'https://github.com/Tencent/WeKnora/blob/main/website-docs/01-getting-started/05-troubleshooting.md#database-migrations' +const troubleshootingDocsURL = docsUrl('troubleshootingMigrations') // Pre-fills a new issue with the current migration error so users don't have to // paste it manually. Body is intentionally minimal — the bug template will fill diff --git a/frontend/src/views/settings/TenantMembers.vue b/frontend/src/views/settings/TenantMembers.vue index d2a4334d..fb106d06 100644 --- a/frontend/src/views/settings/TenantMembers.vue +++ b/frontend/src/views/settings/TenantMembers.vue @@ -54,7 +54,7 @@ {{ $t('tenantMember.sectionDescription') }} @@ -535,6 +535,7 @@ import { revokeInvitation, type TenantInvitation, } from '@/api/tenant/invitations' +import { docsUrl } from '@/utils/docsUrl' import { listAuditLog, type AuditLog,