修正消息中心不显示

This commit is contained in:
2025-11-22 16:01:36 +08:00
parent f3a9926caf
commit 12592c5a24
15 changed files with 331 additions and 380 deletions

View File

@@ -64,7 +64,7 @@ export const menuApi = {
* @returns Promise<ResultDomain<string>> 返回菜单ID
*/
async createMenu(menu: SysMenu): Promise<ResultDomain<string>> {
const response = await api.post<string>('/menu', menu);
const response = await api.post<string>('/menus/menu', menu);
return response.data;
},
@@ -75,7 +75,7 @@ export const menuApi = {
* @returns Promise<ResultDomain<boolean>>
*/
async updateMenu(menu: SysMenu): Promise<ResultDomain<boolean>> {
const response = await api.put<boolean>(`/menus`, menu);
const response = await api.put<boolean>(`/menus/menu`, menu);
return response.data;
},
@@ -85,7 +85,7 @@ export const menuApi = {
* @returns Promise<ResultDomain<boolean>>
*/
async deleteMenu(menuID: string): Promise<ResultDomain<boolean>> {
const response = await api.delete<boolean>(`/menus`, { menuID });
const response = await api.delete<boolean>(`/menus/menu`, { menuID });
return response.data;
},

View File

@@ -195,7 +195,7 @@ $spacing-xxl: 24px;
justify-content: flex-end;
align-items: center;
padding: $spacing-md 0;
margin-top: 32px;
margin-top: auto; // 自动推到底部
// background: #F9FAFB;
border-radius: $border-radius-large;

View File

@@ -195,7 +195,6 @@ function handleWheel(event: WheelEvent) {
// 处理导航点击
function handleNavClick(menu: SysMenu) {
activeDropdown.value = null;
if (menu.url) {
router.push(menu.url);
} else if (menu.children && menu.children.length > 0) {

View File

@@ -161,14 +161,41 @@ function generateRouteFromMenu(menu: SysMenu, isTopLevel = true): RouteRecordRaw
}
// 处理子路由
if (layout && LAYOUT_MAP[layout] && !hasChildren && menu.component && isTopLevel) {
// 如果指定了布局但没有子菜单,将页面组件作为子路由
if (layout && LAYOUT_MAP[layout] && menu.component && isTopLevel) {
// 如果指定了布局,将页面组件作为子路由
route.children = [{
path: '',
name: `${menu.menuID}_page`,
component: getComponent(menu.component),
meta: route.meta
}];
// 如果还有其他子菜单,继续添加
if (hasChildren) {
const pageChildren: SysMenu[] = [];
const normalChildren: SysMenu[] = [];
menu.children!.forEach(child => {
if (child.type === MenuType.PAGE) {
pageChildren.push(child);
} else {
normalChildren.push(child);
}
});
// 添加普通子菜单
normalChildren.forEach(child => {
const childRoute = generateRouteFromMenu(child, false);
if (childRoute) {
route.children!.push(childRoute);
}
});
// PAGE 类型的菜单保存到 meta
if (pageChildren.length > 0) {
route.meta.pageChildren = pageChildren;
}
}
} else if (hasChildren) {
// 处理有子菜单的情况
route.children = [];
@@ -290,6 +317,11 @@ function getComponent(componentName: string) {
return module;
})
.catch(error => {
console.error('[路由生成] 组件加载失败:', {
原始组件名: componentName,
最终路径: componentPath,
错误: error
});
// 返回404组件
return import('@/views/public/error/404.vue').catch(() =>
Promise.resolve({

View File

@@ -346,10 +346,12 @@ onMounted(() => {
<style lang="scss" scoped>
.my-message-list {
padding: 20px;
max-width: 1200px;
margin: 0 auto;
padding: 20px;
max-width: 1200px;
margin: 0 auto;
min-height: calc(100vh - 76px - 40px);
display: flex;
flex-direction: column;
.header {
display: flex;
justify-content: space-between;