-
{{trans.src}}
-
n. {{trans.dst}}
+
+
+
{{selectData.translate.src}}
+
+
commonClick(op, selectData.fileUrl)" class="options-item" v-for="op in targetOptions">
diff --git a/static/plugins/superPanel/index.js b/static/plugins/superPanel/index.js
index b4618c7..c72243b 100644
--- a/static/plugins/superPanel/index.js
+++ b/static/plugins/superPanel/index.js
@@ -1,14 +1,10 @@
const {ipcRenderer, nativeImage, remote, clipboard} = require('electron')
-const md5 = require("md5");
const rp = require("request-promise");
-const isChinese = require('is-chinese');
const path = require('path');
const fs = require('fs');
const { spawn } = require ('child_process');
const mineType = require("mime-types");
-const opConfig = remote.getGlobal('opConfig');
-
new Vue({
el: '#app',
data: {
@@ -66,6 +62,7 @@ new Vue({
]
},
targetOptions: [],
+ loading: false,
},
created() {
// 简单唤起超级面板
@@ -74,9 +71,9 @@ new Vue({
const ext = path.extname(this.selectData.fileUrl);
// 剪切板只有文本时,显示翻译
if (!this.selectData.fileUrl) {
+ this.loading = true;
const word = this.selectData.text;
- const isCh = isChinese(word);
- this.translate(word, isCh ? 'en' : 'zh');
+ this.translate(word);
this.targetOptions = JSON.parse(JSON.stringify(this.options.translate));
(this.selectData.optionPlugin || []).forEach(plugin => {
plugin.features.forEach(fe => {
@@ -172,20 +169,20 @@ new Vue({
},
methods: {
- translate(msg, to) {
- const {appid, key} = opConfig.get().superPanel.baiduAPI;
- if (!appid || !key) return;
- const q = msg;
- const salt = parseInt(Math.random() * 1000000000); //加盐
- const sign = md5(appid + q + salt + key); //生成签名
+ translate(msg) {
const params = encodeURI(
- `q=${q}&from=auto&to=${to}&appid=${appid}&salt=${salt}&sign=${sign}`
+ `q=${msg}&keyfrom=neverland&key=969918857&type=data&doctype=json&version=1.1`
);
const options = {
- uri: `https://fanyi-api.baidu.com/api/trans/vip/translate?${params}`,
+ uri: `http://fanyi.youdao.com/openapi.do?${params}`,
};
return rp(options).then((res) => {
- this.$set(this.selectData, 'translate', JSON.parse(res).trans_result)
+ this.$set(this.selectData, 'translate', {
+ ...JSON.parse(res),
+ src: msg,
+ });
+ }).finally(() => {
+ this.loading = false;
})
},
commonClick(item, fileUrl) {
From c5064909333fe9d894dc0ec6f2c1613e01ad2101 Mon Sep 17 00:00:00 2001
From: muwoo <2424880409@qq.com>
Date: Tue, 20 Jul 2021 14:18:40 +0800
Subject: [PATCH 2/2] =?UTF-8?q?ref:=20=E4=BC=98=E5=8C=96=E5=8F=96=E8=89=B2?=
=?UTF-8?q?=E5=92=8C=E6=88=AA=E5=B1=8F?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
static/plugins/superPanel/index.html | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/static/plugins/superPanel/index.html b/static/plugins/superPanel/index.html
index 7b7dc82..535464a 100644
--- a/static/plugins/superPanel/index.html
+++ b/static/plugins/superPanel/index.html
@@ -144,7 +144,7 @@