123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384 |
- <!-- ai全局提示 message -->
- <template>
- <div
- v-if="visible"
- class="ai-message"
- :class="{
- success: option.type === 'success',
- warning: option.type === 'warning',
- error: option.type === 'error'
- }"
- >
- {{ option.text }}
- </div>
- </template>
- <script setup lang="ts">
- import { watch, computed } from 'vue'
- const props = defineProps({
- /*
- 配置
- text: 提示文字
- type: 提示状态 success warning error
- */
- messageOption: {
- type: Object,
- default: () => {}
- },
- visible: {
- type: Boolean,
- default: false
- }
- })
- const option = computed(() => {
- return {
- text: '',
- type: '', // success warning error
- ...props.messageOption
- }
- })
- const emit = defineEmits(['update:visible'])
- watch(
- () => props.visible,
- (value) => {
- if (value) {
- setTimeout(() => {
- emit('update:visible', false)
- }, 1500)
- }
- }
- )
- </script>
- <style lang="less" scoped>
- @import '../styles/variables.less';
- .ai-message {
- position: absolute;
- left: 50%;
- top: 50%;
- transform: translate(-50%, -50%);
- background: #fff;
- padding: 8px 16px;
- border-radius: 8px;
- box-shadow: 2px 2px 10px 2px rgba(0, 0, 0, 0.1);
- max-width: 300px;
- border: 1px solid transparent;
- &.success {
- // border-color: $--color-success;
- color: @color-success;
- // box-shadow: 2px 2px 10px 2px rgba($--color-success, 0.1);
- }
- &.warning {
- // border-color: $--color-warning;
- color: @color-warning;
- // box-shadow: 2px 2px 10px 2px rgba($--color-warning, 0.1);
- }
- &.error {
- // border-color: $--color-danger;
- color: @color-danger;
- // box-shadow: 2px 2px 10px 2px rgba($--color-danger, 0.1);
- }
- }
- </style>
|