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