One of Xiaomi route research, add menu, Xiaomi route menu

Source: Internet
Author: User

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.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.