import lodash from 'lodash'
import { reactive } from 'vue'

const status = reactive({
  server: {
    enabled: false,
  },
  proxy: {
    enabled: false,
  },
  plugin: {
    node: {},
  },
})
async function install (app, api) {
  api.ipc.on('status', (event, message) => {
    console.log('view on status', event, message)
    const value = message.value
    const key = message.key
    lodash.set(status, key, value)
  })
  const basicStatus = await api.status.get()
  lodash.merge(status, basicStatus)
  app.config.globalProperties.$status = status
  return status
}
export default {
  install,
  status,
}
