A join menu in Xiaomi routing research

Source: Internet
Author: User

OpenWRT 's Xiaomi routing Luci Controller

There are a lot of directories under the controller , and they all build their own tree:

Web:index.htm-- The very many branches under the Web tree node

Mobile:Index-- a note on Some of the nodes under mbile

Dispatch: ...

Api: ...

Sevice: ...

According to our former native OpenWRT environment can be learned. Suppose we want to Create an option in the Web interface. We need to do a few major steps:

1. The Web Interface Registration node displayed under controller , and the processing mode when the Register node is registered.

2, according to the processing method to write the corresponding documents

A,template Way to write an htm file under view

B,CBI way to write the corresponding documents under model

C, call mode calls The corresponding function under the controller (contains some imported library functions)

Normally when I write a lua file under my controller , it is assumed that the call method is processed, and the

function or call a function in the import library.

Simple Combat Project: Add a menu option under Xiaomi Routing and do the corresponding processing

Back-end Processing: Register node

In the index.lua file under controller under the Web , We register a node.

--added by Heyg:test htm

Entry ({"Web", "Testhyg"}, Template ("Web/heyg"), _ ("Testhyg"), 74)

Front-end Processing:

Write the heyg.htm file under view , because some js and htm about the front end Language is not very familiar with me here directly copy the contents of the manager.htm file into the heyg.htm file

Note the following about the htm file place :

....

<div id= "NAV" >

<script>

var navcurrent = '. Manager ';

</script>

<%include ("Web/inc/nav")%>

</div>

....

The . Manager above is very important, in the Xiaomi routing interface, in the back end of the register node, in front: layout, layout, block ID Association, etc., have done a lot of processing, At the moment I do not have a detailed understanding of the Xiaomi front-end coding.

such as : <%include ("Web/inc/nav")%> Observation, we also need to Add a <li in web/inc/nav.htm >...</li> to display on the menu, add content such as the following:

<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 location of the heyg.htm should be changed to the following:

....

<div id= "NAV" >

<script>

var navcurrent = '. Testhyg ';

</script>

<%include ("Web/inc/nav")%>

</div>

....

After the save is complete. I can show my menu on the Xiaomi menu ... . Some of the menus in the spare JS and the HTML and Embedding Lua Language and C language Processing, I am not very clear here, there is no redundant to repeat.

A join menu in Xiaomi routing research

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.