generated from thzxcx/vue3
refactor: 组件导入逻辑
This commit is contained in:
@ -2,7 +2,7 @@
|
|||||||
* @Author: zhaojinfeng 121016171@qq.com
|
* @Author: zhaojinfeng 121016171@qq.com
|
||||||
* @Date: 2023-06-25 10:56:32
|
* @Date: 2023-06-25 10:56:32
|
||||||
* @LastEditors: zhaojinfeng 121016171@qq.com
|
* @LastEditors: zhaojinfeng 121016171@qq.com
|
||||||
* @LastEditTime: 2023-07-13 12:47:21
|
* @LastEditTime: 2023-07-13 13:05:09
|
||||||
* @FilePath: \uni\utils\resolver.js
|
* @FilePath: \uni\utils\resolver.js
|
||||||
* @Description: 自动导入组件的解析器
|
* @Description: 自动导入组件的解析器
|
||||||
*
|
*
|
||||||
@ -12,21 +12,26 @@ const reg = /[A-Z]/
|
|||||||
function toLower(name) {
|
function toLower(name) {
|
||||||
let lower = ''
|
let lower = ''
|
||||||
for (let i = 0; i <= name.length - 1; i++) {
|
for (let i = 0; i <= name.length - 1; i++) {
|
||||||
if (reg.test(name[i]))
|
if (i === 0) {
|
||||||
|
lower += name[i].toLowerCase()
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
if (reg.test(name[i])) {
|
||||||
lower += `-${name[i].toLowerCase()}`
|
lower += `-${name[i].toLowerCase()}`
|
||||||
else
|
continue
|
||||||
lower += name[i]
|
}
|
||||||
|
lower += name[i]
|
||||||
}
|
}
|
||||||
return lower
|
return lower
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports.resolverThzxcx = function (name) {
|
module.exports.resolverThzxcx = function (name) {
|
||||||
if (name.startsWith('Th')) {
|
if (name.startsWith('Th')) {
|
||||||
const componentName = toLower(name.slice(2))
|
const componentName = toLower(name.slice(2)).slice(1)
|
||||||
return {
|
return {
|
||||||
name: 'default',
|
name: 'default',
|
||||||
as: name,
|
as: name,
|
||||||
from: `@thzxcx/uni/packages/th${componentName}/index.vue`,
|
from: `@thzxcx/uni/packages/${componentName}/index.vue`,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -36,7 +41,7 @@ module.exports.resolverThorUi = function (name) {
|
|||||||
return {
|
return {
|
||||||
name: 'default',
|
name: 'default',
|
||||||
as: name,
|
as: name,
|
||||||
from: `thorui-uni/lib/thorui/tui${componentName}/tui${componentName}.vue`,
|
from: `thorui-uni/lib/thorui/tui-${componentName}/tui${componentName}.vue`,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -47,7 +52,7 @@ module.exports.resolverUniUi = function (name) {
|
|||||||
return {
|
return {
|
||||||
name: 'default',
|
name: 'default',
|
||||||
as: name,
|
as: name,
|
||||||
from: `@dcloudio/uni-ui/lib/uni${componentName}/uni${componentName}.vue`,
|
from: `@dcloudio/uni-ui/lib/uni-${componentName}/uni${componentName}.vue`,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
* @Author: zhaojinfeng 121016171@qq.com
|
* @Author: zhaojinfeng 121016171@qq.com
|
||||||
* @Date: 2023-06-25 10:56:32
|
* @Date: 2023-06-25 10:56:32
|
||||||
* @LastEditors: zhaojinfeng 121016171@qq.com
|
* @LastEditors: zhaojinfeng 121016171@qq.com
|
||||||
* @LastEditTime: 2023-07-13 12:52:10
|
* @LastEditTime: 2023-07-13 13:06:00
|
||||||
* @FilePath: \uni\utils\resolver.mjs
|
* @FilePath: \uni\utils\resolver.mjs
|
||||||
* @Description: 自动导入组件的解析器
|
* @Description: 自动导入组件的解析器
|
||||||
*
|
*
|
||||||
@ -12,10 +12,15 @@ const reg = /[A-Z]/
|
|||||||
function toLower(name) {
|
function toLower(name) {
|
||||||
let lower = ''
|
let lower = ''
|
||||||
for (let i = 0; i <= name.length - 1; i++) {
|
for (let i = 0; i <= name.length - 1; i++) {
|
||||||
if (reg.test(name[i]))
|
if (i === 0) {
|
||||||
|
lower += name[i].toLowerCase()
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
if (reg.test(name[i])) {
|
||||||
lower += `-${name[i].toLowerCase()}`
|
lower += `-${name[i].toLowerCase()}`
|
||||||
else
|
continue
|
||||||
lower += name[i]
|
}
|
||||||
|
lower += name[i]
|
||||||
}
|
}
|
||||||
return lower
|
return lower
|
||||||
}
|
}
|
||||||
@ -26,7 +31,7 @@ export function resolverThzxcx(name) {
|
|||||||
return {
|
return {
|
||||||
name: 'default',
|
name: 'default',
|
||||||
as: name,
|
as: name,
|
||||||
from: `@thzxcx/uni/packages/th${componentName}/index.vue`,
|
from: `@thzxcx/uni/packages/${componentName}/index.vue`,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -37,7 +42,7 @@ export function resolverThorUi(name) {
|
|||||||
return {
|
return {
|
||||||
name: 'default',
|
name: 'default',
|
||||||
as: name,
|
as: name,
|
||||||
from: `thorui-uni/lib/thorui/tui${componentName}/tui${componentName}.vue`,
|
from: `thorui-uni/lib/thorui/tui-${componentName}/tui${componentName}.vue`,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -48,7 +53,7 @@ export function resolverUniUi(name) {
|
|||||||
return {
|
return {
|
||||||
name: 'default',
|
name: 'default',
|
||||||
as: name,
|
as: name,
|
||||||
from: `@dcloudio/uni-ui/lib/uni${componentName}/uni${componentName}.vue`,
|
from: `@dcloudio/uni-ui/lib/uni-${componentName}/uni${componentName}.vue`,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user