import { createModel } from '../../moox' ; type StateType = { list : string [ ] ; status : number ; filterText : string ; currentEditIndex : number ; } ; const state = { list : [ 'tom' , 'xiaoming' ] , status : 0 , filterText : '' , currentEditIndex : 0 } ; const actions = { changeCurrentEditUser : function ( state , params ) { state . list [ params . index ] = params . name ; } , changeFilterValue : function ( state , params ) { console . log ( 555 , state , params ) ; state . filterText = params . text ; } , changeEditIndex : function ( state , params ) { state . currentEditIndex = params . index ; } , addUser : function ( state , params ) { state . list . push ( getRandomName ( ) ) ; state . status = 0 ; } , requestStatus : function ( state , params ) { state . status = 1 ; } , delUser : function ( state , params ) { state . list . splice ( params . index , 1 ) ; } } ; export default createModel ( { state , actions } ) ; function getRandomName ( len = 4 ) { let str = '' ; while ( len -- ) str += String . fromCharCode ( 97 + Math . ceil ( Math . random ( ) * 25 ) ) ; return str ; }