From 361d7815fab4d811de930f75f5a111a7035b5bbd Mon Sep 17 00:00:00 2001
From: zhangzhen <525765282@qq.com>
Date: Fri, 16 May 2025 11:00:40 +0800
Subject: [PATCH] 使用umi icons加载svg;
---
.umirc.ts | 66 ++++++++++++++++++++----------------------------------------------
src/components/SvgIcon/index.js | 24 +++++++++++-------------
src/icons/account.svg | 3 +++
src/icons/add.svg | 3 +++
src/icons/batchSubmit.svg | 4 ++++
src/icons/batchSubmitCancel.svg | 11 +++++++++++
src/icons/bottom.svg | 3 +++
src/icons/calculator.svg | 3 +++
src/icons/card.svg | 3 +++
src/icons/check.svg | 3 +++
src/icons/close.svg | 3 +++
src/icons/copy.svg | 3 +++
src/icons/copyall.svg | 5 +++++
src/icons/custom.svg | 4 ++++
src/icons/delete.svg | 3 +++
src/icons/edit.svg | 3 +++
src/icons/export.svg | 3 +++
src/icons/function.svg | 1 +
src/icons/function2.svg | 3 +++
src/icons/gen.svg | 3 +++
src/icons/material.svg | 3 +++
src/icons/next.svg | 4 ++++
src/icons/nextpage.svg | 3 +++
src/icons/password.svg | 3 +++
src/icons/plus.svg | 3 +++
src/icons/prevpage.svg | 3 +++
src/icons/printer.svg | 5 +++++
src/icons/process.svg | 3 +++
src/icons/reload.svg | 3 +++
src/icons/rollback.svg | 3 +++
src/icons/save.svg | 3 +++
src/icons/search.svg | 3 +++
src/icons/setting.svg | 10 ++++++++++
src/icons/submit.svg | 4 ++++
src/icons/submitCancel.svg | 4 ++++
src/icons/top.svg | 3 +++
src/icons/tree.svg | 3 +++
src/icons/upload.svg | 3 +++
38 files changed, 161 insertions(+), 59 deletions(-)
create mode 100644 src/icons/account.svg
create mode 100644 src/icons/add.svg
create mode 100644 src/icons/batchSubmit.svg
create mode 100644 src/icons/batchSubmitCancel.svg
create mode 100644 src/icons/bottom.svg
create mode 100644 src/icons/calculator.svg
create mode 100644 src/icons/card.svg
create mode 100644 src/icons/check.svg
create mode 100644 src/icons/close.svg
create mode 100644 src/icons/copy.svg
create mode 100644 src/icons/copyall.svg
create mode 100644 src/icons/custom.svg
create mode 100644 src/icons/delete.svg
create mode 100644 src/icons/edit.svg
create mode 100644 src/icons/export.svg
create mode 100644 src/icons/function.svg
create mode 100644 src/icons/function2.svg
create mode 100644 src/icons/gen.svg
create mode 100644 src/icons/material.svg
create mode 100644 src/icons/next.svg
create mode 100644 src/icons/nextpage.svg
create mode 100644 src/icons/password.svg
create mode 100644 src/icons/plus.svg
create mode 100644 src/icons/prevpage.svg
create mode 100644 src/icons/printer.svg
create mode 100644 src/icons/process.svg
create mode 100644 src/icons/reload.svg
create mode 100644 src/icons/rollback.svg
create mode 100644 src/icons/save.svg
create mode 100644 src/icons/search.svg
create mode 100644 src/icons/setting.svg
create mode 100644 src/icons/submit.svg
create mode 100644 src/icons/submitCancel.svg
create mode 100644 src/icons/top.svg
create mode 100644 src/icons/tree.svg
create mode 100644 src/icons/upload.svg
diff --git a/.umirc.ts b/.umirc.ts
index c5003c7..16c950f 100644
--- a/.umirc.ts
+++ b/.umirc.ts
@@ -1,55 +1,29 @@
-import { defineConfig } from 'umi';
+import { defineConfig } from "umi";
+import { join } from "path";
+import { readdirSync } from "fs";
+
+const getIcons = () => {
+ const iconDir = join(__dirname, "src/icons");
+ return readdirSync(iconDir)
+ .filter(file => file.endsWith(".svg"))
+ .map(file => `local:${file.replace(/\.svg$/, "")}`);
+};
export default defineConfig({
routes: [
- { path: '/', redirect: '/login' },
- { path: '/login', component: '@/routes/login/login' },
+ { path: "/", redirect: "/login" },
+ { path: "/login", component: "@/routes/login/login" },
{
- path: '/indexPage',
- component: '@/routes/indexPage',
- routes: [
- { path: '/indexPage/CommonList' },
- { path: '/indexPage/CommonListA' },
- { path: '/indexPage/CommonNewBill' },
- { path: '/indexPage/CommonBill' },
- { path: '/indexPage/CommonListEdit' },
- { path: '/indexPage/CommonClassify' },
- { path: '/indexPage/eleknifemould'},
- { path: '/indexPage/elecustomer'},
- { path: '/indexPage/CommonListTab'},
- { path: '/indexPage/commonColumnList'},
- { path: '/indexPage/commonListTree'},
- { path: '/indexPage/commonListLeft'},
- { path: '/indexPage/commonGatte'},
- { path: '/indexPage/materialRequirementsPlanning'},
- { path: '/indexPage/eleteststand'},
- { path: '/indexPage/eleemployee'},
- { path: '/indexPage/elematerials'},
- { path: '/indexPage/eleproduct'},
- { path: '/indexPage/syssystemsettings'},
- { path: '/indexPage/elesupply'},
- { path: '/indexPage/eleprocess'},
- { path: '/indexPage/elecheckmodel'},
- { path: '/indexPage/sischeckphase'},
- { path: '/indexPage/sftlogininfo'},
- { path: '/indexPage/siscommonstyle'},
- { path: '/indexPage/sisproductclassify'},
- { path: '/indexPage/commonCheckBill'},
- { path: '/indexPage/workOrderNew'},
- { path: '/indexPage/workOrderPack'},
- { path: '/indexPage/workOrderPackTableTree'},
- { path: '/indexPage/workOrderResearchTableTree'},
- { path: '/indexPage/processCard'},
- { path: '/indexPage/processCardPack'},
- { path: '/indexPage/processCardPackTableTree'},
- { path: '/indexPage/processCardPackTableTreeNew'},
- { path: '/indexPage/workOrderPackTableTreeNew'},
- { path: '/indexPage/productionPlan'},
- ],
+ path: "/indexPage",
+ component: "@/routes/indexPage",
+ routes: [{ path: "*" }],
},
],
- npmClient: 'pnpm',
+ npmClient: "pnpm",
dva: {},
- plugins: ['@umijs/plugins/dist/dva'],
+ icons: {
+ include: getIcons(),
+ },
+ plugins: ["@umijs/plugins/dist/dva"],
});
diff --git a/src/components/SvgIcon/index.js b/src/components/SvgIcon/index.js
index b69eaef..400b957 100644
--- a/src/components/SvgIcon/index.js
+++ b/src/components/SvgIcon/index.js
@@ -1,22 +1,20 @@
-import React from 'react';
-
-const SvgIcon = (props) => {
- const {
- iconClass, className, size, offsetX, fill, offsetY,
- } = props;
-
+import { Icon } from "umi";
+const SvgIcon = props => {
+ const { iconClass = "add", className, size, offsetX, fill, offsetY } = props;
return (
-
+ icon={`local:${iconClass}`}
+ />
);
};
diff --git a/src/icons/account.svg b/src/icons/account.svg
new file mode 100644
index 0000000..54b547c
--- /dev/null
+++ b/src/icons/account.svg
@@ -0,0 +1,3 @@
+
diff --git a/src/icons/add.svg b/src/icons/add.svg
new file mode 100644
index 0000000..c229691
--- /dev/null
+++ b/src/icons/add.svg
@@ -0,0 +1,3 @@
+
diff --git a/src/icons/batchSubmit.svg b/src/icons/batchSubmit.svg
new file mode 100644
index 0000000..a28c473
--- /dev/null
+++ b/src/icons/batchSubmit.svg
@@ -0,0 +1,4 @@
+
\ No newline at end of file
diff --git a/src/icons/batchSubmitCancel.svg b/src/icons/batchSubmitCancel.svg
new file mode 100644
index 0000000..175d62e
--- /dev/null
+++ b/src/icons/batchSubmitCancel.svg
@@ -0,0 +1,11 @@
+
\ No newline at end of file
diff --git a/src/icons/bottom.svg b/src/icons/bottom.svg
new file mode 100644
index 0000000..2b4e9b4
--- /dev/null
+++ b/src/icons/bottom.svg
@@ -0,0 +1,3 @@
+
diff --git a/src/icons/calculator.svg b/src/icons/calculator.svg
new file mode 100644
index 0000000..4a1b94b
--- /dev/null
+++ b/src/icons/calculator.svg
@@ -0,0 +1,3 @@
+
diff --git a/src/icons/card.svg b/src/icons/card.svg
new file mode 100644
index 0000000..1982d6f
--- /dev/null
+++ b/src/icons/card.svg
@@ -0,0 +1,3 @@
+
diff --git a/src/icons/check.svg b/src/icons/check.svg
new file mode 100644
index 0000000..a9093ed
--- /dev/null
+++ b/src/icons/check.svg
@@ -0,0 +1,3 @@
+
diff --git a/src/icons/close.svg b/src/icons/close.svg
new file mode 100644
index 0000000..7d40e2d
--- /dev/null
+++ b/src/icons/close.svg
@@ -0,0 +1,3 @@
+
diff --git a/src/icons/copy.svg b/src/icons/copy.svg
new file mode 100644
index 0000000..011ccdb
--- /dev/null
+++ b/src/icons/copy.svg
@@ -0,0 +1,3 @@
+
diff --git a/src/icons/copyall.svg b/src/icons/copyall.svg
new file mode 100644
index 0000000..4dbc2f4
--- /dev/null
+++ b/src/icons/copyall.svg
@@ -0,0 +1,5 @@
+
diff --git a/src/icons/custom.svg b/src/icons/custom.svg
new file mode 100644
index 0000000..fb2373e
--- /dev/null
+++ b/src/icons/custom.svg
@@ -0,0 +1,4 @@
+
diff --git a/src/icons/delete.svg b/src/icons/delete.svg
new file mode 100644
index 0000000..7b6463f
--- /dev/null
+++ b/src/icons/delete.svg
@@ -0,0 +1,3 @@
+
diff --git a/src/icons/edit.svg b/src/icons/edit.svg
new file mode 100644
index 0000000..1d3295f
--- /dev/null
+++ b/src/icons/edit.svg
@@ -0,0 +1,3 @@
+
diff --git a/src/icons/export.svg b/src/icons/export.svg
new file mode 100644
index 0000000..d0a88e6
--- /dev/null
+++ b/src/icons/export.svg
@@ -0,0 +1,3 @@
+
diff --git a/src/icons/function.svg b/src/icons/function.svg
new file mode 100644
index 0000000..5e4b5da
--- /dev/null
+++ b/src/icons/function.svg
@@ -0,0 +1 @@
+
diff --git a/src/icons/function2.svg b/src/icons/function2.svg
new file mode 100644
index 0000000..837a15c
--- /dev/null
+++ b/src/icons/function2.svg
@@ -0,0 +1,3 @@
+
diff --git a/src/icons/gen.svg b/src/icons/gen.svg
new file mode 100644
index 0000000..a1e44db
--- /dev/null
+++ b/src/icons/gen.svg
@@ -0,0 +1,3 @@
+
diff --git a/src/icons/material.svg b/src/icons/material.svg
new file mode 100644
index 0000000..0b1be88
--- /dev/null
+++ b/src/icons/material.svg
@@ -0,0 +1,3 @@
+
diff --git a/src/icons/next.svg b/src/icons/next.svg
new file mode 100644
index 0000000..efda033
--- /dev/null
+++ b/src/icons/next.svg
@@ -0,0 +1,4 @@
+
diff --git a/src/icons/nextpage.svg b/src/icons/nextpage.svg
new file mode 100644
index 0000000..b2abde4
--- /dev/null
+++ b/src/icons/nextpage.svg
@@ -0,0 +1,3 @@
+
diff --git a/src/icons/password.svg b/src/icons/password.svg
new file mode 100644
index 0000000..38d79e0
--- /dev/null
+++ b/src/icons/password.svg
@@ -0,0 +1,3 @@
+
diff --git a/src/icons/plus.svg b/src/icons/plus.svg
new file mode 100644
index 0000000..4558a95
--- /dev/null
+++ b/src/icons/plus.svg
@@ -0,0 +1,3 @@
+
diff --git a/src/icons/prevpage.svg b/src/icons/prevpage.svg
new file mode 100644
index 0000000..7599f14
--- /dev/null
+++ b/src/icons/prevpage.svg
@@ -0,0 +1,3 @@
+
diff --git a/src/icons/printer.svg b/src/icons/printer.svg
new file mode 100644
index 0000000..040a7e8
--- /dev/null
+++ b/src/icons/printer.svg
@@ -0,0 +1,5 @@
+
diff --git a/src/icons/process.svg b/src/icons/process.svg
new file mode 100644
index 0000000..6f728fa
--- /dev/null
+++ b/src/icons/process.svg
@@ -0,0 +1,3 @@
+
diff --git a/src/icons/reload.svg b/src/icons/reload.svg
new file mode 100644
index 0000000..0dbe79f
--- /dev/null
+++ b/src/icons/reload.svg
@@ -0,0 +1,3 @@
+
diff --git a/src/icons/rollback.svg b/src/icons/rollback.svg
new file mode 100644
index 0000000..7953996
--- /dev/null
+++ b/src/icons/rollback.svg
@@ -0,0 +1,3 @@
+
diff --git a/src/icons/save.svg b/src/icons/save.svg
new file mode 100644
index 0000000..cab7281
--- /dev/null
+++ b/src/icons/save.svg
@@ -0,0 +1,3 @@
+
diff --git a/src/icons/search.svg b/src/icons/search.svg
new file mode 100644
index 0000000..c532731
--- /dev/null
+++ b/src/icons/search.svg
@@ -0,0 +1,3 @@
+
diff --git a/src/icons/setting.svg b/src/icons/setting.svg
new file mode 100644
index 0000000..9d6907e
--- /dev/null
+++ b/src/icons/setting.svg
@@ -0,0 +1,10 @@
+
diff --git a/src/icons/submit.svg b/src/icons/submit.svg
new file mode 100644
index 0000000..9e4a479
--- /dev/null
+++ b/src/icons/submit.svg
@@ -0,0 +1,4 @@
+
diff --git a/src/icons/submitCancel.svg b/src/icons/submitCancel.svg
new file mode 100644
index 0000000..d245939
--- /dev/null
+++ b/src/icons/submitCancel.svg
@@ -0,0 +1,4 @@
+
diff --git a/src/icons/top.svg b/src/icons/top.svg
new file mode 100644
index 0000000..24f4500
--- /dev/null
+++ b/src/icons/top.svg
@@ -0,0 +1,3 @@
+
diff --git a/src/icons/tree.svg b/src/icons/tree.svg
new file mode 100644
index 0000000..3687307
--- /dev/null
+++ b/src/icons/tree.svg
@@ -0,0 +1,3 @@
+
diff --git a/src/icons/upload.svg b/src/icons/upload.svg
new file mode 100644
index 0000000..5966528
--- /dev/null
+++ b/src/icons/upload.svg
@@ -0,0 +1,3 @@
+
--
libgit2 0.22.2