Commit 8f9eff78aa3979929c3efff4967b1608abcab7e8

Authored by vben
1 parent dddda5b2

style: update back-top style

CHANGELOG.zh_CN.md
@@ -4,6 +4,10 @@ @@ -4,6 +4,10 @@
4 4
5 - 移除左侧菜单搜索,新增顶部菜单搜索功能 5 - 移除左侧菜单搜索,新增顶部菜单搜索功能
6 6
  7 +### 🎫 Chores
  8 +
  9 +- 返回顶部样式调整,避免遮住其他元素
  10 +
7 ## 2.0.0-rc.13 (2020-12-10) 11 ## 2.0.0-rc.13 (2020-12-10)
8 12
9 ## (破坏性更新) Breaking changes 13 ## (破坏性更新) Breaking changes
src/components/ClickOutSide/index.ts
1 -import ClickOutSide from './src/index.vue';  
2 import { withInstall } from '../util'; 1 import { withInstall } from '../util';
  2 +import { createAsyncComponent } from '/@/utils/factory/createAsyncComponent';
3 3
4 -withInstall(ClickOutSide); 4 +export const ClickOutSide = createAsyncComponent(() => import('./src/index.vue'));
5 5
6 -export { ClickOutSide }; 6 +withInstall(ClickOutSide);
src/design/ant/index.less
@@ -7,6 +7,11 @@ @@ -7,6 +7,11 @@
7 width: 100%; 7 width: 100%;
8 } 8 }
9 9
  10 +.ant-back-top {
  11 + right: 20px;
  12 + bottom: 20px;
  13 +}
  14 +
10 .collapse-container__body { 15 .collapse-container__body {
11 > .ant-descriptions { 16 > .ant-descriptions {
12 margin-left: 6px; 17 margin-left: 6px;
src/router/index.ts
@@ -6,7 +6,7 @@ import { createRouter, createWebHashHistory } from 'vue-router'; @@ -6,7 +6,7 @@ import { createRouter, createWebHashHistory } from 'vue-router';
6 import { createGuard } from './guard/'; 6 import { createGuard } from './guard/';
7 7
8 import { basicRoutes } from './routes/'; 8 import { basicRoutes } from './routes/';
9 -import { scrollBehavior } from './scrollBehaviour'; 9 +import { scrollBehavior } from './scrollBehavior';
10 10
11 export const hashRouter = createWebHashHistory(); 11 export const hashRouter = createWebHashHistory();
12 12
src/router/scrollBehaviour.ts renamed to src/router/scrollBehavior.ts
src/utils/factory/createAsyncComponent.tsx
1 import { defineAsyncComponent } from 'vue'; 1 import { defineAsyncComponent } from 'vue';
2 import { Spin } from 'ant-design-vue'; 2 import { Spin } from 'ant-design-vue';
  3 +import { noop } from '/@/utils/index';
  4 +interface Options {
  5 + size?: 'default' | 'small' | 'large';
  6 + delay?: number;
  7 + timeout?: number;
  8 + loading?: boolean;
  9 + retry?: boolean;
  10 +}
3 11
4 -export function createAsyncComponent(loader: any) { 12 +export function createAsyncComponent(loader: Fn, options: Options = {}) {
  13 + const { size = 'small', delay = 100, timeout = 3000, loading = true, retry = true } = options;
5 return defineAsyncComponent({ 14 return defineAsyncComponent({
6 - loader: loader,  
7 - loadingComponent: <Spin spinning={true} />, 15 + loader,
  16 + loadingComponent: loading ? <Spin spinning={true} size={size} /> : undefined,
8 // The error component will be displayed if a timeout is 17 // The error component will be displayed if a timeout is
9 // provided and exceeded. Default: Infinity. 18 // provided and exceeded. Default: Infinity.
10 - timeout: 3000, 19 + timeout,
11 // Defining if component is suspensible. Default: true. 20 // Defining if component is suspensible. Default: true.
12 // suspensible: false, 21 // suspensible: false,
13 - delay: 100, 22 + delay,
14 /** 23 /**
15 * 24 *
16 * @param {*} error Error message object 25 * @param {*} error Error message object
@@ -18,15 +27,17 @@ export function createAsyncComponent(loader: any) { @@ -18,15 +27,17 @@ export function createAsyncComponent(loader: any) {
18 * @param {*} fail End of failure 27 * @param {*} fail End of failure
19 * @param {*} attempts Maximum allowed retries number 28 * @param {*} attempts Maximum allowed retries number
20 */ 29 */
21 - onError(error, retry, fail, attempts) {  
22 - if (error.message.match(/fetch/) && attempts <= 3) {  
23 - // retry on fetch errors, 3 max attempts  
24 - retry();  
25 - } else {  
26 - // Note that retry/fail are like resolve/reject of a promise:  
27 - // one of them must be called for the error handling to continue.  
28 - fail();  
29 - }  
30 - }, 30 + onError: !retry
  31 + ? noop
  32 + : (error, retry, fail, attempts) => {
  33 + if (error.message.match(/fetch/) && attempts <= 3) {
  34 + // retry on fetch errors, 3 max attempts
  35 + retry();
  36 + } else {
  37 + // Note that retry/fail are like resolve/reject of a promise:
  38 + // one of them must be called for the error handling to continue.
  39 + fail();
  40 + }
  41 + },
31 }); 42 });
32 } 43 }