function main() {
	// 验证用户权限
	'use api/user/acl/excerpt.js'

	// 获取角色和菜单
	const role = SQL.query('system_sql', 'SELECT * FROM sys_roles WHERE delete_time IS NULL AND role_id = ?', USER_INFO.role_id);
	const menus = SQL.query(
		'system_sql',
		`SELECT sm.*
FROM sys_role_menus_rel srm
JOIN sys_menus sm ON srm.menu_id = sm.menu_id
WHERE srm.role_id = ? AND srm.delete_time IS NULL`,
		USER_INFO.role_id
	);
	const newUserInfo = {};
	const newRoles = {};
	const permissions = [];
	Object.keys(USER_INFO).forEach((item) => {
		newUserInfo[underscoreToCamel(item)] = USER_INFO[item];
	});

	// 从 newUserInfo 中删除不需要的属性
	delete newUserInfo.password;
	delete newUserInfo.salt;

	Object.keys(role[0]).forEach((item) => {
		newRoles[underscoreToCamel(item)] = role[0][item];
	});
	const newMenus = menus.map((itemO) => {
		if (itemO.permission) {
			permissions.push(itemO.permission);
		}
		const newObj = {};
		Object.keys(itemO).forEach((item) => {
			newObj[underscoreToCamel(item)] = itemO[item];
		});
		const meta = {
			title: newObj.menuName,
			isLink: newObj.isLink,
			isHide: newObj.isHide == 1,
			isAffix: newObj.isAffix != 1,
			isIframe: newObj.isIframe != 1,
			auth: [newObj.permission],
			icon: newObj.icon,
		};
		return {
			name: newObj.path,
			path: newObj.path,
			redirect: '',
			component: newObj.component,
			parentId: newObj.parentId == 0 ? null : newObj.parentId,
			menuId: newObj.menuId,
			menuType: newObj.menuType,
			meta,
			sort: newObj.sort
		};
	});
	newMenus.sort((a, b) => a.sort - b.sort)
	const formatRes = formatMenuData(newMenus);
	// 推送预热大文件
	// response.headers.set("Link", "<https://cdn.bootcdn.net/ajax/libs/font-awesome/6.6.0/css/all.css>; rel=preload; as=style")
	// response.headers.set("Link", "<https://cdn.bootcdn.net/ajax/libs/crypto-js/4.2.0/crypto-js.min.js>; rel=preload; as=script")
	// let dirInfo = fs.dir('app/assets')
	// for (let i = 0; i < dirInfo.length; i++) {
	// 	if (dirInfo[i].size > 1024 * 1000) { // 大小超过1MB
	// 		response.headers.add("Link", `</app/assets/${dirInfo[i].name}>; rel=preload; as=${dirInfo[i].name.split('.').pop() == 'css' ? 'style' : 'script'}`)
	// 	}
	// }
	return okMsg({ user: newUserInfo, role: newRoles, permissions: permissions, menus: formatRes });
}

function formatMenuData(data, parentId = null) {
	const newData = data.filter((item) => item.parentId == parentId);
	const coverData = [];
	newData.forEach((item) => {
		if (item.menuType != 'F')
			coverData.push({
				...item,
				children: formatMenuData(data, item.menuId),
			});
	});
	return coverData;
}
