index.vue
1.27 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
<template>
<a-button v-if="type === 'Button'" type="text" size="small" :disabled="disabled as boolean" @click="onClick">
<slot>详情</slot>
</a-button>
<a-link v-else class="link" :disabled="disabled as boolean" :hoverable="false" @click="onClick">
<a-typography-text
type="primary"
:disabled="disabled"
style="margin-bottom: 0 !important"
:ellipsis="{ rows: 1, showTooltip: showTooltip }"
>
<slot>详情</slot>
</a-typography-text>
</a-link>
</template>
<script lang="ts" setup>
import { RouteParamsRaw, useRouter } from 'vue-router';
import { AnyObject } from '@/types/global';
const props = withDefaults(
defineProps<{
name?: string;
params?: AnyObject;
type?: 'Button' | 'link';
showTooltip?: boolean;
disabled?: boolean;
}>(),
{
name: '',
type: 'Button',
params: undefined,
showTooltip: true,
disabled: false,
}
);
const router = useRouter();
const onClick = () => {
router.push({
name: props.name,
params: (props.params as RouteParamsRaw) || {},
});
};
</script>
<style lang="less" scoped>
.link {
width: 100%;
padding: 1px 0;
display: block !important;
}
.link:hover {
cursor: pointer;
}
</style>