All files / lib control.ts

84.78% Statements 39/46
50% Branches 7/14
85.71% Functions 6/7
84.78% Lines 39/46

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 471x 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 1x   1x 1x 9x 9x   1x 1x       1x 1x 1x   1x 1x 1x  
/**
 * @file 控制脚本
 * @Author wangjie19
 * @Date 2020-07-26 09:49:24
 * @Last Modified by: wangjie19
 * @Last Modified time: 2020-07-27 09:04:38
 */
 
import FileDB from './index';
import { recive } from './redux/action';
import store from './redux/store';
import { IConfig } from './interface';
 
class ControlProxy {
    private fileDB: FileDB
    constructor() {
        this.fileDB = new FileDB();
    }
 
    config(conf: IConfig) {
        conf.root ? store.dispatch(recive('root', conf.root)) : null;
        return this;
    }
 
    createDB(name: string = '') {
        store.dispatch(recive('db', name));
        this.fileDB.createDB();
        return this.fileDB.db();
    }
 
    db(name: string = '') {
        store.dispatch(recive('db', name));
        return this.fileDB.db();
    }
 
    deleteDB(name: string = '') {
        store.dispatch(recive('db', ''));
        return this.fileDB.deleteDB(name);
    }
 
    dbs() {
        return this.fileDB.dbs();
    }
}
 
export default new ControlProxy();