Pārlūkot izejas kodu

修复icon不显示

code4eat 2 gadi atpakaļ
vecāks
revīzija
2e70efa3a9
1 mainītis faili ar 32 papildinājumiem un 6 dzēšanām
  1. 32 6
      src/app.tsx

+ 32 - 6
src/app.tsx

@@ -2,7 +2,7 @@
  * @Author: code4eat awesomedema@gmail.com
  * @Date: 2022-12-14 14:14:32
  * @LastEditors: code4eat awesomedema@gmail.com
- * @LastEditTime: 2023-04-18 17:05:04
+ * @LastEditTime: 2023-04-19 17:00:39
  * @FilePath: /BudgetManaSystem/src/app.ts
  * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
  */
@@ -17,7 +17,7 @@
 import { AxiosResponse } from '@umijs/max';
 import { message, notification } from 'antd';
 import type { RequestConfig } from 'umi';
-import {history} from 'umi';
+
 
 import iconEnum from './menuIcons.js';
 
@@ -228,8 +228,6 @@ export const request: RequestConfig = {
 
 
 export function patchClientRoutes({ routes }:{routes:any}) {
-
-  console.log({routes});
   
   const paths = [...new Array(10).keys()].map((a,index)=>({
     path: `/setting/manaPerformanceSet/reports/${index}`,
@@ -243,7 +241,7 @@ export function patchClientRoutes({ routes }:{routes:any}) {
       paths.forEach((a:any)=>{
         treeData.routes.push(a); 
       });
-      console.log({treeData});
+
       return;  
     }else{
         if(treeData.routes&&treeData.routes.length>0){
@@ -370,7 +368,35 @@ export const layout = ({ initialState, setInitialState }: { initialState: any, s
     
             setInitialState((t: any) => ({ ...t, spacicalPageParamsType: _menu,userData:JSON.parse(userData as string) }));
 
-            return mappingIcon(data);
+            //return mappingIcon(data);
+
+            
+            
+            function addIconToPath(node:any, paths:string[]) {
+              if (paths.includes(node.path)) {
+                  if(node.path == '/home'){
+                      node.icon =  <Icon component={imgNode} />;
+                  }
+                  if(node.path == '/budgetMana'){
+                    node.icon =  <Icon component={fileIcon} />;
+                  }
+                  if(node.path == '/setting'){
+                    node.icon =  <Icon component={setting} />;
+                  }
+                  if(node.path == '/reportCheck'){
+                    node.icon =  <Icon component={setting} />;
+                  }
+              }
+              if (node.children) {
+                node.children.forEach((child:any) => addIconToPath(child, paths));
+              }
+            }
+
+            data.forEach((item:any)=>{
+              addIconToPath(item,['/home','/budgetMana','/setting','/reportCheck']);
+            });
+
+            return data
           }
         }