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

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

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

实现步骤:
1.在/www/index.html里做出判断,是web端登录还是移动端登录。代码如下:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"  xml:lang="zh-CN" lang="zh-CN">
<head>
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="Cache-Control" content="no-cache, must-revalidate">
<meta http-equiv="expires" content="Wed, 26 Feb 1997 08:21:57 GMT"> 
<script src="/turbo-static/turbo/web/js/jquery-1.8.1.min.js?v=986"></script> //引入必要的js文件
<script src="/turbo-static/turbo/web/js/jquery.cookie.min.js?v=986"></script>
<script src="/turbo-static/turbo/interface.js?v=986"></script> //引入用来判断平台的js文件

<script language="javascript" type="text/javascript">
format_is_mobile();
if(needJumpMobile()){
window.location.href="/cgi-bin/luci/admin_mobile"; //浏览器根据这里的url去走不同的路径,这里是/admon_mobile
  }
else {
window.location.href="/cgi-bin/luci"; //这里luci的开始路径是 /
}

</script>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>OPENWRT</title>
<noscript><meta http-equiv="refresh" content="0; url=/" /></noscript>
</head> 
<script type="text/javascript">

</script>
</html>

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文件,实现相应的功能。







  • 2
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值