index.vue 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232
  1. <template>
  2. <div :class="[prefixCls, getLayoutContentMode, { 'layout-content-full': getShowFullHeader }]" v-loading="getOpenPageLoading && getPageLoading">
  3. <PageLayout />
  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" style="position: relative" v-if="openQianKun == 'true'"> </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(true);
  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. if (!route.path.startsWith('/micro-vent-3dModal')) {
  62. if (document.body.getAttribute('class')?.includes('style-styleTwo')) document.body.removeAttribute('class', 'style-styleTwo');
  63. } else {
  64. document.body.setAttribute('class', 'style-styleTwo');
  65. }
  66. return getShowFullHeaderRef && !route.path.startsWith('/micro-');
  67. });
  68. onBeforeMount(() => {});
  69. onMounted(() => {
  70. //注册openQianKun
  71. // console.log('window.qiankunStarted------>', window.qiankunStarted);
  72. if (openQianKun == 'true') {
  73. if (!window.qiankunStarted) {
  74. window.qiankunStarted = true;
  75. registerApps();
  76. }
  77. }
  78. });
  79. return {
  80. prefixCls,
  81. openQianKun,
  82. getOpenPageLoading,
  83. getLayoutContentMode,
  84. getPageLoading,
  85. getShowFullHeader,
  86. loading,
  87. };
  88. },
  89. });
  90. </script>
  91. <style lang="less" scoped>
  92. @prefix-cls: ~'@{namespace}-layout-content';
  93. .@{prefix-cls} {
  94. position: relative;
  95. flex: 1 1 auto;
  96. min-height: 0;
  97. &.fixed {
  98. width: 1200px;
  99. margin: 0 auto;
  100. }
  101. &-loading {
  102. position: absolute;
  103. top: 200px;
  104. z-index: @page-loading-z-index;
  105. }
  106. }
  107. .layout-content-full {
  108. height: calc(100vh - 48px);
  109. margin-top: 48px;
  110. overflow-y: auto;
  111. }
  112. .app-loading {
  113. display: flex;
  114. width: 100%;
  115. height: 100%;
  116. justify-content: center;
  117. align-items: center;
  118. flex-direction: column;
  119. // background-color: #f4f7f900;
  120. background-image: url('/@/assets/images/vent/loading-bg.png');
  121. background-size: cover;
  122. background-repeat: no-repeat;
  123. background-color: #00144b;
  124. }
  125. .app-loading .app-loading-wrap {
  126. position: absolute;
  127. top: 50%;
  128. left: 50%;
  129. display: flex;
  130. -webkit-transform: translate3d(-50%, -50%, 0);
  131. transform: translate3d(-50%, -50%, 0);
  132. justify-content: center;
  133. align-items: center;
  134. flex-direction: column;
  135. }
  136. .app-loading .dots {
  137. display: flex;
  138. padding: 98px;
  139. justify-content: center;
  140. align-items: center;
  141. }
  142. .app-loading .app-loading-title {
  143. display: flex;
  144. margin-top: 30px;
  145. font-size: 30px;
  146. color: rgba(0, 0, 0, 0.85);
  147. justify-content: center;
  148. align-items: center;
  149. }
  150. .dot {
  151. position: relative;
  152. display: inline-block;
  153. width: 32px;
  154. height: 32px;
  155. margin-top: 30px;
  156. font-size: 32px;
  157. transform: rotate(45deg);
  158. box-sizing: border-box;
  159. animation: antRotate 1.2s infinite linear;
  160. }
  161. .dot i {
  162. position: absolute;
  163. display: block;
  164. width: 14px;
  165. height: 14px;
  166. background-color: #0065cc;
  167. // background-color: #d1d1d1;
  168. border-radius: 100%;
  169. opacity: 0.3;
  170. transform: scale(0.75);
  171. animation: antSpinMove 1s infinite linear alternate;
  172. transform-origin: 50% 50%;
  173. }
  174. .dot i:nth-child(1) {
  175. top: 0;
  176. left: 0;
  177. }
  178. .dot i:nth-child(2) {
  179. top: 0;
  180. right: 0;
  181. -webkit-animation-delay: 0.4s;
  182. animation-delay: 0.4s;
  183. }
  184. .dot i:nth-child(3) {
  185. right: 0;
  186. bottom: 0;
  187. -webkit-animation-delay: 0.8s;
  188. animation-delay: 0.8s;
  189. }
  190. .dot i:nth-child(4) {
  191. bottom: 0;
  192. left: 0;
  193. -webkit-animation-delay: 1.2s;
  194. animation-delay: 1.2s;
  195. }
  196. @keyframes antRotate {
  197. to {
  198. -webkit-transform: rotate(405deg);
  199. transform: rotate(405deg);
  200. }
  201. }
  202. @-webkit-keyframes antRotate {
  203. to {
  204. -webkit-transform: rotate(405deg);
  205. transform: rotate(405deg);
  206. }
  207. }
  208. @keyframes antSpinMove {
  209. to {
  210. opacity: 1;
  211. }
  212. }
  213. @-webkit-keyframes antSpinMove {
  214. to {
  215. opacity: 1;
  216. }
  217. }
  218. </style>