From b88672c762c0a3fe8c3a43d6ac178b6fbe1e88b1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=B4=A4=E5=BF=83?= <3277200+sentsim@users.noreply.github.com> Date: Fri, 26 May 2023 12:17:19 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=20code=20=E7=9A=84=20`copy`?= =?UTF-8?q?=20=E5=B1=9E=E6=80=A7=E5=BC=80=E5=90=AF=E6=97=B6,=20=E5=AF=B9?= =?UTF-8?q?=20`tools`=20=E5=B1=9E=E6=80=A7=E7=9A=84=E5=88=9D=E5=A7=8B?= =?UTF-8?q?=E5=8C=96=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/modules/code.js | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/modules/code.js b/src/modules/code.js index 51cf8290..aa6c4ba6 100644 --- a/src/modules/code.js +++ b/src/modules/code.js @@ -186,8 +186,15 @@ layui.define(['lay', 'util', 'element', 'form'], function(exports){ }); // copy - if(options.copy && layui.type(options.tools) === 'array'){ - options.tools.unshift('copy'); + if(options.copy){ + if(layui.type(options.tools) === 'array'){ + // 若 copy 未存在于 tools 中,则追加到最前 + if(options.tools.indexOf('copy') === -1){ + options.tools.unshift('copy'); + } + } else { + options.tools = ['copy']; + } } // 工具栏事件