refactor: button text prop 改成 link element-plus将废弃text

This commit is contained in:
roymondchen 2024-01-08 17:49:41 +08:00
parent aa601f8703
commit 5c54f50365
19 changed files with 30 additions and 29 deletions

View File

@ -27,6 +27,7 @@ export interface BadgeProps {
export interface ButtonProps { export interface ButtonProps {
type?: string; type?: string;
size?: FieldSize; size?: FieldSize;
link?: boolean;
text?: boolean; text?: boolean;
icon?: any; icon?: any;
} }

View File

@ -18,7 +18,7 @@
@closed="closedHandler" @closed="closedHandler"
> >
<template #left> <template #left>
<TMagicButton type="primary" text @click="difVisible = true">查看修改</TMagicButton> <TMagicButton type="primary" link @click="difVisible = true">查看修改</TMagicButton>
</template> </template>
</component> </component>

View File

@ -6,7 +6,7 @@
<span>{{ title }}</span> <span>{{ title }}</span>
</slot> </slot>
<div> <div>
<TMagicButton text size="small" :icon="Close" @click="closeHandler"></TMagicButton> <TMagicButton link size="small" :icon="Close" @click="closeHandler"></TMagicButton>
</div> </div>
</div> </div>
<div class="m-editor-float-box-body"> <div class="m-editor-float-box-body">

View File

@ -12,11 +12,11 @@
<template v-else-if="data.type === 'button'"> <template v-else-if="data.type === 'button'">
<TMagicTooltip v-if="data.tooltip" effect="dark" placement="bottom-start" :content="data.tooltip"> <TMagicTooltip v-if="data.tooltip" effect="dark" placement="bottom-start" :content="data.tooltip">
<TMagicButton size="small" text :disabled="disabled" <TMagicButton size="small" link :disabled="disabled"
><MIcon v-if="data.icon" :icon="data.icon"></MIcon><span>{{ data.text }}</span></TMagicButton ><MIcon v-if="data.icon" :icon="data.icon"></MIcon><span>{{ data.text }}</span></TMagicButton
> >
</TMagicTooltip> </TMagicTooltip>
<TMagicButton v-else size="small" text :disabled="disabled" :title="data.text" <TMagicButton v-else size="small" link :disabled="disabled" :title="data.text"
><MIcon v-if="data.icon" :icon="data.icon"></MIcon><span>{{ data.text }}</span></TMagicButton ><MIcon v-if="data.icon" :icon="data.icon"></MIcon><span>{{ data.text }}</span></TMagicButton
> >
</template> </template>

View File

@ -36,7 +36,7 @@
></m-form-container> ></m-form-container>
<TMagicButton <TMagicButton
style="color: #f56c6c" style="color: #f56c6c"
text link
:icon="Delete" :icon="Delete"
:disabled="disabled" :disabled="disabled"
:size="size" :size="size"

View File

@ -51,7 +51,7 @@
v-if="config.advanced" v-if="config.advanced"
size="default" size="default"
:disabled="disabled" :disabled="disabled"
text link
:icon="CodeIcon" :icon="CodeIcon"
@click="showCode = !showCode" @click="showCode = !showCode"
></TMagicButton> ></TMagicButton>

View File

@ -1,6 +1,6 @@
<template> <template>
<div class="m-fields-ui-select" v-if="uiSelectMode" @click="cancelHandler"> <div class="m-fields-ui-select" v-if="uiSelectMode" @click="cancelHandler">
<TMagicButton type="danger" :icon="Delete" :disabled="disabled" :size="size" text style="padding: 0" <TMagicButton type="danger" :icon="Delete" :disabled="disabled" :size="size" link style="padding: 0"
>取消</TMagicButton >取消</TMagicButton
> >
</div> </div>
@ -13,14 +13,14 @@
:icon="Close" :icon="Close"
:disabled="disabled" :disabled="disabled"
:size="size" :size="size"
text link
@click.stop="deleteHandler" @click.stop="deleteHandler"
></TMagicButton> ></TMagicButton>
</TMagicTooltip> </TMagicTooltip>
<TMagicTooltip content="点击选中组件" placement="top"> <TMagicTooltip content="点击选中组件" placement="top">
<TMagicButton <TMagicButton
text link
style="padding: 0; margin: 0" style="padding: 0; margin: 0"
:disabled="disabled" :disabled="disabled"
:size="size" :size="size"
@ -33,7 +33,7 @@
</template> </template>
<TMagicTooltip v-else content="点击此处选择" placement="top"> <TMagicTooltip v-else content="点击此处选择" placement="top">
<TMagicButton text style="padding: 0; margin: 0" :disabled="disabled" :size="size" @click="startSelect" <TMagicButton link style="padding: 0; margin: 0" :disabled="disabled" :size="size" @click="startSelect"
>点击此处选择</TMagicButton >点击此处选择</TMagicButton
> >
</TMagicTooltip> </TMagicTooltip>

View File

@ -4,7 +4,7 @@
class="m-editor-page-bar-switch-type-button" class="m-editor-page-bar-switch-type-button"
size="small" size="small"
:key="item.type" :key="item.type"
text link
:class="{ active: modelValue === item.type }" :class="{ active: modelValue === item.type }"
:type="modelValue === item.type ? 'primary' : ''" :type="modelValue === item.type ? 'primary' : ''"
@click="clickHandler(item.type)" @click="clickHandler(item.type)"

View File

@ -1,7 +1,7 @@
<template> <template>
<div v-if="nodes.length === 1" class="m-editor-breadcrumb"> <div v-if="nodes.length === 1" class="m-editor-breadcrumb">
<template v-for="(item, index) in path" :key="item.id"> <template v-for="(item, index) in path" :key="item.id">
<TMagicButton text :disabled="item.id === node?.id" @click="select(item)">{{ item.name }}</TMagicButton <TMagicButton link :disabled="item.id === node?.id" @click="select(item)">{{ item.name }}</TMagicButton
><span v-if="index < path.length - 1">/</span> ><span v-if="index < path.length - 1">/</span>
</template> </template>
</div> </div>

View File

@ -212,7 +212,7 @@
</template> </template>
<div style="text-align: center" v-if="config.expand && type !== 'fieldset'"> <div style="text-align: center" v-if="config.expand && type !== 'fieldset'">
<TMagicButton type="primary" size="small" :disabled="false" text @click="expandHandler">{{ <TMagicButton type="primary" size="small" :disabled="false" link @click="expandHandler">{{
expand ? '收起配置' : '展开更多配置' expand ? '收起配置' : '展开更多配置'
}}</TMagicButton> }}</TMagicButton>
</div> </div>

View File

@ -1,24 +1,24 @@
<template> <template>
<div class="m-fields-group-list-item"> <div class="m-fields-group-list-item">
<div> <div>
<TMagicButton text :disabled="disabled" :icon="expand ? CaretBottom : CaretRight" @click="expandHandler">{{ <TMagicButton link :disabled="disabled" :icon="expand ? CaretBottom : CaretRight" @click="expandHandler">{{
title title
}}</TMagicButton> }}</TMagicButton>
<TMagicButton <TMagicButton
v-show="showDelete(parseInt(String(index)))" v-show="showDelete(parseInt(String(index)))"
style="color: #f56c6c" style="color: #f56c6c"
text link
:icon="Delete" :icon="Delete"
:disabled="disabled" :disabled="disabled"
@click="removeHandler" @click="removeHandler"
></TMagicButton> ></TMagicButton>
<template v-if="movable()"> <template v-if="movable()">
<TMagicButton v-show="index !== 0" text :disabled="disabled" size="small" @click="changeOrder(-1)" <TMagicButton v-show="index !== 0" link :disabled="disabled" size="small" @click="changeOrder(-1)"
>上移<TMagicIcon><CaretTop /></TMagicIcon >上移<TMagicIcon><CaretTop /></TMagicIcon
></TMagicButton> ></TMagicButton>
<TMagicButton v-show="index !== length - 1" :disabled="disabled" text size="small" @click="changeOrder(1)" <TMagicButton v-show="index !== length - 1" :disabled="disabled" link size="small" @click="changeOrder(1)"
>下移<TMagicIcon><CaretBottom /></TMagicIcon >下移<TMagicIcon><CaretBottom /></TMagicIcon
></TMagicButton> ></TMagicButton>
</template> </template>

View File

@ -6,7 +6,7 @@
> >
<template #header> <template #header>
<div style="width: 100%; display: flex; align-items: center"> <div style="width: 100%; display: flex; align-items: center">
<TMagicButton style="padding: 0" text :icon="expand ? CaretBottom : CaretRight" @click="expand = !expand"> <TMagicButton style="padding: 0" link :icon="expand ? CaretBottom : CaretRight" @click="expand = !expand">
</TMagicButton> </TMagicButton>
<span v-if="config && config.extra" v-html="config.extra" class="m-form-tip"></span> <span v-if="config && config.extra" v-html="config.extra" class="m-form-tip"></span>
<slot name="header">{{ filter(config.title) }}</slot> <slot name="header">{{ filter(config.title) }}</slot>

View File

@ -54,7 +54,7 @@
type="primary" type="primary"
:icon="ArrowUp" :icon="ArrowUp"
:disabled="disabled" :disabled="disabled"
text link
@click="upHandler(scope.$index + 1 + pagecontext * pagesize - 1)" @click="upHandler(scope.$index + 1 + pagecontext * pagesize - 1)"
@dblclick="topHandler(scope.$index + 1 + pagecontext * pagesize - 1)" @dblclick="topHandler(scope.$index + 1 + pagecontext * pagesize - 1)"
></TMagicButton> ></TMagicButton>
@ -70,7 +70,7 @@
type="primary" type="primary"
:icon="ArrowDown" :icon="ArrowDown"
:disabled="disabled" :disabled="disabled"
text link
@click="downHandler(scope.$index + 1 + pagecontext * pagesize - 1)" @click="downHandler(scope.$index + 1 + pagecontext * pagesize - 1)"
@dblclick="bottomHandler(scope.$index + 1 + pagecontext * pagesize - 1)" @dblclick="bottomHandler(scope.$index + 1 + pagecontext * pagesize - 1)"
></TMagicButton> ></TMagicButton>

View File

@ -2,7 +2,7 @@
<a v-if="config.href && !disabled" target="_blank" :href="href" :style="config.css || {}">{{ displayText }}</a> <a v-if="config.href && !disabled" target="_blank" :href="href" :style="config.css || {}">{{ displayText }}</a>
<span v-else-if="config.href && disabled" :style="config.disabledCss || {}">{{ displayText }}</span> <span v-else-if="config.href && disabled" :style="config.disabledCss || {}">{{ displayText }}</span>
<div v-else class="m-fields-link"> <div v-else class="m-fields-link">
<TMagicButton :text="true" type="primary" @click="editHandler">点击编辑</TMagicButton> <TMagicButton link type="primary" @click="editHandler">点击编辑</TMagicButton>
<FormDialog <FormDialog
ref="editor" ref="editor"
:title="config.formTitle || '编辑扩展配置'" :title="config.formTitle || '编辑扩展配置'"

View File

@ -11,7 +11,7 @@
<TMagicButton <TMagicButton
v-show="display(action.display, scope.row) && !editState[scope.$index]" v-show="display(action.display, scope.row) && !editState[scope.$index]"
class="action-btn" class="action-btn"
text link
size="small" size="small"
:type="action.buttonType || 'primary'" :type="action.buttonType || 'primary'"
:icon="action.icon" :icon="action.icon"
@ -22,7 +22,7 @@
<TMagicButton <TMagicButton
class="action-btn" class="action-btn"
v-show="editState[scope.$index]" v-show="editState[scope.$index]"
text link
type="primary" type="primary"
size="small" size="small"
@click="save(scope.$index, config)" @click="save(scope.$index, config)"
@ -31,7 +31,7 @@
<TMagicButton <TMagicButton
class="action-btn" class="action-btn"
v-show="editState[scope.$index]" v-show="editState[scope.$index]"
text link
type="primary" type="primary"
size="small" size="small"
@click="editState[scope.$index] = undefined" @click="editState[scope.$index] = undefined"

View File

@ -14,7 +14,7 @@
:data="(config.prop && scope.row[config.prop]) || []" :data="(config.prop && scope.row[config.prop]) || []"
></MTable> ></MTable>
<template #reference> <template #reference>
<TMagicButton text type="primary"> {{ config.text || formatter(config, scope.row) }}</TMagicButton> <TMagicButton link type="primary"> {{ config.text || formatter(config, scope.row) }}</TMagicButton>
</template> </template>
</TMagicPopover> </TMagicPopover>
</template> </template>

View File

@ -20,7 +20,7 @@
<TMagicButton <TMagicButton
v-else-if="config.action === 'actionLink' && config.prop" v-else-if="config.action === 'actionLink' && config.prop"
text link
type="primary" type="primary"
@click="config.handler?.(scope.row)" @click="config.handler?.(scope.row)"
> >
@ -43,7 +43,7 @@
<template #content> <template #content>
<div>{{ formatter(config, scope.row) }}</div> <div>{{ formatter(config, scope.row) }}</div>
</template> </template>
<TMagicButton text type="primary">{{ config.buttonText || '扩展配置' }}</TMagicButton> <TMagicButton link type="primary">{{ config.buttonText || '扩展配置' }}</TMagicButton>
</el-tooltip> </el-tooltip>
<TMagicTag <TMagicTag

View File

@ -126,7 +126,7 @@ const adapter: any = {
theme: props.type, theme: props.type,
size: props.size === 'default' ? 'medium' : props.size, size: props.size === 'default' ? 'medium' : props.size,
icon: () => (props.icon ? h(props.icon) : null), icon: () => (props.icon ? h(props.icon) : null),
variant: props.text ? 'text' : 'base', variant: props.link || props.text ? 'text' : 'base',
}), }),
}, },

View File

@ -5,7 +5,7 @@
class="menu-item button" class="menu-item button"
:key="index" :key="index"
size="small" size="small"
text link
@click="item.handler" @click="item.handler"
> >
<TMagicIcon><component :is="item.icon"></component></TMagicIcon><span>{{ item.text }}</span> <TMagicIcon><component :is="item.icon"></component></TMagicIcon><span>{{ item.text }}</span>