Skip to content

Commit

Permalink
2.1.2
Browse files Browse the repository at this point in the history
  • Loading branch information
ZeeLyn committed Sep 24, 2023
1 parent 13259b2 commit 89a1111
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 19 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": "2.1.0",
"version": "2.1.2",
"private": true,
"scripts": {
"serve": "vue-cli-service serve",
Expand Down
15 changes: 3 additions & 12 deletions src/components/Settings.vue
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,11 @@
<el-form-item label="密钥">
<el-input v-model="baidu.key" placeholder="请输入百度翻译API秘钥" clearable type="password" show-password></el-input>
</el-form-item>
<el-form-item>
<div style="text-align: center; width: 100%">
<el-button type="danger" @click="ResetBiaduHandle">重置为默认百度APP ID</el-button>
</div>
</el-form-item>

<el-divider> Google翻译 </el-divider>
<el-form-item label="域名">
<el-select v-model="google.domain" style="width: 100%" :loading="loading">
<el-select v-model="google.domain" style="width: 100%" :loading="loading" placement="top">
<template #prefix> {{ google.domain == "https://translate.google.com" ? "官方" : "镜像" }}: </template>
<el-option label="https://translate.google.com" value="https://translate.google.com">
<div class="option-wrap">
<span>官方:https://translate.google.com</span>
Expand Down Expand Up @@ -127,12 +124,6 @@ export default {
});
});
},
ResetBiaduHandle() {
this.$confirm("确定要重置吗?", "提示").then(() => {
this.baidu.appid = this.store.defBaidu.appid;
this.baidu.key = this.store.defBaidu.key;
});
},
},
};
</script>
Expand Down
8 changes: 2 additions & 6 deletions src/stores/globalStore.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,9 @@ import { defineStore } from "pinia";

export const globalStore = defineStore("globalStore", {
state: () => ({
defBaidu: {
appid: "20211114000998654",
key: "0gPJopPB9IlfqAb1cS8k",
},
baidu: {
appid: "20211114000998654",
key: "0gPJopPB9IlfqAb1cS8k",
appid: "",
key: "",
},
google: {
domain: "https://translate.google.com",
Expand Down
5 changes: 5 additions & 0 deletions src/utils/baidu.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@ import request from "@zeelyn/http";
// import { ElNotification } from "element-plus";

export function BaiduTranslate(store, query, from, to, callback, _err, _finally) {
if (!store.baidu.appid || !store.baidu.key) {
if (_err) _err("请先申请一个免费的百度翻译账号,在右上角设置里填入申请的APPID和秘钥。");
if (_finally) _finally();
return;
}
var salt = new Date().getTime();
var sign_source = `${store.baidu.appid}${query}${salt}${store.baidu.key}`;
request
Expand Down

0 comments on commit 89a1111

Please sign in to comment.