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

@kbse/system

v0.2.13

Published

KBSE 前端开发框架

Readme

kb-smart Pro 基础框架

开发请参考以下文档

开始一个页面

以 demo 页面为例

src/pages 新建文件夹demo,文件夹内新建index.tsx.

src
├── pages
│   ├── demo
│   │   ├── index.less
│   │   └── index.tsx

注:

  • 页面组件请使用.tsx,工具文件使用.ts

编写页面代码

import React from 'react';
import styles from './index.less';
import { Page } from '@kbse/system';
import { useModel } from 'umi';

const Demo: React.FC = () => {
  const { currentUser } = useModel('system');
  return (
    <Page pageFooter>
      <div className={styles.container}> demo</div>
      <div>My name is {currentUser?.name}</div>
    </Page>
  );
};

export default Demo;

保存,访问http://localhost:8000/#/demo 即可看到页面

注:

  • Page@kbse/system基础框架提供的页面组件,提供了页面 header 和 footer 以及面包屑等。参数会透传给 antd PageHeader,可以使用其功能,见PageHeader
  • 组件和页面都推荐使用react hooks方式编写,class 组件建议新功能页面不使用

数据流方案

可以继续使用dva数据方案,也可以使用useModel方案,基础框架都使用useModelhooks 方案,需要消费基础框架的数据,请使用以下方式

const { currentUser } = useModel('system');

models

dvauseModel 都支持

推荐使用hooks model + useRequest编写 model,以下是框架里的写法:

import { useMemo } from 'react';
import { useRequest } from 'umi';
import { MenuDataItem } from '@ant-design/pro-layout';
import { Resource, User, LocalResource, ResourceType, ENV } from '../schema/system';
import { getResources, getCurrentUser, getEnv } from '../services/system';
import { formatJsonMessage } from '../utils/locale';

export interface Params {
  resources: Resource[];
  resourcesTree: LocalResource[];
  refreshResources: () => Promise<Resource[]>;
  routes: MenuDataItem[];
  currentUser?: User;
  loading: boolean;
  env?: ENV; // 环境
}

/**
 * 系统加载资源,在所有页面render前
 */
export default (): Params => {
  // 加载资源
  const { data: resources = [], loading: loadingResource, refresh: refreshResources } = useRequest(
    getResources,
  );
  // 当前用户
  const { data: currentUser, loading: loadingCurUser } = useRequest(getCurrentUser);
  // 环境
  const { data: env, loading: loadingEnv } = useRequest(getEnv);

  // 树形资源
  const resourcesTree = useMemo(() => {
    return list2Tree(resources);
  }, [resources]);

  // 路由
  const routes: MenuDataItem[] = useMemo(() => {
    return resources2Routes(resources);
  }, [resources]);

  return {
    resources,
    routes,
    resourcesTree,
    refreshResources,
    currentUser,
    loading: loadingResource || loadingCurUser || loadingEnv,
    env,
  };
};

其中,hooks 就是纯函数,请务必写函数返回的类型,如上面的Params,消费数据useModel('xxx')返回值有语法提示,减少文件切换和手误成本。

  • 关于请求 Hooks useRequest,请参考一个强大的管理异步数据请求的 Hook
  • 上例中,是在系统render前就会请求必备的全局数据,业务页面数据,请使用参数{ manual: true }run手动触发请求。