mirror of
https://github.com/rubickCenter/rubick
synced 2025-07-19 22:31:26 +08:00
Merge branch 'master' of https://github.com/clouDr-f2e/rubick into master
This commit is contained in:
commit
de49636f1f
@ -55,17 +55,6 @@
|
|||||||
<div class="title">长按以下设置的毫秒响应</div>
|
<div class="title">长按以下设置的毫秒响应</div>
|
||||||
<a-slider :step="100" v-model:value="config.superPanel.mouseDownTime" :min="200" :max="1000" />
|
<a-slider :step="100" v-model:value="config.superPanel.mouseDownTime" :min="200" :max="1000" />
|
||||||
</div>
|
</div>
|
||||||
<div class="setting-item">
|
|
||||||
<div class="title">百度搜索配置</div>
|
|
||||||
<a-form :label-col="{ span: 3 }" :wrapper-col="{ span: 14 }">
|
|
||||||
<a-form-item label="appid">
|
|
||||||
<a-input v-model:value="config.superPanel.baiduAPI.appid" />
|
|
||||||
</a-form-item>
|
|
||||||
<a-form-item label="key">
|
|
||||||
<a-input v-model:value="config.superPanel.baiduAPI.key" />
|
|
||||||
</a-form-item>
|
|
||||||
</a-form>
|
|
||||||
</div>
|
|
||||||
<img width="100%" src="https://static.91jkys.com/upload/202107/02/fa4a5c614234409fb32ddda70cb900aa.jpg" />
|
<img width="100%" src="https://static.91jkys.com/upload/202107/02/fa4a5c614234409fb32ddda70cb900aa.jpg" />
|
||||||
</div>
|
</div>
|
||||||
<div v-if="currentSelect[0] === 2">
|
<div v-if="currentSelect[0] === 2">
|
||||||
|
@ -79,6 +79,50 @@
|
|||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
.spinner {
|
||||||
|
padding-left: 10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.spinner > div {
|
||||||
|
width: 10px;
|
||||||
|
height: 10px;
|
||||||
|
background-color: #ddd;
|
||||||
|
|
||||||
|
border-radius: 100%;
|
||||||
|
display: inline-block;
|
||||||
|
-webkit-animation: bouncedelay 1.4s infinite ease-in-out;
|
||||||
|
animation: bouncedelay 1.4s infinite ease-in-out;
|
||||||
|
/* Prevent first frame from flickering when animation starts */
|
||||||
|
-webkit-animation-fill-mode: both;
|
||||||
|
animation-fill-mode: both;
|
||||||
|
}
|
||||||
|
|
||||||
|
.spinner .bounce1 {
|
||||||
|
-webkit-animation-delay: -0.32s;
|
||||||
|
animation-delay: -0.32s;
|
||||||
|
}
|
||||||
|
|
||||||
|
.spinner .bounce2 {
|
||||||
|
-webkit-animation-delay: -0.16s;
|
||||||
|
animation-delay: -0.16s;
|
||||||
|
}
|
||||||
|
|
||||||
|
@-webkit-keyframes bouncedelay {
|
||||||
|
0%, 80%, 100% { -webkit-transform: scale(0.0) }
|
||||||
|
40% { -webkit-transform: scale(1.0) }
|
||||||
|
}
|
||||||
|
|
||||||
|
@keyframes bouncedelay {
|
||||||
|
0%, 80%, 100% {
|
||||||
|
transform: scale(0.0);
|
||||||
|
-webkit-transform: scale(0.0);
|
||||||
|
} 40% {
|
||||||
|
transform: scale(1.0);
|
||||||
|
-webkit-transform: scale(1.0);
|
||||||
|
}
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
<script src="./index.js" type="module"></script>
|
<script src="./index.js" type="module"></script>
|
||||||
<body>
|
<body>
|
||||||
@ -87,10 +131,22 @@
|
|||||||
<span class="img"><img src="./assets/logo.png" /></span>
|
<span class="img"><img src="./assets/logo.png" /></span>
|
||||||
<span class="text" v-if="selectData.text && selectData.text.length">选择的文本 {{selectData.text.length}} 个</span>
|
<span class="text" v-if="selectData.text && selectData.text.length">选择的文本 {{selectData.text.length}} 个</span>
|
||||||
</div>
|
</div>
|
||||||
<div class="translate" v-if="selectData.translate">
|
<div class="spinner" v-if="loading">
|
||||||
<div class="trans-item" v-for="trans in selectData.translate">
|
<div class="bounce1"></div>
|
||||||
<div>{{trans.src}}</div>
|
<div class="bounce2"></div>
|
||||||
<div>n. {{trans.dst}}</div>
|
<div class="bounce3"></div>
|
||||||
|
</div>
|
||||||
|
<div class="translate" v-if="selectData.translate && !loading">
|
||||||
|
<div>{{selectData.translate.src}}</div>
|
||||||
|
<div v-if="selectData.translate.basic">
|
||||||
|
<div v-for="item in selectData.translate.basic.explains">
|
||||||
|
{{item}}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div v-else>
|
||||||
|
<div v-for="item in selectData.translate.translation">
|
||||||
|
{{item}}
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div @click="() => commonClick(op, selectData.fileUrl)" class="options-item" v-for="op in targetOptions">
|
<div @click="() => commonClick(op, selectData.fileUrl)" class="options-item" v-for="op in targetOptions">
|
||||||
|
@ -1,14 +1,10 @@
|
|||||||
const {ipcRenderer, nativeImage, remote, clipboard} = require('electron')
|
const {ipcRenderer, nativeImage, remote, clipboard} = require('electron')
|
||||||
const md5 = require("md5");
|
|
||||||
const rp = require("request-promise");
|
const rp = require("request-promise");
|
||||||
const isChinese = require('is-chinese');
|
|
||||||
const path = require('path');
|
const path = require('path');
|
||||||
const fs = require('fs');
|
const fs = require('fs');
|
||||||
const { spawn } = require ('child_process');
|
const { spawn } = require ('child_process');
|
||||||
const mineType = require("mime-types");
|
const mineType = require("mime-types");
|
||||||
|
|
||||||
const opConfig = remote.getGlobal('opConfig');
|
|
||||||
|
|
||||||
new Vue({
|
new Vue({
|
||||||
el: '#app',
|
el: '#app',
|
||||||
data: {
|
data: {
|
||||||
@ -66,6 +62,7 @@ new Vue({
|
|||||||
]
|
]
|
||||||
},
|
},
|
||||||
targetOptions: [],
|
targetOptions: [],
|
||||||
|
loading: false,
|
||||||
},
|
},
|
||||||
created() {
|
created() {
|
||||||
// 简单唤起超级面板
|
// 简单唤起超级面板
|
||||||
@ -74,9 +71,9 @@ new Vue({
|
|||||||
const ext = path.extname(this.selectData.fileUrl);
|
const ext = path.extname(this.selectData.fileUrl);
|
||||||
// 剪切板只有文本时,显示翻译
|
// 剪切板只有文本时,显示翻译
|
||||||
if (!this.selectData.fileUrl) {
|
if (!this.selectData.fileUrl) {
|
||||||
|
this.loading = true;
|
||||||
const word = this.selectData.text;
|
const word = this.selectData.text;
|
||||||
const isCh = isChinese(word);
|
this.translate(word);
|
||||||
this.translate(word, isCh ? 'en' : 'zh');
|
|
||||||
this.targetOptions = JSON.parse(JSON.stringify(this.options.translate));
|
this.targetOptions = JSON.parse(JSON.stringify(this.options.translate));
|
||||||
(this.selectData.optionPlugin || []).forEach(plugin => {
|
(this.selectData.optionPlugin || []).forEach(plugin => {
|
||||||
plugin.features.forEach(fe => {
|
plugin.features.forEach(fe => {
|
||||||
@ -172,20 +169,20 @@ new Vue({
|
|||||||
},
|
},
|
||||||
|
|
||||||
methods: {
|
methods: {
|
||||||
translate(msg, to) {
|
translate(msg) {
|
||||||
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); //生成签名
|
|
||||||
const params = encodeURI(
|
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 = {
|
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) => {
|
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) {
|
commonClick(item, fileUrl) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user