重构渲染器
This commit is contained in:
@@ -1,8 +1,59 @@
|
||||
import VXEStore from './store'
|
||||
import XEUtils from 'xe-utils'
|
||||
import { warnLog } from '../../tools/log'
|
||||
|
||||
import { VxeGlobalCommands } from '../../../types/v-x-e-table'
|
||||
|
||||
export const commands = new VXEStore() as VxeGlobalCommands
|
||||
class VXECommandsStore {
|
||||
private store: any = {}
|
||||
|
||||
mixin (options: any): VXECommandsStore {
|
||||
XEUtils.each(options, (item, key) => {
|
||||
this.add(key, item)
|
||||
})
|
||||
return this
|
||||
}
|
||||
|
||||
has (name: string): boolean {
|
||||
return !!this.get(name)
|
||||
}
|
||||
|
||||
get (name: string): any {
|
||||
return this.store[name]
|
||||
}
|
||||
|
||||
add (name: string, render: any): VXECommandsStore {
|
||||
const conf = this.store[name]
|
||||
// 兼容
|
||||
if (XEUtils.isFunction(render)) {
|
||||
// warnLog('vxe.error.delProp', ['callback', 'commandMethod'])
|
||||
render = {
|
||||
commandMethod: render
|
||||
}
|
||||
}
|
||||
|
||||
// 检测是否覆盖
|
||||
if (process.env.VUE_APP_VXE_TABLE_ENV === 'development') {
|
||||
const confKeys = XEUtils.keys(conf)
|
||||
XEUtils.each(render, (item, key) => {
|
||||
if (confKeys.includes(key)) {
|
||||
warnLog('vxe.error.coverProp', [name, key])
|
||||
}
|
||||
})
|
||||
}
|
||||
this.store[name] = conf ? XEUtils.merge(conf, render) : render
|
||||
return this
|
||||
}
|
||||
|
||||
delete (name: string): void {
|
||||
delete this.store[name]
|
||||
}
|
||||
|
||||
forEach (callback: any): void {
|
||||
XEUtils.objectEach(this.store, callback)
|
||||
}
|
||||
}
|
||||
|
||||
export const commands = new VXECommandsStore() as VxeGlobalCommands
|
||||
|
||||
if (process.env.VUE_APP_VXE_TABLE_ENV === 'development') {
|
||||
Object.assign(commands, { _name: 'Commands' })
|
||||
|
||||
@@ -15,6 +15,7 @@ const GlobalConfig: VXETableGlobalConfig = {
|
||||
animat: true,
|
||||
delayHover: 250,
|
||||
autoResize: true,
|
||||
minHeight: 144,
|
||||
// keepSource: false,
|
||||
// showOverflow: null,
|
||||
// showHeaderOverflow: null,
|
||||
@@ -49,7 +50,7 @@ const GlobalConfig: VXETableGlobalConfig = {
|
||||
validConfig: {
|
||||
showMessage: true,
|
||||
autoClear: true,
|
||||
message: 'default',
|
||||
message: 'inline',
|
||||
msgMode: 'single'
|
||||
},
|
||||
columnConfig: {
|
||||
|
||||
@@ -1,8 +1,59 @@
|
||||
import VXEStore from './store'
|
||||
import XEUtils from 'xe-utils'
|
||||
import { warnLog } from '../../tools/log'
|
||||
|
||||
import { VxeGlobalFormats } from '../../../types/v-x-e-table'
|
||||
|
||||
export const formats = new VXEStore() as VxeGlobalFormats
|
||||
class VXEFormatsStore {
|
||||
private store: any = {}
|
||||
|
||||
mixin (options: any): VXEFormatsStore {
|
||||
XEUtils.each(options, (item, key) => {
|
||||
this.add(key, item)
|
||||
})
|
||||
return this
|
||||
}
|
||||
|
||||
has (name: string): boolean {
|
||||
return !!this.get(name)
|
||||
}
|
||||
|
||||
get (name: string): any {
|
||||
return this.store[name]
|
||||
}
|
||||
|
||||
add (name: string, render: any): VXEFormatsStore {
|
||||
const conf = this.store[name]
|
||||
// 兼容
|
||||
if (XEUtils.isFunction(render)) {
|
||||
// warnLog('vxe.error.delProp', ['callback', 'formatMethod'])
|
||||
render = {
|
||||
formatMethod: render
|
||||
}
|
||||
}
|
||||
|
||||
// 检测是否覆盖
|
||||
if (process.env.VUE_APP_VXE_TABLE_ENV === 'development') {
|
||||
const confKeys = XEUtils.keys(conf)
|
||||
XEUtils.each(render, (item, key) => {
|
||||
if (confKeys.includes(key)) {
|
||||
warnLog('vxe.error.coverProp', [name, key])
|
||||
}
|
||||
})
|
||||
}
|
||||
this.store[name] = conf ? XEUtils.merge(conf, render) : render
|
||||
return this
|
||||
}
|
||||
|
||||
delete (name: string): void {
|
||||
delete this.store[name]
|
||||
}
|
||||
|
||||
forEach (callback: any): void {
|
||||
XEUtils.objectEach(this.store, callback)
|
||||
}
|
||||
}
|
||||
|
||||
export const formats = new VXEFormatsStore() as VxeGlobalFormats
|
||||
|
||||
if (process.env.VUE_APP_VXE_TABLE_ENV === 'development') {
|
||||
Object.assign(formats, { _name: 'Formats' })
|
||||
|
||||
@@ -25,6 +25,7 @@ class VXEMenusStore {
|
||||
const conf = this.store[name]
|
||||
// 兼容
|
||||
if (XEUtils.isFunction(render)) {
|
||||
// warnLog('vxe.error.delProp', ['callback', 'menuMethod'])
|
||||
render = {
|
||||
menuMethod: render
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user