yc-vep-ui 0.0.30 → 0.0.32

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.
@@ -0,0 +1,65 @@
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
+ 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
+ module.exports = 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,65 @@
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
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "yc-vep-ui",
3
- "version": "0.0.30",
3
+ "version": "0.0.32",
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"