@@ -30,7 +30,7 @@ export default (api: IApi) => {
3030 function checkPkgPath ( ) {
3131 if ( ! pkgPath ) {
3232 throw new Error (
33- `Can't find element-plus package. Please install element-plus first.`
33+ `Can't find element-plus package. Please install element-plus first.` ,
3434 ) ;
3535 }
3636 }
@@ -43,39 +43,58 @@ export default (api: IApi) => {
4343 . object ( {
4444 importStyle : zod
4545 . union ( [ zod . boolean ( ) , zod . literal ( 'css' ) , zod . literal ( 'sass' ) ] )
46- . describe ( '样式导入方式。true 或 "css" 导入编译后的 CSS 文件,"sass" 导入 Sass 源文件以支持主题定制,false 不自动导入样式。推荐使用 "sass" 以获得更好的主题定制能力。' )
46+ . describe (
47+ '样式导入方式。true 或 "css" 导入编译后的 CSS 文件,"sass" 导入 Sass 源文件以支持主题定制,false 不自动导入样式。推荐使用 "sass" 以获得更好的主题定制能力。' ,
48+ )
4749 . default ( true )
4850 . optional ( ) ,
4951 version : zod
5052 . string ( )
51- . describe ( '手动指定 Element Plus 版本,用于覆盖自动检测的版本。格式如 "2.4.1"、"2.3.8" 等。通常无需配置,插件会自动从 package.json 检测版本。' )
53+ . describe (
54+ '手动指定 Element Plus 版本,用于覆盖自动检测的版本。格式如 "2.4.1"、"2.3.8" 等。通常无需配置,插件会自动从 package.json 检测版本。' ,
55+ )
5256 . optional ( ) ,
5357 prefix : zod
5458 . string ( )
55- . describe ( '组件名称前缀。默认为 "El",对应 "ElButton"、"ElInput" 等组件名。如需自定义可修改此配置,但需确保与实际使用的组件名一致。' )
59+ . describe (
60+ '组件名称前缀。默认为 "El",对应 "ElButton"、"ElInput" 等组件名。如需自定义可修改此配置,但需确保与实际使用的组件名一致。' ,
61+ )
5662 . default ( 'El' )
5763 . optional ( ) ,
5864 exclude : zod
5965 . array ( zod . string ( ) )
60- . describe ( '排除自动导入的组件列表。数组元素为组件名称(不含前缀),如 ["Button", "Input"]。被排除的组件需要手动导入。适用于需要自定义导入逻辑的场景。' )
66+ . describe (
67+ '排除自动导入的组件列表。数组元素为组件名称(不含前缀),如 ["Button", "Input"]。被排除的组件需要手动导入。适用于需要自定义导入逻辑的场景。' ,
68+ )
6169 . optional ( ) ,
6270 noStylesComponents : zod
6371 . array ( zod . string ( ) )
64- . describe ( '无需导入样式的组件列表。这些组件不会自动导入对应的样式文件,适用于一些功能性组件(如 ElMessage、ElNotification 等),它们的样式通常已全局引入。' )
65- . default ( [ 'ElMessage' , 'ElNotification' , 'ElMessageBox' , 'ElLoading' ] )
72+ . describe (
73+ '无需导入样式的组件列表。这些组件不会自动导入对应的样式文件,适用于一些功能性组件(如 ElMessage、ElNotification 等),它们的样式通常已全局引入。' ,
74+ )
75+ . default ( [
76+ 'ElMessage' ,
77+ 'ElNotification' ,
78+ 'ElMessageBox' ,
79+ 'ElLoading' ,
80+ ] )
6681 . optional ( ) ,
6782 directives : zod
6883 . boolean ( )
69- . describe ( '是否启用 Element Plus 指令的自动导入。设为 true 时会自动导入 v-loading、v-infinite-scroll 等指令。默认启用以提供完整的 Element Plus 功能。' )
84+ . describe (
85+ '是否启用 Element Plus 指令的自动导入。设为 true 时会自动导入 v-loading、v-infinite-scroll 等指令。默认启用以提供完整的 Element Plus 功能。' ,
86+ )
7087 . default ( true )
71- . optional ( )
88+ . optional ( ) ,
7289 } )
73- . describe ( 'Element Plus 自动导入插件配置。集成 unplugin-vue-components 的 ElementPlusResolver,提供 Element Plus 组件、样式和指令的按需自动导入功能,支持主题定制和性能优化,适用于 Vue 3 项目。' )
90+ . describe (
91+ 'Element Plus 自动导入插件配置。集成 unplugin-vue-components 的 ElementPlusResolver,提供 Element Plus 组件、样式和指令的按需自动导入功能,支持主题定制和性能优化,适用于 Vue 3 项目。' ,
92+ )
7493 . optional ( )
7594 . default ( { } ) ;
76- }
95+ } ,
7796 } ,
78- enableBy : api . EnableBy . config
97+ enableBy : api . EnableBy . config ,
7998 } ) ;
8099
81100 checkPkgPath ( ) ;
@@ -87,7 +106,7 @@ export default (api: IApi) => {
87106 memo . elementPlus = {
88107 pkgPath,
89108 version : finalVersion ,
90- detectedVersion
109+ detectedVersion,
91110 } ;
92111 return memo ;
93112 } ) ;
@@ -96,24 +115,31 @@ export default (api: IApi) => {
96115 const userConfig = api . userConfig . elementPlus || { } ;
97116 const resolverConfig = {
98117 // 样式导入方式:默认为 true
99- importStyle : userConfig . importStyle !== undefined ? userConfig . importStyle : true ,
118+ importStyle :
119+ userConfig . importStyle !== undefined ? userConfig . importStyle : true ,
100120 // 组件前缀:默认为 'El'
101121 prefix : userConfig . prefix || 'El' ,
102122 // 排除的组件列表
103123 ...( userConfig . exclude && { exclude : userConfig . exclude } ) ,
104124 // 无需导入样式的组件
105- noStylesComponents : userConfig . noStylesComponents || [ 'ElMessage' , 'ElNotification' , 'ElMessageBox' , 'ElLoading' ] ,
125+ noStylesComponents : userConfig . noStylesComponents || [
126+ 'ElMessage' ,
127+ 'ElNotification' ,
128+ 'ElMessageBox' ,
129+ 'ElLoading' ,
130+ ] ,
106131 // 是否启用指令
107- directives : userConfig . directives !== false
132+ directives : userConfig . directives !== false ,
108133 } ;
109134
110135 const unComponents = {
111- resolvers : [
112- ElementPlusResolver ( resolverConfig )
113- ]
136+ resolvers : [ ElementPlusResolver ( resolverConfig ) ] ,
114137 } ;
115138
116- api . userConfig . autoImport = deepmerge ( {
117- unComponents
118- } , api . userConfig . autoImport || { } ) ;
119- }
139+ api . userConfig . autoImport = deepmerge (
140+ {
141+ unComponents,
142+ } ,
143+ api . userConfig . autoImport || { } ,
144+ ) ;
145+ } ;
0 commit comments