帶着這些問題,來閱讀本文吧
https://imgcook.taobao.org/
因爲我這裏負責的業務比較核心敏感,就拿官方案例的Skecth文件來作示例
{"type":"Block","id":"Block_1","__VERSION__":"2.0","props":{"style":{"width":750,"height":348},"attrs":{"x":0,"y":0}},"children":[{"__VERSION__":"2.0","props":{"style":{"width":750,"height":348,"backgroundColor":"rgba(255,255,255,1)","overflow":"hidden"},"attrs":{"x":0,"y":0}},"selfId":"70CC9868-1AC8-486E-84E3-75887F3A10A6","children":[],"nodeLayerName":"Rectangle","type":"Shape","id":"Shape_0"},{"__VERSION__":"2.0","props":{"style":{"width":364,"height":80,"color":"rgba(153, 153, 153, 1)","fontFamily":"PingFang SC","fontSize":26,"fontWeight":300,"lineHeight":40,"opacity":1},"attrs":{"x":354,"y":88,"text":"畫面清晰流暢,佩戴溫馨且操做簡便,能給你優質使用體驗","lines":2}},"selfId":"25E60004-A8C6-4691-81A3-CDA67EEF76D70","nodeLayerName":"畫面清晰流暢,佩戴溫馨且操做簡便,能給你","type":"Text","id":"Text_1_0"},{"__VERSION__":"2.0","props":{"style":{"width":39,"height":28,"color":"rgba(34, 170, 255, 1)","fontFamily":"PingFang SC","fontSize":24,"fontWeight":400,"lineHeight":28,"opacity":1},"attrs":{"x":687,"y":284,"text":"152","lines":1}},"selfId":"4BD9A28A-CCE8-4E25-9051-77FDEB978EFD0","nodeLayerName":"152","type":"Text","id":"Text_2_0"},{"__VERSION__":"2.0","props":{"style":{"width":36,"height":36},"attrs":{"x":642,"y":280,"source":"https://ai-sample.oss-cn-hangzhou.aliyuncs.com/test/4543191097ed11eaab429db2572494df.png","originStyles":{"backgroundColor":"rgba(34,170,255,1)"}}},"selfId":"07F98BC9-BC4E-473C-B20F-20380FBCA7B5","children":[],"nodeLayerName":"Combined Shape","type":"Image","id":"Image_3"},{"__VERSION__":"2.0","props":{"style":{"width":288,"height":34,"color":"rgba(51, 51, 51, 1)","fontFamily":"PingFang SC","fontSize":30,"fontWeight":600,"lineHeight":34,"opacity":1},"attrs":{"x":354,"y":40,"text":"惠普MR混合現實眼鏡","lines":1}},"selfId":"1CC6F0E4-0531-4836-8857-D4DF39FC8CA50","nodeLayerName":"惠普MR混合現實眼鏡","type":"Text","id":"Text_4_0"},{"__VERSION__":"2.0","props":{"style":{"width":300,"height":300,"overflow":"hidden"},"attrs":{"x":24,"y":24,"source":"https://ai-sample.oss-cn-hangzhou.aliyuncs.com/test/45c2f77097ed11ea9ffb4d12d04995ca.png","originStyles":{"backgroundColor":"rgba(0,0,0,0.02)","borderTopLeftRadius":12,"borderTopRightRadius":12,"borderBottomRightRadius":12,"borderBottomLeftRadius":12}}},"selfId":"20DE93EB-3C70-4903-AA0E-5474EEA9E014","children":[],"nodeLayerName":"Rectangle 2 Copy","type":"Image","id":"Image_5"},{"__VERSION__":"2.0","props":{"style":{"width":300,"height":300},"attrs":{"x":24,"y":24,"source":"https://ai-sample.oss-cn-hangzhou.aliyuncs.com/test/4764c09097ed11ea8f4f8bb23c14090e.png"}},"selfId":"281A54D6-33E9-4186-8A4E-313B1D2FCCC9","children":[],"nodeLayerName":"Bitmap","type":"Image","id":"Image_6"}],"layerProtocols":[],"artboardImg":"https://ai-sample.oss-cn-hangzhou.aliyuncs.com/test/44c584a097ed11ea84362f052c062532.png","taskId":"445C667DA4BE50E086C299DD221AA5F6-1589685595582","name":"Group 8 Copy 23","pluginVersion":"2.2.0","reference":"sketch"}
這個須要先本身建立對應的組織和項目才能保存
'use strict'; import React, { Component } from 'react'; import styles from './style.js'; class Block_0 extends Component { render() { return ( <div style={styles.mod}> <div style={styles.box}> <img style={styles.primary} onClick={(e) => { console.log('onclick'); }} src={'https://ai-sample.oss-cn-hangzhou.aliyuncs.com/test/7aa1833097ed11eaaa44854a54132a4d.png'} /> <div style={styles.side}> <span style={styles.title} lines={undefined}> 惠普MR混合現實眼鏡 </span> <span style={styles.summary} lines={undefined}> 畫面清晰流暢,佩戴溫馨且操做簡便,能給你優質使用體驗 </span> <div style={styles.wrap}> <img style={styles.icon} src={'https://ai-sample.oss-cn-hangzhou.aliyuncs.com/test/784ff21097ed11ea9ffb4d12d04995ca.png'} /> <span style={styles.num} lines={undefined}> 152 </span> </div> </div> </div> </div> ); } } export default Block_0;
export default { mod: { width: '750px', height: '348px' }, box: { display: 'flex', alignItems: 'flex-start', flexDirection: 'row', justifyContent: 'center', backgroundColor: '#ffffff', width: '750px', height: '348px', overflow: 'hidden', }, primary: { marginTop: '24px', marginRight: '30px', width: '300px', height: '300px' }, side: { display: 'flex', alignItems: 'flex-start', flexDirection: 'column', marginTop: '40px', height: '276px' }, title: { position: 'relative', opacity: 1, maxWidth: '384px', height: '34px', overflow: 'hidden', textOverflow: 'ellipsis', lineHeight: '34px', whiteSpace: 'nowrap', color: '#333333', fontSize: '30px', fontWeight: 600, }, summary: { WebkitLineClamp: '2px', position: 'relative', opacity: 1, marginTop: '14px', width: '364px', height: '80px', overflow: 'hidden', textOverflow: 'ellipsis', lineHeight: '40px', color: '#999999', fontSize: '26px', fontWeight: 300, }, wrap: { display: 'flex', position: 'relative', alignItems: 'center', alignSelf: 'flex-end', flexDirection: 'row', marginTop: '112px', width: '84px', height: '36px', }, icon: { marginRight: '9px', width: '36px', height: '36px' }, num: { opacity: 1, lineHeight: '28px', whiteSpace: 'nowrap', color: '#22aaff', fontSize: '24px', fontWeight: 400 }, };
https://github.com/alibaba/pipcook
本文使用 mdnice 排版前端