-
-
Notifications
You must be signed in to change notification settings - Fork 78
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
38 changed files
with
1,341 additions
and
495 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
<template> | ||
<i class="mdui-icon material-icons help no-sl" :mdui-tooltip="tooltip">{{ | ||
$root.dark ? 'info' : 'info_outline' | ||
}}</i> | ||
</template> | ||
|
||
<script setup> | ||
import { computed } from 'vue'; | ||
const props = defineProps({ | ||
content: { | ||
type: String, | ||
default: '', | ||
}, | ||
position: { | ||
type: String, | ||
default: 'top', | ||
}, | ||
}); | ||
const tooltip = computed(() => `{content:'${props.content}',position:'${props.position}'}`); | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
<template> | ||
<component | ||
v-if="isOpen" | ||
ref="dialogRef" | ||
:is="component" | ||
v-bind="$attrs" | ||
v-on="$listeners" | ||
@closed="handleClosed" | ||
><slot></slot | ||
></component> | ||
</template> | ||
|
||
<script setup> | ||
import { getWrapper } from '@/mixins/mduiDialog'; | ||
import { sleep } from '@/utils/common'; | ||
import { ref } from 'vue'; | ||
defineProps({ component: Object }); | ||
const emit = defineEmits(['full-closed']); | ||
const isOpen = ref(false); | ||
const dialogRef = ref(); | ||
const wrapper = getWrapper(dialogRef); | ||
let isClosing = false; | ||
const handleClosed = async () => { | ||
if (wrapper.isTempClose()) return; | ||
isClosing = true; | ||
await sleep(); | ||
isOpen.value = false; | ||
isClosing = false; | ||
emit('full-closed'); | ||
}; | ||
const open = async (...args) => { | ||
if (isClosing) return; | ||
isOpen.value = true; | ||
await sleep(); | ||
wrapper.open(...args); | ||
}; | ||
const close = async (...args) => { | ||
wrapper.close(...args); | ||
}; | ||
const toggle = (...args) => (isOpen.value ? close(...args) : open(...args)); | ||
defineExpose({ ...wrapper, open, close, toggle }); | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,111 @@ | ||
<template> | ||
<Teleport v-if="isShow" to="body"> | ||
<div | ||
class="simple-alert-overlay" | ||
:class="{ 'simple-alert-overlay-show': isShowAnimation }" | ||
@transitionend="handleOverlayTransitionEnd" | ||
@click.self="close" | ||
> | ||
<div | ||
class="simple-alert mdui-dialog mdui-dialog-alert" | ||
:class="{ 'mdui-dialog-open': isShowAnimation }" | ||
@transitionend="handleDialogTransitionEnd" | ||
> | ||
<div class="mdui-dialog-content mdui-p-b-0" v-html="html"></div> | ||
<div class="mdui-dialog-actions"> | ||
<a | ||
href="javascript:void(0)" | ||
class="mdui-btn mdui-ripple mdui-text-color-primary" | ||
@click="close" | ||
>{{ $t('common.close') }}</a | ||
> | ||
</div> | ||
</div> | ||
</div> | ||
</Teleport> | ||
</template> | ||
|
||
<script setup> | ||
import { ref } from 'vue'; | ||
import { sleep } from '@/utils/common'; | ||
defineProps({ | ||
html: String, | ||
}); | ||
const isShow = ref(false); | ||
const isShowAnimation = ref(false); | ||
let resolveOverlayTransition; | ||
let resolveDialogTransition; | ||
const handleOverlayTransitionEnd = () => { | ||
if (isShowAnimation.value) return; | ||
resolveOverlayTransition?.(); | ||
}; | ||
const handleDialogTransitionEnd = () => { | ||
if (isShowAnimation.value) return; | ||
resolveDialogTransition?.(); | ||
}; | ||
const open = async () => { | ||
if (isShow.value) return; | ||
isShow.value = true; | ||
await sleep(); | ||
isShowAnimation.value = true; | ||
}; | ||
const close = async () => { | ||
if (!isShowAnimation.value) return; | ||
const promises = [ | ||
new Promise(resolve => { | ||
resolveOverlayTransition = () => { | ||
resolve(); | ||
resolveOverlayTransition = null; | ||
}; | ||
}), | ||
new Promise(resolve => { | ||
resolveDialogTransition = () => { | ||
resolve(); | ||
resolveDialogTransition = null; | ||
}; | ||
}), | ||
]; | ||
isShowAnimation.value = false; | ||
await Promise.race([Promise.all(promises), sleep(500)]); | ||
isShow.value = false; | ||
}; | ||
defineExpose({ open, close }); | ||
</script> | ||
<style lang="scss" scoped> | ||
.simple-alert { | ||
display: block; | ||
position: fixed; | ||
top: 0; | ||
right: 0; | ||
bottom: 0; | ||
left: 0; | ||
height: fit-content; | ||
max-width: 560px; | ||
margin: auto; | ||
opacity: 1; | ||
&-overlay { | ||
position: fixed; | ||
top: 0; | ||
right: 0; | ||
bottom: 0; | ||
left: 0; | ||
background: rgba(0, 0, 0, 0.4); | ||
opacity: 0; | ||
transition-duration: 0.3s; | ||
transition-property: opacity; | ||
backface-visibility: hidden; | ||
z-index: 8000; | ||
&-show { | ||
opacity: 1; | ||
} | ||
} | ||
} | ||
</style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.