index.js 583 B

123456789101112131415161718192021
  1. import MonitorEntApi from '../plugins/ent-api'
  2. import MonitorProjectApi from '../plugins/project-api'
  3. import MonitorClientApi from '../plugins/client-api'
  4. /**
  5. * 一键使用项目监控、企业监控功能
  6. * 1. 根据 type 查询当前监控信息
  7. * 2. 返回监控信息及改变监控状态的事件钩子 { state, doChange }
  8. */
  9. const APIS = {
  10. project: MonitorProjectApi,
  11. ent: MonitorEntApi,
  12. client: MonitorClientApi
  13. }
  14. function useQuickMonitor({ type, params }) {
  15. const useMonitorApi = APIS[type]
  16. return new useMonitorApi(params)
  17. }
  18. export default useQuickMonitor