import { message } from 'antd';
import { service, request } from '@wisdom-utils/utils';
import { getRootContext } from '@wisdom-utils/vapp-browser-vm/lib/vm';
import AppService from './service/base';
import notificationService from './service/notification';
// eslint-disable-next-line no-return-await
request.reportCodeError = true;

// request.setResponseHandler(response => {
//   if (response.code === 401) {
//     return window.location.reload();
//   }
//   return response;
// });

request.setErrorHandler((resData, { config }) => {
  if (!config.noErrorTip) {
    message.error(resData.message);
  }
});

const appService = service(AppService);
const noticeService = service(notificationService);
export { appService, noticeService };
