Commit 6b996229e1449b1721ce6797ba6a964850e2e215

Authored by Vben
1 parent 67a7a76b

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

CHANGELOG.zh_CN.md
@@ -19,6 +19,7 @@ @@ -19,6 +19,7 @@
19 - 修复 tinymce 上传按钮全屏模式下消失问题 19 - 修复 tinymce 上传按钮全屏模式下消失问题
20 - 确保 title 在重新登录后正常改变 20 - 确保 title 在重新登录后正常改变
21 - 确保后台模式登录正常 21 - 确保后台模式登录正常
  22 +- 修复 TableAction 点击事件问题
22 23
23 ## 2.1.1 (2021-03-26) 24 ## 2.1.1 (2021-03-26)
24 25
build/vite/plugin/theme.ts
@@ -19,7 +19,6 @@ export function configThemePlugin(isBuild: boolean): Plugin[] { @@ -19,7 +19,6 @@ export function configThemePlugin(isBuild: boolean): Plugin[] {
19 mixLighten, 19 mixLighten,
20 tinycolor, 20 tinycolor,
21 }); 21 });
22 -  
23 const plugin = [ 22 const plugin = [
24 viteThemePlugin({ 23 viteThemePlugin({
25 resolveSelector: (s) => `[data-theme] ${s}`, 24 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[] {
41 // black: '#0e1117', 40 // black: '#0e1117',
42 // #8b949e 41 // #8b949e
43 'text-color-secondary': '#8b949e', 42 'text-color-secondary': '#8b949e',
44 - 'border-color-base': '#30363d', 43 + // 'border-color-base': '#30363d',
  44 + // 'border-color-split': '#30363d',
45 'item-active-bg': '#111b26', 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,7 +4,7 @@ import type { LoadingProps } from './types';
4 import { createVNode, render, reactive, h } from 'vue'; 4 import { createVNode, render, reactive, h } from 'vue';
5 import Loading from './index.vue'; 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 let vm: Nullable<VNode> = null; 8 let vm: Nullable<VNode> = null;
9 const data = reactive({ 9 const data = reactive({
10 tip: '', 10 tip: '',
@@ -13,16 +13,21 @@ export function createLoading(props?: Partial&lt;LoadingProps&gt;, target?: HTMLElemen @@ -13,16 +13,21 @@ export function createLoading(props?: Partial&lt;LoadingProps&gt;, target?: HTMLElemen
13 }); 13 });
14 14
15 const LoadingWrap = defineComponent({ 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 vm = createVNode(LoadingWrap); 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 function close() { 32 function close() {
28 if (vm?.el && vm.el.parentNode) { 33 if (vm?.el && vm.el.parentNode) {
src/components/Loading/src/useLoading.ts
@@ -27,7 +27,7 @@ export function useLoading(opt: Partial&lt;LoadingProps&gt; | Partial&lt;UseLoadingOption @@ -27,7 +27,7 @@ export function useLoading(opt: Partial&lt;LoadingProps&gt; | Partial&lt;UseLoadingOption
27 props = opt as Partial<LoadingProps>; 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 const open = (): void => { 32 const open = (): void => {
33 const t = unref(target); 33 const t = unref(target);
src/design/theme.less
@@ -18,6 +18,11 @@ html[data-theme=&#39;dark&#39;] { @@ -18,6 +18,11 @@ html[data-theme=&#39;dark&#39;] {
18 0 9px 28px 8px rgb(0 0 0 / 20%); 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 .ant-alert-message, 26 .ant-alert-message,
22 .ant-alert-with-description .ant-alert-message, 27 .ant-alert-with-description .ant-alert-message,
23 .ant-alert-description { 28 .ant-alert-description {
src/views/demo/comp/loading/index.vue
1 <template> 1 <template>
2 <PageWrapper v-loading="loadingRef" loading-tip="加载中..." title="Loading组件示例"> 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 </PageWrapper> 23 </PageWrapper>
20 </template> 24 </template>
21 <script lang="ts"> 25 <script lang="ts">