One of Xiaomi route research, add menu, Xiaomi route menu
OpenWRT: controller of Xiaomi router luci
There are many folders in the controller, and they all create corresponding trees independently:
Web: index.htm -- registered many branches under the web Tree node
Mobile: index -- some nodes under mbile are registered.
Dispatch :...
Api :...
Sevice :...
We can see from the original openWRT environment that we have learned that if we want to create an option on the web interface, we need to do a few basic steps:
1. register the node on the web interface displayed under the controller and the processing method when registering the node.
2. Compile the corresponding file according to the Processing Method
A. Compile the htm file in the view using the template method.
B. Use the cbi method to compile the corresponding files under the model.
C. call the corresponding functions under the controller (including the functions of some imported libraries)
When I write a lua file under my controller, if it is handled in call mode
Function or call the function in the import/export database.
Simple practice project: Add a menu option under Xiaomi route and perform corresponding processing
Backend processing: Registration Node
Register a node in the index. lua file under the controller.
-- Added by heyg: test htm
Entry ({"web", "testhyg"}, template ("web/heyg"), _ ("testhyg"), 74)
Frontend processing:
In the hosts file
Note the following:
....
<Div id = "nav">
<Script>
Var navCurrent = '. Manager ';
</Script>
<% Include ("web/inc/nav") %>
</Div>
....
Above. manager is very important. On the Xiaomi routing interface, in addition to registering nodes at the backend, it has done a lot of work in front-end: block id Association in layout and layout, at present, I have no specific knowledge about the front-end encoding of Xiaomi.
For example: <% include ("web/inc/nav") %> for observation, we also need to add a <li>... </li> to display on the menu, add the following content:
<Li class = "testhyg">
<A href = "<% = luci. dispatcher. build_url ("web", "testhyg") %> "> <I class =" ico ico-nav-4 "> </I> <span> testhyg </span> </a>
</Li>
The corresponding heyg.htm location should be changed to the following:
....
<Div id = "nav">
<Script>
Var navCurrent = '. testhyg ';
</Script>
<% Include ("web/inc/nav") %>
</Div>
....
After saving, you can display your menu on the Xiaomi menu .... in addition, some js and html in the menu, as well as the processing of embedded lua and C language, I am not very clear here, so there is no need to go into details.