All files / lib/redux action.ts

77.61% Statements 52/67
57.14% Branches 4/7
75% Functions 3/4
77.61% Lines 52/67

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 681x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x         1x 1x 1x 1x 1x 1x 10x 10x         1x 1x 1x 1x 1x 1x             1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 11x    
/**
 * @file redux的action
 * @Author wangjie19
 * @Date 2020-07-25 21:24:11
 * @Last Modified by: wangjie19
 * @Last Modified time: 2020-07-27 08:36:46
 */
 
import { ROOT, DB, TABLE } from './actionTypes';
import { IAction } from '../interface';
 
/**
 * 获取根目录action
 * @param data 根目录数据
 * @return 根目录action
 */
function root(data: any): IAction {
    return {
        type: ROOT,
        payload: data
    };
}
 
/**
 * 获取数据库action
 * @param data 根目录数据
 * @return 根目录action
 */
function db(data: any): IAction {
    return {
        type: DB,
        payload: data
    }
}
 
/**
 * 获取数据库action
 * @param data 根目录数据
 * @return 根目录action
 */
function table(data: any): IAction {
    return {
        type: TABLE,
        payload: data
    }
}
 
/**
 * action字典
 */
const dic = {
    root,
    db,
    table
};
 
type Types = 'root' | 'db' | 'table';
 
/**
 * 获取对应字典action
 * @param subdic 字典映射字段
 * @param data 数据
 * @return 对应action
 */
export function recive(subdic: Types, data: any): IAction {
    return dic[subdic](data);
}