import { BaseModel , dvaModel , effect , reducer , subscription } from 'utils/dva' ; import createService from 'utils/createService' ; interface ICommonState { [ key ] : any ; } const DEFAULT_STATE = { licensekey : 1 , } ; @ dvaModel ( 'common' ) class Common extends BaseModel { state : ICommonState = DEFAULT_STATE ; @ subscription whenLocationChange ( ) { } @ effect ( ) * getLicenseKey ( ) { yield effect . call ( createService ( 'api/xxx' , 'get' ) ) ; } @ reducer setLicenseKey ( licenseKey ) { return { ... this . state , licenseKey , } ; } } export default new Common ( ) . model ; declare global { interface Actions { common : Common ; } }