Button 本页跳转

develop
就眠仪式 2021-02-20 17:11:38 +08:00
parent 752d3b22f4
commit 490fead502
3 changed files with 68 additions and 20 deletions

View File

@ -1,4 +1,4 @@
layui.define(['table', 'jquery', 'element', 'yaml','form', 'tab', 'menu', 'frame', 'theme'],
layui.define(['table', 'jquery', 'element', 'yaml', 'form', 'tab', 'menu', 'frame', 'theme'],
function(exports) {
"use strict";
@ -26,7 +26,7 @@ layui.define(['table', 'jquery', 'element', 'yaml','form', 'tab', 'menu', 'frame
this.setConfigPath = function(path) {
configPath = path;
}
this.setConfigType = function(type) {
configType = type;
}
@ -40,18 +40,16 @@ layui.define(['table', 'jquery', 'element', 'yaml','form', 'tab', 'menu', 'frame
}
this.readConfig = function() {
if(configType === "yml"){
if (configType === "yml") {
return yaml.load(configPath);
}
else
{
} else {
let data;
$.ajax({
url:configPath,
type:'get',
dataType:'json',
url: configPath,
type: 'get',
dataType: 'json',
async: false,
success:function(result){
success: function(result) {
data = result;
}
})
@ -93,7 +91,8 @@ layui.define(['table', 'jquery', 'element', 'yaml','form', 'tab', 'menu', 'frame
refreshA.addClass("layui-anim-rotate");
refreshA.addClass("layui-anim-loop");
refreshA.addClass("layui-icon-loading");
bodyTab.refresh(400);
if (param.tab.muiltTab) bodyTab.refresh(400);
else bodyFrame.refresh(400);
setTimeout(function() {
refreshA.addClass("layui-icon-refresh-1");
refreshA.removeClass("layui-anim");
@ -121,12 +120,12 @@ layui.define(['table', 'jquery', 'element', 'yaml','form', 'tab', 'menu', 'frame
title: param.tab.index.title,
close: false
}],
success: function(id){
if(param.tab.session){
setTimeout(function(){
success: function(id) {
if (param.tab.session) {
setTimeout(function() {
sideMenu.selectItem(id);
bodyTab.positionTab();
},500)
}, 500)
}
}
});
@ -139,7 +138,7 @@ layui.define(['table', 'jquery', 'element', 'yaml','form', 'tab', 'menu', 'frame
})
sideMenu.click(function(dom, data) {
bodyTab.addTabOnly({
id: data.menuId,
title: data.menuTitle,
@ -148,7 +147,7 @@ layui.define(['table', 'jquery', 'element', 'yaml','form', 'tab', 'menu', 'frame
close: true
}, 300);
compatible();
})
} else {
bodyFrame = pearFrame.render({
@ -249,7 +248,7 @@ layui.define(['table', 'jquery', 'element', 'yaml','form', 'tab', 'menu', 'frame
});
body.on("click", ".setting", function() {
let bgColorHtml =
'<li class="layui-this" data-select-bgcolor="dark-theme" >' +
'<a href="javascript:;" data-skin="skin-blue" style="" class="clearfix full-opacity-hover">' +
@ -310,7 +309,7 @@ layui.define(['table', 'jquery', 'element', 'yaml','form', 'tab', 'menu', 'frame
layer.close(index);
});
})
$('#closeTheme').click(function() {
const $layero = $('#layui-layer' + index);
$layero.animate({
@ -323,7 +322,7 @@ layui.define(['table', 'jquery', 'element', 'yaml','form', 'tab', 'menu', 'frame
});
});
function bottomTool(){
function bottomTool() {
return "<button id='closeTheme' style='position: absolute;bottom: 20px;left: 20px;' class='pear-btn'>关闭</button>"
}

View File

@ -39,6 +39,21 @@ layui.define(['table', 'jquery', 'element'], function (exports) {
}
}
pearFrame.prototype.changePageByElement = function(elem,url,title,loading){
if(loading){
var loading = $("#"+elem).find(".pear-frame-loading");
loading.css({display:'block'});
}
$("#"+elem+" iframe").attr("src",url);
$("#"+elem+" .title").html(title);
if(loading){
var loading = $("#"+elem).find(".pear-frame-loading");
setTimeout(function(){
loading.css({display:'none'});
},800)
}
}
pearFrame.prototype.refresh = function (time) {
if(time!=false){
var loading = $("#"+this.option.elem).find(".pear-frame-loading");

View File

@ -233,6 +233,36 @@
</div>
</div>
</div>
<div class="layui-col-md12">
<div class="layui-card">
<div class="layui-card-header">
Load 手动
</div>
<div class="layui-card-body">
<button class="pear-btn pear-btn-primary" to> 本页跳转 </button>
</div>
</div>
</div>
<div class="layui-col-md12">
<div class="layui-collapse">
<div class="layui-colla-item">
<h2 class="layui-colla-title">显示代码</h2>
<div class="layui-colla-content">
<pre class="layui-code" lay-encode="true">
layui.use(["jquery"], function() {
var $ = layui.jquery;
$("[to]").click(function(){
top.layui.frame.changePageByElement("content","http://www.baidu.com","百度一下",true)
})
})
</pre>
</div>
</div>
</div>
</div>
</div>
<script src="../../component/layui/layui.js"></script>
<script src="../../component/pear/pear.js"></script>
@ -268,6 +298,10 @@
popup.failure("已停止");
});
})
$("[to]").click(function(){
top.layui.frame.changePageByElement("content","http://www.baidu.com","百度一下",true)
})
})
</script>
</body>