mirror of
https://gitee.com/qqtt-ah/ecom-dmb.git
synced 2026-11-24 20:29:19 +08:00
feat: 系统菜单增加自定义svg支持
This commit is contained in:
@@ -71,6 +71,7 @@ interface FormData {
|
||||
component: string;
|
||||
redirect: string;
|
||||
icon: string;
|
||||
iconSvg: string;
|
||||
order: number;
|
||||
type: string;
|
||||
visible: boolean;
|
||||
@@ -88,6 +89,7 @@ const formData = ref<FormData>({
|
||||
component: '',
|
||||
redirect: '',
|
||||
icon: '',
|
||||
iconSvg: '',
|
||||
order: 0,
|
||||
type: 'menu',
|
||||
visible: true,
|
||||
@@ -349,6 +351,7 @@ function open(edit: boolean, record?: MenuVO.MenuInfo) {
|
||||
component: record.component || '',
|
||||
redirect: record.redirect || '',
|
||||
icon: record.icon || '',
|
||||
iconSvg: record.iconSvg || '',
|
||||
order: record.order || 0,
|
||||
type: record.type,
|
||||
visible: record.visible === 1, // 转换为boolean
|
||||
@@ -377,6 +380,7 @@ function open(edit: boolean, record?: MenuVO.MenuInfo) {
|
||||
component: '',
|
||||
redirect: '',
|
||||
icon: '',
|
||||
iconSvg: '',
|
||||
order: 0,
|
||||
type: 'menu',
|
||||
visible: true,
|
||||
@@ -394,6 +398,7 @@ function open(edit: boolean, record?: MenuVO.MenuInfo) {
|
||||
component: '',
|
||||
redirect: '',
|
||||
icon: '',
|
||||
iconSvg: '',
|
||||
order: 0,
|
||||
type: 'menu',
|
||||
visible: true,
|
||||
@@ -479,6 +484,8 @@ async function handleSubmit() {
|
||||
const submitData = {
|
||||
...formData.value,
|
||||
parentId: formData.value.parentId ?? null,
|
||||
icon: formData.value.icon?.trim() || null,
|
||||
iconSvg: formData.value.iconSvg?.trim() || null,
|
||||
superMenu: formData.value.superMenu ? 1 : 0,
|
||||
visible: formData.value.visible ? 1 : 0,
|
||||
status: formData.value.status ? 1 : 0,
|
||||
@@ -662,6 +669,23 @@ defineExpose({
|
||||
</Popover>
|
||||
</Form.Item>
|
||||
|
||||
<Form.Item label="自定义 SVG" name="iconSvg">
|
||||
<div class="flex gap-3">
|
||||
<Input.TextArea
|
||||
v-model:value="formData.iconSvg"
|
||||
placeholder="粘贴完整 <svg>...</svg>;有值时优先于上方 Iconify 图标"
|
||||
:rows="4"
|
||||
class="flex-1"
|
||||
/>
|
||||
<div
|
||||
v-if="formData.iconSvg?.trim().startsWith('<svg')"
|
||||
class="flex size-10 shrink-0 items-center justify-center rounded border border-border [&>svg]:size-6"
|
||||
title="SVG 预览"
|
||||
v-html="formData.iconSvg"
|
||||
></div>
|
||||
</div>
|
||||
</Form.Item>
|
||||
|
||||
<Form.Item label="排序" name="order">
|
||||
<InputNumber
|
||||
v-model:value="formData.order"
|
||||
|
||||
@@ -456,7 +456,13 @@ const [Grid, gridApi] = useVbenVxeGrid({
|
||||
<!-- 图标列 -->
|
||||
<template #icon="{ row }: { row: MenuVO.MenuInfo }">
|
||||
<div
|
||||
v-if="row.icon"
|
||||
v-if="row.iconSvg?.trim()"
|
||||
class="flex items-center justify-center [&>svg]:size-4"
|
||||
title="自定义 SVG"
|
||||
v-html="row.iconSvg"
|
||||
></div>
|
||||
<div
|
||||
v-else-if="row.icon"
|
||||
class="flex items-center justify-center"
|
||||
:title="row.icon"
|
||||
>
|
||||
|
||||
Reference in New Issue
Block a user