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
3fb87894
Commit
3fb87894
authored
Jan 06, 2022
by
zhangtingting
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修改lineHeight设置
parent
046c83ff
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
25 additions
and
24 deletions
+25
-24
package.json
package.json
+18
-18
compilelocal.js
src/compilelocal.js
+4
-3
index.js
test/index.js
+3
-3
No files found.
package.json
View file @
3fb87894
{
{
"name"
:
"psd-parse-web"
,
"name"
:
"psd-parse-web"
,
"version"
:
"2.1.7
"
,
"version"
:
"2.1.8
"
,
"main"
:
"src/index.js"
,
"main"
:
"src/index.js"
,
"module"
:
"dist/index.es.js"
,
"module"
:
"dist/index.es.js"
,
"license"
:
"
MIT
"
,
"license"
:
"
MIT
"
,
...
...
src/compilelocal.js
View file @
3fb87894
...
@@ -125,9 +125,10 @@ async function compilePsdToJson(psdFile, options) {
...
@@ -125,9 +125,10 @@ async function compilePsdToJson(psdFile, options) {
properties
.
style
.
fontSize
=
parseInt
(
fsize
);
//字体取整
properties
.
style
.
fontSize
=
parseInt
(
fsize
);
//字体取整
//字体取整情况下有可能导致宽度不够,默认扩大10像素
//字体取整情况下有可能导致宽度不够,默认扩大10像素
viewNode
.
properties
.
style
.
width
+=
10
;
viewNode
.
properties
.
style
.
width
+=
10
;
viewNode
.
properties
.
style
.
lineHeight
=
`
${
height
}
`
;
if
((
height
/
fsize
)
<
2
){
//超过两行不设置行高
viewNode
.
properties
.
style
.
lineHeight
=
`
${
height
}
`
;
}
let
[
r
,
g
,
b
,
a
]
=
colors
[
0
];
let
[
r
,
g
,
b
,
a
]
=
colors
[
0
];
properties
.
style
.
color
=
`rgba(
${
r
}
,
${
g
}
,
${
b
}
,
${
a
/
255
}
)`
;
properties
.
style
.
color
=
`rgba(
${
r
}
,
${
g
}
,
${
b
}
,
${
a
/
255
}
)`
;
...
...
test/index.js
View file @
3fb87894
var
{
execute
}
=
require
(
'../src/index'
);
var
{
execute
,
compilePsdToJson
}
=
require
(
'../src/index'
);
let
test
=
async
()
=>
{
let
test
=
async
()
=>
{
let
result
=
await
execute
(
'/Users/
davezh/Downloads/1.psd'
,{
mode
:
'none'
,
singleView
:
true
})
let
result
=
await
execute
(
'/Users/
tiffany/Downloads/1.psd'
,{
mode
:
'none'
,
projectPath
:
'/Users/tiffany/Downloads/test/'
,
singleView
:
true
})
console
.
log
(
"---------"
);
console
.
log
(
"---------"
);
console
.
log
(
result
);
// await compilePsdToJson('/Users/tiffany/Downloads/1.psd', { mode: 'none', singleView: true, assetsPath: '/Users/tiffany/Downloads/test/' }
);
}
}
test
();
test
();
\ No newline at end of file
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