OpenWrt超时检测

参考http://www.right.com.cn/forum/thread-261702-1-1.html

vim /home/ihid/chaos_calmer/feeds/luci/modules/luci-base/root/etc/config/luci

修改sessiontime为自定义数值:

config internal sauth
	option sessionpath "/tmp/luci-sessions"
	option sessiontime 3600

修改/home/ihid/chaos_calmer/feeds/luci/themes/luci-theme-violet/luasrc/view/themes/violet/header.htm文件(取决于你用的是哪个主题),在里面添加一个js函数解决问题 :

<script>
        var lastTime = new Date().getTime();
        var currentTime = new Date().getTime();
        var timeOut = 20 * 60 * 1000;

        window.onload=function (){
                window.document.onmousemove=function(){
                        lastTime = new Date().getTime();
                }
        };
        function testTime(){
                currentTime = new Date().getTime(); 
                if(currentTime - lastTime > timeOut){
                        console.log("TimeOut");
                        var tmp = 0;
                        document.onmousedown=function(event){ 
                                if (tmp == 0){
                                        alert("操作超时,请重新登录!");
                                        window.location.href="/cgi-bin/luci";
                                        tmp = 1;
                                }
                        }
                        document.onkeydown=function(event){
                                if (tmp == 0){
                                        alert("操作超时,请重新登录!");
                                        window.location.href="/cgi-bin/luci";
                                        tmp = 1;
                                }
                        }
                }
        }

        window.setInterval(testTime, 1000);
</script>
原文地址:https://www.cnblogs.com/ihid/p/9458541.html