umi-plugin-auto

0.0.28 • Public • Published

umi-plugin-auto

NPM version NPM downloads

myself

Usage

Configure in .umirc.js,

export default {
  plugins: [
    ['umi-plugin-auto', options],
  ],
}

全局参数

{
  quotes: 'single',    // 单引号还是双引号  默认双引号
  globalIndex:'$name'   // 全局设置每个模块的入口文件,默认index.tsx 可以指定设置为一个文字,也可以使用$xxx 动态取name字段为名字
  ...
}

三大分类

common: [],   // 组件,数组每项为obj,具体格式看模块参数
layouts: [],  // 数组每项为obj,具体格式看模块参数
pages: []     // 数组每项为obj,具体格式看模块参数

模块

{
    name: '',                  // 模块名字,必填
    state: [],                 // redux中可读的数据 
    func: [],                  // redux中可写的数据
    isPage:false               // 是否生成入口文件 默认是true
    isComponent:false :false   // 同上 仅仅为语义化
    index:'index',             // 入口文件的名字,先取这个,取不到取全局的,全局没有就是默认了
    type:'class'               // react风格,默认hook
    children:[]                // 子页面/模块
}

state

{
    'name': 'name',            //必须和func对应
    'type': 'string',          //必须和func对应
    'default': 'hello word'
}

func

{
    'method': 'setName',
    'parameter': 'name',       //必须和state对应
    'parmType': 'string'       //必须和state对应
}

Options

{
    quotes: 'single',
    common: [
        {
            name: 'formNameInput',
            state: [{
              'name': 'nameInput',
              'type': 'string',
              'default': 'user'
            }],
            func: [{
              'method': 'setNameInput',
              'parameter': 'nameInput',
              'parmType': 'string'
            }],
        },
        {
            name: 'formPasswordInput',
            state: [{
              'name': 'passwordInput',
              'type': 'string',
              'default': ''
            }],
            func: [{
              'method': 'setPasswordInput',
              'parameter': 'passwordInput',
              'parmType': 'string'
            }],
        }
    ],
    layouts: [
        {
            name: 'loginLayout',
            state: [],
            func: [],
        }, 
        {
            name: 'appLayout',
            state: [],
            func: [],
        }
    ],
    pages: [
        {
            name: 'login',
            state: [],
            func: [],
        },
        {
            name: 'app',
            state: [],
            func: [],
            children:[
                {
                    name:'components',
                    isPage: false,
                    state: [],
                    func: [],
                    children:[
                        {
                            name: 'user1',
                            state: [{
                                'name': 'title',
                                'type': 'string',
                                'default': ''
                            }],
                            func: [],
                        },
                        {
                            name: 'user2',
                            state: [{
                                'name': 'title',
                                'type': 'string',
                                'default': ''
                            }],
                            func: [{
                                'method': 'setTitle',
                                'parameter': 'title',
                                'parmType': 'string'
                            }],
                        }
                    ]
                }
            ]
        }
    ]
}

Introduction

http://upa.fzcode.com/

LICENSE

MIT

Readme

Keywords

none

Package Sidebar

Install

npm i umi-plugin-auto

Weekly Downloads

0

Version

0.0.28

License

MIT

Unpacked Size

39.4 kB

Total Files

5

Last publish

Collaborators

  • dazan