- 添加基于 VbenAdmin + Vue3 + Element Plus 的前端管理系统 - 包含完整的 UI 组件库和工具链 - 支持多应用架构 (web-ele, backend-mock, playground) - 包含完整的开发规范和配置 - 修复 admin 目录的子模块问题,确保正确提交
30 lines
837 B
TypeScript
30 lines
837 B
TypeScript
import { eventHandler, getQuery } from 'h3';
|
|
import { verifyAccessToken } from '~/utils/jwt-utils';
|
|
import { MOCK_MENU_LIST } from '~/utils/mock-data';
|
|
import { unAuthorizedResponse, useResponseSuccess } from '~/utils/response';
|
|
|
|
const pathMap: Record<string, any> = { '/': 0 };
|
|
|
|
function getPaths(menus: any[]) {
|
|
menus.forEach((menu) => {
|
|
pathMap[menu.path] = String(menu.id);
|
|
if (menu.children) {
|
|
getPaths(menu.children);
|
|
}
|
|
});
|
|
}
|
|
getPaths(MOCK_MENU_LIST);
|
|
|
|
export default eventHandler(async (event) => {
|
|
const userinfo = verifyAccessToken(event);
|
|
if (!userinfo) {
|
|
return unAuthorizedResponse(event);
|
|
}
|
|
const { id, path } = getQuery(event);
|
|
|
|
return (path as string) in pathMap &&
|
|
(!id || pathMap[path as string] !== String(id))
|
|
? useResponseSuccess(true)
|
|
: useResponseSuccess(false);
|
|
});
|