消息
This commit is contained in:
3
TUIKit/components/common/Dialog/index.ts
Normal file
3
TUIKit/components/common/Dialog/index.ts
Normal file
@@ -0,0 +1,3 @@
|
||||
import Dialog from './index.vue';
|
||||
|
||||
export default Dialog;
|
||||
119
TUIKit/components/common/Dialog/index.vue
Normal file
119
TUIKit/components/common/Dialog/index.vue
Normal file
@@ -0,0 +1,119 @@
|
||||
<template>
|
||||
<div
|
||||
v-if="showDialog"
|
||||
class="dialog"
|
||||
:class="[!isPC ? 'dialog-h5' : '', center ? 'center' : '']"
|
||||
@click.stop.prevent="toggleView(clickType.OUTSIDE)"
|
||||
>
|
||||
<main
|
||||
class="dialog-main"
|
||||
:class="[!backgroundDialog ? 'dialog-main-back' : '']"
|
||||
@click.stop.prevent="toggleView(clickType.INSIDE)"
|
||||
>
|
||||
<header
|
||||
v-if="isHeaderShowDialog"
|
||||
class="dialog-main-header"
|
||||
>
|
||||
<h1 class="dialog-main-title">
|
||||
{{ showTitle }}
|
||||
</h1>
|
||||
<i
|
||||
class="icon icon-close"
|
||||
@click="close"
|
||||
/>
|
||||
</header>
|
||||
<div
|
||||
class="dialog-main-content"
|
||||
:class="[isUniFrameWork && isH5 ? 'dialog-main-content-uniapp' : '']"
|
||||
>
|
||||
<slot />
|
||||
</div>
|
||||
<footer
|
||||
v-if="isFooterShowDialog"
|
||||
class="dialog-main-footer"
|
||||
>
|
||||
<button
|
||||
class="btn btn-cancel"
|
||||
@click="close"
|
||||
>
|
||||
{{ TUITranslateService.t('component.取消') }}
|
||||
</button>
|
||||
<button
|
||||
class="btn btn-default"
|
||||
@click="submit"
|
||||
>
|
||||
{{ TUITranslateService.t('component.确定') }}
|
||||
</button>
|
||||
</footer>
|
||||
</main>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { ref, watchEffect } from '../../../adapter-vue';
|
||||
import { TUITranslateService } from '@tencentcloud/chat-uikit-engine';
|
||||
import { isPC, isH5, isUniFrameWork } from '../../../utils/env';
|
||||
const clickType = {
|
||||
OUTSIDE: 'outside',
|
||||
INSIDE: 'inside',
|
||||
};
|
||||
const props = defineProps({
|
||||
show: {
|
||||
type: Boolean,
|
||||
default: false,
|
||||
},
|
||||
isHeaderShow: {
|
||||
type: Boolean,
|
||||
default: true,
|
||||
},
|
||||
isFooterShow: {
|
||||
type: Boolean,
|
||||
default: true,
|
||||
},
|
||||
background: {
|
||||
type: Boolean,
|
||||
default: true,
|
||||
},
|
||||
title: {
|
||||
type: String,
|
||||
default: '',
|
||||
},
|
||||
center: {
|
||||
type: Boolean,
|
||||
default: false,
|
||||
},
|
||||
});
|
||||
|
||||
const showDialog = ref(false);
|
||||
const isHeaderShowDialog = ref(true);
|
||||
const isFooterShowDialog = ref(true);
|
||||
const backgroundDialog = ref(true);
|
||||
const showTitle = ref('');
|
||||
|
||||
watchEffect(() => {
|
||||
showDialog.value = props.show;
|
||||
showTitle.value = props.title;
|
||||
isHeaderShowDialog.value = props.isHeaderShow;
|
||||
isFooterShowDialog.value = props.isFooterShow;
|
||||
backgroundDialog.value = props.background;
|
||||
});
|
||||
|
||||
const emit = defineEmits(['update:show', 'submit']);
|
||||
|
||||
const toggleView = (type: string) => {
|
||||
if (type === clickType.OUTSIDE) {
|
||||
close();
|
||||
}
|
||||
};
|
||||
|
||||
const close = () => {
|
||||
showDialog.value = !showDialog.value;
|
||||
emit('update:show', showDialog.value);
|
||||
};
|
||||
|
||||
const submit = () => {
|
||||
emit('submit');
|
||||
close();
|
||||
};
|
||||
</script>
|
||||
<style lang="scss" scoped src="./style/dialog.scss"></style>
|
||||
43
TUIKit/components/common/Dialog/style/color.scss
Normal file
43
TUIKit/components/common/Dialog/style/color.scss
Normal file
@@ -0,0 +1,43 @@
|
||||
.dialog {
|
||||
background: rgba(0, 0, 0, 0.6);
|
||||
|
||||
&-main {
|
||||
background: #FFF;
|
||||
|
||||
&-header {
|
||||
font-weight: 500;
|
||||
color: #333;
|
||||
}
|
||||
|
||||
&-title {
|
||||
font-family: PingFangSC-Medium;
|
||||
font-weight: 500;
|
||||
color: #333;
|
||||
}
|
||||
|
||||
&-back {
|
||||
background: none;
|
||||
}
|
||||
|
||||
&-content {
|
||||
font-weight: 400;
|
||||
color: #333;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.btn {
|
||||
font-weight: 400;
|
||||
color: #FFF;
|
||||
letter-spacing: 0;
|
||||
|
||||
&-cancel {
|
||||
border: 1px solid #ddd;
|
||||
color: #666;
|
||||
}
|
||||
|
||||
&-default {
|
||||
background: #006EFF;
|
||||
border: 1px solid #006EFF;
|
||||
}
|
||||
}
|
||||
4
TUIKit/components/common/Dialog/style/dialog.scss
Normal file
4
TUIKit/components/common/Dialog/style/dialog.scss
Normal file
@@ -0,0 +1,4 @@
|
||||
@import '../../../../assets/styles/common';
|
||||
@import "./color";
|
||||
@import "./web";
|
||||
@import "./h5";
|
||||
56
TUIKit/components/common/Dialog/style/h5.scss
Normal file
56
TUIKit/components/common/Dialog/style/h5.scss
Normal file
@@ -0,0 +1,56 @@
|
||||
.dialog-h5 {
|
||||
height: 100%;
|
||||
top: 0;
|
||||
align-items: inherit;
|
||||
|
||||
.dialog {
|
||||
&-main {
|
||||
border-radius: 0;
|
||||
padding: 0;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
overflow: hidden;
|
||||
width: 100%;
|
||||
min-height: 80px;
|
||||
min-width: 120px;
|
||||
|
||||
&-content {
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
min-height: 0;
|
||||
overflow: hidden;
|
||||
text-align: center;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
margin-bottom: 0;
|
||||
|
||||
&-uniapp {
|
||||
padding: 40px 0;
|
||||
}
|
||||
}
|
||||
|
||||
&-footer {
|
||||
border-top: 1px solid #DDD;
|
||||
|
||||
.btn {
|
||||
flex: 1;
|
||||
margin: 0;
|
||||
background: none;
|
||||
border-right: 1px solid #DDD;
|
||||
|
||||
&-default {
|
||||
color: #FF584C;
|
||||
border: none;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.center {
|
||||
align-items: center;
|
||||
padding: 20px;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
61
TUIKit/components/common/Dialog/style/web.scss
Normal file
61
TUIKit/components/common/Dialog/style/web.scss
Normal file
@@ -0,0 +1,61 @@
|
||||
.dialog {
|
||||
position: fixed;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
left: 0;
|
||||
top: 0;
|
||||
z-index: 6;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
|
||||
&-main {
|
||||
min-width: 368px;
|
||||
border-radius: 10px;
|
||||
padding: 20px 30px;
|
||||
|
||||
&-header {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
font-size: 16px;
|
||||
line-height: 30px;
|
||||
}
|
||||
|
||||
&-title {
|
||||
font-size: 16px;
|
||||
line-height: 30px;
|
||||
}
|
||||
|
||||
&-content {
|
||||
font-size: 14px;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
|
||||
&-footer {
|
||||
display: flex;
|
||||
justify-content: flex-end;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.btn {
|
||||
padding: 8px 20px;
|
||||
margin: 0 6px;
|
||||
border-radius: 4px;
|
||||
border: none;
|
||||
font-size: 14px;
|
||||
text-align: center;
|
||||
line-height: 20px;
|
||||
|
||||
&:disabled {
|
||||
opacity: 0.3;
|
||||
}
|
||||
|
||||
&:last-child {
|
||||
margin-right: 0;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user