palxiao / poster-design

一款漂亮且功能强大的在线海报设计器,图片编辑器,仿稿定设计,适用于多种场景:海报生成、电商产品图、文章长图、视频/公众号封面等。A beautiful online image designer, suitable for various scenarios like generate posters, making design easier!
https://design.palxp.cn
MIT License
3.78k stars 588 forks source link

Question: Regarding the use of personal templates #127

Open ashleyyy94 opened 7 months ago

ashleyyy94 commented 7 months ago

Hi there, first of all thank you for this awesome project! I'm interested in adding my own templates to edit as a base. However, I realise it is not just about uploading a cover image to start editing.

When clicking on a template to start editing, the response from the API call contains id, cover, title, width, height etc. What I'm interested in is the "data" key. What is the data structure, or how do you set the values for this "data" attribute in order to get the template editing working?

Thank you very much :)

palxiao commented 7 months ago

Hello, thank you for liking! This project is planned to be updated for a long time, welcome to add star 😁

As for the problem you mentioned, this data structure is mainly processed and applied in the front end. For the API, it is just a serialized JSON data, which is saved to the server after being generated in the front end.

The specific data structure can be viewed in the src/store/widget of the code, they create by Pinia, like this:

image

So add a template just save those data (created on the front end) to the server.

There have been some changes in the data structure to support the cause of "multi artboards". I just recently drew a graph, it should be able to help you better understand:

image

Currently, both data structures are compatible. certainly, they both processed on the front end.