后台管理页面的JS文件
2023-12-28 11:11:13
<body>
<div id="top-wrap"><iframe src="{$Url}AdminTop" name="header" target="menu" scrolling="no" frameborder="0"></iframe></div>
<div id="header">
<div class="con">
<div class="left">
欢迎登录<span class="WebName"><a href="{$Group}/Config/basic" target="main">{$WebName}</a></span>管理后台!
<eq name="AppDebug" value="1">
<a class="debug" title="网站正式发布后,请关闭调试模式!" href="{$Group}/Config/basic" target="main">调试模式</a>
</eq>
</div>
<div class="right">
<ul class="headerlist">
<li><a class="title" href="{$WebInstallDir}" target="_blank"><i class="ydimg-home"></i>网站首页</a></li>
<li><a class="title" href="{$Group}/Decoration/index" target="_blank"><i class="ydicon-zhuangxiu"></i>模板装修</a></li>
<li><a class="title" onclick="checkUpgrade(false)" target="_self"><i class="ydicon-update"></i>检查更新</a></li>
<li><a class="title" href="{$Group}/Public/ClearCache" target="main"><i class="ydimg-cache"></i>缓存管理</a></li>
<empty name="IsOem">
<li style="width: 120px;">
<a class="title"><i class="ydimg-support"></i>技术支持<i class="ydimg-bottom"></i></a>
<div class="list">
<a href="" target="_blank">帮助手册</a>
<a href="" target="_blank">二次开发手册</a>
<a href="" target="_blank">高级装修手册</a>
<a href="" target="_blank">多端小程序手册</a>
<a href="" target="_blank">官方网站</a>
</div>
</li>
</empty>
<notempty name="Language">
<li style="width: 120px;">
<a class="title" href="{$Group}/Config/language" target="main">
<i class="ydimg-lang"></i>语言切换<i class="ydimg-bottom"></i>
</a>
<div id="language" class="list">
<volist name="Language" id="l">
<a <eq name="l.LanguageMark" value="$AdminLanguageMark">class="active"</eq> οnclick="ChangeLng(this,'{$l.LanguageMark}','{$Url}','lng{$l.LanguageID}')" target="main">
<img src="{$WebPublic}Images/mark/{$l.LanguageMark}.png" />
{$l.LanguageName}</a>
</volist>
<a href="{$Group}/Language/index" target="main"><span class="add-language">+ 添加网站语言<span></a>
</div>
</li>
</notempty>
<li><a class="title" href="{$Group}/Config/theme" target="main"><i class="ydimg-theme"></i>主题颜色</a></li>
<li class="admin" style="width: 190px;">
<a class="title">
<notempty name="MemberAvatar">
<img class="avatar" src="{$MemberAvatar}" />
<else />
<img class="avatar" src="{$Images}defaultavatar.png">
</notempty>
<span class="AdminName">{$AdminName}</span><br/>
<span class="AdminGroupName">{$AdminGroupName}</span>
<i class="ydimg-bottom"></i>
</a>
<div class="list">
<a href="{$Group}/member/Modify/MemberID/{$Think.session.AdminMemberID}" target="main">个人信息</a>
<a href="{$Url}pwd" target='main'>修改密码</a>
<a href="{$Url}logout" target="_top">安全退出</a>
</div>
</li>
</ul>
</div>
</div>
</div>
<div id="menu-wrap"><iframe src="{$Url}AdminLeft/MenuTopID/{$MenuTopID}" id="menu" name="menu" target="main" scrolling="no" frameborder="0"></iframe></div>
<div id="main-wrap"><iframe src="{$Url}Welcome" id="main" name="main" frameborder="0" scrolling="yes"></iframe></div>
<empty name="IsOem">
</empty>
</body>
<script type="text/javascript">
var gUpgradeUrl = "{$Url}upgrade?debug=1"; //升级接口地址
var gTimeout = 180*1000; //超时时间
var gNewVersion = ""; //当前新版本号
var gReleaseDate = ""; //发布日期
var gIsUpgrading = false; //是否正在升级
var gIsReUpgrade = 0; //是否强制升级
//检测升级
function checkUpgrade(isAutoCheck){
if(checkSafeQuestion()) return;
gIsUpgrading = false;
gNewVersion = "";
gReleaseDate = "";
clearTip();
var url = "{$Url}checkUpgrade?debug=1";
$.get(url, null, function(data){
var ver = (data.data && data.data.version) || "";
gNewVersion = ver;
if (data.status == 1){
gReleaseDate = data.data.date;
openUpgradeDlg("发现新版本 v"+ver, data.data.description, 1);
}else{
if(isAutoCheck){
console.log("升级检测失败:"+data.info);
}else{
var des = "<span class='des' style='color:red;'>";
des += "<img src='{$Images}artdialog/warning.png' />"+data.info+"</span>";
openUpgradeDlg("检查新版本", des, 2);
}
}
}, "json");
}
//打开升级对话框 mode=1 显示升级和取消,2:显示我知道了
function openUpgradeDlg(title, des, mode){
$(".upgrade_title").text(title);
$(".upgrade_body").html(des);
var dlgWidth = 450;
var winWidth = parseInt( $(window).width() );
var offsetX = (winWidth-dlgWidth)/2;
$(".dlg_upgrade").css({
"top": "25%",
"left": offsetX+"px",
"width": dlgWidth+"px"
});
if(mode == 1){
$(".btnKnow").hide();
$(".btnUpgrade").show();
$(".btnReUpgrade").hide();
$(".btnCancel").show();
}else{ //仅提示
$(".btnKnow").show();
$(".btnUpgrade").hide();
$(".btnCancel").hide();
$(".btnReUpgrade").show();
$(".btnReUpgrade").removeClass("disabled");
$(".btnReUpgrade").attr('disabled', false);
$(".btnReUpgrade").val("重新升级");
}
$(".dlg_upgrade").show();
}
//关闭升级对话框
function closeUpgradeDlg(){
gIsUpgrading = false;
$(".dlg_upgrade").hide();
}
//第1步:下载升级文件
function downloadFile(){
if(!gIsUpgrading) return;
clearTip();
showTip("开始升级");
var params = {
"Step":1,
"Version":gNewVersion,
"random":new Date().getTime(),
"IsReUpgrade":gIsReUpgrade
};
$.ajax({url: gUpgradeUrl, type: "POST", timeout: gTimeout, data: params, dataType:"json",
success: function(data){
if (data.status == 1){
showTip(data.info);
unzipFile(data.data);
}else{
showError(data.info);
}
},
error:function errorCallback(obj, textStatus, errorThrown){
var errmsg = (textStatus == "timeout") ? "下载升级包超时" :"发生错误 "+obj.statusText;
showError(errmsg);
}
});
}
//第2步:解压升级包
function unzipFile(data){
if(!gIsUpgrading) return;
var params = {
"Step":2,
"ZipFile":data['ZipFile'],
"random":new Date().getTime(),
"Version":gNewVersion,
"IsReUpgrade":gIsReUpgrade
};
$.ajax({url: gUpgradeUrl, type: "POST", timeout: gTimeout, data: params, dataType:"json",
success: function(data){
if (data.status == 1){
showTip(data.info);
upgradeDb(data.data);
}else{
showError(data.info);
}
},
error:function errorCallback(obj, textStatus, errorThrown){
var errmsg = (textStatus == "timeout") ? "解压升级包超时" :"发生错误 "+obj.statusText;
showError(errmsg);
}
});
}
//第3步:升级数据库
function upgradeDb(data){
if(!gIsUpgrading) return;
var params = {
"Step":3,
"Version":gNewVersion,
"ReleaseDate":gReleaseDate,
"IsReUpgrade":gIsReUpgrade,
"random":new Date().getTime()
};
$.ajax({url: gUpgradeUrl, type: "POST", timeout: gTimeout, data: params, dataType:"json",
success: function(data){
if (data.status == 1){
showTip(data.info);
showTip("恭喜,升级完成!");
$(".upgrade-loading").hide();
$(".btnKnow").show();
$(".btnUpgrade").hide();
$(".btnReUpgrade").hide();
$(".btnCancel").hide();
}else{
showError(data.info);
}
},
error:function errorCallback(obj, textStatus, errorThrown){
var errmsg = (textStatus == "timeout") ? "升级数据库超时" :"发生错误 "+obj.statusText;
showError(errmsg);
}
});
}
function getTipPrefix(){
var myDate = new Date();
var hour = myDate.getHours(); //获取时,
var min = myDate.getMinutes(); //分
var second = myDate.getSeconds(); //秒
if(second<10) second = "0"+second;
var prefix = "· "+hour+":"+min+":"+second+" ";
return prefix;
}
//停止升级
function stopUpgrade(){
gIsUpgrading = false;
$(".upgrade-loading").hide();
$(".btnUpgrade").removeClass("disabled");
$(".btnUpgrade").attr('disabled', false);
$(".btnUpgrade").val("一键升级");
$(".btnReUpgrade").removeClass("disabled");
$(".btnReUpgrade").attr('disabled', false);
$(".btnReUpgrade").val("重新升级");
}
//升级提示
function showTip(html){
if(!html) return;
var prefix = getTipPrefix();
html = "<div class='item'>"+prefix+html+"</div>";
$(".upgrade_tip").append(html);
}
//清空所有升级提示
function clearTip(){
$(".upgrade_tip").html("");
}
//显示升级错误
function showError(message){
var prefix = getTipPrefix();
html = "<div class='item'>"+prefix+"<span style='color:red;'>"+message+"</span></div>";
$(".upgrade_tip").append(html);
stopUpgrade();
}
$(document).ready(function(){
$('.headerlist li').mouseenter(function(){
$(this).find('.list').show();
})
$('.headerlist li').mouseleave(function(){
$(this).find('.list').hide();
})
//取消升级
$(".btnCancel").click(function(){
closeUpgradeDlg();
});
//我知道了
$(".btnKnow").click(function(){
closeUpgradeDlg();
});
//立即升级
$(".btnUpgrade").click(function(){
$(".upgrade-loading").show();
$(".btnUpgrade").attr('disabled',true);
$(".btnUpgrade").addClass("disabled");
$(".btnUpgrade").val("升级中,请稍后...");
gIsUpgrading = true;
gIsReUpgrade = 0;
downloadFile(); //下载升级文件
});
//强制升级
$(".btnReUpgrade").click(function(){
$(".upgrade-loading").show();
$(".btnReUpgrade").attr('disabled',true);
$(".btnReUpgrade").addClass("disabled");
$(".btnReUpgrade").val("升级中,请稍后...");
gIsUpgrading = true;
gIsReUpgrade = 1;
downloadFile(); //下载升级文件
});
//是否自动检测更新
var checkUpdate = "{$CheckUpdate}";
if(1==checkUpdate) checkUpgrade(true);
});
</script>
文章来源:https://blog.csdn.net/withkai44/article/details/135260149
本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。 如若内容造成侵权/违法违规/事实不符,请联系我的编程经验分享网邮箱:veading@qq.com进行投诉反馈,一经查实,立即删除!
本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。 如若内容造成侵权/违法违规/事实不符,请联系我的编程经验分享网邮箱:veading@qq.com进行投诉反馈,一经查实,立即删除!