index.vue 6.6 KB

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