feat: 部分组件重构完成
This commit is contained in:
18
src/plugins/element-plus/element.config.ts
Normal file
18
src/plugins/element-plus/element.config.ts
Normal file
@@ -0,0 +1,18 @@
|
||||
/**
|
||||
* 为了保持多页element组件的样式统一,提供全局配置的方法。
|
||||
*/
|
||||
import { ConfigElement } from './types'
|
||||
|
||||
const elementConfig: ConfigElement = {
|
||||
/**
|
||||
* 尺寸
|
||||
*/
|
||||
size: 'medium',
|
||||
|
||||
/**
|
||||
* 层级
|
||||
*/
|
||||
zIndex: 2000
|
||||
}
|
||||
|
||||
export default elementConfig
|
||||
23
src/plugins/element-plus/index.ts
Normal file
23
src/plugins/element-plus/index.ts
Normal file
@@ -0,0 +1,23 @@
|
||||
// 按需加载element
|
||||
// 目前需要手动引入loading等插件,无法自动导入
|
||||
// size和zIndex也需要这样设置,暂时还无法在全局配置组件中去设置
|
||||
// 需要看看后面官方是不是能优化这点
|
||||
import type { App } from 'vue'
|
||||
|
||||
import ElementConfig from './element.config'
|
||||
|
||||
// element全局配置项
|
||||
const { size, zIndex } = ElementConfig
|
||||
|
||||
import { ElLoading } from 'element-plus'
|
||||
|
||||
const plugins = [ElLoading]
|
||||
|
||||
export function setupElement(app: App<Element>): void {
|
||||
plugins.forEach((plugin: any) => {
|
||||
app.use(plugin)
|
||||
})
|
||||
|
||||
// 全局配置
|
||||
app.config.globalProperties.$ELEMENT = { size: size, zIndex: zIndex }
|
||||
}
|
||||
7
src/plugins/element-plus/types.ts
Normal file
7
src/plugins/element-plus/types.ts
Normal file
@@ -0,0 +1,7 @@
|
||||
/**
|
||||
* element配置
|
||||
*/
|
||||
export interface ConfigElement {
|
||||
zIndex: number
|
||||
size: 'medium' | 'small' | 'mini'
|
||||
}
|
||||
Reference in New Issue
Block a user