mirror of
https://github.com/fofolee/uTools-Manuals.git
synced 2025-10-09 15:33:29 +08:00
添加收藏文本功能,更改划词搜索UI
This commit is contained in:
@@ -142,6 +142,7 @@ toggleView = () => {
|
||||
manualSubInput();
|
||||
} else if ($("#manual").is(":visible") && $("#mainlist").is(":hidden")) {
|
||||
$("#manual").fadeOut();
|
||||
$("#infopannel").fadeOut();
|
||||
$("#mainlist").fadeIn();
|
||||
let num = $(".info").length
|
||||
utools.setExpendHeight(num > 11 ? 550 : 50 * num);
|
||||
@@ -254,6 +255,7 @@ utools.onPluginOut(() => {
|
||||
$("#options").html('').hide();
|
||||
$("#manual").html('').hide();
|
||||
$(".load").html('').hide();
|
||||
$("#infopannel").html('').hide();;
|
||||
$('link[name="manual"]').remove();
|
||||
})
|
||||
|
||||
@@ -286,6 +288,8 @@ $("#manual").on('mousedown', function (e) {
|
||||
} else if (2 == e.which) {
|
||||
var select = document.getSelection().toString();
|
||||
select && sendText(select);
|
||||
} else if (1 == e.which) {
|
||||
$("#infopannel").fadeOut(300);
|
||||
}
|
||||
})
|
||||
|
||||
@@ -379,6 +383,17 @@ $(document).keydown(e => {
|
||||
}
|
||||
}
|
||||
break;
|
||||
// 收藏
|
||||
case 83:
|
||||
if ($('#mainlist').is(':hidden') && $("#manual").is(":visible")) {
|
||||
let text = window.getSelection().toString();
|
||||
if (text) {
|
||||
utools.redirect('收藏', {
|
||||
'type': 'text',
|
||||
'data': text
|
||||
})
|
||||
}
|
||||
}
|
||||
// 划词翻译
|
||||
case 84:
|
||||
if ($('#mainlist').is(':hidden') && $("#manual").is(":visible")) {
|
||||
@@ -388,6 +403,7 @@ $(document).keydown(e => {
|
||||
utools.showNotification('中文你还看不懂嘛!', clickFeatureCode = null, silent = true)
|
||||
} else {
|
||||
let enText = encodeURIComponent(text)
|
||||
$("#infopannel").html('在线翻译中...').fadeIn(300);
|
||||
$.get("http://fanyi.youdao.com/translate?&doctype=json&type=EN2ZH_CN&i=" + enText, data => {
|
||||
let result = data.translateResult;
|
||||
let cnText = '';
|
||||
@@ -397,10 +413,9 @@ $(document).keydown(e => {
|
||||
for (var a of r) {
|
||||
cnText += a.tgt;
|
||||
}
|
||||
cnText += '\r';
|
||||
cnText += '<br>';
|
||||
}
|
||||
let msg = '翻译结果:\n' + cnText;
|
||||
utools.showNotification(msg, clickFeatureCode = null, silent = true)
|
||||
$("#infopannel").html(cnText)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
@@ -79,6 +79,17 @@
|
||||
display: none;
|
||||
}
|
||||
|
||||
#infopannel {
|
||||
position: fixed;
|
||||
left: 0;
|
||||
right: 0;
|
||||
bottom: 0;
|
||||
padding: 1rem;
|
||||
color: white;
|
||||
background: #24292ee3;
|
||||
display: none;
|
||||
}
|
||||
|
||||
.founds {
|
||||
background-color: #ff572236;
|
||||
color: #fd4005;
|
||||
|
Reference in New Issue
Block a user