@adminforth/dashboard

中文文档
2.1.3发布于 2026/10/21MITTypeScriptES Module近 30 天下载 1743

行政板插件

中文使用文档
文档目录6 节
  1. 访问
  2. 代理核准
  3. 剪贴板配置形状
  4. 部件支持矩阵
  5. 查询形状
  6. 运行时结构

@adminforth/ dashboard (中文(简体) )

AdminForth 的 Dashboard 插件 .

它增加了可配置的由行政资源支持的仪表板页面。 Dashboard 记录定义组和部件,插件使其在 /dashboard/:slug,贡献a 盘子 侧边栏组,并曝光来自“管理Forth UI”的编辑组和部件的端点.

完整的设置指南 : https://adminforth.dev/docs/tutorial/Plugins/dashboard/ 页面存档备份,存于互联网档案馆

访问

台板取景和编辑仅限于 superadmin 默认。 设定 editRoles 允许其他角色编辑仪表板,以及 viewRoles 让角色查看仪表板而不编辑它们:

new DashboardPlugin({
  dashboardConfigsResourceId: 'dashboard_configs',
  editRoles: ['superadmin', 'developer'],
  viewRoles: ['manager'],
})

代理核准

默认情况下,AI代理在更改仪表板设置,组或部件配置,或删除组和部件之前,会向用户请求批准. 设定 agentEditsRequireApproval: false 允许它实施这些修改,而不要求:

new DashboardPlugin({
  dashboardConfigsResourceId: 'dashboard_configs',
  agentEditsRequireApproval: false,
})

editRoles 仍然适用,而MCP客户端不再收到这些工具的破坏性提示.

剪贴板配置形状

type DashboardConfig = {
  version: number
  groups: {
    id: string
    label: string
    order: number
  }[]
  widgets: DashboardWidgetConfig[]
}

每个部件都有共同字段:

外地说明
id错误部件 ID .
group_id组合部件的渲染位置 .
label可选部件标题 .
target部件类型 : table, (中文(简体) ), chart, (中文(简体) ), kpi_card, (中文(简体) ), pivot_table,或 gauge_card。 。 。 .
order组内的部件顺序 .
variables可选部件变量传递给部件数据加载 。 内部没有变量 query.calcs。 。 。 .
size预设宽度 : small, (中文(简体) ), medium, (中文(简体) ), large, (中文(简体) ), wide,或 full。 。 。 .
width, (中文(简体) ), height, (中文(简体) ), min_width, (中文(简体) ), max_width可选的明确布局限制. 无 height,图表,表格和中枢表格高400px,KPI和测量卡符合其内容.
query数据查询定义.

部件支持矩阵

部件目标配置字段主要设置数据使用情况
tabletablepagination, (中文(简体) ), page_size, (中文(简体) ), columns用途 query 以显示生行或集合行.
chartcharttype, (中文(简体) ), x, (中文(简体) ), y, (中文(简体) ), label, (中文(简体) ), value, (中文(简体) ), series, (中文(简体) ), buckets, (中文(简体) ), color, (中文(简体) ), colors使用同样的 query 大多数图表类型的形状。 多资源图表的使用 query.source: steps; 添加 query.bucket 用于共享跨资源的数字桶.
kpi_cardcardvalue, (中文(简体) ), subtitle, (中文(简体) ), comparison, (中文(简体) ), sparkline读取第一个返回的查询行.
gauge_cardcardvalue, (中文(简体) ), target, (中文(简体) ), progress, (中文(简体) ), color读取第一个返回的查询行.
pivot_tablepivotrows, (中文(简体) ), columns, (中文(简体) ), values使用查询行来构建枢轴表.

图表部件类型 :

图表类型页:1
line用途 x 财务报告和审定财务报表 y· ; y 可能包含多个配置字段.
pie用途 label 财务报告和审定财务报表 value。 。 。 .
bar用途 x 财务报告和审定财务报表 y。 。 。 .
stacked_bar用途 x, (中文(简体) ), y,以及 series。 。 。 .
funnel用途 label, (中文(简体) ), value选择 colors。数据来自同一数据 query 形状与其他图表一样.
histogram用途 x, (中文(简体) ), y选择 buckets。当前直方图运行时间支持仅为单资源:为数字字段提供生行并允许 chart.buckets 生成前端的计数。 多资源桶分配,使用 stacked_bar 与 query.source: steps 财务报告和审定财务报表 query.bucket。 。 。 .

查询形状

type QueryConfig = {
  source?: 'resource'
  resource: string
  select?: Array<
    | { field: string; as?: string; grain?: 'day' | 'week' | 'month' | 'year' }
    | { agg: 'sum' | 'count' | 'count_distinct' | 'avg' | 'min' | 'max' | 'median'; field?: string; as: string; filters?: DashboardFilter | DashboardFilter[] }
    | { calc: string; as: string }
  >
  filters?: DashboardFilter | DashboardFilter[]
  group_by?: Array<string | { field: string; as?: string; grain?: 'day' | 'week' | 'month' | 'year'; timezone?: string }>
  order_by?: Array<{ field: string; direction?: 'asc' | 'desc' }>
  limit?: number
  offset?: number
  bucket?: { field: string; buckets: Array<{ label: string; min?: number; max?: number }> }
  calcs?: Array<{ calc: string; as: string }>
  formatting?: Record<string, JsonValue>
} | {
  source: 'steps'
  steps: Array<{
    name: string
    resource: string
    select: Array<{ agg: 'sum' | 'count' | 'count_distinct' | 'avg' | 'min' | 'max' | 'median'; field?: string; as: string; filters?: DashboardFilter | DashboardFilter[] }>
    filters?: DashboardFilter | DashboardFilter[]
  }>
  calcs?: Array<{ calc: string; as: string }>
  order_by?: Array<{ field: string; direction?: 'asc' | 'desc' }>
  limit?: number
  offset?: number
  formatting?: Record<string, JsonValue>
}

`source: 'steps'` returns one aggregate row per step by default. Each step supports aggregate `select` items plus optional `filters`; it does not support per-step `field` selects, `calc` selects, or `group_by`. Add `query.bucket` when multiple resources need the same numeric buckets, for example a stacked bar distribution by price range.

type DashboardFilter =
  | { and: DashboardFilter[] }
  | { or: DashboardFilter[] }
  | {
      field: string
      eq?: FilterValue
      neq?: FilterValue
      gt?: FilterValue
      gte?: FilterValue
      lt?: FilterValue
      lte?: FilterValue
      in?: FilterValue[]
      not_in?: FilterValue[]
      like?: FilterValue
      ilike?: FilterValue
    }

type JsonValue = string | number | boolean | null | JsonValue[] | { [key: string]: JsonValue }
type RelativeDateValue = { now: true } | { now_minus: `${number}${'h' | 'd' | 'w' | 'mo' | 'y'}` }
type FilterValue = JsonValue | RelativeDateValue

使用 filters 用于滚动日期范围。 不为随时间而移动的仪表板设置硬码日期 :

query:
  resource: orders
  filters:
    and:
      - field: created_at
        gte:
          now_minus: 30d
      - field: created_at
        lt:
          now: true

使用多种资源查询 source: steps。每个步骤使用 select即使它只有一个总和:

target: chart
label: Average price by database
chart:
  type: bar
  title: Average price by database
  x:
    field: name
  y:
    field: value
query:
  source: steps
  steps:
    - name: SQLite
      resource: cars_sl
      select:
        - agg: avg
          field: price
          as: value
    - name: MySQL
      resource: cars_mysql
      select:
        - agg: avg
          field: price
          as: value

多资源查询的使用 query.bucket。仪表板每桶运行一步,返回一行 label, (中文(简体) ), name, (中文(简体) ), resource,以及选定的集合别名:

target: chart
label: Cars by price range and database
chart:
  type: stacked_bar
  title: Cars by price range and database
  x:
    field: label
  y:
    field: count
  series:
    field: name
query:
  source: steps
  bucket:
    field: price
    buckets:
      - label: Budget
        max: 3500
      - label: Mid-range
        min: 3500
        max: 7000
      - label: Premium
        min: 7000
  steps:
    - name: SQLite
      resource: cars_sl
      select:
        - agg: count
          as: count
    - name: MySQL
      resource: cars_mysql
      select:
        - agg: count
          as: count

成本计算示例:

target: chart
label: Model costs
chart:
  type: stacked_bar
  title: GPT-5.4 costs by day
  x:
    field: day
  y:
    - field: input_cost
    - field: output_cost
    - field: cached_cost
query:
  resource: model_usage
  filters:
    and:
      - field: model
        eq: gpt-5.4
      - field: used_at
        gte:
          now_minus: 7d
      - field: used_at
        lt:
          now: true
  select:
    - field: used_at
      as: day
      grain: day
    - agg: sum
      field: input_tokens
      as: input_tokens
    - agg: sum
      field: output_tokens
      as: output_tokens
    - agg: sum
      field: cached_tokens
      as: cached_tokens
  group_by:
    - field: used_at
      as: day
      grain: day
  calcs:
    - calc: input_tokens / 1000000 * 2.5
      as: input_cost
    - calc: output_tokens / 1000000 * 15
      as: output_cost
    - calc: cached_tokens / 1000000 * 0.25
      as: cached_cost

运行时结构

DashboardPage.vue
└── DashboardRuntime.vue
    └── DashboardGroup.vue
        └── WidgetShell.vue
            └── WidgetRenderer.vue
                ├── TableWidget.vue
                ├── ChartWidget.vue
                ├── KpiCardWidget.vue
                ├── PivotTableWidget.vue
                └── GaugeCardWidget.vue

DashboardPage.vue 用弹子装入仪表板, DashboardRuntime.vue 制作命令组, WidgetShell.vue 提供部件框架和编辑器动作,以及 WidgetRenderer.vue 选择部件组件 target。 。 。 .

版本与发布记录

@adminforth/dashboard 共发布 54 个版本,首次发布于 2026/05/28;过去 12 个月发布了 54 个版本。

版本发布日期距今
2.1.3latest2026/10/2119 天前
2.1.22026/10/1921 天前
2.1.12026/10/1921 天前
2.1.02026/10/1922 天前
2.0.02026/10/1822 天前
1.23.02026/10/1624 天前

关于 @adminforth/dashboard 的常见问题

@adminforth/dashboard 是什么?

行政板插件

如何安装 @adminforth/dashboard?

在项目目录运行 npm install @adminforth/dashboard,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:adminforth(^4.7.3)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。

@adminforth/dashboard 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@adminforth/dashboard 支持 ESM 还是 CommonJS?

以 ES Module 形式发布,推荐使用 import 引入。在 CommonJS 项目中,Node.js 20.19+ / 22.12+ 可以直接 require() 不含顶层 await 的 ES Module,更早的版本需要改用动态 import()。

@adminforth/dashboard 可以商用吗?

@adminforth/dashboard 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@adminforth/dashboard 的下载量有多少?

根据 npm 官方下载统计,@adminforth/dashboard 在 2026/10/05 – 2026/11/03 这 30 天内被下载 1,743 次,日均约 58 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@adminforth/dashboard 还在维护吗?

最新版本 2.1.3 发布于 2026/10/21(19 天前);至今共发布 54 个版本,其中过去 12 个月发布了 54 个;首次发布于 2026/05/28。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。