@chatbi-v/cli 1.0.8 → 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 (104) 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/dist/{default/apps/main → 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 +5343 -4330
  38. package/dist/monorepo/.gitignore.hbs +3 -0
  39. package/dist/{default → monorepo}/package.json.hbs +4 -0
  40. package/dist/monorepo/pnpm-workspace.yaml.hbs +10 -0
  41. package/dist/{default → monorepo}/tsconfig.json.hbs +3 -1
  42. package/dist/{default/plugins/demo-plugin → plugin}/package.json.hbs +7 -2
  43. package/dist/plugin/src/index.tsx.hbs +90 -0
  44. package/dist/plugin/tsconfig.json.hbs +14 -0
  45. package/package.json +9 -4
  46. package/templates/app/.env.hbs +8 -0
  47. package/templates/app/README.md.hbs +16 -0
  48. package/templates/app/chatbi.config.ts.hbs +60 -0
  49. package/templates/app/index.html.hbs +12 -0
  50. package/templates/app/package.json.hbs +34 -0
  51. package/templates/app/postcss.config.cjs.hbs +6 -0
  52. package/templates/app/src/App.tsx.hbs +92 -0
  53. package/templates/app/src/components/GlobalErrorBoundary.tsx.hbs +69 -0
  54. package/templates/app/src/components/GlobalSettingsModal.tsx.hbs +35 -0
  55. package/templates/app/src/components/LayoutSkeletons.tsx.hbs +79 -0
  56. package/templates/app/src/components/index.ts.hbs +2 -0
  57. package/templates/app/src/custom-antd.less.hbs +7 -0
  58. package/templates/app/src/features/settings/ConfigRenderStrategy.tsx.hbs +119 -0
  59. package/templates/app/src/features/settings/ExtensionSettings.tsx.hbs +52 -0
  60. package/templates/app/src/features/settings/PluginList.tsx.hbs +115 -0
  61. package/templates/app/src/features/settings/PluginSettings.tsx.hbs +123 -0
  62. package/templates/app/src/features/settings/SchemaSettingsRenderer.tsx.hbs +56 -0
  63. package/templates/app/src/hooks/useAppRoutes.ts.hbs +39 -0
  64. package/templates/app/src/hooks/usePluginLoader.ts.hbs +22 -0
  65. package/templates/app/src/hooks/usePluginSettings.ts.hbs +29 -0
  66. package/templates/app/src/hooks/useThemeSync.ts.hbs +108 -0
  67. package/templates/app/src/index.css.hbs +45 -0
  68. package/templates/app/src/layouts/BackgroundEffects.tsx.hbs +10 -0
  69. package/templates/app/src/layouts/MainContent.tsx.hbs +58 -0
  70. package/templates/app/src/layouts/SidebarNav.tsx.hbs +182 -0
  71. package/templates/app/src/main.tsx.hbs +43 -0
  72. package/templates/app/src/providers/AppProviders.tsx.hbs +36 -0
  73. package/templates/app/src/services/api/index.ts.hbs +37 -0
  74. package/templates/app/src/services/api/modules/auth.ts.hbs +18 -0
  75. package/templates/app/src/services/config-service.ts.hbs +48 -0
  76. package/templates/app/src/stores/storage-adapter.ts.hbs +29 -0
  77. package/templates/app/src/stores/useSessionStore.ts.hbs +22 -0
  78. package/templates/app/src/stores/useUIStore.ts.hbs +64 -0
  79. package/templates/app/tailwind.config.cjs.hbs +14 -0
  80. package/templates/app/tsconfig.json.hbs +26 -0
  81. package/templates/app/vite.config.ts.hbs +89 -0
  82. package/templates/monorepo/.gitignore.hbs +3 -0
  83. package/templates/monorepo/README.md.hbs +30 -0
  84. package/templates/monorepo/package.json.hbs +38 -0
  85. package/templates/monorepo/pnpm-workspace.yaml.hbs +10 -0
  86. package/templates/monorepo/tsconfig.json.hbs +26 -0
  87. package/templates/plugin/package.json.hbs +23 -0
  88. package/templates/plugin/src/index.tsx.hbs +90 -0
  89. package/templates/plugin/tsconfig.json.hbs +14 -0
  90. package/dist/default/apps/main/package.json.hbs +0 -20
  91. package/dist/default/apps/main/src/App.tsx.hbs +0 -178
  92. package/dist/default/apps/main/src/components/NavIcon.tsx.hbs +0 -41
  93. package/dist/default/apps/main/src/hooks/usePluginLoader.ts.hbs +0 -25
  94. package/dist/default/apps/main/src/index.css.hbs +0 -8
  95. package/dist/default/apps/main/src/main.tsx.hbs +0 -13
  96. package/dist/default/apps/main/src/pages/Guide.tsx.hbs +0 -133
  97. package/dist/default/apps/main/tailwind.config.cjs.hbs +0 -17
  98. package/dist/default/apps/main/tsconfig.json.hbs +0 -10
  99. package/dist/default/apps/main/vite.config.ts.hbs +0 -16
  100. package/dist/default/plugins/demo-plugin/src/index.tsx.hbs +0 -44
  101. package/dist/default/plugins/demo-plugin/tsconfig.json.hbs +0 -10
  102. package/dist/default/pnpm-workspace.yaml.hbs +0 -3
  103. /package/dist/{default/apps/main → app}/postcss.config.cjs.hbs +0 -0
  104. /package/dist/{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/
@@ -0,0 +1,30 @@
1
+ # {{name}}
2
+
3
+ 基于 ChatBI-V SDK 初始化的业务插件项目。
4
+
5
+ ## 项目结构
6
+
7
+ - `apps/main`: 宿主应用,用于验证插件功能。
8
+ - `plugins/`: 业务插件源码目录。
9
+ - `.chatbi/`: 离线 SDK 资源(核心包、标准插件、CLI 工具)。
10
+
11
+ ## 快速开始
12
+
13
+ 1. 安装依赖:
14
+ ```bash
15
+ pnpm install
16
+ ```
17
+
18
+ 2. 启动开发服务器:
19
+ ```bash
20
+ pnpm dev
21
+ ```
22
+
23
+ 3. 创建新插件:
24
+ ```bash
25
+ pnpm create:plugin <plugin-name>
26
+ ```
27
+
28
+ ## 插件开发
29
+
30
+ 参考 `plugins/demo-plugin` 示例。
@@ -0,0 +1,38 @@
1
+ {
2
+ "name": "{{name}}",
3
+ "private": true,
4
+ "version": "1.0.0",
5
+ "description": "ChatBI-V {{#if isBusiness}}Business{{else}}System{{/if}} Plugin Project",
6
+ "type": "module",
7
+ "scripts": {
8
+ "dev": "pnpm --filter @chatbi-v/main dev",
9
+ "build": "pnpm -r build",
10
+ "create:plugin": "node scripts/create-plugin.js"
11
+ },
12
+ "workspaces": [
13
+ "apps/*",
14
+ "plugins/*"
15
+ ],
16
+ "dependencies": {
17
+ "react": "^18.3.1",
18
+ "react-dom": "^18.3.1",
19
+ "antd": "^5.29.3",
20
+ "axios": "^1.13.2",
21
+ "clsx": "^2.1.1",
22
+ "echarts-for-react": "^3.0.5",
23
+ "reactflow": "^11.11.4"
24
+ },
25
+ "devDependencies": {
26
+ "typescript": "^5.0.0",
27
+ "@chatbi-v/cli": "link:./.chatbi/cli",
28
+ "@ant-design/icons": "^5.6.1",
29
+ "@types/react": "^18.3.1",
30
+ "@types/react-dom": "^18.3.1",
31
+ "vite": "^5.4.0",
32
+ "@vitejs/plugin-react": "^4.3.1",
33
+ "tailwindcss": "^3.4.0",
34
+ "postcss": "^8.4.0",
35
+ "autoprefixer": "^10.4.0",
36
+ "pnpm": ">=9.0.0"
37
+ }
38
+ }
@@ -0,0 +1,10 @@
1
+ # ChatBI Monorepo Workspace Configuration
2
+ packages:
3
+ # 宿主应用目录
4
+ - 'apps/*'
5
+ # 插件目录
6
+ - 'plugins/*'
7
+
8
+ # 增量配置:如果添加了核心库或工具库,可在此处包含
9
+ # - 'packages/*'
10
+ # - 'libs/*'
@@ -0,0 +1,26 @@
1
+ {
2
+ "extends": "./.chatbi/tsconfig.paths.json",
3
+ "compilerOptions": {
4
+ "target": "ESNext",
5
+ "useDefineForClassFields": true,
6
+ "lib": ["DOM", "DOM.Iterable", "ESNext"],
7
+ "allowJs": false,
8
+ "skipLibCheck": true,
9
+ "esModuleInterop": false,
10
+ "allowSyntheticDefaultImports": true,
11
+ "strict": true,
12
+ "forceConsistentCasingInFileNames": true,
13
+ "module": "ESNext",
14
+ "moduleResolution": "Node",
15
+ "resolveJsonModule": true,
16
+ "isolatedModules": true,
17
+ "noEmit": true,
18
+ "jsx": "react-jsx",
19
+ "baseUrl": ".",
20
+ "paths": {
21
+ "@chatbi-plugins/*": ["./plugins/*/src"],
22
+ "@chatbi-apps/*": ["./apps/*/src"]
23
+ }
24
+ },
25
+ "include": ["apps/main/src", "plugins/*/src"]
26
+ }
@@ -0,0 +1,23 @@
1
+ {
2
+ "name": "{{name}}",
3
+ "version": "1.0.0",
4
+ "type": "module",
5
+ "plugin": true,
6
+ "pluginType": "{{pluginType}}",
7
+ "main": "src/index.tsx",
8
+ "module": "src/index.tsx",
9
+ "exports": {
10
+ ".": "./src/index.tsx"
11
+ },
12
+ "scripts": {
13
+ "build": "chatbi-cli build"
14
+ },
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"
22
+ }
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,178 +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 font-sans ${
46
- {{#if isNebula}}'bg-purple-50'{{else if isGlass}}'bg-slate-100'{{else}}'bg-gray-50'{{/if}}
47
- }`}>
48
- {/* Header */}
49
- <header className={`flex h-16 items-center justify-between px-6 text-white shadow-md z-10 ${
50
- {{#if isNebula}}'bg-gradient-to-r from-indigo-900 to-purple-900'{{else if isGlass}}'bg-white/70 backdrop-blur-md text-slate-900 border-b border-white/20'{{else}}'bg-slate-900'{{/if}}
51
- }`}>
52
- <div className="flex items-center gap-4">
53
- <div className="flex items-center gap-2 group cursor-pointer" onClick={() => navigate('/')}>
54
- <div className={`w-8 h-8 rounded-lg flex items-center justify-center shadow-lg transition-transform group-hover:scale-105 ${
55
- {{#if isNebula}}'bg-purple-500 shadow-purple-500/20'{{else if isGlass}}'bg-blue-500 shadow-blue-500/20'{{else}}'bg-indigo-500 shadow-indigo-500/20'{{/if}}
56
- }`}>
57
- <ThunderboltOutlined className="text-lg text-white" />
58
- </div>
59
- <h2 className={`m-0 text-lg font-bold tracking-tight uppercase ${
60
- {{#if isGlass}}'text-slate-800'{{else}}'text-white'{{/if}}
61
- }`}>
62
- {{name}}
63
- </h2>
64
- </div>
65
- <nav className="ml-8 flex gap-4">
66
- <Link
67
- to="/guide"
68
- className={`flex items-center gap-1.5 px-3 py-1 rounded transition-colors ${
69
- location.pathname === '/guide'
70
- ? ({{#if isGlass}}'bg-blue-500/10 text-blue-600'{{else}}'bg-indigo-500/20 text-indigo-300'{{/if}})
71
- : ({{#if isGlass}}'text-slate-500 hover:text-slate-800'{{else}}'text-gray-400 hover:text-white'{{/if}})
72
- }`}
73
- >
74
- <QuestionCircleOutlined />
75
- <span>开发指南</span>
76
- </Link>
77
- </nav>
78
- </div>
79
- <div className="header-actions flex items-center gap-4">
80
- <PluginSlot slot={Slot.Header} />
81
- </div>
82
- </header>
83
-
84
- <div className="flex flex-1 overflow-hidden">
85
- {/* Sidebar */}
86
- <aside
87
- className={`flex flex-col border-r transition-all duration-300 ease-in-out ${
88
- collapsed ? 'w-16' : 'w-64'
89
- } ${
90
- {{#if isGlass}}'bg-white/40 backdrop-blur-lg border-white/20 shadow-xl shadow-slate-200/50'{{else if isNebula}}'bg-white border-purple-100 shadow-sm'{{else}}'bg-white border-gray-200 shadow-sm'{{/if}}
91
- }`}
92
- >
93
- <div className={`p-4 border-b text-xs font-semibold uppercase tracking-wider overflow-hidden whitespace-nowrap ${collapsed ? 'text-center px-0' : ''} ${
94
- {{#if isNebula}}'bg-purple-50/50 text-purple-400 border-purple-50'{{else if isGlass}}'bg-blue-50/30 text-blue-500 border-white/20'{{else}}'bg-gray-50/50 text-gray-400 border-gray-50'{{/if}}
95
- }`}>
96
- {collapsed ? '···' : '插件菜单'}
97
- </div>
98
- <div className="flex-1 overflow-y-auto no-scrollbar py-4 px-2">
99
- <PluginSlot
100
- slot={Slot.Sidebar}
101
- className="flex flex-col gap-2 w-full items-center"
102
- skeleton={
103
- <div className="flex flex-col gap-4 w-full items-center px-2">
104
- {[1, 2, 3].map(i => <SidebarIconSkeleton key={i} />)}
105
- </div>
106
- }
107
- renderItem={({ key, extension }: { key: string, extension: PluginExtension }) => (
108
- <NavIcon
109
- key={key}
110
- icon={extension.meta?.icon}
111
- label={extension.meta?.label}
112
- active={
113
- activeTab === (extension.meta?.path || extension.meta?.key)?.replace(/^\//, '') ||
114
- activeTab.startsWith(((extension.meta?.path || extension.meta?.key)?.replace(/^\//, '') || '') + '/')
115
- }
116
- onClick={() => navigate(extension.meta?.path || '/')}
117
- expanded={!collapsed}
118
- />
119
- )}
120
- />
121
- </div>
122
-
123
- {/* Sidebar Footer */}
124
- <div className="p-2 border-t border-gray-100">
125
- <NavIcon
126
- icon={collapsed ? <MenuUnfoldOutlined /> : <MenuFoldOutlined />}
127
- onClick={() => setCollapsed(!collapsed)}
128
- title={collapsed ? "展开侧边栏" : "折叠侧边栏"}
129
- label={collapsed ? "展开" : "折叠"}
130
- expanded={!collapsed}
131
- />
132
- </div>
133
- </aside>
134
-
135
- {/* Main Content */}
136
- <main className="flex-1 relative overflow-hidden flex flex-col">
137
- <div className={`absolute top-0 left-0 right-0 h-1 z-20 ${
138
- {{#if isNebula}}'bg-purple-500/20'{{else if isGlass}}'bg-blue-500/20'{{else}}'bg-indigo-500/10'{{/if}}
139
- }`} />
140
-
141
- <div className="flex-1 overflow-y-auto p-6 scroll-smooth bg-transparent">
142
- <div className={`mx-auto max-w-7xl h-full ${
143
- {{#if isGlass}}'bg-white/60 backdrop-blur-md rounded-2xl border border-white/40 shadow-xl p-8'{{else}}''{{/if}}
144
- }`}>
145
- <Routes>
146
- <Route path="/guide" element={<GuidePage />} />
147
- {routes.map(route => (
148
- <Route key={route.path} path={route.path} element={<route.component />} />
149
- ))}
150
- <Route path="/" element={<Navigate to={defaultRoute} replace />} />
151
- </Routes>
152
- </div>
153
- </div>
154
-
155
- {/* Footer Slot */}
156
- <div className={`mt-auto px-6 py-3 border-t text-xs text-gray-400 flex justify-between items-center ${
157
- {{#if isGlass}}'bg-white/30 border-white/20'{{else if isNebula}}'bg-purple-50/30 border-purple-50'{{else}}'bg-white border-gray-100'{{/if}}
158
- }`}>
159
- <div>ChatBI-V Plugin Container v1.0.0</div>
160
- <PluginSlot slot={Slot.Footer} />
161
- </div>
162
- </main>
163
- </div>
164
-
165
- {/* Footer */}
166
- <footer className="h-10 flex items-center px-4 bg-white border-t border-gray-200 text-xs text-gray-400 shrink-0">
167
- <div className="flex-1 flex items-center">
168
- <PluginSlot slot={Slot.StatusBar} />
169
- </div>
170
- <div>
171
- SDK Version: 1.0.0
172
- </div>
173
- </footer>
174
- </div>
175
- )
176
- }
177
-
178
- 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
- )