feat: GhostButton component

This commit is contained in:
dap 2024-10-07 13:53:10 +08:00
parent 1aa338ba34
commit 81d868aa61
4 changed files with 47 additions and 22 deletions

View File

@ -0,0 +1,21 @@
import { defineComponent, h } from 'vue';
import { Button } from 'ant-design-vue';
import buttonProps from 'ant-design-vue/es/button/buttonTypes';
import { omit } from 'lodash-es';
/**
*
*/
export const GhostButton = defineComponent({
name: 'GhostButton',
props: omit(buttonProps(), ['type', 'ghost', 'size']),
setup(props, { attrs, slots }) {
return () =>
h(
Button,
{ ...props, ...attrs, type: 'primary', ghost: true, size: 'small' },
slots,
);
},
});

View File

@ -2,9 +2,13 @@ import type { App } from 'vue';
import { Button as AButton } from 'ant-design-vue';
import { GhostButton } from './button';
/**
*
*/
export function setupGlobalComponent(app: App) {
app.use(AButton);
// 表格操作列专用按钮
app.component('GhostButton', GhostButton);
}

View File

@ -248,29 +248,28 @@ function handleResetPwd(record: Recordable<any>) {
</template>
<template #action="{ row }">
<template v-if="row.userId !== 1">
<a-button
size="small"
type="link"
v-access:code="['system:user:edit']"
@click.stop="handleEdit(row)"
>
{{ $t('pages.common.edit') }}
</a-button>
<Popconfirm
placement="left"
title="确认删除?"
@confirm="handleDelete(row)"
>
<a-button
danger
size="small"
type="link"
v-access:code="['system:user:remove']"
@click.stop=""
<Space>
<ghost-button
v-access:code="['system:user:edit']"
@click.stop="handleEdit(row)"
>
{{ $t('pages.common.delete') }}
</a-button>
</Popconfirm>
{{ $t('pages.common.edit') }}
</ghost-button>
<Popconfirm
:get-popup-container="getPopupContainer"
placement="left"
title="确认删除?"
@confirm="handleDelete(row)"
>
<ghost-button
danger
v-access:code="['system:user:remove']"
@click.stop=""
>
{{ $t('pages.common.delete') }}
</ghost-button>
</Popconfirm>
</Space>
<Dropdown
:get-popup-container="getPopupContainer"
placement="bottomRight"

View File

@ -4,5 +4,6 @@ export {};
declare module 'vue' {
export interface GlobalComponents {
AButton: typeof import('ant-design-vue/es/button')['default'];
GhostButton: typeof import('#/components/global/button')['GhostButton']
}
}