import { NPMRegistry } from '@/types/node' ; import { ipcRenderer } from 'electron' ; export default { state : { npmInstalled : false , allNpmRegistries : [ ] , currentNpmRegistry : '' , isAliInternal : false , } , effects : ( ) => ( { async getAllNpmRegistries ( ) { const allNpmRegistries = await ipcRenderer . invoke ( 'get-all-npm-registries' ) ; const npmRegistries = allNpmRegistries . map ( ( { registry , recommended = false } ) => ( { value : registry , label : registry , recommended } ) ) ; this . setState ( { allNpmRegistries : npmRegistries } ) ; } , async getCurrentNpmRegistry ( ) { const currentNpmRegistry = await ipcRenderer . invoke ( 'get-current-npm-registry' ) ; this . setState ( { currentNpmRegistry } ) ; } , async setCurrentNpmRegistry ( registry ) { await ipcRenderer . invoke ( 'set-current-npm-registry' , registry ) ; this . setState ( { currentNpmRegistry : registry } ) ; } , async checkNpmInstalled ( ) { const npmInstalled = await ipcRenderer . invoke ( 'check-npm-installed' ) ; this . setState ( { npmInstalled } ) ; } , async checkIsAliInternal ( ) { const isAliInternal = await ipcRenderer . invoke ( 'check-is-ali-internal' ) ; this . setState ( { isAliInternal } ) ; } , } ) , } ;