From f1f71bd0b4892abc83f882e60924e839902f7462 Mon Sep 17 00:00:00 2001 From: expressgy Date: Thu, 4 Jul 2024 02:29:05 +0800 Subject: [PATCH] =?UTF-8?q?#=20=E6=91=B8=E6=B8=85=E4=BA=86=E5=9B=BE?= =?UTF-8?q?=E6=A0=87=E6=89=B9=E9=87=8F=E5=BC=95=E5=85=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## 给组件套壳,不在内部重新定义参数,参数会默认传递 --- src/assets/custom.css | 26 ++--- .../AntdModalTemplate/index.vue | 41 ++++++++ .../Button/AckCreateAntdButton.vue | 8 +- .../Button/CreateAntdButton.vue | 3 + .../CustomAntDesignVue/IconSelect/index.vue | 52 ++++++++++ .../AntDesignVue/CustomAntDesignVue/index.js | 10 +- .../AntDesignVue/Icon/asyncCustomIcon.js | 61 ++++++++++++ .../AntDesignVue/Icon/customIcon.js | 80 ++++++++++++++++ .../AntDesignVue/Icon/icon1/aigongju.svg | 8 ++ .../AntDesignVue/Icon/icon1/beifen.svg | 1 + .../AntDesignVue/Icon/icon1/beifenyuhuifu.svg | 1 + .../AntDesignVue/Icon/icon1/bizhi.svg | 1 + .../AntDesignVue/Icon/icon1/gouwu.svg | 1 + .../AntDesignVue/Icon/icon1/guanyu.svg | 1 + .../AntDesignVue/Icon/icon1/kuaijielan.svg | 1 + .../AntDesignVue/Icon/icon1/lianjie.svg | 1 + .../AntDesignVue/Icon/icon1/shangchuan.svg | 1 + .../AntDesignVue/Icon/icon1/sheji.svg | 1 + .../AntDesignVue/Icon/icon1/shijianriqi.svg | 1 + .../AntDesignVue/Icon/icon1/sousuokuang.svg | 1 + .../Icon/icon1/tiaozhuanzhida.svg | 1 + .../AntDesignVue/Icon/icon1/tubiao.svg | 1 + .../AntDesignVue/Icon/icon1/wangzhan.svg | 1 + .../AntDesignVue/Icon/icon1/xiaoyouxi.svg | 1 + .../AntDesignVue/Icon/icon1/yingyin.svg | 1 + .../AntDesignVue/Icon/icon1/zhuti.svg | 1 + .../AntDesignVue/Icon/icon1/zhuye.svg | 1 + .../Icon/icon1/zidingyitubiao.svg | 1 + .../AntDesignVue/Icon/icon1/zujian.svg | 1 + src/components/AntDesignVue/Icon/index.js | 25 +++++ src/components/AntDesignVue/Icon/t.js | 49 ++++++++++ src/components/AntDesignVue/Icon/test.js | 52 ++++++++++ src/components/AntDesignVue/index.js | 10 +- src/views/Auth/Dict/DictForm.vue | 94 +++++++++---------- src/views/Auth/Dict/index.vue | 21 +++-- src/views/Auth/Dict/t.vue | 18 ++++ 36 files changed, 503 insertions(+), 75 deletions(-) create mode 100644 src/components/AntDesignVue/CustomAntDesignVue/AntdModalTemplate/index.vue create mode 100644 src/components/AntDesignVue/CustomAntDesignVue/IconSelect/index.vue create mode 100644 src/components/AntDesignVue/Icon/asyncCustomIcon.js create mode 100644 src/components/AntDesignVue/Icon/customIcon.js create mode 100644 src/components/AntDesignVue/Icon/icon1/aigongju.svg create mode 100644 src/components/AntDesignVue/Icon/icon1/beifen.svg create mode 100644 src/components/AntDesignVue/Icon/icon1/beifenyuhuifu.svg create mode 100644 src/components/AntDesignVue/Icon/icon1/bizhi.svg create mode 100644 src/components/AntDesignVue/Icon/icon1/gouwu.svg create mode 100644 src/components/AntDesignVue/Icon/icon1/guanyu.svg create mode 100644 src/components/AntDesignVue/Icon/icon1/kuaijielan.svg create mode 100644 src/components/AntDesignVue/Icon/icon1/lianjie.svg create mode 100644 src/components/AntDesignVue/Icon/icon1/shangchuan.svg create mode 100644 src/components/AntDesignVue/Icon/icon1/sheji.svg create mode 100644 src/components/AntDesignVue/Icon/icon1/shijianriqi.svg create mode 100644 src/components/AntDesignVue/Icon/icon1/sousuokuang.svg create mode 100644 src/components/AntDesignVue/Icon/icon1/tiaozhuanzhida.svg create mode 100644 src/components/AntDesignVue/Icon/icon1/tubiao.svg create mode 100644 src/components/AntDesignVue/Icon/icon1/wangzhan.svg create mode 100644 src/components/AntDesignVue/Icon/icon1/xiaoyouxi.svg create mode 100644 src/components/AntDesignVue/Icon/icon1/yingyin.svg create mode 100644 src/components/AntDesignVue/Icon/icon1/zhuti.svg create mode 100644 src/components/AntDesignVue/Icon/icon1/zhuye.svg create mode 100644 src/components/AntDesignVue/Icon/icon1/zidingyitubiao.svg create mode 100644 src/components/AntDesignVue/Icon/icon1/zujian.svg create mode 100644 src/components/AntDesignVue/Icon/index.js create mode 100644 src/components/AntDesignVue/Icon/t.js create mode 100644 src/components/AntDesignVue/Icon/test.js create mode 100644 src/views/Auth/Dict/t.vue diff --git a/src/assets/custom.css b/src/assets/custom.css index a4c366e..2c0fbda 100644 --- a/src/assets/custom.css +++ b/src/assets/custom.css @@ -13,27 +13,31 @@ /* 模态框 */ .ant-modal{ position: relative; - max-height: 75vh; + max-height: 65vh; height: 900px; - overflow: hidden; + padding: 24px 20px; + /*overflow: hidden;*/ .ant-modal-content{ position: relative; box-sizing: border-box; - max-height: 100%; height: 100%; overflow: hidden; display: flex; + box-sizing: border-box; flex-direction: column; + .ant-modal-header{ + flex-shrink: 0; + } .ant-modal-body{ - height: 100%; + /*max-height: 100%;*/ + /*height: 100%;*/ + padding: 10px 0; overflow: hidden; - & > *{ - position: relative; - height: 100%; - overflow: auto; - padding: 0 5px ; - - } + flex: 1 1; + } + .ant-modal-footer{ + flex-shrink: 0; + margin-top: 0; } } } diff --git a/src/components/AntDesignVue/CustomAntDesignVue/AntdModalTemplate/index.vue b/src/components/AntDesignVue/CustomAntDesignVue/AntdModalTemplate/index.vue new file mode 100644 index 0000000..21dbfe1 --- /dev/null +++ b/src/components/AntDesignVue/CustomAntDesignVue/AntdModalTemplate/index.vue @@ -0,0 +1,41 @@ + + + + + diff --git a/src/components/AntDesignVue/CustomAntDesignVue/Button/AckCreateAntdButton.vue b/src/components/AntDesignVue/CustomAntDesignVue/Button/AckCreateAntdButton.vue index e107fea..7b955d0 100644 --- a/src/components/AntDesignVue/CustomAntDesignVue/Button/AckCreateAntdButton.vue +++ b/src/components/AntDesignVue/CustomAntDesignVue/Button/AckCreateAntdButton.vue @@ -1,7 +1,9 @@ diff --git a/src/components/AntDesignVue/CustomAntDesignVue/Button/CreateAntdButton.vue b/src/components/AntDesignVue/CustomAntDesignVue/Button/CreateAntdButton.vue index 96814ee..788a5d1 100644 --- a/src/components/AntDesignVue/CustomAntDesignVue/Button/CreateAntdButton.vue +++ b/src/components/AntDesignVue/CustomAntDesignVue/Button/CreateAntdButton.vue @@ -1,4 +1,7 @@ + + + + diff --git a/src/components/AntDesignVue/CustomAntDesignVue/index.js b/src/components/AntDesignVue/CustomAntDesignVue/index.js index 29a4eed..fd7262d 100644 --- a/src/components/AntDesignVue/CustomAntDesignVue/index.js +++ b/src/components/AntDesignVue/CustomAntDesignVue/index.js @@ -13,14 +13,20 @@ import CreateAntdButton from './Button/CreateAntdButton.vue'; import AckCreateAntdButton from './Button/AckCreateAntdButton.vue'; +import AntdModalTemplate from './AntdModalTemplate/index.vue'; +import IconSelect from './IconSelect/index.vue'; + +// console.log(AntdModalTemplate); // ! 全局导出自定义的Antd组件 export default function setupCustomAntdComponents(app) { const customComponentList = [ CreateAntdButton, // ! 主要添加按钮 - AckCreateAntdButton + AckCreateAntdButton, + AntdModalTemplate, + IconSelect, ]; for (let component of customComponentList) { - app.component(component.__name, component); + app.component(component.name, component); } } diff --git a/src/components/AntDesignVue/Icon/asyncCustomIcon.js b/src/components/AntDesignVue/Icon/asyncCustomIcon.js new file mode 100644 index 0000000..94604c3 --- /dev/null +++ b/src/components/AntDesignVue/Icon/asyncCustomIcon.js @@ -0,0 +1,61 @@ +// | ------------------------------------------------------------ +// | @版本: version 0.1 +// | @创建人: 【Nie-hotok】 +// | @E-mail: x71291@outlook.com +// | @所在项目: hoto-auth-vue3 +// | @文件描述: asyncCustomIcon.js - +// | @创建时间: 2024-07-04 00:01 +// | @更新时间: 2024-07-04 00:01 +// | @修改记录: +// | -*-*-*- (时间--修改人--修改说明) -*-*-*- +// | = +// | ------------------------------------------------------------ + +import { defineAsyncComponent, h } from 'vue'; + +const svgModules = import.meta.glob('./icon1/*.svg', { as: 'raw' }); +// console.log(svgModules); +// +// for (const [path, importFunc] of Object.entries(svgModules)) { +// +// try { +// // 解析 Promise 以获取 SVG 文本内容 +// const svgContent = await importFunc(); +// // 这里你可以对 svgContent 进行处理,例如将其转换为 URL 或 Blob 对象,或者直接使用它 +// console.log(path, svgContent); // 注意:可能需要根据实际情况访问正确的属性(如 .default) +// } catch (error) { +// console.error(`Failed to load SVG from ${path}`, error); +// } +// } + +const svgComponentList = []; + +for (const path in svgModules) { + // ! svg文件名 + const name = path.match(/\/(\w+)\.svg/)[1]; + // ! 异步组件 + const asyncSvgComponent = defineAsyncComponent(() => { + console.log('A'); + svgModules[path]().then((module) => { + console.log(module); + const svg = module.default || module; + const svgContent = svg.replace(/<\?xml.*?\?>|/g, ''); + return { + name, + cname: 'C' + name, + setup() { + return () => + h('svg', { + innerHTML: svgContent, + class: 'svg-icon', + }); + }, + }; + }).catch(e => { + console.log(e); + }); + }); + svgComponentList.push(asyncSvgComponent); +} + +export const SvgComponentList = svgComponentList; diff --git a/src/components/AntDesignVue/Icon/customIcon.js b/src/components/AntDesignVue/Icon/customIcon.js new file mode 100644 index 0000000..1e33b75 --- /dev/null +++ b/src/components/AntDesignVue/Icon/customIcon.js @@ -0,0 +1,80 @@ +// | ------------------------------------------------------------ +// | @版本: version 0.1 +// | @创建人: 【Nie-hotok】 +// | @E-mail: x71291@outlook.com +// | @所在项目: hoto-auth-vue3 +// | @文件描述: customIcon.js - +// | @创建时间: 2024-07-03 21:41 +// | @更新时间: 2024-07-03 21:41 +// | @修改记录: +// | -*-*-*- (时间--修改人--修改说明) -*-*-*- +// | = +// | ------------------------------------------------------------ +import { defineComponent, h } from 'vue'; +import Icon, { HomeOutlined } from '@ant-design/icons-vue'; + +console.log(HomeOutlined); + +const svgContentPool1 = import.meta.glob('./icon1/*.svg', { + eager: true, + query: '?raw', + import: 'default', +}); +const iconComponentList1 = []; +for (const path in svgContentPool1) { + const svgName = path.match(/\/(\w+)\.svg/)[1]; + let svgContent = svgContentPool1[path].default || svgContentPool1[path]; + svgContent = svgContent.replace(/<\?xml.*?\?>|/g, ''); + // 正则表达式,匹配并替换width和height属性为1em + const sizeReplacementRegex = /(width|height)="([^"]+)"/g; + svgContent = svgContent.replace(sizeReplacementRegex, (match, prop, value) => { + return `${prop}="1em"`; + }); + const SvgComponent = defineComponent({ + name: svgName, + cname: 'C' + svgName, + setup() { + return () => + h('div', { + innerHTML: svgContent, + attrs: { viewBox: '0 0 1024 1024' }, + }); + }, + }); + // name: SvgComponent.name, + // cname: SvgComponent.cname, + // console.log(SvgComponent); + const icon = defineComponent({ + name: SvgComponent.name, + setup(props) { + return () => + h(Icon, { + ...props, + component: SvgComponent, + }); + }, + }); + // iconComponentList1.push(SvgComponent); + iconComponentList1.push(icon); +} + +export const IconComponentList1 = iconComponentList1; +export const A = defineComponent({ + name: 'AntDesignVue', + setup() { + return () => + h(Icon, { + component: HomeOutlined, + }); + }, +}); +export const B = defineComponent({ + name: 'AntDesignVueB', + setup() { + return () => + h(Icon, { + component: iconComponentList1[0], + }); + }, +}); +export const C = iconComponentList1[0]; diff --git a/src/components/AntDesignVue/Icon/icon1/aigongju.svg b/src/components/AntDesignVue/Icon/icon1/aigongju.svg new file mode 100644 index 0000000..a45f2e7 --- /dev/null +++ b/src/components/AntDesignVue/Icon/icon1/aigongju.svg @@ -0,0 +1,8 @@ + + + + + diff --git a/src/components/AntDesignVue/Icon/icon1/beifen.svg b/src/components/AntDesignVue/Icon/icon1/beifen.svg new file mode 100644 index 0000000..a82dff9 --- /dev/null +++ b/src/components/AntDesignVue/Icon/icon1/beifen.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/src/components/AntDesignVue/Icon/icon1/beifenyuhuifu.svg b/src/components/AntDesignVue/Icon/icon1/beifenyuhuifu.svg new file mode 100644 index 0000000..68c7907 --- /dev/null +++ b/src/components/AntDesignVue/Icon/icon1/beifenyuhuifu.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/src/components/AntDesignVue/Icon/icon1/bizhi.svg b/src/components/AntDesignVue/Icon/icon1/bizhi.svg new file mode 100644 index 0000000..2beb809 --- /dev/null +++ b/src/components/AntDesignVue/Icon/icon1/bizhi.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/src/components/AntDesignVue/Icon/icon1/gouwu.svg b/src/components/AntDesignVue/Icon/icon1/gouwu.svg new file mode 100644 index 0000000..e5f273c --- /dev/null +++ b/src/components/AntDesignVue/Icon/icon1/gouwu.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/src/components/AntDesignVue/Icon/icon1/guanyu.svg b/src/components/AntDesignVue/Icon/icon1/guanyu.svg new file mode 100644 index 0000000..dee04c3 --- /dev/null +++ b/src/components/AntDesignVue/Icon/icon1/guanyu.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/src/components/AntDesignVue/Icon/icon1/kuaijielan.svg b/src/components/AntDesignVue/Icon/icon1/kuaijielan.svg new file mode 100644 index 0000000..819b80e --- /dev/null +++ b/src/components/AntDesignVue/Icon/icon1/kuaijielan.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/src/components/AntDesignVue/Icon/icon1/lianjie.svg b/src/components/AntDesignVue/Icon/icon1/lianjie.svg new file mode 100644 index 0000000..3f41ade --- /dev/null +++ b/src/components/AntDesignVue/Icon/icon1/lianjie.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/src/components/AntDesignVue/Icon/icon1/shangchuan.svg b/src/components/AntDesignVue/Icon/icon1/shangchuan.svg new file mode 100644 index 0000000..2e6893d --- /dev/null +++ b/src/components/AntDesignVue/Icon/icon1/shangchuan.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/src/components/AntDesignVue/Icon/icon1/sheji.svg b/src/components/AntDesignVue/Icon/icon1/sheji.svg new file mode 100644 index 0000000..57b6c5a --- /dev/null +++ b/src/components/AntDesignVue/Icon/icon1/sheji.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/src/components/AntDesignVue/Icon/icon1/shijianriqi.svg b/src/components/AntDesignVue/Icon/icon1/shijianriqi.svg new file mode 100644 index 0000000..2930a77 --- /dev/null +++ b/src/components/AntDesignVue/Icon/icon1/shijianriqi.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/src/components/AntDesignVue/Icon/icon1/sousuokuang.svg b/src/components/AntDesignVue/Icon/icon1/sousuokuang.svg new file mode 100644 index 0000000..bff06f2 --- /dev/null +++ b/src/components/AntDesignVue/Icon/icon1/sousuokuang.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/src/components/AntDesignVue/Icon/icon1/tiaozhuanzhida.svg b/src/components/AntDesignVue/Icon/icon1/tiaozhuanzhida.svg new file mode 100644 index 0000000..71fd0a9 --- /dev/null +++ b/src/components/AntDesignVue/Icon/icon1/tiaozhuanzhida.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/src/components/AntDesignVue/Icon/icon1/tubiao.svg b/src/components/AntDesignVue/Icon/icon1/tubiao.svg new file mode 100644 index 0000000..7b0b7e3 --- /dev/null +++ b/src/components/AntDesignVue/Icon/icon1/tubiao.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/src/components/AntDesignVue/Icon/icon1/wangzhan.svg b/src/components/AntDesignVue/Icon/icon1/wangzhan.svg new file mode 100644 index 0000000..8b6daec --- /dev/null +++ b/src/components/AntDesignVue/Icon/icon1/wangzhan.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/src/components/AntDesignVue/Icon/icon1/xiaoyouxi.svg b/src/components/AntDesignVue/Icon/icon1/xiaoyouxi.svg new file mode 100644 index 0000000..4d8d427 --- /dev/null +++ b/src/components/AntDesignVue/Icon/icon1/xiaoyouxi.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/src/components/AntDesignVue/Icon/icon1/yingyin.svg b/src/components/AntDesignVue/Icon/icon1/yingyin.svg new file mode 100644 index 0000000..b997cde --- /dev/null +++ b/src/components/AntDesignVue/Icon/icon1/yingyin.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/src/components/AntDesignVue/Icon/icon1/zhuti.svg b/src/components/AntDesignVue/Icon/icon1/zhuti.svg new file mode 100644 index 0000000..026b9a7 --- /dev/null +++ b/src/components/AntDesignVue/Icon/icon1/zhuti.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/src/components/AntDesignVue/Icon/icon1/zhuye.svg b/src/components/AntDesignVue/Icon/icon1/zhuye.svg new file mode 100644 index 0000000..bf3b409 --- /dev/null +++ b/src/components/AntDesignVue/Icon/icon1/zhuye.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/src/components/AntDesignVue/Icon/icon1/zidingyitubiao.svg b/src/components/AntDesignVue/Icon/icon1/zidingyitubiao.svg new file mode 100644 index 0000000..f41745d --- /dev/null +++ b/src/components/AntDesignVue/Icon/icon1/zidingyitubiao.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/src/components/AntDesignVue/Icon/icon1/zujian.svg b/src/components/AntDesignVue/Icon/icon1/zujian.svg new file mode 100644 index 0000000..92b2e25 --- /dev/null +++ b/src/components/AntDesignVue/Icon/icon1/zujian.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/src/components/AntDesignVue/Icon/index.js b/src/components/AntDesignVue/Icon/index.js new file mode 100644 index 0000000..84322f4 --- /dev/null +++ b/src/components/AntDesignVue/Icon/index.js @@ -0,0 +1,25 @@ +// | ------------------------------------------------------------ +// | @版本: version 0.1 +// | @创建人: 【Nie-hotok】 +// | @E-mail: x71291@outlook.com +// | @所在项目: hoto-auth-vue3 +// | @文件描述: index.js - +// | @创建时间: 2024-07-03 21:18 +// | @更新时间: 2024-07-03 21:18 +// | @修改记录: +// | -*-*-*- (时间--修改人--修改说明) -*-*-*- +// | = +// | ------------------------------------------------------------ + +import { MyIcon } from './customIcon.js'; + +// ! 全局导出Antd图标组件 +export default function setupIconAntdComponents(app) { + // const iconComponentList = [ + // { name: '', component: ''} + // ]; + // for (let item of iconComponentList) { + // app.component(item.name, item.component); + // } + app.component('MyIcon', MyIcon); +} diff --git a/src/components/AntDesignVue/Icon/t.js b/src/components/AntDesignVue/Icon/t.js new file mode 100644 index 0000000..facce56 --- /dev/null +++ b/src/components/AntDesignVue/Icon/t.js @@ -0,0 +1,49 @@ +// | ------------------------------------------------------------ +// | @版本: version 0.1 +// | @创建人: 【Nie-hotok】 +// | @E-mail: x71291@outlook.com +// | @所在项目: hoto-auth-vue3 +// | @文件描述: customIcon.js - +// | @创建时间: 2024-07-03 21:41 +// | @更新时间: 2024-07-03 21:41 +// | @修改记录: +// | -*-*-*- (时间--修改人--修改说明) -*-*-*- +// | = +// | ------------------------------------------------------------ +import { defineComponent, h } from 'vue'; +import Icon, { HomeOutlined } from '@ant-design/icons-vue'; + +const svgContentPool1 = import.meta.glob('./icon1/*.svg', { + eager: true, + query: '?raw', + import: 'default' +}); +const iconComponentList1 = []; +for (const path in svgContentPool1) { + const svgName = path.match(/\/(\w+)\.svg/)[1]; + let svgContent = svgContentPool1[path].default || svgContentPool1[path]; + svgContent = svgContent.replace(/<\?xml.*?\?>|/g, ''); + const SvgComponent = defineComponent({ + name: svgName, + cname: 'C' + svgName, + setup() { + return () => + h('div', { + innerHTML: svgContent, attrs: { viewBox: '0 0 1024 1024' } + }); + }, + }); + // name: SvgComponent.name, + // cname: SvgComponent.cname, + // console.log(SvgComponent); + const icon = defineComponent({ + name: SvgComponent.name, + setup() { + return () => h(Icon, {}, HomeOutlined); + }, + }); + // iconComponentList1.push(SvgComponent); + iconComponentList1.push(Icon); +} + +export const IconComponentList1 = iconComponentList1; diff --git a/src/components/AntDesignVue/Icon/test.js b/src/components/AntDesignVue/Icon/test.js new file mode 100644 index 0000000..10fcda2 --- /dev/null +++ b/src/components/AntDesignVue/Icon/test.js @@ -0,0 +1,52 @@ +// | ------------------------------------------------------------ +// | @版本: version 0.1 +// | @创建人: 【Nie-hotok】 +// | @E-mail: x71291@outlook.com +// | @所在项目: hoto-auth-vue3 +// | @文件描述: test.js - +// | @创建时间: 2024-07-03 22:43 +// | @更新时间: 2024-07-03 22:43 +// | @修改记录: +// | -*-*-*- (时间--修改人--修改说明) -*-*-*- +// | = +// | ------------------------------------------------------------ + +import { defineAsyncComponent, defineComponent, h } from 'vue'; + +const iconPool = import.meta.glob('./icon1/*.svg', { eager: true, as: 'raw'}); +// const iconPool = import.meta.glob('./icon1/*.svg', ); +const nameList = []; +const componentList = []; +for (const path in iconPool) { + const name = path.match(/\/(\w+)\.svg/)[1]; + nameList.push(name); + const componentConfig = iconPool[path].default || iconPool[path]; + const svgContent = componentConfig.replace(/<\?xml.*?\?>|/g, ''); + // console.log(svgContent); + const SvgComponent = defineComponent({ + name, + // setup() { + // return () => h('div',svgContent); + // }, + // setup() { + // return { + // svgContent + // }; + // }, + // render() { + // return h('div', { + // innerHTML: this.svgContent, + // class: 'svg-icon' + // }); + // } + setup() { + return () => h('div', { + innerHTML: svgContent, + }); + }, + }); + componentList.push(SvgComponent); +} + +// export const NameList = nameList; +export const ComponentList = componentList; diff --git a/src/components/AntDesignVue/index.js b/src/components/AntDesignVue/index.js index 2bfb701..eeac9db 100644 --- a/src/components/AntDesignVue/index.js +++ b/src/components/AntDesignVue/index.js @@ -24,12 +24,11 @@ import { Space, Flex, Select, - SelectOption, Textarea, Input, Radio, RadioGroup, - InputNumber, Affix, + InputNumber, Affix } from 'ant-design-vue'; import 'ant-design-vue/dist/reset.css'; @@ -55,7 +54,10 @@ export function setupCustomAntDesignVueComponents(app) { Space, // ! 间隔 Flex, // ! 弹性布局 Select, // ! 选择器 - SelectOption, // ! 选择项 + Select.Option, + Select.OptGroup, + // SelectOption, // ! 选择项 + // SelectOptGroup, // ! 选项组 Textarea, // ! 多行文本 Input, // ! 输入框 RadioGroup, // ! 单选组 @@ -66,5 +68,7 @@ export function setupCustomAntDesignVueComponents(app) { for (let component of componentList) { app.component(component.name, component); } + app.component('ASelectOption', Select.Option); + app.component('ASelectOptGroup', Select.OptGroup); setupCustomAntdComponents(app); } diff --git a/src/views/Auth/Dict/DictForm.vue b/src/views/Auth/Dict/DictForm.vue index f9ec61a..a95ab55 100644 --- a/src/views/Auth/Dict/DictForm.vue +++ b/src/views/Auth/Dict/DictForm.vue @@ -1,57 +1,45 @@ diff --git a/src/views/Auth/Dict/index.vue b/src/views/Auth/Dict/index.vue index 44d96b6..c7c2b19 100644 --- a/src/views/Auth/Dict/index.vue +++ b/src/views/Auth/Dict/index.vue @@ -1,9 +1,10 @@