@kkt/plugin-pro-access
TypeScript icon, indicating that this package has built-in type declarations

1.1.5 • Public • Published

权限配置

权限控制,开启 access 配置, 则src目录下自动生成 access 文件。可以在业务中根据路径来定制需求。

参数

export interface AccessPluginProps {
  /** 是否开启权限 */
  access?: string;
}

roles

当路由配置roles参数,在页面中可以直接获取roles用于页面模块校验权限。

// config/routes.json
const routes = [
  // ....
  {
    path: '/demo',
    element: '@/pages/demo',
    roles: ['admin', 'users']
  }
]

// page
const Page = (props) => {
  const { roles = [] } = props;

  return <div />
}
export default Page;

access.ts

页面跳转拦截,思路来源于vue-routerbeforeEach

// src/access.ts
/**
 * @path: 当前页面地址
 * @return 返回true则通过,返回路由则表示跳转
 */
const beforeEach = (path: string) => {
  return new Promise((resolve, reject) => {
    const isAuth = false;
    if (isAuth) {
      resolve(true);
    } else {
      // 如果当前无权限则跳转到 login 页面
      resolve('/login')
    }
  })
};

export default beforeEach;

kktp配置文件

// .kktprc.ts
export default {
  access: true
}

Contributors

License

Licensed under the MIT License.

Versions

Current Tags

VersionDownloads (Last 7 Days)Tag
1.1.50latest
1.0.11-bate.20bate

Version History

VersionDownloads (Last 7 Days)Published
1.1.50
1.1.40
1.1.30
1.1.20
1.1.10
1.1.00
1.0.140
1.0.130
1.0.120
1.0.110
1.0.11-bate.20
1.0.11-bate.10
1.0.100
1.0.91
1.0.81
1.0.70
1.0.60
1.0.6-bate.20
1.0.50
1.0.40
1.0.30
1.0.20
1.0.10
1.0.1-bate.10
1.0.0-bate.10
1.0.0-alpha.10

Package Sidebar

Install

npm i @kkt/plugin-pro-access

Weekly Downloads

2

Version

1.1.5

License

MIT

Unpacked Size

19 kB

Total Files

22

Last publish

Collaborators

  • uiwjs
  • wcjiang