feat: 初始化
This commit is contained in:
25
pages/components/baseTree/TreeProcessorVue.ts
Normal file
25
pages/components/baseTree/TreeProcessorVue.ts
Normal file
@ -0,0 +1,25 @@
|
||||
import { makeTreeProcessor, Options } from "./tree-utils";
|
||||
export * from "./tree-utils";
|
||||
import { reactive } from "./vue";
|
||||
|
||||
export function vueMakeTreeProcessor<T>(data: T[], options: Options = {}) {
|
||||
const opt = {
|
||||
...options,
|
||||
statHandler(input) {
|
||||
if (this["_statHandler2"]) {
|
||||
input = this["_statHandler2"](input);
|
||||
}
|
||||
return filter(options.statHandler, reactive(input));
|
||||
},
|
||||
statsHandler(input) {
|
||||
return filter(options.statsHandler, reactive(input));
|
||||
},
|
||||
statsFlatHandler(input) {
|
||||
return filter(options.statsFlatHandler, reactive(input));
|
||||
},
|
||||
};
|
||||
return makeTreeProcessor(data, opt);
|
||||
}
|
||||
function filter<T>(func: Function | null | undefined, input: T): T {
|
||||
return func ? func(input) : input;
|
||||
}
|
Reference in New Issue
Block a user