Skip to content

CommonPage 通用页面布局

标准后台页面布局组件。提供可配置的页面头部(标题、返回按钮、操作按钮区域)和内容区。头部使用 AppCard 包裹并粘性定位在顶部,标题优先取 props 传入值,其次取路由 meta.title

基础用法

vue
<template>
  <CommonPage title="用户管理" back show-header>
    <template #action>
      <n-button type="primary">新增</n-button>
    </template>

    <AiCrudPage api="/api/user" :columns="columns" :edit-schema="editSchema" />
  </CommonPage>
</template>

<script setup>
import CommonPage from '@/components/common/CommonPage.vue'
</script>

Props

属性类型默认值说明
backBooleanfalse是否显示返回按钮(调用 router.back()
showFooterBooleanfalse是否显示默认底部
showHeaderBooleanfalse是否显示头部区域。设为 true 后头部粘性定位在顶部
titleString页面标题。未传时自动取路由 meta.title

Slots

插槽名说明优先级
header完全自定义头部内容最高
title-prefix标题前缀区域(默认放返回按钮)
title-suffix标题后缀区域
action右侧操作按钮区域
default页面主内容区域
footer自定义底部

典型布局示例

vue
<CommonPage back show-header title="订单列表">
  <!-- 右侧操作按钮 -->
  <template #action>
    <n-space>
      <n-button type="primary" @click="showImport = true">导入</n-button>
      <n-button @click="handleExport">导出</n-button>
    </n-space>
  </template>

  <!-- 标题后缀加角标 -->
  <template #title-suffix>
    <n-tag type="info" size="small">共 {{ total }} 条</n-tag>
  </template>

  <!-- 主内容 -->
  <AiCrudPage ref="crudRef" api="/api/order" :columns="orderColumns" />
</CommonPage>

Forge Admin — 基于 Vue3 + Spring Boot 的企业级后台管理框架