refactor(仪表板): 按钮组件禁止复制和移入Tab内

This commit is contained in:
wangjiahao 2023-01-17 12:18:45 +08:00
parent 0e76ea8dae
commit a38f243727
5 changed files with 18 additions and 5 deletions

View File

@ -1,5 +1,7 @@
import store from '@/store' import store from '@/store'
import eventBus from '@/components/canvas/utils/eventBus' import eventBus from '@/components/canvas/utils/eventBus'
import { $warning } from '@/utils/message'
import i18n from '@/lang'
const ctrlKey = 17 const ctrlKey = 17
const commandKey = 91 // mac command const commandKey = 91 // mac command
@ -25,6 +27,8 @@ const enlargeKey = 190 // command + .
export const keycodes = [66, 67, 68, 69, 71, 76, 80, 83, 85, 86, 88, 89, 90] export const keycodes = [66, 67, 68, 69, 71, 76, 80, 83, 85, 86, 88, 89, 90]
const ignoreComponent = ['de-button', 'de-reset-button']
// 与组件状态无关的操作 // 与组件状态无关的操作
const basemap = { const basemap = {
[vKey]: paste, [vKey]: paste,
@ -134,10 +138,14 @@ function decompose() {
function copyAndPast() { function copyAndPast() {
if (store.state.curComponent) { if (store.state.curComponent) {
if (ignoreComponent.includes(store.state.curComponent.component)) {
$warning(i18n.t('panel.forbidden_copy'))
} else {
store.commit('copy') store.commit('copy')
store.commit('paste', false) store.commit('paste', false)
store.commit('recordSnapshot', 'copyAndPast') store.commit('recordSnapshot', 'copyAndPast')
} }
}
} }
function deleteComponent() { function deleteComponent() {

View File

@ -455,7 +455,9 @@ export default {
latestMoveY: 0, latestMoveY: 0,
seriesIdMap: { seriesIdMap: {
id: '' id: ''
} },
// Tab
ignoreTabMoveComponent: ['de-button', 'de-reset-button', 'de-tabs']
} }
}, },
computed: { computed: {
@ -1966,7 +1968,7 @@ export default {
const width = this.width const width = this.width
const height = this.height const height = this.height
// tab tabtab // tab tabtab
if (this.isTabMoveCheck && this.element.type !== 'de-tabs') { if (this.isTabMoveCheck && !this.ignoreTabMoveComponent.includes(this.element.component)) {
const nodes = this.$el.parentNode.childNodes // const nodes = this.$el.parentNode.childNodes //
for (const item of nodes) { for (const item of nodes) {
if ( if (

View File

@ -1963,6 +1963,7 @@ export default {
back_parent: 'Back to previous' back_parent: 'Back to previous'
}, },
panel: { panel: {
forbidden_copy: 'Forbidden copy',
url_check_error: 'Jump error, Illegal URL', url_check_error: 'Jump error, Illegal URL',
view_style: 'View Style', view_style: 'View Style',
view_color_setting: 'View Color Setting', view_color_setting: 'View Color Setting',

View File

@ -1957,6 +1957,7 @@ export default {
back_parent: '返回上一級' back_parent: '返回上一級'
}, },
panel: { panel: {
forbidden_copy: '當前組件不允許復製',
url_check_error: '跳轉錯誤URL不合法', url_check_error: '跳轉錯誤URL不合法',
view_style: '視圖樣式', view_style: '視圖樣式',
view_color_setting: '視圖配色', view_color_setting: '視圖配色',

View File

@ -1957,6 +1957,7 @@ export default {
back_parent: '返回上一级' back_parent: '返回上一级'
}, },
panel: { panel: {
forbidden_copy: '当前组件不允许复制',
url_check_error: '跳转错误URL不合法', url_check_error: '跳转错误URL不合法',
view_style: '视图样式', view_style: '视图样式',
view_color_setting: '视图配色', view_color_setting: '视图配色',