From 4dd527b6cf649a62e460f4664666db4d3081e293 Mon Sep 17 00:00:00 2001 From: cdswyda Date: Wed, 21 Apr 2021 19:00:25 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E9=87=8D=E6=9E=84?= =?UTF-8?q?=E5=B7=A5=E5=85=B7=E6=A0=8F=E9=85=8D=E7=BD=AE=E5=90=8E=E4=B8=8D?= =?UTF-8?q?=E4=BC=A0=20showtoolbar=20showtoolbarConfig=20=E6=97=B6?= =?UTF-8?q?=E7=9A=84bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/controllers/resize.js | 36 ++++++++++++++++------------- src/controllers/toolbar.js | 46 ++++++++++++++------------------------ src/utils/util.js | 13 ++++++++++- 3 files changed, 50 insertions(+), 45 deletions(-) diff --git a/src/controllers/resize.js b/src/controllers/resize.js index 8f61f2120..6ee6aaf7c 100644 --- a/src/controllers/resize.js +++ b/src/controllers/resize.js @@ -5,7 +5,7 @@ import Store from '../store'; import locale from '../locale/locale'; import sheetmanage from './sheetmanage'; import tooltip from '../global/tooltip' -import { $$, getObjType } from "../utils/util"; +import { $$, getObjType, camel2split } from "../utils/util"; import { defaultToolbar, toolbarIdMap } from './toolbar'; let gridW = 0, @@ -344,18 +344,14 @@ export function menuToolBarWidth() { * } */ function buildBoolBarConfig() { - const obj = {}; - // 数组形式直接生成 - if (getObjType(showtoolbarConfig) === 'array') { - // show 为 false - if (!showtoolbar) { - return obj; - } + let obj = {}; + function array2Config(arr) { + const obj = {}; let current,next; let index = 0; - for (let i = 0; i` - ); - } else { - buttonHTML.push(htmlMap[key]); + } + for (let i = 0; i < defaultToolbar.length; i++) { + let key = defaultToolbar[i]; + if (!config[key] && key !== '|') { + // 如果当前元素隐藏 按照之前的规则 后面紧跟的 | 分割也不需要显示了 + if (defaultToolbar[i + 1] === '|') { + i++; } + continue; + } + if (key === '|') { + buttonHTML.push( + `
` + ); + } else { + buttonHTML.push(htmlMap[key]); } } - + console.log(buttonHTML); return buttonHTML.join(''); } - -/** - * camel 形式的单词转换为 - 形式 如 fillColor -> fill-color - * @param {string} camel camel 形式 - * @returns - */ -function camel2split(camel) { - return camel.replace(/([A-Z])/g, function(all, group) { - return '-' + group.toLowerCase(); - }); -} diff --git a/src/utils/util.js b/src/utils/util.js index b088d5d8d..0a6974382 100644 --- a/src/utils/util.js +++ b/src/utils/util.js @@ -871,6 +871,16 @@ function arrayRemoveItem(array, item) { }) } +/** + * camel 形式的单词转换为 - 形式 如 fillColor -> fill-color + * @param {string} camel camel 形式 + * @returns + */ + function camel2split(camel) { + return camel.replace(/([A-Z])/g, function(all, group) { + return '-' + group.toLowerCase(); + }); +} export { isJsonString, @@ -900,5 +910,6 @@ export { transformRangeToAbsolute, openSelfModel, createProxy, - arrayRemoveItem + arrayRemoveItem, + camel2split } \ No newline at end of file