npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@wair/access-control

v1.0.2

Published

访问控制相关页面

Readme

@wair/access-control

抽离访问控制相关页面代码,方便各项目集成

目录

集成指南

1. 安装依赖

pnpm install @wair/access-control

2. 配置访问控制参数

在项目入口文件设置访问控制相关的配置:

import { setAccessControlConfig } from "@wair/access-control"

// 配置类型定义
type IConfig = {
	fetchData: () => Promise<any> // 用于发送请求的实例,例如 axios 实例
	isAxiosInstance: boolean // 是否是 axios 实例,原代码是用的fetch实例,调用方式有点不一样
	userGroupPath: string // 用户组页面的路径
}

// 配置示例
setAccessControlConfig({
	fetchData: request1,
	isAxiosInstance: true,
	userGroupPath: "/operation/group"
})

3. 页面集成

调用访问控制相关的页面组件:

import { UserManagementPage, UserGroupManagementPage, StrategyManagementPage } from "@wair/access-control"

// 用户组管理页面
export default function UserGroupManagement() {
  return (
    <UserGroupManagementPage />
  )
}

// 用户管理页面(需要权限控制和参数)
export default function UserManagement({ userInfo, clientId }) {
  return (
    <PermissionWrapper permissionField="user">
      <UserManagementPage userInfo={{ id: userInfo?.id }} clientId={clientId} />
    </PermissionWrapper>
  )
}

// 策略管理页面
export default function StrategyManagement() {
  return (
    <StrategyManagementPage />
  )
}

配置说明

| 配置项 | 类型 | 说明 | | ----------------- | ---------- | ------------------------------------------------------------ | | fetchData | Function | 用于发送请求的实例,例如 axios 实例 | | isAxiosInstance | boolean | 是否是 axios 实例,原代码是用的fetch实例,调用方式有点不一样 | | userGroupPath | string | 用户组页面的路径 |

组件使用

导出的组件

| 组件名称 | 说明 | 必需参数 | | ------------------------- | -------------- | ---------------------- | | UserManagementPage | 用户管理页面 | userInfoclientId | | UserGroupManagementPage | 用户组管理页面 | 无 | | StrategyManagementPage | 策略管理页面 | 无 |

注意事项

  1. 权限处理:组件内部未做页面权限相关处理,需要在组件外部包裹 PermissionWrapper 类似组件
  2. 参数说明UserManagementPage 组件需要传入 userInfoclientId(sso登录的client_id)两个参数
  3. React Query:页面中有使用到 @tanstack/react-query,需要在项目入口文件设置全局配置

依赖说明

项目需要安装以下前置依赖:

  • react
  • react-dom
  • @douyinfe/semi-ui
  • @douyinfe/semi-icons
  • styled-components
  • @tanstack/react-query
  • dayjs
  • valtio