Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[3.9.0] use asset image in asset header #16137

Merged
merged 1 commit into from
Sep 15, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 4 additions & 17 deletions editor/inspector/contributions/asset.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,14 @@ const path = require('path');
const { injectionStyle } = require('../utils/prop');
const History = require('./asset-history/index');

const showImage = ['image', 'texture', 'sprite-frame', 'gltf-mesh'];
exports.listeners = {};

exports.style = fs.readFileSync(path.join(__dirname, './asset.css'), 'utf8');

exports.template = `
<div class="container">
<header class="header">
<ui-icon class="icon" color tooltip="i18n:ENGINE.assets.locate_asset"></ui-icon>
<ui-image class="image" tooltip="i18n:ENGINE.assets.locate_asset"></ui-image>
<ui-asset-image class="image" tooltip="i18n:ENGINE.assets.locate_asset"></ui-asset-image>
<ui-label class="name"></ui-label>
<ui-button class="save tiny green" tooltip="i18n:ENGINE.assets.save">
<ui-icon value="check"></ui-icon>
Expand Down Expand Up @@ -41,7 +39,6 @@ exports.$ = {
header: '.header',
content: '.content',
copy: '.copy',
icon: '.icon',
image: '.image',
name: '.name',
help: '.help',
Expand Down Expand Up @@ -216,7 +213,7 @@ const Elements = {
}
});

panel.$.icon.addEventListener('click', (event) => {
panel.$.image.addEventListener('click', (event) => {
event.stopPropagation();
panel.uuidList.forEach((uuid) => {
Editor.Message.request('assets', 'ui-kit:touch-asset', uuid);
Expand Down Expand Up @@ -247,19 +244,9 @@ const Elements = {
panel.$.copy.style.display = 'none';
}

const isImage = showImage.includes(panel.asset.importer);

if (isImage) {
panel.$.image.value = panel.asset.uuid;
panel.$.header.prepend(panel.$.image);
panel.$.icon.remove();
} else {
panel.$.icon.value = panel.asset.importer === '*' ? 'file' : panel.asset.importer;
panel.$.header.prepend(panel.$.icon);

panel.$.image.value = ''; // 清空,避免缓存
panel.$.image.remove();
}
panel.$.image.value = panel.asset.uuid;
panel.$.image.importer = panel.asset.importer;
},
async isDirty() {
const panel = this;
Expand Down
Loading