Selaa lähdekoodia

调整菜单icon

taosj 1 päivä sitten
vanhempi
commit
7f50e90e70

+ 4 - 0
forecast-backend-vue/src/assets/icons/OLDetection.svg

@@ -0,0 +1,4 @@
+<svg viewBox="0 0 1024 1024" xmlns="http://www.w3.org/2000/svg">
+  <path d="M511.4 116.5L878 228.8v340.9c-4 6.9-18.3 27.5-66 73.6-34.8 33.5-81 74.7-137.5 122.2C611 819 548.7 868.7 513 896.8c-35.7-28.1-98-77.8-161.5-131.2C295 718 248.8 676.8 214 643.2c-47.7-46.1-62-66.7-66-73.6v-341l363.4-112.1m-0.1-52.3L98 191.8v384.3c0 63.9 415 384.2 415 384.2S928 640 928 576V191.7L511.3 64.2z" fill="currentColor"></path>
+  <path d="M634.6 737.8L508 327.5 392 592.2l-146.6-152H128v-50h138.7l109.5 113.6 140-319.4L645.7 604l107-213.8h143.5v50H783.6z" fill="currentColor"></path>
+</svg>

+ 5 - 0
forecast-backend-vue/src/assets/icons/OLDeviceManagement.svg

@@ -0,0 +1,5 @@
+<svg viewBox="0 0 1024 1024" xmlns="http://www.w3.org/2000/svg">
+  <path d="M19.04319 295L497.04319 56.3c9.7-4.8 21-4.8 30.7 0L1005.04319 295.1c25.3 12.6 25.3 48.7 0.1 61.4L527.74319 596.7c-9.7 4.9-21.2 4.9-30.9 0L18.94319 356.4c-25.2-12.7-25.2-48.7 0.1-61.4z" fill="currentColor"></path>
+  <path d="M510.54319 791.2c-6.2 0-12.3-1.4-18-4.2L22.24319 551.6c-19.9-9.9-27.9-34.1-18-54 9.9-19.9 34.1-27.9 54-18L510.54319 706l455.3-226.3c19.9-9.9 44-1.8 53.9 18.1 9.9 19.9 1.8 44-18.1 53.9L528.44319 786.9c-5.7 2.8-11.8 4.3-17.9 4.3z" fill="currentColor"></path>
+  <path d="M510.54319 971.3c-6.2 0-12.3-1.4-18-4.2L22.24319 731.8c-19.9-9.9-27.9-34.1-18-54 9.9-19.9 34.1-27.9 54-18l452.3 226.3 455.3-226.3c19.9-9.9 44-1.8 53.9 18.1 9.9 19.9 1.8 44-18.1 53.9L528.44319 967.1c-5.7 2.8-11.8 4.2-17.9 4.2z" fill="currentColor"></path>
+</svg>

+ 7 - 0
forecast-backend-vue/src/assets/icons/OLMeteorologicalResources.svg

@@ -0,0 +1,7 @@
+<svg viewBox="0 0 1024 1024" xmlns="http://www.w3.org/2000/svg">
+  <path d="M860.645397 1024H163.354603a163.354603 163.354603 0 0 1-163.354603-163.354603V163.354603A163.354603 163.354603 0 0 1 163.354603 0h697.290794a163.354603 163.354603 0 0 1 163.354603 163.354603v697.290794a163.354603 163.354603 0 0 1-163.354603 163.354603zM163.354603 46.672744A116.68186 116.68186 0 0 0 46.672744 163.354603v697.290794a116.68186 116.68186 0 0 0 116.681859 116.681859h697.290794a116.68186 116.68186 0 0 0 116.681859-116.681859V163.354603a116.68186 116.68186 0 0 0-116.681859-116.681859z" fill="currentColor"></path>
+  <path d="M100.696445 446.424795a23.336372 23.336372 0 0 1-23.336372-23.336372V240.714676a163.354603 163.354603 0 0 1 163.354603-163.354603h271.168642a23.336372 23.336372 0 0 1 0 46.672744H240.714676a116.68186 116.68186 0 0 0-116.681859 116.681859v182.373747a23.336372 23.336372 0 0 1-23.336372 23.336372zM319.824977 597.294439a23.336372 23.336372 0 0 1-17.969006-8.517775 142.701914 142.701914 0 0 1 187.274385-210.844121 23.336372 23.336372 0 0 1-25.203282 39.205105 96.02917 96.02917 0 0 0-126.016409 142.001823 23.336372 23.336372 0 0 1-17.969006 38.154968z" fill="currentColor"></path>
+  <path d="M369.764813 557.739289a24.036463 24.036463 0 0 1-4.083865 0 23.336372 23.336372 0 0 1-18.902461-27.070191A203.493163 203.493163 0 0 1 711.759344 446.424795a23.336372 23.336372 0 1 1-37.688241 27.536919 156.820419 156.820419 0 0 0-281.203282 64.64175 23.336372 23.336372 0 0 1-23.103008 19.135825z" fill="currentColor"></path>
+  <path d="M694.723792 763.682771a23.336372 23.336372 0 1 1 0-46.672744A110.731085 110.731085 0 1 0 606.74567 539.536919a23.336372 23.336372 0 1 1-37.221513-28.23701 157.403829 157.403829 0 1 1 125.199635 252.382862z" fill="currentColor"></path>
+  <path d="M417.487694 763.682771a131.500456 131.500456 0 0 1-62.891523-246.898815 23.336372 23.336372 0 0 1 22.402917 40.955333 84.827712 84.827712 0 0 0 40.488606 159.270738h275.369188a23.336372 23.336372 0 0 1 0 46.672744zM487.030082 350.979034a23.336372 23.336372 0 0 1-17.035551-39.321787l28.003646-29.987238a23.336372 23.336372 0 0 1 34.071103 31.854148l-28.003646 29.987238a23.336372 23.336372 0 0 1-17.035552 7.467639zM374.898815 346.778487a23.336372 23.336372 0 0 1-22.636281-17.502279l-10.268003-39.788514a23.336372 23.336372 0 0 1 45.272561-11.668186l10.268004 39.788514a23.336372 23.336372 0 0 1-16.802188 28.470374 23.336372 23.336372 0 0 1-5.834093 0.700091zM267.668186 411.770283A23.336372 23.336372 0 0 1 256.700091 408.386509l-36.054694-19.602553a23.336372 23.336372 0 0 1 22.286235-41.072014l36.054694 19.602552a23.336372 23.336372 0 0 1-11.668186 43.872379zM195.208751 533.236098a23.336372 23.336372 0 0 1-2.450319-46.672743l40.838651-4.317229a23.336372 23.336372 0 0 1 4.900638 46.672744l-40.838651 4.317228z" fill="currentColor"></path>
+</svg>

+ 4 - 0
forecast-backend-vue/src/assets/icons/OLPowerForecasting.svg

@@ -0,0 +1,4 @@
+<svg viewBox="0 0 1024 1024" xmlns="http://www.w3.org/2000/svg">
+  <path d="M885.568 486.272c-23.52 0-43.904 19.648-43.904 45.824v217.6c0 49.056-39.168 89.952-86.208 89.952H236.48c-47.04 0-86.24-40.896-86.24-89.984V309.6c0-49.088 39.2-89.984 86.24-89.984h257.12c23.52 0 43.904-19.648 43.904-45.824 0-26.144-18.816-45.792-43.904-45.792H236.48C140.8 128 64 208.16 64 307.968v440.064C64 847.84 140.8 928 236.48 928h518.976c95.616 0 172.48-80.16 172.48-179.968v-215.936c1.536-24.544-18.848-45.824-42.368-45.824z" fill="currentColor"></path>
+  <path d="M445.12 701.536v52.512c0 24.64 18.944 45.952 44.192 45.952 23.68 0 44.256-19.68 44.256-45.952v-54.144c0-24.64-18.976-45.952-44.256-45.952-23.68 1.632-44.224 22.976-44.224 47.584z m-189.536-45.952v98.464c0 24.64 18.944 45.952 44.224 45.952 25.28 0 44.224-19.68 44.224-45.952v-98.464c0-24.608-18.976-45.952-44.224-45.952-25.28 0-44.224 21.344-44.224 45.952z m380.64-36.096v134.56c0 24.64 18.944 45.952 44.224 45.952 25.28 0 44.224-19.68 44.224-45.952v-136.192c0-24.64-18.976-45.952-44.224-45.952-25.28 0-44.224 21.312-44.224 47.584z m-243.232-262.56c-17.376-13.12-41.088-11.52-56.864 4.928l-131.104 134.56a45.824 45.824 0 0 0 0 64 41.792 41.792 0 0 0 61.6 0l104.256-108.32 143.712 111.584c7.904 6.592 17.376 9.856 26.88 9.856 11.04 0 22.08-4.928 31.552-13.12l230.624-239.584 57.536 59.776a16 16 0 0 0 27.008-7.104L960 96l-267.968 74.848a16 16 0 0 0-7.232 26.496l58.816 61.12-206.912 210.048-143.712-111.584z" fill="currentColor"></path>
+</svg>

+ 1 - 15
forecast-backend-vue/src/components/layout/SideMenu.vue

@@ -36,7 +36,7 @@
       <template v-for="(router, index) in menuData">
         <!-- 情况1: 当父菜单有多个子菜单时,渲染成可折叠的 SubMenu -->
         <a-sub-menu
-            v-if="router.children && router.children.length > 1"
+            v-if="router.children && router.children.length > 0"
             :key="`${router.path}-${index}`"
         >
           <template #icon>
@@ -93,20 +93,6 @@
           </template>
         </a-sub-menu>
 
-        <!-- 情况2: 当父菜单只有一个子菜单时 (包括外链),直接渲染成一个普通的 MenuItem -->
-        <a-menu-item
-            v-else-if="router.children && router.children.length === 1 && router.children[0]"
-            :key="`single-child-wrapper-${router.children[0].path}`"
-            @click="handleMenuClick(router.name, router.path, getTitle(router), router.children[0].name, router.children[0].path, getTitle(router.children[0]), router.children[0].component)"
-        >
-          <template #icon>
-            <BearJiaIcon :icon="router.children[0].meta?.icon || router.meta?.icon || 'MenuOutlined'" />
-          </template>
-          <span>{{ router.children[0].meta?.title }}</span>
-          <!-- 新增: 判断唯一的子菜单是否是外链 -->
-          <BearJiaIcon v-if="isExternal(router.children[0].path)" icon="LinkOutlined" class="external-link-icon" />
-        </a-menu-item>
-
         <!-- 情况3 (可选,容错): 没有子菜单的顶级菜单 -->
         <a-menu-item
             v-else-if="!router.children || router.children.length === 0"

+ 1 - 0
forecast-backend-vue/src/main.js

@@ -15,6 +15,7 @@ import 'ant-design-vue/dist/reset.css';
 import './plugins/dayjs';
 // 导入全局样式 (包含所有主题样式)
 import './style/global.less';
+import './style/svg.less';
 // 导入主题服务
 import { themeService } from '@/utils/theme';
 // 应用挂载后初始化配置

+ 6 - 0
forecast-backend-vue/src/style/svg.less

@@ -0,0 +1,6 @@
+.bearjia-svg-icon svg {
+  width: 1em;
+  height: 1em;
+  fill: currentColor !important;
+  vertical-align: -0.125em;
+}

+ 28 - 2
forecast-backend-vue/src/utils/BearJiaIcon.js

@@ -1,5 +1,17 @@
-import {createVNode} from 'vue';
+import {createVNode, h} from 'vue';
 import * as $Icon from '@ant-design/icons-vue';
+const svgRawModules = import.meta.glob('../assets/icons/*.svg', {
+  eager: true,
+  query: '?raw',
+  import: 'default',
+});
+
+const svgModules = Object.fromEntries(
+  Object.entries(svgRawModules).map(([path, raw]) => [
+    path.split('/').pop().replace(/\.svg$/, ''),
+    raw,
+  ])
+);
 
 // 实现动态加载antd的图标
 export const BearJiaIcon = (props) => {
@@ -79,7 +91,21 @@ export const BearJiaIcon = (props) => {
         // console.log('$Icon[iconName]=' + $Icon[iconName]);
         if ($Icon[iconName]) {
             return createVNode($Icon[iconName]);
-        } else {
+        } else if (iconName.startsWith('OL')) { // 自定义svg
+            const raw = svgModules[iconName];
+            if (raw) {
+                return h(
+                    'span',
+                    {
+                        class: 'anticon bearjia-svg-icon',
+                        role: 'img',
+                        innerHTML: raw,
+                    }
+                );
+            }
+            console.warn(`[BearJiaIcon] 未找到自定义图标: ${iconName}`);
+            return createVNode($Icon['BarsOutlined']);
+        }else {
             // 获取不到对应图标时,使用默认图标
             return createVNode($Icon['BarsOutlined']);
         }

+ 5 - 0
release_note/20261112/dml.sql

@@ -0,0 +1,5 @@
+update "public"."sys_menu" set icon = 'OLDetection' where menu_name = '测点监测';
+update "public"."sys_menu" set icon = 'OLDetection' where menu_name = '实时监控';
+update "public"."sys_menu" set icon = 'OLDeviceManagement' where menu_name = '设备管理';
+update "public"."sys_menu" set icon = 'OLMeteorologicalResources' where menu_name = '气象资源';
+update "public"."sys_menu" set icon = 'OLPowerForecasting' where menu_name = '功率预测';