pearAdmin.instances.tabPage = tabPage.render({
elem: 'content',
session: param.tab.session,
index: 0,
tabMax: param.tab.max,
preload: param.tab.preload,
closeEvent: function (id) {
pearAdmin.instances.menu.selectItem(id);
},
data: [{
id: param.tab.index.id,
url: param.tab.index.href,
title: param.tab.index.title,
type: param.tab.index.type,//修复 20241018 解决原来的没有指定类型,加载页面报错导致后台渲染异常
close: false
}],
success: function (id) {
if (param.tab.session) {
setTimeout(function () {
pearAdmin.instances.menu.selectItem(id);
pearAdmin.instances.tabPage.positionTab();
}, 500)
}
}
});
// 不支持IE
//this.configurationProvider = () => {
// return new Promise((resolve) => {
// if (this.configurationPath.indexOf("yml") == -1) {
// $.ajax({
// type: 'get',
// url: this.configurationPath,
// dataType: 'json',
// async: false,
// success: (result) => {
// resolve(result);
// }
// });
// } else {
// resolve(yaml.load(this.configurationPath));
// }
// })
//}
// 修复 20241018 支持IE
this.configurationProvider = (callback) => {
$.ajax({
url: this.configurationPath,
type: 'get',
dataType: 'json',
success: function (result) {
// 调用回调并将结果作为第二个参数
if (typeof callback === "function") {
callback(null, result);
} else {
console.log("Callback is not a function.");
}
},
error: function (jqXHR, textStatus, errorThrown) {
// 调用回调并传递错误
if (typeof callback === "function") {
callback(new Error(`Request failed: ${textStatus}`));
} else {
console.log("Callback is not a function.");
}
}
});
};
//不支持IE
//this.configurationProvider().then((result) => {
// pearAdmin.apply(result);
//})
// 修复 20241018 支持IE
this.configurationProvider((error, result) => {
if (error) {
console.error(error);
} else {
pearAdmin.apply(result);
}
});