Commit 7653610c7bc45e97cb744994835cf7fb5074ff7b
1 parent
e4c952f3
fix: fix the problem of page blank caused by page refresh
Showing
4 changed files
with
35 additions
and
54 deletions
src/layouts/default/LayoutContent.tsx
@@ -6,23 +6,17 @@ import { ContentEnum } from '/@/enums/appEnum'; | @@ -6,23 +6,17 @@ import { ContentEnum } from '/@/enums/appEnum'; | ||
6 | import { appStore } from '/@/store/modules/app'; | 6 | import { appStore } from '/@/store/modules/app'; |
7 | // import { RouterView } from 'vue-router'; | 7 | // import { RouterView } from 'vue-router'; |
8 | import PageLayout from '/@/layouts/page/index'; | 8 | import PageLayout from '/@/layouts/page/index'; |
9 | -import FrameLayout from '/@/layouts/iframe/index.vue'; | ||
10 | - | ||
11 | -import { useSetting } from '/@/hooks/core/useSetting'; | ||
12 | export default defineComponent({ | 9 | export default defineComponent({ |
13 | name: 'DefaultLayoutContent', | 10 | name: 'DefaultLayoutContent', |
14 | setup() { | 11 | setup() { |
15 | - const { projectSetting } = useSetting(); | ||
16 | - | ||
17 | return () => { | 12 | return () => { |
18 | const { getProjectConfig } = appStore; | 13 | const { getProjectConfig } = appStore; |
19 | const { contentMode } = getProjectConfig; | 14 | const { contentMode } = getProjectConfig; |
20 | - | ||
21 | const wrapClass = contentMode === ContentEnum.FULL ? 'full' : 'fixed'; | 15 | const wrapClass = contentMode === ContentEnum.FULL ? 'full' : 'fixed'; |
22 | return ( | 16 | return ( |
23 | <Layout.Content class={`layout-content ${wrapClass} `}> | 17 | <Layout.Content class={`layout-content ${wrapClass} `}> |
24 | {{ | 18 | {{ |
25 | - default: () => [<PageLayout />, projectSetting.canEmbedIFramePage && <FrameLayout />], | 19 | + default: () => <PageLayout />, |
26 | }} | 20 | }} |
27 | </Layout.Content> | 21 | </Layout.Content> |
28 | ); | 22 | ); |
src/layouts/page/index.tsx
@@ -6,7 +6,9 @@ import { useTransition } from './useTransition'; | @@ -6,7 +6,9 @@ import { useTransition } from './useTransition'; | ||
6 | 6 | ||
7 | import { RouterView, RouteLocation } from 'vue-router'; | 7 | import { RouterView, RouteLocation } from 'vue-router'; |
8 | import { tabStore } from '/@/store/modules/tab'; | 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 | // import { useRouter } from 'vue-router'; | 12 | // import { useRouter } from 'vue-router'; |
11 | export default defineComponent({ | 13 | export default defineComponent({ |
12 | name: 'PageLayout', | 14 | name: 'PageLayout', |
@@ -22,6 +24,7 @@ export default defineComponent({ | @@ -22,6 +24,7 @@ export default defineComponent({ | ||
22 | const { on: transitionOn } = useTransition(); | 24 | const { on: transitionOn } = useTransition(); |
23 | on = transitionOn; | 25 | on = transitionOn; |
24 | } | 26 | } |
27 | + const { projectSetting } = useSetting(); | ||
25 | return () => { | 28 | return () => { |
26 | const { | 29 | const { |
27 | routerTransition, | 30 | routerTransition, |
@@ -32,32 +35,35 @@ export default defineComponent({ | @@ -32,32 +35,35 @@ export default defineComponent({ | ||
32 | 35 | ||
33 | const openCache = openKeepAlive && show; | 36 | const openCache = openKeepAlive && show; |
34 | const cacheTabs = toRaw(tabStore.getKeepAliveTabsState) as string[]; | 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 | <Component {...route.params} /> | 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,6 +23,7 @@ export default { | ||
23 | meta: { | 23 | meta: { |
24 | frameSrc: 'https://2x.antdv.com/docs/vue/introduce-cn/', | 24 | frameSrc: 'https://2x.antdv.com/docs/vue/introduce-cn/', |
25 | title: 'antVue文档(内嵌)', | 25 | title: 'antVue文档(内嵌)', |
26 | + afterCloseLoading: true, | ||
26 | }, | 27 | }, |
27 | }, | 28 | }, |
28 | { | 29 | { |
@@ -32,6 +33,7 @@ export default { | @@ -32,6 +33,7 @@ export default { | ||
32 | meta: { | 33 | meta: { |
33 | frameSrc: 'https://vvbin.cn/docs/', | 34 | frameSrc: 'https://vvbin.cn/docs/', |
34 | title: '项目文档(内嵌)', | 35 | title: '项目文档(内嵌)', |
36 | + afterCloseLoading: true, | ||
35 | }, | 37 | }, |
36 | }, | 38 | }, |
37 | { | 39 | { |
yarn.lock
@@ -1601,7 +1601,7 @@ cli-cursor@^3.1.0: | @@ -1601,7 +1601,7 @@ cli-cursor@^3.1.0: | ||
1601 | dependencies: | 1601 | dependencies: |
1602 | restore-cursor "^3.1.0" | 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 | version "2.4.0" | 1605 | version "2.4.0" |
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" | 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 | integrity sha1-xiVtsha4eM+6RyDnGc7Hz3JoXX8= | 1607 | integrity sha1-xiVtsha4eM+6RyDnGc7Hz3JoXX8= |
@@ -4821,20 +4821,6 @@ ora@^4.0.4: | @@ -4821,20 +4821,6 @@ ora@^4.0.4: | ||
4821 | strip-ansi "^6.0.0" | 4821 | strip-ansi "^6.0.0" |
4822 | wcwidth "^1.0.1" | 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 | os-tmpdir@~1.0.2: | 4824 | os-tmpdir@~1.0.2: |
4839 | version "1.0.2" | 4825 | version "1.0.2" |
4840 | resolved "https://registry.npm.taobao.org/os-tmpdir/download/os-tmpdir-1.0.2.tgz#bbe67406c79aa85c5cfec766fe5734555dfa1274" | 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,13 +6921,6 @@ vfile@^4.0.0: | ||
6935 | unist-util-stringify-position "^2.0.0" | 6921 | unist-util-stringify-position "^2.0.0" |
6936 | vfile-message "^2.0.0" | 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 | vite-plugin-mock@^1.0.2: | 6924 | vite-plugin-mock@^1.0.2: |
6946 | version "1.0.2" | 6925 | version "1.0.2" |
6947 | resolved "https://registry.npm.taobao.org/vite-plugin-mock/download/vite-plugin-mock-1.0.2.tgz#07bdd67a8006fd60a6a83198479f3c0c57c7df53" | 6926 | resolved "https://registry.npm.taobao.org/vite-plugin-mock/download/vite-plugin-mock-1.0.2.tgz#07bdd67a8006fd60a6a83198479f3c0c57c7df53" |