Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
psd-parse-web
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
劳工
psd-parse-web
Commits
144f980e
Commit
144f980e
authored
Apr 23, 2020
by
rockyl
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
支持宽高百分比
parent
9524069b
Changes
7
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
151 additions
and
99 deletions
+151
-99
index.es.js
dist/index.es.js
+37
-24
index.es.js.map
dist/index.es.js.map
+1
-1
index.js
dist/index.js
+37
-24
index.js.map
dist/index.js.map
+1
-1
index.umd.js
dist/index.umd.js
+37
-24
index.umd.js.map
dist/index.umd.js.map
+1
-1
zeroing.js
src/zeroing.js
+37
-24
No files found.
dist/index.es.js
View file @
144f980e
...
@@ -66,14 +66,14 @@ async function walkNode(node, callback, includeSelf = false) {
...
@@ -66,14 +66,14 @@ async function walkNode(node, callback, includeSelf = false) {
*/
*/
const
relativePosPrefixMap
=
{
const
relativePosPrefixMap
=
{
l
:
'left'
,
l
:
{
field
:
'left'
,}
,
t
:
'top'
,
t
:
{
field
:
'top'
,}
,
r
:
'right'
,
r
:
{
field
:
'right'
,}
,
b
:
'bottom'
,
b
:
{
field
:
'bottom'
,}
,
h
:
'horizonCenter'
,
h
:
{
field
:
'horizonCenter'
,}
,
v
:
'verticalCenter'
,
v
:
{
field
:
'verticalCenter'
,}
,
wp
:
'percentWidth'
,
wp
:
{
field
:
'width'
,
isPercent
:
true
}
,
hp
:
'percentHeight'
,
hp
:
{
field
:
'height'
,
isPercent
:
true
}
,
};
};
async
function
execute
(
psdFile
,
options
)
{
async
function
execute
(
psdFile
,
options
)
{
...
@@ -97,24 +97,38 @@ async function execute(psdFile, options) {
...
@@ -97,24 +97,38 @@ async function execute(psdFile, options) {
};
};
if
(
name
.
includes
(
'|'
))
{
if
(
name
.
includes
(
'|'
))
{
let
arr
=
name
.
split
(
'|'
);
try
{
name
=
arr
[
0
];
let
arr
=
name
.
split
(
'|'
);
let
paramsStr
=
arr
[
1
];
name
=
arr
[
0
];
let
params
=
paramsStr
.
split
(
';'
);
let
paramsStr
=
arr
[
1
];
let
relativePos
=
params
[
0
];
let
params
=
paramsStr
.
split
(
';'
);
if
(
relativePos
)
{
let
relativePos
=
params
[
0
];
let
items
=
relativePos
.
split
(
','
);
if
(
relativePos
)
{
for
(
let
item
of
items
)
{
let
items
=
relativePos
.
split
(
','
);
let
prefix
=
item
[
0
];
for
(
let
item
of
items
)
{
let
field
=
relativePosPrefixMap
[
prefix
];
let
result
=
item
.
match
(
/
[
a-zA-Z
]
+/
);
if
(
field
)
{
if
(
!
result
){
let
value
=
parseFloat
(
item
.
substr
(
1
));
continue
;
if
(
isNaN
(
value
)){
}
value
=
0
;
let
prefix
=
result
[
0
];
let
mapItem
=
relativePosPrefixMap
[
prefix
];
if
(
mapItem
)
{
const
{
field
,
isPercent
}
=
mapItem
;
let
value
=
item
.
substr
(
prefix
.
length
);
if
(
isPercent
)
{
value
+=
'%'
;
}
else
{
value
=
parseFloat
(
value
);
if
(
isNaN
(
value
))
{
value
=
0
;
}
}
properties
[
field
]
=
value
;
}
}
properties
[
field
]
=
value
;
}
}
}
}
}
catch
(
e
)
{
console
.
log
(
e
);
}
}
}
}
...
@@ -216,7 +230,6 @@ async function execute(psdFile, options) {
...
@@ -216,7 +230,6 @@ async function execute(psdFile, options) {
};
};
let
dataString
=
JSON
.
stringify
(
data
);
let
dataString
=
JSON
.
stringify
(
data
);
console
.
log
(
dataString
.
length
);
let
buf
=
new
Buffer
(
dataString
);
let
buf
=
new
Buffer
(
dataString
);
return
await
new
Promise
((
resolve
,
reject
)
=>
{
return
await
new
Promise
((
resolve
,
reject
)
=>
{
...
...
dist/index.es.js.map
View file @
144f980e
This diff is collapsed.
Click to expand it.
dist/index.js
View file @
144f980e
...
@@ -72,14 +72,14 @@ async function walkNode(node, callback, includeSelf = false) {
...
@@ -72,14 +72,14 @@ async function walkNode(node, callback, includeSelf = false) {
*/
*/
const
relativePosPrefixMap
=
{
const
relativePosPrefixMap
=
{
l
:
'left'
,
l
:
{
field
:
'left'
,}
,
t
:
'top'
,
t
:
{
field
:
'top'
,}
,
r
:
'right'
,
r
:
{
field
:
'right'
,}
,
b
:
'bottom'
,
b
:
{
field
:
'bottom'
,}
,
h
:
'horizonCenter'
,
h
:
{
field
:
'horizonCenter'
,}
,
v
:
'verticalCenter'
,
v
:
{
field
:
'verticalCenter'
,}
,
wp
:
'percentWidth'
,
wp
:
{
field
:
'width'
,
isPercent
:
true
}
,
hp
:
'percentHeight'
,
hp
:
{
field
:
'height'
,
isPercent
:
true
}
,
};
};
async
function
execute
(
psdFile
,
options
)
{
async
function
execute
(
psdFile
,
options
)
{
...
@@ -103,24 +103,38 @@ async function execute(psdFile, options) {
...
@@ -103,24 +103,38 @@ async function execute(psdFile, options) {
};
};
if
(
name
.
includes
(
'|'
))
{
if
(
name
.
includes
(
'|'
))
{
let
arr
=
name
.
split
(
'|'
);
try
{
name
=
arr
[
0
];
let
arr
=
name
.
split
(
'|'
);
let
paramsStr
=
arr
[
1
];
name
=
arr
[
0
];
let
params
=
paramsStr
.
split
(
';'
);
let
paramsStr
=
arr
[
1
];
let
relativePos
=
params
[
0
];
let
params
=
paramsStr
.
split
(
';'
);
if
(
relativePos
)
{
let
relativePos
=
params
[
0
];
let
items
=
relativePos
.
split
(
','
);
if
(
relativePos
)
{
for
(
let
item
of
items
)
{
let
items
=
relativePos
.
split
(
','
);
let
prefix
=
item
[
0
];
for
(
let
item
of
items
)
{
let
field
=
relativePosPrefixMap
[
prefix
];
let
result
=
item
.
match
(
/
[
a-zA-Z
]
+/
);
if
(
field
)
{
if
(
!
result
){
let
value
=
parseFloat
(
item
.
substr
(
1
));
continue
;
if
(
isNaN
(
value
)){
}
value
=
0
;
let
prefix
=
result
[
0
];
let
mapItem
=
relativePosPrefixMap
[
prefix
];
if
(
mapItem
)
{
const
{
field
,
isPercent
}
=
mapItem
;
let
value
=
item
.
substr
(
prefix
.
length
);
if
(
isPercent
)
{
value
+=
'%'
;
}
else
{
value
=
parseFloat
(
value
);
if
(
isNaN
(
value
))
{
value
=
0
;
}
}
properties
[
field
]
=
value
;
}
}
properties
[
field
]
=
value
;
}
}
}
}
}
catch
(
e
)
{
console
.
log
(
e
);
}
}
}
}
...
@@ -222,7 +236,6 @@ async function execute(psdFile, options) {
...
@@ -222,7 +236,6 @@ async function execute(psdFile, options) {
};
};
let
dataString
=
JSON
.
stringify
(
data
);
let
dataString
=
JSON
.
stringify
(
data
);
console
.
log
(
dataString
.
length
);
let
buf
=
new
Buffer
(
dataString
);
let
buf
=
new
Buffer
(
dataString
);
return
await
new
Promise
((
resolve
,
reject
)
=>
{
return
await
new
Promise
((
resolve
,
reject
)
=>
{
...
...
dist/index.js.map
View file @
144f980e
This diff is collapsed.
Click to expand it.
dist/index.umd.js
View file @
144f980e
...
@@ -72,14 +72,14 @@
...
@@ -72,14 +72,14 @@
*/
*/
const
relativePosPrefixMap
=
{
const
relativePosPrefixMap
=
{
l
:
'left'
,
l
:
{
field
:
'left'
,}
,
t
:
'top'
,
t
:
{
field
:
'top'
,}
,
r
:
'right'
,
r
:
{
field
:
'right'
,}
,
b
:
'bottom'
,
b
:
{
field
:
'bottom'
,}
,
h
:
'horizonCenter'
,
h
:
{
field
:
'horizonCenter'
,}
,
v
:
'verticalCenter'
,
v
:
{
field
:
'verticalCenter'
,}
,
wp
:
'percentWidth'
,
wp
:
{
field
:
'width'
,
isPercent
:
true
}
,
hp
:
'percentHeight'
,
hp
:
{
field
:
'height'
,
isPercent
:
true
}
,
};
};
async
function
execute
(
psdFile
,
options
)
{
async
function
execute
(
psdFile
,
options
)
{
...
@@ -103,24 +103,38 @@
...
@@ -103,24 +103,38 @@
};
};
if
(
name
.
includes
(
'|'
))
{
if
(
name
.
includes
(
'|'
))
{
let
arr
=
name
.
split
(
'|'
);
try
{
name
=
arr
[
0
];
let
arr
=
name
.
split
(
'|'
);
let
paramsStr
=
arr
[
1
];
name
=
arr
[
0
];
let
params
=
paramsStr
.
split
(
';'
);
let
paramsStr
=
arr
[
1
];
let
relativePos
=
params
[
0
];
let
params
=
paramsStr
.
split
(
';'
);
if
(
relativePos
)
{
let
relativePos
=
params
[
0
];
let
items
=
relativePos
.
split
(
','
);
if
(
relativePos
)
{
for
(
let
item
of
items
)
{
let
items
=
relativePos
.
split
(
','
);
let
prefix
=
item
[
0
];
for
(
let
item
of
items
)
{
let
field
=
relativePosPrefixMap
[
prefix
];
let
result
=
item
.
match
(
/
[
a-zA-Z
]
+/
);
if
(
field
)
{
if
(
!
result
){
let
value
=
parseFloat
(
item
.
substr
(
1
));
continue
;
if
(
isNaN
(
value
)){
}
value
=
0
;
let
prefix
=
result
[
0
];
let
mapItem
=
relativePosPrefixMap
[
prefix
];
if
(
mapItem
)
{
const
{
field
,
isPercent
}
=
mapItem
;
let
value
=
item
.
substr
(
prefix
.
length
);
if
(
isPercent
)
{
value
+=
'%'
;
}
else
{
value
=
parseFloat
(
value
);
if
(
isNaN
(
value
))
{
value
=
0
;
}
}
properties
[
field
]
=
value
;
}
}
properties
[
field
]
=
value
;
}
}
}
}
}
catch
(
e
)
{
console
.
log
(
e
);
}
}
}
}
...
@@ -222,7 +236,6 @@
...
@@ -222,7 +236,6 @@
};
};
let
dataString
=
JSON
.
stringify
(
data
);
let
dataString
=
JSON
.
stringify
(
data
);
console
.
log
(
dataString
.
length
);
let
buf
=
new
Buffer
(
dataString
);
let
buf
=
new
Buffer
(
dataString
);
return
await
new
Promise
((
resolve
,
reject
)
=>
{
return
await
new
Promise
((
resolve
,
reject
)
=>
{
...
...
dist/index.umd.js.map
View file @
144f980e
This diff is collapsed.
Click to expand it.
src/zeroing.js
View file @
144f980e
...
@@ -13,14 +13,14 @@ import hash from 'object-hash';
...
@@ -13,14 +13,14 @@ import hash from 'object-hash';
import
zlib
from
'zlib'
;
import
zlib
from
'zlib'
;
const
relativePosPrefixMap
=
{
const
relativePosPrefixMap
=
{
l
:
'left'
,
l
:
{
field
:
'left'
,}
,
t
:
'top'
,
t
:
{
field
:
'top'
,}
,
r
:
'right'
,
r
:
{
field
:
'right'
,}
,
b
:
'bottom'
,
b
:
{
field
:
'bottom'
,}
,
h
:
'horizonCenter'
,
h
:
{
field
:
'horizonCenter'
,}
,
v
:
'verticalCenter'
,
v
:
{
field
:
'verticalCenter'
,}
,
wp
:
'percentWidth'
,
wp
:
{
field
:
'width'
,
isPercent
:
true
}
,
hp
:
'percentHeight'
,
hp
:
{
field
:
'height'
,
isPercent
:
true
}
,
};
};
export
async
function
execute
(
psdFile
,
options
)
{
export
async
function
execute
(
psdFile
,
options
)
{
...
@@ -44,24 +44,38 @@ export async function execute(psdFile, options) {
...
@@ -44,24 +44,38 @@ export async function execute(psdFile, options) {
};
};
if
(
name
.
includes
(
'|'
))
{
if
(
name
.
includes
(
'|'
))
{
let
arr
=
name
.
split
(
'|'
);
try
{
name
=
arr
[
0
];
let
arr
=
name
.
split
(
'|'
);
let
paramsStr
=
arr
[
1
];
name
=
arr
[
0
];
let
params
=
paramsStr
.
split
(
';'
);
let
paramsStr
=
arr
[
1
];
let
relativePos
=
params
[
0
];
let
params
=
paramsStr
.
split
(
';'
);
if
(
relativePos
)
{
let
relativePos
=
params
[
0
];
let
items
=
relativePos
.
split
(
','
);
if
(
relativePos
)
{
for
(
let
item
of
items
)
{
let
items
=
relativePos
.
split
(
','
);
let
prefix
=
item
[
0
];
for
(
let
item
of
items
)
{
let
field
=
relativePosPrefixMap
[
prefix
];
let
result
=
item
.
match
(
/
[
a-zA-Z
]
+/
);
if
(
field
)
{
if
(
!
result
){
let
value
=
parseFloat
(
item
.
substr
(
1
));
continue
;
if
(
isNaN
(
value
)){
}
value
=
0
;
let
prefix
=
result
[
0
];
let
mapItem
=
relativePosPrefixMap
[
prefix
];
if
(
mapItem
)
{
const
{
field
,
isPercent
}
=
mapItem
;
let
value
=
item
.
substr
(
prefix
.
length
);
if
(
isPercent
)
{
value
+=
'%'
;
}
else
{
value
=
parseFloat
(
value
);
if
(
isNaN
(
value
))
{
value
=
0
;
}
}
properties
[
field
]
=
value
;
}
}
properties
[
field
]
=
value
;
}
}
}
}
}
catch
(
e
)
{
console
.
log
(
e
);
}
}
}
}
...
@@ -163,7 +177,6 @@ export async function execute(psdFile, options) {
...
@@ -163,7 +177,6 @@ export async function execute(psdFile, options) {
};
};
let
dataString
=
JSON
.
stringify
(
data
);
let
dataString
=
JSON
.
stringify
(
data
);
console
.
log
(
dataString
.
length
);
let
buf
=
new
Buffer
(
dataString
);
let
buf
=
new
Buffer
(
dataString
);
return
await
new
Promise
((
resolve
,
reject
)
=>
{
return
await
new
Promise
((
resolve
,
reject
)
=>
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment