Commit 8417141f authored by rockyl's avatar rockyl

修复png内容为空的情况

parent 45dacb44
...@@ -280,24 +280,26 @@ async function execute$1(psdFile, options) { ...@@ -280,24 +280,26 @@ async function execute$1(psdFile, options) {
const uuid = generateUUID(); const uuid = generateUUID();
const ext = '.png'; const ext = '.png';
properties.source = 'asset://' + uuid;
const imageFilePath = path.join(imagesPath, uuid + ext); const imageFilePath = path.join(imagesPath, uuid + ext);
await fs.ensureDir(path.dirname(imageFilePath)); await fs.ensureDir(path.dirname(imageFilePath));
let png = node.origin.toPng(); let png = node.origin.toPng();
let buffer = await savePng(png, imageFilePath); let buffer = await savePng(png, imageFilePath).catch(e=>{});
//await node.origin.saveAsPng(imageFilePath); //await node.origin.saveAsPng(imageFilePath);
const hashFileName = hash(buffer); if(buffer){
const hashFilePath = path.join(imagesPath, hashFileName + ext); properties.source = 'asset://' + uuid;
await fs.rename(imageFilePath, hashFilePath);
const hashFileName = hash(buffer);
const hashFilePath = path.join(imagesPath, hashFileName + ext);
await fs.rename(imageFilePath, hashFilePath);
assets.push({ assets.push({
name, name,
ext, ext,
uuid, uuid,
hash: hashFileName, hash: hashFileName,
}); });
}
} }
} }
......
This diff is collapsed.
...@@ -286,24 +286,26 @@ async function execute$1(psdFile, options) { ...@@ -286,24 +286,26 @@ async function execute$1(psdFile, options) {
const uuid = generateUUID(); const uuid = generateUUID();
const ext = '.png'; const ext = '.png';
properties.source = 'asset://' + uuid;
const imageFilePath = path.join(imagesPath, uuid + ext); const imageFilePath = path.join(imagesPath, uuid + ext);
await fs.ensureDir(path.dirname(imageFilePath)); await fs.ensureDir(path.dirname(imageFilePath));
let png = node.origin.toPng(); let png = node.origin.toPng();
let buffer = await savePng(png, imageFilePath); let buffer = await savePng(png, imageFilePath).catch(e=>{});
//await node.origin.saveAsPng(imageFilePath); //await node.origin.saveAsPng(imageFilePath);
const hashFileName = hash(buffer); if(buffer){
const hashFilePath = path.join(imagesPath, hashFileName + ext); properties.source = 'asset://' + uuid;
await fs.rename(imageFilePath, hashFilePath);
const hashFileName = hash(buffer);
const hashFilePath = path.join(imagesPath, hashFileName + ext);
await fs.rename(imageFilePath, hashFilePath);
assets.push({ assets.push({
name, name,
ext, ext,
uuid, uuid,
hash: hashFileName, hash: hashFileName,
}); });
}
} }
} }
......
This diff is collapsed.
...@@ -286,24 +286,26 @@ ...@@ -286,24 +286,26 @@
const uuid = generateUUID(); const uuid = generateUUID();
const ext = '.png'; const ext = '.png';
properties.source = 'asset://' + uuid;
const imageFilePath = path.join(imagesPath, uuid + ext); const imageFilePath = path.join(imagesPath, uuid + ext);
await fs.ensureDir(path.dirname(imageFilePath)); await fs.ensureDir(path.dirname(imageFilePath));
let png = node.origin.toPng(); let png = node.origin.toPng();
let buffer = await savePng(png, imageFilePath); let buffer = await savePng(png, imageFilePath).catch(e=>{});
//await node.origin.saveAsPng(imageFilePath); //await node.origin.saveAsPng(imageFilePath);
const hashFileName = hash(buffer); if(buffer){
const hashFilePath = path.join(imagesPath, hashFileName + ext); properties.source = 'asset://' + uuid;
await fs.rename(imageFilePath, hashFilePath);
const hashFileName = hash(buffer);
const hashFilePath = path.join(imagesPath, hashFileName + ext);
await fs.rename(imageFilePath, hashFilePath);
assets.push({ assets.push({
name, name,
ext, ext,
uuid, uuid,
hash: hashFileName, hash: hashFileName,
}); });
}
} }
} }
......
This diff is collapsed.
...@@ -73,24 +73,26 @@ export async function execute(psdFile, options) { ...@@ -73,24 +73,26 @@ export async function execute(psdFile, options) {
const uuid = generateUUID(); const uuid = generateUUID();
const ext = '.png'; const ext = '.png';
properties.source = 'asset://' + uuid;
const imageFilePath = path.join(imagesPath, uuid + ext); const imageFilePath = path.join(imagesPath, uuid + ext);
await fs.ensureDir(path.dirname(imageFilePath)); await fs.ensureDir(path.dirname(imageFilePath));
let png = node.origin.toPng(); let png = node.origin.toPng();
let buffer = await savePng(png, imageFilePath); let buffer = await savePng(png, imageFilePath).catch(e=>{});
//await node.origin.saveAsPng(imageFilePath); //await node.origin.saveAsPng(imageFilePath);
const hashFileName = hash(buffer); if(buffer){
const hashFilePath = path.join(imagesPath, hashFileName + ext); properties.source = 'asset://' + uuid;
await fs.rename(imageFilePath, hashFilePath);
const hashFileName = hash(buffer);
const hashFilePath = path.join(imagesPath, hashFileName + ext);
await fs.rename(imageFilePath, hashFilePath);
assets.push({ assets.push({
name, name,
ext, ext,
uuid, uuid,
hash: hashFileName, hash: hashFileName,
}); });
}
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment