update
This commit is contained in:
@@ -0,0 +1,53 @@
|
||||
const menu = [{
|
||||
"name": "首页",
|
||||
"icon": "",
|
||||
"url": "index.html",
|
||||
"hidden": false,
|
||||
"list": []
|
||||
}, {
|
||||
"name": "系统设置",
|
||||
"icon": "",
|
||||
"url": "",
|
||||
"hidden": false,
|
||||
"list": [{
|
||||
"name": "全局head",
|
||||
"url": "/web/index.html"
|
||||
}, {
|
||||
"name": "友情连接",
|
||||
"url": "/web/link.html"
|
||||
},{
|
||||
"name": "全局顶部",
|
||||
"url": "/web/header.html"
|
||||
}, {
|
||||
"name": "导航管理",
|
||||
"url": "/web/nav.html"
|
||||
}, {
|
||||
"name": "全局底部",
|
||||
"url": "/web/footer.html"
|
||||
}, {
|
||||
"name": "清除缓存",
|
||||
"url": "/index/web_cache.html"
|
||||
}, {
|
||||
"name": "文件管理",
|
||||
"url": "/file/index.html"
|
||||
}]
|
||||
}, {
|
||||
"name": "退出登录",
|
||||
"icon": "",
|
||||
"url": "/index/out.html",
|
||||
"list": []
|
||||
}];
|
||||
|
||||
const config = {
|
||||
name: "Tool",
|
||||
menu: menu,
|
||||
version: 'v1.6',
|
||||
official:'/'
|
||||
};
|
||||
|
||||
try {
|
||||
module.exports.name = "Tool";
|
||||
module.exports.menu = menu;
|
||||
}catch (e){
|
||||
|
||||
}
|
||||
@@ -0,0 +1,191 @@
|
||||
|
||||
layui.use('form', function () {
|
||||
var form = layui.form,
|
||||
layer = layui.layer;
|
||||
});
|
||||
|
||||
var vue = new Vue({
|
||||
el:'#app',
|
||||
data:{
|
||||
webname:config.name,
|
||||
menu:[],
|
||||
address:[]
|
||||
},
|
||||
created:function(){
|
||||
this.menu = config.menu;
|
||||
this.thisActive();
|
||||
this.thisAttr();
|
||||
},
|
||||
methods:{
|
||||
//记住收展
|
||||
onActive:function (pid,id=false) {
|
||||
let data;
|
||||
if(id===false){
|
||||
data = this.menu[pid];
|
||||
if(data.url.length>0){
|
||||
this.menu.forEach((v,k)=>{
|
||||
v.active = false;
|
||||
v.list.forEach((v2,k2)=>{
|
||||
v2.active = false;
|
||||
})
|
||||
})
|
||||
data.active = true;
|
||||
}
|
||||
data.hidden = !data.hidden;
|
||||
}else{
|
||||
this.menu.forEach((v,k)=>{
|
||||
v.active = false;
|
||||
v.list.forEach((v2,k2)=>{
|
||||
v2.active = false;
|
||||
})
|
||||
})
|
||||
data = this.menu[pid].list[id];
|
||||
}
|
||||
|
||||
this.updateStorage();
|
||||
if(data.url.length>0){
|
||||
if(data.target){
|
||||
if(data.target=='_blank'){
|
||||
window.open(data.url);
|
||||
}else{
|
||||
window.location.href = data.url;
|
||||
}
|
||||
}else{
|
||||
window.location.href = data.url;
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
//更新菜单缓存
|
||||
updateStorage(){
|
||||
sessionStorage.menu = JSON.stringify(this.menu);
|
||||
},
|
||||
//菜单高亮
|
||||
thisActive:function(){
|
||||
let pathname = window.location.pathname;
|
||||
let host = window.location.host;
|
||||
let pid = false;
|
||||
let id = false;
|
||||
this.menu.forEach((v,k)=>{
|
||||
let url = v.url;
|
||||
if(url.length>0){
|
||||
if(url[0]!='/' && url.substr(0,4)!='Net'){
|
||||
url = '/'+url;
|
||||
}
|
||||
}
|
||||
if(pathname==url){
|
||||
pid = k;
|
||||
}
|
||||
v.list.forEach((v2,k2)=>{
|
||||
let url = v2.url;
|
||||
|
||||
if(url.length>0){
|
||||
if(url[0]!='/' && url.substr(0,4)!='Net'){
|
||||
url = '/'+url;
|
||||
}
|
||||
}
|
||||
if(pathname==url){
|
||||
pid = k;
|
||||
id = k2;
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
|
||||
if(id!==false){
|
||||
this.menu[pid].list[id].active = true;
|
||||
}else{
|
||||
if(pid!==false){
|
||||
this.menu[pid].active = true;
|
||||
}
|
||||
}
|
||||
|
||||
this.updateStorage();
|
||||
|
||||
},
|
||||
//当前位置
|
||||
thisAttr:function () {
|
||||
//当前位置
|
||||
let address = [{
|
||||
name:'首页',
|
||||
url:'index.html'
|
||||
}];
|
||||
this.menu.forEach((v,k)=>{
|
||||
v.list.forEach((v2,k2)=>{
|
||||
if(v2.active){
|
||||
address.push({
|
||||
name:v.name,
|
||||
url:'javascript:;'
|
||||
})
|
||||
address.push({
|
||||
name:v2.name,
|
||||
url:v2.url,
|
||||
})
|
||||
this.address = address;
|
||||
}
|
||||
})
|
||||
})
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
$(document).ready(function() {
|
||||
//删除
|
||||
$(".del").click(function () {
|
||||
var url = $(this).attr("href");
|
||||
var id = $(this).attr("data-id");
|
||||
|
||||
layer.confirm('你确定要删除么?', {
|
||||
btn: ['确定', '取消']
|
||||
}, function () {
|
||||
$.get(url, function (data) {
|
||||
if (data.code == 1) {
|
||||
$(id).fadeOut();
|
||||
layer.msg(data.msg, {icon: 1});
|
||||
} else {
|
||||
layer.msg(data.msg, {icon: 2});
|
||||
}
|
||||
});
|
||||
}, function () {
|
||||
layer.msg("您取消了删除!");
|
||||
});
|
||||
return false;
|
||||
});
|
||||
})
|
||||
|
||||
function delCache(){
|
||||
sessionStorage.clear();
|
||||
localStorage.clear();
|
||||
}
|
||||
|
||||
function msg(code=1,msg='',url='',s=3) {
|
||||
if(typeof code == 'object') {
|
||||
msg = code.msg;
|
||||
url = code.url || '';
|
||||
s = code.s || 3;
|
||||
code = code.code;
|
||||
}
|
||||
code = code==1 ? 1 : 2;
|
||||
layer.msg(msg, {icon: code,offset: 't',shade: [0.4, '#000']});
|
||||
if(url!=''){
|
||||
setTimeout(function () {
|
||||
window.location.href = url;
|
||||
},s*1000);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//百度统计,使用时请去掉
|
||||
var _hmt = _hmt || [];
|
||||
(function() {
|
||||
var hm = document.createElement("script");
|
||||
hm.src = "https://hm.baidu.com/hm.js?2b45cf3bb7ac4664bb612c10feebf85d";
|
||||
var s = document.getElementsByTagName("script")[0];
|
||||
s.parentNode.insertBefore(hm, s);
|
||||
})();
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,56 @@
|
||||
/**
|
||||
* 检查版本更新
|
||||
* @type {string}
|
||||
*/
|
||||
|
||||
let html = `
|
||||
<div class="modal fade" id="versionUpdate" data-backdrop="static" data-keyboard="false" tabindex="-1" aria-labelledby="staticBackdropLabel" aria-hidden="true">
|
||||
<div class="modal-dialog">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h5 class="modal-title" id="staticBackdropLabel">提示</h5>
|
||||
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
|
||||
<span aria-hidden="true">×</span>
|
||||
</button>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
|
||||
|
||||
<p>
|
||||
发现新的版本: <b id="newVersion">v1.23</b>
|
||||
</p>
|
||||
<p>
|
||||
永不提示请删除: static/admin/js/update.js 中代码
|
||||
</p>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-secondary" id="noUpdate" data-dismiss="modal">关闭</button>
|
||||
<a type="button" href="http://www.qadmin.net/bsadmin.html" target="_blank" class="btn btn-primary">去看看</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
`
|
||||
|
||||
let noUpdate = sessionStorage.getItem('noUpdate');
|
||||
if(noUpdate!=1){
|
||||
$.get(config.official+"/api/version/qadmin",res=>{
|
||||
if(res.code==1){
|
||||
if(config.version<res.data.v){
|
||||
|
||||
layer.confirm('发现新的版本: <b id="newVersion">'+res.data.v+'</b>?<p>\n 永不提示请删除: static/admin/js/update.js 中代码\n </p>', {
|
||||
btn: ['关闭','去看看'] //按钮
|
||||
}, function(){
|
||||
sessionStorage.setItem('noUpdate',1);
|
||||
console.log('不在提示');
|
||||
layer.closeAll()
|
||||
}, function(){
|
||||
window.location.href = 'http://www.qadmin.net/';
|
||||
layer.closeAll()
|
||||
});
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user