generated from thzxcx/vue3
feat: 自动导入解析器
This commit is contained in:
29
utils/resolver.d.ts
vendored
29
utils/resolver.d.ts
vendored
@ -1,14 +1,31 @@
|
||||
/*
|
||||
* @Author: peerless_hero peerless_hero@outlook.com
|
||||
* @Date: 2023-07-13 04:11:13
|
||||
* @LastEditors: peerless_hero peerless_hero@outlook.com
|
||||
* @LastEditTime: 2023-07-13 04:15:06
|
||||
* @LastEditors: zhaojinfeng 121016171@qq.com
|
||||
* @LastEditTime: 2023-07-13 10:58:35
|
||||
* @FilePath: \uni\utils\resolver.d.ts
|
||||
* @Description:
|
||||
*
|
||||
*/
|
||||
export const resolverThzxcx: (name: string) =>({
|
||||
name: string;
|
||||
as: string;
|
||||
type ComponentResolveResult = {
|
||||
|
||||
}
|
||||
interface ImportInfo {
|
||||
as?: string;
|
||||
name?: string;
|
||||
from: string;
|
||||
})
|
||||
}
|
||||
type SideEffectsInfo = (ImportInfo | string)[] | ImportInfo | string | undefined;
|
||||
interface ComponentInfo extends ImportInfo {
|
||||
sideEffects?: SideEffectsInfo;
|
||||
}
|
||||
type ComponentResolverFunction = (name: string) => ComponentResolveResult;
|
||||
|
||||
/** ThUi 自动导入解析器 */
|
||||
export const resolverThzxcx: ComponentResolverFunction
|
||||
|
||||
/** thorui-uni 自动导入解析器 */
|
||||
export const resolverTui: ComponentResolverFunction
|
||||
|
||||
/** uni-ui 自动导入解析器 */
|
||||
export const resolveruUniUi: ComponentResolverFunction
|
||||
|
@ -2,7 +2,7 @@
|
||||
* @Author: zhaojinfeng 121016171@qq.com
|
||||
* @Date: 2023-06-25 10:56:32
|
||||
* @LastEditors: zhaojinfeng 121016171@qq.com
|
||||
* @LastEditTime: 2023-07-13 10:20:10
|
||||
* @LastEditTime: 2023-07-13 10:55:59
|
||||
* @FilePath: \uni\utils\resolver.js
|
||||
* @Description: 自动导入组件的解析器
|
||||
*
|
||||
@ -30,3 +30,24 @@ module.exports.resolverThzxcx = function (name) {
|
||||
}
|
||||
}
|
||||
}
|
||||
module.exports.resolverThzxcx = 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`,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,9 +1,9 @@
|
||||
/*
|
||||
* @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
|
||||
* @LastEditors: zhaojinfeng 121016171@qq.com
|
||||
* @LastEditTime: 2023-07-13 10:58:22
|
||||
* @FilePath: \uni\utils\resolver.mjs
|
||||
* @Description: 自动导入组件的解析器
|
||||
*
|
||||
*/
|
||||
@ -20,7 +20,7 @@ function toLower(name) {
|
||||
return lower
|
||||
}
|
||||
|
||||
export default function resolverThzxcx(name) {
|
||||
export function resolverThzxcx(name) {
|
||||
if (name.startsWith('Th')) {
|
||||
const componentName = toLower(name.slice(2))
|
||||
return {
|
||||
@ -30,3 +30,25 @@ export default function resolverThzxcx(name) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export function resolverTui(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`,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export function resolverUniUi(name) {
|
||||
if (name.startsWith('Uni')) {
|
||||
const componentName = toLower(name.slice(3))
|
||||
return {
|
||||
name: 'default',
|
||||
as: name,
|
||||
from: `@dcloudio/uni-ui/lib/uni${componentName}/uni${componentName}.vue`,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user