Skip to content
On this page

CommonLayer 系统整体布局

基础用法

更多 简体中文

配置参数

menu相关字段

参数说明类型是否必须
isCollapse侧边栏折叠与展开,默认为falseBooleanfalse
menuList菜单栏menu列表,如果没有菜单时,可以不传Array[]false
----label菜单展示项Stringtrue
----name菜单路由名称,与path中的路劲保持一致Stringtrue
----icon菜单左侧的icon,默认可以从common-icon中去做选择Stringfalse
----level菜单层级Numbertrue
----path菜单路径,默认语name相同Stringtrue

header相关字段

参数说明类型是否必须
headerInfoObjectfalse
----logo产品logo路劲,遵循vue静态文件引入方式即可Filetrue
----title产品名称Stringtrue
----menustodo: header中菜单方式Stringfalse
showMore是否显示加载更多按钮文字Booleanfalse
showLang是否显示切换语言文字Booleanfalse
showSearch是否显示header中的搜索按钮Booleanfalse
showInformation是否显示说明文档图标或者文字Booleanfalse
showMessage是否显示message iconBooleanfalse
userInfo用户信息Objecttrue
----src用户头像连接Stringtrue
----userAccount用户名称Stringtrue
commondsheader中点击头像时触发的下拉时间列表Objecttrue
----commond触发commond的name,例如logout/goInfoStringtrue
----labelcommond展示文本Stringtrue

其他字段

参数说明类型是否必须
breads整体框架中的面包屑展示,需要与router信息配合,此字段取自route-> meta -> breadcrumb 中的breadcrumb字段,所以需要引入route后方可实现Arrayfalse
asideWidth侧边栏位宽度,默认'260px'Stringfalse

事件

事件名称说明回调
handleChangeCollapse点击collape时,收缩时的宽度--

<script setup lang="ts">
import { ref } from 'vue';
// import { useRoute } from 'vue-router';
// import logo from './assets/images/hd-logo.svg';

const menuList = ref<any>([
  {
    label: '表格示例',
    name: 'table',
    icon: 'common-jihuoshebei',
    level: 1,
    path: '/table'
  },
  {
    label: '栅格示例',
    name: 'grid',
    icon: 'common-jihuoshebei',
    level: 1,
    path: '/grid'
  },
  {
    label: '卡片示例',
    name: 'card',
    icon: 'common-jihuoshebei',
    level: 1,
    path: '/card'
  },
  {
    label: '标签页示例',
    name: 'tabs',
    icon: 'common-jihuoshebei',
    level: 1,
    path: '/tabs'
  },
  {
    label: '描述页示例',
    name: 'info',
    icon: 'common-jihuoshebei',
    level: 1,
    path: '/info'
  },
  {
    label: '复杂表格',
    name: 'complex-form',
    icon: 'common-jihuoshebei',
    level: 1,
    path: '/complex-form'
  },
  {
    label: '弹窗demo',
    name: 'dialog',
    icon: 'common-jihuoshebei',
    level: 1,
    path: '/dialog'
  },
  {
    label: '上传组件demo',
    name: 'upload',
    icon: 'common-jihuoshebei',
    level: 1,
    path: '/upload'
  },
  {
    label: '图标集合',
    name: 'icons',
    icon: 'common-jihuoshebei',
    level: 1,
    path: '/icons'
  }
]);

const headerInfo = ref<any>({
  // title: 'AIoT Edge管理平台',
  // logo
});
// const route = useRoute();

const userInfo = ref<any>({
  userAccount: 'deployer'
});
const commonds = ref<any>([
  { label: '个人中心', commond: 'user' },
  { label: '退出登录', commond: 'logout' }
]);
const asideWidth = ref<any>('260px');
const isCollapse = ref<any>(false);

function handleChangeCollapse(collapse: any) {
  isCollapse.value = collapse;
  if (isCollapse.value) {
    asideWidth.value = '70px';
  } else {
    asideWidth.value = '260px';
  }
}
</script>

<template>
  <common-layer
    :menu-list="menuList"
    :user-info="userInfo"
    :header-info="headerInfo"
    :commonds="commonds"
    :is-collapse="isCollapse"
    :aside-width="asideWidth"
    @handle-change-collapse="handleChangeCollapse"
  ></common-layer>
</template>

<script setup lang="ts">
import { ref } from 'vue';
// import { useRoute } from 'vue-router';
// import logo from './assets/images/hd-logo.svg';

const menuList = ref<any>([
  {
    label: '表格示例',
    name: 'table',
    icon: 'common-jihuoshebei',
    level: 1,
    path: '/table'
  },
  {
    label: '栅格示例',
    name: 'grid',
    icon: 'common-jihuoshebei',
    level: 1,
    path: '/grid'
  },
  {
    label: '卡片示例',
    name: 'card',
    icon: 'common-jihuoshebei',
    level: 1,
    path: '/card'
  },
  {
    label: '标签页示例',
    name: 'tabs',
    icon: 'common-jihuoshebei',
    level: 1,
    path: '/tabs'
  },
  {
    label: '描述页示例',
    name: 'info',
    icon: 'common-jihuoshebei',
    level: 1,
    path: '/info'
  },
  {
    label: '复杂表格',
    name: 'complex-form',
    icon: 'common-jihuoshebei',
    level: 1,
    path: '/complex-form'
  },
  {
    label: '弹窗demo',
    name: 'dialog',
    icon: 'common-jihuoshebei',
    level: 1,
    path: '/dialog'
  },
  {
    label: '上传组件demo',
    name: 'upload',
    icon: 'common-jihuoshebei',
    level: 1,
    path: '/upload'
  },
  {
    label: '图标集合',
    name: 'icons',
    icon: 'common-jihuoshebei',
    level: 1,
    path: '/icons'
  }
]);

const headerInfo = ref<any>({
  // title: 'AIoT Edge管理平台',
  // logo
});
// const route = useRoute();

const userInfo = ref<any>({
  userAccount: 'deployer'
});
const commonds = ref<any>([
  { label: '个人中心', commond: 'user' },
  { label: '退出登录', commond: 'logout' }
]);
const asideWidth = ref<any>('260px');
const isCollapse = ref<any>(false);

function handleChangeCollapse(collapse: any) {
  isCollapse.value = collapse;
  if (isCollapse.value) {
    asideWidth.value = '70px';
  } else {
    asideWidth.value = '260px';
  }
}
</script>

<template>
  <common-layer
    :menu-list="menuList"
    :user-info="userInfo"
    :header-info="headerInfo"
    :commonds="commonds"
    :is-collapse="isCollapse"
    :aside-width="asideWidth"
    @handle-change-collapse="handleChangeCollapse"
  ></common-layer>
</template>