Skip to content

Commit

Permalink
- 前端调整
Browse files Browse the repository at this point in the history
- 添加翻译并拼接的自定义快捷键
- 完善右键切换相似性功能
- OCR文本忽略前后的括号
  • Loading branch information
Echoosx committed Jan 30, 2024
1 parent a2c2885 commit b344ee5
Show file tree
Hide file tree
Showing 8 changed files with 743 additions and 315 deletions.
53 changes: 30 additions & 23 deletions Config.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import os
import sys

from yaml import CLoader as CLoader, CDumper as CDumper, load as yaml_load, dump as yaml_dump
import sys, os

NOPROXIES = {
"http": "",
Expand All @@ -11,38 +13,43 @@

configPath = f'{os.path.dirname(sys.executable)}/TranslatorConfig.yaml' if isPacked else f'{os.path.dirname(os.path.abspath(__file__))}/TranslatorConfig.yaml'


def writeConfig(data: dict) -> None:
with open(configPath, mode='w', encoding='utf-8') as f:
yaml_dump(data, f, CDumper)


def readConfig() -> dict:
with open(configPath,encoding='utf-8') as f:
return yaml_load(f,CLoader)
with open(configPath, encoding='utf-8') as f:
return yaml_load(f, CLoader)


def initConfig() -> None:
emptyData = {'YOUDAO_KEY': '',
'YOUDAO_SECRET': '',
'CAIYUN_TOKEN': '',
'BAIDU_APPID': '',
'BAIDU_SECRETKEY': '',
'TENCENT_SECERTID': '',
'TENCENT_SECERTKEY': '',
'XIAONIU_KEY': '',
'ALIYUN_KEY': '',
'ALIYUN_SECRET': '',
'SELECTED_TRANSLATORS': [],
'Hotkey_OCR': 'Ctrl + Space',
'OCR_APPID': 'c788b7aa',
'OCR_SECRET': 'ODFmODQwZWJmZDhlNTIzOTljNGI3OTcy',
'OCR_KEY': '7ec53833f14724cffb810c14e72eef0d',
'YOUDAO_FREE_RIDER': False,
'CAIYUN_FREE_RIDER': False,
'BAIDU_FREE_RIDER': False,
'TENCENT_FREE_RIDER': False,
'OPACITY': 95}
'YOUDAO_SECRET': '',
'CAIYUN_TOKEN': '',
'BAIDU_APPID': '',
'BAIDU_SECRETKEY': '',
'TENCENT_SECERTID': '',
'TENCENT_SECERTKEY': '',
'XIAONIU_KEY': '',
'ALIYUN_KEY': '',
'ALIYUN_SECRET': '',
'SELECTED_TRANSLATORS': [],
'Hotkey_OCR': 'Ctrl + Space',
'Hotkey_CONCAT': 'Ctrl + Shift + Space',
'OCR_APPID': 'c788b7aa',
'OCR_SECRET': 'ODFmODQwZWJmZDhlNTIzOTljNGI3OTcy',
'OCR_KEY': '7ec53833f14724cffb810c14e72eef0d',
'YOUDAO_FREE_RIDER': False,
'CAIYUN_FREE_RIDER': False,
'BAIDU_FREE_RIDER': False,
'TENCENT_FREE_RIDER': False,
'OPACITY': 95}
writeConfig(emptyData)

if(not os.path.exists(configPath)):

if not os.path.exists(configPath):
isInit = False
print('Config file not found, creating a new one...')
initConfig()
Loading

0 comments on commit b344ee5

Please sign in to comment.