$(function(){
// add 成功响应的 data 携带一次性明文密钥(secret_key):
// 用独立 layer.alert 展示 + 复制按钮,替代默认的"成功提示后直接关窗"流程。
ua.listen(null, function (res) {
var secretKey = res.data && res.data.secret_key ? res.data.secret_key : '';
if (secretKey) {
var html = ''
+ '密钥已创建,仅展示一次,请立即复制保存:'
+ '
'
+ '' + secretKey + ''
+ ' '
+ '
'
+ '关闭后将无法再次查看明文,遗失只能删除后重建。';
layer.alert(html, {
title: '密钥创建成功',
icon: 1,
area: ['520px', 'auto'],
success: function (layero) {
// 弹层内绑定复制按钮(ClipboardJS)
ua.api.copyText(layero);
}
}, function (index) {
layer.close(index);
// 关闭密钥弹窗后再走默认的关窗/刷新流程
if (ua.checkMobile()) {
location.href = ua.url(init.indexUrl);
} else {
ua.api.closeCurrentOpen({ refreshTable: true });
}
});
return false;
}
// 兜底:无 secret_key 时走默认成功流程
ua.msg.success(res.msg || '保存成功', function () {
if (ua.checkMobile()) {
location.href = ua.url(init.indexUrl);
} else {
ua.api.closeCurrentOpen({ refreshTable: true });
}
});
return false;
});
})