提交 6b996229 编写于 作者: V Vben

fix(use-loading): rendering fails when used with onMounted, fix #438

上级 67a7a76b
...@@ -19,6 +19,7 @@ ...@@ -19,6 +19,7 @@
- 修复 tinymce 上传按钮全屏模式下消失问题 - 修复 tinymce 上传按钮全屏模式下消失问题
- 确保 title 在重新登录后正常改变 - 确保 title 在重新登录后正常改变
- 确保后台模式登录正常 - 确保后台模式登录正常
- 修复 TableAction 点击事件问题
## 2.1.1 (2021-03-26) ## 2.1.1 (2021-03-26)
......
...@@ -19,7 +19,6 @@ export function configThemePlugin(isBuild: boolean): Plugin[] { ...@@ -19,7 +19,6 @@ export function configThemePlugin(isBuild: boolean): Plugin[] {
mixLighten, mixLighten,
tinycolor, tinycolor,
}); });
const plugin = [ const plugin = [
viteThemePlugin({ viteThemePlugin({
resolveSelector: (s) => `[data-theme] ${s}`, resolveSelector: (s) => `[data-theme] ${s}`,
...@@ -41,7 +40,8 @@ export function configThemePlugin(isBuild: boolean): Plugin[] { ...@@ -41,7 +40,8 @@ export function configThemePlugin(isBuild: boolean): Plugin[] {
// black: '#0e1117', // black: '#0e1117',
// #8b949e // #8b949e
'text-color-secondary': '#8b949e', 'text-color-secondary': '#8b949e',
'border-color-base': '#30363d', // 'border-color-base': '#30363d',
// 'border-color-split': '#30363d',
'item-active-bg': '#111b26', 'item-active-bg': '#111b26',
}, },
}), }),
......
...@@ -4,7 +4,7 @@ import type { LoadingProps } from './types'; ...@@ -4,7 +4,7 @@ import type { LoadingProps } from './types';
import { createVNode, render, reactive, h } from 'vue'; import { createVNode, render, reactive, h } from 'vue';
import Loading from './index.vue'; import Loading from './index.vue';
export function createLoading(props?: Partial<LoadingProps>, target?: HTMLElement) { export function createLoading(props?: Partial<LoadingProps>, target?: HTMLElement, wait = false) {
let vm: Nullable<VNode> = null; let vm: Nullable<VNode> = null;
const data = reactive({ const data = reactive({
tip: '', tip: '',
...@@ -13,16 +13,21 @@ export function createLoading(props?: Partial<LoadingProps>, target?: HTMLElemen ...@@ -13,16 +13,21 @@ export function createLoading(props?: Partial<LoadingProps>, target?: HTMLElemen
}); });
const LoadingWrap = defineComponent({ const LoadingWrap = defineComponent({
setup() { render() {
return () => { return h(Loading, { ...data });
return h(Loading, { ...data });
};
}, },
}); });
vm = createVNode(LoadingWrap); vm = createVNode(LoadingWrap);
render(vm, document.createElement('div')); // TODO fix https://github.com/anncwb/vue-vben-admin/issues/438
if (wait) {
setTimeout(() => {
render(vm, document.createElement('div'));
}, 0);
} else {
render(vm, document.createElement('div'));
}
function close() { function close() {
if (vm?.el && vm.el.parentNode) { if (vm?.el && vm.el.parentNode) {
......
...@@ -27,7 +27,7 @@ export function useLoading(opt: Partial<LoadingProps> | Partial<UseLoadingOption ...@@ -27,7 +27,7 @@ export function useLoading(opt: Partial<LoadingProps> | Partial<UseLoadingOption
props = opt as Partial<LoadingProps>; props = opt as Partial<LoadingProps>;
} }
const instance = createLoading(props); const instance = createLoading(props, undefined, true);
const open = (): void => { const open = (): void => {
const t = unref(target); const t = unref(target);
......
...@@ -18,6 +18,11 @@ html[data-theme='dark'] { ...@@ -18,6 +18,11 @@ html[data-theme='dark'] {
0 9px 28px 8px rgb(0 0 0 / 20%); 0 9px 28px 8px rgb(0 0 0 / 20%);
} }
.ant-card-grid {
box-shadow: 1px 0 0 0 #434343, 0 1px 0 0 #434343, 1px 1px 0 0 #434343, 1px 0 0 0 #434343 inset,
0 1px 0 0 #434343 inset;
}
.ant-alert-message, .ant-alert-message,
.ant-alert-with-description .ant-alert-message, .ant-alert-with-description .ant-alert-message,
.ant-alert-description { .ant-alert-description {
......
<template> <template>
<PageWrapper v-loading="loadingRef" loading-tip="加载中..." title="Loading组件示例"> <PageWrapper v-loading="loadingRef" loading-tip="加载中..." title="Loading组件示例">
<a-alert message="组件方式" /> <div ref="wrapEl">
<a-button class="my-4 mr-4" type="primary" @click="openCompFullLoading"> <a-alert message="组件方式" />
全屏 Loading <a-button class="my-4 mr-4" type="primary" @click="openCompFullLoading">
</a-button> 全屏 Loading
<a-button class="my-4" type="primary" @click="openCompAbsolute"> 容器内 Loading </a-button> </a-button>
<Loading :loading="loading" :absolute="absolute" :tip="tip" /> <a-button class="my-4" type="primary" @click="openCompAbsolute"> 容器内 Loading </a-button>
<Loading :loading="loading" :absolute="absolute" :tip="tip" />
<a-alert message="函数方式" /> <a-alert message="函数方式" />
<a-button class="my-4 mr-4" type="primary" @click="openFnFullLoading"> 全屏 Loading </a-button> <a-button class="my-4 mr-4" type="primary" @click="openFnFullLoading">
<a-button class="my-4" type="primary" @click="openFnWrapLoading"> 容器内 Loading </a-button> 全屏 Loading
</a-button>
<a-button class="my-4" type="primary" @click="openFnWrapLoading"> 容器内 Loading </a-button>
<a-alert message="指令方式" /> <a-alert message="指令方式" />
<a-button class="my-4 mr-4" type="primary" @click="openDirectiveLoading"> <a-button class="my-4 mr-4" type="primary" @click="openDirectiveLoading">
打开指令Loading 打开指令Loading
</a-button> </a-button>
</div>
</PageWrapper> </PageWrapper>
</template> </template>
<script lang="ts"> <script lang="ts">
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册