feat: 自动回复迁移
This commit is contained in:
@@ -1,2 +1,29 @@
|
||||
import type { Recordable } from '@vben/types';
|
||||
|
||||
export * from './rangePickerProps';
|
||||
export * from './routerHelper';
|
||||
|
||||
/**
|
||||
* 查找数组对象的某个下标
|
||||
* @param {Array} ary 查找的数组
|
||||
* @param {Function} fn 判断的方法
|
||||
*/
|
||||
type Fn<T = any> = (item: T, index: number, array: Array<T>) => boolean;
|
||||
export const findIndex = <T = Recordable<any>>(
|
||||
ary: Array<T>,
|
||||
fn: Fn<T>,
|
||||
): number => {
|
||||
if (ary.findIndex) {
|
||||
return ary.findIndex((item, index, array) => fn(item, index, array));
|
||||
}
|
||||
let index = -1;
|
||||
ary.some((item: T, i: number, ary: Array<T>) => {
|
||||
const ret: boolean = fn(item, i, ary);
|
||||
if (ret) {
|
||||
index = i;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
});
|
||||
return index;
|
||||
};
|
||||
|
||||
@@ -1,3 +1,8 @@
|
||||
import type {
|
||||
RouteLocationNormalized,
|
||||
RouteRecordNormalized,
|
||||
} from 'vue-router';
|
||||
|
||||
import { defineAsyncComponent } from 'vue';
|
||||
|
||||
const modules = import.meta.glob('../views/**/*.{vue,tsx}');
|
||||
@@ -14,3 +19,20 @@ export function registerComponent(componentPath: string) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export const getRawRoute = (
|
||||
route: RouteLocationNormalized,
|
||||
): RouteLocationNormalized => {
|
||||
if (!route) return route;
|
||||
const { matched, ...opt } = route;
|
||||
return {
|
||||
...opt,
|
||||
matched: (matched
|
||||
? matched.map((item) => ({
|
||||
meta: item.meta,
|
||||
name: item.name,
|
||||
path: item.path,
|
||||
}))
|
||||
: undefined) as RouteRecordNormalized[],
|
||||
};
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user