diff --git a/docs/.vitepress/components/BDashboard/index.md b/docs/.vitepress/components/BDashboard/index.md new file mode 100644 index 0000000..1c8cfbd --- /dev/null +++ b/docs/.vitepress/components/BDashboard/index.md @@ -0,0 +1,48 @@ +# BDashboard +提供通用的数据概览布局 + +## 组件注册 + +```js +import { BDashboard } from '@fesjs/traction-widget'; +app.use(BDashboard); +``` + +## 代码演示 +### 基础用法 +数据看板布局,传入sections和slot,自动纵向单列排布。常搭配BCharts组件使用 + +--USE + +--CODE + +## 参数说明 +### BDashboard Props +| 属性 | 说明 | 类型 | 默认值 | 是否必须 | +| -------- | ---------------------- | --------------------------------- | ------ | -------- | +| sections | 看板各区块的配置信息 | Array<{ title: string; name: string }> | [] | 是 | + +### Sections 配置项说明 +| 属性 | 说明 | 类型 | 示例 | +| ----- | ---------------------- | -------- | -------- | +| title | 区块标题 | string | '销售统计' | +| name | 对应插槽名称 | string | 'sales' | + +### Slots +| 插槽名 | 说明 | +| -------- | ---------------------- | +| [name] | 通过sections中的name字段动态匹配的具名插槽,用于放置对应区块的内容 | + +## 使用建议 +1. **布局规范** + - 建议每个区块内容保持合适的高度,避免过高或过低 + - 区块内容建议使用响应式组件,以适应不同宽度 + +2. **性能优化** + - 当区块较多时,建议使用动态组件或懒加载 + - 可以根据视口判断是否渲染可视区域外的内容 + +## 注意事项 +1. sections 的 name 属性值必须唯一,且与插槽名称一一对应 +2. 每个区块都需要提供对应的具名插槽内容,否则该区块将为空 +3. 组件默认提供了基础样式,如需自定义样式,可通过 CSS 变量覆盖 diff --git a/docs/.vitepress/components/BDashboard/use.vue b/docs/.vitepress/components/BDashboard/use.vue new file mode 100644 index 0000000..aae5fb2 --- /dev/null +++ b/docs/.vitepress/components/BDashboard/use.vue @@ -0,0 +1,98 @@ + + + \ No newline at end of file diff --git a/docs/.vitepress/config.js b/docs/.vitepress/config.js index 9bb0866..35fffee 100644 --- a/docs/.vitepress/config.js +++ b/docs/.vitepress/config.js @@ -107,6 +107,7 @@ export default defineConfig({ { text: 'BTablePage', link: '/components/BTablePage' }, { text: 'BNavBar', link: '/components/BNavBar'}, { text: 'BNavHeader', link: '/components/BNavHeader'}, + { text: 'BDashboard', link: '/components/BDashboard'}, ] } ], diff --git a/packages/traction-widget/components/Dashboard/Dashboard.vue b/packages/traction-widget/components/Dashboard/Dashboard.vue new file mode 100644 index 0000000..43b40bf --- /dev/null +++ b/packages/traction-widget/components/Dashboard/Dashboard.vue @@ -0,0 +1,25 @@ + + + diff --git a/packages/traction-widget/components/Dashboard/index.ts b/packages/traction-widget/components/Dashboard/index.ts new file mode 100644 index 0000000..89eae1f --- /dev/null +++ b/packages/traction-widget/components/Dashboard/index.ts @@ -0,0 +1,9 @@ +import { withInstall } from '../_util/withInstall'; +import Dashboard from './Dashboard.vue'; + +import type { SFCWithInstall } from '../_util/interface'; + +type DashboardType = SFCWithInstall; +export const BDashboard = withInstall(Dashboard as DashboardType); + +export default BDashboard; diff --git a/packages/traction-widget/components/Dashboard/style/index.less b/packages/traction-widget/components/Dashboard/style/index.less new file mode 100644 index 0000000..8d8369e --- /dev/null +++ b/packages/traction-widget/components/Dashboard/style/index.less @@ -0,0 +1,25 @@ +.wd-dashboard { + background: #f7f8fa; + display: flex; + flex-direction: column; + gap: 24px; + padding: 16px; + + &-section { + + &__header { + margin-bottom: 16px; + } + + &__title { + // 会被文档样式影响到 + // margin: 0; + } + + &__content { + padding: 24px; + background: #fff; + border-radius: 4px; + } + } +} \ No newline at end of file diff --git a/packages/traction-widget/components/Dashboard/style/index.ts b/packages/traction-widget/components/Dashboard/style/index.ts new file mode 100644 index 0000000..d74e52e --- /dev/null +++ b/packages/traction-widget/components/Dashboard/style/index.ts @@ -0,0 +1 @@ +import './index.less'; diff --git a/packages/traction-widget/components/index.ts b/packages/traction-widget/components/index.ts index 5fb0ffa..daa8ff1 100644 --- a/packages/traction-widget/components/index.ts +++ b/packages/traction-widget/components/index.ts @@ -11,6 +11,7 @@ import { BNavBar } from './NavBar'; import { BNavHeader } from './NavHeader'; import { BMetricTip } from './MetricTip'; import { BCharts } from './Charts'; +import { BDashboard } from './Dashboard'; const components = [ BTagsPanel, @@ -23,7 +24,8 @@ const components = [ BNavBar, BNavHeader, BMetricTip, - BCharts + BCharts, + BDashboard ]; const install = (app: any): any => { @@ -52,7 +54,8 @@ export { BNavBar, BNavHeader, BMetricTip, - BCharts + BCharts, + BDashboard }; export default { @@ -74,5 +77,6 @@ export default { BNavBar, BNavHeader, BMetricTip, - BCharts + BCharts, + BDashboard };