diff --git a/.vitepress/config.mts b/.vitepress/config.mts index 796f579..50820b6 100644 --- a/.vitepress/config.mts +++ b/.vitepress/config.mts @@ -1,4 +1,5 @@ import vueJsx from '@vitejs/plugin-vue-jsx' +import react from '@vitejs/plugin-react' import { defineConfig } from 'vitepress' import { vitepressDemoPlugin } from 'vitepress-demo-plugin' import { tabsMarkdownPlugin } from 'vitepress-plugin-tabs' @@ -168,6 +169,8 @@ const robotSidebarItems = [ } ] + +const reactDemoRE = /\/demos\/(?:[a-z-]+\/)?react\/.*\.[jt]sx$/ // https://vitepress.dev/reference/site-config export default defineConfig({ title: 'OpenTiny NEXT', @@ -213,7 +216,9 @@ export default defineConfig({ // 允许以大写扩展名结尾的图片/静态资源被当作资产处理,避免被 import-analyze 当作 JS 解析 assetsInclude: ['**/*.{png,PNG,jpg,JPG,jpeg,JPEG,gif,GIF,webp,WEBP,svg,SVG}'], plugins: [ - vueJsx(), + // vueJsx忽略对react demo的解析 + vueJsx({ exclude: [reactDemoRE] }), + react({ include: /\.(jsx|tsx)$/ }), resolveSubmoduleRelativePathsPlugin([ { source: path.resolve(rootDir, 'demos'), @@ -222,12 +227,17 @@ export default defineConfig({ ]) ], server: { open: true }, + esbuild: { + include: [/\.ts$/, reactDemoRE] + }, // 子模块里有大量独立站点的 index.html。依赖扫描如果把它们都当成入口, // 会扫到无效的 import.meta.glob,导致文档站起不来。 optimizeDeps: { - entries: ['.vitepress/theme/index.ts'] + entries: ['.vitepress/theme/index.ts'], + include: ['react', 'react-dom', 'react/jsx-runtime', 'antd'] }, resolve: { + dedupe: ['react', 'react-dom'], alias: { '@opentiny/tiny-robot-style': '../../tiny-robot/packages/components/dist/style.css', '@demos': '../' // 根据你的项目结构调整路径 @@ -335,7 +345,7 @@ export default defineConfig({ activeMatch: '/guide/' }, { - text: '组件文档', + text: '参考文档', link: '/genui-sdk/components/renderer', activeMatch: '/components/' }, @@ -451,6 +461,14 @@ export default defineConfig({ { text: '使用 Renderer 组件', link: 'guide/angular/start-with-renderer' } ] }, + { + text: 'GenUI SDK React 指引', + base: '/genui-sdk/', + items: [ + { text: '安装与配置', link: 'guide/react/install' }, + { text: '使用 Renderer 组件', link: 'guide/react/start-with-renderer' } + ] + }, { text: 'GenUI SDK Server 指引', base: '/genui-sdk', @@ -459,21 +477,33 @@ export default defineConfig({ ], '/genui-sdk/components/': [ { - text: 'Vue 组件文档', + text: 'Vue 文档', base: '/genui-sdk/components/', items: [ { text: 'GenuiRenderer', link: 'renderer' }, { text: 'GenuiChat', link: 'chat' }, - { text: 'GenuiConfigProvider', link: 'config-provider' } + { text: 'GenuiConfigProvider', link: 'config-provider' }, + { text: 'generateCode', link: 'code-generator' } + ] + }, + { + text: 'Angular 文档', + base: '/genui-sdk/components/', + items: [ + { text: 'GenuiRenderer', link: 'angular/renderer' }, + { text: 'GenuiConfigProvider', link: 'angular/config-provider' } ] }, { - text: 'Angular 组件文档', + text: 'React 文档', base: '/genui-sdk/components/', - items: [{ text: 'GenuiRenderer', link: 'angular/renderer' }] + items: [ + { text: 'GenuiRenderer', link: 'react/renderer' }, + { text: 'GenuiConfigProvider', link: 'react/config-provider' } + ] }, { - text: 'Server 库文档', + text: 'Server 文档', base: '/genui-sdk/components/', items: [ { text: 'API 参考', link: 'server/api' }, @@ -481,23 +511,29 @@ export default defineConfig({ ] }, { - text: 'Core 库文档', + text: 'Core 文档', base: '/genui-sdk/components/', items: [{ text: 'API 文档', link: 'core/api' }] }, + { + text: 'Skill Generator 文档', + base: '/genui-sdk/components/', + items: [{ text: 'API 文档', link: 'skill-generator/api' }] + }, { text: '物料包文档', base: '/genui-sdk/components/', items: [ { text: 'Vue OpenTiny Vue', link: 'materials/vue-opentiny-vue' }, { text: 'Vue Element Plus', link: 'materials/vue-element-plus' }, - { text: 'Angular OpenTiny NG', link: 'materials/angular-opentiny-ng' } + { text: 'Angular OpenTiny NG', link: 'materials/angular-opentiny-ng' }, + { text: 'React Ant Design', link: 'materials/react-antd' } ] } ], '/genui-sdk/examples/': [ { - text: 'Vue组件 特性示例', + text: 'Vue组件特性示例', collapsed: false, items: [ { @@ -539,6 +575,12 @@ export default defineConfig({ { text: '自定义主题', link: 'custom-theme' }, { text: '国际化配置', link: 'i18n' } ] + }, + { + text: '物料库', + collapsed: false, + base: '/genui-sdk/examples/', + items: [{ text: '自定义物料库', link: 'custom-materials' }] } ] }, @@ -559,6 +601,20 @@ export default defineConfig({ ] } ] + }, + { + text: 'React 组件特性示例', + collapsed: false, + items: [ + { + text: 'Renderer 组件', + base: '/genui-sdk', + items: [ + { text: '自定义 Actions', link: '/examples/react/renderer/custom-actions' }, + { text: '传递合并 State', link: '/examples/react/renderer/state' } + ] + } + ] } ], '/tiny-vue/guide/': [ diff --git a/genui/genui-sdk b/genui/genui-sdk index b71ab08..e72ca35 160000 --- a/genui/genui-sdk +++ b/genui/genui-sdk @@ -1 +1 @@ -Subproject commit b71ab08f324b69449318b4cb4ff55a8996035f72 +Subproject commit e72ca35a9d5d12635b9cf4206da5ea80af2ff64a diff --git a/genui/package.json b/genui/package.json index a704d24..fc50cb6 100644 --- a/genui/package.json +++ b/genui/package.json @@ -12,8 +12,10 @@ "license": "MIT", "dependencies": { "@opentiny/genui-sdk-angular": "workspace:*", - "@opentiny/genui-sdk-materials-vue-opentiny-vue": "1.3.0", - "@opentiny/genui-sdk-vue": "1.3.0" + "@opentiny/genui-sdk-materials-react-antd": "1.4.0", + "@opentiny/genui-sdk-materials-vue-opentiny-vue": "1.4.0", + "@opentiny/genui-sdk-react": "1.4.0", + "@opentiny/genui-sdk-vue": "1.4.0" }, "devDependencies": { "vitepress": "^1.6.3", diff --git a/package.json b/package.json index 0aa47f5..a19c0f7 100644 --- a/package.json +++ b/package.json @@ -20,7 +20,11 @@ "@opentiny/fluent-editor": "^4.1.0", "@opentiny/tiny-robot": "workspace:^", "@opentiny/tiny-robot-playground": "workspace:^", + "@types/react": "^18.3.29", + "@types/react-dom": "^18.3.7", + "@vitejs/plugin-react": "^4.7.0", "@vitejs/plugin-vue-jsx": "^4.1.2", + "antd": "^5.29.3", "cross-env": "^7.0.3", "emoji-mart": "^5.6.0", "gh-pages": "^2.1.1", @@ -36,6 +40,8 @@ "quill-markdown-shortcuts": "^0.0.10", "quill-table-up": "^3.3.0", "quill-toolbar-tip": "^0.0.13", + "react": "^18.3.1", + "react-dom": "^18.3.1", "simple-mind-map": "0.14.0-fix.1", "simple-mind-map-plugin-themes": "^1.0.1", "vitepress": "^1.6.3",