@chatbi-v/cli 1.0.7 → 1.0.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (117) hide show
  1. package/dist/app/.env +8 -0
  2. package/dist/app/.env.hbs +8 -0
  3. package/dist/app/README.md.hbs +16 -0
  4. package/dist/app/chatbi.config.ts.hbs +60 -0
  5. package/{templates/default/apps/main → dist/app}/index.html.hbs +3 -4
  6. package/dist/app/package.json.hbs +34 -0
  7. package/dist/app/src/App.tsx.hbs +92 -0
  8. package/dist/app/src/components/GlobalErrorBoundary.tsx.hbs +69 -0
  9. package/dist/app/src/components/GlobalSettingsModal.tsx.hbs +35 -0
  10. package/dist/app/src/components/LayoutSkeletons.tsx.hbs +79 -0
  11. package/dist/app/src/components/index.ts.hbs +2 -0
  12. package/dist/app/src/custom-antd.less.hbs +7 -0
  13. package/dist/app/src/features/settings/ConfigRenderStrategy.tsx.hbs +119 -0
  14. package/dist/app/src/features/settings/ExtensionSettings.tsx.hbs +52 -0
  15. package/dist/app/src/features/settings/PluginList.tsx.hbs +115 -0
  16. package/dist/app/src/features/settings/PluginSettings.tsx.hbs +123 -0
  17. package/dist/app/src/features/settings/SchemaSettingsRenderer.tsx.hbs +56 -0
  18. package/dist/app/src/hooks/useAppRoutes.ts.hbs +39 -0
  19. package/dist/app/src/hooks/usePluginLoader.ts.hbs +22 -0
  20. package/dist/app/src/hooks/usePluginSettings.ts.hbs +29 -0
  21. package/dist/app/src/hooks/useThemeSync.ts.hbs +108 -0
  22. package/dist/app/src/index.css.hbs +45 -0
  23. package/dist/app/src/layouts/BackgroundEffects.tsx.hbs +10 -0
  24. package/dist/app/src/layouts/MainContent.tsx.hbs +58 -0
  25. package/dist/app/src/layouts/SidebarNav.tsx.hbs +182 -0
  26. package/dist/app/src/main.tsx.hbs +43 -0
  27. package/dist/app/src/providers/AppProviders.tsx.hbs +36 -0
  28. package/dist/app/src/services/api/index.ts.hbs +37 -0
  29. package/dist/app/src/services/api/modules/auth.ts.hbs +18 -0
  30. package/dist/app/src/services/config-service.ts.hbs +48 -0
  31. package/dist/app/src/stores/storage-adapter.ts.hbs +29 -0
  32. package/dist/app/src/stores/useSessionStore.ts.hbs +22 -0
  33. package/dist/app/src/stores/useUIStore.ts.hbs +64 -0
  34. package/dist/app/tailwind.config.cjs.hbs +14 -0
  35. package/dist/app/tsconfig.json.hbs +26 -0
  36. package/dist/app/vite.config.ts.hbs +89 -0
  37. package/dist/index.js +5662 -4194
  38. package/{templates/default → dist/monorepo}/package.json.hbs +5 -0
  39. package/dist/monorepo/pnpm-workspace.yaml.hbs +10 -0
  40. package/dist/{default → monorepo}/tsconfig.json.hbs +3 -1
  41. package/{templates/default/plugins/demo-plugin → dist/plugin}/package.json.hbs +9 -3
  42. package/dist/plugin/src/index.tsx.hbs +90 -0
  43. package/dist/plugin/tsconfig.json.hbs +14 -0
  44. package/package.json +18 -6
  45. package/templates/app/.env.hbs +8 -0
  46. package/templates/app/README.md.hbs +16 -0
  47. package/templates/app/chatbi.config.ts.hbs +60 -0
  48. package/{dist/default/apps/main → templates/app}/index.html.hbs +3 -4
  49. package/templates/app/package.json.hbs +34 -0
  50. package/templates/app/src/App.tsx.hbs +92 -0
  51. package/templates/app/src/components/GlobalErrorBoundary.tsx.hbs +69 -0
  52. package/templates/app/src/components/GlobalSettingsModal.tsx.hbs +35 -0
  53. package/templates/app/src/components/LayoutSkeletons.tsx.hbs +79 -0
  54. package/templates/app/src/components/index.ts.hbs +2 -0
  55. package/templates/app/src/custom-antd.less.hbs +7 -0
  56. package/templates/app/src/features/settings/ConfigRenderStrategy.tsx.hbs +119 -0
  57. package/templates/app/src/features/settings/ExtensionSettings.tsx.hbs +52 -0
  58. package/templates/app/src/features/settings/PluginList.tsx.hbs +115 -0
  59. package/templates/app/src/features/settings/PluginSettings.tsx.hbs +123 -0
  60. package/templates/app/src/features/settings/SchemaSettingsRenderer.tsx.hbs +56 -0
  61. package/templates/app/src/hooks/useAppRoutes.ts.hbs +39 -0
  62. package/templates/app/src/hooks/usePluginLoader.ts.hbs +22 -0
  63. package/templates/app/src/hooks/usePluginSettings.ts.hbs +29 -0
  64. package/templates/app/src/hooks/useThemeSync.ts.hbs +108 -0
  65. package/templates/app/src/index.css.hbs +45 -0
  66. package/templates/app/src/layouts/BackgroundEffects.tsx.hbs +10 -0
  67. package/templates/app/src/layouts/MainContent.tsx.hbs +58 -0
  68. package/templates/app/src/layouts/SidebarNav.tsx.hbs +182 -0
  69. package/templates/app/src/main.tsx.hbs +43 -0
  70. package/templates/app/src/providers/AppProviders.tsx.hbs +36 -0
  71. package/templates/app/src/services/api/index.ts.hbs +37 -0
  72. package/templates/app/src/services/api/modules/auth.ts.hbs +18 -0
  73. package/templates/app/src/services/config-service.ts.hbs +48 -0
  74. package/templates/app/src/stores/storage-adapter.ts.hbs +29 -0
  75. package/templates/app/src/stores/useSessionStore.ts.hbs +22 -0
  76. package/templates/app/src/stores/useUIStore.ts.hbs +64 -0
  77. package/templates/app/tailwind.config.cjs.hbs +14 -0
  78. package/templates/app/tsconfig.json.hbs +26 -0
  79. package/templates/app/vite.config.ts.hbs +89 -0
  80. package/templates/monorepo/.gitignore.hbs +3 -0
  81. package/{dist/default → templates/monorepo}/package.json.hbs +5 -0
  82. package/templates/monorepo/pnpm-workspace.yaml.hbs +10 -0
  83. package/templates/{default → monorepo}/tsconfig.json.hbs +3 -1
  84. package/{dist/default/plugins/demo-plugin → templates/plugin}/package.json.hbs +9 -3
  85. package/templates/plugin/src/index.tsx.hbs +90 -0
  86. package/templates/plugin/tsconfig.json.hbs +14 -0
  87. package/dist/default/apps/main/package.json.hbs +0 -20
  88. package/dist/default/apps/main/src/App.tsx.hbs +0 -162
  89. package/dist/default/apps/main/src/components/NavIcon.tsx.hbs +0 -41
  90. package/dist/default/apps/main/src/hooks/usePluginLoader.ts.hbs +0 -25
  91. package/dist/default/apps/main/src/index.css.hbs +0 -8
  92. package/dist/default/apps/main/src/main.tsx.hbs +0 -13
  93. package/dist/default/apps/main/src/pages/Guide.tsx.hbs +0 -133
  94. package/dist/default/apps/main/tailwind.config.cjs.hbs +0 -17
  95. package/dist/default/apps/main/tsconfig.json.hbs +0 -10
  96. package/dist/default/apps/main/vite.config.ts.hbs +0 -16
  97. package/dist/default/plugins/demo-plugin/src/index.tsx.hbs +0 -44
  98. package/dist/default/plugins/demo-plugin/tsconfig.json.hbs +0 -10
  99. package/dist/default/pnpm-workspace.yaml.hbs +0 -3
  100. package/templates/default/apps/main/package.json.hbs +0 -20
  101. package/templates/default/apps/main/src/App.tsx.hbs +0 -162
  102. package/templates/default/apps/main/src/components/NavIcon.tsx.hbs +0 -41
  103. package/templates/default/apps/main/src/hooks/usePluginLoader.ts.hbs +0 -25
  104. package/templates/default/apps/main/src/index.css.hbs +0 -8
  105. package/templates/default/apps/main/src/main.tsx.hbs +0 -13
  106. package/templates/default/apps/main/src/pages/Guide.tsx.hbs +0 -133
  107. package/templates/default/apps/main/tailwind.config.cjs.hbs +0 -17
  108. package/templates/default/apps/main/tsconfig.json.hbs +0 -10
  109. package/templates/default/apps/main/vite.config.ts.hbs +0 -16
  110. package/templates/default/plugins/demo-plugin/src/index.tsx.hbs +0 -44
  111. package/templates/default/plugins/demo-plugin/tsconfig.json.hbs +0 -10
  112. package/templates/default/pnpm-workspace.yaml.hbs +0 -3
  113. /package/dist/{default/apps/main → app}/postcss.config.cjs.hbs +0 -0
  114. /package/{templates/default → dist/monorepo}/.gitignore.hbs +0 -0
  115. /package/dist/{default → monorepo}/README.md.hbs +0 -0
  116. /package/templates/{default/apps/main → app}/postcss.config.cjs.hbs +0 -0
  117. /package/templates/{default → monorepo}/README.md.hbs +0 -0
@@ -0,0 +1,89 @@
1
+ import react from '@vitejs/plugin-react';
2
+ import fs from 'fs';
3
+ import path from 'path';
4
+ import { defineConfig, loadEnv } from 'vite';
5
+ import tsconfigPaths from 'vite-tsconfig-paths';
6
+
7
+ /**
8
+ * 分包策略函数
9
+ * 用于将依赖打包成独立的 chunk,利用浏览器缓存优化加载性能
10
+ */
11
+ function manualChunks(id: string) {
12
+ // 1. ChatBI 核心层
13
+ if (id.includes('@chatbi-v/core')) return 'chatbi-core';
14
+
15
+ // 2. 第三方依赖 (Node Modules)
16
+ if (id.includes('node_modules')) {
17
+ // React 核心 (将 React 相关包分组)
18
+ if (
19
+ /[\\/]node_modules[\\/](react|react-dom|react-router|react-router-dom|scheduler)[\\/]/.test(
20
+ id,
21
+ )
22
+ ) {
23
+ return 'react-vendor';
24
+ }
25
+
26
+ // UI 组件库 (Ant Design)
27
+ if (id.includes('antd') || id.includes('@ant-design')) {
28
+ return 'antd-vendor';
29
+ }
30
+
31
+ // 其他通用依赖
32
+ return 'vendor';
33
+ }
34
+ }
35
+
36
+ // https://vitejs.dev/config/
37
+ export default defineConfig(({ mode }) => {
38
+ const env = loadEnv(mode, process.cwd(), '');
39
+
40
+ return {
41
+ base: env.VITE_APP_BASE_URL || '/',
42
+
43
+ plugins: [
44
+ react(),
45
+ // 自动读取 tsconfig.json 中的 paths 配置,实现别名映射
46
+ tsconfigPaths(),
47
+ ],
48
+
49
+ resolve: {
50
+ alias: {
51
+ '@': path.resolve(__dirname, './src'),
52
+ },
53
+ // 强制统一核心依赖实例,避免多副本导致的 Context 失效
54
+ dedupe: [
55
+ 'react',
56
+ 'react-dom',
57
+ 'react-router',
58
+ 'react-router-dom',
59
+ 'antd',
60
+ '@ant-design/icons',
61
+ '@ant-design/x',
62
+ '@chatbi-v/core'
63
+ ],
64
+ },
65
+
66
+ // 开发服务器配置
67
+ server: {
68
+ host: true,
69
+ port: 3000,
70
+ // 增量配置:如果需要代理后端接口,可在此配置
71
+ // proxy: {
72
+ // '/api': {
73
+ // target: 'http://localhost:8080',
74
+ // changeOrigin: true,
75
+ // rewrite: (path) => path.replace(/^\/api/, '')
76
+ // }
77
+ // }
78
+ },
79
+
80
+ build: {
81
+ rollupOptions: {
82
+ output: {
83
+ manualChunks,
84
+ },
85
+ },
86
+ chunkSizeWarningLimit: 1000,
87
+ },
88
+ };
89
+ });
@@ -0,0 +1,3 @@
1
+ .chatbi/
2
+ node_modules/
3
+ dist/
@@ -2,6 +2,7 @@
2
2
  "name": "{{name}}",
3
3
  "private": true,
4
4
  "version": "1.0.0",
5
+ "description": "ChatBI-V {{#if isBusiness}}Business{{else}}System{{/if}} Plugin Project",
5
6
  "type": "module",
6
7
  "scripts": {
7
8
  "dev": "pnpm --filter @chatbi-v/main dev",
@@ -13,6 +14,8 @@
13
14
  "plugins/*"
14
15
  ],
15
16
  "dependencies": {
17
+ "react": "^18.3.1",
18
+ "react-dom": "^18.3.1",
16
19
  "antd": "^5.29.3",
17
20
  "axios": "^1.13.2",
18
21
  "clsx": "^2.1.1",
@@ -23,6 +26,8 @@
23
26
  "typescript": "^5.0.0",
24
27
  "@chatbi-v/cli": "link:./.chatbi/cli",
25
28
  "@ant-design/icons": "^5.6.1",
29
+ "@types/react": "^18.3.1",
30
+ "@types/react-dom": "^18.3.1",
26
31
  "vite": "^5.4.0",
27
32
  "@vitejs/plugin-react": "^4.3.1",
28
33
  "tailwindcss": "^3.4.0",
@@ -0,0 +1,10 @@
1
+ # ChatBI Monorepo Workspace Configuration
2
+ packages:
3
+ # 宿主应用目录
4
+ - 'apps/*'
5
+ # 插件目录
6
+ - 'plugins/*'
7
+
8
+ # 增量配置:如果添加了核心库或工具库,可在此处包含
9
+ # - 'packages/*'
10
+ # - 'libs/*'
@@ -1,4 +1,5 @@
1
1
  {
2
+ "extends": "./.chatbi/tsconfig.paths.json",
2
3
  "compilerOptions": {
3
4
  "target": "ESNext",
4
5
  "useDefineForClassFields": true,
@@ -17,7 +18,8 @@
17
18
  "jsx": "react-jsx",
18
19
  "baseUrl": ".",
19
20
  "paths": {
20
- "@chatbi-v/core": ["./.chatbi/core"]
21
+ "@chatbi-plugins/*": ["./plugins/*/src"],
22
+ "@chatbi-apps/*": ["./apps/*/src"]
21
23
  }
22
24
  },
23
25
  "include": ["apps/main/src", "plugins/*/src"]
@@ -1,8 +1,9 @@
1
1
  {
2
- "name": "@chatbi-v/plugin-demo-plugin",
2
+ "name": "{{name}}",
3
3
  "version": "1.0.0",
4
4
  "type": "module",
5
5
  "plugin": true,
6
+ "pluginType": "{{pluginType}}",
6
7
  "main": "src/index.tsx",
7
8
  "module": "src/index.tsx",
8
9
  "exports": {
@@ -11,7 +12,12 @@
11
12
  "scripts": {
12
13
  "build": "chatbi-cli build"
13
14
  },
14
- "dependencies": {
15
- "@chatbi-v/core": "link:../../.chatbi/core"
15
+ "devDependencies": {
16
+ },
17
+ "peerDependencies": {
18
+ "@chatbi-v/core": "*",
19
+ "react": ">=18.0.0",
20
+ "react-dom": ">=18.0.0",
21
+ "antd": ">=5.0.0"
16
22
  }
17
23
  }
@@ -0,0 +1,90 @@
1
+ import React from 'react'
2
+ import { Plugin, PluginContext, Slot } from '@chatbi-v/core'
3
+ import { MessageOutlined } from '@ant-design/icons'
4
+
5
+ /**
6
+ * 插件入口类
7
+ * 必须实现 Plugin 接口,并导出为 default
8
+ *
9
+ * 生命周期说明:
10
+ * - onLoad: 插件加载时调用,用于初始化状态、注册服务等
11
+ * - onUnload: 插件卸载时调用,用于清理资源
12
+ */
13
+ export class {{className}} implements Plugin {
14
+ // 插件唯一标识,必须与 metadata.id 保持一致
15
+ id = '{{pluginId}}'
16
+
17
+ // 插件元数据定义
18
+ metadata = {
19
+ id: '{{pluginId}}',
20
+ name: '{{pluginId}} Plugin',
21
+ version: '1.0.0',
22
+ type: '{{pluginType}}' as const, // business | system
23
+
24
+ /**
25
+ * 路由配置 (可选)
26
+ * 如果插件需要注册页面路由,在此处定义
27
+ */
28
+ routes: [
29
+ {
30
+ path: '/{{pluginId}}',
31
+ // 路由对应的组件
32
+ component: () => <div style=\{{ padding: '20px', background: '#f5f5f5', borderRadius: '8px' }}>
33
+ <h3>Hello from {{pluginId}} Plugin!</h3>
34
+ <p>This is a {{pluginType}} plugin generated by ChatBI CLI.</p>
35
+ </div>,
36
+ meta: {
37
+ title: '{{pluginId}}',
38
+ icon: 'MessageOutlined' // 对应 AntD Icon 名称
39
+ }
40
+ }
41
+ ],
42
+
43
+ /**
44
+ * 扩展插槽配置 (可选)
45
+ * 用于将组件注入到系统的各个位置 (如侧边栏、顶部栏等)
46
+ */
47
+ extensions: [
48
+ {
49
+ slot: Slot.Sidebar, // 注入到侧边栏
50
+ component: () => null, // 侧边栏通常不需要组件实体,只需要 meta 信息
51
+ order: 10, // 排序权重,越小越靠前
52
+ meta: {
53
+ title: '{{pluginId}}',
54
+ icon: <MessageOutlined />, // 直接传入 ReactNode
55
+ path: '/{{pluginId}}' // 点击跳转的路径
56
+ }
57
+ }
58
+ // 示例:注入到顶部栏
59
+ // {
60
+ // slot: Slot.TopBar,
61
+ // component: () => <MyTopBarComponent />,
62
+ // order: 5
63
+ // }
64
+ ]
65
+ }
66
+
67
+ /**
68
+ * 插件加载回调
69
+ * @param context 插件上下文,包含 logger, eventBus, serviceRegistry 等
70
+ */
71
+ onLoad(context: PluginContext) {
72
+ context.logger.info('{{className}} Loaded!')
73
+
74
+ // 示例:监听事件
75
+ // context.eventBus.on('some-event', () => { ... })
76
+
77
+ // 示例:注册服务
78
+ // context.serviceRegistry.register('myService', new MyService())
79
+ }
80
+
81
+ /**
82
+ * 插件卸载回调 (可选)
83
+ */
84
+ onUnload() {
85
+ // 清理资源
86
+ console.log('{{className}} Unloaded')
87
+ }
88
+ }
89
+
90
+ export default {{className}}
@@ -0,0 +1,14 @@
1
+ {
2
+ "extends": "{{tsconfigPath}}",
3
+ "compilerOptions": {
4
+ "baseUrl": ".",
5
+ "noEmit": false,
6
+ "declaration": true,
7
+ "emitDeclarationOnly": true,
8
+ "declarationDir": "./dist",
9
+ "paths": {
10
+ "@/*": ["./src/*"]
11
+ }
12
+ },
13
+ "include": ["src"]
14
+ }
@@ -1,20 +0,0 @@
1
- {
2
- "name": "@chatbi-v/main",
3
- "private": true,
4
- "type": "module",
5
- "scripts": {
6
- "dev": "vite",
7
- "build": "vite build"
8
- },
9
- "dependencies": {
10
- "react": "^18.3.1",
11
- "react-dom": "^18.3.1",
12
- "react-router-dom": "^6.22.3",
13
- "antd": "^5.20.0",
14
- "@ant-design/icons": "^5.2.6",
15
- "@chatbi-v/core": "link:../../.chatbi/core"
16
- },
17
- "devDependencies": {
18
- "@vitejs/plugin-react": "^4.3.1"
19
- }
20
- }
@@ -1,162 +0,0 @@
1
- import React, { useMemo, useState } from 'react'
2
- import { Routes, Route, Navigate, Link, useLocation, useNavigate } from 'react-router-dom'
3
- import { usePluginLoader } from './hooks/usePluginLoader'
4
- import { pluginManager, PluginSlot, Slot, SidebarIconSkeleton, type PluginExtension } from '@chatbi-v/core'
5
- import { QuestionCircleOutlined, MenuFoldOutlined, MenuUnfoldOutlined, ThunderboltOutlined } from '@ant-design/icons'
6
- import GuidePage from './pages/Guide'
7
- import { NavIcon } from './components/NavIcon'
8
-
9
- const App: React.FC = () => {
10
- const { pluginsLoaded } = usePluginLoader()
11
- const location = useLocation()
12
- const navigate = useNavigate()
13
- const [collapsed, setCollapsed] = useState(false)
14
-
15
- // 收集插件路由
16
- const routes = useMemo(() => {
17
- return pluginsLoaded ? pluginManager.getRoutes() : []
18
- }, [pluginsLoaded])
19
-
20
- // 当前激活的 Tab (路径去掉前导斜杠)
21
- const activeTab = useMemo(() => {
22
- return location.pathname.replace(/^\//, '')
23
- }, [location.pathname])
24
-
25
- // 默认路由重定向逻辑
26
- const defaultRoute = useMemo(() => {
27
- if (routes.length > 0) {
28
- return routes[0].path
29
- }
30
- return '/guide'
31
- }, [routes])
32
-
33
- if (!pluginsLoaded) {
34
- return (
35
- <div className="h-screen flex items-center justify-center bg-gray-50">
36
- <div className="text-center">
37
- <div className="animate-spin rounded-full h-12 w-12 border-b-2 border-indigo-500 mx-auto mb-4"></div>
38
- <p className="text-gray-500">正在加载插件与内核...</p>
39
- </div>
40
- </div>
41
- )
42
- }
43
-
44
- return (
45
- <div className="flex h-screen flex-col overflow-hidden bg-gray-50 font-sans">
46
- {/* Header */}
47
- <header className="flex h-16 items-center justify-between bg-slate-900 px-6 text-white shadow-md z-10">
48
- <div className="flex items-center gap-4">
49
- <div className="flex items-center gap-2 group cursor-pointer" onClick={() => navigate('/')}>
50
- <div className="w-8 h-8 rounded-lg bg-indigo-500 flex items-center justify-center shadow-lg shadow-indigo-500/20 group-hover:scale-105 transition-transform">
51
- <ThunderboltOutlined className="text-lg text-white" />
52
- </div>
53
- <h2 className="m-0 text-lg font-bold tracking-tight text-white uppercase">
54
- {{name}}
55
- </h2>
56
- </div>
57
- <nav className="ml-8 flex gap-4">
58
- <Link
59
- to="/guide"
60
- className={`flex items-center gap-1.5 px-3 py-1 rounded transition-colors ${
61
- location.pathname === '/guide' ? 'bg-indigo-500/20 text-indigo-300' : 'text-gray-400 hover:text-white'
62
- }`}
63
- >
64
- <QuestionCircleOutlined />
65
- <span>开发指南</span>
66
- </Link>
67
- </nav>
68
- </div>
69
- <div className="header-actions flex items-center gap-4">
70
- <PluginSlot slot={Slot.Header} />
71
- </div>
72
- </header>
73
-
74
- <div className="flex flex-1 overflow-hidden">
75
- {/* Sidebar */}
76
- <aside
77
- className={`flex flex-col border-r border-gray-200 bg-white shadow-sm transition-all duration-300 ease-in-out ${
78
- collapsed ? 'w-16' : 'w-64'
79
- }`}
80
- >
81
- <div className={`p-4 border-b border-gray-50 bg-gray-50/50 text-xs font-semibold text-gray-400 uppercase tracking-wider overflow-hidden whitespace-nowrap ${collapsed ? 'text-center px-0' : ''}`}>
82
- {collapsed ? '···' : '插件菜单'}
83
- </div>
84
- <div className="flex-1 overflow-y-auto no-scrollbar py-4 px-2">
85
- <PluginSlot
86
- slot={Slot.Sidebar}
87
- className="flex flex-col gap-2 w-full items-center"
88
- skeleton={
89
- <div className="flex flex-col gap-4 w-full items-center px-2">
90
- {[1, 2, 3].map(i => <SidebarIconSkeleton key={i} />)}
91
- </div>
92
- }
93
- renderItem={({ key, extension }: { key: string, extension: PluginExtension }) => (
94
- <NavIcon
95
- key={key}
96
- icon={extension.meta?.icon}
97
- label={extension.meta?.label}
98
- active={
99
- activeTab === (extension.meta?.path || extension.meta?.key)?.replace(/^\//, '') ||
100
- activeTab.startsWith(((extension.meta?.path || extension.meta?.key)?.replace(/^\//, '') || '') + '/')
101
- }
102
- onClick={() => navigate(extension.meta?.path || '/')}
103
- expanded={!collapsed}
104
- />
105
- )}
106
- />
107
- </div>
108
-
109
- {/* Sidebar Footer */}
110
- <div className="p-2 border-t border-gray-100">
111
- <NavIcon
112
- icon={collapsed ? <MenuUnfoldOutlined /> : <MenuFoldOutlined />}
113
- onClick={() => setCollapsed(!collapsed)}
114
- title={collapsed ? "展开侧边栏" : "折叠侧边栏"}
115
- label={collapsed ? "展开" : "折叠"}
116
- expanded={!collapsed}
117
- />
118
- </div>
119
- </aside>
120
-
121
- {/* Main Content */}
122
- <main className="relative flex-1 overflow-y-auto bg-gray-50 p-6 scroll-smooth">
123
- <Routes>
124
- <Route path="/guide" element={<GuidePage />} />
125
- {routes.map(route => (
126
- <Route
127
- key={route.path}
128
- path={route.path}
129
- element={<route.component />}
130
- />
131
- ))}
132
- <Route path="/" element={<Navigate to={defaultRoute} replace />} />
133
- <Route path="*" element={
134
- <div className="mt-24 text-center">
135
- <h3 className="text-2xl font-bold text-gray-800">404 Not Found</h3>
136
- <p className="mt-2 text-gray-500">请求的页面不存在或插件未加载。</p>
137
- <Link to="/guide" className="mt-6 inline-block text-indigo-500 hover:text-indigo-600">
138
- 返回开发指南
139
- </Link>
140
- </div>
141
- } />
142
- </Routes>
143
- <div className="mt-8">
144
- <PluginSlot slot={Slot.Custom} />
145
- </div>
146
- </main>
147
- </div>
148
-
149
- {/* Footer */}
150
- <footer className="h-10 flex items-center px-4 bg-white border-t border-gray-200 text-xs text-gray-400 shrink-0">
151
- <div className="flex-1 flex items-center">
152
- <PluginSlot slot={Slot.StatusBar} />
153
- </div>
154
- <div>
155
- SDK Version: 1.0.0
156
- </div>
157
- </footer>
158
- </div>
159
- )
160
- }
161
-
162
- export default App
@@ -1,41 +0,0 @@
1
- import React from 'react';
2
-
3
- export const NavIcon = React.memo(({
4
- icon,
5
- active,
6
- onClick,
7
- title,
8
- label,
9
- expanded,
10
- }: {
11
- icon: React.ReactNode;
12
- active?: boolean;
13
- onClick?: () => void;
14
- title?: string;
15
- label?: string;
16
- expanded?: boolean;
17
- }) => (
18
- <div
19
- onClick={onClick}
20
- title={title}
21
- className={`flex items-center cursor-pointer transition-all duration-300 relative group
22
- ${expanded ? 'w-full' : 'w-12'} px-3 h-11 rounded-xl
23
- ${
24
- active
25
- ? 'bg-indigo-500/15 text-indigo-600 font-semibold shadow-sm ring-1 ring-indigo-500/20'
26
- : 'text-slate-500 hover:bg-slate-100 hover:text-slate-900 hover:scale-105 active:scale-95'
27
- }`}
28
- >
29
- <div className="w-6 h-6 flex items-center justify-center shrink-0">
30
- <div className={`text-xl transition-transform duration-300 ${!expanded && active ? 'scale-110' : ''}`}>{icon}</div>
31
- </div>
32
-
33
- <div className={`overflow-hidden whitespace-nowrap transition-all duration-300 ease-in-out ${
34
- expanded ? 'w-auto opacity-100 ml-3' : 'w-0 opacity-0 ml-0'
35
- }`}>
36
- <span className="text-sm block">
37
- {label}
38
- </span>
39
- </div>
40
- </div>
41
- ));
@@ -1,25 +0,0 @@
1
- import { usePluginLoader as useCoreLoader } from '@chatbi-v/core'
2
- import { useMemo } from 'react'
3
-
4
- // 离线插件注册表
5
- const offlineRegistry = {
6
- "theme-manager": () => import("@chatbi-v/plugin-theme-manager"),
7
- "system-user": () => import("@chatbi-v/plugin-system-user"),
8
- "system-monitor": () => import("@chatbi-v/plugin-system-monitor"),
9
- "demo-plugin": () => import("@chatbi-v/plugin-demo-plugin")
10
- }
11
-
12
- export const usePluginLoader = () => {
13
- const options = useMemo(() => ({
14
- pluginConfigs: {
15
- 'theme-manager': { enabled: true },
16
- 'system-user': { enabled: true },
17
- 'system-monitor': { enabled: true },
18
- 'demo-plugin': { enabled: true }
19
- },
20
- registry: offlineRegistry,
21
- sharedContext: { api: {} }
22
- }), [])
23
-
24
- return useCoreLoader(options)
25
- }
@@ -1,8 +0,0 @@
1
- @tailwind base;
2
- @tailwind components;
3
- @tailwind utilities;
4
-
5
- :root {
6
- --layout-sidebar-width: 260px;
7
- --layout-gap: 16px;
8
- }
@@ -1,13 +0,0 @@
1
- import React from 'react'
2
- import ReactDOM from 'react-dom/client'
3
- import { HashRouter } from 'react-router-dom'
4
- import App from './App'
5
- import './index.css'
6
-
7
- ReactDOM.createRoot(document.getElementById('root')!).render(
8
- <React.StrictMode>
9
- <HashRouter>
10
- <App />
11
- </HashRouter>
12
- </React.StrictMode>,
13
- )