diff --git a/README.md b/README.md index 7664b5c8..7ffb788a 100644 --- a/README.md +++ b/README.md @@ -301,7 +301,7 @@ WeKnora serves as the core technology framework for the [WeChat Dialog Open Plat ## 📘 API Reference -**Official product documentation**: [`website-docs/`](./website-docs/README.md) — the complete documentation set organized as Getting Started → Architecture → Features → API → Clients → Development, covering ~360 API endpoints, ~150 environment variables, and 9 extension points. The directory is also a VitePress site: run `cd website-docs && npm install && npm run dev` to preview locally, or deploy it standalone with the `Dockerfile` inside. +**Official website and product documentation**: [`website-docs/`](./website-docs/README.md) contains the product homepage and the complete documentation set organized as Getting Started → Architecture → Features → API → Clients → Development. With Node.js 24, run `cd website-docs && npm run setup && npm run build && npm run preview` to preview both together. The unified static output serves the homepage at `/` and documentation at `/docs/`; see the directory's README for Nginx and Docker deployment. Troubleshooting FAQ: [Troubleshooting FAQ](./docs/QA.md) diff --git a/docs/QA.md b/docs/QA.md index 974b50d8..7e770136 100644 --- a/docs/QA.md +++ b/docs/QA.md @@ -381,18 +381,18 @@ SystemAdmin 可在 **系统管理 → 平台 API Key** 创建 `scope_type=platfo 0.7.2 新增了完整的官方产品文档,位于仓库 [`website-docs/`](../website-docs/README.md) 目录,按「入门 → 架构 → 功能 → API → 客户端 → 开发」六个板块组织,覆盖约 360 个 API 端点、约 150 个环境变量与 9 大扩展点。 -该目录同时是一个 VitePress 站点,两种使用方式: +该目录现在包含官网与 VitePress 文档站,统一构建和部署。以下命令分别从仓库根目录执行: ```bash -# 本地预览 -cd website-docs && npm install && npm run dev +# 本地预览(需要 Node.js 24) +(cd website-docs && npm run setup && npm run build && npm run preview) -# 独立容器部署(容器内 Nginx 监听 8081) -docker build -t weknora-docs website-docs -docker run -d -p 8081:8081 weknora-docs +# 独立容器部署(容器内完成构建,Nginx 监听 80) +docker build -t weknora-site website-docs +docker run -d -p 8081:80 weknora-site ``` -站点的版本号在构建时自动读取仓库根目录的 `VERSION` 文件,因此升级版本后无需手动改文档。若某处截图显示为虚线占位框,说明 `website-docs/public/screenshots/` 下缺少同名图片,补图即可生效,不需要改 Markdown。 +官网位于 `/`,文档位于 `/docs/`。从旧文档容器迁移时注意将反向代理目标端口改为 `80`,并让域名根路径指向同一容器。站点版本号在构建时读取 `website-docs/VERSION`,发布时需同步更新;该目录可独立复制构建。完整部署说明见 [website-docs/README.md](../website-docs/README.md)。若某处截图显示为虚线占位框,说明 `website-docs/public/screenshots/` 下缺少同名图片,补图即可生效,不需要改 Markdown。 `website-docs/sample-data/` 下还提供了 4 份 Markdown 样例文档与 1 份 FAQ 导入 JSON,可以直接用来跑一遍「建库 → 上传 → 问答」;`examples/mcp-demo/` 是一个可直接运行的本地 MCP 服务示例。 diff --git a/website-docs/.dockerignore b/website-docs/.dockerignore new file mode 100644 index 00000000..e24fdf01 --- /dev/null +++ b/website-docs/.dockerignore @@ -0,0 +1,12 @@ +**/node_modules +**/.next +**/out +.vitepress/cache +.vitepress/dist +static-site +releases +**/.git +**/.DS_Store +**/.env* +**/npm-debug.log* +**/*.tsbuildinfo diff --git a/website-docs/.gitignore b/website-docs/.gitignore index 20e860ad..49a14e4b 100644 --- a/website-docs/.gitignore +++ b/website-docs/.gitignore @@ -1,7 +1,13 @@ -# 仓库根 .gitignore 忽略了所有隐藏目录,这里把站点源码目录放回来 !.vitepress/ +!.dockerignore +!.nvmrc .vitepress/cache/ .vitepress/dist/ - -node_modules/ +**/node_modules/ +homepage/.next/ +homepage/out/ +static-site/ +releases/ +*.tsbuildinfo .shots/ +.DS_Store diff --git a/website-docs/.nvmrc b/website-docs/.nvmrc new file mode 100644 index 00000000..a45fd52c --- /dev/null +++ b/website-docs/.nvmrc @@ -0,0 +1 @@ +24 diff --git a/website-docs/.vitepress/config.mts b/website-docs/.vitepress/config.mts index 75ae9885..a13450f2 100644 --- a/website-docs/.vitepress/config.mts +++ b/website-docs/.vitepress/config.mts @@ -58,7 +58,6 @@ function tokenize(text: string): string[] { } const repo = 'https://github.com/Tencent/WeKnora' -const site = 'https://weknora.weixin.qq.com' export default withMermaid( defineConfig({ @@ -68,12 +67,17 @@ export default withMermaid( lang: 'zh-CN', base: '/docs/', cleanUrls: true, + appearance: { storageKey: 'vitepress-theme-appearance' }, lastUpdated: true, - srcExclude: ['README.md'], + srcExclude: ['README.md', 'homepage/**', 'shared/**', 'scripts/**', 'deploy/**', 'static-site/**', 'releases/**'], metaChunk: true, + transformPageData(pageData) { + // The shared masthead replaces the default documentation navbar. + pageData.frontmatter.navbar = false + }, head: [ - ['link', { rel: 'icon', href: '/favicon.svg', type: 'image/svg+xml' }], + ['link', { rel: 'icon', href: '/docs/favicon.ico', type: 'image/x-icon' }], ['meta', { name: 'theme-color', content: '#101f38' }], ['meta', { property: 'og:type', content: 'website' }], ['meta', { property: 'og:title', content: 'WeKnora 文档' }], @@ -100,18 +104,10 @@ export default withMermaid( }, themeConfig: { - logo: { light: '/logo-mark.svg', dark: '/logo-mark-dark.svg', alt: 'WeKnora' }, + logoLink: { link: '/', target: '_self' }, siteTitle: 'WeKnora', - nav: [ - { text: '快速开始', link: '/01-getting-started/01-introduction', activeMatch: '/01-getting-started/' }, - { text: '架构', link: '/02-architecture/01-overview', activeMatch: '/02-architecture/' }, - { text: '功能', link: '/03-features/01-tenant-auth', activeMatch: '/03-features/' }, - { text: 'API', link: '/04-api/01-api-overview', activeMatch: '/04-api/' }, - { text: '客户端', link: '/05-clients/01-frontend', activeMatch: '/05-clients/' }, - { text: '开发', link: '/06-development/01-dev-guide', activeMatch: '/06-development/' }, - { text: '官网', link: site }, - ], + nav: [], weknoraVersion: repoVersionLabel, diff --git a/website-docs/.vitepress/theme/Illus.vue b/website-docs/.vitepress/theme/Illus.vue deleted file mode 100644 index ef5b84d7..00000000 --- a/website-docs/.vitepress/theme/Illus.vue +++ /dev/null @@ -1,539 +0,0 @@ - - - - - diff --git a/website-docs/.vitepress/theme/Landing.vue b/website-docs/.vitepress/theme/Landing.vue deleted file mode 100644 index 9a430fd2..00000000 --- a/website-docs/.vitepress/theme/Landing.vue +++ /dev/null @@ -1,1552 +0,0 @@ - - - - - diff --git a/website-docs/.vitepress/theme/SidebarNavigationSync.vue b/website-docs/.vitepress/theme/SidebarNavigationSync.vue new file mode 100644 index 00000000..e47b22e7 --- /dev/null +++ b/website-docs/.vitepress/theme/SidebarNavigationSync.vue @@ -0,0 +1,32 @@ + + + diff --git a/website-docs/.vitepress/theme/SiteHeader.vue b/website-docs/.vitepress/theme/SiteHeader.vue new file mode 100644 index 00000000..c989e9f2 --- /dev/null +++ b/website-docs/.vitepress/theme/SiteHeader.vue @@ -0,0 +1,42 @@ + + + diff --git a/website-docs/.vitepress/theme/index.ts b/website-docs/.vitepress/theme/index.ts index d634feb7..16baf53e 100644 --- a/website-docs/.vitepress/theme/index.ts +++ b/website-docs/.vitepress/theme/index.ts @@ -1,16 +1,20 @@ import { h } from 'vue' import type { Theme } from 'vitepress' -import DefaultTheme from 'vitepress/theme' -import Landing from './Landing.vue' +import DefaultTheme from 'vitepress/theme-without-fonts' +import SiteHeader from './SiteHeader.vue' +import SidebarNavigationSync from './SidebarNavigationSync.vue' import MermaidZoom from './MermaidZoom.vue' import Screenshot from './Screenshot.vue' import './style.css' export default { extends: DefaultTheme, - Layout: () => h(DefaultTheme.Layout, null, { 'layout-bottom': () => h(MermaidZoom) }), + Layout: () => h(DefaultTheme.Layout, null, { + 'layout-bottom': () => h(MermaidZoom), + 'layout-top': () => h(SiteHeader), + 'sidebar-nav-before': () => h(SidebarNavigationSync), + }), enhanceApp({ app }) { - app.component('Landing', Landing) app.component('Screenshot', Screenshot) }, } satisfies Theme diff --git a/website-docs/.vitepress/theme/style.css b/website-docs/.vitepress/theme/style.css index e1fee4f6..5d6d357f 100644 --- a/website-docs/.vitepress/theme/style.css +++ b/website-docs/.vitepress/theme/style.css @@ -1,28 +1,13 @@ +@import '../../shared/brand.css'; +@import '../../shared/header.css'; + /* ========================================================================== WeKnora 文档站主题 墨蓝(logo 主色)· 纸白 · 鎏金(帆浪点缀) ========================================================================== */ :root { - --wk-ink: #101f38; - --wk-ink-deep: #0a1526; - --wk-ink-soft: #40536f; - --wk-ink-mute: #6d7d94; - --wk-gold: #b8863b; - --wk-gold-light: #d9a94f; - --wk-paper: #fdfcfa; - --wk-paper-2: #f5f3ee; - --wk-paper-3: #edeae2; - --wk-rule: rgba(16, 31, 56, 0.12); - --wk-rule-soft: rgba(16, 31, 56, 0.07); - --wk-font-sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", - "PingFang SC", "HarmonyOS Sans SC", "Source Han Sans SC", "Noto Sans CJK SC", - "Hiragino Sans GB", "Microsoft YaHei", sans-serif; - --wk-font-serif: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", - Georgia, "Songti SC", "Source Han Serif SC", "Noto Serif CJK SC", "STSong", serif; - --wk-font-mono: "JetBrains Mono", ui-monospace, SFMono-Regular, "SF Mono", Menlo, - Consolas, "Liberation Mono", monospace; /* —— 覆盖 VitePress 默认变量 —— */ --vp-font-family-base: var(--wk-font-sans); @@ -51,7 +36,7 @@ 大片空白;给一个大于视口的定值又会让左内边距被钳到 0、正文钻到侧栏底下。 取 100vw 时右侧内边距为 0、左侧正好等于侧栏宽度。 */ --vp-layout-max-width: 100vw; - --vp-nav-height: 68px; + --vp-nav-height: 64px; --vp-sidebar-width: 288px; --vp-code-block-bg: #fbf9f5; @@ -60,16 +45,6 @@ } .dark { - --wk-ink: #e6ecf5; - --wk-ink-soft: #a9b6c9; - --wk-ink-mute: #7d8ca2; - --wk-gold: #d9a94f; - --wk-gold-light: #e8c176; - --wk-paper: #0b1220; - --wk-paper-2: #101a2b; - --wk-paper-3: #16233a; - --wk-rule: rgba(190, 208, 232, 0.14); - --wk-rule-soft: rgba(190, 208, 232, 0.08); --vp-c-brand-1: #e6ecf5; --vp-c-brand-2: #c3d0e2; @@ -92,91 +67,6 @@ body { background: rgba(184, 134, 59, 0.22); } -/* -------------------------------------------------------------------------- - 顶栏 - -------------------------------------------------------------------------- */ - -.VPNav { - backdrop-filter: saturate(140%) blur(14px); -} - -.VPNavBar:not(.has-sidebar):not(.top) { - background-color: color-mix(in srgb, var(--wk-paper) 82%, transparent); -} - -/* 导航栏与正文之间不要任何分隔线或渐变 */ -.VPNavBar .divider, -.VPNavBar .curtain { - display: none; -} - -/* 默认主题在有侧栏时把标题块撑到侧栏宽、搜索框推到正文列起点, - 这里让它与首页(无侧栏)共用同一套居中容器,两种页面的 logo 与搜索位置才一致 */ -@media (min-width: 960px) { - .VPNavBar.has-sidebar .wrapper { - padding: 0 32px; - } - - .VPNavBar.has-sidebar .container { - max-width: calc(var(--vp-layout-max-width) - 64px); - } - - .VPNavBar.has-sidebar .title { - position: static; - width: auto; - padding: 0; - } - - .VPNavBar.has-sidebar .content { - padding-left: 0; - padding-right: 0; - } -} - -.VPNavBarTitle .title { - font-family: var(--wk-font-sans); - font-weight: 600; - letter-spacing: 0.14em; - font-size: 15px; - text-transform: uppercase; - border-bottom: none !important; -} - -.VPNavBarTitle .logo { - height: 22px; - margin-right: 10px; -} - -.VPNavBarMenuLink { - position: relative; - font-size: 13.5px !important; - font-weight: 500; - letter-spacing: 0.04em; - color: var(--wk-ink-soft) !important; -} - -.VPNavBarMenuLink.active, -.VPNavBarMenuLink:hover { - color: var(--wk-ink) !important; -} - -.VPNavBarMenuLink.active::after { - content: ""; - position: absolute; - left: 12px; - right: 12px; - bottom: 16px; - height: 1px; - background: var(--wk-gold); -} - -.VPNavBarSearch .DocSearch-Button, -.VPNavBarSearch button { - border-radius: 2px; - border: 1px solid var(--wk-rule); - background: transparent; -} - /* -------------------------------------------------------------------------- 侧边栏 -------------------------------------------------------------------------- */ @@ -223,7 +113,7 @@ body { /* 默认主题的 curtain 用负 margin 铺满侧栏宽度,会盖住滚动条顶部 */ @media (min-width: 960px) { .VPSidebar .curtain { - /* 默认写死 -64px,本站 nav-height 为 68px,对齐以免 sticky 错位 */ + /* Keep the sidebar curtain aligned with the shared masthead. */ top: calc(var(--vp-nav-height) * -1); margin-right: 0; width: calc(100% + 32px); @@ -300,24 +190,31 @@ body { color: var(--wk-ink); } +.VPSidebarItem.level-1 > .item { + margin-left: -10px; + padding: 0 10px; + width: calc(100% + 10px); + border-radius: 5px; +} + .VPSidebarItem.level-1.is-active .link .text { - color: var(--wk-ink) !important; - font-weight: 600; + color: var(--wk-accent-text) !important; + font-weight: 700; } .VPSidebarItem.level-1.is-active > .item { position: relative; + background: color-mix(in srgb, var(--wk-gold) 16%, var(--wk-paper)); } .VPSidebarItem.level-1.is-active > .item::before { content: ""; position: absolute; - left: -14px; - top: 50%; - transform: translateY(-50%); + left: 0; + top: 6px; + bottom: 6px; width: 3px; - height: 3px; - border-radius: 50%; + border-radius: 2px; background: var(--wk-gold); } @@ -733,23 +630,6 @@ body { letter-spacing: 0.06em; } -/* -------------------------------------------------------------------------- - 首页容器:去掉默认 page 布局的边距限制 - -------------------------------------------------------------------------- */ - -.landing-page .VPPage { - padding: 0; -} - -.landing-page .VPContent.is-home, -.landing-page .VPContent { - padding: 0 !important; -} - -.landing-page .VPFooter { - display: none; -} - @media (max-width: 640px) { .vp-doc h1 { font-size: 32px; @@ -759,3 +639,28 @@ body { margin-top: 52px; } } + +/* Reserve the same masthead space in the default documentation layout. */ +:root, .hide-nav, .hide-nav .VPSidebar { --vp-nav-height: 64px; } +.wk-docs-header { position: fixed; left: 0; top: 0; } +.VPLocalNav { top: var(--vp-nav-height); } + .wk-docs-label { margin: 0; padding: 24px 0 16px; color: var(--wk-ink-mute); font-size: 12px; letter-spacing: .08em; } +.wk-header-search .VPNavBarSearch { padding: 0; } +.wk-header-search .DocSearch-Button { width: 160px; height: 36px; padding: 0 10px; justify-content: space-between; border: 1px solid var(--wk-rule); border-radius: 4px; background: var(--wk-paper-2); } +.wk-header-search .DocSearch-Button-Placeholder { display: inline-block; padding: 0 8px; font-size: 12px; } +.wk-header-search .DocSearch-Button-Keys { display: flex; } +@media (min-width: 801px) and (max-width: 1280px) { + .wk-header-search .DocSearch-Button { width: 36px; justify-content: center; } + .wk-header-search .DocSearch-Button-Placeholder, .wk-header-search .DocSearch-Button-Keys { display: none; } + .wk-header-search .DocSearch-Search-Icon { margin: 0; } +} +@media (max-width: 800px) { + .wk-header-search { order: -1; margin-bottom: 10px; } + .wk-header-search, .wk-header-search #local-search, .wk-header-search .DocSearch-Button { width: 100%; } +} +@media (max-width: 959px) { + .Layout { padding-top: var(--vp-nav-height); } + .VPSidebar { top: var(--vp-nav-height); } + .wk-docs-label { padding-top: 0; } +} +@media (max-width: 800px) { :root, .hide-nav, .hide-nav .VPSidebar { --vp-nav-height: 64px; } } diff --git a/website-docs/.vitepress/version.ts b/website-docs/.vitepress/version.ts index dda572c0..dcf436da 100644 --- a/website-docs/.vitepress/version.ts +++ b/website-docs/.vitepress/version.ts @@ -1,9 +1,9 @@ import { existsSync, readFileSync } from 'node:fs' import { resolve } from 'node:path' -const versionFile = resolve(import.meta.dirname, '../../VERSION') +const versionFile = resolve(import.meta.dirname, '../VERSION') -/** 仓库根目录 VERSION 文件中的发布版本(与 scripts/get_version.sh 同源) */ +/** website-docs/VERSION 中的站点发布版本,独立构建时无需读取父目录 */ export function getRepoVersion(): string { if (!existsSync(versionFile)) return 'unknown' return readFileSync(versionFile, 'utf-8').trim() || 'unknown' diff --git a/website-docs/03-features/02-knowledge-base.md b/website-docs/03-features/02-knowledge-base.md index 09d4875f..cc3a6b09 100644 --- a/website-docs/03-features/02-knowledge-base.md +++ b/website-docs/03-features/02-knowledge-base.md @@ -41,11 +41,6 @@ 开启自动标签后,系统在解析完成时从已有候选标签中选择匹配项。默认每篇最多关联 3 个,已有标签时跳过。配置只影响后续解析,不自动补齐历史文档,模型失败也不会阻塞文档完成。 - - - 图谱存储使用 Neo4j,并依赖 APOC 插件。 ## 开启配置 diff --git a/website-docs/03-features/13-embed-channel.md b/website-docs/03-features/13-embed-channel.md index b295a028..f7af022e 100644 --- a/website-docs/03-features/13-embed-channel.md +++ b/website-docs/03-features/13-embed-channel.md @@ -109,7 +109,7 @@ publish token 只保存在业务后端,页面通过 `data-token-endpoint` 指 A 网站嵌入 B 的 WeKnora 时,白名单填 A。标准 Nginx 使用 `/api/v1/embed-frame-policy` 获取渠道策略(无需 token,仅返回 CSP,不返回渠道配置),并在 `/embed/:channelId` 的 HTML 响应中设置 `frame-ancestors`;Lite 使用同一策略。该页面不缓存,策略获取失败时不返回嵌入 HTML。 -升级时,过去仅填 B 的渠道需改填实际宿主 A,并同时更新前后端。自定义反向代理需保留 CSP、原始 Host(含端口)、协议及 `Sec-Fetch-Site`;详见 [embed-subdomain.md](../../docs/embed-subdomain.md)。白名单限制浏览器嵌入,不能代替访客认证或阻止持有 token 的非浏览器客户端;此类访问控制使用安全模式和限流。 +升级时,过去仅填 B 的渠道需改填实际宿主 A,并同时更新前后端。自定义反向代理需保留 CSP、原始 Host(含端口)、协议及 `Sec-Fetch-Site`;详见 [embed-subdomain.md](https://github.com/Tencent/WeKnora/blob/main/docs/embed-subdomain.md)。白名单限制浏览器嵌入,不能代替访客认证或阻止持有 token 的非浏览器客户端;此类访问控制使用安全模式和限流。 ### Token 交换(安全模式核心) diff --git a/website-docs/Dockerfile b/website-docs/Dockerfile index cccbf724..2dc91d77 100644 --- a/website-docs/Dockerfile +++ b/website-docs/Dockerfile @@ -1,37 +1,23 @@ -# Build from repository root: -# docker build --platform linux/amd64 -f website-docs/Dockerfile -t wechatopenai/weknora-docs:latest . -# -# Gateway (preserve /docs/ prefix): -# location /docs/ { proxy_pass http://weknora-docs:80/docs/; } -# -# VitePress reads VERSION from the repo root (see .vitepress/version.ts), so the -# builder stage mirrors the monorepo layout instead of flattening website-docs/. -FROM node:22-bookworm-slim AS builder - +# Build from the repository root with: +# docker build -t weknora-site website-docs +# No host Node.js installation or prebuilt static-site/ is required. +FROM node:24-bookworm-slim AS builder RUN apt-get update \ && apt-get install -y --no-install-recommends git \ && rm -rf /var/lib/apt/lists/* - WORKDIR /build +ENV NEXT_TELEMETRY_DISABLED=1 -COPY VERSION VERSION -COPY website-docs/package.json website-docs/package-lock.json website-docs/ -RUN cd website-docs && npm ci +# Install both locked dependency sets before copying source for layer caching. +COPY package.json package-lock.json ./ +COPY homepage/package.json homepage/package-lock.json ./homepage/ +RUN npm run setup -COPY website-docs/ website-docs/ -RUN cd website-docs && npm run build - -# Align with internal frontend image: stable-alpine + custom entrypoint + bash. -FROM nginx:stable-alpine AS production-stage - -COPY --from=builder /build/website-docs/.vitepress/dist /usr/share/nginx/html - -RUN apk add --no-cache bash - -COPY website-docs/nginx.conf /etc/nginx/conf.d/default.conf -COPY website-docs/docker-entrypoint.sh /docker-entrypoint.sh -RUN chmod +x /docker-entrypoint.sh +COPY . . +RUN npm run build +FROM nginx:stable-alpine AS runtime +COPY deploy/nginx.conf /etc/nginx/conf.d/default.conf +RUN rm -rf /usr/share/nginx/html/* +COPY --from=builder /build/static-site/ /usr/share/nginx/html/ EXPOSE 80 - -ENTRYPOINT ["/docker-entrypoint.sh"] diff --git a/website-docs/README.md b/website-docs/README.md index 2f5870eb..3a3ed117 100644 --- a/website-docs/README.md +++ b/website-docs/README.md @@ -1,196 +1,132 @@ -# WeKnora 文档 +# WeKnora 官网与文档 -WeKnora(维娜拉)是腾讯开源的企业级知识库与 RAG(Retrieval-Augmented Generation)系统:Go 单体后端 + Vue 3 前端 + Python 文档解析微服务(docreader),支持多租户、多知识库、混合检索、Agent 智能体、知识图谱、Wiki 生成、MCP 集成、多平台 IM 接入与网页嵌入等能力。 +`website-docs/` 包含官网、文档、共享样式和全部构建部署脚本,可独立复制和构建,不依赖仓库外层文件。官网和文档共用一个域名、一次构建和一份部署产物。 -本目录是 WeKnora 的官方文档,按「入门 → 架构 → 功能 → API → 客户端 → 开发」六个部分组织。 +- `/`:产品首页。 +- `/docs/`:直接进入“快速上手”。 +- `/docs/…`:完整文档,保留分类导航、搜索和侧栏。 -## 文档站点 +顶栏高 64px、横向铺满。两边使用 README 原版商标,共用颜色、字体和深浅色偏好;Logo 在当前标签返回官网。官网和文档各自使用适合当前页面的导航。 -本目录同时是一个 VitePress 站点,Markdown 即页面,新增文件会自动进入侧边栏(标题取正文一级标题,目录顺序按文件名数字前缀)。 +## 发布方式:静态文件 + Nginx + +### 1. 准备部署包 + +使用 Node.js 24,在仓库的 `website-docs/` 目录执行。首次构建或依赖锁文件变更后,先安装依赖: ```bash -npm install -npm run dev # 本地预览 -npm run build # 产物输出到 .vitepress/dist -npm run preview # 预览构建产物 +cd website-docs +npm run setup +npm run build +npm run package:site ``` -主题位于 `.vitepress/theme/`:`style.css` 是排版与配色的单一来源,`Landing.vue` 是首页。 +`build` 会编译官网、检查文档链接和 Mermaid、编译文档,并校验合并后的资源路径。全部通过后更新 `static-site/`;`package:site` 将其打包到 `releases/`。 -## 写作约定 +### 2. 上传并解压 -- 首段直接说明功能、适用范围和操作结果。使用简洁、客观的表述,减少章节预告、反问、口语化比喻和设计辩解。 -- 快速开始按准备、操作、预期结果组织;功能指南以用户任务为主线,配置影响与限制紧跟相关操作;客户端文档先说明连接和使用方式。 -- API 参考先说明用途、认证和权限,再列请求、响应与错误;架构文档解释组件职责、数据流和设计约束;开发指南保留修改入口、实现步骤与验证方法。 -- 每段围绕一个结论展开。连续段落用于解释行为与原因,列表用于操作步骤,表格用于参数、权限和选项比较。避免用字段清单代替功能说明。 -- 接口、字段和默认值保持准确。功能页中的源码索引放在文末「实现参考」,详细实现与日常操作分节编排;迁移历史集中到开发文档或实现参考。 -- 标题使用明确的主题或动作,避免手工章节编号。修改已有标题时保留原锚点,或同步修正文内链接;不要用「见第几节」代替链接。 -- 涉及界面操作时使用 `` 组件;只在有助于理解操作时增加截图。 +只需把压缩包上传到服务器。服务器不需要 Node.js,也不需要 WeKnora 后端或独立文档服务。 -## 截图 +每次发布使用一个新的空目录,避免混入旧站点文件。下面的 `20260915-1` 是示例发布编号,后续发布换一个编号: -截图用全局组件 `` 引用,图片放在 `public/screenshots/` 下: - -```md - +```bash +sudo mkdir -p /srv/www/weknora/releases/20260915-1 +sudo tar -xzf weknora-site-v0.8.0.tar.gz -C /srv/www/weknora/releases/20260915-1 ``` -图片文件不存在时,组件会渲染成一个带说明的虚线占位框,标出期望的文件路径与该图应当展示的内容;把同名图片放进 `website-docs/public/screenshots/` 即可自动生效,**不需要改 Markdown**。 +解压后该目录下应直接有 `index.html`、`docs/`、`_next/`,无需再套一层 `static-site/`。 -当前待补充的截图共 2 张: +### 3. 配置域名根目录 -| 文件名(放在 `public/screenshots/` 下) | 出现位置 | 应当展示 | -| --- | --- | --- | -| `kb-folder-tree.png` | 知识库 | 文档列表的文件夹树 | -| `kg-graph.png` | 知识图谱 | 实体关系图 | +以 [deploy/nginx.conf](deploy/nginx.conf) 为模板添加站点配置,修改: -仓库 `docs/images/` 下已有一批现成的产品截图(`qa.png`、`knowledgebases.png`、`wiki-browser.png`、`wiki-graph.png`、`settings.png`、`agent-qa.png`、`graph1-3.png`、`langfuse.png`、`rbac-*.png` 等),补图时可以先看看能否直接复用。 - -## 阅读路径建议 - -- **初次使用**:01 快速开始 四篇按顺序读完即可完成部署与首次问答。 -- **评估选型 / 了解原理**:02 架构 五篇给出系统全貌与两条核心流水线(文档入库、检索问答)。 -- **使用某项具体功能**:直接查 03 功能模块 对应章节。 -- **对接 API / 写集成**:04 API 参考 + 05 客户端(CLI / Go SDK)。 -- **二次开发 / 贡献代码**:06 开发指南,尤其是扩展点指南。 - -## 目录 - -### 快速开始 {#_01-快速开始} - -| 文档 | 内容 | -| --- | --- | -| [产品介绍](01-getting-started/01-introduction.md) | WeKnora 是什么、核心概念(租户/知识库/知识/分块/会话/Agent 等)、功能总览与系统组件图 | -| [安装部署](01-getting-started/02-installation.md) | docker-compose(含 12 个可选 profile)、开发模式、Helm、Lite 单二进制与桌面应用、Homebrew | -| [快速上手](01-getting-started/03-quickstart.md) | 注册 → 初始化向导 → 配置模型 → 建库 → 上传 → 问答的完整路径,含可直接执行的 curl 链路 | -| [配置详解](01-getting-started/04-configuration.md) | config.yaml 全字段、约 150 个环境变量、prompt 模板、内置模型与内置 Agent 配置 | - -### 架构 {#_02-架构} - -| 文档 | 内容 | -| --- | --- | -| [总体架构](02-architecture/01-overview.md) | 组件构成、技术栈、进程间通信、顶层目录导览 | -| [Go 后端设计](02-architecture/02-backend-design.md) | 四层架构、uber/dig 依赖注入、启动与优雅退出、路由与中间件、领域模型 ER 图 | -| [文档入库流程](02-architecture/03-document-pipeline.md) | 上传/URL/手动创建 → 存储 → 解析 → 分块 → 向量化 → 索引 → 后处理的全链路与状态机 | -| [检索问答流程](02-architecture/04-rag-pipeline.md) | chat_pipeline 插件流水线、跨库检索与融合、重排、流式输出(SSE)与引用生成 | -| [异步任务系统](02-architecture/05-async-tasks.md) | asynq 队列拓扑、6 个 worker pool、Lite 同步模式、死信与任务巡检、事件总线 | - -### 功能模块 {#_03-功能模块} - -| 文档 | 内容 | -| --- | --- | -| [租户、用户与认证授权](03-features/01-tenant-auth.md) | 多租户模型、JWT / API Key / OIDC、RBAC 角色矩阵、组织与共享空间 | -| [知识库与知识管理](03-features/02-knowledge-base.md) | 知识库类型与全部可配置项、树形文件夹、多标签、自动标签与批量打标、分块编辑与版本历史、自定义元数据、预览安全、复制与移动、活动流、配额 | -| [文档解析服务 docreader](03-features/03-document-parsing.md) | gRPC 接口、三引擎注册表、解析器矩阵(含 HTML / MHTML / Excel 表头模式)、并发模型、部署与扩容 | -| [分块机制](03-features/04-chunking.md) | 自适应分块架构(heading/heuristic/recursive)、父子分块、语义边界重叠、ContextHeader、调试端点 | -| [检索引擎与向量存储](03-features/05-retrieval-engines.md) | 各检索引擎(向量/BM25/全文/混合)能力对比、驱动选择、维度管理、打分归一化 | -| [模型管理](03-features/06-models.md) | 5 类模型、26 个厂商 Provider、内置模型机制、Ollama 本地模型、限流与用量 | -| [Agent 引擎](03-features/07-agent.md) | ReAct 循环、内置与动态工具、上下文与记忆管理、技能系统与沙箱、自定义 Agent、建议问题 | -| [MCP 集成](03-features/08-mcp.md) | MCP 客户端管理、OAuth 2.0 + PKCE 全流程、工具启停与审批、WeKnora MCP Server(`tencent-weknora-mcp`,31 个工具) | -| [知识图谱](03-features/09-knowledge-graph.md) | 两级开关、LLM 实体关系抽取、Neo4j 存储、图谱增强检索 | -| [数据源导入](03-features/10-datasource.md) | 连接器体系(飞书/Lark/GitLab/IMA/Notion/语雀/RSS)、凭据加密、同步调度与增量更新 | -| [网络搜索与网页抓取](03-features/11-web-search.md) | 13 个搜索引擎、SSRF 防护、web_fetch 双实现、SearXNG 自托管 | -| [IM 集成](03-features/12-im-integration.md) | 10 个 IM 平台适配、消息处理流水线、内置命令、流式渲染、多实例协同 | -| [网页嵌入 Embed Channel](03-features/13-embed-channel.md) | 嵌入渠道配置、匿名会话与 token 交换、安全模式、webhook、接入示例 | -| [Wiki 能力](03-features/14-wiki.md) | 基于知识库的 LLM Wiki 站点生成、四阶段管道、slug 机制、人工编辑与版本回滚、issue 闭环、变更并入知识库活动流 | -| [评估能力](03-features/15-evaluation.md) | 评估任务、Parquet 数据集格式、12 项检索/生成指标 | -| [可观测性与审计](03-features/16-observability.md) | 日志体系、Langfuse 追踪、审计日志与保留策略、限流、健康检查 | -| [FAQ 能力](03-features/17-faq.md) | FAQ 条目模型、批量导入与去重、检索命中策略、克隆同步 | -| [会话与对话体验](03-features/18-chat-experience.md) | 进度条、问题大纲与引用面板、生成文件、导出对话、会话内临时附件、渠道会话可见性、跨会话历史搜索 | -| [存储后端](03-features/19-storage-backends.md) | 多实例注册、空间默认与按库绑定、连通性测试、legacy 别名迁移 | -| [平台管理与系统管理员](03-features/20-platform-admin.md) | 平台级身份与空间 Owner 的边界、首个管理员引导、创建用户、控制台四分区、运行时系统设置 | -| [图片与文件的对外访问](03-features/21-file-access.md) | 四种 URL 形式、各渠道怎么取、IM/API 图片不显示的排查表 | -| [技能目录与沙箱](03-features/22-skills-sandbox.md) | 目录/安装、Docker/Cube/E2B、网络策略、个人变量、生成文件 | -| [跨会话长期记忆](03-features/23-memory.md) | 空间/个人开关、自动提取、待确认项、主题/文档偏好与整理 | - -### API 参考 {#_04-api-参考} - -按资源分组列出端点、权限、参数、响应与 curl 示例。 - -| 文档 | 内容 | -| --- | --- | -| [API 总览](04-api/01-api-overview.md) | Base URL、三种认证方式、通用响应包与错误码、分页规范、SSE 协议、限流 | -| [认证与用户](04-api/02-api-auth.md) | /auth 注册登录、token 刷新、邀请 | -| [租户与成员](04-api/02-api-tenant.md) | 租户、成员、邀请、API Key、审计 | -| [组织与共享](04-api/02-api-org.md) | 组织、知识库共享、Agent 共享 | -| [知识库与知识](04-api/02-api-knowledge.md) | 知识库、知识、文件夹 | -| [分块与标签](04-api/02-api-chunks.md) | 分块读写与版本、生成问题、标签、分块预览 | -| [FAQ 与 Wiki](04-api/02-api-faq-wiki.md) | FAQ 管理与导入、Wiki 读写 | -| [会话与聊天](04-api/02-api-chat.md) | 会话、消息、知识问答与 Agent 对话(SSE) | -| [模型与初始化](04-api/02-api-model-system.md) | 模型、初始化向导、WeKnoraCloud、评估 | -| [系统与平台管理](04-api/02-api-system.md) | 系统信息、全局设置、运行时队列、平台 API Key、系统审计 | -| [基础设施与数据源](04-api/02-api-infra.md) | 向量存储、存储后端、Web 搜索、数据源 | -| [Agent 与 MCP](04-api/02-api-agent-mcp.md) | Agent、MCP 服务、OAuth、技能、收藏 | -| [IM、Embed 与文件](04-api/02-api-channels.md) | IM 回调与渠道、微信扫码、Embed、文件服务 | -| [沙箱、技能与个人变量](04-api/02-api-sandbox-skills.md) | 配置、模板、库存、安装与进度、目录、个人变量 | -| [长期记忆](04-api/02-api-memory.md) | 空间配置、个人设置/条目、主题、文档偏好、导出与整理 | - -### 客户端 {#_05-客户端} - -| 文档 | 内容 | -| --- | --- | -| [Web 前端](05-clients/01-frontend.md) | Vue 3 + TDesign 技术栈、页面路由、状态管理、i18n、部署 | -| [命令行工具 CLI](05-clients/02-cli.md) | 17 个命令组、多 profile 配置、输出格式与退出码、脚本化用法 | -| [Go SDK](05-clients/03-go-sdk.md) | 资源与方法覆盖、流式对话、错误处理、完整示例 | -| [微信小程序](05-clients/04-miniprogram.md) | 页面结构、后端地址与 API Key 配置、构建发布 | -| [桌面端](05-clients/05-desktop.md) | 单机桌面应用(未正式发布)、数据目录与端口设置、偏好设置与自动更新 | -| [Chrome 插件](05-clients/06-chrome-extension.md) | 网页侧边栏问答、剪藏与速记,凭证配置与排查 | -| [Claw Skill](05-clients/07-claw-skill.md) | ClawHub 上的 WeKnora Skill、环境变量配置、与 MCP 的取舍 | -| [DeepSeek Harness 插件](05-clients/08-deepseek-harness.md) | 安装与凭证、4 个工具、范围选择、引用图片与排查 | - -### 开发指南 {#_06-开发指南} - -| 文档 | 内容 | -| --- | --- | -| [开发指南](06-development/01-dev-guide.md) | 环境要求、Makefile 全目标、开发模式、四条测试线、CI 与代码规范、调试技巧 | -| [数据库与迁移](06-development/02-database-schema.md) | 40+ 张表结构与 ER 图、golang-migrate 双路径(versioned / sqlite)、新增迁移步骤、故障排查 | -| [扩展点指南](06-development/03-extension-points.md) | 9 大扩展点:解析器/分块策略/检索引擎/模型 Provider/搜索引擎/数据源连接器/IM 适配器/Agent 工具/存储后端 | - -## 系统组件速览 - -```mermaid -flowchart LR - subgraph Clients["客户端"] - FE["Web 前端 Vue 3"] - CLI["CLI weknora"] - SDK["Go SDK"] - MINI["微信小程序"] - EMBED["网页嵌入挂件"] - IM["IM 平台 x10"] - end - subgraph Core["核心服务"] - APP["app 主服务 Go/Gin :8080"] - DR["docreader 解析服务 Python gRPC :50051"] - end - subgraph Infra["基础设施"] - PG[("PostgreSQL / ParadeDB")] - RD[("Redis + asynq")] - VS[("向量/检索引擎 可选多种")] - OBJ[("对象存储 local/minio/cos/oss/s3 等")] - NEO[("Neo4j 知识图谱 可选")] - end - LLM["LLM / Embedding / Rerank / VLM 多厂商"] - FE --> APP - CLI --> APP - SDK --> APP - MINI --> APP - EMBED --> APP - IM --> APP - APP --> DR - APP --> PG - APP --> RD - APP --> VS - APP --> OBJ - APP --> NEO - APP --> LLM +```nginx +server_name 你的域名; +root /srv/www/weknora/releases/20260915-1; ``` -## 文档约定 +如果域名已有 HTTPS 配置,保留原来的证书及监听设置,把模板中的 `root`、`index` 和 `location` 规则合入现有站点配置。域名应指向这台服务器。 -- 文中源码路径均相对仓库根目录,如 `internal/agent/engine.go`。 -- API 路径默认带 `/api/v1` 前缀;认证方式见 [API 总览](04-api/01-api-overview.md)。 -- 配置示例中的密钥均为占位符,生产环境务必替换(尤其 `JWT_SECRET`、`SYSTEM_AES_KEY`、数据库口令)。 -- 文档基于仓库根目录 `VERSION` 文件对应版本源码整理(VitePress 构建时自动读取),随代码变更同步维护。 +必须保留文档的 `.html` 路由解析规则;不要把所有未知路径回退到官网 `index.html`。当前构建部署在域名根路径,不支持直接放进 `/weknora/` 等子目录。 + +检查配置后重载: + +```bash +sudo nginx -t +sudo nginx -s reload +``` + +### 4. 确认上线 + +访问以下路径: + +- `/`:官网。 +- `/docs/`:快速上手。 +- `/docs/03-features/23-memory`:长期记忆文档,直接打开和刷新均正常。 +- `/docs/not-found`:返回 404。 + +再确认搜索、深浅色切换和 Logo 返回官网正常。 + +后续更新重复构建、打包、上传到新目录,再修改 Nginx `root` 并重载。需要回滚时,将 `root` 改回上一发布目录。确认新版本稳定后再清理旧发布目录。 + +## 可选:Docker 部署 + +从干净源码即可构建,无需在宿主机安装 Node.js 或提前生成静态文件。Dockerfile 使用两个阶段:Node.js 24 按两份锁文件安装依赖并构建官网与文档,最终 Nginx 镜像只包含静态产物和服务配置。 + +在仓库根目录执行: + +```bash +docker build -t weknora-site:0.8.0 website-docs +docker run -d --name weknora-site --restart unless-stopped -p 8080:80 weknora-site:0.8.0 +``` + +访问 `http://服务器地址:8080/`。如使用域名和 HTTPS,让现有反向代理转发到该端口即可。镜像内已经包含官网、文档和 Nginx 路由配置。 + +也可以只复制 `website-docs/` 目录,在该目录执行 `docker build -t weknora-site:0.8.0 .`。构建上下文必须是 `website-docs/`,宿主机的依赖、旧构建产物和部署包由 `.dockerignore` 排除。 + +从旧文档镜像迁移时,将容器端口映射或反向代理目标端口从 `8081` 改为 `80`(宿主机端口可自行选择,例如 `-p 8081:80`)。域名根路径 `/` 现在提供官网,`/docs/` 提供文档,反向代理需覆盖整个站点并保留请求路径。容器使用 Nginx 官方镜像的默认入口,无需额外的 `docker-entrypoint.sh`。 + +构建后可在安装了 Node.js 24 和 Docker 的机器上执行以下检查,无需安装 npm 依赖。检查会临时启动容器并自动清理,验证两站路由、静态资源、404、压缩和响应头: + +```bash +cd website-docs +npm run test:docker -- weknora-site:0.8.0 +``` + +## 本地开发 + +使用 Node.js 24 LTS(目录内提供 `.nvmrc`,使用 nvm 时可执行 `nvm use`)。首次获取源码后安装依赖(分别按文档和官网的锁文件安装): + +```bash +cd website-docs +npm run setup +npm run build +npm run preview +``` + +预览地址:`http://127.0.0.1:3000/`。修改源码后重新构建并刷新;可用 `npm run preview -- --port 8080` 指定其他端口。 + +```bash +npm run check +npm run test:integration +``` + +集成检查需要安装 Google Chrome,验证主题同步、两边导航、搜索、手机端控件及直达文档路由。可用 `SITE_TEST_URL` 指定待验证的站点。 + +开发时可分别使用 `npm run dev:homepage`(官网)和 `npm run dev:docs`(文档)获得热更新;完整站内跳转请使用统一构建后的 `npm run preview`。 + +`npm run build:docs` 只编译文档,`npm run build:homepage` 只编译官网;正式发布使用 `npm run build`,输出会同时包含两者。`VERSION` 是这份站点构建使用的发布版本。 + +## 工程目录(相对于 website-docs) + +- `homepage/`:Next.js 官网源码、品牌素材及独立依赖锁文件。 +- `01-getting-started/` 至 `06-development/`:文档正文,原有路径不变。 +- `.vitepress/`:文档站配置与主题。 +- `public/`、`sample-data/`:文档截图和示例。 +- `shared/`:品牌变量、顶栏样式及共用图标。 +- `scripts/`:统一构建、检查、预览和打包。 +- `static-site/`:唯一的部署目录,由构建生成。 +- `deploy/`、`Dockerfile`:Nginx 和 Docker 部署配置。 +- `releases/`:生成的部署压缩包。 + +品牌素材来源见 [homepage/BRAND-ASSETS.md](homepage/BRAND-ASSETS.md)。产品视频使用 README 中的 GitHub 原始附件,播放需要访问 GitHub;页面、文档和截图随包部署。 diff --git a/website-docs/VERSION b/website-docs/VERSION new file mode 100644 index 00000000..a3df0a69 --- /dev/null +++ b/website-docs/VERSION @@ -0,0 +1 @@ +0.8.0 diff --git a/website-docs/deploy/nginx.conf b/website-docs/deploy/nginx.conf new file mode 100644 index 00000000..cf9f3aac --- /dev/null +++ b/website-docs/deploy/nginx.conf @@ -0,0 +1,30 @@ +server { + listen 80; + server_name _; + root /usr/share/nginx/html; + index index.html; + # Preserve the public scheme and port when served behind a proxy or Docker. + absolute_redirect off; + + gzip on; + gzip_vary on; + gzip_min_length 1024; + gzip_comp_level 6; + gzip_proxied any; + gzip_types text/plain text/css text/javascript application/javascript application/json + application/xml application/rss+xml image/svg+xml font/ttf font/otf; + + add_header X-Frame-Options "SAMEORIGIN" always; + add_header X-Content-Type-Options "nosniff" always; + add_header Referrer-Policy "strict-origin-when-cross-origin" always; + + location = /docs { return 308 /docs/; } + location /docs/ { + try_files $uri $uri.html $uri/ =404; + error_page 404 /docs/404.html; + } + location / { + try_files $uri $uri/ =404; + error_page 404 /404.html; + } +} diff --git a/website-docs/docker-entrypoint.sh b/website-docs/docker-entrypoint.sh deleted file mode 100644 index 911d7022..00000000 --- a/website-docs/docker-entrypoint.sh +++ /dev/null @@ -1,4 +0,0 @@ -#!/bin/sh -set -e - -exec nginx -g 'daemon off;' diff --git a/website-docs/homepage/BRAND-ASSETS.md b/website-docs/homepage/BRAND-ASSETS.md new file mode 100644 index 00000000..a0788602 --- /dev/null +++ b/website-docs/homepage/BRAND-ASSETS.md @@ -0,0 +1,16 @@ +# Brand asset sources + +Logos identify supported integrations; their names and marks belong to their respective owners. + +- WeKnora logo: `docs/images/logo.png` from the WeKnora repository (the README logo), copied unchanged to `public/brand/weknora-original.png`. The site preserves all lettering, graphics and proportions. CSS hides only the empty outer canvas and blends the white background into the page; dark mode uses an inverted presentation with hue rotation. The source image remains unchanged. +- WeKnora browser icon: copied unchanged from the existing product's `frontend/public/favicon.ico` into the homepage and documentation. The replacement square sail SVG is no longer shipped. +- Feishu, GitLab, Tencent IMA, Notion, Yuque, RSS, WeCom, Slack, Telegram: copied unchanged from the WeKnora frontend asset library. +- OpenAI, DeepSeek, Qwen, Hunyuan, Gemini, Ollama, MCP: static SVGs from [Lobe Icons](https://github.com/lobehub/lobe-icons), `@lobehub/icons-static-svg@1.95.0`. Upstream MIT license included with assets. +- Chrome: [official Chrome website asset](https://www.google.com/chrome/static/images/chrome-logo-m100.svg). +- File formats, REST API, CLI: generic interface icons, not brand logos. +- LiteLLM: [official documentation favicon](https://docs.litellm.ai/img/favicon.ico). + +## Product screenshots + +- Wiki browser: copied unchanged from `../public/screenshots/wiki-browser.png` to `public/product/wiki-browser.png`. Shows the actual Wiki directory, linked page and source references using sample company policies. +- Wiki graph and revision history: copied unchanged from `../public/screenshots/wiki-graph.png` and `wiki-revision-history.png` to matching files in `public/product/`, for the horizontal Wiki gallery. diff --git a/website-docs/homepage/README.md b/website-docs/homepage/README.md new file mode 100644 index 00000000..f8102c84 --- /dev/null +++ b/website-docs/homepage/README.md @@ -0,0 +1,11 @@ +# WeKnora homepage source + +The Next.js homepage is one part of the unified site. Run `npm run setup`, `npm run build`, and `npm run preview` from the parent directory to include both the homepage and the complete `/docs/` site. Deployment instructions are in the parent README. + +- `app/page.tsx`: product content and same-origin documentation links. +- `app/home.module.css`: homepage layout. +- `app/interactive.tsx`: responsive navigation, theme switch, and on-demand README video. +- `app/theme.ts`: VitePress-compatible theme persistence and pre-paint initialization. +- `../shared/brand.css`: shared light/dark design tokens. + +`npm run dev` can still preview the homepage alone during development. `/docs/` requires the combined preview from the parent directory. diff --git a/website-docs/homepage/app/brand-logo.tsx b/website-docs/homepage/app/brand-logo.tsx new file mode 100644 index 00000000..e92315de --- /dev/null +++ b/website-docs/homepage/app/brand-logo.tsx @@ -0,0 +1,6 @@ +import Image from "next/image"; + +/** Show the complete original artwork; the viewport only trims blank canvas. */ +export function BrandLogo({ priority = false }: { priority?: boolean }) { + return WeKnora; +} diff --git a/website-docs/homepage/app/brands.tsx b/website-docs/homepage/app/brands.tsx new file mode 100644 index 00000000..3439a905 --- /dev/null +++ b/website-docs/homepage/app/brands.tsx @@ -0,0 +1,45 @@ +import Image from "next/image"; +import { Icon } from "./ui"; + +type Integration = { name: string; logo: string } | { name: string; icon: string }; + +export const dataSources: Integration[] = [ + { name: "PDF / Office", icon: "file" }, + { name: "飞书", logo: "feishu.ico" }, + { name: "GitLab", logo: "gitlab.png" }, + { name: "腾讯 IMA", logo: "ima.png" }, + { name: "Notion", logo: "notion.ico" }, + { name: "语雀", logo: "yuque.ico" }, + { name: "RSS", logo: "rss.svg" }, +]; + +export const clients: Integration[] = [ + { name: "企业微信", logo: "wecom.svg" }, + { name: "飞书", logo: "feishu.ico" }, + { name: "Slack", logo: "slack.svg" }, + { name: "Telegram", logo: "telegram.svg" }, + { name: "Chrome", logo: "chrome.svg" }, + { name: "MCP", logo: "mcp.svg" }, + { name: "API", icon: "code" }, + { name: "CLI", icon: "terminal" }, + { name: "DeepSeek Harness", logo: "deepseek-color.svg" }, +]; + +export const modelProviders: Integration[] = [ + { name: "OpenAI", logo: "openai.svg" }, + { name: "DeepSeek", logo: "deepseek-color.svg" }, + { name: "Qwen", logo: "qwen-color.svg" }, + { name: "混元", logo: "hunyuan-color.svg" }, + { name: "Gemini", logo: "gemini-color.svg" }, + { name: "Ollama", logo: "ollama.svg" }, + { name: "LiteLLM", logo: "litellm.ico" }, +]; + +export function IntegrationMark({ item }: { item: Integration }) { + return <> + {"logo" in item + ? + : } + {item.name} + ; +} diff --git a/website-docs/homepage/app/favicon.ico b/website-docs/homepage/app/favicon.ico new file mode 100644 index 00000000..c8931efa Binary files /dev/null and b/website-docs/homepage/app/favicon.ico differ diff --git a/website-docs/homepage/app/globals.css b/website-docs/homepage/app/globals.css new file mode 100644 index 00000000..fada06c8 --- /dev/null +++ b/website-docs/homepage/app/globals.css @@ -0,0 +1,13 @@ +@import "tailwindcss"; +@import "../../shared/brand.css"; +@import "../../shared/header.css"; +:root { background: var(--wk-paper); color: var(--wk-ink); } +* { box-sizing: border-box; } +body { margin: 0; font-family: var(--wk-font-sans); -webkit-font-smoothing: antialiased; } +html { scroll-behavior: smooth; } +button, a { -webkit-tap-highlight-color: transparent; touch-action: manipulation; } +button { font: inherit; cursor: pointer; } +a { text-decoration: none; } +::selection { background: var(--wk-accent-border); color: var(--wk-ink); } +:focus-visible { outline: 2px solid #b8863b; outline-offset: 5px; } +@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } *, *::before, *::after { transition: none !important; animation: none !important; } } diff --git a/website-docs/homepage/app/home.module.css b/website-docs/homepage/app/home.module.css new file mode 100644 index 00000000..f55dc3a8 --- /dev/null +++ b/website-docs/homepage/app/home.module.css @@ -0,0 +1,260 @@ +.site { + --ink: var(--wk-ink); + --soft: var(--wk-ink-soft); + --mute: var(--wk-ink-mute); + --gold: var(--wk-gold); + --paper: var(--wk-paper); + --paper2: var(--wk-paper-2); + --rule: var(--wk-rule); + --serif: var(--wk-font-serif); + color: var(--ink); + background: var(--paper); + font-size: 16px; + line-height: 1.75; +} +.site svg { flex-shrink: 0; } +.site section[id], .videoFigure { scroll-margin-top: 105px; } +.shell { width: calc(100% - 112px); max-width: 1600px; margin-inline: auto; } +.skipLink { position: fixed; left: 20px; top: -100px; z-index: 30; padding: 12px 20px; background: var(--ink); color: var(--paper); } +.skipLink:focus { top: 12px; } +.brand { display: inline-flex; align-items: center; gap: 12px; color: var(--ink); flex-shrink: 0; } +.hero { padding-top: 51px; } +.releaseLink { display: inline-flex; align-items: center; flex-wrap: wrap; gap: 13px; color: var(--soft); font-size: 14px; } +.releaseLink > span { border: 1px solid var(--wk-accent-border); padding: 3px 10px; color: var(--wk-accent-text); font-family: ui-monospace, monospace; font-size: 12px; } +.releaseLink svg { width: 17px; height: 17px; transition: transform .2s; } +.releaseLink:hover svg { transform: translateX(4px); } +.heroGrid { display: grid; grid-template-columns: 1.2fr 1fr; align-items: end; gap: 6vw; margin: 28px 0 50px; } +.hero h1 { font-family: var(--serif); font-size: clamp(42px, 4.5vw, 80px); font-weight: 500; line-height: 1.17; letter-spacing: -.045em; margin: 0; } +.hero h1 em { font-style: normal; color: var(--gold); } +.heroAside { padding-bottom: 6px; } +.eyebrow { font-family: ui-monospace, "SF Mono", monospace; color: var(--gold); font-size: 12px; letter-spacing: .14em; font-weight: 500; margin: 0 0 20px; } +.heroDescription { font-size: clamp(16px, 1.32vw, 21px); line-height: 1.85; color: var(--soft); margin: 0; max-width: 550px; } +.actions { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 26px; } +.primary, .secondary { display: inline-flex; align-items: center; justify-content: center; gap: 28px; font-size: 15px; font-weight: 550; min-height: 49px; padding: 12px 23px; border: 1px solid var(--ink); border-radius: 3px; transition: background .2s, color .2s, transform .2s; } +.primary { color: var(--paper); background: var(--ink); } +.primary:hover { background: var(--wk-button-hover); transform: translateY(-2px); } +.secondary { color: var(--ink); background: transparent; border-color: var(--rule); gap: 11px; } +.secondary:hover { border-color: var(--gold); background: var(--paper2); } +.primary svg, .secondary svg { width: 18px; height: 18px; } +.heroNote { color: var(--mute); font-size: 13px; margin: 19px 0 0; letter-spacing: .02em; } +.videoFigure { margin: 0; border: 1px solid var(--rule); border-radius: 7px; overflow: hidden; box-shadow: 0 22px 55px -35px rgba(16, 31, 56, .28); background: var(--wk-surface); } +.videoTop { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 13px 22px; color: var(--soft); background: var(--paper2); font-family: ui-monospace, monospace; font-size: 12px; letter-spacing: .1em; } +.videoTop > span { display: inline-flex; align-items: center; gap: 10px; } +.videoDot { margin-inline: 5px; color: var(--gold); } +.videoStage { position: relative; aspect-ratio: 16 / 8.5; background: #14191e; } +.videoStage video { width: 100%; height: 100%; display: block; object-fit: contain; } +.videoCover { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; display: flex; flex-direction: column; justify-content: center; align-items: center; color: white; background: linear-gradient(180deg, rgba(18,22,26,.24), rgba(18,22,26,.6)); transition: background .2s; } +.playCircle { width: 82px; height: 82px; display: flex; align-items: center; justify-content: center; background: #fdfcfa; color: #101f38; border-radius: 50%; box-shadow: 0 4px 24px #0002; transition: transform .2s; } +.playCircle svg { width: 29px; height: 29px; transform: translateX(-2px); fill: #101f38; stroke-width: 0; } +.videoCover:hover .playCircle { transform: scale(1.08); } +.videoCoverTitle { font-size: clamp(18px, 2vw, 30px); font-weight: 500; letter-spacing: .07em; margin-top: 24px; } +.videoCoverHint { font-size: 14px; margin-top: 8px; color: #eee8dc; } +.videoError { position: absolute; inset: 0; display: flex; flex-direction: column; justify-content: center; align-items: center; background: var(--paper2); color: var(--ink); gap: 18px; } +.videoError a { display: inline-flex; gap: 8px; align-items: center; text-decoration: underline; } +.videoError svg { width: 18px; height: 18px; } +.videoCaption { display: flex; justify-content: space-between; align-items: center; gap: 15px; padding: 14px 22px; font-size: 13px; color: var(--soft); } +.videoCaption a { color: var(--mute); display: inline-flex; align-items: center; gap: 9px; } +.videoCaption svg { height: 14px; width: 14px; } +.trustBar { display: flex; justify-content: center; align-items: center; gap: 7vw; padding: 30px 0; font-size: 13px; color: var(--soft); border-bottom: 1px solid var(--rule); } +.trustBar span { display: flex; align-items: center; gap: 10px; } +.trustBar svg { width: 18px; height: 18px; color: var(--mute); } +.section { padding-block: 104px; } +.sectionHeading { display: flex; justify-content: space-between; align-items: end; gap: 40px; margin-bottom: 45px; } +.sectionHeading h2, .closing h2 { font-family: var(--serif); font-size: clamp(32px, 3.1vw, 50px); font-weight: 500; line-height: 1.35; letter-spacing: -.03em; margin: 0; } +.sectionHeading > p { font-size: 16px; color: var(--soft); line-height: 1.9; margin: 0 0 3px; } +.modeGrid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); border-block: 1px solid var(--rule); } +.mode { padding: 35px 35px 32px; display: flex; flex-direction: column; } +.mode:first-child { padding-left: 0; } +.mode:last-child { padding-right: 0; } +.mode + .mode { border-left: 1px solid var(--rule); } +.modeTop { display: flex; justify-content: space-between; align-items: center; margin-bottom: 31px; } +.modeTop > svg { width: 33px; height: 33px; stroke-width: 1.1; } +.modeTop > span { font-family: ui-monospace, monospace; font-size: 12px; letter-spacing: .11em; color: var(--gold); } +.mode h3 { font-size: clamp(20px, 1.7vw, 26px); font-weight: 550; line-height: 1.5; margin: 0 0 15px; } +.mode > p { font-size: 16px; line-height: 1.85; color: var(--soft); margin: 0 0 23px; } +.tags { display: flex; gap: 9px; flex-wrap: wrap; padding: 0; list-style: none; margin: auto 0 31px; } +.tags li { color: var(--soft); background: var(--paper2); padding: 3px 9px; font-size: 12px; border-radius: 2px; } +.textLink { display: inline-flex; gap: 10px; align-items: center; color: var(--ink); font-size: 14px; min-height: 32px; width: fit-content; } +.textLink svg { width: 17px; height: 17px; transition: transform .2s; } +.textLink:hover { color: var(--wk-accent-text); } +.textLink:hover svg { transform: translateX(3px); } +.release { padding-block: 93px 44px; background: var(--paper2); border-block: 1px solid var(--rule); } +.releaseGrid { display: grid; grid-template-columns: 1.4fr 1fr; gap: 58px; align-items: center; } +.artifactFigure { margin: 0; min-width: 0; background: var(--paper); border: 1px solid var(--rule); border-radius: 5px; box-shadow: 0 18px 45px -35px #101f3844; overflow: hidden; } +.artifactHeading { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; padding: 16px 20px; font-size: 13px; border-bottom: 1px solid var(--rule); } +.artifactHeading > span { display: inline-flex; align-items: center; gap: 8px; } +.artifactHeading > span:last-child { font-family: ui-monospace, monospace; letter-spacing: .07em; font-size: 12px; color: var(--mute); } +.artifactHeading svg { width: 17px; height: 17px; color: var(--gold); } +.artifactImage img { display: block; width: 100%; height: auto; } +.artifactFigure figcaption { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px; padding: 14px 20px; font-size: 12px; color: var(--soft); border-top: 1px solid var(--rule); } +.artifactFigure figcaption > span:last-child { color: var(--mute); } +.releaseFeatures article { display: grid; grid-template-columns: 27px 1fr; gap: 18px; padding-block: 25px; border-bottom: 1px solid var(--rule); } +.releaseFeatures article:first-child { padding-top: 0; } +.releaseFeatures article:last-child { border: 0; padding-bottom: 0; } +.releaseFeatures article > svg { margin-top: 4px; width: 26px; height: 26px; stroke-width: 1.3; } +.featureLabel { color: var(--wk-accent-text); font-size: 12px; letter-spacing: .08em; } +.releaseFeatures h3 { font-size: 20px; font-weight: 550; line-height: 1.5; margin: 5px 0 10px; } +.releaseFeatures p { font-size: 15px; line-height: 1.85; color: var(--soft); margin: 0 0 7px; } +.releaseFeatures .textLink { font-size: 13px; } +.releaseExtras { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 12px 24px; padding-top: 29px; margin-top: 48px; border-top: 1px solid var(--rule); font-size: 13px; color: var(--soft); } +.releaseExtras > span { color: var(--mute); } +.releaseExtras p { margin: 0; } +.site .wiki { border-bottom: 1px solid var(--rule); padding-block: 48px; scroll-margin-top: 64px; } +.site section.wiki[id] { scroll-margin-top: 64px; } +.wiki .sectionHeading { margin-bottom: 24px; } +.wiki .eyebrow { margin-bottom: 12px; } +.wikiGallery { min-width: 0; } +.wikiGalleryToolbar { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 8px 20px; margin-bottom: 16px; } +.wikiGalleryTabs { display: flex; gap: 8px; flex-wrap: wrap; } +.wikiGalleryTabs button { display: inline-flex; align-items: center; gap: 9px; padding: 10px 16px; min-height: 44px; border: 1px solid transparent; border-radius: 3px; color: var(--soft); background: transparent; font-size: 14px; } +.wikiGalleryTabs button[aria-pressed="true"] { color: var(--ink); border-color: var(--rule); background: var(--paper2); } +.wikiGalleryTabs button:hover { color: var(--wk-accent-text); } +.wikiGalleryTabs svg { width: 19px; height: 19px; } +.wikiGalleryTrack { --wiki-slide-width: min(84%, 720px); --wiki-slide-gap: 24px; display: flex; gap: var(--wiki-slide-gap); overflow-x: auto; scroll-snap-type: x mandatory; overscroll-behavior-x: contain; scrollbar-width: thin; scrollbar-color: var(--rule) transparent; padding-bottom: 16px; } +.wikiSlide { flex: 0 0 var(--wiki-slide-width); scroll-snap-align: center; box-shadow: none; } +.wikiSlide .artifactHeading { padding-block: 10px; } +.wikiSlide .artifactHeading .textLink { font-size: 12px; min-height: 24px; color: var(--soft); } +.wikiSlide .wikiSlideCaption { display: block; padding: 18px 24px; } +.wikiSlideCaption h3 { margin: 0 0 8px; color: var(--ink); font-size: 22px; font-weight: 550; line-height: 1.5; } +.wikiSlideCaption p { margin: 0; max-width: 780px; color: var(--soft); font-size: 15px; line-height: 1.85; } +.wikiGalleryControls { margin-left: auto; color: var(--mute); font-size: 13px; } +.wikiGalleryControls > div { display: flex; align-items: center; gap: 18px; flex-shrink: 0; } +.wikiGalleryControls > div > span { font-family: ui-monospace, monospace; color: var(--soft); } +.wikiGalleryControls button { display: grid; place-items: center; height: 44px; width: 44px; border: 1px solid var(--rule); border-radius: 50%; color: var(--ink); background: var(--paper); } +.wikiGalleryControls button:first-child svg { transform: rotate(180deg); } +.wikiGalleryControls button:disabled { opacity: .3; cursor: default; } +.wikiGalleryControls button:hover:not(:disabled) { color: var(--wk-accent-text); border-color: var(--gold); } +@media (min-width: 1100px) { + .wikiGalleryToolbar { display: none; } + .wikiGalleryTrack { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); overflow: visible; scroll-snap-type: none; padding-bottom: 0; } + .wikiSlideCaption h3 { font-size: 20px; } + .wikiSlide .wikiSlideCaption { padding: 20px; } + .wikiSlide .artifactHeading { padding-inline: 16px; } +} +.ecosystem { display: grid; grid-template-columns: 1fr .85fr 1fr; gap: 48px; padding: 38px 0 46px; border-block: 1px solid var(--rule); } +.ecosystemColumn > svg { width: 29px; height: 29px; color: var(--gold); } +.ecosystemColumn h3 { font-size: 23px; font-weight: 550; margin: 18px 0 7px; } +.ecosystemColumn > p { color: var(--soft); font-size: 15px; margin: 0 0 20px; } +.integrations { display: flex; flex-wrap: wrap; gap: 9px; margin-bottom: 22px; } +.integrations span { display: inline-flex; align-items: center; gap: 8px; padding: 8px 11px; border: 1px solid var(--rule); font-size: 13px; background: var(--wk-surface); border-radius: 3px; } +.integrations img, .integrations svg { display: block; width: 20px; height: 20px; flex-shrink: 0; object-fit: contain; } +.ecosystemCore { position: relative; display: flex; justify-content: center; align-items: center; flex-direction: column; border-inline: 1px solid var(--rule); gap: 5px; text-align: center; } +.ecosystemCore > strong { font-size: 28px; margin-top: 10px; font-weight: 550; letter-spacing: -.03em; } +.ecosystemCore > span:not(:global(.wk-logo)) { font-size: 14px; color: var(--soft); } +.ecosystemCore > div { font-size: 12px; color: var(--gold); margin-top: 18px; } +.models { display: flex; align-items: center; justify-content: space-between; gap: 16px 25px; flex-wrap: wrap; padding-top: 28px; } +.models > span { color: var(--mute); font-size: 13px; } +.models > p { display: inline-flex; align-items: center; gap: 9px; font-size: 16px; color: var(--soft); font-weight: 550; margin: 0; } +.models img { display: block; width: 24px; height: 24px; flex-shrink: 0; object-fit: contain; } +.models a { display: flex; align-items: center; min-height: 40px; min-width: 40px; color: var(--soft); } +.enterprise { background: var(--paper2); border-block: 1px solid var(--rule); padding-block: 87px; } +.enterpriseGrid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 50px; border-top: 1px solid var(--rule); padding-top: 37px; } +.enterpriseGrid article > svg { color: var(--gold); width: 29px; height: 29px; } +.enterpriseGrid h3 { margin: 22px 0 12px; font-size: 22px; font-weight: 550; } +.enterpriseGrid p { margin: 0; color: var(--soft); font-size: 16px; line-height: 1.9; } +.closing { padding-block: 95px; display: flex; align-items: center; justify-content: space-between; gap: 40px; } +.closing h2 { font-size: clamp(30px, 2.8vw, 43px); } +.closing .primary { flex-shrink: 0; } +.footer { display: flex; flex-wrap: wrap; align-items: center; gap: 24px; padding-block: 28px; border-top: 1px solid var(--rule); } +.footer > p { color: var(--mute); font-size: 12px; margin: 0; } +.footer nav { margin-left: auto; display: flex; gap: 28px; } +.footer nav a { display: flex; align-items: center; gap: 4px; min-height: 44px; color: var(--soft); font-size: 13px; } +@media (min-width: 1800px) { .heroGrid { margin-bottom: 62px; } .hero { padding-top: 70px; } } +@media (max-width: 1100px) { + .shell { width: calc(100% - 64px); } + .heroGrid { gap: 32px; grid-template-columns: 1.1fr 1fr; } + .hero h1 { font-size: clamp(36px, 4.2vw, 48px); } + .heroDescription { font-size: 16px; } + .section { padding-block: 78px; } + .sectionHeading { gap: 30px; } + .sectionHeading > p { max-width: 370px; font-size: 15px; } + .mode { padding-inline: 23px; } + .mode h3 { font-size: 20px; } + .releaseGrid { gap: 32px; grid-template-columns: 1.15fr 1fr; } + .releaseFeatures h3 { font-size: 18px; } + .ecosystem { gap: 28px; grid-template-columns: 1fr .7fr 1fr; } +} +@media (max-width: 800px) { + .wikiGalleryTrack { --wiki-slide-width: 92%; --wiki-slide-gap: 14px; } + .wikiSlide .wikiSlideCaption { padding: 18px; } + .wikiSlideCaption h3 { font-size: 20px; } + .navigationOpen { display: flex; position: absolute; left: 0; top: 72px; right: 0; padding: 20px 32px 26px; background: var(--paper); border-bottom: 1px solid var(--rule); flex-direction: column; align-items: stretch; gap: 4px; box-shadow: 0 15px 20px #101f380a; } + .navigationOpen a { font-size: 16px; } + .hero { padding-top: 34px; } + .heroGrid { align-items: start; grid-template-columns: 1fr; gap: 28px; margin-top: 26px; margin-bottom: 35px; } + .hero h1 { font-size: clamp(38px, 6.2vw, 68px); } + .heroAside > .eyebrow { display: none; } + .heroDescription { max-width: 100%; } + .heroNote { margin-top: 17px; } + .videoTop { padding: 11px 15px; font-size: 12px; } + .videoCaption { align-items: start; flex-direction: column; padding: 13px 15px; gap: 3px; } + .videoCaption a { font-size: 12px; } + .trustBar { gap: 16px 24px; flex-wrap: wrap; justify-content: flex-start; padding: 24px 0; } + .sectionHeading { flex-direction: column; align-items: start; gap: 20px; margin-bottom: 34px; } + .sectionHeading > p { max-width: none; } + .modeGrid { grid-template-columns: 1fr; } + .mode, .mode:first-child, .mode:last-child { padding: 29px 0; } + .mode + .mode { border-left: 0; border-top: 1px solid var(--rule); } + .modeTop { margin-bottom: 18px; } + .mode h3 { font-size: 24px; } + .mode > p { margin-bottom: 18px; } + .tags { margin-bottom: 17px; } + .release { padding-block: 65px 35px; } + .releaseGrid { grid-template-columns: 1fr; gap: 35px; } + .releaseFeatures h3 { font-size: 22px; } + .releaseFeatures p { font-size: 16px; } + .releaseExtras { justify-content: flex-start; margin-top: 28px; padding-top: 23px; } + .releaseExtras > span { flex-basis: 100%; } + .ecosystem { grid-template-columns: 1fr 1fr; gap: 32px; } + .ecosystemCore { grid-row: 1; grid-column: 1 / -1; border-inline: 0; border-bottom: 1px solid var(--rule); padding-bottom: 30px; } + .ecosystemColumn h3 { font-size: 22px; } + .enterprise { padding-block: 65px; } + .enterpriseGrid { grid-template-columns: 1fr; gap: 32px; } + .enterpriseGrid h3 { margin-top: 14px; } + .closing { flex-direction: column; align-items: start; padding-block: 68px; gap: 27px; } + .footer { gap: 14px 25px; } + .footer nav { margin-left: 0; width: 100%; gap: 26px; } +} +@media (max-width: 480px) { + .site .wiki { padding-block: 28px; } + .wiki .sectionHeading { gap: 12px; margin-bottom: 18px; } + .wiki .sectionHeading h2 { font-size: 28px; } + .wikiGalleryTabs { gap: 2px; } + .wikiGalleryTabs button { padding-inline: 9px; gap: 6px; font-size: 13px; } + .wikiGalleryTabs svg { width: 16px; height: 16px; } + .wikiSlide .wikiSlideCaption { padding: 18px 14px; } + .shell { width: calc(100% - 40px); } + .hero h1 { font-size: clamp(28px, 7.9vw, 38px); } + .releaseLink { font-size: 12px; gap: 8px; } + .heroDescription br { display: none; } + .videoTop { letter-spacing: 0; padding-inline: 10px; } + .videoTop > span { gap: 6px; } + .videoTop > span:last-child { display: none; } + .videoDot { margin: 0; } + .playCircle { height: 52px; width: 52px; } + .playCircle svg { width: 22px; height: 22px; } + .videoCoverTitle { font-size: 17px; margin-top: 13px; } + .videoCoverHint { font-size: 12px; margin-top: 4px; } + .trustBar { font-size: 12px; gap: 13px; } + .trustBar span { gap: 7px; } + .section { padding-block: 60px; } + .sectionHeading h2 { font-size: 32px; } + .eyebrow { font-size: 12px; letter-spacing: .09em; margin-bottom: 15px; } + .ecosystem { grid-template-columns: 1fr; padding-top: 28px; } + .ecosystemCore { grid-column: 1; } + .ecosystemColumn + .ecosystemColumn { border-top: 1px solid var(--rule); padding-top: 26px; } + .models { justify-content: flex-start; gap: 15px 22px; } + .models > span { flex-basis: 100%; } + .models > p { font-size: 15px; } + .releaseFeatures article { grid-template-columns: 24px 1fr; gap: 14px; } + .releaseFeatures h3 { font-size: 20px; } + .artifactHeading { padding-inline: 12px; } + .artifactHeading > span:last-child { font-size: 12px; } + .artifactFigure figcaption { padding-inline: 12px; } + .closing h2 { font-size: 30px; } + .footer > p { font-size: 12px; } +} + +:global(.dark) .integrations img, :global(.dark) .models img { background: var(--wk-logo-ground); padding: 2px; border-radius: 3px; } + +.ecosystemCore > :global(.wk-logo) { margin-bottom: 18px; } diff --git a/website-docs/homepage/app/interactive.tsx b/website-docs/homepage/app/interactive.tsx new file mode 100644 index 00000000..c26d4ec1 --- /dev/null +++ b/website-docs/homepage/app/interactive.tsx @@ -0,0 +1,57 @@ +"use client"; +import Link from "next/link"; +import { BrandLogo } from "./brand-logo"; +import { useRef, useState, useSyncExternalStore } from "react"; +import { Icon } from "./ui"; +import { getThemeSnapshot, subscribeToTheme, toggleTheme } from "./theme"; +import { siteNavigation, repositoryUrl, headerIcons } from "../../shared/header"; +import s from "./home.module.css"; +const videoUrl = "https://github.com/user-attachments/assets/2819598d-3140-4623-814a-8162a22b653c"; + +function HeaderIcon({ name }: { name: string }) { + return ; +} +function ThemeToggle() { + const dark = useSyncExternalStore(subscribeToTheme, getThemeSnapshot, () => false); + const label = dark ? "切换到浅色" : "切换到深色"; + return ; +} +export function Header() { + const [open, setOpen] = useState(false); + const menu = useRef(null); + return
{ if (event.key === "Escape" && open) { setOpen(false); menu.current?.focus(); } }}> +
+ + + + GitHub + +
+
; +} +export function ProductVideo() { + const player = useRef(null); + const [started, setStarted] = useState(false); + const [failed, setFailed] = useState(false); + function play() { + setStarted(true); + const video = player.current; + if (video) { + video.src = videoUrl; + video.play().catch(() => { /* Keep native controls available when another playback gesture is required. */ }); + video.focus(); + } + } + return
+
产品演示 / PRODUCT FILM02:25 / 1080P
+
+
+
知识问答、Agent 推理与 Wiki 整理README 产品视频 · 英文旁白 / 中英字幕
+
; +} diff --git a/website-docs/homepage/app/layout.tsx b/website-docs/homepage/app/layout.tsx new file mode 100644 index 00000000..67fcf961 --- /dev/null +++ b/website-docs/homepage/app/layout.tsx @@ -0,0 +1,21 @@ +import type { Metadata } from "next"; +import "./globals.css"; +import { themeInitializationScript } from "./theme"; + +export const metadata: Metadata = { + title: "WeKnora — 帮你找到答案,并将知识付诸实践", + description: "腾讯开源知识框架 WeKnora,集 RAG 问答、Agent 推理与自动 Wiki 于一体。v0.8.0 带来技能目录、会话级沙箱和跨会话长期记忆,支持私有化部署。", +}; + +export default function RootLayout({ + children, +}: Readonly<{ + children: React.ReactNode; +}>) { + return ( + + + +[进入快速上手](/01-getting-started/03-quickstart) diff --git a/website-docs/nginx.conf b/website-docs/nginx.conf deleted file mode 100644 index a4463487..00000000 --- a/website-docs/nginx.conf +++ /dev/null @@ -1,45 +0,0 @@ -server { - listen 8081; - server_name localhost; - - gzip on; - gzip_vary on; - gzip_min_length 1024; - gzip_comp_level 6; - gzip_proxied any; - gzip_types text/plain text/css text/javascript application/javascript application/json - application/xml application/rss+xml image/svg+xml font/ttf font/otf; - - add_header X-Frame-Options "SAMEORIGIN" always; - add_header X-Content-Type-Options "nosniff" always; - add_header X-XSS-Protection "1; mode=block" always; - add_header Referrer-Policy "strict-origin-when-cross-origin" always; - - error_log /var/log/nginx/error.log warn; - access_log /var/log/nginx/access.log; - - # 独立容器时根路径重定向到文档前缀;经网关反代 /docs/ 时通常不会命中。 - location = / { - return 302 /docs/; - } - - # VitePress base=/docs/:磁盘上是 dist/assets/...,URL 为 /docs/assets/... - location /docs { - alias /usr/share/nginx/html/; - index index.html; - try_files $uri $uri/ $uri.html /docs/index.html; - add_header Cache-Control "no-cache, must-revalidate" always; - } - - location ^~ /docs/assets/ { - alias /usr/share/nginx/html/assets/; - add_header Cache-Control "public, max-age=31536000, immutable" always; - } - - error_page 404 /docs/404.html; - - error_page 500 502 503 504 /50x.html; - location = /50x.html { - root /usr/share/nginx/html; - } -} diff --git a/website-docs/package-lock.json b/website-docs/package-lock.json index 4af81024..758cee1b 100644 --- a/website-docs/package-lock.json +++ b/website-docs/package-lock.json @@ -1,10 +1,12 @@ { "name": "weknora-docs-site", + "version": "0.8.0", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "weknora-docs-site", + "version": "0.8.0", "devDependencies": { "jsdom": "^28.0.0", "mermaid": "^11.16.0", @@ -12,6 +14,9 @@ "vitepress": "^1.6.4", "vitepress-plugin-mermaid": "^2.0.17", "vue": "^3.5.13" + }, + "engines": { + "node": "^22.13.0 || >=24.0.0" } }, "node_modules/@acemir/cssom": { diff --git a/website-docs/package.json b/website-docs/package.json index dc118abb..2dabe722 100644 --- a/website-docs/package.json +++ b/website-docs/package.json @@ -3,12 +3,22 @@ "private": true, "type": "module", "scripts": { - "dev": "vitepress dev", - "build": "vitepress build", - "preview": "vitepress preview", + "setup": "npm ci && npm --prefix homepage ci", + "dev": "node scripts/serve-site.mjs", + "dev:docs": "vitepress dev", + "dev:homepage": "npm --prefix homepage run dev", + "build": "node scripts/build-site.mjs", + "build:docs": "vitepress build", + "build:homepage": "npm --prefix homepage run build", + "preview": "node scripts/serve-site.mjs", "check:mermaid": "node scripts/check-mermaid.mjs", "check:links": "node scripts/check-links.mjs", - "check": "npm run check:links && npm run check:mermaid" + "check:docs": "npm run check:links && npm run check:mermaid", + "check:site": "node scripts/check-site.mjs", + "check": "npm run check:docs && npm run check:site", + "package:site": "node scripts/package-site.mjs", + "test:integration": "node scripts/test-integration.mjs", + "test:docker": "node scripts/test-docker.mjs" }, "devDependencies": { "mermaid": "^11.16.0", @@ -17,5 +27,9 @@ "vitepress-plugin-mermaid": "^2.0.17", "vue": "^3.5.13", "jsdom": "^28.0.0" + }, + "version": "0.8.0", + "engines": { + "node": "^22.13.0 || >=24.0.0" } } diff --git a/website-docs/public/favicon.ico b/website-docs/public/favicon.ico new file mode 100644 index 00000000..c8931efa Binary files /dev/null and b/website-docs/public/favicon.ico differ diff --git a/website-docs/public/favicon.svg b/website-docs/public/favicon.svg deleted file mode 100644 index 146e4625..00000000 --- a/website-docs/public/favicon.svg +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - diff --git a/website-docs/public/logo-mark-dark.svg b/website-docs/public/logo-mark-dark.svg deleted file mode 100644 index c502fe66..00000000 --- a/website-docs/public/logo-mark-dark.svg +++ /dev/null @@ -1,5 +0,0 @@ - - - - - diff --git a/website-docs/public/logo-mark.svg b/website-docs/public/logo-mark.svg deleted file mode 100644 index b30a8f3a..00000000 --- a/website-docs/public/logo-mark.svg +++ /dev/null @@ -1,5 +0,0 @@ - - - - - diff --git a/website-docs/scripts/build-site.mjs b/website-docs/scripts/build-site.mjs new file mode 100644 index 00000000..c03a8c12 --- /dev/null +++ b/website-docs/scripts/build-site.mjs @@ -0,0 +1,26 @@ +import { spawnSync } from 'node:child_process'; +import { cpSync, rmSync, existsSync } from 'node:fs'; +import { resolve, dirname } from 'node:path'; +import { fileURLToPath } from 'node:url'; +const root = resolve(dirname(fileURLToPath(import.meta.url)), '..'); +function run(dir, script) { + const result = spawnSync('npm', ['run', script], { cwd: resolve(root, dir), stdio: 'inherit' }); + if (result.status !== 0) process.exit(result.status || 1); +} +for (const dir of ['homepage', '.']) { + if (!existsSync(resolve(root, dir, 'node_modules'))) throw new Error('Dependencies missing. Run npm run setup first.'); +} +run('homepage', 'build'); +run('.', 'check:docs'); +run('.', 'build:docs'); +const output = resolve(root, 'homepage/out'); +rmSync(resolve(output, 'docs'), { recursive: true, force: true }); +cpSync(resolve(root, '.vitepress/dist'), resolve(output, 'docs'), { recursive: true }); +run('homepage', 'audit:content'); +const check = spawnSync(process.execPath, ['scripts/check-site.mjs', output], { cwd: root, stdio: 'inherit' }); +if (check.status !== 0) process.exit(check.status || 1); +// Update the deployment directory only after both applications and their links pass. +const destination = resolve(root, 'static-site'); +rmSync(destination, { recursive: true, force: true }); +cpSync(output, destination, { recursive: true }); +console.log('Unified site ready: static-site/ (homepage + /docs/).'); diff --git a/website-docs/scripts/check-links.mjs b/website-docs/scripts/check-links.mjs index a9e6a2f1..20311fb2 100644 --- a/website-docs/scripts/check-links.mjs +++ b/website-docs/scripts/check-links.mjs @@ -8,7 +8,7 @@ const root = join(dirname(fileURLToPath(import.meta.url)), '..') function walk(dir, out = []) { for (const name of readdirSync(dir)) { - if (name === 'node_modules' || name.startsWith('.')) continue + if (['node_modules', 'homepage', 'shared', 'scripts', 'deploy', 'static-site', 'releases'].includes(name) || name.startsWith('.')) continue const path = join(dir, name) if (statSync(path).isDirectory()) walk(path, out) else if (name.endsWith('.md')) out.push(path) diff --git a/website-docs/scripts/check-mermaid.mjs b/website-docs/scripts/check-mermaid.mjs index a6b1f125..dd359d2c 100644 --- a/website-docs/scripts/check-mermaid.mjs +++ b/website-docs/scripts/check-mermaid.mjs @@ -23,7 +23,7 @@ mermaid.initialize({ startOnLoad: false, securityLevel: 'loose' }) function walk(dir, out = []) { for (const name of readdirSync(dir)) { - if (name === 'node_modules' || name.startsWith('.')) continue + if (['node_modules', 'homepage', 'shared', 'scripts', 'deploy', 'static-site', 'releases'].includes(name) || name.startsWith('.')) continue const path = join(dir, name) if (statSync(path).isDirectory()) walk(path, out) else if (name.endsWith('.md')) out.push(path) diff --git a/website-docs/scripts/check-site.mjs b/website-docs/scripts/check-site.mjs new file mode 100644 index 00000000..ca80c57c --- /dev/null +++ b/website-docs/scripts/check-site.mjs @@ -0,0 +1,42 @@ +import assert from 'node:assert/strict'; +import { readFile, readdir } from 'node:fs/promises'; +import { dirname, resolve, relative } from 'node:path'; +import { fileURLToPath } from 'node:url'; +import { resolveSiteFile } from './site-files.mjs'; +const project = resolve(dirname(fileURLToPath(import.meta.url)), '..'); +const root = resolve(process.argv[2] || resolve(project, 'static-site')); +async function walk(dir) { + const result = []; + for (const entry of await readdir(dir, { withFileTypes: true })) { + const path = resolve(dir, entry.name); + if (entry.isDirectory()) result.push(...await walk(path)); + else if (entry.name.endsWith('.html')) result.push(path); + } + return result; +} +for (const retired of ['/demo/', '/demo/1/', '/redesign/', '/redesign/1/', '/demo6/preview.html', '/brand/weknora.svg', '/icon.svg', '/docs/favicon.svg', '/docs/README.html', '/docs/homepage/README.html', '/docs/homepage/BRAND-ASSETS.html', '/docs/static-site/', '/docs/releases/']) { + assert.equal(await resolveSiteFile(root, retired), null, `Retired demo must not be published: ${retired}`); +} +const failures = []; +const checked = new Map(); +const pages = await walk(root); +for (const file of pages) { + const html = await readFile(file, 'utf8'); + const route = '/' + relative(root, file).replaceAll('\\', '/'); + const base = new URL(route, 'https://weknora.test'); + for (const match of html.matchAll(/<(?:a|link|img|script|source|video)\b[^>]*>/g)) { + const tag = match[0]; + for (const [, raw] of tag.matchAll(/(?:href|src|poster)="([^"]+)"/g)) { + const url = new URL(raw.replaceAll('&', '&'), base); + if (url.origin !== base.origin) continue; + if (!checked.has(url.pathname)) checked.set(url.pathname, !!await resolveSiteFile(root, url.pathname)); + if (!checked.get(url.pathname)) failures.push(`${route}: missing ${url.pathname}`); + if (url.pathname === '/' && tag.startsWith(']*href="\/"[^>]*target="_self"/.test(html)) failures.push(`${route}: documentation logo must navigate to the main site`); +} +for (const path of ['/docs/', '/docs/03-features/22-skills-sandbox.html', '/docs/03-features/23-memory.html']) assert.ok(await resolveSiteFile(root, path), path); +assert.equal(failures.length, 0, [...new Set(failures)].join('\n')); +console.log(`Unified site check passed: ${pages.length} pages, ${checked.size} local routes/assets, same-tab homepage links and documentation logos.`); diff --git a/website-docs/scripts/package-site.mjs b/website-docs/scripts/package-site.mjs new file mode 100644 index 00000000..be46d2e8 --- /dev/null +++ b/website-docs/scripts/package-site.mjs @@ -0,0 +1,13 @@ +import { mkdirSync, readFileSync } from 'node:fs'; +import { resolve, dirname } from 'node:path'; +import { fileURLToPath } from 'node:url'; +import { spawnSync } from 'node:child_process'; +const root = resolve(dirname(fileURLToPath(import.meta.url)), '..'); +const check = spawnSync(process.execPath, ['scripts/check-site.mjs'], { cwd: root, stdio: 'inherit' }); +if (check.status !== 0) process.exit(check.status || 1); +mkdirSync(resolve(root, 'releases'), { recursive: true }); +const version = readFileSync(resolve(root, 'VERSION'), 'utf8').trim(); +const output = resolve(root, `releases/weknora-site-v${version}.tar.gz`); +const packed = spawnSync('tar', ['-czf', output, '-C', resolve(root, 'static-site'), '.'], { stdio: 'inherit', env: { ...process.env, COPYFILE_DISABLE: '1' } }); +if (packed.status !== 0) process.exit(packed.status || 1); +console.log(`Deployable archive: ${output}`); diff --git a/website-docs/scripts/serve-site.mjs b/website-docs/scripts/serve-site.mjs new file mode 100644 index 00000000..20023582 --- /dev/null +++ b/website-docs/scripts/serve-site.mjs @@ -0,0 +1,24 @@ +import { createServer } from 'node:http'; +import { createReadStream } from 'node:fs'; +import { resolve, dirname, extname } from 'node:path'; +import { fileURLToPath } from 'node:url'; +import { resolveSiteFile } from './site-files.mjs'; +const root = resolve(dirname(fileURLToPath(import.meta.url)), '../static-site'); +const portIndex = process.argv.indexOf('--port'); +const port = Number(portIndex < 0 ? 3000 : process.argv[portIndex + 1]); +const types = { '.html': 'text/html; charset=utf-8', '.js': 'text/javascript; charset=utf-8', '.css': 'text/css; charset=utf-8', '.json': 'application/json', '.svg': 'image/svg+xml', '.png': 'image/png', '.jpg': 'image/jpeg', '.jpeg': 'image/jpeg', '.webp': 'image/webp', '.ico': 'image/x-icon', '.woff2': 'font/woff2', '.txt': 'text/plain; charset=utf-8' }; +const server = createServer(async (request, response) => { + try { + if (!['GET', 'HEAD'].includes(request.method)) { response.writeHead(405, { Allow: 'GET, HEAD' }).end(); return; } + const url = new URL(request.url, 'http://localhost'); + if (url.pathname === '/docs') { response.writeHead(308, { Location: '/docs/' + url.search }).end(); return; } + let file = await resolveSiteFile(root, url.pathname); + const status = file ? 200 : 404; + if (!file) file = await resolveSiteFile(root, url.pathname.startsWith('/docs/') ? '/docs/404.html' : '/404.html'); + if (!file) { response.writeHead(404).end('Not found'); return; } + response.writeHead(status, { 'Content-Type': types[extname(file.path)] || 'application/octet-stream', 'Content-Length': file.info.size, 'Cache-Control': 'no-cache', 'X-Content-Type-Options': 'nosniff' }); + if (request.method === 'HEAD') response.end(); + else createReadStream(file.path).pipe(response); + } catch { response.writeHead(500).end('Unable to serve this page'); } +}); +server.listen(port, '127.0.0.1', () => console.log(`WeKnora unified preview: http://127.0.0.1:${port}/`)); diff --git a/website-docs/scripts/site-files.mjs b/website-docs/scripts/site-files.mjs new file mode 100644 index 00000000..cba812ba --- /dev/null +++ b/website-docs/scripts/site-files.mjs @@ -0,0 +1,14 @@ +import { stat } from 'node:fs/promises'; +import { resolve, sep } from 'node:path'; +export async function resolveSiteFile(root, pathname) { + let decoded; + try { decoded = decodeURIComponent(pathname); } catch { return null; } + if (decoded.includes('\0') || decoded.includes('\\')) return null; + const path = resolve(root, `.${decoded}`); + if (path !== root && !path.startsWith(root + sep)) return null; + for (const candidate of [path, `${path}.html`, resolve(path, 'index.html')]) { + const info = await stat(candidate).catch(() => null); + if (info?.isFile()) return { path: candidate, info }; + } + return null; +} diff --git a/website-docs/scripts/test-docker.mjs b/website-docs/scripts/test-docker.mjs new file mode 100644 index 00000000..d165ceac --- /dev/null +++ b/website-docs/scripts/test-docker.mjs @@ -0,0 +1,66 @@ +import assert from 'node:assert/strict'; +import { spawnSync } from 'node:child_process'; +import { randomUUID } from 'node:crypto'; +import { setTimeout } from 'node:timers/promises'; + +const image = process.argv[2] || 'weknora-site:0.8.0'; +const name = `weknora-site-test-${randomUUID()}`; +function docker(...args) { + const result = spawnSync('docker', args, { encoding: 'utf8' }); + if (result.error) throw result.error; + assert.equal(result.status, 0, `docker ${args.join(' ')}\n${result.stderr}`); + return result.stdout.trim(); +} + +try { + docker('run', '-d', '--name', name, '-p', '127.0.0.1::80', image); + const origin = `http://${docker('port', name, '80/tcp')}`; + docker('exec', name, 'nginx', '-t'); + docker('exec', name, 'sh', '-c', '! command -v node && test ! -d /build && test ! -e /usr/share/nginx/html/package.json'); + let ready = false; + for (let attempt = 0; attempt < 30; attempt++) { + try { + ready = (await fetch(origin, { signal: AbortSignal.timeout(2000) })).ok; + if (ready) break; + } catch { /* Nginx may still be starting. */ } + await setTimeout(200); + } + assert.ok(ready, 'Container did not become ready'); + + const redirect = await fetch(`${origin}/docs`, { redirect: 'manual' }); + assert.equal(redirect.status, 308); + assert.equal(new URL(redirect.headers.get('location'), origin).origin, origin); + assert.equal(new URL(redirect.headers.get('location'), origin).pathname, '/docs/'); + const assets = new Set(['/brand/weknora-original.png', '/product/wiki-browser.png', '/docs/favicon.ico']); + for (const path of ['/', '/docs/', '/docs/03-features/14-wiki', '/docs/03-features/14-wiki.html']) { + const response = await fetch(origin + path); + assert.equal(response.status, 200, path); + assert.match(response.headers.get('content-type'), /text\/html/); + assert.equal(response.headers.get('x-content-type-options'), 'nosniff'); + assert.equal(response.headers.get('x-frame-options'), 'SAMEORIGIN'); + assert.equal(response.headers.get('referrer-policy'), 'strict-origin-when-cross-origin'); + const html = await response.text(); + assert.match(html, /WeKnora/i, path); + for (const [, asset] of html.matchAll(/(?:src|href)="([^"?#]+\.(?:js|css))"/g)) { + const url = new URL(asset, origin + path); + if (url.origin === origin) assets.add(url.pathname); + } + } + assert.ok([...assets].some(path => path.startsWith('/_next/')), 'Homepage scripts are missing'); + assert.ok([...assets].some(path => path.startsWith('/docs/assets/')), 'Documentation scripts are missing'); + for (const asset of assets) { + const response = await fetch(origin + asset); + assert.equal(response.status, 200, asset); + assert.doesNotMatch(response.headers.get('content-type'), /text\/html/, asset); + } + const compressed = await fetch(origin + '/', { headers: { 'Accept-Encoding': 'gzip' } }); + assert.equal(compressed.headers.get('content-encoding'), 'gzip'); + for (const path of ['/not-found', '/docs/not-found']) { + const response = await fetch(origin + path); + assert.equal(response.status, 404, path); + assert.equal(response.headers.get('x-content-type-options'), 'nosniff'); + } + console.log(`Docker site check passed: homepage, docs routes, ${assets.size} assets, redirects, 404s, compression, headers and runtime isolation.`); +} finally { + spawnSync('docker', ['rm', '-f', name], { stdio: 'ignore' }); +} diff --git a/website-docs/scripts/test-integration.mjs b/website-docs/scripts/test-integration.mjs new file mode 100644 index 00000000..c864f844 --- /dev/null +++ b/website-docs/scripts/test-integration.mjs @@ -0,0 +1,189 @@ +import assert from 'node:assert/strict'; +import { chromium } from 'playwright-core'; + +const origin = process.env.SITE_TEST_URL || 'http://127.0.0.1:3000'; +const key = 'vitepress-theme-appearance'; +const browser = await chromium.launch({ channel: 'chrome', headless: true }); +const context = await browser.newContext({ colorScheme: 'light', viewport: { width: 1440, height: 1000 } }); +const page = await context.newPage(); +const errors = []; +context.on('page', p => p.on('pageerror', error => errors.push(error.message))); +page.on('pageerror', error => errors.push(error.message)); +async function expectTheme(p, dark) { + await p.waitForFunction(expected => document.documentElement.classList.contains('dark') === expected, dark); +} +async function homepage(p = page) { + await p.waitForSelector('#hero-title'); + assert.equal(new URL(p.url()).pathname, '/'); +} +async function checkVisibleControl(p, selector) { + await p.waitForFunction(selector => { + const box = document.querySelector(selector)?.getBoundingClientRect(); + return box && box.width > 0 && box.x >= 0 && box.right <= innerWidth + 1; + }, selector); + const box = await p.locator(selector).boundingBox(); + assert.ok(box && box.width > 0 && box.x >= 0 && box.x + box.width <= p.viewportSize().width + 1, `${selector} must fit in the viewport`); +} +async function headerGeometry(p) { + return p.locator('.wk-header').evaluate(header => ({ + links: [...header.querySelectorAll('#main-navigation a')].map(a => [a.textContent.trim(), a.getAttribute('href')]), + controls: [...header.querySelectorAll('.wk-header-inner, .wk-brand, .wk-theme-toggle, .wk-header-github')].map(el => { + const box = el.getBoundingClientRect(); + return [Math.round(box.x), Math.round(box.y), Math.round(box.width), Math.round(box.height)]; + }), + })); +} +async function currentSidebarLinkVisible(p) { + await p.waitForFunction(() => { + const sidebar = document.querySelector('.VPSidebar'); + const active = sidebar?.querySelector('.VPSidebarItem.is-active > .item > a'); + if (!active) return false; + const bounds = sidebar.getBoundingClientRect(); + const item = active.getBoundingClientRect(); + return item.height > 0 && item.top >= bounds.top && item.bottom <= bounds.bottom; + }); +} +try { + assert.equal((await page.goto(origin + '/')).status(), 200); + await expectTheme(page, false); + const masthead = await headerGeometry(page); + await page.getByRole('switch', { name: '切换到深色' }).click(); + await expectTheme(page, true); + assert.equal(await page.evaluate(k => localStorage.getItem(k), key), 'dark'); + await page.reload(); + await expectTheme(page, true); + await page.locator('#main-navigation').getByRole('link', { name: '文档', exact: true }).click(); + await page.waitForSelector('.VPDoc h1'); + await expectTheme(page, true); + assert.equal(new URL(page.url()).pathname, '/docs/01-getting-started/03-quickstart.html'); + assert.match(await page.locator('.VPDoc h1').innerText(), /快速上手/); + assert.equal(await page.getByRole('link', { name: '文档首页', exact: true }).count(), 0); + assert.deepEqual((await headerGeometry(page)).controls, masthead.controls); + assert.deepEqual((await headerGeometry(page)).links.map(link => link[0]), ['快速开始', '架构', '功能', 'API', '客户端', '开发', 'GitHub']); + assert.equal(await page.locator('.wk-header').evaluate(el => el.getBoundingClientRect().height), 64); + assert.equal(context.pages().length, 1); + // Switching distant sections must reveal the selected sidebar item in both directions. + for (const section of ['客户端', '开发', '快速开始', '功能', '架构']) { + await page.locator('#main-navigation').getByRole('link', { name: section, exact: true }).click(); + await page.waitForFunction(section => document.querySelector('#main-navigation a[aria-current="page"]')?.textContent.trim() === section, section); + await currentSidebarLinkVisible(page); + assert.ok(await page.evaluate(() => window.scrollY < 2), 'Sidebar synchronization must not scroll the document'); + } + // Manual sidebar scrolling must remain untouched until navigation occurs. + await page.locator('.VPSidebar').evaluate(el => el.scrollTop = el.scrollHeight); + await page.locator('.wk-theme-toggle').click(); + assert.ok(await page.locator('.VPSidebar').evaluate(el => el.scrollTop > 500)); + await page.locator('.wk-theme-toggle').click(); + await page.locator('#main-navigation').getByRole('link', { name: 'API', exact: true }).click(); + await page.waitForFunction(() => location.pathname.includes('/04-api/')); + await page.waitForSelector('.VPDoc h1'); + await page.waitForFunction(() => document.querySelector('#main-navigation a[aria-current="page"]')?.textContent.trim() === 'API'); + const palette = await page.evaluate(() => getComputedStyle(document.documentElement).getPropertyValue('--wk-paper').trim()); + assert.equal(palette, '#0b1220'); + await page.locator('.wk-header-search button').click(); + await page.locator('#localsearch-input').fill('长期记忆'); + await page.waitForSelector('.VPLocalSearchBox .result'); + await page.keyboard.press('Escape'); + await page.locator('.wk-theme-toggle').click(); + await expectTheme(page, false); + await page.locator('.wk-brand').click(); + await homepage(); + await expectTheme(page, false); + assert.equal(context.pages().length, 1); + + // Navigation to new v0.8.0 docs, returning through the explicit home link. + await page.locator('#release').getByRole('link', { name: '了解更多', exact: true }).last().click(); + await page.waitForSelector('.VPDoc h1'); + assert.match(await page.locator('.VPDoc h1').innerText(), /记忆/); + await page.locator('.wk-brand').click(); + await homepage(); + assert.equal(context.pages().length, 1); + + // Preferences propagate between open homepage and docs tabs in both directions. + const docs = await context.newPage(); + await docs.goto(origin + '/docs/'); + await docs.waitForSelector('.VPDoc h1'); + await docs.locator('.wk-theme-toggle').click(); + await expectTheme(docs, true); + await expectTheme(page, true); + await page.getByRole('switch', { name: '切换到浅色' }).click(); + await expectTheme(page, false); + await expectTheme(docs, false); + await docs.close(); + + // With no explicit selection, follow the operating-system preference. + const automatic = await browser.newContext({ colorScheme: 'dark' }); + const autoPage = await automatic.newPage(); + await autoPage.goto(origin + '/'); + await expectTheme(autoPage, true); + await autoPage.emulateMedia({ colorScheme: 'light' }); + await expectTheme(autoPage, false); + await autoPage.goto(origin + '/docs/'); + await autoPage.waitForSelector('.VPDoc h1'); + await expectTheme(autoPage, false); + await autoPage.emulateMedia({ colorScheme: 'dark' }); + await expectTheme(autoPage, true); + await automatic.close(); + + // Switch and return links remain reachable on a narrow phone viewport. + await page.setViewportSize({ width: 320, height: 800 }); + await page.goto(origin + '/'); + await checkVisibleControl(page, 'button[role="switch"]'); + await page.getByRole('switch', { name: '切换到深色' }).click(); + await expectTheme(page, true); + await page.getByRole('button', { name: '打开导航' }).click(); + await page.locator('#main-navigation').getByRole('link', { name: '文档', exact: true }).click(); + await page.waitForSelector('.VPDoc h1'); + await expectTheme(page, true); + await checkVisibleControl(page, '.wk-brand'); + await page.locator('.wk-theme-toggle').click(); + await page.getByRole('button', { name: '打开导航' }).click(); + await checkVisibleControl(page, '.wk-header-search button'); + await page.locator('.wk-header-search button').click(); + await page.locator('#localsearch-input').fill('长期记忆'); + await page.waitForSelector('.VPLocalSearchBox .result'); + await page.keyboard.press('Escape'); + await page.keyboard.press('Escape'); + await page.locator('.VPLocalNav button.menu').click(); + await checkVisibleControl(page, '.VPSidebar.open'); + await page.keyboard.press('Escape'); + // A deep link must reveal its entry after hydration, including the mobile drawer. + await page.goto(origin + '/docs/05-clients/01-frontend.html'); + await page.locator('.VPLocalNav button.menu').click(); + await currentSidebarLinkVisible(page); + await page.keyboard.press('Escape'); + await expectTheme(page, false); + await page.locator('.wk-brand').click(); + await homepage(); + await expectTheme(page, false); + assert.equal(context.pages().length, 1); + + for (const path of ['/docs/03-features/22-skills-sandbox', '/docs/03-features/22-skills-sandbox.html', '/docs/03-features/23-memory.html']) { + const response = await context.request.get(origin + path); + assert.equal(response.status(), 200, path); + assert.ok(!(await response.text()).includes('id="hero-title"'), 'A missing docs route must not fall back to the homepage'); + } + assert.equal((await context.request.get(origin + '/docs/this-page-does-not-exist')).status(), 404); + for (const width of [320, 801, 1024, 1920]) { + await page.setViewportSize({ width, height: 900 }); + for (const path of ['/', '/docs/01-getting-started/02-installation.html']) { + await page.goto(origin + path); + await page.waitForSelector('.wk-header'); + const dimensions = await page.locator('.wk-header').evaluate(el => ({ width: el.getBoundingClientRect().width, height: el.getBoundingClientRect().height, scrollWidth: el.scrollWidth })); + assert.equal(dimensions.height, 64); + assert.equal(dimensions.width, width); + assert.equal(dimensions.scrollWidth, width); + await checkVisibleControl(page, '.wk-brand'); + await page.waitForFunction(() => { + const image = document.querySelector('.wk-brand img'); + return image?.complete && image.naturalWidth === 945 && image.naturalHeight === 650; + }); + assert.equal(await page.locator('.wk-brand img').getAttribute('src'), '/brand/weknora-original.png'); + await checkVisibleControl(page, '.wk-theme-toggle'); + } + } + assert.deepEqual(errors, []); + console.log('Integration checks passed: compact full-width mastheads, distinct product/docs navigation, quickstart entry, header search, theme toggle, reload, shared preferences, system theme, same-tab docs/home/logo navigation, mobile controls, and direct docs/404 routes.'); +} finally { + await browser.close(); +} diff --git a/website-docs/shared/brand.css b/website-docs/shared/brand.css new file mode 100644 index 00000000..b3dcb9d7 --- /dev/null +++ b/website-docs/shared/brand.css @@ -0,0 +1,52 @@ +/* Shared by the product homepage and VitePress documentation. */ +:root { + color-scheme: light; + --wk-ink: #101f38; + --wk-ink-deep: #0a1526; + --wk-ink-soft: #40536f; + --wk-ink-mute: #6d7d94; + --wk-gold: #b8863b; + --wk-gold-light: #d9a94f; + --wk-paper: #fdfcfa; + --wk-paper-2: #f5f3ee; + --wk-paper-3: #edeae2; + --wk-rule: rgba(16, 31, 56, .12); + --wk-rule-soft: rgba(16, 31, 56, .07); + --wk-surface: #fff; + --wk-header: rgba(253, 252, 250, .96); + --wk-button-hover: #24395a; + --wk-accent-text: #886025; + --wk-accent-border: #dfd1b9; + --wk-logo-ground: #fff; + --wk-font-sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "HarmonyOS Sans SC", "Source Han Sans SC", "Noto Sans CJK SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif; + --wk-font-serif: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, "Songti SC", "Source Han Serif SC", "Noto Serif CJK SC", "STSong", serif; + --wk-font-mono: "JetBrains Mono", ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace; +} +html.dark { + color-scheme: dark; + --wk-ink: #e6ecf5; + --wk-ink-soft: #a9b6c9; + --wk-ink-mute: #9aaac0; + --wk-gold: #d9a94f; + --wk-gold-light: #e8c176; + --wk-paper: #0b1220; + --wk-paper-2: #101a2b; + --wk-paper-3: #16233a; + --wk-rule: rgba(190, 208, 232, .14); + --wk-rule-soft: rgba(190, 208, 232, .08); + --wk-surface: #101a2b; + --wk-header: rgba(11, 18, 32, .96); + --wk-button-hover: #c3d0e2; + --wk-accent-text: #e8c176; + --wk-accent-border: #685638; +} + +/* Original README artwork, copied byte-for-byte. Only blank outer canvas is + hidden (source viewport: x=0, y=208, width=945, height=238). Keep the full + lettering, sail and waves. Blend away the blank background in light mode; + the user-approved inverted presentation is applied only in dark mode. */ +.wk-logo { position: relative; display: inline-block; width: 164px; aspect-ratio: 945 / 238; overflow: hidden; flex-shrink: 0; vertical-align: middle; mix-blend-mode: multiply; } +html.dark .wk-logo { mix-blend-mode: screen; } +html.dark .wk-logo img { filter: invert(1) hue-rotate(180deg); } +.wk-logo img { position: absolute; display: block; left: 0; top: -87.394958%; width: 100%; max-width: none; height: auto; } +@media (max-width: 480px) { .wk-brand .wk-logo { width: 148px; } } diff --git a/website-docs/shared/header.css b/website-docs/shared/header.css new file mode 100644 index 00000000..8a0aabd4 --- /dev/null +++ b/website-docs/shared/header.css @@ -0,0 +1,39 @@ +/* Keep the masthead identical across the product site and documentation. */ +.wk-header { position: sticky; top: 0; z-index: 30; width: 100%; border-bottom: 1px solid var(--wk-rule); background: var(--wk-header); backdrop-filter: blur(16px); color: var(--wk-ink); font-family: var(--wk-font-sans); font-feature-settings: normal; line-height: 1.75; } +.wk-header *, .wk-header *::before, .wk-header *::after { box-sizing: border-box; } +.wk-header a { text-decoration: none; } +.wk-header button { font: inherit; cursor: pointer; padding: 0; } +.wk-header-inner { width: 100%; padding-inline: 32px; margin-inline: auto; height: 63px; display: flex; align-items: center; gap: 28px; } +.wk-brand { display: inline-flex; align-items: center; gap: 12px; color: var(--wk-ink); flex-shrink: 0; } +.wk-navigation { display: flex; align-items: center; justify-content: center; gap: clamp(20px, 2.2vw, 40px); flex: 1; } +.wk-navigation a { min-height: 44px; display: inline-flex; align-items: center; gap: 6px; font-size: 14px; font-weight: 400; color: var(--wk-ink-soft); transition: color .2s; } +.wk-navigation a:hover, .wk-navigation a[aria-current="page"] { color: var(--wk-gold); } +.wk-header svg { width: 24px; height: 24px; flex-shrink: 0; } +.wk-navigation svg { width: 14px; height: 14px; } +.wk-new-label { font-size: 12px; font-weight: 650; color: var(--wk-accent-text); letter-spacing: .03em; border: 1px solid var(--wk-accent-border); padding: 0 4px; line-height: 1.6; } +.wk-header-github { font-size: 14px; display: flex; align-items: center; gap: 9px; color: var(--wk-ink); padding-left: 28px; border-left: 1px solid var(--wk-rule); min-height: 30px; } +.wk-header-github svg { width: 20px; height: 20px; } +.wk-header .wk-menu-toggle { display: none; border: 0; background: none; width: 44px; height: 44px; color: var(--wk-ink); align-items: center; justify-content: center; } +.wk-header .wk-theme-toggle { display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; width: 40px; height: 40px; border: 1px solid var(--wk-rule); border-radius: 20px; background: var(--wk-paper-2); color: var(--wk-ink-soft); } +.wk-theme-toggle:hover { color: var(--wk-gold); border-color: var(--wk-gold); } +.wk-theme-toggle svg { width: 19px; height: 19px; } +.wk-navigation .wk-mobile-github { display: none; } +.wk-header :focus-visible { outline: 2px solid var(--wk-gold); outline-offset: 5px; } +@media (max-width: 1100px) { + .wk-header-inner { padding-inline: 24px; gap: 14px; } + .wk-navigation { gap: 14px; } + .wk-navigation a { font-size: 13px; } + .wk-header-github { padding-left: 18px; } + .wk-header-github span { display: none; } +} +@media (max-width: 800px) { + .wk-header-inner { gap: 12px; } + .wk-header-github { display: none; } + .wk-header .wk-menu-toggle { display: flex; } + .wk-theme-toggle { margin-left: auto; } + .wk-navigation { display: none; } + .wk-navigation.is-open { display: flex; position: absolute; left: 0; top: 63px; max-height: calc(100dvh - 64px); overflow-y: auto; right: 0; padding: 20px 32px 26px; background: var(--wk-paper); border-bottom: 1px solid var(--wk-rule); flex-direction: column; align-items: stretch; gap: 4px; box-shadow: 0 15px 20px #101f380a; } + .wk-navigation a { font-size: 16px; } + .wk-navigation .wk-mobile-github { display: inline-flex; } +} +@media (max-width: 480px) { .wk-header-inner { padding-inline: 20px; } } diff --git a/website-docs/shared/header.ts b/website-docs/shared/header.ts new file mode 100644 index 00000000..8d3f72b3 --- /dev/null +++ b/website-docs/shared/header.ts @@ -0,0 +1,17 @@ +// Product navigation and shared masthead icons. +export const siteNavigation = [ + { label: '产品能力', href: '/#capabilities', badge: '' }, + { label: 'v0.8.0', href: '/#release', badge: 'NEW' }, + { label: '生态集成', href: '/#ecosystem', badge: '' }, + { label: '企业部署', href: '/#enterprise', badge: '' }, + { label: '文档', href: '/docs/', badge: '' }, +]; +export const repositoryUrl = 'https://github.com/Tencent/WeKnora'; +export const headerIcons: Record = { + sun: 'M16 12a4 4 0 1 1-8 0 4 4 0 0 1 8 0M12 2v2m0 16v2M2 12h2m16 0h2M5 5l1.5 1.5m11 11L19 19M5 19l1.5-1.5m11-11L19 5', + moon: 'M20.8 13A9 9 0 0 1 11 3.2 9 9 0 1 0 20.8 13Z', + menu: 'M4 6h16M4 12h16M4 18h16', + close: 'm5 5 14 14M5 19 19 5', + external: 'M8 5H5v14h14v-3M12 5h7v7M10 14 19 5', + github: 'M9 19c-4.3 1.3-4.3-2.2-6-2.7m12 5v-3.5c0-1 .1-1.4-.5-2 3.4-.4 7-1.7 7-7.5a5.7 5.7 0 0 0-1.5-4 5.4 5.4 0 0 0-.1-4S18.6-.1 15.5 2a14 14 0 0 0-7 0C5.4-.1 4.1.3 4.1.3A5.4 5.4 0 0 0 4 4.3a5.7 5.7 0 0 0-1.5 4c0 5.8 3.6 7.1 7 7.5-.6.6-.6 1.2-.5 2V21', +};