yc-vep-ui 0.0.30 → 0.0.31
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/resolver.cjs +133 -0
- package/dist/resolver.d.ts +16 -0
- package/dist/resolver.mjs +133 -0
- package/package.json +7 -1
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* unplugin-vue-components 解析器
|
|
3
|
+
* 用于自动导入 yc-vep-ui 组件
|
|
4
|
+
*
|
|
5
|
+
* 使用方式:
|
|
6
|
+
* ```ts
|
|
7
|
+
* import Components from 'unplugin-vue-components/vite'
|
|
8
|
+
* import { YcVepUiResolver } from 'yc-vep-ui/resolver'
|
|
9
|
+
*
|
|
10
|
+
* export default defineConfig({
|
|
11
|
+
* plugins: [
|
|
12
|
+
* Components({
|
|
13
|
+
* resolvers: [YcVepUiResolver()],
|
|
14
|
+
* }),
|
|
15
|
+
* ],
|
|
16
|
+
* })
|
|
17
|
+
* ```
|
|
18
|
+
*/
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* @typedef {Object} YcVepUiResolverOptions
|
|
22
|
+
* @property {string} [prefix='Ui'] - 组件前缀
|
|
23
|
+
*/
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* yc-vep-ui 组件库的自动导入解析器
|
|
27
|
+
* @param {YcVepUiResolverOptions} [options={}]
|
|
28
|
+
* @returns {import('unplugin-vue-components/types').ComponentResolver}
|
|
29
|
+
*/
|
|
30
|
+
export function YcVepUiResolver(options = {}) {
|
|
31
|
+
const { prefix = 'Ui' } = options
|
|
32
|
+
|
|
33
|
+
return {
|
|
34
|
+
type: 'component',
|
|
35
|
+
resolve: (name) => {
|
|
36
|
+
// 匹配以 Ui 开头的组件名
|
|
37
|
+
if (name.startsWith(prefix)) {
|
|
38
|
+
const componentName = name.slice(prefix.length)
|
|
39
|
+
|
|
40
|
+
// 组件名称映射(将驼峰命名转换为实际的文件名)
|
|
41
|
+
const componentMap = {
|
|
42
|
+
Card: 'Card',
|
|
43
|
+
Table: 'Table',
|
|
44
|
+
Filter: 'Filter',
|
|
45
|
+
Form: 'Form',
|
|
46
|
+
Editor: 'Editor',
|
|
47
|
+
Tree: 'Tree',
|
|
48
|
+
InfiniteScroll: 'InfiniteScroll',
|
|
49
|
+
Descriptions: 'Descriptions',
|
|
50
|
+
Dialog: 'Dialog',
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
const mappedName = componentMap[componentName]
|
|
54
|
+
if (mappedName) {
|
|
55
|
+
return {
|
|
56
|
+
name: `Ui${mappedName}`,
|
|
57
|
+
from: 'yc-vep-ui',
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
},
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
export default YcVepUiResolver
|
|
66
|
+
/**
|
|
67
|
+
* unplugin-vue-components 解析器
|
|
68
|
+
* 用于自动导入 yc-vep-ui 组件
|
|
69
|
+
*
|
|
70
|
+
* 使用方式:
|
|
71
|
+
* ```ts
|
|
72
|
+
* import Components from 'unplugin-vue-components/vite'
|
|
73
|
+
* import { YcVepUiResolver } from 'yc-vep-ui/resolver'
|
|
74
|
+
*
|
|
75
|
+
* export default defineConfig({
|
|
76
|
+
* plugins: [
|
|
77
|
+
* Components({
|
|
78
|
+
* resolvers: [YcVepUiResolver()],
|
|
79
|
+
* }),
|
|
80
|
+
* ],
|
|
81
|
+
* })
|
|
82
|
+
* ```
|
|
83
|
+
*/
|
|
84
|
+
|
|
85
|
+
import type { ComponentResolver } from 'unplugin-vue-components/types'
|
|
86
|
+
|
|
87
|
+
export interface YcVepUiResolverOptions {
|
|
88
|
+
/**
|
|
89
|
+
* 组件前缀(默认 'Ui')
|
|
90
|
+
* @default 'Ui'
|
|
91
|
+
*/
|
|
92
|
+
prefix?: string
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
/**
|
|
96
|
+
* yc-vep-ui 组件库的自动导入解析器
|
|
97
|
+
*/
|
|
98
|
+
export function YcVepUiResolver(options: YcVepUiResolverOptions = {}): ComponentResolver {
|
|
99
|
+
const { prefix = 'Ui' } = options
|
|
100
|
+
|
|
101
|
+
return {
|
|
102
|
+
type: 'component',
|
|
103
|
+
resolve: (name: string) => {
|
|
104
|
+
// 匹配以 Ui 开头的组件名
|
|
105
|
+
if (name.startsWith(prefix)) {
|
|
106
|
+
const componentName = name.slice(prefix.length)
|
|
107
|
+
|
|
108
|
+
// 组件名称映射(将驼峰命名转换为实际的文件名)
|
|
109
|
+
const componentMap: Record<string, string> = {
|
|
110
|
+
Card: 'Card',
|
|
111
|
+
Table: 'Table',
|
|
112
|
+
Filter: 'Filter',
|
|
113
|
+
Form: 'Form',
|
|
114
|
+
Editor: 'Editor',
|
|
115
|
+
Tree: 'Tree',
|
|
116
|
+
InfiniteScroll: 'InfiniteScroll',
|
|
117
|
+
Descriptions: 'Descriptions',
|
|
118
|
+
Dialog: 'Dialog',
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
const mappedName = componentMap[componentName]
|
|
122
|
+
if (mappedName) {
|
|
123
|
+
return {
|
|
124
|
+
name: `Ui${mappedName}`,
|
|
125
|
+
from: 'yc-vep-ui',
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
},
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
export default YcVepUiResolver
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { ComponentResolver } from 'unplugin-vue-components/types'
|
|
2
|
+
|
|
3
|
+
export interface YcVepUiResolverOptions {
|
|
4
|
+
/**
|
|
5
|
+
* 组件前缀(默认 'Ui')
|
|
6
|
+
* @default 'Ui'
|
|
7
|
+
*/
|
|
8
|
+
prefix?: string
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* yc-vep-ui 组件库的自动导入解析器
|
|
13
|
+
*/
|
|
14
|
+
export declare function YcVepUiResolver(options?: YcVepUiResolverOptions): ComponentResolver
|
|
15
|
+
|
|
16
|
+
export default YcVepUiResolver
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* unplugin-vue-components 解析器
|
|
3
|
+
* 用于自动导入 yc-vep-ui 组件
|
|
4
|
+
*
|
|
5
|
+
* 使用方式:
|
|
6
|
+
* ```ts
|
|
7
|
+
* import Components from 'unplugin-vue-components/vite'
|
|
8
|
+
* import { YcVepUiResolver } from 'yc-vep-ui/resolver'
|
|
9
|
+
*
|
|
10
|
+
* export default defineConfig({
|
|
11
|
+
* plugins: [
|
|
12
|
+
* Components({
|
|
13
|
+
* resolvers: [YcVepUiResolver()],
|
|
14
|
+
* }),
|
|
15
|
+
* ],
|
|
16
|
+
* })
|
|
17
|
+
* ```
|
|
18
|
+
*/
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* @typedef {Object} YcVepUiResolverOptions
|
|
22
|
+
* @property {string} [prefix='Ui'] - 组件前缀
|
|
23
|
+
*/
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* yc-vep-ui 组件库的自动导入解析器
|
|
27
|
+
* @param {YcVepUiResolverOptions} [options={}]
|
|
28
|
+
* @returns {import('unplugin-vue-components/types').ComponentResolver}
|
|
29
|
+
*/
|
|
30
|
+
export function YcVepUiResolver(options = {}) {
|
|
31
|
+
const { prefix = 'Ui' } = options
|
|
32
|
+
|
|
33
|
+
return {
|
|
34
|
+
type: 'component',
|
|
35
|
+
resolve: (name) => {
|
|
36
|
+
// 匹配以 Ui 开头的组件名
|
|
37
|
+
if (name.startsWith(prefix)) {
|
|
38
|
+
const componentName = name.slice(prefix.length)
|
|
39
|
+
|
|
40
|
+
// 组件名称映射(将驼峰命名转换为实际的文件名)
|
|
41
|
+
const componentMap = {
|
|
42
|
+
Card: 'Card',
|
|
43
|
+
Table: 'Table',
|
|
44
|
+
Filter: 'Filter',
|
|
45
|
+
Form: 'Form',
|
|
46
|
+
Editor: 'Editor',
|
|
47
|
+
Tree: 'Tree',
|
|
48
|
+
InfiniteScroll: 'InfiniteScroll',
|
|
49
|
+
Descriptions: 'Descriptions',
|
|
50
|
+
Dialog: 'Dialog',
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
const mappedName = componentMap[componentName]
|
|
54
|
+
if (mappedName) {
|
|
55
|
+
return {
|
|
56
|
+
name: `Ui${mappedName}`,
|
|
57
|
+
from: 'yc-vep-ui',
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
},
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
export default YcVepUiResolver
|
|
66
|
+
/**
|
|
67
|
+
* unplugin-vue-components 解析器
|
|
68
|
+
* 用于自动导入 yc-vep-ui 组件
|
|
69
|
+
*
|
|
70
|
+
* 使用方式:
|
|
71
|
+
* ```ts
|
|
72
|
+
* import Components from 'unplugin-vue-components/vite'
|
|
73
|
+
* import { YcVepUiResolver } from 'yc-vep-ui/resolver'
|
|
74
|
+
*
|
|
75
|
+
* export default defineConfig({
|
|
76
|
+
* plugins: [
|
|
77
|
+
* Components({
|
|
78
|
+
* resolvers: [YcVepUiResolver()],
|
|
79
|
+
* }),
|
|
80
|
+
* ],
|
|
81
|
+
* })
|
|
82
|
+
* ```
|
|
83
|
+
*/
|
|
84
|
+
|
|
85
|
+
import type { ComponentResolver } from 'unplugin-vue-components/types'
|
|
86
|
+
|
|
87
|
+
export interface YcVepUiResolverOptions {
|
|
88
|
+
/**
|
|
89
|
+
* 组件前缀(默认 'Ui')
|
|
90
|
+
* @default 'Ui'
|
|
91
|
+
*/
|
|
92
|
+
prefix?: string
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
/**
|
|
96
|
+
* yc-vep-ui 组件库的自动导入解析器
|
|
97
|
+
*/
|
|
98
|
+
export function YcVepUiResolver(options: YcVepUiResolverOptions = {}): ComponentResolver {
|
|
99
|
+
const { prefix = 'Ui' } = options
|
|
100
|
+
|
|
101
|
+
return {
|
|
102
|
+
type: 'component',
|
|
103
|
+
resolve: (name: string) => {
|
|
104
|
+
// 匹配以 Ui 开头的组件名
|
|
105
|
+
if (name.startsWith(prefix)) {
|
|
106
|
+
const componentName = name.slice(prefix.length)
|
|
107
|
+
|
|
108
|
+
// 组件名称映射(将驼峰命名转换为实际的文件名)
|
|
109
|
+
const componentMap: Record<string, string> = {
|
|
110
|
+
Card: 'Card',
|
|
111
|
+
Table: 'Table',
|
|
112
|
+
Filter: 'Filter',
|
|
113
|
+
Form: 'Form',
|
|
114
|
+
Editor: 'Editor',
|
|
115
|
+
Tree: 'Tree',
|
|
116
|
+
InfiniteScroll: 'InfiniteScroll',
|
|
117
|
+
Descriptions: 'Descriptions',
|
|
118
|
+
Dialog: 'Dialog',
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
const mappedName = componentMap[componentName]
|
|
122
|
+
if (mappedName) {
|
|
123
|
+
return {
|
|
124
|
+
name: `Ui${mappedName}`,
|
|
125
|
+
from: 'yc-vep-ui',
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
},
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
export default YcVepUiResolver
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "yc-vep-ui",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.31",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "基于 Vue 3 + Element Plus 的企业级 UI 组件库",
|
|
6
6
|
"keywords": [
|
|
@@ -25,6 +25,11 @@
|
|
|
25
25
|
"import": "./dist/vep-ui.es.js",
|
|
26
26
|
"require": "./dist/vep-ui.umd.js"
|
|
27
27
|
},
|
|
28
|
+
"./resolver": {
|
|
29
|
+
"types": "./dist/resolver.d.ts",
|
|
30
|
+
"import": "./dist/resolver.mjs",
|
|
31
|
+
"require": "./dist/resolver.cjs"
|
|
32
|
+
},
|
|
28
33
|
"./dist/yc-vep-ui.css": "./dist/yc-vep-ui.css"
|
|
29
34
|
},
|
|
30
35
|
"files": [
|
|
@@ -48,6 +53,7 @@
|
|
|
48
53
|
"@vitejs/plugin-vue": "^6.0.6",
|
|
49
54
|
"@vue/tsconfig": "^0.9.1",
|
|
50
55
|
"typescript": "~6.0.2",
|
|
56
|
+
"unplugin-vue-components": "^32.1.0",
|
|
51
57
|
"vite": "^8.0.12",
|
|
52
58
|
"vite-plugin-dts": "^4.5.0",
|
|
53
59
|
"vue-tsc": "^3.2.8"
|