OpenWrt的luci web管理器添加新菜单(二)

继上一篇:OpenWrt的luci web管理器添加新菜单

Call的方式:

在/usr/lib/lua/luci/controller/admin/new_tab.lua 文件中添加如下红色部分的内容:

— Copyright 2008 fulinux <fulinux@sina.com>– Licensed to the public under the Apache License 2.0.local fs = require "nixio.fs"module("luci.controller.admin.new_tab", package.seeall) –notice that new_tab is the name of the file new_tab.luafunction index() entry({"admin", "new_tab"}, firstchild(), "New tab", 30).dependent=false –this adds the top level tab and defaults to the entry({"admin", "new_tab", "tab_from_cbi"}, cbi("admin_myapp/cbi_tab"), "CBI Tab", 1) –this adds the first sub-tab that is entry({"admin", "new_tab", "tab_from_view"}, template("admin_myapp/view_tab"), "View Tab", 2) –this adds the second sub-ta entry({"admin", "new_tab", "action_counter"}, call("counter"), _("Click here"), 3).leaf = trueendfunction counter () local i = 0 if fs.access("/var/run/test") then i = tonumber((fs.readfile("/var/run/test"))) end i = i + 1 fs.writefile("/var/run/test", string.format("%d\n", i)) — luci.http.redirect(luci.dispatcher.build_url("admin/new_tab/tab_from_view")) luci.http.write(tostring(i)) returnend

这样你每次点击下面的菜单时都会跳转到一个页面显示你点击此菜单的次数:

版权声明:本文为博主原创文章,,未经博主允许不得转载。

想像力比知识更重要

OpenWrt的luci web管理器添加新菜单(二)

相关文章:

你感兴趣的文章:

标签云: