feat: add search page

This commit is contained in:
vben
2020-12-10 23:58:11 +08:00
parent 596e7062e9
commit dddda5b296
45 changed files with 1399 additions and 1004 deletions

View File

@@ -0,0 +1,32 @@
import { defineAsyncComponent } from 'vue';
import { Spin } from 'ant-design-vue';
export function createAsyncComponent(loader: any) {
return defineAsyncComponent({
loader: loader,
loadingComponent: <Spin spinning={true} />,
// The error component will be displayed if a timeout is
// provided and exceeded. Default: Infinity.
timeout: 3000,
// Defining if component is suspensible. Default: true.
// suspensible: false,
delay: 100,
/**
*
* @param {*} error Error message object
* @param {*} retry A function that indicating whether the async component should retry when the loader promise rejects
* @param {*} fail End of failure
* @param {*} attempts Maximum allowed retries number
*/
onError(error, retry, fail, attempts) {
if (error.message.match(/fetch/) && attempts <= 3) {
// retry on fetch errors, 3 max attempts
retry();
} else {
// Note that retry/fail are like resolve/reject of a promise:
// one of them must be called for the error handling to continue.
fail();
}
},
});
}

View File

@@ -124,7 +124,7 @@ export function filter<T = any>(
tree: T[],
func: (n: T) => boolean,
config: Partial<TreeHelperConfig> = {}
) {
): T[] {
config = getConfig(config);
const children = config.children as string;
function listFilter(list: T[]) {
@@ -142,7 +142,7 @@ export function forEach<T = any>(
tree: T[],
func: (n: T) => any,
config: Partial<TreeHelperConfig> = {}
) {
): void {
config = getConfig(config);
const list: any[] = [...tree];
const { children } = config;
@@ -155,7 +155,7 @@ export function forEach<T = any>(
/**
* @description: 提取tree指定结构
*/
export function treeMap(treeData: any[], opt: { children?: string; conversion: Fn }) {
export function treeMap<T = any>(treeData: T[], opt: { children?: string; conversion: Fn }): T[] {
return treeData.map((item) => treeMapEach(item, opt));
}