Commit d88e43ad authored by 张九刚's avatar 张九刚

新增透明度属性解析

parent 44d8e594
{ {
"name": "psd-parse-web", "name": "psd-parse-web",
"version": "2.1.4", "version": "2.1.5",
"main": "src/index.js", "main": "src/index.js",
"module": "dist/index.es.js", "module": "dist/index.es.js",
"license": "MIT", "license": "MIT",
......
...@@ -59,13 +59,17 @@ ...@@ -59,13 +59,17 @@
if (!page.children) { if (!page.children) {
console.warn(`${page.name}不合法,请保持设计稿根目录为全部文件夹形式`); console.warn(`${page.name}不合法,请保持设计稿根目录为全部文件夹形式`);
} else { } else {
const { x, y, width, height } = page; const { x, y, width, height, alpha } = page;
let opacityObj = {};
if (alpha != 1) {
opacityObj = { opacity: alpha.toFixed(2) };
}
const viewNode = { const viewNode = {
name: folderName, name: folderName,
nodeType: 'Div', nodeType: 'Div',
properties: { properties: {
style: { style: {
width, height, left: x, top: y, position: "absolute" width, height, left: x, top: y, position: "absolute", ...opacityObj
}, },
attrs: { attrs: {
...@@ -80,11 +84,16 @@ ...@@ -80,11 +84,16 @@
} }
await walkNode(page, async (node, parent) => { await walkNode(page, async (node, parent) => {
let { name } = node; let { name } = node;
name = trimCustom(name); name = trimCustom(name);
const { x, y, width, height, origin: { layer, layer: { typeTool, solidColor } } } = node; const { x, y, width, height, alpha,origin: { layer, layer: { typeTool, solidColor } } } = node;
let opacityObj = {};
if (alpha != 1) {
opacityObj = { opacity: alpha.toFixed(2) };
}
let properties = { let properties = {
style: { style: {
width, height, left: x, top: y, position: "absolute" width, height, left: x, top: y, position: "absolute", ...opacityObj
}, },
attrs: { attrs: {
......
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