generated from thzxcx/vue3
59 lines
1.4 KiB
JavaScript
59 lines
1.4 KiB
JavaScript
/*
|
|
* @Author: zhaojinfeng 121016171@qq.com
|
|
* @Date: 2023-06-25 10:56:32
|
|
* @LastEditors: zhaojinfeng 121016171@qq.com
|
|
* @LastEditTime: 2023-07-13 13:05:09
|
|
* @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 (i === 0) {
|
|
lower += name[i].toLowerCase()
|
|
continue
|
|
}
|
|
if (reg.test(name[i])) {
|
|
lower += `-${name[i].toLowerCase()}`
|
|
continue
|
|
}
|
|
lower += name[i]
|
|
}
|
|
return lower
|
|
}
|
|
|
|
module.exports.resolverThzxcx = function (name) {
|
|
if (name.startsWith('Th')) {
|
|
const componentName = toLower(name.slice(2))
|
|
return {
|
|
name: 'default',
|
|
as: name,
|
|
from: `@thzxcx/uni/packages/${componentName}/index.vue`,
|
|
}
|
|
}
|
|
}
|
|
module.exports.resolverThorUi = function (name) {
|
|
if (name.startsWith('Tui')) {
|
|
const componentName = toLower(name.slice(3))
|
|
return {
|
|
name: 'default',
|
|
as: name,
|
|
from: `thorui-uni/lib/thorui/tui-${componentName}/tui-${componentName}.vue`,
|
|
}
|
|
}
|
|
}
|
|
|
|
module.exports.resolverUniUi = function (name) {
|
|
if (name.startsWith('Tui')) {
|
|
const componentName = toLower(name.slice(3))
|
|
return {
|
|
name: 'default',
|
|
as: name,
|
|
from: `@dcloudio/uni-ui/lib/uni-${componentName}/uni-${componentName}.vue`,
|
|
}
|
|
}
|
|
}
|