/** * 用户模块权限 API */ import { getAccessToken } from './api'; const API_BASE = '/api/v1/auth'; /** * 获取当前用户可访问的模块 */ export async function fetchUserModules(): Promise { const token = getAccessToken(); const headers: HeadersInit = { 'Content-Type': 'application/json', }; if (token) { (headers as Record)['Authorization'] = `Bearer ${token}`; } const response = await fetch(`${API_BASE}/me/modules`, { method: 'GET', headers, }); if (!response.ok) { const error = await response.json(); throw new Error(error.message || '获取模块权限失败'); } const result = await response.json(); return result.data || []; }