import http, { request, RequestOptions } from '@/utils/fetch';
import { getPanelApi } from '@/utils/screen';
import { urlCacheReplace } from 'utils/utils';
import { api } from 'constants/config';
enum PanelApis {
  SharedGatewayPanelGet = api.sharedGatewayPanelGet,
  SharedPanelGet = api.sharedPanelGet,
  PanelGetOfChecked = api.panelGetOfChecked,
  AppPanelGet = api.appPanelGet,
  PanelGet = api.panelGet,
}
/**
 * //TODO  后续服务端关于引用面板接口迁移，请更改下面的函数
 * @description 合并get和http参数，调用时，只需要将所有参数传进来即可，前面四个为request参数，后面为get参数
 * @param requestParams
 * @param requestQuery
 * @param requestBody
 * @param requestOptions
 * @param queryData
 * @param getOptions
 * @returns
 */
export const getPanelInfoByParams = async <T>(
  requestParams = {},
  requestQuery = {},
  requestBody: string | FormData | undefined = undefined,
  requestOptions: any = {},
  getQuery: { [k: string]: any } = {},
  getOptions?: RequestOptions,
) => {
  const url = getPanelApi() as PanelApis;
  if (
    url === PanelApis.PanelGet ||
    url === urlCacheReplace(PanelApis.SharedPanelGet) ||
    url === PanelApis.PanelGetOfChecked
  ) {
    return request(`${url}`, requestParams, requestQuery, requestBody, requestOptions);
  }
  return http.get<T>(`${url}`, getQuery, getOptions);
};
