mirror of https://github.com/halo-dev/halo-admin
feat(components/base/button): support route prop to push route
parent
3208cc8bdc
commit
3d81d94197
|
@ -37,6 +37,8 @@
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import type { PropType } from "vue";
|
import type { PropType } from "vue";
|
||||||
import { computed } from "vue";
|
import { computed } from "vue";
|
||||||
|
import type { RouteLocationRaw } from "vue-router";
|
||||||
|
import { useRouter } from "vue-router";
|
||||||
import type { Size, Type } from "@/components/base/button/interface";
|
import type { Size, Type } from "@/components/base/button/interface";
|
||||||
|
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
|
@ -64,8 +66,12 @@ const props = defineProps({
|
||||||
type: Boolean,
|
type: Boolean,
|
||||||
default: false,
|
default: false,
|
||||||
},
|
},
|
||||||
|
route: {
|
||||||
|
type: Object as PropType<RouteLocationRaw>,
|
||||||
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const router = useRouter();
|
||||||
const emit = defineEmits(["click"]);
|
const emit = defineEmits(["click"]);
|
||||||
|
|
||||||
const classes = computed(() => {
|
const classes = computed(() => {
|
||||||
|
@ -80,6 +86,9 @@ const classes = computed(() => {
|
||||||
|
|
||||||
function handleClick() {
|
function handleClick() {
|
||||||
if (props.disabled || props.loading) return;
|
if (props.disabled || props.loading) return;
|
||||||
|
if (props.route) {
|
||||||
|
router.push(props.route);
|
||||||
|
}
|
||||||
emit("click");
|
emit("click");
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
@ -120,6 +129,7 @@ function handleClick() {
|
||||||
|
|
||||||
.btn-default {
|
.btn-default {
|
||||||
border: 1px solid #d9d9d9;
|
border: 1px solid #d9d9d9;
|
||||||
|
|
||||||
.btn-icon {
|
.btn-icon {
|
||||||
color: #0e1731;
|
color: #0e1731;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue