消息
This commit is contained in:
@@ -0,0 +1,138 @@
|
||||
<template>
|
||||
<div
|
||||
ref="toolbarItemRef"
|
||||
:class="[
|
||||
'toolbar-item-container',
|
||||
!isPC && 'toolbar-item-container-h5',
|
||||
isUniFrameWork && 'toolbar-item-container-uni',
|
||||
]"
|
||||
>
|
||||
<div
|
||||
:class="[
|
||||
'toolbar-item-container-icon',
|
||||
isUniFrameWork && 'toolbar-item-container-uni-icon',
|
||||
]"
|
||||
@click="toggleToolbarItem"
|
||||
>
|
||||
<Icon
|
||||
:file="props.iconFile"
|
||||
class="icon"
|
||||
:width="props.iconWidth"
|
||||
:height="props.iconHeight"
|
||||
/>
|
||||
</div>
|
||||
<div
|
||||
v-if="isUniFrameWork"
|
||||
:class="['toolbar-item-container-uni-title']"
|
||||
>
|
||||
{{ props.title }}
|
||||
</div>
|
||||
<div
|
||||
v-show="showDialog"
|
||||
ref="dialogRef"
|
||||
:class="[
|
||||
'toolbar-item-container-dialog',
|
||||
isDark && 'toolbar-item-container-dialog-dark',
|
||||
!isPC && 'toolbar-item-container-h5-dialog',
|
||||
isUniFrameWork && 'toolbar-item-container-uni-dialog',
|
||||
]"
|
||||
>
|
||||
<BottomPopup
|
||||
v-if="props.needBottomPopup && !isPC"
|
||||
class="toolbar-bottom-popup"
|
||||
:show="showDialog"
|
||||
@touchmove.stop.prevent
|
||||
@onClose="onPopupClose"
|
||||
>
|
||||
<slot />
|
||||
</BottomPopup>
|
||||
<slot v-else />
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
<script lang="ts" setup>
|
||||
import { ref } from '../../../../adapter-vue';
|
||||
import { outsideClick } from '@tencentcloud/universal-api';
|
||||
import Icon from '../../../common/Icon.vue';
|
||||
import BottomPopup from '../../../common/BottomPopup/index.vue';
|
||||
import { isPC, isUniFrameWork } from '../../../../utils/env';
|
||||
import TUIChatConfig from '../../config';
|
||||
|
||||
const props = defineProps({
|
||||
iconFile: {
|
||||
type: String,
|
||||
required: true,
|
||||
},
|
||||
title: {
|
||||
type: String,
|
||||
default: '',
|
||||
},
|
||||
needDialog: {
|
||||
type: Boolean,
|
||||
default: true,
|
||||
},
|
||||
iconWidth: {
|
||||
type: String,
|
||||
default: '20px',
|
||||
},
|
||||
iconHeight: {
|
||||
type: String,
|
||||
default: '20px',
|
||||
},
|
||||
// Whether to display the bottom popup dialog on mobile devices
|
||||
// Invalid on PC
|
||||
needBottomPopup: {
|
||||
type: Boolean,
|
||||
default: false,
|
||||
},
|
||||
});
|
||||
|
||||
const emits = defineEmits(['onIconClick', 'onDialogClose', 'onDialogShow']);
|
||||
|
||||
const isDark = ref(TUIChatConfig.getTheme() === 'dark');
|
||||
const showDialog = ref(false);
|
||||
const toolbarItemRef = ref();
|
||||
const dialogRef = ref();
|
||||
|
||||
const toggleToolbarItem = () => {
|
||||
emits('onIconClick', dialogRef);
|
||||
if (isPC) {
|
||||
outsideClick.listen({
|
||||
domRefs: toolbarItemRef.value,
|
||||
handler: closeToolbarItem,
|
||||
});
|
||||
}
|
||||
if (!props.needDialog) {
|
||||
return;
|
||||
}
|
||||
toggleDialogDisplay(!showDialog.value);
|
||||
};
|
||||
|
||||
const closeToolbarItem = () => {
|
||||
showDialog.value = false;
|
||||
emits('onDialogClose', dialogRef);
|
||||
};
|
||||
|
||||
const toggleDialogDisplay = (showStatus: boolean) => {
|
||||
if (showDialog.value === showStatus) {
|
||||
return;
|
||||
}
|
||||
showDialog.value = showStatus;
|
||||
switch (showStatus) {
|
||||
case true:
|
||||
emits('onDialogShow', dialogRef);
|
||||
break;
|
||||
case false:
|
||||
emits('onDialogClose', dialogRef);
|
||||
}
|
||||
};
|
||||
|
||||
const onPopupClose = () => {
|
||||
showDialog.value = false;
|
||||
};
|
||||
|
||||
defineExpose({
|
||||
toggleDialogDisplay,
|
||||
});
|
||||
</script>
|
||||
<style lang="scss" scoped src="./style/index.scss"></style>
|
||||
@@ -0,0 +1,6 @@
|
||||
.toolbar-item-container {
|
||||
&-dialog {
|
||||
background: #fff;
|
||||
box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.1);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
.toolbar-item-container-h5 {
|
||||
&-dialog {
|
||||
position: static !important;
|
||||
width: 100%;
|
||||
box-shadow: none;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
@import "../../../../../assets/styles/common";
|
||||
@import "./color";
|
||||
@import "./web";
|
||||
@import "./h5";
|
||||
@import "./uni";
|
||||
@@ -0,0 +1,36 @@
|
||||
.toolbar-item-container-uni {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
position: static;
|
||||
|
||||
&-icon {
|
||||
background: #fff;
|
||||
border-radius: 15px;
|
||||
width: 60px;
|
||||
height: 60px;
|
||||
padding: 0;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
&-title {
|
||||
font-size: 14px;
|
||||
color: #8F959D;
|
||||
}
|
||||
|
||||
&-dialog{
|
||||
position: absolute !important;
|
||||
background: transparent;
|
||||
left: -10px;
|
||||
bottom: -5px;
|
||||
|
||||
.toolbar-bottom-popup{
|
||||
position: sticky;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
.toolbar-item-container {
|
||||
position: relative;
|
||||
|
||||
&-icon {
|
||||
padding: 8px;
|
||||
cursor: pointer;
|
||||
-webkit-tap-highlight-color: transparent;
|
||||
}
|
||||
|
||||
&-dialog {
|
||||
z-index: 5;
|
||||
position: absolute;
|
||||
background: #fff;
|
||||
box-shadow: 0 2px 4px -3px rgba(32, 77, 141, 0.03), 0 6px 10px 1px rgba(32, 77, 141, 0.06), 0 3px 14px 2px rgba(32, 77, 141, 0.05);
|
||||
width: fit-content;
|
||||
height: fit-content;
|
||||
bottom: 35px;
|
||||
}
|
||||
|
||||
&-dialog-dark {
|
||||
background: #22262E;
|
||||
box-shadow: 0 8px 40px 0 rgba(23, 25, 31, 0.6), 0 4px 12px 0 rgba(23, 25, 31, 0.8);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user