diff --git a/src/controllers/resize.js b/src/controllers/resize.js index 8f61f21..6ee6aaf 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 b088d5d..0a69743 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