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 🙏

© 2025 – Pkg Stats / Ryan Hefner

base-element-react

v2.5.27

Published

基于Ant Design的管理后台配置化开发框架

Downloads

189

Readme

base-element的react版本

基于 Ant Design 的管理后台配置化开发框架

文举 2023

快速开始

1. 安装依赖

npm install base-element-react --save

2. 初始化

main.tsx中设置全局配置

import BaseElement from 'base-element-react';

BaseElement.use({
  http: xx, // 通用接口请求 (使用在接口枚举。若没有使用接口枚举,则不用配置)
  uploadApi: xx, // 单文件上传接口 (使用在富文本。若没有用富文本则不必配置)
  uploadAction: xx, // 上传组件的action配置 (使用在上传组件。若没有使用上传组件, 则不用配置)
  imgHost: xx, // 自动拼接图片和视频的域名地址 (若没有使用图片和视频组件, 则不用配置)
  imgType: 'OSS', // 云存储类型 (阿里云"OSS"|七牛云"QiNiu")
  rowKey: 'id', // table的唯一标识 (默认"id")
  pageKey: 'pageNum', // 分页页码的key (默认"pageNum")
  sizeKey: 'pageSize', // 分页页长的key (默认"pageSize")
  listKey: 'list', // 列表数据的key (默认"list") 
  totalKey: 'total', // 列表总数的key (默认"total")
  gaodeKey: '', // 高德地图jsapi的key (没有使用地图组件, 则不用配置)
  gaodeSecret: '', // 高德地图jsapi的秘钥 (没有使用地图组件, 则不用配置)
});

3. 使用

import { apiSearch } from './api';
import dialogEdit from './dialog/edit';
import type { BasePageConfig } from 'base-element-react';
import { BasePage, BaseText } from 'base-element-react';
import { BASE_USE } from 'base-element-react/lib';
import { getDiffDateArr } from 'base-element-react/util/format';

export default () => {
  /** 列表页的配置 */
  const config: BasePageConfig = {
    // 搜索栏
    form: [
        { label: '手机号', prop: 'phone', type: 'tel' },
        { label: '运行状态', prop: 'run_type', comp: 'select', lib: BASE_USE },
        {
            label: '搜索日期',
            prop: ['start_dt', 'end_dt'],
            comp: 'picker-date',
            value: getDiffDateArr(-90),
        },
    ],
    // 按钮栏
    btns: [
      { label: '新增', dialog: dialogEdit },
    ],
    // 分页表格
    table: [
      { label: '手机号', prop: 'phone_number' },
      { label: '发送时间', prop: 'send_time' },
      { label: '短信内容', prop: 'body_msg', ellipsis: true },
      {
        label: '状态码',
        width: 100,
        render(row) {
          return (
            <BaseText value={row.err_code} color={row.success == 1 ? 'green' : 'yellow'}></BaseText>
          );
        },
      },
      {
        label: '操作',
        btns: [
          {
            vif: (row) => row.run_type != 20,
            label: '编辑',
            dialog: dialogEdit,
          },
          {
            label: '详情',
            dialog: dialogDetail,
          },
        ],
      },
    ],
    // 搜索接口
    apiSearch,
  };

  return <BasePage config={config} />;
};

弹窗配置

import { apiResetProtected } from '../api';
import type { BaseDialog, BaseDialogConfig } from 'base-element-react';
import { BASE_USE } from 'base-element-react/lib';

const dialog: BaseDialog = (): BaseDialogConfig => {
  return {
    // 表单配置
    form: [
        { label: '手机号', prop: 'phone', type: 'tel', required: true },
        { label: '运行状态', prop: 'run_type', comp: 'select', lib: BASE_USE },
    ],
    // 点击确定按钮的接口
    apiSubmit: apiResetProtected,
  };
};

export default dialog;

注意

如果遇到git提交时,lint检查报braft-utils模块未定义,可以在src目录创建module.d.ts

// 解决ts模块引入时,提示模块未定义的异常: 只需新增"xx.d.ts",然后declare module '第三方类库名'
declare module 'braft-utils';
declare module 'braft-extensions/dist/color-picker';
declare module 'braft-extensions/dist/table';