mirror of
https://github.com/cocos/cocos4.git
synced 2026-11-21 16:12:40 +08:00
[Bug] performance optimize in inspector (#12328)
* interface optimize * performance optimize in editor inspector
This commit is contained in:
@@ -466,6 +466,11 @@ exports.update = async function(assetList, metaList) {
|
||||
this.asset = assetList[0];
|
||||
this.meta = metaList[0];
|
||||
|
||||
// 增加容错
|
||||
if (!this.$this.isConnected) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (assetList.length !== 1) {
|
||||
this.$.invalid.setAttribute('active', '');
|
||||
return;
|
||||
@@ -492,7 +497,7 @@ exports.update = async function(assetList, metaList) {
|
||||
/**
|
||||
* Method of initializing the panel
|
||||
*/
|
||||
exports.ready = async function() {
|
||||
exports.ready = function() {
|
||||
this.canUpdatePreview = false;
|
||||
// Used to determine whether the material has been modified in isDirty()
|
||||
this.dirtyData = {
|
||||
|
||||
@@ -363,6 +363,13 @@ const uiElements = {
|
||||
if (autoflag) {
|
||||
const oldChildren = Array.from(element.children);
|
||||
const children = [];
|
||||
|
||||
const oldCheckbox = element.querySelector('[slot="header"] > ui-checkbox');
|
||||
if (oldCheckbox) {
|
||||
oldCheckbox.removeEventListener('change', oldCheckbox.changeEvent);
|
||||
oldCheckbox.changeEvent = undefined;
|
||||
}
|
||||
|
||||
const header = document.createElement('ui-prop');
|
||||
header.setAttribute('slot', 'header');
|
||||
header.setAttribute('type', 'dump');
|
||||
@@ -370,10 +377,11 @@ const uiElements = {
|
||||
header.className = 'header';
|
||||
header.dump = this.getObjectByKey(this.dump.value, key);
|
||||
const checkbox = document.createElement('ui-checkbox');
|
||||
checkbox.addEventListener('change', (event) => {
|
||||
checkbox.changeEvent = (event) => {
|
||||
this.getObjectByKey(this.dump.value, key).value.enable.value = event.target.value;
|
||||
header.dispatch('change-dump');
|
||||
});
|
||||
};
|
||||
checkbox.addEventListener('change', checkbox.changeEvent);
|
||||
checkbox.setAttribute('value', this.getObjectByKey(this.dump.value, key).value.enable.value);
|
||||
const label = document.createElement('ui-label');
|
||||
label.setAttribute('value', this.getName(this.getObjectByKey(this.dump.value, key)));
|
||||
@@ -669,7 +677,7 @@ exports.$ = {
|
||||
noisePreview: '#noisePreview',
|
||||
|
||||
};
|
||||
exports.ready = function () {
|
||||
exports.ready = function() {
|
||||
for (const key in uiElements) {
|
||||
const element = uiElements[key];
|
||||
if (typeof element.ready === 'function') {
|
||||
@@ -677,7 +685,7 @@ exports.ready = function () {
|
||||
}
|
||||
}
|
||||
};
|
||||
exports.update = function (dump) {
|
||||
exports.update = function(dump) {
|
||||
this.dump = dump;
|
||||
for (const key in uiElements) {
|
||||
const element = uiElements[key];
|
||||
|
||||
@@ -8,8 +8,10 @@
|
||||
flex: 1;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
overflow: scroll;
|
||||
overflow-y: scroll;
|
||||
overflow-x: auto;
|
||||
padding-left: 6px;
|
||||
padding-right: 2px;
|
||||
}
|
||||
|
||||
.container[hoving] {
|
||||
|
||||
@@ -1248,7 +1248,7 @@ const Elements = {
|
||||
panel.$.sectionAsset.prepend(materialPanel);
|
||||
}
|
||||
|
||||
materialPanel.addEventListener('focus', () => {
|
||||
materialPanel.focusEventInNode = () => {
|
||||
const children = Array.from(materialPanel.parentElement.children);
|
||||
children.forEach((child) => {
|
||||
if (child === materialPanel) {
|
||||
@@ -1257,14 +1257,16 @@ const Elements = {
|
||||
child.removeAttribute('focused');
|
||||
}
|
||||
});
|
||||
});
|
||||
materialPanel.addEventListener('blur', () => {
|
||||
};
|
||||
materialPanel.blurEventInNode = () => {
|
||||
if (panel.blurSleep) {
|
||||
return;
|
||||
}
|
||||
|
||||
materialPanel.removeAttribute('focused');
|
||||
});
|
||||
};
|
||||
materialPanel.addEventListener('focus', materialPanel.focusEventInNode);
|
||||
materialPanel.addEventListener('blur', materialPanel.blurEventInNode);
|
||||
}
|
||||
materialPanels.push(materialPanel);
|
||||
materialPrevPanel = materialPanel;
|
||||
@@ -1274,6 +1276,10 @@ const Elements = {
|
||||
for (const oldChild of oldChildren) {
|
||||
if (oldChild && materialPanels.indexOf(oldChild) === -1) {
|
||||
await oldChild.panel.beforeClose.call(oldChild.panelObject);
|
||||
oldChild.removeEventListener('focus', oldChild.focusEventInNode);
|
||||
oldChild.removeEventListener('blur', oldChild.blurEventInNode);
|
||||
oldChild.focusEventInNode = undefined;
|
||||
oldChild.blurEventInNode = undefined;
|
||||
oldChild.remove();
|
||||
}
|
||||
}
|
||||
@@ -1289,6 +1295,10 @@ const Elements = {
|
||||
if (next === false) {
|
||||
return false;
|
||||
} else {
|
||||
materialPanel.removeEventListener('focus', materialPanel.focusEventInNode);
|
||||
materialPanel.removeEventListener('blur', materialPanel.blurEventInNode);
|
||||
materialPanel.focusEventInNode = undefined;
|
||||
materialPanel.blurEventInNode = undefined;
|
||||
materialPanel.remove();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user