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) {
*/
const
relativePosPrefixMap
=
{
l
:
'left'
,
t
:
'top'
,
r
:
'right'
,
b
:
'bottom'
,
h
:
'horizonCenter'
,
v
:
'verticalCenter'
,
wp
:
'percentWidth'
,
hp
:
'percentHeight'
,
l
:
{
field
:
'left'
,}
,
t
:
{
field
:
'top'
,}
,
r
:
{
field
:
'right'
,}
,
b
:
{
field
:
'bottom'
,}
,
h
:
{
field
:
'horizonCenter'
,}
,
v
:
{
field
:
'verticalCenter'
,}
,
wp
:
{
field
:
'width'
,
isPercent
:
true
}
,
hp
:
{
field
:
'height'
,
isPercent
:
true
}
,
};
async
function
execute
(
psdFile
,
options
)
{
...
...
@@ -97,24 +97,38 @@ async function execute(psdFile, options) {
};
if
(
name
.
includes
(
'|'
))
{
let
arr
=
name
.
split
(
'|'
);
name
=
arr
[
0
];
let
paramsStr
=
arr
[
1
];
let
params
=
paramsStr
.
split
(
';'
);
let
relativePos
=
params
[
0
];
if
(
relativePos
)
{
let
items
=
relativePos
.
split
(
','
);
for
(
let
item
of
items
)
{
let
prefix
=
item
[
0
];
let
field
=
relativePosPrefixMap
[
prefix
];
if
(
field
)
{
let
value
=
parseFloat
(
item
.
substr
(
1
));
if
(
isNaN
(
value
)){
value
=
0
;
try
{
let
arr
=
name
.
split
(
'|'
);
name
=
arr
[
0
];
let
paramsStr
=
arr
[
1
];
let
params
=
paramsStr
.
split
(
';'
);
let
relativePos
=
params
[
0
];
if
(
relativePos
)
{
let
items
=
relativePos
.
split
(
','
);
for
(
let
item
of
items
)
{
let
result
=
item
.
match
(
/
[
a-zA-Z
]
+/
);
if
(
!
result
){
continue
;
}
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) {
};
let
dataString
=
JSON
.
stringify
(
data
);
console
.
log
(
dataString
.
length
);
let
buf
=
new
Buffer
(
dataString
);
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) {
*/
const
relativePosPrefixMap
=
{
l
:
'left'
,
t
:
'top'
,
r
:
'right'
,
b
:
'bottom'
,
h
:
'horizonCenter'
,
v
:
'verticalCenter'
,
wp
:
'percentWidth'
,
hp
:
'percentHeight'
,
l
:
{
field
:
'left'
,}
,
t
:
{
field
:
'top'
,}
,
r
:
{
field
:
'right'
,}
,
b
:
{
field
:
'bottom'
,}
,
h
:
{
field
:
'horizonCenter'
,}
,
v
:
{
field
:
'verticalCenter'
,}
,
wp
:
{
field
:
'width'
,
isPercent
:
true
}
,
hp
:
{
field
:
'height'
,
isPercent
:
true
}
,
};
async
function
execute
(
psdFile
,
options
)
{
...
...
@@ -103,24 +103,38 @@ async function execute(psdFile, options) {
};
if
(
name
.
includes
(
'|'
))
{
let
arr
=
name
.
split
(
'|'
);
name
=
arr
[
0
];
let
paramsStr
=
arr
[
1
];
let
params
=
paramsStr
.
split
(
';'
);
let
relativePos
=
params
[
0
];
if
(
relativePos
)
{
let
items
=
relativePos
.
split
(
','
);
for
(
let
item
of
items
)
{
let
prefix
=
item
[
0
];
let
field
=
relativePosPrefixMap
[
prefix
];
if
(
field
)
{
let
value
=
parseFloat
(
item
.
substr
(
1
));
if
(
isNaN
(
value
)){
value
=
0
;
try
{
let
arr
=
name
.
split
(
'|'
);
name
=
arr
[
0
];
let
paramsStr
=
arr
[
1
];
let
params
=
paramsStr
.
split
(
';'
);
let
relativePos
=
params
[
0
];
if
(
relativePos
)
{
let
items
=
relativePos
.
split
(
','
);
for
(
let
item
of
items
)
{
let
result
=
item
.
match
(
/
[
a-zA-Z
]
+/
);
if
(
!
result
){
continue
;
}
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) {
};
let
dataString
=
JSON
.
stringify
(
data
);
console
.
log
(
dataString
.
length
);
let
buf
=
new
Buffer
(
dataString
);
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 @@
*/
const
relativePosPrefixMap
=
{
l
:
'left'
,
t
:
'top'
,
r
:
'right'
,
b
:
'bottom'
,
h
:
'horizonCenter'
,
v
:
'verticalCenter'
,
wp
:
'percentWidth'
,
hp
:
'percentHeight'
,
l
:
{
field
:
'left'
,}
,
t
:
{
field
:
'top'
,}
,
r
:
{
field
:
'right'
,}
,
b
:
{
field
:
'bottom'
,}
,
h
:
{
field
:
'horizonCenter'
,}
,
v
:
{
field
:
'verticalCenter'
,}
,
wp
:
{
field
:
'width'
,
isPercent
:
true
}
,
hp
:
{
field
:
'height'
,
isPercent
:
true
}
,
};
async
function
execute
(
psdFile
,
options
)
{
...
...
@@ -103,24 +103,38 @@
};
if
(
name
.
includes
(
'|'
))
{
let
arr
=
name
.
split
(
'|'
);
name
=
arr
[
0
];
let
paramsStr
=
arr
[
1
];
let
params
=
paramsStr
.
split
(
';'
);
let
relativePos
=
params
[
0
];
if
(
relativePos
)
{
let
items
=
relativePos
.
split
(
','
);
for
(
let
item
of
items
)
{
let
prefix
=
item
[
0
];
let
field
=
relativePosPrefixMap
[
prefix
];
if
(
field
)
{
let
value
=
parseFloat
(
item
.
substr
(
1
));
if
(
isNaN
(
value
)){
value
=
0
;
try
{
let
arr
=
name
.
split
(
'|'
);
name
=
arr
[
0
];
let
paramsStr
=
arr
[
1
];
let
params
=
paramsStr
.
split
(
';'
);
let
relativePos
=
params
[
0
];
if
(
relativePos
)
{
let
items
=
relativePos
.
split
(
','
);
for
(
let
item
of
items
)
{
let
result
=
item
.
match
(
/
[
a-zA-Z
]
+/
);
if
(
!
result
){
continue
;
}
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 @@
};
let
dataString
=
JSON
.
stringify
(
data
);
console
.
log
(
dataString
.
length
);
let
buf
=
new
Buffer
(
dataString
);
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';
import
zlib
from
'zlib'
;
const
relativePosPrefixMap
=
{
l
:
'left'
,
t
:
'top'
,
r
:
'right'
,
b
:
'bottom'
,
h
:
'horizonCenter'
,
v
:
'verticalCenter'
,
wp
:
'percentWidth'
,
hp
:
'percentHeight'
,
l
:
{
field
:
'left'
,}
,
t
:
{
field
:
'top'
,}
,
r
:
{
field
:
'right'
,}
,
b
:
{
field
:
'bottom'
,}
,
h
:
{
field
:
'horizonCenter'
,}
,
v
:
{
field
:
'verticalCenter'
,}
,
wp
:
{
field
:
'width'
,
isPercent
:
true
}
,
hp
:
{
field
:
'height'
,
isPercent
:
true
}
,
};
export
async
function
execute
(
psdFile
,
options
)
{
...
...
@@ -44,24 +44,38 @@ export async function execute(psdFile, options) {
};
if
(
name
.
includes
(
'|'
))
{
let
arr
=
name
.
split
(
'|'
);
name
=
arr
[
0
];
let
paramsStr
=
arr
[
1
];
let
params
=
paramsStr
.
split
(
';'
);
let
relativePos
=
params
[
0
];
if
(
relativePos
)
{
let
items
=
relativePos
.
split
(
','
);
for
(
let
item
of
items
)
{
let
prefix
=
item
[
0
];
let
field
=
relativePosPrefixMap
[
prefix
];
if
(
field
)
{
let
value
=
parseFloat
(
item
.
substr
(
1
));
if
(
isNaN
(
value
)){
value
=
0
;
try
{
let
arr
=
name
.
split
(
'|'
);
name
=
arr
[
0
];
let
paramsStr
=
arr
[
1
];
let
params
=
paramsStr
.
split
(
';'
);
let
relativePos
=
params
[
0
];
if
(
relativePos
)
{
let
items
=
relativePos
.
split
(
','
);
for
(
let
item
of
items
)
{
let
result
=
item
.
match
(
/
[
a-zA-Z
]
+/
);
if
(
!
result
){
continue
;
}
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) {
};
let
dataString
=
JSON
.
stringify
(
data
);
console
.
log
(
dataString
.
length
);
let
buf
=
new
Buffer
(
dataString
);
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