index.vue 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241
  1. <template>
  2. <div :class="[prefixCls, getLayoutContentMode, { 'layout-content-full': getShowFullHeader }]" v-loading="getOpenPageLoading && getPageLoading">
  3. <PageLayout class="page-box"/>
  4. <!-- update-begin-author:zyf date:20211129 for:qiankun 挂载子应用盒子 -->
  5. <div v-if="getShowFullHeader && loading" class="app-loading">
  6. <div id="loader-wrapper" class="app-loading">
  7. <div class="app-loading-wrap">
  8. <div class="app-loading-dots">
  9. <span class="dot dot-spin"><i></i><i></i><i></i><i></i></span>
  10. </div>
  11. </div>
  12. </div>
  13. </div>
  14. <div id="content" class="app-view-box" v-show="openQianKun == 'true' && currentRoute.path.startsWith('/micro-')" :style="{top: getShowFullHeader ? 0 : '48px'}"> </div>
  15. <!-- update-end-author:zyf date:20211129 for: qiankun 挂载子应用盒子-->
  16. </div>
  17. </template>
  18. <script lang="ts">
  19. import { defineComponent, onMounted, unref, computed, ref, onBeforeMount } from 'vue';
  20. import PageLayout from '/@/layouts/page/index.vue';
  21. import { useDesign } from '/@/hooks/web/useDesign';
  22. import { useRootSetting } from '/@/hooks/setting/useRootSetting';
  23. import { useTransitionSetting } from '/@/hooks/setting/useTransitionSetting';
  24. import { useContentViewHeight } from './useContentViewHeight';
  25. import { useHeaderSetting } from '/@/hooks/setting/useHeaderSetting';
  26. import { useRouter } from 'vue-router';
  27. import { registerApps } from '/@/qiankun';
  28. import { useGlobSetting } from '/@/hooks/setting';
  29. import { getActions } from '/@/qiankun/state';
  30. export default defineComponent({
  31. name: 'LayoutContent',
  32. components: { PageLayout },
  33. setup() {
  34. const { prefixCls } = useDesign('layout-content');
  35. const { getOpenPageLoading } = useTransitionSetting();
  36. const { getLayoutContentMode, getPageLoading } = useRootSetting();
  37. const { getShowFullHeaderRef } = useHeaderSetting();
  38. const router = useRouter();
  39. const { currentRoute } = router;
  40. const globSetting = useGlobSetting();
  41. const openQianKun = globSetting.openQianKun;
  42. const loading = ref(false);
  43. let actions;
  44. if (openQianKun == 'true') {
  45. actions = getActions();
  46. actions.setGlobalState({ isMounted: false });
  47. actions.onGlobalStateChange((newState, prev) => {
  48. for (const key in newState) {
  49. if (key === 'isMounted') {
  50. if (newState[key] !== prev[key] && newState[key] === true) {
  51. loading.value = false;
  52. console.log('首页已经渲染完毕');
  53. }
  54. }
  55. }
  56. });
  57. }
  58. useContentViewHeight();
  59. const getShowFullHeader = computed(() => {
  60. const route = unref(currentRoute);
  61. return getShowFullHeaderRef.value && ((route.path.startsWith('/micro-')));
  62. });
  63. onBeforeMount(() => {});
  64. onMounted(() => {
  65. //注册openQianKun
  66. // console.log('window.qiankunStarted------>', window.qiankunStarted);
  67. if (openQianKun == 'true') {
  68. if (!window.qiankunStarted) {
  69. window.qiankunStarted = true;
  70. registerApps();
  71. }
  72. }
  73. });
  74. return {
  75. prefixCls,
  76. openQianKun,
  77. getOpenPageLoading,
  78. getLayoutContentMode,
  79. getPageLoading,
  80. getShowFullHeader,
  81. loading,
  82. currentRoute
  83. };
  84. },
  85. });
  86. </script>
  87. <style lang="less" scoped>
  88. @prefix-cls: ~'@{namespace}-layout-content';
  89. @ventSpace: zxm;
  90. .@{prefix-cls} {
  91. position: relative;
  92. flex: 1 1 auto;
  93. min-height: 0;
  94. &.fixed {
  95. width: 1200px;
  96. margin: 0 auto;
  97. }
  98. &-loading {
  99. position: absolute;
  100. top: 200px;
  101. z-index: @page-loading-z-index;
  102. }
  103. }
  104. .app-view-box{
  105. position: fixed;
  106. width: 100%;
  107. height: 100%;
  108. top: 0;
  109. left:0;
  110. background: transparent;
  111. }
  112. .layout-content-full {
  113. // height: calc(100vh - 48px);
  114. // margin-top: 48px;
  115. // overflow-y: auto;
  116. height: 100%
  117. }
  118. .app-loading {
  119. display: flex;
  120. width: 100%;
  121. height: 100%;
  122. justify-content: center;
  123. align-items: center;
  124. flex-direction: column;
  125. // background-color: #f4f7f900;
  126. background-image: url('/@/assets/images/vent/loading-bg.png');
  127. background-size: cover;
  128. background-repeat: no-repeat;
  129. background-color: #09172C;
  130. }
  131. .app-loading .app-loading-wrap {
  132. position: absolute;
  133. top: 50%;
  134. left: 50%;
  135. display: flex;
  136. -webkit-transform: translate3d(-50%, -50%, 0);
  137. transform: translate3d(-50%, -50%, 0);
  138. justify-content: center;
  139. align-items: center;
  140. flex-direction: column;
  141. }
  142. .app-loading .dots {
  143. display: flex;
  144. padding: 98px;
  145. justify-content: center;
  146. align-items: center;
  147. }
  148. .app-loading .app-loading-title {
  149. display: flex;
  150. margin-top: 30px;
  151. font-size: 30px;
  152. color: rgba(0, 0, 0, 0.85);
  153. justify-content: center;
  154. align-items: center;
  155. }
  156. .dot {
  157. position: relative;
  158. display: inline-block;
  159. width: 32px;
  160. height: 32px;
  161. margin-top: 30px;
  162. font-size: 32px;
  163. transform: rotate(45deg);
  164. box-sizing: border-box;
  165. animation: antRotate 1.2s infinite linear;
  166. }
  167. .dot i {
  168. position: absolute;
  169. display: block;
  170. width: 14px;
  171. height: 14px;
  172. background-color: #0065cc;
  173. // background-color: #d1d1d1;
  174. border-radius: 100%;
  175. opacity: 0.3;
  176. transform: scale(0.75);
  177. animation: antSpinMove 1s infinite linear alternate;
  178. transform-origin: 50% 50%;
  179. }
  180. .dot i:nth-child(1) {
  181. top: 0;
  182. left: 0;
  183. }
  184. .dot i:nth-child(2) {
  185. top: 0;
  186. right: 0;
  187. -webkit-animation-delay: 0.4s;
  188. animation-delay: 0.4s;
  189. }
  190. .dot i:nth-child(3) {
  191. right: 0;
  192. bottom: 0;
  193. -webkit-animation-delay: 0.8s;
  194. animation-delay: 0.8s;
  195. }
  196. .dot i:nth-child(4) {
  197. bottom: 0;
  198. left: 0;
  199. -webkit-animation-delay: 1.2s;
  200. animation-delay: 1.2s;
  201. }
  202. @keyframes antRotate {
  203. to {
  204. -webkit-transform: rotate(405deg);
  205. transform: rotate(405deg);
  206. }
  207. }
  208. @-webkit-keyframes antRotate {
  209. to {
  210. -webkit-transform: rotate(405deg);
  211. transform: rotate(405deg);
  212. }
  213. }
  214. @keyframes antSpinMove {
  215. to {
  216. opacity: 1;
  217. }
  218. }
  219. @-webkit-keyframes antSpinMove {
  220. to {
  221. opacity: 1;
  222. }
  223. }
  224. :deep(.@{ventSpace}-layout){
  225. background: transparent !important;
  226. }
  227. </style>