预览扫描
This commit is contained in:
1 parent
2a5fe0ce1f
commit
2cb70c49d4
6 files changed
+86
-10
No files matched your search
@@ -545,6 +545,37 @@
|
||||
return false;
|
||||
}
|
||||
|
||||
async function getPreviewSearchRoots(sourcePath) {
|
||||
const currentDir = path.dirname(sourcePath);
|
||||
const libraryRoot = utils.findLibraryRoot(sourcePath);
|
||||
if (!libraryRoot) return null;
|
||||
const folders = utils.foldersOfItem(sourcePath);
|
||||
const params = new URLSearchParams({
|
||||
limit: '1000',
|
||||
keyword: utils.normalizeStem(path.basename(sourcePath)),
|
||||
});
|
||||
if (folders.length) params.set('folders', folders.join(','));
|
||||
try {
|
||||
const response = await fetch('http://localhost:41595/api/item/list?' + params.toString() + '&_=' + Date.now(), {
|
||||
cache: 'no-store',
|
||||
});
|
||||
const result = await response.json();
|
||||
if (!response.ok || !result || result.status !== 'success' || !Array.isArray(result.data)) return null;
|
||||
const imagesDir = path.join(libraryRoot, 'images');
|
||||
const roots = [currentDir];
|
||||
for (const item of result.data) {
|
||||
if (!item || !/^[A-Za-z0-9_-]+$/.test(item.id || '')) continue;
|
||||
if (!utils.extOf(String(item.name || '') + '.' + String(item.ext || ''))) continue;
|
||||
const itemDir = path.join(imagesDir, item.id + '.info');
|
||||
if (utils.isEagleItemDir(itemDir)) roots.push(itemDir);
|
||||
}
|
||||
return [...new Set(roots.map((root) => path.resolve(root)))];
|
||||
} catch (error) {
|
||||
log('Eagle 候选素材查询失败,回退到本地发现: ' + error.message);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
function currentResourcePaths() {
|
||||
if (!activeAssets) return [];
|
||||
const groupStems = new Set([
|
||||
@@ -1142,7 +1173,8 @@
|
||||
else showTextPreview(name, parsed === undefined ? text : JSON.stringify(parsed, null, 2));
|
||||
return;
|
||||
}
|
||||
const assets = utils.discoverAssets(filePath);
|
||||
const previewSearchRoots = await getPreviewSearchRoots(filePath);
|
||||
const assets = utils.discoverAssets(filePath, previewSearchRoots ? { searchRoots: previewSearchRoots } : undefined);
|
||||
|
||||
if (!assets.skeletonPath || !assets.atlasPath) {
|
||||
if (!assets.skeletonPath) {
|
||||
|
||||
Reference in new issue
Block a user