diff --git a/packages/shell-chrome/assets/css/tran.css b/packages/shell-chrome/assets/css/tran.css index 24604e6..37cb9c6 100644 --- a/packages/shell-chrome/assets/css/tran.css +++ b/packages/shell-chrome/assets/css/tran.css @@ -4,10 +4,12 @@ } #trans{ width: 280px; - height: 490px; + height: 540px; float: left; margin-left: 10px; background-color: rgb(251, 252, 250); + border:2px solid rgb(251, 252, 250); + border-radius:25px ; } #trans_header{ width: 300px; @@ -50,6 +52,7 @@ border:none height: 170px; margin-bottom: 10px; } + #middleTans{ font-size: 15px; margin-bottom: 5px; @@ -71,5 +74,7 @@ border:none color: azure; } #outPutRes{ - -} \ No newline at end of file + width: 280px; + height: 230px; + overflow:auto; + } \ No newline at end of file diff --git a/packages/shell-chrome/assets/js/translate/tran.js b/packages/shell-chrome/assets/js/translate/tran.js index 680b450..8e23a8a 100644 --- a/packages/shell-chrome/assets/js/translate/tran.js +++ b/packages/shell-chrome/assets/js/translate/tran.js @@ -6,7 +6,7 @@ var BitTarnsDiv = document.createElement("div") BitTarnsDiv.id = "BitTarnsDivId" document.body.appendChild(BitTarnsDiv) BitTarnsDiv.style.backgroundColor = "RGB(238,237,237)" -BitTarnsDiv.style.height = "500px" +BitTarnsDiv.style.height = "550px" BitTarnsDiv.style.width = "300px" BitTarnsDiv.style.zIndex = 99999 BitTarnsDiv.style.position = "fixed" @@ -34,14 +34,15 @@ BitTarnsDiv.innerHTML = ` - + +
自动检测语言:

English


-

+
` @@ -49,8 +50,6 @@ var from = 'auto'; var to = 'auto'; var postMsg = async function () { - from = document.getElementById("inputLangSelect").value - to = document.getElementById("outLangSelect").value var msgq = document.getElementById("inputLang").value // 翻译api msgq = encodeURIComponent(msgq) @@ -60,7 +59,6 @@ var postMsg = async function () { let res1 = await fetch(httpUrl1) let result1 = await res1.json() let res2 = result1.trans_result[0].dst - document.getElementById("outPutRes").innerHTML = res2 } @@ -73,13 +71,20 @@ var onInputChange = async function () { let result1 = await res1.json() let res2 = result1.data.src if (res2 == 'en') { - document.getElementById("LangType").innerHTML = '英文' + document.getElementById("LangType").innerHTML = 'English' + from = 'en'; + to = 'zh'; + postMsg() } else if (res2 == 'zh') { document.getElementById("LangType").innerHTML = '简体中文' + from = 'zh'; + to = 'en'; + postMsg() } else { document.getElementById("LangType").innerHTML = res + postMsg() } - postMsg() + } //触发识别语言,再翻译 @@ -88,6 +93,8 @@ document.getElementById("inputLang").onchange = function () { } //直接翻译 document.getElementById("tranbtn").onclick = function () { + from = document.getElementById("inputLangSelect").value + to = document.getElementById("outLangSelect").value postMsg() } //关闭翻译模块