mirror of
https://github.com/pure-admin/vue-pure-admin.git
synced 2025-06-07 08:57:19 +08:00
23 lines
491 B
TypeScript
23 lines
491 B
TypeScript
interface ProxyAlgorithm {
|
|
increaseIndexes<T>(val: Array<T>): Array<T>;
|
|
}
|
|
|
|
class algorithmProxy implements ProxyAlgorithm {
|
|
constructor() {}
|
|
|
|
// 数组每一项添加索引字段
|
|
public increaseIndexes<T>(val: Array<T>): Array<T> {
|
|
return Object.keys(val)
|
|
.map((v) => {
|
|
return {
|
|
// @ts-ignore
|
|
...val[v],
|
|
key: v,
|
|
};
|
|
})
|
|
.filter((v) => v.meta && v.meta.showLink);
|
|
}
|
|
}
|
|
|
|
export const algorithm = new algorithmProxy();
|