Commit 7653610c7bc45e97cb744994835cf7fb5074ff7b

Authored by 陈文彬
1 parent e4c952f3

fix: fix the problem of page blank caused by page refresh

src/layouts/default/LayoutContent.tsx
... ... @@ -6,23 +6,17 @@ import { ContentEnum } from '/@/enums/appEnum';
6 6 import { appStore } from '/@/store/modules/app';
7 7 // import { RouterView } from 'vue-router';
8 8 import PageLayout from '/@/layouts/page/index';
9   -import FrameLayout from '/@/layouts/iframe/index.vue';
10   -
11   -import { useSetting } from '/@/hooks/core/useSetting';
12 9 export default defineComponent({
13 10 name: 'DefaultLayoutContent',
14 11 setup() {
15   - const { projectSetting } = useSetting();
16   -
17 12 return () => {
18 13 const { getProjectConfig } = appStore;
19 14 const { contentMode } = getProjectConfig;
20   -
21 15 const wrapClass = contentMode === ContentEnum.FULL ? 'full' : 'fixed';
22 16 return (
23 17 <Layout.Content class={`layout-content ${wrapClass} `}>
24 18 {{
25   - default: () => [<PageLayout />, projectSetting.canEmbedIFramePage && <FrameLayout />],
  19 + default: () => <PageLayout />,
26 20 }}
27 21 </Layout.Content>
28 22 );
... ...
src/layouts/page/index.tsx
... ... @@ -6,7 +6,9 @@ import { useTransition } from &#39;./useTransition&#39;;
6 6  
7 7 import { RouterView, RouteLocation } from 'vue-router';
8 8 import { tabStore } from '/@/store/modules/tab';
  9 +import FrameLayout from '/@/layouts/iframe/index.vue';
9 10  
  11 +import { useSetting } from '/@/hooks/core/useSetting';
10 12 // import { useRouter } from 'vue-router';
11 13 export default defineComponent({
12 14 name: 'PageLayout',
... ... @@ -22,6 +24,7 @@ export default defineComponent({
22 24 const { on: transitionOn } = useTransition();
23 25 on = transitionOn;
24 26 }
  27 + const { projectSetting } = useSetting();
25 28 return () => {
26 29 const {
27 30 routerTransition,
... ... @@ -32,32 +35,35 @@ export default defineComponent({
32 35  
33 36 const openCache = openKeepAlive && show;
34 37 const cacheTabs = toRaw(tabStore.getKeepAliveTabsState) as string[];
35   - return [
36   - <RouterView>
37   - {{
38   - default: ({ Component, route }: { Component: any; route: RouteLocation }) => {
39   - const Content = openCache ? (
40   - <KeepAlive max={max} include={cacheTabs}>
  38 + return (
  39 + <div>
  40 + <RouterView>
  41 + {{
  42 + default: ({ Component, route }: { Component: any; route: RouteLocation }) => {
  43 + const Content = openCache ? (
  44 + <KeepAlive max={max} include={cacheTabs}>
  45 + <Component {...route.params} />
  46 + </KeepAlive>
  47 + ) : (
41 48 <Component {...route.params} />
42   - </KeepAlive>
43   - ) : (
44   - <Component {...route.params} />
45   - );
46   - return openRouterTransition ? (
47   - <Transition
48   - {...on}
49   - name={route.meta.transitionName || routerTransition}
50   - mode="out-in"
51   - >
52   - {() => Content}
53   - </Transition>
54   - ) : (
55   - Content
56   - );
57   - },
58   - }}
59   - </RouterView>,
60   - ];
  49 + );
  50 + return openRouterTransition ? (
  51 + <Transition
  52 + {...on}
  53 + name={route.meta.transitionName || routerTransition}
  54 + mode="out-in"
  55 + >
  56 + {() => Content}
  57 + </Transition>
  58 + ) : (
  59 + Content
  60 + );
  61 + },
  62 + }}
  63 + </RouterView>
  64 + {projectSetting.canEmbedIFramePage && <FrameLayout />}
  65 + </div>
  66 + );
61 67 };
62 68 },
63 69 });
... ...
src/router/routes/modules/demo/iframe.ts
... ... @@ -23,6 +23,7 @@ export default {
23 23 meta: {
24 24 frameSrc: 'https://2x.antdv.com/docs/vue/introduce-cn/',
25 25 title: 'antVue文档(内嵌)',
  26 + afterCloseLoading: true,
26 27 },
27 28 },
28 29 {
... ... @@ -32,6 +33,7 @@ export default {
32 33 meta: {
33 34 frameSrc: 'https://vvbin.cn/docs/',
34 35 title: '项目文档(内嵌)',
  36 + afterCloseLoading: true,
35 37 },
36 38 },
37 39 {
... ...
yarn.lock
... ... @@ -1601,7 +1601,7 @@ cli-cursor@^3.1.0:
1601 1601 dependencies:
1602 1602 restore-cursor "^3.1.0"
1603 1603  
1604   -cli-spinners@^2.2.0, cli-spinners@^2.4.0:
  1604 +cli-spinners@^2.2.0:
1605 1605 version "2.4.0"
1606 1606 resolved "https://registry.npm.taobao.org/cli-spinners/download/cli-spinners-2.4.0.tgz?cache=0&sync_timestamp=1595080377121&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fcli-spinners%2Fdownload%2Fcli-spinners-2.4.0.tgz#c6256db216b878cfba4720e719cec7cf72685d7f"
1607 1607 integrity sha1-xiVtsha4eM+6RyDnGc7Hz3JoXX8=
... ... @@ -4821,20 +4821,6 @@ ora@^4.0.4:
4821 4821 strip-ansi "^6.0.0"
4822 4822 wcwidth "^1.0.1"
4823 4823  
4824   -ora@^5.1.0:
4825   - version "5.1.0"
4826   - resolved "https://registry.npm.taobao.org/ora/download/ora-5.1.0.tgz?cache=0&sync_timestamp=1599424857800&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fora%2Fdownload%2Fora-5.1.0.tgz#b188cf8cd2d4d9b13fd25383bc3e5cba352c94f8"
4827   - integrity sha1-sYjPjNLU2bE/0lODvD5cujUslPg=
4828   - dependencies:
4829   - chalk "^4.1.0"
4830   - cli-cursor "^3.1.0"
4831   - cli-spinners "^2.4.0"
4832   - is-interactive "^1.0.0"
4833   - log-symbols "^4.0.0"
4834   - mute-stream "0.0.8"
4835   - strip-ansi "^6.0.0"
4836   - wcwidth "^1.0.1"
4837   -
4838 4824 os-tmpdir@~1.0.2:
4839 4825 version "1.0.2"
4840 4826 resolved "https://registry.npm.taobao.org/os-tmpdir/download/os-tmpdir-1.0.2.tgz#bbe67406c79aa85c5cfec766fe5734555dfa1274"
... ... @@ -6935,13 +6921,6 @@ vfile@^4.0.0:
6935 6921 unist-util-stringify-position "^2.0.0"
6936 6922 vfile-message "^2.0.0"
6937 6923  
6938   -vite-jsx@^1.0.5:
6939   - version "1.0.6"
6940   - resolved "https://registry.npm.taobao.org/vite-jsx/download/vite-jsx-1.0.6.tgz#5c33b9da6a6562d041418005370a7e3043b0e70c"
6941   - integrity sha1-XDO52mplYtBBQYAFNwp+MEOw5ww=
6942   - dependencies:
6943   - magic-string "^0.25.7"
6944   -
6945 6924 vite-plugin-mock@^1.0.2:
6946 6925 version "1.0.2"
6947 6926 resolved "https://registry.npm.taobao.org/vite-plugin-mock/download/vite-plugin-mock-1.0.2.tgz#07bdd67a8006fd60a6a83198479f3c0c57c7df53"
... ...