Skip to content

Commit 611841d

Browse files
authored
feat(resolver): 新增 ZPagingResolver 用于自动导入 z-paging (#21)
1 parent 67e1ed6 commit 611841d

File tree

2 files changed

+31
-0
lines changed

2 files changed

+31
-0
lines changed

packages/core/src/_resolvers/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,4 @@ export * from './uni-ui'
33
export * from './wot-design-uni'
44
export * from './uv-ui'
55
export * from './uview-pro'
6+
export * from './z-paging'
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
import type { FilterPattern } from '@rollup/pluginutils'
2+
import type { ComponentResolver } from '../types'
3+
import { isExclude, kebabCase } from '../utils'
4+
5+
export interface ZPagingResolverOptions {
6+
/**
7+
* RegExp or string to match component names that will NOT be imported
8+
*/
9+
exclude?: FilterPattern
10+
}
11+
12+
export function ZPagingResolver(
13+
options: ZPagingResolverOptions = {},
14+
): ComponentResolver {
15+
return {
16+
type: 'component',
17+
resolve: (name: string) => {
18+
if (isExclude(name, options.exclude))
19+
return
20+
21+
if (name.match(/^(?!ZPagingRefresh|ZPagingLoadMore)ZPaging(.*)/)) {
22+
const compName = kebabCase(name)
23+
return {
24+
name,
25+
from: `z-paging/components/${compName}/${compName}.vue`,
26+
}
27+
}
28+
},
29+
}
30+
}

0 commit comments

Comments
 (0)