fastlion-amis
Version:
一种MIS页面生成工具
98 lines (97 loc) • 3.51 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
var tslib_1 = require("tslib");
var message_1 = tslib_1.__importDefault(require("antd/lib/message"));
var helper_1 = require("../../../utils/helper");
var _success = function (content, container, duration) {
message_1.default.success({
content: content,
className: 'lion-msg-success',
style: {
zIndex: (0, helper_1.getLagerThanMaxZindex)()
},
getContainer: container ? container : document.body,
duration: duration ? duration : 3
});
};
var _error = function (content, container, duration) {
message_1.default.error({
content: content,
className: 'lion-msg-error',
style: {
zIndex: (0, helper_1.getLagerThanMaxZindex)()
},
getContainer: container ? container : document.body,
duration: duration ? duration : 3
});
};
var _info = function (content, container, duration) {
message_1.default.info({
content: content,
className: 'lion-msg-info',
style: {
zIndex: (0, helper_1.getLagerThanMaxZindex)()
},
getContainer: container ? container : document.body,
duration: duration ? duration : 2
});
};
var _warning = function (content, container, duration) {
message_1.default.warning({
content: content,
className: 'lion-msg-warning',
style: {
zIndex: (0, helper_1.getLagerThanMaxZindex)()
},
getContainer: container ? container : document.body,
duration: duration ? duration : 3
});
};
var MessageProxy = {
success: _success,
error: _error,
info: _info,
warning: _warning,
};
var getMessage = function () {
// 拦截这四种方法
var interceptedMethods = Object.keys(MessageProxy);
return new Proxy(message_1.default, {
get: function (target, propKey, receiver) {
var originalMember = target[propKey];
// 非函数或非拦截方法:直接返回
if (typeof originalMember !== 'function' ||
!interceptedMethods.includes(propKey)) {
return originalMember;
}
// 包装需拦截的方法
return function () {
var args = [];
for (var _i = 0; _i < arguments.length; _i++) {
args[_i] = arguments[_i];
}
// 检查参数中是否有对象
var hasObjectArg = args.some(function (arg) {
return typeof arg === 'object' && arg !== null;
});
// 条件1:参数含对象 -> 使用原方法
// 条件2:无对象参数 -> 执行自定义逻辑(此处示例为打印日志)
if (hasObjectArg) {
return originalMember.apply(target, args);
}
else if (interceptedMethods.includes(propKey)) {
return MessageProxy[propKey].apply(MessageProxy, args);
// 可在此处添加自定义逻辑(如日志、转换参数等)
}
};
}
});
};
exports.default = {
_success: _success,
_error: _error,
_info: _info,
_warning: _warning,
getMessage: getMessage
};
//# sourceMappingURL=./renderers/Lion/utils/msgsub.js.map