From d60f583aef82b3769663e08af3f1751262e5d2a0 Mon Sep 17 00:00:00 2001 From: zhaojinfeng <121016171@qq.com> Date: Thu, 13 Jul 2023 10:20:54 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E6=8B=86=E5=88=86es=E5=92=8Ccommonjs?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- utils/resolver.d.ts | 8 +++----- utils/resolver.js | 6 +++--- utils/resolver.mjs | 32 ++++++++++++++++++++++++++++++++ 3 files changed, 38 insertions(+), 8 deletions(-) create mode 100644 utils/resolver.mjs diff --git a/utils/resolver.d.ts b/utils/resolver.d.ts index b809fc3..aac84b1 100644 --- a/utils/resolver.d.ts +++ b/utils/resolver.d.ts @@ -6,11 +6,9 @@ * @FilePath: \uni\utils\resolver.d.ts * @Description: * - */ -declare const _default: (name: string) =>({ + */ +export const resolverThzxcx: (name: string) =>({ name: string; as: string; from: string; -}) - -export default _default \ No newline at end of file +}) \ No newline at end of file diff --git a/utils/resolver.js b/utils/resolver.js index 681944e..69245d4 100644 --- a/utils/resolver.js +++ b/utils/resolver.js @@ -1,8 +1,8 @@ /* * @Author: zhaojinfeng 121016171@qq.com * @Date: 2023-06-25 10:56:32 - * @LastEditors: peerless_hero peerless_hero@outlook.com - * @LastEditTime: 2023-07-13 04:11:50 + * @LastEditors: zhaojinfeng 121016171@qq.com + * @LastEditTime: 2023-07-13 10:20:10 * @FilePath: \uni\utils\resolver.js * @Description: 自动导入组件的解析器 * @@ -20,7 +20,7 @@ function toLower(name) { return lower } -export default function (name) { +module.exports.resolverThzxcx = function (name) { if (name.startsWith('Th')) { const componentName = toLower(name.slice(2)) return { diff --git a/utils/resolver.mjs b/utils/resolver.mjs new file mode 100644 index 0000000..14862c7 --- /dev/null +++ b/utils/resolver.mjs @@ -0,0 +1,32 @@ +/* + * @Author: zhaojinfeng 121016171@qq.com + * @Date: 2023-06-25 10:56:32 + * @LastEditors: peerless_hero peerless_hero@outlook.com + * @LastEditTime: 2023-07-13 04:11:50 + * @FilePath: \uni\utils\resolver.js + * @Description: 自动导入组件的解析器 + * + */ +const reg = /[A-Z]/ + +function toLower(name) { + let lower = '' + for (let i = 0; i <= name.length - 1; i++) { + if (reg.test(name[i])) + lower += `-${name[i].toLowerCase()}` + else + lower += name[i] + } + return lower +} + +export default function resolverThzxcx(name) { + if (name.startsWith('Th')) { + const componentName = toLower(name.slice(2)) + return { + name: 'default', + as: name, + from: `@thzxcx/uni/es/${componentName}/index.vue`, + } + } +}