perf: 优化 tags 关联

This commit is contained in:
ibuler
2024-06-11 19:39:59 +08:00
parent f706d38e2d
commit d0ae764ab6
2 changed files with 9 additions and 3 deletions

View File

@@ -57,12 +57,13 @@
:el="formatterArgs.config"
:label="label"
class="tag-formatter"
closable
@close="handleCloseTag(label)"
/>
</div>
<div class="tag-tip">
<el-link @click="goToLabelList">
{{ $t('LabelList') }} <i class="fa fa-external-link" />
{{ $t('TagList') }} <i class="fa fa-external-link" />
</el-link>
</div>
</div>

View File

@@ -1,15 +1,16 @@
<template>
<el-tag
:class="{'no-color': !label.color}"
:closable="closable"
:color="label.color"
:title="label.name + ': ' + label.value"
class="tag-formatter"
disable-transitions
effect="plain"
size="mini"
type="success"
v-bind="el"
@click="handleClick(label)"
v-on="$listeners"
>
<span :class="[getColor(label)]">
<b> {{ getKey(label) }}:</b> {{ getValue(label) }}
@@ -30,6 +31,10 @@ export default {
el: {
type: Object,
default: () => ({})
},
closable: {
type: Boolean,
default: false
}
},
methods: {
@@ -45,7 +50,7 @@ export default {
},
getValue(tag) {
if (typeof tag === 'string') {
return tag.split(':').slice(1).join(':')
return tag.split(':')?.slice(1).join(':')
} else {
return tag.value
}