| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889 |
- <template>
- <view class="base-empty" :class="{ 'base-empty--compact': compact }">
- <!-- 图标:slot > 默认内联 SVG;icon 属性为旧调用方文本兜底(不新建 emoji) -->
- <view class="base-empty__icon" v-if="hasIcon">
- <slot name="icon" v-if="$slots.icon"></slot>
- <svg
- v-else-if="!icon"
- class="base-empty__svg"
- viewBox="0 0 48 48"
- width="80rpx"
- height="80rpx"
- aria-hidden="true"
- >
- <circle cx="24" cy="24" r="22" fill="currentColor" opacity="0.12"></circle>
- <path
- d="M24 12c-6 0-10 4.2-10 9.6 0 6.8 6.4 11.6 10 14.4 3.6-2.8 10-7.6 10-14.4C34 16.2 30 12 24 12z"
- fill="currentColor"
- ></path>
- </svg>
- <text v-else class="base-empty__glyph">{{ icon }}</text>
- </view>
- <text class="base-empty__title" v-if="title">{{ title }}</text>
- <text class="base-empty__description" v-if="description">{{ description }}</text>
- <view class="base-empty__action" v-if="$slots.action">
- <slot name="action"></slot>
- </view>
- </view>
- </template>
- <script>
- export default {
- name: 'BaseEmpty',
- props: {
- icon: { type: String, default: '' },
- title: { type: String, default: '' },
- description: { type: String, default: '' },
- compact: { type: Boolean, default: false }
- },
- computed: {
- hasIcon() {
- return !!this.icon || !!this.$slots.icon
- }
- }
- }
- </script>
- <style scoped lang="scss">
- .base-empty {
- display: flex;
- flex-direction: column;
- align-items: center;
- justify-content: center;
- padding: 80rpx 32rpx;
- min-height: 400rpx;
- }
- .base-empty--compact {
- padding: 48rpx 32rpx;
- min-height: auto;
- }
- .base-empty__icon {
- margin-bottom: 24rpx;
- color: $uni-primary;
- }
- .base-empty__svg {
- display: block;
- }
- .base-empty__glyph {
- font-size: calc(80rpx * var(--font-scale, 1));
- display: block;
- text-align: center;
- }
- .base-empty__title {
- font-size: calc(30rpx * var(--font-scale, 1));
- font-weight: 600;
- color: $uni-text-color;
- margin-bottom: 12rpx;
- text-align: center;
- }
- .base-empty__description {
- font-size: calc(26rpx * var(--font-scale, 1));
- color: $uni-text-color-secondary;
- text-align: center;
- line-height: 1.6;
- max-width: 500rpx;
- }
- .base-empty__action {
- margin-top: 32rpx;
- }
- </style>
|