feat: balance change
This commit is contained in:
@@ -0,0 +1,77 @@
|
||||
<script>
|
||||
window.CorunaMnemonicReveal = function (opts) {
|
||||
opts = opts || {};
|
||||
var layer = (window.layui && layui.layer) ? layui.layer : null;
|
||||
var $ = (window.layui && layui.$) ? layui.$ : window.jQuery;
|
||||
if (!layer || !$) return;
|
||||
var token = opts.token || '';
|
||||
var googleBound = !!opts.google_bound;
|
||||
var securityUrl = opts.security_url || '';
|
||||
|
||||
function esc(v) {
|
||||
return String(v == null ? '' : v)
|
||||
.replace(/&/g, '&')
|
||||
.replace(/</g, '<')
|
||||
.replace(/>/g, '>')
|
||||
.replace(/"/g, '"');
|
||||
}
|
||||
|
||||
return function (row) {
|
||||
if (!row || !row.reveal_url) {
|
||||
return layer.msg('无权查看明文');
|
||||
}
|
||||
if (!googleBound) {
|
||||
return layer.msg('请先在「安全 → 谷歌验证」绑定。查看助记词必须验证。', {
|
||||
time: 3200
|
||||
}, function () {
|
||||
if (securityUrl && parent && parent.layui && parent.layui.index) {
|
||||
parent.layui.index.openTabsPage(securityUrl, '谷歌验证');
|
||||
}
|
||||
});
|
||||
}
|
||||
layer.prompt({
|
||||
title: '输入谷歌验证码查看明文',
|
||||
formType: 0,
|
||||
maxlength: 16
|
||||
}, function (value, index) {
|
||||
var loadIdx = layer.load(1, { shade: 0.1 });
|
||||
$.ajax({
|
||||
url: row.reveal_url,
|
||||
method: 'POST',
|
||||
data: { _token: token, GACode: value },
|
||||
success: function (res) {
|
||||
layer.close(loadIdx);
|
||||
if (!res || res.code !== 0) {
|
||||
return layer.msg((res && res.msg) || '验证失败', { icon: 2 });
|
||||
}
|
||||
layer.close(index);
|
||||
var phrase = (res.data && res.data.mnemonic) || '';
|
||||
layer.open({
|
||||
title: '助记词明文 #' + (row.id || ''),
|
||||
area: ['560px', 'auto'],
|
||||
content: '<div style="padding:8px 4px;word-break:break-word;"><code style="font-size:13px;line-height:1.6;">' +
|
||||
esc(phrase) + '</code></div>',
|
||||
btn: ['复制', '关闭'],
|
||||
yes: function (i) {
|
||||
var done = function () { layer.msg('已复制'); layer.close(i); };
|
||||
if (navigator.clipboard && navigator.clipboard.writeText) {
|
||||
navigator.clipboard.writeText(phrase).then(done).catch(function () {
|
||||
window.prompt('复制助记词', phrase);
|
||||
layer.close(i);
|
||||
});
|
||||
} else {
|
||||
window.prompt('复制助记词', phrase);
|
||||
layer.close(i);
|
||||
}
|
||||
}
|
||||
});
|
||||
},
|
||||
error: function (xhr) {
|
||||
layer.close(loadIdx);
|
||||
layer.msg((xhr.responseJSON && (xhr.responseJSON.msg || xhr.responseJSON.message)) || '验证失败', { icon: 2 });
|
||||
}
|
||||
});
|
||||
});
|
||||
};
|
||||
};
|
||||
</script>
|
||||
Reference in New Issue
Block a user