mirror of
https://github.com/VickScarlet/lifeRestart.git
synced 2026-04-19 03:10:01 +08:00
update daily
This commit is contained in:
24
src/ui/pluginFunction.js
Normal file
24
src/ui/pluginFunction.js
Normal file
@@ -0,0 +1,24 @@
|
||||
var plugin = {};
|
||||
|
||||
plugin.extractComponents = function(uiView, componentNames) {
|
||||
const components = {};
|
||||
const deepSearch = (uiView, componentNames) => {
|
||||
if(!uiView.child) return;
|
||||
for(let i = uiView.child.length - 1; i >= 0; i--) {
|
||||
const child = uiView.child[i];
|
||||
if(componentNames.includes(child?.props.name)) {
|
||||
components[child.props.name] = child;
|
||||
uiView.child.splice(i, 1);
|
||||
continue;
|
||||
}
|
||||
deepSearch(child, componentNames, components);
|
||||
}
|
||||
};
|
||||
deepSearch(uiView, componentNames);
|
||||
return componentName => {
|
||||
if(components[componentName]) {
|
||||
return Laya.View.createComp(components[componentName]);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user