LoadingPage.vue 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. <script setup lang="ts">
  2. import ActivityIndicator from '@/components/basic/ActivityIndicator.vue';
  3. import Text, { type TextProps } from '@/components/basic/Text.vue';
  4. import FlexView, { type FlexProps } from '@/components/layout/FlexView.vue';
  5. import { propGetThemeVar, useTheme, type ViewStyle } from '@/components/theme/ThemeDefine';
  6. export interface LoadingPageProps extends FlexProps {
  7. /**
  8. * 加载器下方文字
  9. */
  10. loadingText?: string,
  11. /**
  12. * 加载器下方文字样式
  13. */
  14. loadingTextProps?: TextProps,
  15. /**
  16. * 加载器颜色
  17. * @default Color.primary
  18. */
  19. indicatorColor?: string,
  20. /**
  21. * 加载器样式
  22. */
  23. indicatorStyle?: ViewStyle,
  24. /**
  25. * 容器自定义样式
  26. */
  27. innerStyle?: ViewStyle,
  28. }
  29. const themeContext = useTheme();
  30. const props = withDefaults(defineProps<LoadingPageProps>(), {
  31. loadingText: '加载中',
  32. indicatorColor: () => propGetThemeVar('LoadingPageIndicatorColor', 'primary'),
  33. });
  34. </script>
  35. <template>
  36. <FlexView
  37. position="absolute"
  38. direction="column"
  39. :backgroundColor="themeContext.resolveThemeColor('LoadingPageBackgroundColor', 'mask.white')"
  40. :left="0"
  41. :right="0"
  42. :top="0"
  43. :bottom="0"
  44. center
  45. v-bind="$attrs"
  46. >
  47. <ActivityIndicator
  48. :color="indicatorColor"
  49. :innerStyle="indicatorStyle"
  50. :size="50"
  51. />
  52. <Text
  53. v-if="loadingText"
  54. v-bind="loadingTextProps"
  55. :text="loadingText"
  56. />
  57. <slot />
  58. </FlexView>
  59. </template>