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 🙏

© 2024 – Pkg Stats / Ryan Hefner

tkit-tkit

v3.1.3

Published

> TODO: description

Downloads

7

Readme


name: tkit menu: '开发/测试/构建' route: /tkit/tkit

npm i tkit-tkit

脚手架 CLI

1. Usage

- 1.1 创建组件

- 1.1.① 创建 Component

命名遵循驼峰格式,不能使用 default, index

# 创建组件 feature/components/componentName
./node_modules/.bin/tkit-kit add component feature//componentName

# 创建组件 feature/h5Components/componentName
./node_modules/.bin/tkit-kit add component feature/h5/componentName

# 创建组件 feature/componentName
./node_modules/.bin/tkit-kit add component feature/componentName

-c : connect redux store
-u : 路由页面,存在 this.props.match.params,组件名请使用 XXXPage
-p : pureComponent
-f : 慎用,覆盖已有
-w : 将组件 ts 与 less 文件包在同一个文件里,默认 true

- 1.1.② 创建无状态组件,Presenter、SFC

命名遵循驼峰格式,不能使用 default, index,自版本 3.1.0 起,不再自动添加 SFC 前缀

# 创建组件 feature/components/componentName
./node_modules/.bin/tkit-kit add presenter feature//componentName

# 创建组件 feature/h5Components/componentName
./node_modules/.bin/tkit-kit add presenter feature/h5/componentName

# 创建组件 feature/componentName
./node_modules/.bin/tkit-kit add presenter feature/presenterName

-c : connect redux store
-u : 路由页面,存在 props.match.params,组件名请使用 XXXPage
-f : 慎用,覆盖已有
-w : 将组件 ts 与 less 文件包在同一个文件里,默认 false
-k, --hooks : 创建 hooks,默认 false

- 1.2 redux 相关

- 1.2.① 创建 model

命名遵循驼峰格式: xxModel

- 1.2.①.a 3.1.0 以后版本

创建集成 immer & redux store namespace 自动隔离的 model

  # 集成 immer & namespace 隔离的全局 model
  ./node_modules/.bin/tkit-kit add mm feature/myModel
  # 集成 immer 的 local model
  ./node_modules/.bin/tkit-kit add mm feature/myModel -l

见 tkit-model

- 1.2.①.b 3.1.0 之前版本

  ./node_modules/.bin/tkit-kit add model feature/myModel

见 tkit-model

- 1.2.①.c M && MM & useModel

见 tkit-model

- 1.2.② 创建 action - model instead

命名遵循驼峰格式: 动词 + 名词,例如 login,pullUserInfo

实际生成: doLogin, loginReducer

  ./node_modules/.bin/tkit-kit add action feature/actionName

- 1.2.③ 创建异步 action - model instead

命名遵循驼峰格式: 动词 + 名词,例如 login,pullUserInfo

实际生成 action: doLogin, loginReducer, sagaLogin

  ./node_modules/.bin/tkit-kit add action feature/sagaName -a

- 1.2.④ 创建适配 antd 分页 list action

命名请: myList - 用以表示分页

  # 命令请使用 myList 结构
  ./node_modules/.bin/tkit-kit add list feature/myList

对应 store、actions

  // 往指定 feature 下写入 myList 数据结构
  {
    [featureName]: {
      [myList]: {
        pageData: [],
        total: 0,
        params: {
          current: 1,
          pageNum: 1,
          pageSize: 10,
          ...params
        },
        rowKey: 'id', // 默认是 id
        selectedRowKeys: [], // 当前选中的行的 rowKeys
        loading: true, // 是否正在加载
        isfetch: true, // 是否正在加载,同 loading
        fetchError: false // 错误信息
      }
    }
  }

  // 往 actions 内写入
  {
    // 拉取翻页数据
    doTestList: (params: Home.ListParams) => xxx
    // 选中行,适配 antd
    doSelectTestList: (payload: {
      // 设置选中
      selectedRowKeys?: IPagenationState['selectedRowKeys'];
      // 指定新的 rowKey
      rowKey?: string | number;
    }) => xxx
    // 此方法预留,需手动写入 actions
    // modifyDataAction: (reducer: (list: List) => List) => xxx
  }

- 1.2.⑤ tPut, tCall

typescript 化 redux-saga 的 put & call

  import { TkitUtils as Utils } from 'tkit-types';

  // 注意: 不要把这里的 effect 和 model 的 effects 混淆,effects 最终会生成 action 并可以供 tPut 调用
  // args 类型必须是 effect 定义的参数类型
  tCall(effect, args: typed)

  // 解决由于使用了 yield 造成 data 类型丢失的问题, use Utils.GetROA for short
  const data: Utils.GetReturnTypeOfAsyncFun<typeof effect> = yield tCall(effect, args);

  // 调用通过 typesafe-actions 创建的 action 以及从 model effects & reducers 自动生成的 action,向下不兼容 redux-actions 创建的 action
  tPut(action, args: typed) - args 类型必须是 action 定义的参数类型