From cc3797d66433e9872e038a6e62bea8d5ffde4cd3 Mon Sep 17 00:00:00 2001 From: xuliangzhan Date: Sun, 10 Sep 2023 12:44:05 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B0=83=E6=95=B4=E5=85=A8=E5=B1=80=E5=8F=82?= =?UTF-8?q?=E6=95=B0=20setup=20=E4=B8=BA=20config?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- package.json | 2 +- packages/export/src/mixin.js | 10 +++---- packages/table/src/methods.js | 2 +- packages/table/src/table.js | 8 ++--- packages/v-x-e-table/index.js | 11 ++++--- packages/v-x-e-table/src/commands.js | 6 ++-- .../v-x-e-table/src/{setup.js => config.js} | 4 +-- packages/v-x-e-table/src/formats.js | 6 ++-- packages/v-x-e-table/src/menus.js | 6 ++-- types/v-x-e-table/{setup.d.ts => config.d.ts} | 0 types/v-x-e-table/index.d.ts | 30 +++++++++++++------ 11 files changed, 50 insertions(+), 35 deletions(-) rename packages/v-x-e-table/src/{setup.js => config.js} (55%) rename types/v-x-e-table/{setup.d.ts => config.d.ts} (100%) diff --git a/package.json b/package.json index ee67726ce..bf653177f 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "vxe-table", - "version": "3.7.0-beta.17", + "version": "3.7.0-beta.19", "description": "一个基于 vue 的 PC 端表单/表格组件,支持增删改查、虚拟列表、虚拟树、懒加载、快捷菜单、数据校验、树形结构、打印导出、表单渲染、数据分页、弹窗、自定义模板、渲染器、JSON 配置式...", "scripts": { "update": "npm install --legacy-peer-deps", diff --git a/packages/export/src/mixin.js b/packages/export/src/mixin.js index 7291e73f5..a7a4e3283 100644 --- a/packages/export/src/mixin.js +++ b/packages/export/src/mixin.js @@ -858,7 +858,7 @@ function handleFileImport ($xetable, file, opts) { const { type, filename } = UtilTools.parseFile(file) // 检查类型,如果为自定义导出,则不需要校验类型 - if (!importMethod && !XEUtils.includes(VXETable.config.importTypes, type)) { + if (!importMethod && !XEUtils.includes(VXETable.globalConfs.importTypes, type)) { if (opts.message !== false) { // 检测弹窗模块 if (process.env.VUE_APP_VXE_TABLE_ENV === 'development') { @@ -1042,7 +1042,7 @@ function handleExportAndPrint ($xetable, options, isPrint) { const hasTree = treeConfig const hasMerge = !hasTree && mergeList.length const defOpts = Object.assign({ message: true, isHeader: true }, options) - const types = defOpts.types || VXETable.config.exportTypes + const types = defOpts.types || VXETable.globalConfs.exportTypes const modes = defOpts.modes const checkMethod = customOpts.checkMethod const exportColumns = collectColumn.slice(0) @@ -1274,7 +1274,7 @@ export default { } // 检查类型,如果为自定义导出,则不需要校验类型 - if (!opts.exportMethod && !XEUtils.includes(VXETable.config.exportTypes, type)) { + if (!opts.exportMethod && !XEUtils.includes(VXETable.globalConfs.exportTypes, type)) { if (process.env.VUE_APP_VXE_TABLE_ENV === 'development') { errLog('vxe.error.notType', [type]) } @@ -1349,7 +1349,7 @@ export default { }, _importData (options) { const opts = Object.assign({ - types: VXETable.config.importTypes + types: VXETable.globalConfs.importTypes // beforeImportMethod: null, // afterImportMethod: null }, this.importOpts, options) @@ -1399,7 +1399,7 @@ export default { }) }, _openImport (options) { - const defOpts = Object.assign({ mode: 'insert', message: true, types: VXETable.config.importTypes }, options, this.importOpts) + const defOpts = Object.assign({ mode: 'insert', message: true, types: VXETable.globalConfs.importTypes }, options, this.importOpts) const { types } = defOpts const isTree = !!this.getTreeStatus() if (isTree) { diff --git a/packages/table/src/methods.js b/packages/table/src/methods.js index 775eb18c9..f3ddf99bf 100644 --- a/packages/table/src/methods.js +++ b/packages/table/src/methods.js @@ -1498,7 +1498,7 @@ const Methods = { */ showColumn (fieldOrColumn) { const column = handleFieldOrColumn(this, fieldOrColumn) - if (column && column.visible) { + if (column && !column.visible) { column.visible = true return this.handleCustom() } diff --git a/packages/table/src/table.js b/packages/table/src/table.js index 4bb3a6635..fed1fbd5e 100644 --- a/packages/table/src/table.js +++ b/packages/table/src/table.js @@ -803,11 +803,11 @@ export default { // } // 检查导入导出类型,如果自定义导入导出方法,则不校验类型 const { exportConfig, exportOpts, importConfig, importOpts } = this - if (importConfig && importOpts.types && !importOpts.importMethod && !XEUtils.includeArrays(VXETable.config.importTypes, importOpts.types)) { - warnLog('vxe.error.errProp', [`export-config.types=${importOpts.types.join(',')}`, importOpts.types.filter(type => XEUtils.includes(VXETable.config.importTypes, type)).join(',') || VXETable.config.importTypes.join(',')]) + if (importConfig && importOpts.types && !importOpts.importMethod && !XEUtils.includeArrays(VXETable.globalConfs.importTypes, importOpts.types)) { + warnLog('vxe.error.errProp', [`export-config.types=${importOpts.types.join(',')}`, importOpts.types.filter(type => XEUtils.includes(VXETable.globalConfs.importTypes, type)).join(',') || VXETable.globalConfs.importTypes.join(',')]) } - if (exportConfig && exportOpts.types && !exportOpts.exportMethod && !XEUtils.includeArrays(VXETable.config.exportTypes, exportOpts.types)) { - warnLog('vxe.error.errProp', [`export-config.types=${exportOpts.types.join(',')}`, exportOpts.types.filter(type => XEUtils.includes(VXETable.config.exportTypes, type)).join(',') || VXETable.config.exportTypes.join(',')]) + if (exportConfig && exportOpts.types && !exportOpts.exportMethod && !XEUtils.includeArrays(VXETable.globalConfs.exportTypes, exportOpts.types)) { + warnLog('vxe.error.errProp', [`export-config.types=${exportOpts.types.join(',')}`, exportOpts.types.filter(type => XEUtils.includes(VXETable.globalConfs.exportTypes, type)).join(',') || VXETable.globalConfs.exportTypes.join(',')]) } } diff --git a/packages/v-x-e-table/index.js b/packages/v-x-e-table/index.js index d04dc9aa0..bd0236aae 100644 --- a/packages/v-x-e-table/index.js +++ b/packages/v-x-e-table/index.js @@ -6,7 +6,7 @@ import { commands } from './src/commands' import { menus } from './src/menus' import { formats } from './src/formats' import { validators } from './src/validators' -import { setup } from './src/setup' +import { config } from './src/config' import { UtilTools } from '../tools/utils' import { errLog } from '../tools/log' @@ -76,7 +76,9 @@ class VXETableConfig { return getExportOrImpotType(GlobalConfig.export.types, 2) } } -export const config = new VXETableConfig() + +// 已废弃 +export const globalConfs = new VXETableConfig() export function t (key, args) { return GlobalConfig.i18n(key, args) @@ -87,6 +89,7 @@ export function _t (key, args) { } export const v = 'v3' +export const setup = config export const VXETable = { v, @@ -94,13 +97,13 @@ export const VXETable = { reg, use, setup, + config, interceptor, renderer, commands, formats, menus, validators, - config, t, _t } @@ -110,6 +113,6 @@ export * from './src/renderer' export * from './src/commands' export * from './src/menus' export * from './src/formats' -export * from './src/setup' +export * from './src/config' export default VXETable diff --git a/packages/v-x-e-table/src/commands.js b/packages/v-x-e-table/src/commands.js index 5ce239b3c..d8114d815 100644 --- a/packages/v-x-e-table/src/commands.js +++ b/packages/v-x-e-table/src/commands.js @@ -21,9 +21,9 @@ class VXECommandsStore { const conf = this.store[name] // 兼容 if (XEUtils.isFunction(render)) { - if (process.env.VUE_APP_VXE_TABLE_ENV === 'development') { - warnLog('vxe.error.delProp', ['commands -> callback', 'commandMethod']) - } + // if (process.env.VUE_APP_VXE_TABLE_ENV === 'development') { + // warnLog('vxe.error.delProp', ['commands -> callback', 'commandMethod']) + // } render = { commandMethod: render } diff --git a/packages/v-x-e-table/src/setup.js b/packages/v-x-e-table/src/config.js similarity index 55% rename from packages/v-x-e-table/src/setup.js rename to packages/v-x-e-table/src/config.js index 38bfe9e6b..6b34b8b59 100644 --- a/packages/v-x-e-table/src/setup.js +++ b/packages/v-x-e-table/src/config.js @@ -1,9 +1,9 @@ -import GlobalConfig from '../../v-x-e-table/src/conf' +import GlobalConfig from './conf' import XEUtils from 'xe-utils' /** * 全局参数设置 */ -export function setup (options) { +export function config (options) { return XEUtils.merge(GlobalConfig, options) } diff --git a/packages/v-x-e-table/src/formats.js b/packages/v-x-e-table/src/formats.js index 70356e5b8..f6db01118 100644 --- a/packages/v-x-e-table/src/formats.js +++ b/packages/v-x-e-table/src/formats.js @@ -21,9 +21,9 @@ class VXEFormatsStore { const conf = this.store[name] // 兼容 if (XEUtils.isFunction(render)) { - if (process.env.VUE_APP_VXE_TABLE_ENV === 'development') { - warnLog('vxe.error.delProp', ['formats -> callback', 'cellFormatMethod']) - } + // if (process.env.VUE_APP_VXE_TABLE_ENV === 'development') { + // warnLog('vxe.error.delProp', ['formats -> callback', 'cellFormatMethod']) + // } render = { cellFormatMethod: render } diff --git a/packages/v-x-e-table/src/menus.js b/packages/v-x-e-table/src/menus.js index 68a5d64a7..cc3338ec4 100644 --- a/packages/v-x-e-table/src/menus.js +++ b/packages/v-x-e-table/src/menus.js @@ -21,9 +21,9 @@ class VXEMenusStore { const conf = this.store[name] // 兼容 if (XEUtils.isFunction(render)) { - if (process.env.VUE_APP_VXE_TABLE_ENV === 'development') { - warnLog('vxe.error.delProp', ['menus -> callback', 'menuMethod']) - } + // if (process.env.VUE_APP_VXE_TABLE_ENV === 'development') { + // warnLog('vxe.error.delProp', ['menus -> callback', 'menuMethod']) + // } render = { menuMethod: render } diff --git a/types/v-x-e-table/setup.d.ts b/types/v-x-e-table/config.d.ts similarity index 100% rename from types/v-x-e-table/setup.d.ts rename to types/v-x-e-table/config.d.ts diff --git a/types/v-x-e-table/index.d.ts b/types/v-x-e-table/index.d.ts index 9b0ce6e49..02894902d 100644 --- a/types/v-x-e-table/index.d.ts +++ b/types/v-x-e-table/index.d.ts @@ -9,7 +9,7 @@ import { VxeGlobalCommands } from './commands' import { VxeGlobalFormats } from './formats' import { VxeGlobalMenus } from './menus' import { VxeGlobalValidators } from './validators' -import { VxeGlobalConfigMethod } from './setup' +import { VxeGlobalConfigMethod } from './config' /* eslint-disable no-use-before-define */ @@ -17,7 +17,7 @@ export type VxeGlobalI18n = (key: string, args?: any) => number | string; export type VxeGlobalTranslate = (key: string, args?: any) => string; export type VxeGlobalUse = (plugin: VXETablePluginObject, ...options: any[]) => VXETableCore; -export const setup: VxeGlobalConfigMethod +export const config: VxeGlobalConfigMethod export const interceptor: VxeGlobalInterceptor export const renderer: VxeGlobalRenderer export const commands: VxeGlobalCommands @@ -31,6 +31,12 @@ export const t: VxeGlobalI18n export const _t: VxeGlobalTranslate export const use: VxeGlobalUse +/** + * 请使用 config + * @deprecated + */ +export const setup: VxeGlobalConfigMethod + export interface VXETablePluginObject { install(vxetable: VXETableCore, ...options: any[]): void; [key: string]: any; @@ -41,11 +47,6 @@ export type VXETableVersion = 'v1' | 'v2' | 'v3' | 'v4' export const v: VXETableVersion export interface VXETableCore { - /** - * 已被 version 替换 - * @deprecated - */ - v: VXETableVersion; /** * 版本号 */ @@ -53,7 +54,7 @@ export interface VXETableCore { /** * 设置全局参数/获取所有参数 */ - setup: VxeGlobalConfigMethod; + config: VxeGlobalConfigMethod; /** * Table interceptor */ @@ -105,6 +106,17 @@ export interface VXETableCore { */ t: VxeGlobalI18n; _t: VxeGlobalTranslate; + + /** + * 已被 version 替换 + * @deprecated + */ + v: VXETableVersion; + /** + * 请使用 config + * @deprecated + */ + setup: VxeGlobalConfigMethod; } /** @@ -118,6 +130,6 @@ export * from './commands' export * from './formats' export * from './menus' export * from './validators' -export * from './setup' +export * from './config' export default VXETable