import {
  Configuration,
  UserweappApi,
  UserApi,
  BillApi,
  StoreDeviceApi,
} from '@/api';

const apiConfig = new Configuration({
  basePath: 'http://127.0.0.1:3000/api',
});

const api = {
  host: 'http://127.0.0.1:3000/api',
  uploadFile: `/upload/file`,
  userweappApi: new UserweappApi(apiConfig, apiConfig.basePath),
  userApi: new UserApi(apiConfig, apiConfig.basePath),
  billApi: new BillApi(apiConfig, apiConfig.basePath),
  storeDeviceApi: new StoreDeviceApi(apiConfig, apiConfig.basePath),

  /* wxApi: new WxApi(apiConfig, apiConfig.basePath), */
  transUrl: (url?: string) => {
    if (url) {
      return `${api.host}${url}`;
    }
    return undefined;
  },
};

export const useApi = () => api;
