Skip to content

Commit

Permalink
2.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
ZeeLyn committed Sep 16, 2023
1 parent 6563243 commit e02921a
Show file tree
Hide file tree
Showing 4 changed files with 67 additions and 44 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "TranslateDesktop",
"version": "1.1.3",
"version": "2.0.0",
"private": true,
"scripts": {
"serve": "vue-cli-service serve",
Expand Down
6 changes: 6 additions & 0 deletions src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -124,4 +124,10 @@ li {
.not-drag {
-webkit-app-region: no-drag;
}
.el-check-tag {
font-weight: normal !important;
font-size: 13px !important;
line-height: 18px !important;
}
</style>
30 changes: 27 additions & 3 deletions src/utils/google.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,21 +65,45 @@ export function GoogleTranslate(store, query, from, to, callback, _err, _finally
? res.data[1].map((item) => {
return {
attr: item[0],
items: item[1].map((x, idx) => {
items: item[2]?.map((x, idx) => {
var trans = item[2][idx];
var p = {
return {
src: x,
trans: trans[1],
rate: trans[3],
};
return p;
}),
};
})
: null;
var k = res.data[1]
? res.data[1].map((item) => {
return {
attr: item[0],
words: item[2].map((x) => {
return {
word: x[0], //词语
definition: x[1], //释义
};
}),
};
})
: [];
var definitions = [];
k.forEach((item) => {
item.words.forEach((x) => {
definitions.push({
attr: item.attr,
word: x.word,
definition: x.definition,
});
});
});
// console.log(definitions);
callback({
result,
rec: rec,
definitions,
});
})
.catch((err) => {
Expand Down
73 changes: 33 additions & 40 deletions src/views/Home.vue
Original file line number Diff line number Diff line change
Expand Up @@ -53,27 +53,39 @@
<div class="to" v-loading="loading" element-loading-text="拼命加载中..." element-loading-background="rgba(0,0,0,0)">
<div class="trans_wrap">
<div class="socll">
<template v-if="trans_result.result">
<template v-if="trans_result.result && (!trans_result.definitions || trans_result.definitions.length == 0)">
<div class="item" v-for="(item, idx) in trans_result.result" :key="idx">
<div class="src">{{ item.src }}</div>
<div class="dst" title="点击复制" @click="ClickTransItemHandle">{{ item.dst }}</div>
<el-check-tag checked title="点击复制" @click="ClickTransItemHandle">{{ item.dst }}</el-check-tag>
</div>
</template>
<div v-if="trans_result.rec" class="rec">
<div v-for="item in trans_result.rec" :key="item.atrr">
<h4>{{ item.attr }}</h4>
<ul>
<li v-for="r in item.items" :key="r.src">
<div v-if="trans_result.definitions" class="rec">
<div>
<!-- <h4>{{ item.attr }}</h4> -->
<table>
<tr v-for="item in trans_result.definitions" :key="item">
<td>
<el-check-tag title="点击复制" checked @click="ClickTransItemHandle">{{ item.word }}</el-check-tag>
</td>
<td>{{ item.attr }}</td>
<td>
<template v-for="(k, idx) in item.definition" :key="k">
{{ idx > 0 ? " ," : "" }}
<span>{{ k }}</span>
</template>
</td>
</tr>
<!-- <li v-for="item in trans_result.definitions" :key="item">
<div class="info">
<div @click="ClickTransItemHandle">{{ r.src }}</div>
<template v-for="(k, idx) in r.trans" :key="k">
<div @click="ClickTransItemHandle">{{ item.word }}</div>
<div>{{ item.attr }}</div>
<template v-for="(k, idx) in item.definition" :key="k">
{{ idx > 0 ? " ," : "" }}
<span>{{ k }}</span>
</template>
</div>
<!-- <div class="rate">{{ r.rate }}</div> -->
</li>
</ul>
</li> -->
</table>
</div>
</div>
</div>
Expand Down Expand Up @@ -132,6 +144,7 @@ export default {
trans_result: {
result: [],
rec: [],
definitions: [],
},
};
},
Expand Down Expand Up @@ -268,34 +281,13 @@ export default {
};
</script>
<style scoped>
.rec ul li {
display: flex;
margin: 5px 0;
}
.rec h4 {
color: rgb(89, 255, 227);
margin-top: 25px;
font-size: 14px;
font-weight: normal;
}
.rec ul li .info {
flex: 1;
}
.rec ul li .info div {
margin-right: 15px;
display: inline-block;
cursor: pointer;
font-size: 14px;
table {
box-sizing: border-box;
width: 100%;
}
.rec ul li .info div:hover {
background: #fff;
color: #292a2d;
table td {
padding: 3px 3px;
}
.main {
width: 100vw;
height: 100vh;
Expand Down Expand Up @@ -424,11 +416,12 @@ textarea::-webkit-scrollbar-thumb {
.trans_wrap .item {
padding: 5px 0;
display: flex;
align-items: center;
}
.trans_wrap .item:hover {
/* .trans_wrap .item:hover {
background: #4c4f53;
}
} */
.trans_wrap .item .src {
margin-right: 15px;
Expand Down

0 comments on commit e02921a

Please sign in to comment.