6.1.9 • Published 1 year ago

@uiw-admin/basic-layouts v6.1.9

Weekly downloads
2
License
MIT
Repository
github
Last release
1 year ago

页面整体布局

npm version

何时使用

当项目需要默认布局的使用

安装

npm i @uiw-admin/basic-layouts --save # yarn add @uiw-admin/basic-layouts

在项目中,BasicLayouts组件下如果不使用LayoutTabs组件内容放react-router-domOutlet组件。否则只需要放LayoutTabs组件即可。

import { Outlet } from '@kkt/pro';
import BasicLayout from '@uiw-admin/basic-layouts';
import LayoutTabs from "@uiw-admin/layout-tabs";

// 不使用 LayoutTabs 组件
const Layouts = () => {
  return (
    <BasicLayout routes={[]}>
      <Outlet />
    </BasicLayout>
  )
}

// 使用 LayoutTabs 组件
const Layouts = () => {
  return (
    <BasicLayout routes={[]}>
      <LayoutTabs routes={[]} />
    </BasicLayout>
  )
}

基本使用

import React from 'react';
import BasicLayout, { useLayouts } from '@uiw-admin/basic-layouts'
import LayoutTabs from "@uiw-admin/layout-tabs";

function BasicLayoutScreen() {
  const routerArrs = [
    {
      path: "/components/authorized",
      name: "权限组件",
      icon: 'appstore',
      element: <div>测试</div>,
    },
    {
      path: "/components/basic-layouts",
      name: "页面布局",
      icon: 'appstore',
      element: <div>测试2</div>,
    },
    {
      path: "/components/document-title",
      name: "页面标题",
      icon: 'appstore',
      element: <div>测试2</div>,
    }
  ]
  return (
    <div style={{ height: 400 }}>
      <BasicLayout
        isDefaultContentStyle={false}
        routes={routerArrs}
      >
        内容
      </BasicLayout>
    </div>
  )
}
export default BasicLayoutScreen;

头部布局

import React from 'react';
import BasicLayout, { useLayouts } from '@uiw-admin/basic-layouts'
import LayoutTabs from "@uiw-admin/layout-tabs";

function BasicLayoutScreen() {
  const routerArrs =[
    {
      path: "/components/authorized",
      name: "权限组件",
      icon: 'appstore',
      element: <div>测试</div>,
    },
    {
      path: "/components/basic-layouts",
      name: "页面布局",
      icon: 'appstore',
      element: <div>测试2</div>,
    },
    {
      path: "/components/document-title",
      name: "页面标题",
      icon: 'appstore',
      element: <div>测试2</div>,
    }
  ]
  const basicLayoutProps = {
    headerLayout: 'top',
    headerBackground: '#343a40',
    headerFontColor: '#fff',
  }
  return (
    <div style={{ height: 400 }}>
      <BasicLayout
        {...basicLayoutProps} 
        isDefaultContentStyle={false}
        routes={routerArrs}
      >
        内容
      </BasicLayout>
    </div>
  )
}
export default BasicLayoutScreen;

菜单搜索功能

在根目录.kktprc.js文件配置 SEARCH_MENU 参数,类型:boolen 默认true

// .kktprc.ts 
export default {
  define:{
    SEARCH_MENU:true
  }
}

右侧头像部分配置

  • menus配置右侧下拉菜单内容;
  • profile配置头像以及下拉菜单左侧内容;
  • onReloadAuth调用刷新权限接口;
  • layouts.closeMenu关闭菜单事件;
window.SEARCH_MENU = true
import React from 'react';
import BasicLayout, { useLayouts } from '@uiw-admin/basic-layouts';
import LayoutTabs from "@uiw-admin/layout-tabs";

const routerArrs = [
  {
    path: "/components/authorized",
    name: "权限组件",
    icon: 'appstore',
    element: <div>测试</div>,
  },
  {
    path: "/components/basic-layouts",
    name: "页面布局",
    icon: 'appstore',
    element: <div>测试2</div>,
  },
  {
    path: "/components/document-title",
    name: "页面标题",
    icon: 'appstore',
    element: <div>测试2</div>,
  }
]

function BasicLayoutScreen() {
  const layouts = useLayouts()
  const basicLayoutProps = {
    // 右侧下拉菜单内容
    menus: [
      {
        title: '欢迎来到uiw',
        icon: 'smile',
        // 调用关闭菜单事件
        onClick: () => layouts.closeMenu(),
      },
      {
        title: '修改密码',
        icon: 'setting',
      },
    ],
    profile: {
      // 头像地址
      avatar: '',
      // 下拉菜单左侧内容
      menuLeft:<div style={{ marginRight: 15 }}>可做自定义dom</div>
    },
    // 调用刷新接口
    onReloadAuth: () => {},
    layouts,
  }

  return (
    <div style={{ height: 400 }}>
      <BasicLayout
        {...basicLayoutProps}
        isDefaultContentStyle={false}
        routes={routerArrs}  >
        内容
      </BasicLayout>
    </div>
  )
}

export default BasicLayoutScreen;

自定义退出

通过隐藏系统默认的退出登录,自定义退出登录

import React from 'react';
import BasicLayout, { useLayouts } from '@uiw-admin/basic-layouts';
import LayoutTabs from "@uiw-admin/layout-tabs";

const routerArrs = [
  {
    path: "/components/authorized",
    name: "权限组件",
    icon: 'appstore',
    element: <div>测试</div>,
  },
  {
    path: "/components/basic-layouts",
    name: "页面布局",
    icon: 'appstore',
    element: <div>测试2</div>,
  },
  {
    path: "/components/document-title",
    name: "页面标题",
    icon: 'appstore',
    element: <div>测试2</div>,
  }
]

function BasicLayoutScreen() {
  const layouts = useLayouts();

  const basicLayoutProps = {
    // 右侧下拉菜单内容
    menus: [
      {
        title: '欢迎来到uiw',
        icon: 'smile',
        // 调用关闭菜单事件
        onClick: () => layouts.closeMenu(),
      },
      {
        title: '退出登录',
        icon: 'setting',
        onClick: () => { console.log('退出'); layouts.closeMenu() },

      },
    ],
    profile: {
      // 头像地址
      avatar: '',
      // 下拉菜单左侧内容
      menuLeft:<div style={{ marginRight: 15 }}>可做自定义dom</div>
    },
    // 调用刷新接口
    onReloadAuth: () => {},
    layouts,
    hideReloadButton: true,
    hideUserInfo: true,
    hideLogoutButton: true
  }

  return (
    <div style={{ height: 400 }}>
      <BasicLayout
        {...basicLayoutProps}
        isDefaultContentStyle={false}
        routes={routerArrs}  >
        <div style={{ padding: 14 }}>
          <LayoutTabs routes={routerArrs} /> 
          <div>注意:项目中使用 不需要设置 padding 样式</div>
        </div>
      </BasicLayout>
    </div>
  )
}
export default BasicLayoutScreen;

Props

参数说明必填类型默认值
classNameBasicLayout 外层classNamestring-
styleBasicLayout 外层最外层样式式object-
logologo图标string-
projectName项目名称string-
footer页脚React.ReactElement-
routes菜单路由数据KktproRoutesProps[]-
children内容React.ReactNode-
headerLayout头部布局枚举类型:"top" \| "default"default
headerBackground头部背景色string"#fff"
headerFontColor头部字体颜色string"#000"
menuHide菜单隐藏(可从路由组件router-control组件带参数hiddenMainMenu控制)boolenfalse
menus右侧点击头像展示菜单HeaderMenuItemsProps[]-
profile头像部分{avatar(头像)?:string,userName(用户名)?:string,menuLeft(菜单左侧)?:React.ReactElement}-
onReloadAuth重新加载权限() => void
layouts右侧点击头像展示菜单配置UseLayoutsProps-
isDefaultContentStyle内容区域默认样式展示booleantrue
hideReloadButton隐藏刷新权限按钮-Booleanfalse
hideLogoutButton隐藏退出登录按钮-Booleanfalse
hideUserInfo隐藏用户信息-Booleanfalse
onLogout覆盖原始退出事件(navigate: NavigateFunction) => void-
onLogoClicklogo 点击事件(event: React.MouseEvent<HTMLAnchorElement, MouseEvent>) => void-

建议:在使用 @uiw-admin/layout-tabs 组件渲染的时候,建议 isDefaultContentStyle 设置为 false

useLayouts

response

参数说明必填类型默认值
headerRightvisible关闭右上角menu菜单boolen-
closeMenu关闭右上角menu菜单事件() => void-
updateStore更新数据({ headerRightvisible: boolean }) => void-

贡献者

感谢所有的贡献者,欢迎开发者为开源项目贡献力量。

License

Licensed under the MIT License.

6.1.0

1 year ago

6.1.2

1 year ago

6.1.1

1 year ago

6.1.4

1 year ago

6.1.3

1 year ago

6.0.0

1 year ago

6.1.6

1 year ago

6.1.5

1 year ago

6.1.8

1 year ago

6.1.7

1 year ago

6.1.9

1 year ago

6.0.0-bate-1.1

1 year ago

6.0.0-bate-1.0

1 year ago

5.3.21

1 year ago

5.3.20

2 years ago

6.0.0-bate-1

2 years ago

5.3.19

2 years ago

5.3.18

2 years ago

5.3.17

2 years ago

5.3.16

2 years ago

5.3.3

2 years ago

5.3.2

2 years ago

5.3.15

2 years ago

5.3.14

2 years ago

5.3.13

2 years ago

5.3.12

2 years ago

5.3.11

2 years ago

5.3.10

2 years ago

5.3.9

2 years ago

5.3.8

2 years ago

5.3.7

2 years ago

5.3.6

2 years ago

5.3.5

2 years ago

5.3.4

2 years ago

5.3.1

2 years ago

5.3.0

2 years ago

5.2.39

2 years ago

5.2.38

2 years ago

5.2.37

2 years ago

5.2.36

2 years ago

5.2.35

2 years ago

5.2.34

2 years ago

5.2.33

2 years ago

5.2.32

2 years ago

5.2.31

2 years ago

5.2.30

2 years ago

5.2.29

2 years ago

5.2.28

2 years ago

5.1.2

2 years ago

5.1.1

2 years ago

5.1.0

2 years ago

5.2.19

2 years ago

5.2.18

2 years ago

5.2.17

2 years ago

5.2.16

2 years ago

5.2.15

2 years ago

5.2.14

2 years ago

5.2.13

2 years ago

5.2.12

2 years ago

5.2.11

2 years ago

5.2.10

2 years ago

5.2.9

2 years ago

5.2.8

2 years ago

5.2.7

2 years ago

5.0.9

2 years ago

5.2.6

2 years ago

5.0.8

2 years ago

5.2.5

2 years ago

5.0.7

2 years ago

5.2.4

2 years ago

5.0.6

2 years ago

5.2.3

2 years ago

5.0.5

2 years ago

5.2.2

2 years ago

5.0.4

2 years ago

5.2.1

2 years ago

5.0.3

2 years ago

5.2.0

2 years ago

5.0.2

2 years ago

5.0.1

2 years ago

5.0.10

2 years ago

5.0.0

2 years ago

5.0.11

2 years ago

5.1.2-alpha.0

2 years ago

5.2.27

2 years ago

5.1.2-alpha.1

2 years ago

5.2.26

2 years ago

5.2.25

2 years ago

5.2.24

2 years ago

5.2.23

2 years ago

5.2.22

2 years ago

5.2.21

2 years ago

5.2.20

2 years ago

4.1.4

3 years ago

4.1.3

3 years ago

4.1.2

3 years ago

4.1.1

3 years ago

4.1.0

3 years ago

4.0.3

4 years ago

4.0.2

4 years ago

4.0.1

4 years ago

4.0.0

4 years ago