luci界面实现web端和移动端的不同风格

luci界面开发中的web端和移动端

        为适应不同平台,针对web端和移动端,在不同平台的浏览器输入登录地址后,出现不同的登录界面。

实现步骤:
1.在/www/index.html里做出判断,是web端登录还是移动端登录。代码如下:



pragma" content="no-cache">

 
//引入必要的js文件

//引入用来判断平台的js文件



OPENWRT

 



2.在目录/www/cgi-bin里建立脚本文件 luci

3.在目录controller里建立admin_mobile目录,里面添加index.lua文件(luci开始时自动先到此文件里执行firstchild函数等),内容如下:
参考admin目录下的index.lua文件,做如下修改:

module("luci.controller.admin_mobile.index", package.seeall)

root.target = alias("admin_mobile")

local page   = node("admin_mobile")

page.sysauth_authenticator = "htmlauth_mobile"

    4.在luci目录下的dispatcher.lua里添加函数htmlauth_mobile,内容如下:
function authenticator.htmlauth_mobile(validator, accs, default)
local user = luci.http.formvalue("username")
local pass = luci.http.formvalue("password")

if user and validator(user, pass) then
return user
end

require("luci.i18n")
require("luci.template")
context.path = {}
luci.template.render("admin_mobile/sysauth", {duser=default, fuser=user})
return false

end


5.自定义lua及htm文件,实现相应的功能。







你可能感兴趣的:(OpenWrt)