Skip to content

Commit

Permalink
use asset image in asset header (#16137)
Browse files Browse the repository at this point in the history
  • Loading branch information
yanOO1497 authored Sep 15, 2023
1 parent 471fe46 commit a94f4ba
Showing 1 changed file with 4 additions and 17 deletions.
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 @@ -225,7 +222,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 @@ -256,19 +253,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

0 comments on commit a94f4ba

Please sign in to comment.