index.vue 31 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292
  1. <template>
  2. <div class="home">
  3. <!-- 上半部分:校园风景图片轮播 -->
  4. <div class="carousel-section">
  5. <el-carousel :interval="4000" type="card" height="200px" indicator-position="outside" arrow="always" class="campus-carousel">
  6. <el-carousel-item v-for="(image, index) in campusImages" :key="index">
  7. <div class="carousel-item">
  8. <img :src="image.url" :alt="image.title" class="carousel-image" />
  9. <div class="carousel-overlay">
  10. <h3 class="carousel-title">{{ image.title }}</h3>
  11. </div>
  12. </div>
  13. </el-carousel-item>
  14. </el-carousel>
  15. </div>
  16. <!-- 菜单功能区域 -->
  17. <div class="menu-modules-section">
  18. <h2 class="section-title">
  19. <div class="section-icon">
  20. <img src="/src/assets/logo-img/category.svg" alt="系统功能" class="section-icon-img" />
  21. </div>
  22. 系统功能
  23. <span class="function-count" v-if="allMenuActions.length > 0"> ({{ menuModules.length }}个模块,{{ allMenuActions.length }}个功能) </span>
  24. </h2>
  25. <!-- 按模块分组显示菜单 -->
  26. <div v-for="module in menuModules" :key="module.id" class="module-group">
  27. <div class="module-header">
  28. <h3 class="module-title" style="color: #000000">
  29. <div class="module-icon-wrapper">
  30. <img src="/src/assets/logo-img/zj.svg" alt="模块图标" class="module-icon-img" />
  31. </div>
  32. {{ module.title }}
  33. <el-tag type="info" size="small" class="module-count-tag"> {{ module.menus.length }}个功能 </el-tag>
  34. </h3>
  35. <!-- <div class="module-description">{{ module.description }}</div> -->
  36. </div>
  37. <!-- 使用弹性布局替换el-row和el-col -->
  38. <div class="module-content-flex">
  39. <div v-for="menu in module.menus" :key="menu.id" class="menu-card-wrapper">
  40. <el-card shadow="hover" :class="['menu-action-card', { 'disabled': !menu.available }]" @click="handleQuickAction(menu)">
  41. <div class="menu-action">
  42. <!-- 使用随机logo图片替换图标 -->
  43. <div class="menu-logo-wrapper">
  44. <img :src="menu.logoUrl" :alt="menu.title" class="menu-logo" />
  45. </div>
  46. <span class="action-title" :class="{ 'disabled': !menu.available }">{{ menu.title }}</span>
  47. <!-- <span class="action-desc" :class="{ 'disabled': !menu.available }">{{ menu.description }}</span> -->
  48. <!-- 移除层级路径显示 -->
  49. <el-tag v-if="!menu.available" type="info" size="small" class="status-tag">开发中</el-tag>
  50. </div>
  51. </el-card>
  52. </div>
  53. </div>
  54. </div>
  55. <!-- 如果没有菜单数据,显示加载状态 -->
  56. <div v-if="menuModules.length === 0" class="loading-state">
  57. <el-empty description="正在加载菜单数据..." :image-size="100">
  58. <template #description>
  59. <p>正在从系统获取菜单权限数据...</p>
  60. <p class="loading-tips">如果长时间未加载,请检查网络连接或刷新页面</p>
  61. </template>
  62. </el-empty>
  63. </div>
  64. </div>
  65. </div>
  66. </template>
  67. <script setup name="Index" lang="ts">
  68. import { ref, onMounted, computed } from 'vue';
  69. import {
  70. User,
  71. Tools,
  72. Calendar,
  73. Service,
  74. Phone,
  75. Message,
  76. Document,
  77. DataAnalysis,
  78. Bell,
  79. Setting,
  80. Monitor,
  81. Files,
  82. Folder
  83. } from '@element-plus/icons-vue';
  84. import { ElMessage } from 'element-plus/es/components/message/index';
  85. import { useRouter } from 'vue-router';
  86. import { getCurrentInstance, ComponentInternalInstance } from 'vue';
  87. // 导入权限store来获取菜单数据
  88. import { usePermissionStore } from '@/store/modules/permission';
  89. const router = useRouter();
  90. const { proxy } = getCurrentInstance() as ComponentInternalInstance;
  91. const permissionStore = usePermissionStore();
  92. // 校园风景图片数据
  93. const campusImages = [
  94. {
  95. url: '/assets/images/01.jpg',
  96. title: '西溪校园正门'
  97. },
  98. {
  99. url: '/assets/images/02.jpg',
  100. title: '临安校区'
  101. },
  102. {
  103. url: '/assets/images/03.jpg',
  104. title: '临安校区'
  105. }
  106. ];
  107. // 菜单模块数据
  108. interface MenuModule {
  109. id: string;
  110. title: string;
  111. description: string;
  112. color: string;
  113. menus: MenuAction[];
  114. }
  115. interface MenuAction {
  116. id: string;
  117. title: string;
  118. description: string;
  119. icon: any;
  120. color: string;
  121. route: string;
  122. available: boolean;
  123. parentName?: string;
  124. fullPath?: string; // 保留但不再显示
  125. menuType?: string;
  126. visible?: string;
  127. status?: string;
  128. moduleOrder?: number; // 新增:用于模块排序
  129. menuOrder?: number; // 新增:用于菜单项排序
  130. orderNum?: number; // 新增:用于存储菜单的原始排序号
  131. logoUrl?: string; // 新增:用于存储随机logo图片路径
  132. isExternal?: boolean; // 是否外链
  133. }
  134. // 菜单模块配置
  135. const menuModules = ref<MenuModule[]>([]);
  136. const allMenuActions = ref<MenuAction[]>([]);
  137. // 根据icon名称获取对应的图标路径
  138. const getIconPath = (iconName: string): string => {
  139. // 定义可用的图标文件列表(基于logo-img目录中的实际文件)
  140. const availableSvgs = [
  141. 'workflow',
  142. 'tree',
  143. 'tree-table',
  144. 'tag',
  145. 'system',
  146. 'study',
  147. 'row',
  148. 'rate',
  149. 'radio',
  150. 'process-definition',
  151. 'people',
  152. 'peoples',
  153. 'pdf',
  154. // 'other',
  155. 'Notice',
  156. 'nested',
  157. 'my-task',
  158. 'my-copy',
  159. 'money',
  160. 'logininfor',
  161. 'log',
  162. 'lock',
  163. 'list',
  164. 'international',
  165. 'eye',
  166. 'empty',
  167. 'finish',
  168. 'email',
  169. 'education',
  170. 'edit',
  171. 'druid',
  172. 'download',
  173. 'date-range',
  174. 'dashboard',
  175. 'component',
  176. 'company',
  177. 'color',
  178. 'clipboard',
  179. 'checkbox',
  180. 'chart',
  181. 'category',
  182. 'button',
  183. 'build',
  184. '404'
  185. ];
  186. const availablePngs = [
  187. 'table',
  188. 'shopping',
  189. 'redis-list',
  190. 'post',
  191. 'my-task',
  192. 'model',
  193. 'link',
  194. 'language',
  195. 'job',
  196. 'input',
  197. 'icon',
  198. 'guide',
  199. 'form',
  200. 'finish',
  201. 'eye-open',
  202. 'experience',
  203. 'exit-fullscreen1',
  204. 'exit-fullscreen',
  205. 'excel',
  206. 'example',
  207. 'drag',
  208. 'documentation',
  209. 'dict',
  210. 'date',
  211. 'code',
  212. 'cascader',
  213. 'caret-forward',
  214. 'caret-back',
  215. 'bug',
  216. 'other',
  217. 'password'
  218. ];
  219. // 先尝试匹配.svg文件
  220. if (availableSvgs.includes(iconName)) {
  221. return `/src/assets/logo-img/${iconName}.svg`;
  222. }
  223. // 如果.svg不存在,尝试匹配.png文件
  224. if (availablePngs.includes(iconName)) {
  225. return `/src/assets/logo-img/${iconName}.png`;
  226. }
  227. // 如果都不存在,使用默认图标
  228. return `/src/assets/logo-img/other.png`;
  229. };
  230. // 图标映射
  231. const iconMap: { [key: string]: any } = {
  232. 'user': User,
  233. 'peoples': User,
  234. 'system': Setting,
  235. 'monitor': Monitor,
  236. 'tool': Tools,
  237. 'guide': Document,
  238. 'build': Tools,
  239. 'international': Files,
  240. 'bug': Tools,
  241. 'chart': DataAnalysis,
  242. 'dashboard': Monitor,
  243. 'form': Document,
  244. 'table': Files,
  245. 'tree': Files,
  246. 'tree-table': Files,
  247. 'example': Document,
  248. 'edit': Document,
  249. 'dict': Files,
  250. 'config': Setting,
  251. 'logininfor': Monitor,
  252. 'online': Monitor,
  253. 'druid': Monitor,
  254. 'server': Monitor,
  255. 'cache': Monitor,
  256. 'gen': Tools,
  257. 'swagger': Document,
  258. 'job': Tools,
  259. 'client': Service,
  260. 'tenant': User,
  261. 'package': Files,
  262. 'post': Service,
  263. 'role': Service,
  264. 'menu': Setting,
  265. 'dept': Files,
  266. 'notice': Bell,
  267. 'log': Monitor
  268. };
  269. // 模块颜色配置
  270. const moduleColors = [
  271. '#409EFF',
  272. '#67C23A',
  273. '#E6A23C',
  274. '#F56C6C',
  275. '#909399',
  276. '#9966CC',
  277. '#FF6B6B',
  278. '#4ECDC4',
  279. '#45B7D1',
  280. '#96CEB4',
  281. '#FFEAA7',
  282. '#DDA0DD'
  283. ];
  284. // 菜单数据扁平化处理函数 - 重写以正确识别多级目录结构
  285. const flattenMenus = (menus: any[], parentChain: string[] = [], parentPath = '', level = 0): MenuAction[] => {
  286. const result: MenuAction[] = [];
  287. menus.forEach((menu, menuIndex) => {
  288. // 跳过隐藏的菜单
  289. if (menu.hidden === true) {
  290. console.log(`跳过隐藏菜单: ${menu.meta?.title || menu.name}`);
  291. return;
  292. }
  293. // 添加调试信息,特别关注工作流菜单
  294. if (menu.meta?.title === '工作流' || menu.name === 'Workflow11616') {
  295. console.log('=== 工作流菜单处理开始 ===');
  296. console.log('工作流菜单原始数据:', menu);
  297. console.log('工作流菜单组件类型:', menu.component);
  298. console.log('工作流菜单是否有子菜单:', !!menu.children);
  299. console.log('工作流菜单子菜单数量:', menu.children?.length || 0);
  300. console.log('工作流菜单层级:', level);
  301. console.log('工作流菜单父路径:', parentPath);
  302. }
  303. // 识别外链菜单
  304. const rawLink = menu.meta?.link || menu.path;
  305. const isExternalLink = typeof rawLink === 'string' && /^https?:\/\//i.test(rawLink);
  306. // 构建完整路径 - 外链直接使用原始链接,内部路由按层级拼接
  307. let fullPath = menu.path;
  308. if (isExternalLink) {
  309. fullPath = rawLink;
  310. } else {
  311. // 如果当前路径不是以 '/' 开头,需要拼接父路径
  312. if (!menu.path.startsWith('/')) {
  313. if (parentPath) {
  314. // 确保父路径以 '/' 开头
  315. const normalizedParentPath = parentPath.startsWith('/') ? parentPath : '/' + parentPath;
  316. fullPath = normalizedParentPath + '/' + menu.path;
  317. } else {
  318. // 如果没有父路径但不是绝对路径,添加 '/' 前缀
  319. fullPath = '/' + menu.path;
  320. }
  321. }
  322. // 清理路径中的双斜杠
  323. fullPath = fullPath.replace(/\/+/g, '/');
  324. }
  325. // 处理有meta信息且有标题的菜单项
  326. if (menu.meta && menu.meta.title) {
  327. // 获取图标
  328. const iconKey = menu.meta.icon || 'document';
  329. const icon = iconMap[iconKey] || Document;
  330. // 获取颜色(循环使用预定义颜色)
  331. const colorIndex = result.length % moduleColors.length;
  332. const color = moduleColors[colorIndex];
  333. // 构建当前菜单的层级链
  334. const currentChain = [...parentChain];
  335. if (menu.meta.title) {
  336. currentChain.push(menu.meta.title);
  337. }
  338. // 确定一级目录名称 - 改进的层级识别逻辑
  339. let firstLevelModuleName = '';
  340. let menuPath = ''; // 用于显示层级路径
  341. let moduleOrder = 0; // 一级目录的顺序
  342. if (level === 0) {
  343. // 当前就是一级目录
  344. firstLevelModuleName = menu.meta.title;
  345. menuPath = menu.meta.title;
  346. moduleOrder = menuIndex; // 使用一级目录在API中的原始索引
  347. } else {
  348. // 从层级链中取第一个作为一级目录
  349. firstLevelModuleName = currentChain[0] || '其他功能';
  350. // 构建完整的层级路径(一级 > 二级 > 菜单)
  351. menuPath = currentChain.join(' > ');
  352. // 对于子菜单,使用父级的模块顺序
  353. moduleOrder = Math.floor(menuIndex / 1000); // 简单的模块顺序推算
  354. }
  355. // 检查是否有可见的子菜单
  356. const hasVisibleChildren = menu.children && menu.children.some((child: any) => !child.hidden);
  357. // 检查是否为目录类型菜单
  358. // 1. 组件为Layout或ParentView字符串
  359. // 2. 组件为Vue对象且没有子菜单(可能是目录)
  360. // 3. menuType为'M'(目录类型)
  361. const isDirectoryMenu =
  362. !isExternalLink &&
  363. (menu.component === 'Layout' ||
  364. menu.component === 'ParentView' ||
  365. (typeof menu.component === 'object' && !hasVisibleChildren) ||
  366. menu.menuType === 'M');
  367. // 添加工作流菜单的详细调试信息
  368. if (menu.meta?.title === '工作流' || menu.name === 'Workflow11616') {
  369. console.log('=== 工作流菜单判断过程 ===');
  370. console.log('hasVisibleChildren:', hasVisibleChildren);
  371. console.log('isDirectoryMenu:', isDirectoryMenu);
  372. console.log('menu.component:', menu.component);
  373. console.log('menu.component类型:', typeof menu.component);
  374. console.log('menu.menuType:', menu.menuType);
  375. console.log('menu.children:', menu.children);
  376. console.log('fullPath:', fullPath);
  377. console.log('level:', level);
  378. console.log('是否应该创建菜单项:', !hasVisibleChildren && !isDirectoryMenu && fullPath && fullPath !== '/');
  379. console.log('完整菜单对象:', JSON.stringify(menu, null, 2));
  380. }
  381. // 目录菜单处理逻辑:如果是目录菜单且没有子菜单,直接跳过
  382. if (isDirectoryMenu && !hasVisibleChildren) {
  383. if (menu.meta?.title === '工作流' || menu.name === 'Workflow11616') {
  384. console.log('=== 工作流菜单被跳过 ===');
  385. console.log('原因: 是目录菜单且没有子菜单');
  386. }
  387. // 不创建菜单项,直接跳过
  388. }
  389. // 只有叶子节点(没有子菜单或子菜单都是隐藏的)且不是目录菜单才作为可点击的菜单项
  390. else if ((!hasVisibleChildren && !isDirectoryMenu && fullPath && fullPath !== '/') || (isExternalLink && fullPath)) {
  391. const menuAction: MenuAction = {
  392. id: `menu-${menu.name || fullPath}`,
  393. title: menu.meta.title,
  394. description: menu.meta.title + '功能',
  395. icon: icon,
  396. color: color,
  397. route: fullPath,
  398. available: true,
  399. parentName: firstLevelModuleName, // 使用一级目录名称进行分组
  400. fullPath: menuPath, // 保存完整的层级路径用于显示
  401. menuType: menu.menuType || 'C',
  402. visible: menu.visible || '0',
  403. status: menu.status || '0',
  404. moduleOrder: moduleOrder, // 添加模块顺序
  405. menuOrder: menuIndex, // 添加菜单在当前层级的顺序
  406. orderNum: menu.orderNum || 0, // 添加菜单的原始排序号
  407. logoUrl: getIconPath(iconKey), // 根据icon名称获取对应图标
  408. isExternal: isExternalLink
  409. };
  410. // 添加调试日志来验证路径构建和排序
  411. console.log(
  412. `菜单项路径构建: ${menu.meta.title} - 原始path: ${menu.path}, 构建后fullPath: ${fullPath}, orderNum: ${menu.orderNum}, parentPath: ${parentPath}, level: ${level}`
  413. );
  414. result.push(menuAction);
  415. } else if (menu.meta?.title === '工作流' || menu.name === 'Workflow11616') {
  416. console.log('=== 工作流菜单被过滤掉 ===');
  417. console.log('原因: 是目录菜单或没有有效路径');
  418. }
  419. }
  420. // 递归处理子菜单 - 传递完整的层级链
  421. if (menu.children && menu.children.length > 0) {
  422. const newChain = [...parentChain];
  423. if (menu.meta?.title) {
  424. newChain.push(menu.meta.title);
  425. }
  426. // 构建子菜单的父路径 - 使用已经构建好的完整路径
  427. let childParentPath = fullPath;
  428. // 如果当前菜单是目录(没有组件或组件为Layout/ParentView),则传递fullPath作为父路径
  429. // 否则传递当前菜单的路径
  430. if (!menu.component || menu.component === 'Layout' || menu.component === 'ParentView') {
  431. childParentPath = fullPath;
  432. } else {
  433. // 对于有具体组件的菜单,子菜单路径应该基于当前路径构建
  434. childParentPath = fullPath;
  435. }
  436. // 递归处理,传递层级链和增加的层级
  437. const childMenus = flattenMenus(menu.children, newChain, childParentPath, level + 1);
  438. result.push(...childMenus);
  439. }
  440. });
  441. return result;
  442. };
  443. // 按一级目录分组菜单 - 保持API原始顺序
  444. const groupMenusByModule = (menus: MenuAction[]): MenuModule[] => {
  445. const moduleMap = new Map<string, { menus: MenuAction[]; order: number }>();
  446. menus.forEach((menu) => {
  447. const moduleName = menu.parentName || '其他功能';
  448. if (!moduleMap.has(moduleName)) {
  449. moduleMap.set(moduleName, {
  450. menus: [],
  451. order: menu.moduleOrder || 999 // 使用菜单的模块顺序,默认排在最后
  452. });
  453. }
  454. moduleMap.get(moduleName)!.menus.push(menu);
  455. });
  456. const modules: MenuModule[] = [];
  457. let colorIndex = 0;
  458. // 按模块的原始顺序排序,而不是按名称排序
  459. const sortedModuleEntries = Array.from(moduleMap.entries()).sort((a, b) => {
  460. return a[1].order - b[1].order;
  461. });
  462. sortedModuleEntries.forEach(([moduleName, moduleData]) => {
  463. const moduleMenus = moduleData.menus;
  464. // 过滤掉无效的模块
  465. if (moduleMenus.length === 0) {
  466. return;
  467. }
  468. // 按orderNum排序前的日志
  469. console.log(
  470. `${moduleName}模块排序前:`,
  471. moduleMenus.map((m) => `${m.title}(${m.orderNum})`)
  472. );
  473. const sortedMenus = moduleMenus.sort((a, b) => (a.orderNum || 0) - (b.orderNum || 0));
  474. // 按orderNum排序后的日志
  475. console.log(
  476. `${moduleName}模块排序后:`,
  477. sortedMenus.map((m) => `${m.title}(${m.orderNum})`)
  478. );
  479. const module: MenuModule = {
  480. id: `module-${moduleName}`,
  481. title: moduleName,
  482. description: `${moduleName}模块包含${moduleMenus.length}个功能`,
  483. color: moduleColors[colorIndex % moduleColors.length],
  484. // 菜单项按原始orderNum排序,确保显示顺序正确
  485. menus: sortedMenus
  486. };
  487. modules.push(module);
  488. colorIndex++;
  489. });
  490. return modules;
  491. };
  492. // 获取菜单数据 - 使用permissionStore
  493. const loadMenuData = async () => {
  494. try {
  495. // 从权限store获取顶部栏菜单数据(包含更完整的结构)
  496. const topbarRoutes = permissionStore.getTopbarRoutes();
  497. console.log('获取到的顶部栏路由数据:', topbarRoutes);
  498. // 如果顶部栏数据为空,尝试获取侧边栏数据
  499. const routesToProcess = topbarRoutes && topbarRoutes.length > 0 ? topbarRoutes : permissionStore.getSidebarRoutes();
  500. // 过滤掉系统路由
  501. const dynamicRoutes = routesToProcess.filter(
  502. (route) =>
  503. route.path !== '/' && route.path !== '/index' && route.path !== '/user' && !route.path.startsWith('/redirect') && route.hidden !== true
  504. );
  505. console.log('处理的动态路由数据:', dynamicRoutes);
  506. // 扁平化菜单数据
  507. const flatMenus = flattenMenus(dynamicRoutes);
  508. allMenuActions.value = flatMenus;
  509. // 按模块分组
  510. const modules = groupMenusByModule(flatMenus);
  511. menuModules.value = modules;
  512. console.log('菜单数据处理完成', { flatMenus, modules });
  513. } catch (error) {
  514. console.error('获取菜单数据失败:', error);
  515. ElMessage.error('获取菜单数据失败');
  516. }
  517. };
  518. // 处理快捷功能点击
  519. const handleQuickAction = (action: any) => {
  520. // 检查功能是否可用
  521. if (!action.available) {
  522. ElMessage.warning(`${action.title}功能正在开发中,敬请期待!`);
  523. return;
  524. }
  525. console.log('action', action);
  526. // 外链菜单:在新标签页直接打开原始地址,不拼接
  527. if (action.isExternal) {
  528. window.open(action.route, '_blank');
  529. ElMessage.success(`正在打开${action.title}...`);
  530. return;
  531. }
  532. try {
  533. // 使用路由跳转,系统会自动在tab页中打开
  534. router
  535. .push(action.route)
  536. .then(() => {
  537. ElMessage.success(`正在打开${action.title}...`);
  538. })
  539. .catch((error) => {
  540. console.error('路由跳转失败:', error);
  541. // 如果路由不存在,显示提示信息
  542. if (error.name === 'NavigationFailure') {
  543. ElMessage.warning(`${action.title}功能正在开发中,敬请期待!`);
  544. } else {
  545. ElMessage.error(`打开${action.title}失败,请稍后重试`);
  546. }
  547. });
  548. } catch (error) {
  549. console.error('快捷功能点击处理失败:', error);
  550. ElMessage.error(`打开${action.title}失败,请稍后重试`);
  551. }
  552. };
  553. // 组件挂载后加载数据
  554. onMounted(async () => {
  555. // 等待权限数据加载完成,如果还没有数据则等待一段时间
  556. const checkAndLoadMenuData = async () => {
  557. let retries = 0;
  558. const maxRetries = 10;
  559. while (retries < maxRetries) {
  560. const sidebarRoutes = permissionStore.getSidebarRoutes();
  561. if (sidebarRoutes && sidebarRoutes.length > 0) {
  562. // 权限数据已加载,可以处理菜单
  563. await loadMenuData();
  564. console.log('首页菜单数据加载完成');
  565. return;
  566. }
  567. // 等待100ms后重试
  568. await new Promise((resolve) => setTimeout(resolve, 100));
  569. retries++;
  570. }
  571. console.warn('权限数据加载超时,使用空菜单');
  572. menuModules.value = [];
  573. };
  574. await checkAndLoadMenuData();
  575. });
  576. </script>
  577. <style lang="scss" scoped>
  578. .home {
  579. // min-height: calc(100vh - 200px);
  580. // background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
  581. }
  582. // 上半部分:轮播图样式
  583. .carousel-section {
  584. padding: 0 10px;
  585. margin-bottom: 20px;
  586. margin-top: 20px;
  587. // background: rgba(255, 255, 255, 0.1);
  588. backdrop-filter: blur(5px);
  589. }
  590. .campus-carousel {
  591. // max-width: 1200px;
  592. margin: 0 auto;
  593. border-radius: 16px;
  594. overflow: hidden;
  595. box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
  596. :deep(.el-carousel__item) {
  597. border-radius: 16px;
  598. }
  599. }
  600. .carousel-item {
  601. position: relative;
  602. width: 100%;
  603. height: 100%;
  604. overflow: hidden;
  605. border-radius: 16px;
  606. }
  607. .carousel-image {
  608. width: 100%;
  609. height: 100%;
  610. object-fit: cover;
  611. transition: transform 0.3s ease;
  612. }
  613. .carousel-item:hover .carousel-image {
  614. transform: scale(1.05);
  615. }
  616. .carousel-overlay {
  617. position: absolute;
  618. bottom: 0;
  619. left: 0;
  620. right: 0;
  621. // background: linear-gradient(transparent, rgba(0, 0, 0, 0.7));
  622. color: white;
  623. padding: 40px 30px 30px;
  624. text-align: left;
  625. }
  626. .carousel-title {
  627. font-size: 24px;
  628. font-weight: 600;
  629. margin: 0 0 10px 0;
  630. text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.5);
  631. }
  632. .carousel-description {
  633. font-size: 16px;
  634. margin: 0;
  635. opacity: 0.9;
  636. text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.5);
  637. line-height: 1.5;
  638. }
  639. // 下半部分:原有样式
  640. .construction-container {
  641. width: 100%;
  642. max-width: 800px;
  643. padding: 40px;
  644. margin: 0 auto;
  645. }
  646. .construction-content {
  647. text-align: center;
  648. background: rgba(255, 255, 255, 0.95);
  649. backdrop-filter: blur(10px);
  650. border-radius: 20px;
  651. padding: 60px 40px;
  652. box-shadow: 0 20px 40px rgba(0, 0, 0, 0.1);
  653. border: 1px solid rgba(255, 255, 255, 0.2);
  654. }
  655. .system-title {
  656. font-size: 28px;
  657. font-weight: 600;
  658. color: #2c3e50;
  659. margin-bottom: 40px;
  660. letter-spacing: 1px;
  661. }
  662. .construction-icon {
  663. margin-bottom: 30px;
  664. animation: float 3s ease-in-out infinite;
  665. }
  666. @keyframes float {
  667. 0%,
  668. 100% {
  669. transform: translateY(0px);
  670. }
  671. 50% {
  672. transform: translateY(-10px);
  673. }
  674. }
  675. .construction-text {
  676. margin-bottom: 40px;
  677. h2 {
  678. font-size: 24px;
  679. font-weight: 500;
  680. color: #409eff;
  681. margin-bottom: 15px;
  682. }
  683. .description {
  684. font-size: 16px;
  685. color: #606266;
  686. margin-bottom: 10px;
  687. line-height: 1.6;
  688. }
  689. .sub-description {
  690. font-size: 14px;
  691. color: #909399;
  692. line-height: 1.5;
  693. }
  694. }
  695. .progress-section {
  696. margin-bottom: 30px;
  697. .progress-label {
  698. font-size: 14px;
  699. color: #606266;
  700. margin-bottom: 10px;
  701. font-weight: 500;
  702. }
  703. .progress-bar {
  704. max-width: 200px;
  705. margin: 0 auto;
  706. }
  707. }
  708. .completion-info {
  709. margin-bottom: 40px;
  710. .el-tag {
  711. padding: 12px 20px;
  712. font-size: 14px;
  713. .tag-icon {
  714. margin-right: 8px;
  715. }
  716. }
  717. }
  718. .contact-section {
  719. max-width: 200px;
  720. margin: 0 auto;
  721. }
  722. .contact-card {
  723. border-radius: 12px;
  724. border: none;
  725. .card-header {
  726. display: flex;
  727. align-items: center;
  728. gap: 8px;
  729. font-weight: 500;
  730. color: #409eff;
  731. }
  732. }
  733. .contact-content {
  734. p {
  735. display: flex;
  736. align-items: center;
  737. gap: 10px;
  738. margin-bottom: 12px;
  739. font-size: 14px;
  740. color: #606266;
  741. &:last-child {
  742. margin-bottom: 0;
  743. }
  744. .el-icon {
  745. color: #409eff;
  746. }
  747. }
  748. }
  749. // 菜单功能区域样式
  750. .menu-modules-section {
  751. padding: 20px 10px;
  752. background: rgba(255, 255, 255, 0.95);
  753. backdrop-filter: blur(10px);
  754. border-radius: 16px;
  755. margin-bottom: 20px;
  756. box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
  757. border: 1px solid rgba(255, 255, 255, 0.2);
  758. margin-left: 10px;
  759. margin-right: 10px;
  760. }
  761. .section-title {
  762. font-size: 24px;
  763. font-weight: 700;
  764. color: #2c3e50;
  765. margin-bottom: 25px;
  766. display: flex;
  767. align-items: center;
  768. gap: 12px;
  769. padding-bottom: 15px;
  770. border-bottom: 2px solid #f1f2f6;
  771. .section-icon {
  772. display: flex;
  773. align-items: center;
  774. justify-content: center;
  775. }
  776. .section-icon-img {
  777. width: 28px;
  778. height: 28px;
  779. object-fit: contain;
  780. }
  781. .function-count {
  782. font-size: 14px;
  783. font-weight: 400;
  784. color: #909399;
  785. margin-left: 10px;
  786. }
  787. }
  788. .module-group {
  789. margin-bottom: 35px;
  790. padding: 20px;
  791. background: rgba(255, 255, 255, 0.8);
  792. border-radius: 12px;
  793. border: 1px solid rgba(0, 0, 0, 0.05);
  794. transition: all 0.3s ease;
  795. &:hover {
  796. box-shadow: 0 8px 25px rgba(0, 0, 0, 0.1);
  797. transform: translateY(-2px);
  798. }
  799. &:last-child {
  800. margin-bottom: 0;
  801. }
  802. }
  803. .module-header {
  804. display: flex;
  805. flex-direction: column;
  806. gap: 8px;
  807. margin-bottom: 20px;
  808. padding-bottom: 15px;
  809. border-bottom: 1px solid rgba(0, 0, 0, 0.1);
  810. }
  811. .module-title {
  812. font-size: 18px;
  813. font-weight: 600;
  814. display: flex;
  815. align-items: center;
  816. gap: 8px;
  817. .module-icon-wrapper {
  818. display: flex;
  819. align-items: center;
  820. justify-content: center;
  821. }
  822. .module-icon-img {
  823. width: 20px;
  824. height: 20px;
  825. object-fit: contain;
  826. }
  827. .module-count-tag {
  828. margin-left: 10px;
  829. font-weight: 400;
  830. }
  831. }
  832. .module-description {
  833. font-size: 14px;
  834. color: #606266;
  835. line-height: 1.5;
  836. padding-left: 28px; // 与图标对齐
  837. }
  838. .module-content {
  839. margin-top: 15px;
  840. }
  841. // 新增弹性布局样式
  842. .module-content-flex {
  843. display: flex;
  844. flex-wrap: wrap;
  845. gap: 20px;
  846. margin-top: 15px;
  847. justify-content: flex-start;
  848. }
  849. .menu-card-wrapper {
  850. flex: 0 0 calc((100% - 140px) / 8); // 每行8个,精确计算:(100% - 7个间隔*20px) / 8
  851. min-width: 100px;
  852. margin-bottom: 20px;
  853. @media (max-width: 1600px) {
  854. flex: 0 0 calc((100% - 120px) / 7); // 中大屏幕每行7个
  855. }
  856. @media (max-width: 1400px) {
  857. flex: 0 0 calc((100% - 100px) / 6); // 中等屏幕每行6个
  858. }
  859. @media (max-width: 1200px) {
  860. flex: 0 0 calc((100% - 80px) / 5); // 小屏幕每行5个
  861. }
  862. @media (max-width: 992px) {
  863. flex: 0 0 calc((100% - 60px) / 4); // 平板每行4个
  864. }
  865. @media (max-width: 768px) {
  866. flex: 0 0 calc((100% - 40px) / 3); // 移动端每行3个
  867. }
  868. @media (max-width: 600px) {
  869. flex: 0 0 calc((100% - 20px) / 2); // 小手机每行2个
  870. }
  871. @media (max-width: 480px) {
  872. flex: 0 0 calc(100% - 20px); // 超小屏幕每行1个
  873. }
  874. }
  875. .menu-action-card {
  876. border-radius: 12px;
  877. border: none;
  878. transition: all 0.3s ease;
  879. cursor: pointer;
  880. height: 110px;
  881. display: flex;
  882. align-items: center;
  883. justify-content: center;
  884. &:hover {
  885. transform: translateY(-5px);
  886. box-shadow: 0 12px 24px rgba(0, 0, 0, 0.15);
  887. }
  888. &.disabled {
  889. cursor: not-allowed;
  890. opacity: 0.6;
  891. &:hover {
  892. transform: none;
  893. box-shadow: none;
  894. }
  895. }
  896. }
  897. .menu-action {
  898. text-align: center;
  899. padding: 10px 8px;
  900. width: 100%;
  901. }
  902. // 原图标样式(保留以防需要)
  903. .menu-icon {
  904. font-size: 36px;
  905. margin-bottom: 12px;
  906. display: block;
  907. }
  908. // 新增logo图片样式
  909. .menu-logo-wrapper {
  910. display: flex;
  911. justify-content: center;
  912. align-items: center;
  913. margin-bottom: 8px;
  914. height: 36px;
  915. }
  916. .menu-logo {
  917. width: 36px;
  918. height: 36px;
  919. object-fit: contain;
  920. border-radius: 6px;
  921. transition: all 0.3s ease;
  922. filter: drop-shadow(0 2px 8px rgba(0, 0, 0, 0.1));
  923. &:hover {
  924. transform: scale(1.1);
  925. filter: drop-shadow(0 4px 12px rgba(0, 0, 0, 0.15));
  926. }
  927. }
  928. .loading-state {
  929. text-align: center;
  930. padding: 60px 20px;
  931. .loading-tips {
  932. font-size: 12px;
  933. color: #909399;
  934. margin-top: 8px;
  935. }
  936. }
  937. .action-title {
  938. font-size: 14px;
  939. font-weight: 600;
  940. color: #333;
  941. margin-bottom: 4px;
  942. display: block;
  943. line-height: 1.3;
  944. }
  945. .action-desc {
  946. font-size: 11px;
  947. color: #666;
  948. display: block;
  949. line-height: 1.4;
  950. &.disabled {
  951. color: #c0c4cc;
  952. }
  953. }
  954. // .action-path 样式已移除,因为不再显示层级路径
  955. .action-title.disabled {
  956. color: #c0c4cc;
  957. }
  958. .status-tag {
  959. margin-top: 8px;
  960. display: inline-block;
  961. }
  962. // 响应式设计
  963. @media (max-width: 768px) {
  964. .carousel-section {
  965. padding: 20px 10px;
  966. }
  967. .campus-carousel {
  968. height: 300px !important;
  969. }
  970. .carousel-overlay {
  971. padding: 30px 20px 20px;
  972. }
  973. .carousel-title {
  974. font-size: 20px;
  975. }
  976. .carousel-description {
  977. font-size: 14px;
  978. }
  979. .menu-modules-section {
  980. padding: 15px 10px;
  981. margin: 10px;
  982. }
  983. .section-title {
  984. font-size: 20px;
  985. margin-bottom: 20px;
  986. flex-direction: column;
  987. gap: 8px;
  988. text-align: center;
  989. .function-count {
  990. margin-left: 0;
  991. }
  992. }
  993. .module-group {
  994. padding: 15px;
  995. margin-bottom: 25px;
  996. }
  997. .module-header {
  998. margin-bottom: 15px;
  999. }
  1000. .module-title {
  1001. font-size: 16px;
  1002. justify-content: center;
  1003. text-align: center;
  1004. }
  1005. .module-description {
  1006. text-align: center;
  1007. padding-left: 0;
  1008. font-size: 13px;
  1009. }
  1010. .module-content-flex {
  1011. gap: 15px;
  1012. }
  1013. .menu-card-wrapper {
  1014. margin-bottom: 15px;
  1015. }
  1016. .menu-action-card {
  1017. height: 100px;
  1018. }
  1019. .menu-action {
  1020. padding: 8px 5px;
  1021. }
  1022. .menu-logo-wrapper {
  1023. height: 30px;
  1024. margin-bottom: 6px;
  1025. }
  1026. .menu-logo {
  1027. width: 30px;
  1028. height: 30px;
  1029. }
  1030. .action-title {
  1031. font-size: 13px;
  1032. }
  1033. .action-desc {
  1034. font-size: 10px;
  1035. }
  1036. .loading-state {
  1037. padding: 40px 10px;
  1038. }
  1039. }
  1040. // 深色主题适配
  1041. html.dark {
  1042. .carousel-section {
  1043. background: rgba(0, 0, 0, 0.1);
  1044. }
  1045. .menu-modules-section {
  1046. background: rgba(30, 30, 30, 0.95);
  1047. border: 1px solid rgba(255, 255, 255, 0.1);
  1048. }
  1049. .section-title {
  1050. color: #e5eaf3;
  1051. border-bottom: 2px solid #404040;
  1052. }
  1053. .module-group {
  1054. background: rgba(40, 40, 40, 0.8);
  1055. border: 1px solid rgba(255, 255, 255, 0.1);
  1056. &:hover {
  1057. box-shadow: 0 8px 25px rgba(0, 0, 0, 0.3);
  1058. }
  1059. }
  1060. .module-header {
  1061. border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  1062. }
  1063. .module-title {
  1064. color: #000000 !important;
  1065. }
  1066. .module-description {
  1067. color: #a3a6ad;
  1068. }
  1069. .menu-action-card {
  1070. background: rgba(50, 50, 50, 0.8);
  1071. border: 1px solid rgba(255, 255, 255, 0.1);
  1072. &:hover {
  1073. background: rgba(60, 60, 60, 0.9);
  1074. box-shadow: 0 12px 24px rgba(0, 0, 0, 0.3);
  1075. }
  1076. }
  1077. .action-title {
  1078. color: #e5eaf3;
  1079. &.disabled {
  1080. color: #6c6e72;
  1081. }
  1082. }
  1083. .action-desc {
  1084. color: #a3a6ad;
  1085. &.disabled {
  1086. color: #6c6e72;
  1087. }
  1088. }
  1089. .construction-content {
  1090. background: rgba(30, 30, 30, 0.95);
  1091. border: 1px solid rgba(255, 255, 255, 0.1);
  1092. }
  1093. .system-title {
  1094. color: #e5eaf3;
  1095. }
  1096. .construction-text {
  1097. .description {
  1098. color: #a3a6ad;
  1099. }
  1100. .sub-description {
  1101. color: #6c6e72;
  1102. }
  1103. }
  1104. .progress-section .progress-label {
  1105. color: #a3a6ad;
  1106. }
  1107. .contact-content p {
  1108. color: #a3a6ad;
  1109. }
  1110. }
  1111. </style>