search

Home  >  Q&A  >  body text

javascript - Various design discussions on the interface main menu generation logic

The main menu is the kind of background management system in which you can control whether to display a certain menu or a certain function in a certain menu through configuration.
Regarding its design and implementation, my personal summary is as follows.

(1)Save with database table
Generally, the main menu is a tree structure, and there are two solutions based on traditional relational databases.

There are also two data transfer schemes:

(2)Save with json
This is the way I mainly want to know about this problem. I don’t know if you have used it before. Then directly build the parent and child node information of the main menu into json format. Save it to a configuration table or a json file. This saves you the trouble of constructing a tree structure. However, since it is a pure json format, manual maintenance is okay if the data structure is not complex. If you encounter a complex situation, you may need to write a maintenance interface to maintain it. At this time, since json does not have a query syntax similar to sql, the front end (Assuming it is js) It will be particularly complicated to write additions, deletions and check modifications (especially deletions).

this. . . . I don’t know what method you usually use? If possible, I hope you can briefly talk about it.
At the same time, if you have any opinions on (2) using json to save , you can also talk about it.
Comprehensively consider performance, scalability, maintainability, etc.

大家讲道理大家讲道理2756 days ago736

reply all(1)I'll reply

  • 曾经蜡笔没有小新

    曾经蜡笔没有小新2017-06-26 10:51:08

    The solution should be chosen based on technology. As for the two solutions you gave, the first one is more suitable for relational database implementation, and the second one is more suitable for NoSQL database implementation.

    In summary, the first solution is recommended. Flattening the menu structure will be more convenient when designing users, user groups, permissions and other modules later. Using JSON solutions to perform these operations will be more complicated.

    reply
    0
  • Cancelreply