From 6c6d5c9ea3a3016bd4eb9e85e0a6ae1472c02b13 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=B8=8D=E5=A6=82=E6=91=B8=E9=B1=BC=E5=8E=BB?= <1780903673@qq.com> Date: Tue, 8 Jul 2025 17:50:28 +0800 Subject: [PATCH] =?UTF-8?q?docs:=20=E2=9C=8F=EF=B8=8F=20=20=E6=96=87?= =?UTF-8?q?=E6=A1=A3=E4=BE=A7=E8=BE=B9=E6=A0=8F=E6=96=B0=E5=A2=9E=E7=89=88?= =?UTF-8?q?=E6=9C=AC=E5=8F=B7=E6=98=BE=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/.vitepress/config.mts | 10 +- docs/.vitepress/config/version-data.ts | 10 + docs/.vitepress/plugins/version-badge.ts | 87 +++++ .../theme/components/VPSidebarItem.vue | 311 ++++++++++++++++++ docs/.vitepress/types/sidebar.d.ts | 1 + docs/component/circle.md | 2 +- docs/component/count-down.md | 2 +- docs/component/count-to.md | 5 +- docs/component/icon.md | 2 +- docs/component/index-bar.md | 2 +- docs/component/keyboard.md | 5 +- docs/component/overlay.md | 2 +- docs/component/password-input.md | 2 +- docs/component/root-portal.md | 5 +- docs/component/segmented.md | 2 +- docs/component/select-picker.md | 2 +- docs/component/sidebar.md | 2 +- docs/component/signature.md | 5 +- docs/component/table.md | 2 +- docs/component/textarea.md | 2 +- docs/component/watermark.md | 3 +- docs/en-US/component/circle.md | 2 +- docs/en-US/component/count-down.md | 2 +- docs/en-US/component/count-to.md | 2 +- docs/en-US/component/index-bar.md | 2 +- docs/en-US/component/keyboard.md | 5 +- docs/en-US/component/message-box.md | 2 +- docs/en-US/component/overlay.md | 2 +- docs/en-US/component/password-input.md | 2 +- docs/en-US/component/root-portal.md | 5 +- docs/en-US/component/segmented.md | 2 +- docs/en-US/component/select-picker.md | 2 +- docs/en-US/component/sidebar.md | 2 +- docs/en-US/component/signature.md | 5 +- docs/en-US/component/table.md | 2 +- docs/en-US/component/textarea.md | 2 +- docs/en-US/component/watermark.md | 2 +- docs/en-US/guide/locale.md | 2 +- docs/guide/locale.md | 2 +- 39 files changed, 473 insertions(+), 36 deletions(-) create mode 100644 docs/.vitepress/config/version-data.ts create mode 100644 docs/.vitepress/plugins/version-badge.ts create mode 100644 docs/.vitepress/theme/components/VPSidebarItem.vue create mode 100644 docs/.vitepress/types/sidebar.d.ts diff --git a/docs/.vitepress/config.mts b/docs/.vitepress/config.mts index 7bdd43e5..354ba48f 100644 --- a/docs/.vitepress/config.mts +++ b/docs/.vitepress/config.mts @@ -1,7 +1,7 @@ /* * @Author: weisheng * @Date: 2023-07-27 10:26:09 - * @LastEditTime: 2025-07-07 20:46:21 + * @LastEditTime: 2025-07-08 17:45:58 * @LastEditors: weisheng * @Description: * @FilePath: /wot-design-uni/docs/.vitepress/config.mts @@ -11,6 +11,7 @@ import { defineConfig } from 'vitepress'; import viteCompression from 'vite-plugin-compression' import { fileURLToPath, URL } from 'node:url' import { MarkdownTransform } from './plugins/markdown-transform' +import { VersionBadgePlugin } from './plugins/version-badge' import llmstxt from 'vitepress-plugin-llms' import enUS from './locales/en-US' import zhCN from './locales/zh-CN' @@ -22,6 +23,7 @@ export default defineConfig({ domain: 'https://wot-design-uni.cn', }), MarkdownTransform(), + VersionBadgePlugin(), viteCompression({ verbose: true, disable: false, @@ -62,6 +64,12 @@ export default defineConfig({ replacement: fileURLToPath( new URL('./theme/components/VPNavBar.vue', import.meta.url) ) + }, + { + find: /^.*\/VPSidebarItem\.vue$/, + replacement: fileURLToPath( + new URL('./theme/components/VPSidebarItem.vue', import.meta.url) + ) } ] } diff --git a/docs/.vitepress/config/version-data.ts b/docs/.vitepress/config/version-data.ts new file mode 100644 index 00000000..46fe9037 --- /dev/null +++ b/docs/.vitepress/config/version-data.ts @@ -0,0 +1,10 @@ +// 自动生成的版本数据 +// 此文件由插件自动生成,请勿手动修改 +// 如需修改版本信息,请在对应的 Markdown 文件 frontmatter 中修改 + +export const versionData = { + "/component/count-to": "1.3.8", + "/component/keyboard": "1.3.10", + "/component/root-portal": "$LOWEST_VERSION$", + "/component/signature": "1.6.0" +} diff --git a/docs/.vitepress/plugins/version-badge.ts b/docs/.vitepress/plugins/version-badge.ts new file mode 100644 index 00000000..945e9852 --- /dev/null +++ b/docs/.vitepress/plugins/version-badge.ts @@ -0,0 +1,87 @@ +import type { Plugin } from 'vite' +import { readFileSync, existsSync, writeFileSync } from 'fs' +import { resolve } from 'path' +import fs from 'fs' + +// 从 Markdown 文件中提取版本信息 +function extractVersionFromMarkdown(filePath: string): string | null { + if (!existsSync(filePath)) return null + + try { + const content = readFileSync(filePath, 'utf-8') + const frontmatterMatch = content.match(/^---\s*\n([\s\S]*?)\n---\s*\n/) + + if (frontmatterMatch) { + const frontmatter = frontmatterMatch[1] + const versionMatch = frontmatter.match(/version:\s*(['"]?)([^'"\n]+)\1/) + + if (versionMatch) { + return versionMatch[2].trim() + } + } + } catch (e) { + console.warn(`Failed to read file ${filePath}:`, e) + } + + return null +} + +// 扫描组件文档目录,提取版本信息 +function scanComponentVersions(): Record { + const versionData: Record = {} + const componentDir = resolve(__dirname, '../../component') + + if (!existsSync(componentDir)) { + console.warn('Component directory not found:', componentDir) + return versionData + } + + try { + const files = fs.readdirSync(componentDir).filter((file: string) => file.endsWith('.md')) + + files.forEach((filename: string) => { + const filePath = resolve(componentDir, filename) + const version = extractVersionFromMarkdown(filePath) + + if (version) { + const path = `/component/${filename.replace('.md', '')}` + versionData[path] = version + console.log(`✅ Found version info in ${filename}:`, version) + } + }) + } catch (e) { + console.warn('Failed to scan component directory:', e) + } + + return versionData +} + +// 生成版本数据文件 +function generateVersionData(): string { + const versionData = scanComponentVersions() + + return `// 自动生成的版本数据 +// 此文件由插件自动生成,请勿手动修改 +// 如需修改版本信息,请在对应的 Markdown 文件 frontmatter 中修改 + +export const versionData = ${JSON.stringify(versionData, null, 2)} +` +} + +export function VersionBadgePlugin(): Plugin { + return { + name: 'version-badge', + configResolved() { + // 在配置解析后生成版本数据 + try { + const versionDataContent = generateVersionData() + const outputPath = resolve(__dirname, '../config/version-data.ts') + + writeFileSync(outputPath, versionDataContent, 'utf-8') + console.log('✅ Version data generated successfully') + } catch (e) { + console.error('❌ Failed to generate version data:', e) + } + } + } +} \ No newline at end of file diff --git a/docs/.vitepress/theme/components/VPSidebarItem.vue b/docs/.vitepress/theme/components/VPSidebarItem.vue new file mode 100644 index 00000000..e06d376e --- /dev/null +++ b/docs/.vitepress/theme/components/VPSidebarItem.vue @@ -0,0 +1,311 @@ + + + + + diff --git a/docs/.vitepress/types/sidebar.d.ts b/docs/.vitepress/types/sidebar.d.ts new file mode 100644 index 00000000..0519ecba --- /dev/null +++ b/docs/.vitepress/types/sidebar.d.ts @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/docs/component/circle.md b/docs/component/circle.md index 1491d62f..4e1bf4b1 100644 --- a/docs/component/circle.md +++ b/docs/component/circle.md @@ -1,4 +1,4 @@ -# Circle 环形进度条 0.1.19 +# Circle 环形进度条 圆环形的进度条组件,支持进度渐变动画。 diff --git a/docs/component/count-down.md b/docs/component/count-down.md index 16f9bf11..316a5f35 100644 --- a/docs/component/count-down.md +++ b/docs/component/count-down.md @@ -1,4 +1,4 @@ -# CountDown 倒计时0.1.58 +# CountDown 倒计时 用于实时展示倒计时数值,支持毫秒精度。 diff --git a/docs/component/count-to.md b/docs/component/count-to.md index 9d737006..9678d00d 100644 --- a/docs/component/count-to.md +++ b/docs/component/count-to.md @@ -1,4 +1,7 @@ -# CountTo 数字滚动1.3.8 +--- +version: 1.3.8 +--- +# CountTo 数字滚动 数字滚动组件。 diff --git a/docs/component/icon.md b/docs/component/icon.md index 401952e7..37786f98 100644 --- a/docs/component/icon.md +++ b/docs/component/icon.md @@ -1,4 +1,4 @@ -# Icon 图标 0.1.27 更新 +# Icon 图标 基于字体的图标集。 diff --git a/docs/component/index-bar.md b/docs/component/index-bar.md index d23547cc..62ea1f8b 100644 --- a/docs/component/index-bar.md +++ b/docs/component/index-bar.md @@ -1,4 +1,4 @@ -# IndexBar 索引栏 1.2.21 +# IndexBar 索引栏 用于列表的索引分类显示和快速定位。 diff --git a/docs/component/keyboard.md b/docs/component/keyboard.md index e6961583..9d505062 100644 --- a/docs/component/keyboard.md +++ b/docs/component/keyboard.md @@ -1,4 +1,7 @@ -# Keyboard 虚拟键盘 1.3.10 +--- +version: 1.3.10 +--- +# Keyboard 虚拟键盘 虚拟数字键盘,用于输入数字、密码、身份证或车牌号等场景。 diff --git a/docs/component/overlay.md b/docs/component/overlay.md index 8a9d8794..a3b6d575 100644 --- a/docs/component/overlay.md +++ b/docs/component/overlay.md @@ -1,4 +1,4 @@ -# Overlay 遮罩层 0.1.30 +# Overlay 遮罩层 创建一个遮罩层,用于强调特定的页面元素,并阻止用户进行其他操作。 diff --git a/docs/component/password-input.md b/docs/component/password-input.md index dac315a7..7188e620 100644 --- a/docs/component/password-input.md +++ b/docs/component/password-input.md @@ -1,4 +1,4 @@ -# PasswordInput 密码输入框 0.2.0 +# PasswordInput 密码输入框 带网格的输入框组件,可以用于输入密码、短信验证码等场景,通常与[数字键盘](./number-keyboard.md)组件配合使用。 diff --git a/docs/component/root-portal.md b/docs/component/root-portal.md index 080b0edf..01884fcc 100644 --- a/docs/component/root-portal.md +++ b/docs/component/root-portal.md @@ -1,4 +1,7 @@ -# Root Portal 根节点传送$LOWEST_VERSION$ +--- +version: $LOWEST_VERSION$ +--- +# Root Portal 根节点传送 是否从页面中脱离出来,用于解决各种 fixed 失效问题,主要用于制作弹窗、弹出层等。 diff --git a/docs/component/segmented.md b/docs/component/segmented.md index b76f7f31..a9a41cca 100644 --- a/docs/component/segmented.md +++ b/docs/component/segmented.md @@ -1,4 +1,4 @@ -# Segmented 分段器 0.1.23 +# Segmented 分段器 分段器用于展示多个选项并允许用户选择其中单个选项。 diff --git a/docs/component/select-picker.md b/docs/component/select-picker.md index 48cbc493..a81c35e1 100644 --- a/docs/component/select-picker.md +++ b/docs/component/select-picker.md @@ -1,4 +1,4 @@ -# SelectPicker 单复选选择器 0.1.34 更新 +# SelectPicker 单复选选择器 用于从一组选项中进行单选或多选。 diff --git a/docs/component/sidebar.md b/docs/component/sidebar.md index 72f56996..10c1e53f 100644 --- a/docs/component/sidebar.md +++ b/docs/component/sidebar.md @@ -1,4 +1,4 @@ -# Sidebar 侧边导航 0.1.49 +# Sidebar 侧边导航 垂直展示的导航栏,用于在不同的内容区域之间进行切换。 diff --git a/docs/component/signature.md b/docs/component/signature.md index 63a5c46d..fe9fd1af 100644 --- a/docs/component/signature.md +++ b/docs/component/signature.md @@ -1,4 +1,7 @@ -# Signature 签名 1.6.0 +--- +version: 1.6.0 +--- +# Signature 签名 用于签名场景,基于 Canvas 实现的签名组件。提供了基础签名、历史记录、笔锋效果等功能。 diff --git a/docs/component/table.md b/docs/component/table.md index c97a80b8..dc835a9b 100644 --- a/docs/component/table.md +++ b/docs/component/table.md @@ -1,4 +1,4 @@ -# Table 表格 0.1.39 +# Table 表格 用于展示多条结构类似的数据, 可对数据进行排序等操作。 diff --git a/docs/component/textarea.md b/docs/component/textarea.md index d4d7c221..47d771f4 100644 --- a/docs/component/textarea.md +++ b/docs/component/textarea.md @@ -1,4 +1,4 @@ -# Textarea 文本域 0.2.0 +# Textarea 文本域 用于输入多行文本信息。 diff --git a/docs/component/watermark.md b/docs/component/watermark.md index 2f062f4c..7c99ef7f 100644 --- a/docs/component/watermark.md +++ b/docs/component/watermark.md @@ -1,5 +1,4 @@ - -# Watermark 水印 0.1.16 +# Watermark 水印 在页面或组件上添加指定的图片或文字,可用于版权保护、品牌宣传等场景。 diff --git a/docs/en-US/component/circle.md b/docs/en-US/component/circle.md index c3c740e5..90bfcac3 100644 --- a/docs/en-US/component/circle.md +++ b/docs/en-US/component/circle.md @@ -1,4 +1,4 @@ -# Circle Progress Bar 0.1.19 +# Circle Progress Bar A circular progress bar component that supports progress gradient animation. diff --git a/docs/en-US/component/count-down.md b/docs/en-US/component/count-down.md index 671bc636..9171cefa 100644 --- a/docs/en-US/component/count-down.md +++ b/docs/en-US/component/count-down.md @@ -1,4 +1,4 @@ -# CountDown0.1.58 +# CountDown Used to display countdown values in real-time, supporting millisecond precision. diff --git a/docs/en-US/component/count-to.md b/docs/en-US/component/count-to.md index a33b259b..006b01e8 100644 --- a/docs/en-US/component/count-to.md +++ b/docs/en-US/component/count-to.md @@ -1,4 +1,4 @@ -# CountTo Number Animation1.3.8 +# CountTo Number Animation Number animation component. diff --git a/docs/en-US/component/index-bar.md b/docs/en-US/component/index-bar.md index f059205a..6c211823 100644 --- a/docs/en-US/component/index-bar.md +++ b/docs/en-US/component/index-bar.md @@ -1,4 +1,4 @@ -# IndexBar 1.2.21 +# IndexBar Used for displaying index classification and quick positioning of lists. diff --git a/docs/en-US/component/keyboard.md b/docs/en-US/component/keyboard.md index 047ba1a0..4335cee5 100644 --- a/docs/en-US/component/keyboard.md +++ b/docs/en-US/component/keyboard.md @@ -1,4 +1,7 @@ -# Keyboard 1.3.10 +--- +version: 1.3.10 +--- +# Keyboard Virtual keyboard for inputting numbers, passwords, ID cards, or license plate numbers. diff --git a/docs/en-US/component/message-box.md b/docs/en-US/component/message-box.md index c6fdd0af..9a7e35c6 100644 --- a/docs/en-US/component/message-box.md +++ b/docs/en-US/component/message-box.md @@ -1,4 +1,4 @@ -# MessageBox 1.3.10 +# MessageBox A dialog box that pops up, commonly used for message prompts, message confirmation, etc., supports function calls. diff --git a/docs/en-US/component/overlay.md b/docs/en-US/component/overlay.md index 41e5dce6..136dfb3d 100644 --- a/docs/en-US/component/overlay.md +++ b/docs/en-US/component/overlay.md @@ -1,4 +1,4 @@ -# Overlay 0.1.30 +# Overlay Create a mask layer to emphasize specific page elements and prevent users from performing other operations. diff --git a/docs/en-US/component/password-input.md b/docs/en-US/component/password-input.md index e80b43e8..a15ffc4e 100644 --- a/docs/en-US/component/password-input.md +++ b/docs/en-US/component/password-input.md @@ -1,4 +1,4 @@ -# PasswordInput 0.2.0 +# PasswordInput A grid input box component that can be used for inputting passwords, SMS verification codes, and other scenarios. Usually used in conjunction with the [number keyboard](./number-keyboard.md) component. diff --git a/docs/en-US/component/root-portal.md b/docs/en-US/component/root-portal.md index b8ef6140..8a20be3d 100644 --- a/docs/en-US/component/root-portal.md +++ b/docs/en-US/component/root-portal.md @@ -1,4 +1,7 @@ -# Root Portal$LOWEST_VERSION$ +--- +version: $LOWEST_VERSION$ +--- +# Root Portal Whether to break out of the page, used to solve various fixed positioning issues, mainly used for making popups and overlays. diff --git a/docs/en-US/component/segmented.md b/docs/en-US/component/segmented.md index da0662d8..caceea65 100644 --- a/docs/en-US/component/segmented.md +++ b/docs/en-US/component/segmented.md @@ -1,4 +1,4 @@ -# Segmented 0.1.23 +# Segmented Segmented is used to display multiple options and allow users to select a single option. diff --git a/docs/en-US/component/select-picker.md b/docs/en-US/component/select-picker.md index 96c097cf..4658b2e2 100644 --- a/docs/en-US/component/select-picker.md +++ b/docs/en-US/component/select-picker.md @@ -1,4 +1,4 @@ -# SelectPicker 0.1.34 Update +# SelectPicker Used for single or multiple selection from a set of options. diff --git a/docs/en-US/component/sidebar.md b/docs/en-US/component/sidebar.md index c8afdc77..6fdeb0a2 100644 --- a/docs/en-US/component/sidebar.md +++ b/docs/en-US/component/sidebar.md @@ -1,4 +1,4 @@ -# Sidebar 0.1.49 +# Sidebar A vertical navigation bar used to switch between different content areas. diff --git a/docs/en-US/component/signature.md b/docs/en-US/component/signature.md index 7de5405c..a60da714 100644 --- a/docs/en-US/component/signature.md +++ b/docs/en-US/component/signature.md @@ -1,4 +1,7 @@ -# Signature 1.6.0 +--- +version: 1.6.0 +--- +# Signature A signature component based on Canvas for signature scenarios. Provides basic signature, history record, and pressure effect features. diff --git a/docs/en-US/component/table.md b/docs/en-US/component/table.md index 8f267383..61f294f6 100644 --- a/docs/en-US/component/table.md +++ b/docs/en-US/component/table.md @@ -1,4 +1,4 @@ -# Table 0.1.39 +# Table Used to display multiple pieces of data with similar structures, allowing operations such as sorting. diff --git a/docs/en-US/component/textarea.md b/docs/en-US/component/textarea.md index b97f76fa..3ee4e542 100644 --- a/docs/en-US/component/textarea.md +++ b/docs/en-US/component/textarea.md @@ -1,4 +1,4 @@ -'# Textarea 0.2.0 +# Textarea Used for inputting multi-line text information. diff --git a/docs/en-US/component/watermark.md b/docs/en-US/component/watermark.md index c04ce51b..e4929891 100644 --- a/docs/en-US/component/watermark.md +++ b/docs/en-US/component/watermark.md @@ -1,4 +1,4 @@ -# Watermark 0.1.16 +# Watermark Add specified images or text on pages or components, which can be used for copyright protection, brand promotion, and other scenarios. diff --git a/docs/en-US/guide/locale.md b/docs/en-US/guide/locale.md index 220ac0d0..c4f7731f 100644 --- a/docs/en-US/guide/locale.md +++ b/docs/en-US/guide/locale.md @@ -1,4 +1,4 @@ -# Internationalization0.2.20 +# Internationalization Wot UI uses Chinese by default and supports multi-language switching. If you want to use other languages, you can refer to the solutions below. diff --git a/docs/guide/locale.md b/docs/guide/locale.md index 0474a3f2..3f091cfb 100644 --- a/docs/guide/locale.md +++ b/docs/guide/locale.md @@ -1,4 +1,4 @@ -# 国际化0.2.20 +# 国际化 Wot UI 默认使用中文语言,同时支持多语言切换,如果你希望使用其他语言,你可以参考下面的方案。