Skip to content

Commit

Permalink
fix(components): add click event when click mask
Browse files Browse the repository at this point in the history
  • Loading branch information
honghuangdc committed May 25, 2023
1 parent ccc6bb6 commit dbda30a
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
1 change: 1 addition & 0 deletions packages/vue/src/demos/admin-layout.vue
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
:fixed-footer="fixedFooter"
:right-footer="rightFooter"
class="bg-#f2f3f4"
@click-mobile-sider-mask="toggleSiderCollapse"
>
<template #header>
<div class="h-full p-2px bg-white rd-12px">
Expand Down
12 changes: 12 additions & 0 deletions packages/vue/src/libs/admin-layout/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@
<div
v-show="!siderCollapse"
:class="[':soy: absolute left-0 top-0 w-full h-full bg-[rgba(0,0,0,0.2)]', style['layout-mobile-sider-mask']]"
@click="handleClickMask"
></div>
</template>

Expand Down Expand Up @@ -155,6 +156,13 @@ const props = withDefaults(defineProps<LayoutProps>(), {
rightFooter: false
});
interface Emits {
/** 点击移动端模式下的蒙层 */
(e: 'click-mobile-sider-mask'): void;
}
const emit = defineEmits<Emits>();
type SlotFn = (props?: Record<string, unknown>) => any;
type Slots = {
Expand Down Expand Up @@ -228,6 +236,10 @@ const siderPaddingClass = computed(() => {
return cls;
});
function handleClickMask() {
emit('click-mobile-sider-mask');
}
</script>

<style scoped></style>

0 comments on commit dbda30a

Please sign in to comment.