import { request } from '../request';

// 定义 API URL 常量
const BASE_URL = 'http://localhost:58926/api';
// 获取菜单权限
const GetMenus_URL = `${BASE_URL}/System/GetMenus`;

/** get constant routes */
export function fetchGetConstantRoutes() {
  return request<Api.Route.MenuRouteData>({ url: '/route/getConstantRoutes' });
}

/** get user routes */
export function fetchGetUserRoutes(userId: string) {
  return request<Api.Route.UserRouteData>({
    url: GetMenus_URL,
    method: 'post',
    data: {
      userId
    }
  });
}

// /** get user routes */
// export function fetchGetUserRoutes() {
//   return request<Api.Route.UserRoute>({ url: '/route/getUserRoutes' });
// }

/**
 * whether the route is exist
 *
 * @param routeName route name
 */
export function fetchIsRouteExist(routeName: string) {
  return request<boolean>({ url: '/route/isRouteExist', params: { routeName } });
}
