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
e1de4f5d
Commit
e1de4f5d
authored
Aug 03, 2020
by
任建锋
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
--
parent
6da75550
Changes
7
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
149 additions
and
51 deletions
+149
-51
index.es.js
dist/index.es.js
+36
-12
index.es.js.map
dist/index.es.js.map
+1
-1
index.js
dist/index.js
+36
-12
index.js.map
dist/index.js.map
+1
-1
index.umd.js
dist/index.umd.js
+36
-12
index.umd.js.map
dist/index.umd.js.map
+1
-1
zeroing.js
src/zeroing.js
+38
-12
No files found.
dist/index.es.js
View file @
e1de4f5d
...
...
@@ -82,7 +82,24 @@ const relativePosPrefixMap = {
async
function
execute
(
psdFile
,
options
)
{
const
tree
=
await
getTree
(
psdFile
);
const
offset
=
options
?
options
.
offset
:
{
x
:
0
,
y
:
0
};
const
{
mode
=
'none'
,
singleView
=
true
}
=
options
;
let
offset
=
{
x
:
0
,
y
:
0
};
let
cutSize
=
{
x
:
0
,
y
:
0
};
if
(
mode
!==
'none'
)
{
cutSize
.
y
=
offsetAll
;
}
switch
(
mode
)
{
case
'top'
:
offset
.
y
=
offsetAll
;
break
;
case
'center'
:
offset
.
y
=
offsetAll
/
2
;
break
;
}
const
isCenter
=
mode
===
'center'
;
let
viewRoot
=
{
name
:
path
.
basename
(
psdFile
.
name
,
'.psd'
),
...
...
@@ -93,9 +110,9 @@ async function execute(psdFile, options) {
const
assets
=
[];
const
imageHashMap
=
{};
let
{
width
:
stageWidth
,
height
:
stageHeight
}
=
tree
;
stageWidth
-=
offset
.
x
||
0
;
stageHeight
-=
offset
.
y
||
0
;
let
{
width
:
stageWidth
Origin
,
height
:
stageHeightOrigin
}
=
tree
;
const
stageWidth
=
stageWidthOrigin
-
cutSize
.
x
||
0
;
const
stageHeight
=
stageHeightOrigin
-
cutSize
.
y
||
0
;
await
walkNode
(
tree
,
async
function
(
node
,
parent
)
{
let
{
name
}
=
node
;
...
...
@@ -110,15 +127,22 @@ async function execute(psdFile, options) {
},
className
:
""
};
const
isSecondLayer
=
!
parent
.
origin
.
parent
;
const
isSecondLayer
=
singleView
&&
!
parent
.
origin
.
parent
||
!
singleView
&&
parent
.
origin
.
parent
&&
!
parent
.
origin
.
parent
.
parent
;
const
shouldVerticalCenter
=
isSecondLayer
&&
isCenter
;
if
(
name
.
includes
(
'|'
))
{
if
(
name
.
includes
(
'|'
)
||
shouldVerticalCenter
)
{
try
{
let
arr
=
name
.
split
(
'|'
);
name
=
arr
[
0
];
let
paramsStr
=
arr
[
1
];
let
params
=
paramsStr
.
split
(
';'
);
let
relativePos
=
params
[
0
];
let
relativePos
;
if
(
paramsStr
){
let
params
=
paramsStr
.
split
(
';'
);
relativePos
=
params
[
0
];
}
else
if
(
shouldVerticalCenter
){
relativePos
=
'v'
;
}
if
(
relativePos
)
{
let
items
=
relativePos
.
split
(
','
);
for
(
let
item
of
items
)
{
...
...
@@ -142,16 +166,16 @@ async function execute(psdFile, options) {
value
=
y
-
offset
.
y
;
break
;
case
'r'
:
value
=
stageWidth
-
width
;
value
=
stageWidth
-
(
x
-
offset
.
x
)
-
width
;
break
;
case
'b'
:
value
=
stageHeight
-
height
;
value
=
stageHeight
-
(
y
-
offset
.
y
)
-
height
;
break
;
case
'h'
:
value
=
x
+
width
/
2
-
stageWidth
/
2
;
value
=
x
+
width
/
2
-
stageWidth
Origin
/
2
;
break
;
case
'v'
:
value
=
y
+
height
/
2
-
stageHeight
/
2
;
value
=
y
+
height
/
2
-
stageHeight
Origin
/
2
;
break
;
}
}
...
...
dist/index.es.js.map
View file @
e1de4f5d
This diff is collapsed.
Click to expand it.
dist/index.js
View file @
e1de4f5d
...
...
@@ -88,7 +88,24 @@ const relativePosPrefixMap = {
async
function
execute
(
psdFile
,
options
)
{
const
tree
=
await
getTree
(
psdFile
);
const
offset
=
options
?
options
.
offset
:
{
x
:
0
,
y
:
0
};
const
{
mode
=
'none'
,
singleView
=
true
}
=
options
;
let
offset
=
{
x
:
0
,
y
:
0
};
let
cutSize
=
{
x
:
0
,
y
:
0
};
if
(
mode
!==
'none'
)
{
cutSize
.
y
=
offsetAll
;
}
switch
(
mode
)
{
case
'top'
:
offset
.
y
=
offsetAll
;
break
;
case
'center'
:
offset
.
y
=
offsetAll
/
2
;
break
;
}
const
isCenter
=
mode
===
'center'
;
let
viewRoot
=
{
name
:
path
.
basename
(
psdFile
.
name
,
'.psd'
),
...
...
@@ -99,9 +116,9 @@ async function execute(psdFile, options) {
const
assets
=
[];
const
imageHashMap
=
{};
let
{
width
:
stageWidth
,
height
:
stageHeight
}
=
tree
;
stageWidth
-=
offset
.
x
||
0
;
stageHeight
-=
offset
.
y
||
0
;
let
{
width
:
stageWidth
Origin
,
height
:
stageHeightOrigin
}
=
tree
;
const
stageWidth
=
stageWidthOrigin
-
cutSize
.
x
||
0
;
const
stageHeight
=
stageHeightOrigin
-
cutSize
.
y
||
0
;
await
walkNode
(
tree
,
async
function
(
node
,
parent
)
{
let
{
name
}
=
node
;
...
...
@@ -116,15 +133,22 @@ async function execute(psdFile, options) {
},
className
:
""
};
const
isSecondLayer
=
!
parent
.
origin
.
parent
;
const
isSecondLayer
=
singleView
&&
!
parent
.
origin
.
parent
||
!
singleView
&&
parent
.
origin
.
parent
&&
!
parent
.
origin
.
parent
.
parent
;
const
shouldVerticalCenter
=
isSecondLayer
&&
isCenter
;
if
(
name
.
includes
(
'|'
))
{
if
(
name
.
includes
(
'|'
)
||
shouldVerticalCenter
)
{
try
{
let
arr
=
name
.
split
(
'|'
);
name
=
arr
[
0
];
let
paramsStr
=
arr
[
1
];
let
params
=
paramsStr
.
split
(
';'
);
let
relativePos
=
params
[
0
];
let
relativePos
;
if
(
paramsStr
){
let
params
=
paramsStr
.
split
(
';'
);
relativePos
=
params
[
0
];
}
else
if
(
shouldVerticalCenter
){
relativePos
=
'v'
;
}
if
(
relativePos
)
{
let
items
=
relativePos
.
split
(
','
);
for
(
let
item
of
items
)
{
...
...
@@ -148,16 +172,16 @@ async function execute(psdFile, options) {
value
=
y
-
offset
.
y
;
break
;
case
'r'
:
value
=
stageWidth
-
width
;
value
=
stageWidth
-
(
x
-
offset
.
x
)
-
width
;
break
;
case
'b'
:
value
=
stageHeight
-
height
;
value
=
stageHeight
-
(
y
-
offset
.
y
)
-
height
;
break
;
case
'h'
:
value
=
x
+
width
/
2
-
stageWidth
/
2
;
value
=
x
+
width
/
2
-
stageWidth
Origin
/
2
;
break
;
case
'v'
:
value
=
y
+
height
/
2
-
stageHeight
/
2
;
value
=
y
+
height
/
2
-
stageHeight
Origin
/
2
;
break
;
}
}
...
...
dist/index.js.map
View file @
e1de4f5d
This diff is collapsed.
Click to expand it.
dist/index.umd.js
View file @
e1de4f5d
...
...
@@ -88,7 +88,24 @@
async
function
execute
(
psdFile
,
options
)
{
const
tree
=
await
getTree
(
psdFile
);
const
offset
=
options
?
options
.
offset
:
{
x
:
0
,
y
:
0
};
const
{
mode
=
'none'
,
singleView
=
true
}
=
options
;
let
offset
=
{
x
:
0
,
y
:
0
};
let
cutSize
=
{
x
:
0
,
y
:
0
};
if
(
mode
!==
'none'
)
{
cutSize
.
y
=
offsetAll
;
}
switch
(
mode
)
{
case
'top'
:
offset
.
y
=
offsetAll
;
break
;
case
'center'
:
offset
.
y
=
offsetAll
/
2
;
break
;
}
const
isCenter
=
mode
===
'center'
;
let
viewRoot
=
{
name
:
path
.
basename
(
psdFile
.
name
,
'.psd'
),
...
...
@@ -99,9 +116,9 @@
const
assets
=
[];
const
imageHashMap
=
{};
let
{
width
:
stageWidth
,
height
:
stageHeight
}
=
tree
;
stageWidth
-=
offset
.
x
||
0
;
stageHeight
-=
offset
.
y
||
0
;
let
{
width
:
stageWidth
Origin
,
height
:
stageHeightOrigin
}
=
tree
;
const
stageWidth
=
stageWidthOrigin
-
cutSize
.
x
||
0
;
const
stageHeight
=
stageHeightOrigin
-
cutSize
.
y
||
0
;
await
walkNode
(
tree
,
async
function
(
node
,
parent
)
{
let
{
name
}
=
node
;
...
...
@@ -116,15 +133,22 @@
},
className
:
""
};
const
isSecondLayer
=
!
parent
.
origin
.
parent
;
const
isSecondLayer
=
singleView
&&
!
parent
.
origin
.
parent
||
!
singleView
&&
parent
.
origin
.
parent
&&
!
parent
.
origin
.
parent
.
parent
;
const
shouldVerticalCenter
=
isSecondLayer
&&
isCenter
;
if
(
name
.
includes
(
'|'
))
{
if
(
name
.
includes
(
'|'
)
||
shouldVerticalCenter
)
{
try
{
let
arr
=
name
.
split
(
'|'
);
name
=
arr
[
0
];
let
paramsStr
=
arr
[
1
];
let
params
=
paramsStr
.
split
(
';'
);
let
relativePos
=
params
[
0
];
let
relativePos
;
if
(
paramsStr
){
let
params
=
paramsStr
.
split
(
';'
);
relativePos
=
params
[
0
];
}
else
if
(
shouldVerticalCenter
){
relativePos
=
'v'
;
}
if
(
relativePos
)
{
let
items
=
relativePos
.
split
(
','
);
for
(
let
item
of
items
)
{
...
...
@@ -148,16 +172,16 @@
value
=
y
-
offset
.
y
;
break
;
case
'r'
:
value
=
stageWidth
-
width
;
value
=
stageWidth
-
(
x
-
offset
.
x
)
-
width
;
break
;
case
'b'
:
value
=
stageHeight
-
height
;
value
=
stageHeight
-
(
y
-
offset
.
y
)
-
height
;
break
;
case
'h'
:
value
=
x
+
width
/
2
-
stageWidth
/
2
;
value
=
x
+
width
/
2
-
stageWidth
Origin
/
2
;
break
;
case
'v'
:
value
=
y
+
height
/
2
-
stageHeight
/
2
;
value
=
y
+
height
/
2
-
stageHeight
Origin
/
2
;
break
;
}
}
...
...
dist/index.umd.js.map
View file @
e1de4f5d
This diff is collapsed.
Click to expand it.
src/zeroing.js
View file @
e1de4f5d
...
...
@@ -29,7 +29,24 @@ const relativePosPrefixMap = {
export
async
function
execute
(
psdFile
,
options
)
{
const
tree
=
await
getTree
(
psdFile
);
const
offset
=
options
?
options
.
offset
:
{
x
:
0
,
y
:
0
};
const
{
mode
=
'none'
,
singleView
=
true
}
=
options
;
let
offset
=
{
x
:
0
,
y
:
0
};
let
cutSize
=
{
x
:
0
,
y
:
0
};
if
(
mode
!==
'none'
)
{
cutSize
.
y
=
offsetAll
;
}
switch
(
mode
)
{
case
'top'
:
offset
.
y
=
offsetAll
;
break
;
case
'center'
:
offset
.
y
=
offsetAll
/
2
;
break
;
}
const
isCenter
=
mode
===
'center'
;
let
viewRoot
=
{
name
:
path
.
basename
(
psdFile
.
name
,
'.psd'
),
...
...
@@ -40,9 +57,9 @@ export async function execute(psdFile, options) {
const
assets
=
[];
const
imageHashMap
=
{};
let
{
width
:
stageWidth
,
height
:
stageHeight
}
=
tree
;
stageWidth
-=
offset
.
x
||
0
;
stageHeight
-=
offset
.
y
||
0
;
let
{
width
:
stageWidth
Origin
,
height
:
stageHeightOrigin
}
=
tree
;
const
stageWidth
=
stageWidthOrigin
-
cutSize
.
x
||
0
;
const
stageHeight
=
stageHeightOrigin
-
cutSize
.
y
||
0
;
await
walkNode
(
tree
,
async
function
(
node
,
parent
)
{
let
{
name
}
=
node
;
...
...
@@ -57,15 +74,24 @@ export async function execute(psdFile, options) {
},
className
:
""
};
const
isSecondLayer
=
!
parent
.
origin
.
parent
;
const
isSecondLayer
=
singleView
&&
!
parent
.
origin
.
parent
||
!
singleView
&&
parent
.
origin
.
parent
&&
!
parent
.
origin
.
parent
.
parent
;
const
shouldVerticalCenter
=
isSecondLayer
&&
isCenter
;
if
(
name
.
includes
(
'|'
))
{
const
{
width
:
parentWidth
,
height
:
parentHeight
}
=
parent
;
if
(
name
.
includes
(
'|'
)
||
shouldVerticalCenter
)
{
try
{
let
arr
=
name
.
split
(
'|'
);
name
=
arr
[
0
];
let
paramsStr
=
arr
[
1
];
let
params
=
paramsStr
.
split
(
';'
);
let
relativePos
=
params
[
0
];
let
relativePos
;
if
(
paramsStr
){
let
params
=
paramsStr
.
split
(
';'
);
relativePos
=
params
[
0
];
}
else
if
(
shouldVerticalCenter
){
relativePos
=
'v'
;
}
if
(
relativePos
)
{
let
items
=
relativePos
.
split
(
','
);
for
(
let
item
of
items
)
{
...
...
@@ -89,16 +115,16 @@ export async function execute(psdFile, options) {
value
=
y
-
offset
.
y
;
break
;
case
'r'
:
value
=
stageWidth
-
width
;
value
=
stageWidth
-
(
x
-
offset
.
x
)
-
width
;
break
;
case
'b'
:
value
=
stageHeight
-
height
;
value
=
stageHeight
-
(
y
-
offset
.
y
)
-
height
;
break
;
case
'h'
:
value
=
x
+
width
/
2
-
stageWidth
/
2
;
value
=
x
+
width
/
2
-
stageWidth
Origin
/
2
;
break
;
case
'v'
:
value
=
y
+
height
/
2
-
stageHeight
/
2
;
value
=
y
+
height
/
2
-
stageHeight
Origin
/
2
;
break
;
}
}
...
...
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