This thematic directory – more every Monday
- The outline
- Front and rear end construction
- Add, delete, change, check, package and embed basic modules
- Interface add, delete, modify, and check
- Image upload with static resources
- Permission login interception
- Editing system development
- The layers panel
- Layer editing system
- Overall zooming in and out with canvas and coordinate axes
- Edit record and move collision auxiliary line algorithm
Technology stack
- React – ANTD – Pro – Front page directly built
- React-dnd – Drag-and-drop library, simple and powerful API
- Koa.js – Background building
- Mysql – Data store
- Sequelize – a Promise-based Node.js ORM
- Typescript – Type definitions
Environment to prepare
- Redis download
- Mysql download
What you need to know about writing the back end
- The transaction
- Restful specification
Back-end service table design
Navicat download
The front end design
- Processon provides free online mapping and real-time collaboration
- Ink knife prototype drawing
The difficulties in
- Customize the alignment of drag and drop layouts
- Collision detection
- Dynamic programming – Optimal binary search tree
- Complexity analysis
- After the whole material is packaged, the output bundle file is embedded into a third party
Front-end editor implementation
The implementation idea of the editor is as follows: the editor generates JSON data of the page, the server is responsible for accessing JSON data and generating the corresponding template file.jsx, and the data JSON is taken from the server to the front-end template.jsx for processing during rendering.
The page data structure that is finally stored in the database
interface INode {
type: string props: { style: CSS.Properties; // Space spacing applied to the "top layer of the component" style list className: string; [key: string]: any; } children: INode[] | null }Copy the code
Front-end project processing: Store Map unidirectional linked list and flatten it Map
interface INode {
id:string
type: string canDrag: Boolean // Whether absolute supports drag and drop display: Boolean // Whether to render on canvas props: {style: css.properties; // Space spacing applied to the "top layer of the component" style list className: string; [key: string]: any; } children: string[] | null }Copy the code
The core code
Editor core code, by obtaining JSON on the corresponding componentName load corresponding components
import React from 'react';
import { PhotoStory, VideoStory } from './stories';
const components = {
photo: PhotoStory,
video: VideoStory
};
function Story(props) {
const SpecificStory = components[props.storyType];
return <SpecificStory story={props.story} />;
}
Copy the code
Ask for a thumbs-up ❤️
Welcome to like + pay attention to !!!! Ink ❤ ️