index.vue 6.9 KB

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