Commit 6b996229e1449b1721ce6797ba6a964850e2e215
1 parent
67a7a76b
fix(use-loading): rendering fails when used with onMounted, fix #438
Showing
6 changed files
with
37 additions
and
22 deletions
CHANGELOG.zh_CN.md
build/vite/plugin/theme.ts
... | ... | @@ -19,7 +19,6 @@ export function configThemePlugin(isBuild: boolean): Plugin[] { |
19 | 19 | mixLighten, |
20 | 20 | tinycolor, |
21 | 21 | }); |
22 | - | |
23 | 22 | const plugin = [ |
24 | 23 | viteThemePlugin({ |
25 | 24 | resolveSelector: (s) => `[data-theme] ${s}`, |
... | ... | @@ -41,7 +40,8 @@ export function configThemePlugin(isBuild: boolean): Plugin[] { |
41 | 40 | // black: '#0e1117', |
42 | 41 | // #8b949e |
43 | 42 | 'text-color-secondary': '#8b949e', |
44 | - 'border-color-base': '#30363d', | |
43 | + // 'border-color-base': '#30363d', | |
44 | + // 'border-color-split': '#30363d', | |
45 | 45 | 'item-active-bg': '#111b26', |
46 | 46 | }, |
47 | 47 | }), | ... | ... |
src/components/Loading/src/createLoading.ts
... | ... | @@ -4,7 +4,7 @@ import type { LoadingProps } from './types'; |
4 | 4 | import { createVNode, render, reactive, h } from 'vue'; |
5 | 5 | import Loading from './index.vue'; |
6 | 6 | |
7 | -export function createLoading(props?: Partial<LoadingProps>, target?: HTMLElement) { | |
7 | +export function createLoading(props?: Partial<LoadingProps>, target?: HTMLElement, wait = false) { | |
8 | 8 | let vm: Nullable<VNode> = null; |
9 | 9 | const data = reactive({ |
10 | 10 | tip: '', |
... | ... | @@ -13,16 +13,21 @@ export function createLoading(props?: Partial<LoadingProps>, target?: HTMLElemen |
13 | 13 | }); |
14 | 14 | |
15 | 15 | const LoadingWrap = defineComponent({ |
16 | - setup() { | |
17 | - return () => { | |
18 | - return h(Loading, { ...data }); | |
19 | - }; | |
16 | + render() { | |
17 | + return h(Loading, { ...data }); | |
20 | 18 | }, |
21 | 19 | }); |
22 | 20 | |
23 | 21 | vm = createVNode(LoadingWrap); |
24 | 22 | |
25 | - render(vm, document.createElement('div')); | |
23 | + // TODO fix https://github.com/anncwb/vue-vben-admin/issues/438 | |
24 | + if (wait) { | |
25 | + setTimeout(() => { | |
26 | + render(vm, document.createElement('div')); | |
27 | + }, 0); | |
28 | + } else { | |
29 | + render(vm, document.createElement('div')); | |
30 | + } | |
26 | 31 | |
27 | 32 | function close() { |
28 | 33 | if (vm?.el && vm.el.parentNode) { | ... | ... |
src/components/Loading/src/useLoading.ts
... | ... | @@ -27,7 +27,7 @@ export function useLoading(opt: Partial<LoadingProps> | Partial<UseLoadingOption |
27 | 27 | props = opt as Partial<LoadingProps>; |
28 | 28 | } |
29 | 29 | |
30 | - const instance = createLoading(props); | |
30 | + const instance = createLoading(props, undefined, true); | |
31 | 31 | |
32 | 32 | const open = (): void => { |
33 | 33 | const t = unref(target); | ... | ... |
src/design/theme.less
... | ... | @@ -18,6 +18,11 @@ html[data-theme='dark'] { |
18 | 18 | 0 9px 28px 8px rgb(0 0 0 / 20%); |
19 | 19 | } |
20 | 20 | |
21 | + .ant-card-grid { | |
22 | + box-shadow: 1px 0 0 0 #434343, 0 1px 0 0 #434343, 1px 1px 0 0 #434343, 1px 0 0 0 #434343 inset, | |
23 | + 0 1px 0 0 #434343 inset; | |
24 | + } | |
25 | + | |
21 | 26 | .ant-alert-message, |
22 | 27 | .ant-alert-with-description .ant-alert-message, |
23 | 28 | .ant-alert-description { | ... | ... |
src/views/demo/comp/loading/index.vue
1 | 1 | <template> |
2 | 2 | <PageWrapper v-loading="loadingRef" loading-tip="加载中..." title="Loading组件示例"> |
3 | - <a-alert message="组件方式" /> | |
4 | - <a-button class="my-4 mr-4" type="primary" @click="openCompFullLoading"> | |
5 | - 全屏 Loading | |
6 | - </a-button> | |
7 | - <a-button class="my-4" type="primary" @click="openCompAbsolute"> 容器内 Loading </a-button> | |
8 | - <Loading :loading="loading" :absolute="absolute" :tip="tip" /> | |
3 | + <div ref="wrapEl"> | |
4 | + <a-alert message="组件方式" /> | |
5 | + <a-button class="my-4 mr-4" type="primary" @click="openCompFullLoading"> | |
6 | + 全屏 Loading | |
7 | + </a-button> | |
8 | + <a-button class="my-4" type="primary" @click="openCompAbsolute"> 容器内 Loading </a-button> | |
9 | + <Loading :loading="loading" :absolute="absolute" :tip="tip" /> | |
9 | 10 | |
10 | - <a-alert message="函数方式" /> | |
11 | + <a-alert message="函数方式" /> | |
11 | 12 | |
12 | - <a-button class="my-4 mr-4" type="primary" @click="openFnFullLoading"> 全屏 Loading </a-button> | |
13 | - <a-button class="my-4" type="primary" @click="openFnWrapLoading"> 容器内 Loading </a-button> | |
13 | + <a-button class="my-4 mr-4" type="primary" @click="openFnFullLoading"> | |
14 | + 全屏 Loading | |
15 | + </a-button> | |
16 | + <a-button class="my-4" type="primary" @click="openFnWrapLoading"> 容器内 Loading </a-button> | |
14 | 17 | |
15 | - <a-alert message="指令方式" /> | |
16 | - <a-button class="my-4 mr-4" type="primary" @click="openDirectiveLoading"> | |
17 | - 打开指令Loading | |
18 | - </a-button> | |
18 | + <a-alert message="指令方式" /> | |
19 | + <a-button class="my-4 mr-4" type="primary" @click="openDirectiveLoading"> | |
20 | + 打开指令Loading | |
21 | + </a-button> | |
22 | + </div> | |
19 | 23 | </PageWrapper> |
20 | 24 | </template> |
21 | 25 | <script lang="ts"> | ... | ... |