generated from thzxcx/vue3
54 lines
1.3 KiB
JavaScript
54 lines
1.3 KiB
JavaScript
/*
|
|
* @Author: zhaojinfeng 121016171@qq.com
|
|
* @Date: 2023-06-25 10:56:32
|
|
* @LastEditors: zhaojinfeng 121016171@qq.com
|
|
* @LastEditTime: 2023-07-13 12:47:21
|
|
* @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
|
|
}
|
|
|
|
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`,
|
|
}
|
|
}
|
|
}
|