import request from '/@/utils/request';

/**
 * 后端控制菜单模拟json，路径在 https://gitee.com/lyt-top/vue-next-admin-images/tree/master/menu
 * 后端控制路由，isRequestRoutes 为 true，则开启后端控制路由
 */

/**
 * 获取后端动态路由菜单(admin)
 * @link 参考：https://gitee.com/lyt-top/vue-next-admin-images/tree/master/menu
 * @param params 要传的参数值，非必传
 * @returns 返回接口数据
 */
export function getMenuAdmin(params?: object) {
	return request({
		url: '/gitee/lyt-top/vue-next-admin-images/raw/master/menu/adminMenu.json',
		method: 'get',
		params,
	});
}

/**
 * 获取后端动态路由菜单(test)
 * @link 参考：https://gitee.com/lyt-top/vue-next-admin-images/tree/master/menu
 * @param params 要传的参数值，非必传
 * @returns 返回接口数据
 */
export function getMenuTest(params?: object) {
	return request({
		url: '/gitee/lyt-top/vue-next-admin-images/raw/master/menu/testMenu.json',
		method: 'get',
		params,
	});
}

// 保存菜单
export function saveResources(params: object) {
	return request({
		url: '/resource/info/saveResources',
		method: 'post',
		data: params,
	});
}

export function detail2(code: string) {
	return request({
		url: '/resource/info/detail2',
		method: 'post',
        headers: {
            'Content-Type': 'application/x-www-form-urlencoded'
        },
		data: code,
	});
}
export function listResources() {
	return request({
		url: '/resource/info/listResources',
		method: 'post',
        headers: {
            'Content-Type': 'application/x-www-form-urlencoded'
        }
	});
}
export function Add(params: object) {
	return request({
		url: '/resource/info/add',
		method: 'post',
		data: params,
	});
}
export function Update(params: object) {
	return request({
		url: '/resource/info/update',
		method: 'post',
		data: params,
	});
}
export function deleteId(params: string) {
	return request({
		url: '/resource/info/delete',
		method: 'post',
        headers: {
            'Content-Type': 'application/x-www-form-urlencoded'
        },
		data: params,
	});
}
export function list(params: object) {
    return request({
		url: '/resource/info/list',
		method: 'post',
		headers: {
			'Content-Type': 'application/x-www-form-urlencoded'
			},
		params
    })
}
