├── .all-contributorsrc ├── .editorconfig ├── .eslintignore ├── .eslintrc.js ├── .gitignore ├── .postcssrc.js ├── .prettierignore ├── .prettierrc ├── .travis.yml ├── .vscode ├── launch.json └── settings.json ├── LICENSE ├── README.md ├── babel.config.js ├── package.json ├── public ├── css │ ├── google.css │ └── icon.css ├── i18n │ └── zh-CN │ │ └── languages.json ├── icon.icns ├── iconTemplate.ico ├── iconTemplate@2x.ico └── index.html ├── src ├── index.js ├── main │ ├── checkForUpdates.js │ ├── index.js │ └── lib │ │ └── menubar │ │ ├── index.d.ts │ │ └── index.js └── renderer │ ├── App.tsx │ ├── assets │ ├── img │ │ ├── af-2x.png │ │ ├── ar-AE-2x.png │ │ ├── ar-EG-2x.png │ │ ├── ar-SA-2x.png │ │ ├── auto-2x.png │ │ ├── az-2x.png │ │ ├── be-2x.png │ │ ├── bg-2x.png │ │ ├── bn-2x.png │ │ ├── bs-2x.png │ │ ├── ca-2x.png │ │ ├── ceb-2x.png │ │ ├── cs-2x.png │ │ ├── cy-2x.png │ │ ├── da-2x.png │ │ ├── de-2x.png │ │ ├── el-2x.png │ │ ├── en-AU-2x.png │ │ ├── en-UK-2x.png │ │ ├── en-US-2x.png │ │ ├── eo-2x.png │ │ ├── es-ES-2x.png │ │ ├── es-MX-2x.png │ │ ├── es-US-2x.png │ │ ├── et-2x.png │ │ ├── eu-2x.png │ │ ├── fa-2x.png │ │ ├── fi-2x.png │ │ ├── fr-CA-2x.png │ │ ├── fr-FR-2x.png │ │ ├── ga-2x.png │ │ ├── gl-2x.png │ │ ├── gu-2x.png │ │ ├── ha-2x.png │ │ ├── hi-2x.png │ │ ├── hmn-2x.png │ │ ├── hr-2x.png │ │ ├── ht-2x.png │ │ ├── hu-2x.png │ │ ├── hy-2x.png │ │ ├── id-2x.png │ │ ├── ig-2x.png │ │ ├── is-2x.png │ │ ├── it-2x.png │ │ ├── iw-2x.png │ │ ├── ja-2x.png │ │ ├── jw-2x.png │ │ ├── ka-2x.png │ │ ├── kk-2x.png │ │ ├── km-2x.png │ │ ├── kn-2x.png │ │ ├── ko-2x.png │ │ ├── la-2x.png │ │ ├── lo-2x.png │ │ ├── lt-2x.png │ │ ├── lv-2x.png │ │ ├── mg-2x.png │ │ ├── mi-2x.png │ │ ├── mk-2x.png │ │ ├── ml-2x.png │ │ ├── mn-2x.png │ │ ├── mr-2x.png │ │ ├── ms-2x.png │ │ ├── mt-2x.png │ │ ├── my-2x.png │ │ ├── ne-2x.png │ │ ├── nl-2x.png │ │ ├── no-2x.png │ │ ├── ny-2x.png │ │ ├── pa-2x.png │ │ ├── pl-2x.png │ │ ├── pt-BR-2x.png │ │ ├── pt-PT-2x.png │ │ ├── ro-2x.png │ │ ├── ru-2x.png │ │ ├── si-2x.png │ │ ├── sk-2x.png │ │ ├── sl-2x.png │ │ ├── so-2x.png │ │ ├── sq-2x.png │ │ ├── sr-2x.png │ │ ├── st-2x.png │ │ ├── su-2x.png │ │ ├── sv-2x.png │ │ ├── sw-2x.png │ │ ├── ta-2x.png │ │ ├── te-2x.png │ │ ├── tg-2x.png │ │ ├── th-2x.png │ │ ├── tl-2x.png │ │ ├── tr-2x.png │ │ ├── uk-2x.png │ │ ├── ur-2x.png │ │ ├── uz-2x.png │ │ ├── vi-2x.png │ │ ├── yi-2x.png │ │ ├── yo-2x.png │ │ ├── zh-CN-2x.png │ │ ├── zh-HK-2x.png │ │ ├── zh-TW-2x.png │ │ └── zu-2x.png │ ├── languages.json │ └── languages.ts │ ├── components │ ├── Country.tsx │ ├── Header.tsx │ ├── Icon.tsx │ ├── Input.tsx │ ├── InputShortcutKeys.tsx │ ├── Language.tsx │ ├── Layout.tsx │ ├── Link.tsx │ ├── Loading.tsx │ ├── LocaleProvider.tsx │ ├── Progress.tsx │ ├── Radio.tsx │ ├── Select.tsx │ ├── Switch.tsx │ └── TextBox.tsx │ ├── lib │ └── emotion.js │ ├── main.ts │ ├── router.ts │ ├── shims.d.ts │ ├── store.ts │ ├── utils │ └── index.ts │ └── views │ ├── Language.tsx │ ├── Settings.tsx │ └── Translate.tsx ├── tsconfig.json ├── types ├── v-hotkey.d.ts └── vue-emotoin.d.ts ├── vue.config.js └── yarn.lock /.all-contributorsrc: -------------------------------------------------------------------------------- 1 | { 2 | "projectName": "GoogleTranslate", 3 | "projectOwner": "MoeFE", 4 | "commit": false, 5 | "contributors": [ 6 | { 7 | "login": "u3u", 8 | "name": "さくら", 9 | "avatar_url": "https://avatars2.githubusercontent.com/u/20062482?v=4", 10 | "profile": "https://qwq.cat", 11 | "contributions": [ 12 | "code", 13 | "doc", 14 | "design", 15 | "ideas" 16 | ] 17 | }, 18 | { 19 | "login": "Batur24", 20 | "name": "Batur", 21 | "avatar_url": "https://avatars1.githubusercontent.com/u/9591690?v=4", 22 | "profile": "https://github.com/Batur24", 23 | "contributions": [ 24 | "question", 25 | "bug", 26 | "ideas", 27 | "test" 28 | ] 29 | }, 30 | { 31 | "login": "mantou132", 32 | "name": "mantou", 33 | "avatar_url": "https://avatars3.githubusercontent.com/u/3841872?v=4", 34 | "profile": "https://github.com/mantou132", 35 | "contributions": [ 36 | "code", 37 | "ideas" 38 | ] 39 | } 40 | ], 41 | "repoType": "github" 42 | } 43 | -------------------------------------------------------------------------------- /.editorconfig: -------------------------------------------------------------------------------- 1 | # http://editorconfig.org 2 | root = true 3 | 4 | [*] 5 | indent_style = space 6 | indent_size = 2 7 | end_of_line = lf 8 | charset = utf-8 9 | trim_trailing_whitespace = true 10 | insert_final_newline = true 11 | 12 | # Use 4 spaces for the Python files 13 | [*.py] 14 | indent_size = 4 15 | max_line_length = 80 16 | 17 | # The JSON files contain newlines inconsistently 18 | [*.json] 19 | insert_final_newline = ignore 20 | 21 | # Minified JavaScript files shouldn't be changed 22 | [**.min.js] 23 | indent_style = ignore 24 | insert_final_newline = ignore 25 | 26 | # Makefiles always use tabs for indentation 27 | [Makefile] 28 | indent_style = tab 29 | 30 | # Batch files use tabs for indentation 31 | [*.bat] 32 | indent_style = tab 33 | 34 | [*.md] 35 | trim_trailing_whitespace = false 36 | -------------------------------------------------------------------------------- /.eslintignore: -------------------------------------------------------------------------------- 1 | /dist* 2 | /build 3 | /public 4 | -------------------------------------------------------------------------------- /.eslintrc.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | root: true, 3 | env: { 4 | node: true, 5 | }, 6 | extends: ['plugin:vue/essential', '@vue/airbnb', '@vue/typescript'], 7 | rules: { 8 | strict: 'off', 9 | indent: 'off', 10 | 'space-infix-ops': 'off', 11 | 'object-curly-newline': 'off', 12 | 'no-console': process.env.NODE_ENV === 'production' ? 'error' : 'off', 13 | 'no-debugger': process.env.NODE_ENV === 'production' ? 'error' : 'off', 14 | 'no-plusplus': ['error', { allowForLoopAfterthoughts: true }], 15 | 'import/extensions': ['off'], 16 | 'import/no-unresolved': ['off'], 17 | 'import/no-duplicates': ['off'], 18 | 'import/no-named-as-default': ['off'], 19 | 'import/no-named-as-default-member': ['off'], 20 | 'import/no-extraneous-dependencies': ['off'], 21 | 'function-paren-newline': ['off'], 22 | 'class-methods-use-this': [ 23 | 'error', 24 | { 25 | exceptMethods: [ 26 | 'render', 27 | 'beforeCreate', 28 | 'created', 29 | 'beforeMount', 30 | 'mounted', 31 | 'beforeUpdate', 32 | 'updated', 33 | 'activated', 34 | 'deactivated', 35 | 'beforeDestroy', 36 | 'destroyed', 37 | 'errorCaptured', 38 | ], 39 | }, 40 | ], 41 | 'max-len': [ 42 | 'error', 43 | { 44 | code: 80, 45 | ignoreUrls: true, 46 | ignoreStrings: true, 47 | ignoreComments: true, 48 | ignoreTrailingComments: true, 49 | ignoreTemplateLiterals: true, 50 | }, 51 | ], 52 | }, 53 | }; 54 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | node_modules 3 | /dist 4 | /build 5 | 6 | # local env files 7 | .env.local 8 | .env.*.local 9 | 10 | # Log files 11 | npm-debug.log* 12 | yarn-debug.log* 13 | yarn-error.log* 14 | 15 | # Editor directories and files 16 | .idea 17 | *.suo 18 | *.ntvs* 19 | *.njsproj 20 | *.sln 21 | *.sw* 22 | -------------------------------------------------------------------------------- /.postcssrc.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | plugins: { 3 | autoprefixer: {}, 4 | }, 5 | }; 6 | -------------------------------------------------------------------------------- /.prettierignore: -------------------------------------------------------------------------------- 1 | package.json 2 | -------------------------------------------------------------------------------- /.prettierrc: -------------------------------------------------------------------------------- 1 | { 2 | "singleQuote": true, 3 | "trailingComma": "es5", 4 | "arrowParens": "always" 5 | } 6 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: node_js 2 | 3 | node_js: 9 4 | 5 | install: 6 | - yarn 7 | 8 | script: 9 | - yarn lint 10 | - yarn lint:prettier 11 | 12 | cache: 13 | yarn: true 14 | directories: 15 | - node_modules 16 | -------------------------------------------------------------------------------- /.vscode/launch.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "0.2.0", 3 | "configurations": [ 4 | { 5 | "type": "node", 6 | "request": "launch", 7 | "name": "Launch Program", 8 | "program": "${workspaceFolder}/src/index.js" 9 | }, 10 | { 11 | "type": "node", 12 | "request": "launch", 13 | "name": "Electron Main", 14 | "runtimeExecutable": "${workspaceFolder}/node_modules/.bin/electron", 15 | "program": "${workspaceFolder}/build/background.js" 16 | } 17 | ] 18 | } 19 | -------------------------------------------------------------------------------- /.vscode/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "editor.formatOnSave": true, 3 | "prettier.eslintIntegration": true, 4 | "tslint.enable": true, 5 | "tslint.autoFixOnSave": true, 6 | "eslint.autoFixOnSave": true, 7 | "eslint.enable": true, 8 | "eslint.validate": [ 9 | "javascript", 10 | "javascriptreact", 11 | "typescript", 12 | "typescriptreact" 13 | ], 14 | "files.exclude": { 15 | "build": true 16 | }, 17 | "emmet.excludeLanguages": ["typescriptreact"] 18 | } 19 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | Version 3, 29 June 2007 3 | 4 | Copyright (C) 2007 Free Software Foundation, Inc. 5 | Everyone is permitted to copy and distribute verbatim copies 6 | of this license document, but changing it is not allowed. 7 | 8 | Preamble 9 | 10 | The GNU General Public License is a free, copyleft license for 11 | software and other kinds of works. 12 | 13 | The licenses for most software and other practical works are designed 14 | to take away your freedom to share and change the works. By contrast, 15 | the GNU General Public License is intended to guarantee your freedom to 16 | share and change all versions of a program--to make sure it remains free 17 | software for all its users. We, the Free Software Foundation, use the 18 | GNU General Public License for most of our software; it applies also to 19 | any other work released this way by its authors. You can apply it to 20 | your programs, too. 21 | 22 | When we speak of free software, we are referring to freedom, not 23 | price. Our General Public Licenses are designed to make sure that you 24 | have the freedom to distribute copies of free software (and charge for 25 | them if you wish), that you receive source code or can get it if you 26 | want it, that you can change the software or use pieces of it in new 27 | free programs, and that you know you can do these things. 28 | 29 | To protect your rights, we need to prevent others from denying you 30 | these rights or asking you to surrender the rights. Therefore, you have 31 | certain responsibilities if you distribute copies of the software, or if 32 | you modify it: responsibilities to respect the freedom of others. 33 | 34 | For example, if you distribute copies of such a program, whether 35 | gratis or for a fee, you must pass on to the recipients the same 36 | freedoms that you received. You must make sure that they, too, receive 37 | or can get the source code. And you must show them these terms so they 38 | know their rights. 39 | 40 | Developers that use the GNU GPL protect your rights with two steps: 41 | (1) assert copyright on the software, and (2) offer you this License 42 | giving you legal permission to copy, distribute and/or modify it. 43 | 44 | For the developers' and authors' protection, the GPL clearly explains 45 | that there is no warranty for this free software. For both users' and 46 | authors' sake, the GPL requires that modified versions be marked as 47 | changed, so that their problems will not be attributed erroneously to 48 | authors of previous versions. 49 | 50 | Some devices are designed to deny users access to install or run 51 | modified versions of the software inside them, although the manufacturer 52 | can do so. This is fundamentally incompatible with the aim of 53 | protecting users' freedom to change the software. The systematic 54 | pattern of such abuse occurs in the area of products for individuals to 55 | use, which is precisely where it is most unacceptable. Therefore, we 56 | have designed this version of the GPL to prohibit the practice for those 57 | products. If such problems arise substantially in other domains, we 58 | stand ready to extend this provision to those domains in future versions 59 | of the GPL, as needed to protect the freedom of users. 60 | 61 | Finally, every program is threatened constantly by software patents. 62 | States should not allow patents to restrict development and use of 63 | software on general-purpose computers, but in those that do, we wish to 64 | avoid the special danger that patents applied to a free program could 65 | make it effectively proprietary. To prevent this, the GPL assures that 66 | patents cannot be used to render the program non-free. 67 | 68 | The precise terms and conditions for copying, distribution and 69 | modification follow. 70 | 71 | TERMS AND CONDITIONS 72 | 73 | 0. Definitions. 74 | 75 | "This License" refers to version 3 of the GNU General Public License. 76 | 77 | "Copyright" also means copyright-like laws that apply to other kinds of 78 | works, such as semiconductor masks. 79 | 80 | "The Program" refers to any copyrightable work licensed under this 81 | License. Each licensee is addressed as "you". "Licensees" and 82 | "recipients" may be individuals or organizations. 83 | 84 | To "modify" a work means to copy from or adapt all or part of the work 85 | in a fashion requiring copyright permission, other than the making of an 86 | exact copy. The resulting work is called a "modified version" of the 87 | earlier work or a work "based on" the earlier work. 88 | 89 | A "covered work" means either the unmodified Program or a work based 90 | on the Program. 91 | 92 | To "propagate" a work means to do anything with it that, without 93 | permission, would make you directly or secondarily liable for 94 | infringement under applicable copyright law, except executing it on a 95 | computer or modifying a private copy. Propagation includes copying, 96 | distribution (with or without modification), making available to the 97 | public, and in some countries other activities as well. 98 | 99 | To "convey" a work means any kind of propagation that enables other 100 | parties to make or receive copies. Mere interaction with a user through 101 | a computer network, with no transfer of a copy, is not conveying. 102 | 103 | An interactive user interface displays "Appropriate Legal Notices" 104 | to the extent that it includes a convenient and prominently visible 105 | feature that (1) displays an appropriate copyright notice, and (2) 106 | tells the user that there is no warranty for the work (except to the 107 | extent that warranties are provided), that licensees may convey the 108 | work under this License, and how to view a copy of this License. If 109 | the interface presents a list of user commands or options, such as a 110 | menu, a prominent item in the list meets this criterion. 111 | 112 | 1. Source Code. 113 | 114 | The "source code" for a work means the preferred form of the work 115 | for making modifications to it. "Object code" means any non-source 116 | form of a work. 117 | 118 | A "Standard Interface" means an interface that either is an official 119 | standard defined by a recognized standards body, or, in the case of 120 | interfaces specified for a particular programming language, one that 121 | is widely used among developers working in that language. 122 | 123 | The "System Libraries" of an executable work include anything, other 124 | than the work as a whole, that (a) is included in the normal form of 125 | packaging a Major Component, but which is not part of that Major 126 | Component, and (b) serves only to enable use of the work with that 127 | Major Component, or to implement a Standard Interface for which an 128 | implementation is available to the public in source code form. A 129 | "Major Component", in this context, means a major essential component 130 | (kernel, window system, and so on) of the specific operating system 131 | (if any) on which the executable work runs, or a compiler used to 132 | produce the work, or an object code interpreter used to run it. 133 | 134 | The "Corresponding Source" for a work in object code form means all 135 | the source code needed to generate, install, and (for an executable 136 | work) run the object code and to modify the work, including scripts to 137 | control those activities. However, it does not include the work's 138 | System Libraries, or general-purpose tools or generally available free 139 | programs which are used unmodified in performing those activities but 140 | which are not part of the work. For example, Corresponding Source 141 | includes interface definition files associated with source files for 142 | the work, and the source code for shared libraries and dynamically 143 | linked subprograms that the work is specifically designed to require, 144 | such as by intimate data communication or control flow between those 145 | subprograms and other parts of the work. 146 | 147 | The Corresponding Source need not include anything that users 148 | can regenerate automatically from other parts of the Corresponding 149 | Source. 150 | 151 | The Corresponding Source for a work in source code form is that 152 | same work. 153 | 154 | 2. Basic Permissions. 155 | 156 | All rights granted under this License are granted for the term of 157 | copyright on the Program, and are irrevocable provided the stated 158 | conditions are met. This License explicitly affirms your unlimited 159 | permission to run the unmodified Program. The output from running a 160 | covered work is covered by this License only if the output, given its 161 | content, constitutes a covered work. This License acknowledges your 162 | rights of fair use or other equivalent, as provided by copyright law. 163 | 164 | You may make, run and propagate covered works that you do not 165 | convey, without conditions so long as your license otherwise remains 166 | in force. You may convey covered works to others for the sole purpose 167 | of having them make modifications exclusively for you, or provide you 168 | with facilities for running those works, provided that you comply with 169 | the terms of this License in conveying all material for which you do 170 | not control copyright. Those thus making or running the covered works 171 | for you must do so exclusively on your behalf, under your direction 172 | and control, on terms that prohibit them from making any copies of 173 | your copyrighted material outside their relationship with you. 174 | 175 | Conveying under any other circumstances is permitted solely under 176 | the conditions stated below. Sublicensing is not allowed; section 10 177 | makes it unnecessary. 178 | 179 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law. 180 | 181 | No covered work shall be deemed part of an effective technological 182 | measure under any applicable law fulfilling obligations under article 183 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or 184 | similar laws prohibiting or restricting circumvention of such 185 | measures. 186 | 187 | When you convey a covered work, you waive any legal power to forbid 188 | circumvention of technological measures to the extent such circumvention 189 | is effected by exercising rights under this License with respect to 190 | the covered work, and you disclaim any intention to limit operation or 191 | modification of the work as a means of enforcing, against the work's 192 | users, your or third parties' legal rights to forbid circumvention of 193 | technological measures. 194 | 195 | 4. Conveying Verbatim Copies. 196 | 197 | You may convey verbatim copies of the Program's source code as you 198 | receive it, in any medium, provided that you conspicuously and 199 | appropriately publish on each copy an appropriate copyright notice; 200 | keep intact all notices stating that this License and any 201 | non-permissive terms added in accord with section 7 apply to the code; 202 | keep intact all notices of the absence of any warranty; and give all 203 | recipients a copy of this License along with the Program. 204 | 205 | You may charge any price or no price for each copy that you convey, 206 | and you may offer support or warranty protection for a fee. 207 | 208 | 5. Conveying Modified Source Versions. 209 | 210 | You may convey a work based on the Program, or the modifications to 211 | produce it from the Program, in the form of source code under the 212 | terms of section 4, provided that you also meet all of these conditions: 213 | 214 | a) The work must carry prominent notices stating that you modified 215 | it, and giving a relevant date. 216 | 217 | b) The work must carry prominent notices stating that it is 218 | released under this License and any conditions added under section 219 | 7. This requirement modifies the requirement in section 4 to 220 | "keep intact all notices". 221 | 222 | c) You must license the entire work, as a whole, under this 223 | License to anyone who comes into possession of a copy. This 224 | License will therefore apply, along with any applicable section 7 225 | additional terms, to the whole of the work, and all its parts, 226 | regardless of how they are packaged. This License gives no 227 | permission to license the work in any other way, but it does not 228 | invalidate such permission if you have separately received it. 229 | 230 | d) If the work has interactive user interfaces, each must display 231 | Appropriate Legal Notices; however, if the Program has interactive 232 | interfaces that do not display Appropriate Legal Notices, your 233 | work need not make them do so. 234 | 235 | A compilation of a covered work with other separate and independent 236 | works, which are not by their nature extensions of the covered work, 237 | and which are not combined with it such as to form a larger program, 238 | in or on a volume of a storage or distribution medium, is called an 239 | "aggregate" if the compilation and its resulting copyright are not 240 | used to limit the access or legal rights of the compilation's users 241 | beyond what the individual works permit. Inclusion of a covered work 242 | in an aggregate does not cause this License to apply to the other 243 | parts of the aggregate. 244 | 245 | 6. Conveying Non-Source Forms. 246 | 247 | You may convey a covered work in object code form under the terms 248 | of sections 4 and 5, provided that you also convey the 249 | machine-readable Corresponding Source under the terms of this License, 250 | in one of these ways: 251 | 252 | a) Convey the object code in, or embodied in, a physical product 253 | (including a physical distribution medium), accompanied by the 254 | Corresponding Source fixed on a durable physical medium 255 | customarily used for software interchange. 256 | 257 | b) Convey the object code in, or embodied in, a physical product 258 | (including a physical distribution medium), accompanied by a 259 | written offer, valid for at least three years and valid for as 260 | long as you offer spare parts or customer support for that product 261 | model, to give anyone who possesses the object code either (1) a 262 | copy of the Corresponding Source for all the software in the 263 | product that is covered by this License, on a durable physical 264 | medium customarily used for software interchange, for a price no 265 | more than your reasonable cost of physically performing this 266 | conveying of source, or (2) access to copy the 267 | Corresponding Source from a network server at no charge. 268 | 269 | c) Convey individual copies of the object code with a copy of the 270 | written offer to provide the Corresponding Source. This 271 | alternative is allowed only occasionally and noncommercially, and 272 | only if you received the object code with such an offer, in accord 273 | with subsection 6b. 274 | 275 | d) Convey the object code by offering access from a designated 276 | place (gratis or for a charge), and offer equivalent access to the 277 | Corresponding Source in the same way through the same place at no 278 | further charge. You need not require recipients to copy the 279 | Corresponding Source along with the object code. If the place to 280 | copy the object code is a network server, the Corresponding Source 281 | may be on a different server (operated by you or a third party) 282 | that supports equivalent copying facilities, provided you maintain 283 | clear directions next to the object code saying where to find the 284 | Corresponding Source. Regardless of what server hosts the 285 | Corresponding Source, you remain obligated to ensure that it is 286 | available for as long as needed to satisfy these requirements. 287 | 288 | e) Convey the object code using peer-to-peer transmission, provided 289 | you inform other peers where the object code and Corresponding 290 | Source of the work are being offered to the general public at no 291 | charge under subsection 6d. 292 | 293 | A separable portion of the object code, whose source code is excluded 294 | from the Corresponding Source as a System Library, need not be 295 | included in conveying the object code work. 296 | 297 | A "User Product" is either (1) a "consumer product", which means any 298 | tangible personal property which is normally used for personal, family, 299 | or household purposes, or (2) anything designed or sold for incorporation 300 | into a dwelling. In determining whether a product is a consumer product, 301 | doubtful cases shall be resolved in favor of coverage. For a particular 302 | product received by a particular user, "normally used" refers to a 303 | typical or common use of that class of product, regardless of the status 304 | of the particular user or of the way in which the particular user 305 | actually uses, or expects or is expected to use, the product. A product 306 | is a consumer product regardless of whether the product has substantial 307 | commercial, industrial or non-consumer uses, unless such uses represent 308 | the only significant mode of use of the product. 309 | 310 | "Installation Information" for a User Product means any methods, 311 | procedures, authorization keys, or other information required to install 312 | and execute modified versions of a covered work in that User Product from 313 | a modified version of its Corresponding Source. The information must 314 | suffice to ensure that the continued functioning of the modified object 315 | code is in no case prevented or interfered with solely because 316 | modification has been made. 317 | 318 | If you convey an object code work under this section in, or with, or 319 | specifically for use in, a User Product, and the conveying occurs as 320 | part of a transaction in which the right of possession and use of the 321 | User Product is transferred to the recipient in perpetuity or for a 322 | fixed term (regardless of how the transaction is characterized), the 323 | Corresponding Source conveyed under this section must be accompanied 324 | by the Installation Information. But this requirement does not apply 325 | if neither you nor any third party retains the ability to install 326 | modified object code on the User Product (for example, the work has 327 | been installed in ROM). 328 | 329 | The requirement to provide Installation Information does not include a 330 | requirement to continue to provide support service, warranty, or updates 331 | for a work that has been modified or installed by the recipient, or for 332 | the User Product in which it has been modified or installed. Access to a 333 | network may be denied when the modification itself materially and 334 | adversely affects the operation of the network or violates the rules and 335 | protocols for communication across the network. 336 | 337 | Corresponding Source conveyed, and Installation Information provided, 338 | in accord with this section must be in a format that is publicly 339 | documented (and with an implementation available to the public in 340 | source code form), and must require no special password or key for 341 | unpacking, reading or copying. 342 | 343 | 7. Additional Terms. 344 | 345 | "Additional permissions" are terms that supplement the terms of this 346 | License by making exceptions from one or more of its conditions. 347 | Additional permissions that are applicable to the entire Program shall 348 | be treated as though they were included in this License, to the extent 349 | that they are valid under applicable law. If additional permissions 350 | apply only to part of the Program, that part may be used separately 351 | under those permissions, but the entire Program remains governed by 352 | this License without regard to the additional permissions. 353 | 354 | When you convey a copy of a covered work, you may at your option 355 | remove any additional permissions from that copy, or from any part of 356 | it. (Additional permissions may be written to require their own 357 | removal in certain cases when you modify the work.) You may place 358 | additional permissions on material, added by you to a covered work, 359 | for which you have or can give appropriate copyright permission. 360 | 361 | Notwithstanding any other provision of this License, for material you 362 | add to a covered work, you may (if authorized by the copyright holders of 363 | that material) supplement the terms of this License with terms: 364 | 365 | a) Disclaiming warranty or limiting liability differently from the 366 | terms of sections 15 and 16 of this License; or 367 | 368 | b) Requiring preservation of specified reasonable legal notices or 369 | author attributions in that material or in the Appropriate Legal 370 | Notices displayed by works containing it; or 371 | 372 | c) Prohibiting misrepresentation of the origin of that material, or 373 | requiring that modified versions of such material be marked in 374 | reasonable ways as different from the original version; or 375 | 376 | d) Limiting the use for publicity purposes of names of licensors or 377 | authors of the material; or 378 | 379 | e) Declining to grant rights under trademark law for use of some 380 | trade names, trademarks, or service marks; or 381 | 382 | f) Requiring indemnification of licensors and authors of that 383 | material by anyone who conveys the material (or modified versions of 384 | it) with contractual assumptions of liability to the recipient, for 385 | any liability that these contractual assumptions directly impose on 386 | those licensors and authors. 387 | 388 | All other non-permissive additional terms are considered "further 389 | restrictions" within the meaning of section 10. If the Program as you 390 | received it, or any part of it, contains a notice stating that it is 391 | governed by this License along with a term that is a further 392 | restriction, you may remove that term. If a license document contains 393 | a further restriction but permits relicensing or conveying under this 394 | License, you may add to a covered work material governed by the terms 395 | of that license document, provided that the further restriction does 396 | not survive such relicensing or conveying. 397 | 398 | If you add terms to a covered work in accord with this section, you 399 | must place, in the relevant source files, a statement of the 400 | additional terms that apply to those files, or a notice indicating 401 | where to find the applicable terms. 402 | 403 | Additional terms, permissive or non-permissive, may be stated in the 404 | form of a separately written license, or stated as exceptions; 405 | the above requirements apply either way. 406 | 407 | 8. Termination. 408 | 409 | You may not propagate or modify a covered work except as expressly 410 | provided under this License. Any attempt otherwise to propagate or 411 | modify it is void, and will automatically terminate your rights under 412 | this License (including any patent licenses granted under the third 413 | paragraph of section 11). 414 | 415 | However, if you cease all violation of this License, then your 416 | license from a particular copyright holder is reinstated (a) 417 | provisionally, unless and until the copyright holder explicitly and 418 | finally terminates your license, and (b) permanently, if the copyright 419 | holder fails to notify you of the violation by some reasonable means 420 | prior to 60 days after the cessation. 421 | 422 | Moreover, your license from a particular copyright holder is 423 | reinstated permanently if the copyright holder notifies you of the 424 | violation by some reasonable means, this is the first time you have 425 | received notice of violation of this License (for any work) from that 426 | copyright holder, and you cure the violation prior to 30 days after 427 | your receipt of the notice. 428 | 429 | Termination of your rights under this section does not terminate the 430 | licenses of parties who have received copies or rights from you under 431 | this License. If your rights have been terminated and not permanently 432 | reinstated, you do not qualify to receive new licenses for the same 433 | material under section 10. 434 | 435 | 9. Acceptance Not Required for Having Copies. 436 | 437 | You are not required to accept this License in order to receive or 438 | run a copy of the Program. Ancillary propagation of a covered work 439 | occurring solely as a consequence of using peer-to-peer transmission 440 | to receive a copy likewise does not require acceptance. However, 441 | nothing other than this License grants you permission to propagate or 442 | modify any covered work. These actions infringe copyright if you do 443 | not accept this License. Therefore, by modifying or propagating a 444 | covered work, you indicate your acceptance of this License to do so. 445 | 446 | 10. Automatic Licensing of Downstream Recipients. 447 | 448 | Each time you convey a covered work, the recipient automatically 449 | receives a license from the original licensors, to run, modify and 450 | propagate that work, subject to this License. You are not responsible 451 | for enforcing compliance by third parties with this License. 452 | 453 | An "entity transaction" is a transaction transferring control of an 454 | organization, or substantially all assets of one, or subdividing an 455 | organization, or merging organizations. If propagation of a covered 456 | work results from an entity transaction, each party to that 457 | transaction who receives a copy of the work also receives whatever 458 | licenses to the work the party's predecessor in interest had or could 459 | give under the previous paragraph, plus a right to possession of the 460 | Corresponding Source of the work from the predecessor in interest, if 461 | the predecessor has it or can get it with reasonable efforts. 462 | 463 | You may not impose any further restrictions on the exercise of the 464 | rights granted or affirmed under this License. For example, you may 465 | not impose a license fee, royalty, or other charge for exercise of 466 | rights granted under this License, and you may not initiate litigation 467 | (including a cross-claim or counterclaim in a lawsuit) alleging that 468 | any patent claim is infringed by making, using, selling, offering for 469 | sale, or importing the Program or any portion of it. 470 | 471 | 11. Patents. 472 | 473 | A "contributor" is a copyright holder who authorizes use under this 474 | License of the Program or a work on which the Program is based. The 475 | work thus licensed is called the contributor's "contributor version". 476 | 477 | A contributor's "essential patent claims" are all patent claims 478 | owned or controlled by the contributor, whether already acquired or 479 | hereafter acquired, that would be infringed by some manner, permitted 480 | by this License, of making, using, or selling its contributor version, 481 | but do not include claims that would be infringed only as a 482 | consequence of further modification of the contributor version. For 483 | purposes of this definition, "control" includes the right to grant 484 | patent sublicenses in a manner consistent with the requirements of 485 | this License. 486 | 487 | Each contributor grants you a non-exclusive, worldwide, royalty-free 488 | patent license under the contributor's essential patent claims, to 489 | make, use, sell, offer for sale, import and otherwise run, modify and 490 | propagate the contents of its contributor version. 491 | 492 | In the following three paragraphs, a "patent license" is any express 493 | agreement or commitment, however denominated, not to enforce a patent 494 | (such as an express permission to practice a patent or covenant not to 495 | sue for patent infringement). To "grant" such a patent license to a 496 | party means to make such an agreement or commitment not to enforce a 497 | patent against the party. 498 | 499 | If you convey a covered work, knowingly relying on a patent license, 500 | and the Corresponding Source of the work is not available for anyone 501 | to copy, free of charge and under the terms of this License, through a 502 | publicly available network server or other readily accessible means, 503 | then you must either (1) cause the Corresponding Source to be so 504 | available, or (2) arrange to deprive yourself of the benefit of the 505 | patent license for this particular work, or (3) arrange, in a manner 506 | consistent with the requirements of this License, to extend the patent 507 | license to downstream recipients. "Knowingly relying" means you have 508 | actual knowledge that, but for the patent license, your conveying the 509 | covered work in a country, or your recipient's use of the covered work 510 | in a country, would infringe one or more identifiable patents in that 511 | country that you have reason to believe are valid. 512 | 513 | If, pursuant to or in connection with a single transaction or 514 | arrangement, you convey, or propagate by procuring conveyance of, a 515 | covered work, and grant a patent license to some of the parties 516 | receiving the covered work authorizing them to use, propagate, modify 517 | or convey a specific copy of the covered work, then the patent license 518 | you grant is automatically extended to all recipients of the covered 519 | work and works based on it. 520 | 521 | A patent license is "discriminatory" if it does not include within 522 | the scope of its coverage, prohibits the exercise of, or is 523 | conditioned on the non-exercise of one or more of the rights that are 524 | specifically granted under this License. You may not convey a covered 525 | work if you are a party to an arrangement with a third party that is 526 | in the business of distributing software, under which you make payment 527 | to the third party based on the extent of your activity of conveying 528 | the work, and under which the third party grants, to any of the 529 | parties who would receive the covered work from you, a discriminatory 530 | patent license (a) in connection with copies of the covered work 531 | conveyed by you (or copies made from those copies), or (b) primarily 532 | for and in connection with specific products or compilations that 533 | contain the covered work, unless you entered into that arrangement, 534 | or that patent license was granted, prior to 28 March 2007. 535 | 536 | Nothing in this License shall be construed as excluding or limiting 537 | any implied license or other defenses to infringement that may 538 | otherwise be available to you under applicable patent law. 539 | 540 | 12. No Surrender of Others' Freedom. 541 | 542 | If conditions are imposed on you (whether by court order, agreement or 543 | otherwise) that contradict the conditions of this License, they do not 544 | excuse you from the conditions of this License. If you cannot convey a 545 | covered work so as to satisfy simultaneously your obligations under this 546 | License and any other pertinent obligations, then as a consequence you may 547 | not convey it at all. For example, if you agree to terms that obligate you 548 | to collect a royalty for further conveying from those to whom you convey 549 | the Program, the only way you could satisfy both those terms and this 550 | License would be to refrain entirely from conveying the Program. 551 | 552 | 13. Use with the GNU Affero General Public License. 553 | 554 | Notwithstanding any other provision of this License, you have 555 | permission to link or combine any covered work with a work licensed 556 | under version 3 of the GNU Affero General Public License into a single 557 | combined work, and to convey the resulting work. The terms of this 558 | License will continue to apply to the part which is the covered work, 559 | but the special requirements of the GNU Affero General Public License, 560 | section 13, concerning interaction through a network will apply to the 561 | combination as such. 562 | 563 | 14. Revised Versions of this License. 564 | 565 | The Free Software Foundation may publish revised and/or new versions of 566 | the GNU General Public License from time to time. Such new versions will 567 | be similar in spirit to the present version, but may differ in detail to 568 | address new problems or concerns. 569 | 570 | Each version is given a distinguishing version number. If the 571 | Program specifies that a certain numbered version of the GNU General 572 | Public License "or any later version" applies to it, you have the 573 | option of following the terms and conditions either of that numbered 574 | version or of any later version published by the Free Software 575 | Foundation. If the Program does not specify a version number of the 576 | GNU General Public License, you may choose any version ever published 577 | by the Free Software Foundation. 578 | 579 | If the Program specifies that a proxy can decide which future 580 | versions of the GNU General Public License can be used, that proxy's 581 | public statement of acceptance of a version permanently authorizes you 582 | to choose that version for the Program. 583 | 584 | Later license versions may give you additional or different 585 | permissions. However, no additional obligations are imposed on any 586 | author or copyright holder as a result of your choosing to follow a 587 | later version. 588 | 589 | 15. Disclaimer of Warranty. 590 | 591 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY 592 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT 593 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY 594 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, 595 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 596 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM 597 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF 598 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 599 | 600 | 16. Limitation of Liability. 601 | 602 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 603 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS 604 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY 605 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE 606 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF 607 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD 608 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), 609 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF 610 | SUCH DAMAGES. 611 | 612 | 17. Interpretation of Sections 15 and 16. 613 | 614 | If the disclaimer of warranty and limitation of liability provided 615 | above cannot be given local legal effect according to their terms, 616 | reviewing courts shall apply local law that most closely approximates 617 | an absolute waiver of all civil liability in connection with the 618 | Program, unless a warranty or assumption of liability accompanies a 619 | copy of the Program in return for a fee. 620 | 621 | END OF TERMS AND CONDITIONS 622 | 623 | How to Apply These Terms to Your New Programs 624 | 625 | If you develop a new program, and you want it to be of the greatest 626 | possible use to the public, the best way to achieve this is to make it 627 | free software which everyone can redistribute and change under these terms. 628 | 629 | To do so, attach the following notices to the program. It is safest 630 | to attach them to the start of each source file to most effectively 631 | state the exclusion of warranty; and each file should have at least 632 | the "copyright" line and a pointer to where the full notice is found. 633 | 634 | {one line to give the program's name and a brief idea of what it does.} 635 | Copyright (C) 2017 u3u 636 | 637 | This program is free software: you can redistribute it and/or modify 638 | it under the terms of the GNU General Public License as published by 639 | the Free Software Foundation, either version 3 of the License, or 640 | (at your option) any later version. 641 | 642 | This program is distributed in the hope that it will be useful, 643 | but WITHOUT ANY WARRANTY; without even the implied warranty of 644 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 645 | GNU General Public License for more details. 646 | 647 | You should have received a copy of the GNU General Public License 648 | along with this program. If not, see . 649 | 650 | Also add information on how to contact you by electronic and paper mail. 651 | 652 | If the program does terminal interaction, make it output a short 653 | notice like this when it starts in an interactive mode: 654 | 655 | GoogleTranslate Copyright (C) 2017 MoeFE 656 | This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 657 | This is free software, and you are welcome to redistribute it 658 | under certain conditions; type `show c' for details. 659 | 660 | The hypothetical commands `show w' and `show c' should show the appropriate 661 | parts of the General Public License. Of course, your program's commands 662 | might be different; for a GUI interface, you would use an "about box". 663 | 664 | You should also get your employer (if you work as a programmer) or school, 665 | if any, to sign a "copyright disclaimer" for the program, if necessary. 666 | For more information on this, and how to apply and follow the GNU GPL, see 667 | . 668 | 669 | The GNU General Public License does not permit incorporating your program 670 | into proprietary programs. If your program is a subroutine library, you 671 | may consider it more useful to permit linking proprietary applications with 672 | the library. If this is what you want to do, use the GNU Lesser General 673 | Public License instead of this License. But first, please read 674 | . 675 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 |

2 | 3 | Google Translate 4 | 5 |

6 | 7 |

8 | GitHub release 9 | Build Status 10 | LICENSE GPL 11 | Code Style: Prettier 12 |

13 | 14 | > 🌐 Google 翻译 Mac 客户端(这是 2.0 版本的分支) 15 | 16 | ## 状态:公测版 17 | 18 | 所有已知问题都已经修复,并优化了用户体验,但可能依然有少量 BUG。 19 | 如果你在使用中发现了问题,请在[这里](https://github.com/MoeFE/GoogleTranslate/issues/new)报告问题,非常感谢! 20 | 21 | ## 预览 22 | 23 | 预览动态图 24 | 更改语言 25 | 应用程序设置 26 | 27 | ## 功能 28 | 29 | - [x] 基本翻译 30 | - [x] 语音朗读 31 | - [x] 顶端显示 32 | - [x] 开机启动 33 | - [x] ~~自动更新~~ 34 | - [x] 全局快捷键呼出 35 | - [x] 内置多种翻译引擎 36 | 37 | ## 下载 38 | 39 | 您可以在[这里](https://github.com/MoeFE/GoogleTranslate/releases/latest)手动下载最新版本 40 | 41 | ## FAQ 42 | 43 | Q:Electron 不是跨平台的吗?为什么只有 Mac 版本? 44 | A:因为 UI 的交互设计不适用于其他操作系统 45 | 46 | Q:为什么不能自动更新? 47 | A:因为我没有加入 [Apple Developer Program](https://developer.apple.com/programs/)(需要缴纳年费),无法进行[代码签名](https://electronjs.org/docs/tutorial/code-signing),所以无法使用自动更新功能 48 | 49 | Q:所有翻译引擎都提示当前翻译接口不可用? 50 | A:在新版本中,无论你使用哪种翻译引擎,都会先调用国内谷歌翻译的检测语言接口。出现这种情况一般是你的代理节点出现流量异常,导致请求被谷歌拦截,需要输入验证码(你还可以使用 option + command + I 打开调试工具查看请求结果是否正确)所以如果出现这个问题,请更换你的代理节点或不使用代理直接使用国内谷歌引擎。 51 | 52 | Q:无法打开应用,提示该应用来自身份不明的开发者? 53 | A:在终端中输入 `sudo spctl –master-disable` 然后按回车确认,密码是系统开机密码。 54 | 然后打开系统偏好设置 ⇨ 安全性和隐私 ⇨ 任何来源,勾选即可。 55 | 56 | ## 参与贡献 57 | 58 | 1. Fork it! 59 | 2. 将自己添加为贡献者:`npm run contributors` 60 | 3. 创建功能分支:`git checkout -b my-new-feature` 61 | 4. 提交你的更改:`git commit -am 'Add some feature'` 62 | 5. 推送这个分支:`git push origin my-new-feature` 63 | 6. 提交一个拉取请求 :D 64 | 65 | ## 贡献者 66 | 67 | 感谢这些美好的人 ([emoji key](https://github.com/kentcdodds/all-contributors#emoji-key)): 68 | 69 | 70 | 71 | | [
さくら](https://qwq.cat)
[💻](https://github.com/MoeFE/GoogleTranslate/commits?author=u3u "Code") [📖](https://github.com/MoeFE/GoogleTranslate/commits?author=u3u "Documentation") [🎨](#design-u3u "Design") [🤔](#ideas-u3u "Ideas, Planning, & Feedback") | [
Batur](https://github.com/Batur24)
[💬](#question-Batur24 "Answering Questions") [🐛](https://github.com/MoeFE/GoogleTranslate/issues?q=author%3ABatur24 "Bug reports") [🤔](#ideas-Batur24 "Ideas, Planning, & Feedback") [⚠️](https://github.com/MoeFE/GoogleTranslate/commits?author=Batur24 "Tests") | [
mantou](https://github.com/mantou132)
[💻](https://github.com/MoeFE/GoogleTranslate/commits?author=mantou132 "Code") [🤔](#ideas-mantou132 "Ideas, Planning, & Feedback") | 72 | | :---: | :---: | :---: | 73 | 74 | 75 | 76 | 该项目遵循 [all-contributors](https://github.com/kentcdodds/all-contributors) 规范,欢迎任何形式的贡献! 77 | 78 | ## 协议 79 | 80 | [GNU General Public License v3.0](./LICENSE) 81 | 本项目仅供学习交流和私人使用,禁止商业用途 82 | 83 | > [qwq.cat](https://qwq.cat) · GitHub [@u3u](https://github.com/u3u) · Twitter [@hanser0v0](https://twitter.com/hanser0v0) 84 | -------------------------------------------------------------------------------- /babel.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | presets: ['@vue/app'], 3 | plugins: ['jsx-v-model'], 4 | env: { 5 | production: { 6 | plugins: [['emotion', { hoist: true }]], 7 | }, 8 | development: { 9 | plugins: [['emotion', { sourceMap: true, autoLabel: true }]], 10 | }, 11 | }, 12 | }; 13 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "google-translate", 3 | "version": "2.0.0-beta.2", 4 | "private": true, 5 | "main": "build/bundled/background.js", 6 | "scripts": { 7 | "serve": "vue-cli-service serve:electron", 8 | "serve:debug": "vue-cli-service serve:electron --debug", 9 | "build": "vue-cli-service build:electron", 10 | "rebuild": "npm rebuild --update-binary && electron-rebuild", 11 | "lint": "vue-cli-service lint", 12 | "lint:prettier": "prettier-eslint-check \"**/*.{js,jsx,json,ts,tsx,scss,vue,md}\"", 13 | "format": "prettier-eslint \"**/*.{js,jsx,json,ts,tsx,scss,vue,md}\" --write", 14 | "contributors": "all-contributors" 15 | }, 16 | "dependencies": { 17 | "animejs": "^2.2.0", 18 | "auto-launch": "^5.0.5", 19 | "autosize": "^4.0.2", 20 | "keycode": "^2.2.0", 21 | "lodash": "^4.17.11", 22 | "robotjs": "^0.5.1", 23 | "store": "^2.0.12", 24 | "translation.js": "^0.7.5", 25 | "v-hotkey": "^0.2.3", 26 | "vue": "^2.5.17", 27 | "vue-class-component": "^6.2.0", 28 | "vue-emotion": "^0.4.2", 29 | "vue-property-decorator": "^7.0.0", 30 | "vue-router": "^3.0.1", 31 | "vuex": "^3.0.1", 32 | "vuex-class": "^0.3.1" 33 | }, 34 | "devDependencies": { 35 | "@types/animejs": "^2.0.0", 36 | "@types/auto-launch": "^5.0.0", 37 | "@types/autosize": "^3.0.6", 38 | "@types/lodash": "^4.14.116", 39 | "@types/storejs": "^2.0.3", 40 | "@vue/cli-plugin-babel": "^3.0.3", 41 | "@vue/cli-plugin-eslint": "^3.0.3", 42 | "@vue/cli-plugin-typescript": "^3.0.3", 43 | "@vue/cli-service": "^3.0.3", 44 | "@vue/eslint-config-airbnb": "^3.0.3", 45 | "@vue/eslint-config-typescript": "^3.0.3", 46 | "all-contributors-cli": "^5.4.0", 47 | "babel-plugin-emotion": "^9.2.10", 48 | "babel-plugin-jsx-v-model": "^2.0.3", 49 | "download": "^7.1.0", 50 | "electron": "^2.0.10", 51 | "electron-devtools-installer": "^2.2.4", 52 | "electron-positioner": "^4.1.0", 53 | "electron-rebuild": "^1.8.2", 54 | "emotion": "^9.2.9", 55 | "lint-staged": "^7.2.2", 56 | "prettier": "^1.14.3", 57 | "prettier-eslint-check": "^1.0.1", 58 | "prettier-eslint-cli": "^4.7.1", 59 | "typescript": "^3.0.3", 60 | "typescript-styled-plugin": "^0.11.0", 61 | "vue-cli-plugin-electron-builder": "1.0.0-rc.2", 62 | "vue-jsx-hot-loader": "^1.4.0", 63 | "vue-template-compiler": "^2.5.17", 64 | "vue-tsx-support": "^2.1.1" 65 | }, 66 | "browserslist": [ 67 | "> 1%", 68 | "last 2 versions", 69 | "not ie <= 8" 70 | ], 71 | "gitHooks": { 72 | "pre-commit": "lint-staged" 73 | }, 74 | "lint-staged": { 75 | "*.{js,jsx,ts,tsx,vue}": "vue-cli-service lint --no-fix", 76 | "*.{js,jsx,json,ts,tsx,scss,vue,md}": "prettier-eslint-check" 77 | } 78 | } 79 | -------------------------------------------------------------------------------- /public/css/icon.css: -------------------------------------------------------------------------------- 1 | @font-face { 2 | font-family: 'icon'; 3 | src: url('data:application/x-font-woff;charset=utf-8;base64,d09GRgABAAAAAAqUAAsAAAAADrgAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAABHU1VCAAABCAAAADMAAABCsP6z7U9TLzIAAAE8AAAARAAAAFZW7kt3Y21hcAAAAYAAAACvAAACPDluQgFnbHlmAAACMAAABgkAAAeUQQ4x6mhlYWQAAAg8AAAALwAAADYXeAk+aGhlYQAACGwAAAAeAAAAJA16Ca1obXR4AAAIjAAAACAAAAAwOOAAAGxvY2EAAAisAAAAGgAAABoLcgowbWF4cAAACMgAAAAfAAAAIAEhAKVuYW1lAAAI6AAAAUIAAAI9Divfm3Bvc3QAAAosAAAAZgAAAIc4X0h9eJxjYGRgYOBikGPQYWB0cfMJYeBgYGGAAJAMY05meiJQDMoDyrGAaQ4gZoOIAgCKIwNPAHicY2Bk2cs4gYGVgYOpk+kMAwNDP4RmfM1gxMjBwMDEwMrMgBUEpLmmMDgwVLw4wdzwv4EhhrmBoQEozAiSAwAfjwz8eJzFkjEOgzAMRX8gpbQUqQNCPQBjVybuVeUgHZg79SicxOEW9DtmoWJuHb1I/olsyzaAA4Cc3IkH3BsOai+qLuk5zkn3eNBvcKXiESSTWlrpZYhdHOdpWfgaBDvqtzlGaXDbHFWPrKZCxnwnZiiYp6Rc7ET4kbn/pd7aJd3P1atIWGGJAoP9gzhD5yqZof+lNqBaa+hcpTfYcchg6B7EzuAUEEdD92SeDJQfMCgzwAB4nHVVXWwUVRS+596dufvTnd3Zn5lu6f7NdHdKd7trd7Y7tNJtkSJtKdKWllRbaxRS2y6SCAliBINNTAwx2hdjE5UHf0BA44uRGDHSRx8MJgb6YDRRNIqJMWjii+zgmZaiD7q7c+ec79z95vzdM0Qg5PZ37BJrJGHSSjpIPxkhBMQcaBKNQ9ooF2gOomkhqkYkZuhGmutagfWAqokRpVQpZ1WRiwGQIAFmulQxCtSAznKV3gslJQ4Q29S0N5RpDrEl8DYaieftIfomRJN6c6Dabg/meyOlVNj9VEMoFAuFXnSLguCm1BWQ4AlV8Qger2i/LQSaopeSm2kSGmJG0/CD/tSm0KMvlA/FM6oH4ORJCG9KSWd75SYZf8eblHAoxoN+d2OTX2+JwFM/+BrDDfHsdYIfirF+wT5lW0mMbCYkY1TR1QLVMIKgiv6XKpbqxATZslWFUoJGJFoA9v6qpldmF5cWzfl5c3Ggu1ZYlfPpet/wcGZmYWbIMIbwllst1LoHFmcrFfOQ/f0hs6Jrq8F0HtjIlyMZ3PLI/MwuA4w1H1bYKdZLIqQNM11kAcYSUKp0yuvPrnRacjmriVHZwDWSZKbFFn9yiR5RFBiAP+xf4SGpboPLH/Ff5mGJ36Aet5uO/EzR7BLct973+v1epq6I/nD9OQA32+sAt244AL8BLubkwoV+fM1uskkSJAbpIeOEhDt0TYxDRMHaJUHmImgFsJwcZY1sFRRMUTSCucpo2QrCiBagChuo6qD4LcAdmHJEPzoVCIcDp9z8+nVOj7v9IA6P7BsTwS+Lk9P7Rrl9ydfAeGuhrZWDT+ZF07pHXPI2gNij6dDfh2CI7xwGI7ud06aIdCUQcb1Eu1521VcaZD5+5cmjVye4jKxTPz779LcP8e+DspicmptMiXIAhOxCT+8TGeGgJPPOgV3vvlLhsoTM73wyPnov9j2Btab4klKnKpBm0AGnr1Bq37rTK5fZCpshSZJDa2cRLIMXQQ+AwdUA9jBw1UqC2QuqZVgChl0FKwGqBOzyRVo7siyk3ky5lo/U6MU11YWq4Kj2z/3TANP9O5wVqnfQi3f/IywfXlcPLwsdFPdNUTq1o396zd/bn6FP24iEis7xAKi9EFYtdAVOvJF93b4BB14z6G8Duv25thu+yZ62z4D3DeM0dA/qsLVlDyHOeb/KLrAcnvcSqZAqmXRiN9IScBndT6tpjEMuAKxHhJ3AsaC6hH2hoq53mlElKoGlqNzSDVMReRYiop7GJGAicIfZqXfqUZwUJSXKJuxnMrdJSwdARwu05WBiTax/PLSf0v1D2ztYmXpTaq67O5fLuWbOMTr1kRJXhTb/eYhn49AYC9nXJnTjSPJIvM1rvda+14RjoRi9cBL56teQzBFoW0uHPUcfGxp6jLazEvUEoXuyG2Bz5D7m9w8/vDOrqSfz0F9M26uh2MTRVqRLD7e25/PvxUIbfYCefEiacSrgIcRa42TTsNRrRxC4M+uw0Aqtq8ng6rVgsihdWw22/yNLu/GGCkJocOSrjnx1NYjUPoff8zqtkzRpJ1twxu4hh8gxcpwskVfJsvPMKjXKRjpqihzrcLeXLJRQT4CA+oZsrZlLCnba/8FKxZKxBGtlQ5NTNzO6TvyvnRERdNl0jMiga4ZlbHAZ5YqJTBw+2Da7OwUu++Zljx7Z2TV1lLGjU8WBpq6W/dufPc/YeXpwtMZYbXS0RmltNF8FqD7YA9ADh0cPUjSOOOtIvofSnnX84K7H6R4mlbXBBcYWBrWyxPBsGUXvYHB8KL8VYOtkVxcEx8d/2PZAoC9YSPXGbY/vgcFds5TOqdu0WJaf+6Bt7ECxWRnp1xSdsmPTU09TSMW69HZgZ06cOMvo3Pj4HICzDkK1XK461/B/on/CzBxMJOUY1MbG5ik0hjZZW4BujiVa7/8DqqbZ1zdbhV/rXzXQrliusblrXtHHGMzuG1tYsbYooZ1ko39cb8FfONNJRjEx/YBz0OmfAr4ZVVDYAoDPeV95QUn4fvrFl1DAB6LrHAjMA35fIur7/aYXogmf/Qf7GwwOdmcAAAB4nGNgZGBgAOLvE2qd4/ltvjJwszCAwPW4pEkI+v9+zjnMcUAuBwMTSBQAPJALGAB4nGNgZGBgbvjfwBDDpcAABJxzGBgZUAEPAFbGAzwAAHicY2FgYGB+ycDAwoCKmV+g8rkUGBjY3jMwAABErAMXAAAAAAB2ALgA/AF+AYwB1gH4AoICsgOiA8oAAHicY2BkYGDgYZjJwM0AAkxAzAWEDAz/wXwGABl8AccAeJxdkMtOwkAUhv9CQS2JC40m7mZhjNGkXFwY2ZLAngV7KFMuaTvNdCDhaVz6BC5d+hQmbnwR/5YDCzo5p9/5z20yAK7wCw/774a2Zw8+oz3XcIY74Tp1Jezz3As30MKjcJP6i3CAZ7wKt3CNGSd4/gWjJ2yEPZzjXbiGS3wI16l/CvvkL+EGbvEt3KT+Ixxggj/hFh68t2Bg9dTpuZrt1CoyWWwyF5Qw1otNMrUlljbRtliZTHXDThmOdKbtoa/YLnrOxSq2JlVDDtBJYlRuzVpHLlw6l/fb7Vj0MDIprzGAhcYUjn7O55phR79CBIMMceUd6w7KmHULPkfCHntUD/8JsxYF4zJS6CJE55gdMZtVFaf7Cmw5tUfVcaeiWXakpKHcQHNjQlbIq9yaSkQ9xLLqytFHmyc+qQ+r3ek/PzhhdgAAeJxty8EOgyAQRdF5VhCt/UgCUyQlYJhJ9PNt47ZnfS8NdFvovxUDHhhhYDHBYcaCJ1a8CKcV9j1sVo6sYTOys/+42Nse21GdsGquScw7nxxn7b5K8comlO9mU2up8PhLiS4/kxtKAAA=') 4 | format('woff'); 5 | } 6 | 7 | .icon { 8 | font-family: 'icon' !important; 9 | font-size: 16px; 10 | font-style: normal; 11 | -webkit-font-smoothing: antialiased; 12 | -moz-osx-font-smoothing: grayscale; 13 | } 14 | 15 | .icon-search:before { 16 | content: '\e60d'; 17 | } 18 | 19 | .icon-switch:before { 20 | content: '\e798'; 21 | } 22 | 23 | .icon-speak:before { 24 | content: '\e63b'; 25 | } 26 | 27 | .icon-dropdown:before { 28 | content: '\e601'; 29 | } 30 | 31 | .icon-settings:before { 32 | content: '\e724'; 33 | } 34 | 35 | .icon-fixed:before { 36 | content: '\e600'; 37 | } 38 | 39 | .icon-translate:before { 40 | content: '\e8c8'; 41 | } 42 | 43 | .icon-clear:before { 44 | content: '\e635'; 45 | } 46 | 47 | .icon-google:before { 48 | content: '\e616'; 49 | } 50 | 51 | .icon-down:before { 52 | content: '\e602'; 53 | } 54 | -------------------------------------------------------------------------------- /public/i18n/zh-CN/languages.json: -------------------------------------------------------------------------------- 1 | { 2 | "af": "布尔语(南非荷兰语)", 3 | "ar": "阿拉伯语", 4 | "ar-AE": "阿拉伯语(阿联酋)", 5 | "ar-EG": "阿拉伯语(埃及)", 6 | "ar-SA": "阿拉伯语(沙特阿拉伯)", 7 | "auto": "检测语言", 8 | "az": "阿塞拜疆语", 9 | "be": "白俄罗斯语", 10 | "bg": "保加利亚语", 11 | "bn": "孟加拉语", 12 | "bs": "波斯尼亚语", 13 | "ca": "加泰罗尼亚语", 14 | "ceb": "宿务语", 15 | "cs": "捷克语", 16 | "cy": "威尔士语", 17 | "da": "丹麦语", 18 | "de": "德语", 19 | "el": "希腊语", 20 | "en": "英语", 21 | "en-AU": "英语(澳大利亚)", 22 | "en-UK": "英语(英国)", 23 | "en-US": "英语(美国)", 24 | "eo": "世界语", 25 | "es": "西班牙语", 26 | "es-ES": "西班牙语(西班牙)", 27 | "es-MX": "西班牙语(墨西哥)", 28 | "es-US": "西班牙语(美国)", 29 | "et": "爱沙尼亚语", 30 | "eu": "巴斯克语", 31 | "fa": "波斯语", 32 | "fi": "芬兰语", 33 | "fr": "法语", 34 | "fr-CA": "法语(加拿大)", 35 | "fr-FR": "法语", 36 | "ga": "爱尔兰语", 37 | "gl": "加利西亚语", 38 | "gu": "古吉拉特语", 39 | "ha": "豪萨族", 40 | "hi": "印地语", 41 | "hmn": "苗语", 42 | "hr": "克罗地亚语", 43 | "ht": "海地克里奥尔语", 44 | "hu": "匈牙利语", 45 | "hy": "亚美尼亚语", 46 | "id": "印尼语", 47 | "ig": "伊博语", 48 | "is": "冰岛语", 49 | "it": "意大利语", 50 | "iw": "希伯来语", 51 | "ja": "日语", 52 | "jw": "印尼爪哇语", 53 | "ka": "格鲁吉亚语", 54 | "kk": "哈萨克语", 55 | "km": "高棉语", 56 | "kn": "卡纳达语", 57 | "ko": "韩语", 58 | "la": "拉丁语", 59 | "lo": "老挝语", 60 | "lt": "立陶宛语", 61 | "lv": "拉脱维亚语", 62 | "mg": "马尔加什语", 63 | "mi": "毛利语", 64 | "mk": "马其顿语", 65 | "ml": "马拉雅拉姆语", 66 | "mn": "蒙古语", 67 | "mr": "马拉地语", 68 | "ms": "马来语", 69 | "mt": "马耳他语", 70 | "my": "缅甸语", 71 | "ne": "尼泊尔语", 72 | "nl": "荷兰语", 73 | "no": "挪威语", 74 | "ny": "齐切瓦语", 75 | "pa": "旁遮普语", 76 | "pl": "波兰语", 77 | "pt": "葡萄牙语", 78 | "pt-BR": "葡萄牙语(巴西)", 79 | "pt-PT": "葡萄牙语", 80 | "ro": "罗马尼亚语", 81 | "ru": "俄语", 82 | "si": "僧伽罗语", 83 | "sk": "斯洛伐克语", 84 | "sl": "斯洛文尼亚语", 85 | "so": "索马里", 86 | "sq": "阿尔巴尼亚语", 87 | "sr": "塞尔维亚语", 88 | "st": "塞索托语", 89 | "su": "印尼巽他语", 90 | "sv": "瑞典语", 91 | "sw": "斯瓦希里语", 92 | "ta": "泰米尔语", 93 | "te": "泰卢固语", 94 | "tg": "塔吉克语", 95 | "th": "泰语", 96 | "tl": "菲律宾语", 97 | "tr": "土耳其语", 98 | "uk": "乌克兰语", 99 | "ur": "乌尔都语", 100 | "uz": "乌兹别克语", 101 | "vi": "越南语", 102 | "yi": "意第绪语", 103 | "yo": "约鲁巴语", 104 | "zh-CN": "中文(简体)", 105 | "zh-HK": "中文(粤语)", 106 | "zh-TW": "中文(繁体)", 107 | "zu": "祖鲁语" 108 | } 109 | -------------------------------------------------------------------------------- /public/icon.icns: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MoeFE/GoogleTranslate/312282049236e65e3d443f0fc24f7f782022be0a/public/icon.icns -------------------------------------------------------------------------------- /public/iconTemplate.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MoeFE/GoogleTranslate/312282049236e65e3d443f0fc24f7f782022be0a/public/iconTemplate.ico -------------------------------------------------------------------------------- /public/iconTemplate@2x.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MoeFE/GoogleTranslate/312282049236e65e3d443f0fc24f7f782022be0a/public/iconTemplate@2x.ico -------------------------------------------------------------------------------- /public/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | <% if (BASE_URL === './') { %><% } %> 5 | 6 | 7 | 8 | Google Translate 9 | 10 | 11 |
12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /src/index.js: -------------------------------------------------------------------------------- 1 | const path = require('path'); 2 | const download = require('download'); 3 | const { languages } = require('./renderer/assets/languages.json'); 4 | 5 | Promise.all( 6 | languages 7 | .map(x => x.dialects.map(v => v.flag_image_2x)) 8 | .toString() 9 | .split(',') 10 | .map(url => download(url, 'src/renderer/assets/img')), 11 | ).then(() => { 12 | console.log('files downloaded!'); 13 | }); 14 | -------------------------------------------------------------------------------- /src/main/checkForUpdates.js: -------------------------------------------------------------------------------- 1 | import { shell, Notification } from 'electron'; 2 | import download from 'download'; 3 | import pkg from '../../package.json'; 4 | 5 | export default async function checkForUpdates() { 6 | const url = 'https://api.github.com/repos/MoeFE/GoogleTranslate/releases/latest'; // prettier-ignore 7 | const release = await download(url).then(res => JSON.parse(res.toString())); 8 | if (release.name > pkg.version) { 9 | const notice = new Notification({ 10 | title: 'Google 翻译', 11 | body: `发现新版本 (${release.name}) 可用,点击下载最新版本!`, 12 | }); 13 | notice.on('click', () => shell.openExternal(url)); 14 | notice.show(); 15 | return true; 16 | } 17 | return false; 18 | } 19 | -------------------------------------------------------------------------------- /src/main/index.js: -------------------------------------------------------------------------------- 1 | import { 2 | app, 3 | protocol, 4 | systemPreferences, 5 | ipcMain, 6 | Menu, 7 | MenuItem, 8 | clipboard, 9 | } from 'electron'; 10 | import { format as formatUrl } from 'url'; 11 | import path from 'path'; 12 | import robotjs from 'robotjs'; 13 | import { 14 | createProtocol, 15 | installVueDevtools, 16 | } from 'vue-cli-plugin-electron-builder/lib'; 17 | import menubar from './lib/menubar'; 18 | import checkForUpdates from './checkForUpdates'; 19 | 20 | const isDevelopment = process.env.NODE_ENV !== 'production'; 21 | 22 | // global reference to mainWindow (necessary to prevent window from being garbage collected) 23 | let mainWindow; 24 | 25 | // Standard scheme must be registered before the app is ready 26 | protocol.registerStandardSchemes(['app'], { secure: true }); 27 | 28 | function createMainWindow() { 29 | // https://electronjs.org/docs/api/browser-window 30 | const mb = menubar({ 31 | title: 'Google Translate', 32 | icon: path.join(__static, 'iconTemplate.ico'), // https://electronjs.org/docs/api/native-image 33 | index: isDevelopment 34 | ? process.env.WEBPACK_DEV_SERVER_URL 35 | : formatUrl({ 36 | pathname: path.join(__dirname, 'index.html'), 37 | protocol: 'file', 38 | slashes: true, 39 | }), 40 | height: 190, 41 | width: 420, 42 | hasShadow: false, 43 | resizable: false, 44 | minimizable: false, 45 | maximizable: false, 46 | showDockIcon: isDevelopment, 47 | transparent: true, 48 | alwaysOnTop: true, 49 | preloadWindow: true, 50 | webPreferences: { 51 | scrollBounce: true, 52 | webSecurity: false, 53 | allowRunningInsecureContent: true, 54 | }, 55 | }); 56 | 57 | const { window, tray } = mb; 58 | const { webContents } = window; 59 | 60 | systemPreferences.setUserDefault( 61 | 'AppleShowScrollBars', 62 | 'string', 63 | 'Automatic', 64 | ); 65 | 66 | if (!isDevelopment) { 67 | const menu = new Menu(); 68 | menu.append( 69 | new MenuItem({ 70 | role: 'about', 71 | submenu: [{ role: 'toggledevtools' }], 72 | }), 73 | ); 74 | menu.append(new MenuItem({ role: 'editMenu' })); 75 | Menu.setApplicationMenu(menu); 76 | createProtocol('app'); 77 | } 78 | 79 | ipcMain.on('show-window', () => { 80 | mb.showWindow(tray.getBounds()); 81 | }); 82 | 83 | ipcMain.on('hide-window', () => { 84 | mb.hideWindow(); 85 | }); 86 | 87 | ipcMain.on('translate-selection', async () => { 88 | const oldString = clipboard.readText(); 89 | robotjs.keyTap('c', 'command'); // Invalid when no selection text 90 | await new Promise(resolve => setTimeout(resolve, 100)); 91 | const newString = clipboard.readText(); 92 | clipboard.writeText(oldString); 93 | mb.showWindow(); 94 | webContents.send('translate-clipboard-text', newString.trim()); 95 | }); 96 | 97 | if (isDevelopment && !process.env.IS_TEST) { 98 | webContents.openDevTools({ mode: 'undocked' }); 99 | } 100 | 101 | webContents.session.webRequest.onBeforeSendHeaders((detail, cb) => { 102 | const { url, requestHeaders } = detail; 103 | if (url.includes('fanyi.youdao.com')) { 104 | requestHeaders.Referer = 'http://fanyi.youdao.com'; 105 | } else delete requestHeaders.Referer; 106 | cb({ requestHeaders }); 107 | }); 108 | 109 | window.on('closed', () => { 110 | mainWindow = null; 111 | }); 112 | 113 | webContents.on('did-finish-load', () => { 114 | webContents.setZoomFactor(1); 115 | webContents.setVisualZoomLevelLimits(1, 1); 116 | webContents.setLayoutZoomLevelLimits(0, 0); 117 | }); 118 | 119 | webContents.on('devtools-opened', () => { 120 | window.focus(); 121 | setImmediate(() => { 122 | window.focus(); 123 | }); 124 | }); 125 | 126 | mb.on('after-show', () => { 127 | window.focus(); 128 | }); 129 | 130 | return mb; 131 | } 132 | 133 | // quit application when all windows are closed 134 | app.on('window-all-closed', () => { 135 | // on macOS it is common for applications to stay open until the user explicitly quits 136 | if (process.platform !== 'darwin') { 137 | app.quit(); 138 | } 139 | }); 140 | 141 | app.on('activate', () => { 142 | // on macOS it is common to re-create a window even after all windows have been closed 143 | if (mainWindow === null) { 144 | mainWindow = createMainWindow(); 145 | } 146 | }); 147 | 148 | // create main BrowserWindow when electron is ready 149 | app.on('ready', async () => { 150 | try { 151 | if (isDevelopment && !process.env.IS_TEST) { 152 | // Install Vue Devtools 153 | await installVueDevtools(); 154 | } else { 155 | // Check for updates 156 | checkForUpdates(); // do not await 157 | ipcMain.on('check-for-updates', async (event, arg) => { 158 | event.sender.send('check-for-updates', await checkForUpdates()); 159 | }); 160 | } 161 | } finally { 162 | mainWindow = createMainWindow(); 163 | } 164 | }); 165 | -------------------------------------------------------------------------------- /src/main/lib/menubar/index.d.ts: -------------------------------------------------------------------------------- 1 | // Type definitions for menubar 5.1.0 2 | // Project: https://github.com/maxogden/menubar 3 | // Definitions by: rhysd 4 | // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped 5 | // TypeScript Version: 2.3 6 | 7 | // / 8 | // / 9 | 10 | declare namespace Menubar { 11 | type Position = 12 | | 'trayLeft' 13 | | 'trayBottomLeft' 14 | | 'trayRight' 15 | | 'trayBottomRight' 16 | | 'trayCenter' 17 | | 'trayBottomCenter' 18 | | 'topLeft' 19 | | 'topRight' 20 | | 'bottomLeft' 21 | | 'bottomRight' 22 | | 'topCenter' 23 | | 'bottomCenter' 24 | | 'center'; 25 | type TrayBounds = 26 | | 'trayLeft' 27 | | 'trayBottomLeft' 28 | | 'trayRight' 29 | | 'trayBottomRight' 30 | | 'trayCenter' 31 | | 'trayBottomCenter'; 32 | interface ElectronPositioner { 33 | move(pos: Position): void; 34 | calculate(pos: Position, bounds?: TrayBounds): Electron.Point; 35 | } 36 | class MenubarApp extends NodeJS.EventEmitter { 37 | app: Electron.App; 38 | window: Electron.BrowserWindow; 39 | tray: Electron.Tray; 40 | positioner: ElectronPositioner; 41 | 42 | setOption(opt: string, value: any): void; 43 | getOption(opt: string): any; 44 | showWindow(): void; 45 | hideWindow(): void; 46 | } 47 | interface MenubarOptions extends Electron.BrowserWindowConstructorOptions { 48 | dir?: string; 49 | index?: string; 50 | tooltip?: string; 51 | tray?: Electron.Tray; 52 | preloadWindow?: boolean; 53 | alwaysOnTop?: boolean; 54 | showOnAllWorkspaces?: boolean; 55 | windowPosition?: Position; 56 | showDockIcon?: boolean; 57 | showOnRightClick?: boolean; 58 | } 59 | } 60 | 61 | export default function(opts?: Menubar.MenubarOptions): Menubar.MenubarApp; 62 | -------------------------------------------------------------------------------- /src/main/lib/menubar/index.js: -------------------------------------------------------------------------------- 1 | /* eslint-disable */ 2 | const path = require('path'); 3 | const events = require('events'); 4 | const fs = require('fs'); 5 | 6 | const electron = require('electron'); 7 | 8 | const app = electron.app; 9 | const Tray = electron.Tray; 10 | const BrowserWindow = electron.BrowserWindow; 11 | 12 | const extend = require('extend'); 13 | const Positioner = require('electron-positioner'); 14 | 15 | module.exports = function create(opts) { 16 | if (typeof opts === 'undefined') opts = { dir: app.getAppPath() }; 17 | if (typeof opts === 'string') opts = { dir: opts }; 18 | if (!opts.dir) opts.dir = app.getAppPath(); 19 | if (!path.isAbsolute(opts.dir)) opts.dir = path.resolve(opts.dir); 20 | if (!opts.index) opts.index = `file://${path.join(opts.dir, 'index.html')}`; 21 | if (!opts.windowPosition) { 22 | opts.windowPosition = 23 | process.platform === 'win32' ? 'trayBottomCenter' : 'trayCenter'; 24 | } 25 | if (typeof opts.showDockIcon === 'undefined') opts.showDockIcon = false; 26 | 27 | // set width/height on opts to be usable before the window is created 28 | opts.width = opts.width || 400; 29 | opts.height = opts.height || 400; 30 | opts.tooltip = opts.tooltip || ''; 31 | 32 | const menubar = new events.EventEmitter(); 33 | menubar.app = app; 34 | 35 | if (app.isReady()) appReady(); 36 | else app.on('ready', appReady); 37 | 38 | // Set / get options 39 | menubar.setOption = function(opt, val) { 40 | opts[opt] = val; 41 | }; 42 | 43 | menubar.getOption = function(opt) { 44 | return opts[opt]; 45 | }; 46 | 47 | return menubar; 48 | 49 | function appReady() { 50 | if (app.dock && !opts.showDockIcon) app.dock.hide(); 51 | 52 | let iconPath = opts.icon || path.join(opts.dir, 'IconTemplate.png'); 53 | if (!fs.existsSync(iconPath)) { 54 | iconPath = path.join(__dirname, 'example', 'IconTemplate.png'); 55 | } // default cat icon 56 | 57 | let cachedBounds; // cachedBounds are needed for double-clicked event 58 | const defaultClickEvent = opts.showOnRightClick ? 'right-click' : 'click'; 59 | 60 | menubar.tray = opts.tray || new Tray(iconPath); 61 | menubar.tray.on(defaultClickEvent, clicked); 62 | menubar.tray.on('double-click', clicked); 63 | menubar.tray.setToolTip(opts.tooltip); 64 | 65 | // let supportsTrayHighlightState = false; 66 | // try { 67 | // menubar.tray.setHighlightMode('never'); 68 | // supportsTrayHighlightState = true; 69 | // } catch (e) {} 70 | 71 | if (opts.preloadWindow) { 72 | createWindow(); 73 | } 74 | 75 | menubar.showWindow = showWindow; 76 | menubar.hideWindow = hideWindow; 77 | menubar.emit('ready'); 78 | 79 | function clicked(e, bounds) { 80 | if (e.altKey || e.shiftKey || e.ctrlKey || e.metaKey) return hideWindow(); 81 | if (menubar.window && menubar.window.isVisible()) return hideWindow(); 82 | cachedBounds = bounds || cachedBounds; 83 | showWindow(cachedBounds); 84 | } 85 | 86 | function createWindow() { 87 | menubar.emit('create-window'); 88 | const defaults = { 89 | show: false, 90 | frame: false, 91 | }; 92 | 93 | const winOpts = extend(defaults, opts); 94 | menubar.window = new BrowserWindow(winOpts); 95 | menubar.positioner = new Positioner(menubar.window); 96 | 97 | menubar.window.on('blur', () => { 98 | menubar.window.isAlwaysOnTop() ? emitBlur() : hideWindow(); 99 | }); 100 | 101 | if (opts.showOnAllWorkspaces !== false) { 102 | menubar.window.setVisibleOnAllWorkspaces(true); 103 | } 104 | 105 | menubar.window.on('close', windowClear); 106 | menubar.window.loadURL(opts.index); 107 | menubar.emit('after-create-window'); 108 | } 109 | 110 | function showWindow(trayPos) { 111 | // if (supportsTrayHighlightState) menubar.tray.setHighlightMode('always'); 112 | if (!menubar.window) { 113 | createWindow(); 114 | } 115 | 116 | menubar.emit('show'); 117 | 118 | if (trayPos && trayPos.x !== 0) { 119 | // Cache the bounds 120 | cachedBounds = trayPos; 121 | } else if (cachedBounds) { 122 | // Cached value will be used if showWindow is called without bounds data 123 | trayPos = cachedBounds; 124 | } else if (menubar.tray.getBounds) { 125 | // Get the current tray bounds 126 | trayPos = menubar.tray.getBounds(); 127 | } 128 | 129 | // Default the window to the right if `trayPos` bounds are undefined or null. 130 | let noBoundsPosition = null; 131 | if ( 132 | (trayPos === undefined || trayPos.x === 0) && 133 | opts.windowPosition.substr(0, 4) === 'tray' 134 | ) { 135 | noBoundsPosition = 136 | process.platform === 'win32' ? 'bottomRight' : 'topRight'; 137 | } 138 | 139 | const position = menubar.positioner.calculate( 140 | noBoundsPosition || opts.windowPosition, 141 | trayPos 142 | ); 143 | 144 | const x = opts.x !== undefined ? opts.x : position.x; 145 | const y = opts.y !== undefined ? opts.y : position.y; 146 | 147 | menubar.window.setPosition(x, y); 148 | menubar.window.show(); 149 | menubar.emit('after-show'); 150 | } 151 | 152 | function hideWindow() { 153 | // if (supportsTrayHighlightState) menubar.tray.setHighlightMode('never'); 154 | if (!menubar.window) return; 155 | menubar.emit('hide'); 156 | menubar.window.hide(); 157 | if (!menubar.window.webContents.isDevToolsOpened()) app.hide(); 158 | menubar.emit('after-hide'); 159 | } 160 | 161 | function windowClear() { 162 | delete menubar.window; 163 | menubar.emit('after-close'); 164 | } 165 | 166 | function emitBlur() { 167 | menubar.emit('focus-lost'); 168 | } 169 | } 170 | }; 171 | -------------------------------------------------------------------------------- /src/renderer/App.tsx: -------------------------------------------------------------------------------- 1 | import { ipcRenderer } from 'electron'; 2 | 3 | import Vue from 'vue'; 4 | import Comopnent from 'vue-class-component'; 5 | import { injectGlobal } from 'vue-emotion'; 6 | import LocaleProvider from 'components/LocaleProvider'; 7 | 8 | // eslint-disable-next-line no-unused-expressions 9 | injectGlobal` 10 | * { 11 | backface-visibility: hidden; 12 | box-sizing: border-box; 13 | } 14 | html, 15 | body, 16 | #app { 17 | height: 100%; 18 | } 19 | html { 20 | -webkit-font-smoothing: antialiased; 21 | -webkit-user-drag: none; 22 | user-select: none; 23 | font-family: -apple-system, BlinkMacSystemFont, Segoe UI, Roboto, Ubuntu, 24 | Helvetica Neue, sans-serif; 25 | font-weight: 300; 26 | cursor: default; 27 | } 28 | body { 29 | margin: 0; 30 | overflow: hidden; 31 | } 32 | #app { 33 | &:before { 34 | content: '\\e601'; 35 | display: block; 36 | color: #4286f5; 37 | font-family: icon; 38 | font-size: 32px; 39 | text-align: center; 40 | line-height: 0.3; 41 | transform: rotate(180deg); 42 | } 43 | } 44 | `; 45 | 46 | @Comopnent 47 | export default class App extends Vue { 48 | private keymap = { 49 | esc: this.handleEscape, 50 | }; 51 | 52 | private handleEscape() { 53 | if (this.$route.name === 'translate') { 54 | ipcRenderer.send('hide-window'); 55 | } else { 56 | this.$router.push('/'); 57 | } 58 | } 59 | 60 | created() { 61 | document.addEventListener('mouseenter', () => { 62 | ipcRenderer.send('show-window'); 63 | }); 64 | } 65 | 66 | render() { 67 | return ( 68 | 69 | 70 | 71 | 72 | 73 | ); 74 | } 75 | } 76 | -------------------------------------------------------------------------------- /src/renderer/assets/img/af-2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MoeFE/GoogleTranslate/312282049236e65e3d443f0fc24f7f782022be0a/src/renderer/assets/img/af-2x.png -------------------------------------------------------------------------------- /src/renderer/assets/img/ar-AE-2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MoeFE/GoogleTranslate/312282049236e65e3d443f0fc24f7f782022be0a/src/renderer/assets/img/ar-AE-2x.png -------------------------------------------------------------------------------- /src/renderer/assets/img/ar-EG-2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MoeFE/GoogleTranslate/312282049236e65e3d443f0fc24f7f782022be0a/src/renderer/assets/img/ar-EG-2x.png -------------------------------------------------------------------------------- /src/renderer/assets/img/ar-SA-2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MoeFE/GoogleTranslate/312282049236e65e3d443f0fc24f7f782022be0a/src/renderer/assets/img/ar-SA-2x.png -------------------------------------------------------------------------------- /src/renderer/assets/img/auto-2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MoeFE/GoogleTranslate/312282049236e65e3d443f0fc24f7f782022be0a/src/renderer/assets/img/auto-2x.png -------------------------------------------------------------------------------- /src/renderer/assets/img/az-2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MoeFE/GoogleTranslate/312282049236e65e3d443f0fc24f7f782022be0a/src/renderer/assets/img/az-2x.png -------------------------------------------------------------------------------- /src/renderer/assets/img/be-2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MoeFE/GoogleTranslate/312282049236e65e3d443f0fc24f7f782022be0a/src/renderer/assets/img/be-2x.png -------------------------------------------------------------------------------- /src/renderer/assets/img/bg-2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MoeFE/GoogleTranslate/312282049236e65e3d443f0fc24f7f782022be0a/src/renderer/assets/img/bg-2x.png -------------------------------------------------------------------------------- /src/renderer/assets/img/bn-2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MoeFE/GoogleTranslate/312282049236e65e3d443f0fc24f7f782022be0a/src/renderer/assets/img/bn-2x.png -------------------------------------------------------------------------------- /src/renderer/assets/img/bs-2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MoeFE/GoogleTranslate/312282049236e65e3d443f0fc24f7f782022be0a/src/renderer/assets/img/bs-2x.png -------------------------------------------------------------------------------- /src/renderer/assets/img/ca-2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MoeFE/GoogleTranslate/312282049236e65e3d443f0fc24f7f782022be0a/src/renderer/assets/img/ca-2x.png -------------------------------------------------------------------------------- /src/renderer/assets/img/ceb-2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MoeFE/GoogleTranslate/312282049236e65e3d443f0fc24f7f782022be0a/src/renderer/assets/img/ceb-2x.png -------------------------------------------------------------------------------- /src/renderer/assets/img/cs-2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MoeFE/GoogleTranslate/312282049236e65e3d443f0fc24f7f782022be0a/src/renderer/assets/img/cs-2x.png -------------------------------------------------------------------------------- /src/renderer/assets/img/cy-2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MoeFE/GoogleTranslate/312282049236e65e3d443f0fc24f7f782022be0a/src/renderer/assets/img/cy-2x.png -------------------------------------------------------------------------------- /src/renderer/assets/img/da-2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MoeFE/GoogleTranslate/312282049236e65e3d443f0fc24f7f782022be0a/src/renderer/assets/img/da-2x.png -------------------------------------------------------------------------------- /src/renderer/assets/img/de-2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MoeFE/GoogleTranslate/312282049236e65e3d443f0fc24f7f782022be0a/src/renderer/assets/img/de-2x.png -------------------------------------------------------------------------------- /src/renderer/assets/img/el-2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MoeFE/GoogleTranslate/312282049236e65e3d443f0fc24f7f782022be0a/src/renderer/assets/img/el-2x.png -------------------------------------------------------------------------------- /src/renderer/assets/img/en-AU-2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MoeFE/GoogleTranslate/312282049236e65e3d443f0fc24f7f782022be0a/src/renderer/assets/img/en-AU-2x.png -------------------------------------------------------------------------------- /src/renderer/assets/img/en-UK-2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MoeFE/GoogleTranslate/312282049236e65e3d443f0fc24f7f782022be0a/src/renderer/assets/img/en-UK-2x.png -------------------------------------------------------------------------------- /src/renderer/assets/img/en-US-2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MoeFE/GoogleTranslate/312282049236e65e3d443f0fc24f7f782022be0a/src/renderer/assets/img/en-US-2x.png -------------------------------------------------------------------------------- /src/renderer/assets/img/eo-2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MoeFE/GoogleTranslate/312282049236e65e3d443f0fc24f7f782022be0a/src/renderer/assets/img/eo-2x.png -------------------------------------------------------------------------------- /src/renderer/assets/img/es-ES-2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MoeFE/GoogleTranslate/312282049236e65e3d443f0fc24f7f782022be0a/src/renderer/assets/img/es-ES-2x.png -------------------------------------------------------------------------------- /src/renderer/assets/img/es-MX-2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MoeFE/GoogleTranslate/312282049236e65e3d443f0fc24f7f782022be0a/src/renderer/assets/img/es-MX-2x.png -------------------------------------------------------------------------------- /src/renderer/assets/img/es-US-2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MoeFE/GoogleTranslate/312282049236e65e3d443f0fc24f7f782022be0a/src/renderer/assets/img/es-US-2x.png -------------------------------------------------------------------------------- /src/renderer/assets/img/et-2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MoeFE/GoogleTranslate/312282049236e65e3d443f0fc24f7f782022be0a/src/renderer/assets/img/et-2x.png -------------------------------------------------------------------------------- /src/renderer/assets/img/eu-2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MoeFE/GoogleTranslate/312282049236e65e3d443f0fc24f7f782022be0a/src/renderer/assets/img/eu-2x.png -------------------------------------------------------------------------------- /src/renderer/assets/img/fa-2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MoeFE/GoogleTranslate/312282049236e65e3d443f0fc24f7f782022be0a/src/renderer/assets/img/fa-2x.png -------------------------------------------------------------------------------- /src/renderer/assets/img/fi-2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MoeFE/GoogleTranslate/312282049236e65e3d443f0fc24f7f782022be0a/src/renderer/assets/img/fi-2x.png -------------------------------------------------------------------------------- /src/renderer/assets/img/fr-CA-2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MoeFE/GoogleTranslate/312282049236e65e3d443f0fc24f7f782022be0a/src/renderer/assets/img/fr-CA-2x.png -------------------------------------------------------------------------------- /src/renderer/assets/img/fr-FR-2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MoeFE/GoogleTranslate/312282049236e65e3d443f0fc24f7f782022be0a/src/renderer/assets/img/fr-FR-2x.png -------------------------------------------------------------------------------- /src/renderer/assets/img/ga-2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MoeFE/GoogleTranslate/312282049236e65e3d443f0fc24f7f782022be0a/src/renderer/assets/img/ga-2x.png -------------------------------------------------------------------------------- /src/renderer/assets/img/gl-2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MoeFE/GoogleTranslate/312282049236e65e3d443f0fc24f7f782022be0a/src/renderer/assets/img/gl-2x.png -------------------------------------------------------------------------------- /src/renderer/assets/img/gu-2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MoeFE/GoogleTranslate/312282049236e65e3d443f0fc24f7f782022be0a/src/renderer/assets/img/gu-2x.png -------------------------------------------------------------------------------- /src/renderer/assets/img/ha-2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MoeFE/GoogleTranslate/312282049236e65e3d443f0fc24f7f782022be0a/src/renderer/assets/img/ha-2x.png -------------------------------------------------------------------------------- /src/renderer/assets/img/hi-2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MoeFE/GoogleTranslate/312282049236e65e3d443f0fc24f7f782022be0a/src/renderer/assets/img/hi-2x.png -------------------------------------------------------------------------------- /src/renderer/assets/img/hmn-2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MoeFE/GoogleTranslate/312282049236e65e3d443f0fc24f7f782022be0a/src/renderer/assets/img/hmn-2x.png -------------------------------------------------------------------------------- /src/renderer/assets/img/hr-2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MoeFE/GoogleTranslate/312282049236e65e3d443f0fc24f7f782022be0a/src/renderer/assets/img/hr-2x.png -------------------------------------------------------------------------------- /src/renderer/assets/img/ht-2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MoeFE/GoogleTranslate/312282049236e65e3d443f0fc24f7f782022be0a/src/renderer/assets/img/ht-2x.png -------------------------------------------------------------------------------- /src/renderer/assets/img/hu-2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MoeFE/GoogleTranslate/312282049236e65e3d443f0fc24f7f782022be0a/src/renderer/assets/img/hu-2x.png -------------------------------------------------------------------------------- /src/renderer/assets/img/hy-2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MoeFE/GoogleTranslate/312282049236e65e3d443f0fc24f7f782022be0a/src/renderer/assets/img/hy-2x.png -------------------------------------------------------------------------------- /src/renderer/assets/img/id-2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MoeFE/GoogleTranslate/312282049236e65e3d443f0fc24f7f782022be0a/src/renderer/assets/img/id-2x.png -------------------------------------------------------------------------------- /src/renderer/assets/img/ig-2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MoeFE/GoogleTranslate/312282049236e65e3d443f0fc24f7f782022be0a/src/renderer/assets/img/ig-2x.png -------------------------------------------------------------------------------- /src/renderer/assets/img/is-2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MoeFE/GoogleTranslate/312282049236e65e3d443f0fc24f7f782022be0a/src/renderer/assets/img/is-2x.png -------------------------------------------------------------------------------- /src/renderer/assets/img/it-2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MoeFE/GoogleTranslate/312282049236e65e3d443f0fc24f7f782022be0a/src/renderer/assets/img/it-2x.png -------------------------------------------------------------------------------- /src/renderer/assets/img/iw-2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MoeFE/GoogleTranslate/312282049236e65e3d443f0fc24f7f782022be0a/src/renderer/assets/img/iw-2x.png -------------------------------------------------------------------------------- /src/renderer/assets/img/ja-2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MoeFE/GoogleTranslate/312282049236e65e3d443f0fc24f7f782022be0a/src/renderer/assets/img/ja-2x.png -------------------------------------------------------------------------------- /src/renderer/assets/img/jw-2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MoeFE/GoogleTranslate/312282049236e65e3d443f0fc24f7f782022be0a/src/renderer/assets/img/jw-2x.png -------------------------------------------------------------------------------- /src/renderer/assets/img/ka-2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MoeFE/GoogleTranslate/312282049236e65e3d443f0fc24f7f782022be0a/src/renderer/assets/img/ka-2x.png -------------------------------------------------------------------------------- /src/renderer/assets/img/kk-2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MoeFE/GoogleTranslate/312282049236e65e3d443f0fc24f7f782022be0a/src/renderer/assets/img/kk-2x.png -------------------------------------------------------------------------------- /src/renderer/assets/img/km-2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MoeFE/GoogleTranslate/312282049236e65e3d443f0fc24f7f782022be0a/src/renderer/assets/img/km-2x.png -------------------------------------------------------------------------------- /src/renderer/assets/img/kn-2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MoeFE/GoogleTranslate/312282049236e65e3d443f0fc24f7f782022be0a/src/renderer/assets/img/kn-2x.png -------------------------------------------------------------------------------- /src/renderer/assets/img/ko-2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MoeFE/GoogleTranslate/312282049236e65e3d443f0fc24f7f782022be0a/src/renderer/assets/img/ko-2x.png -------------------------------------------------------------------------------- /src/renderer/assets/img/la-2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MoeFE/GoogleTranslate/312282049236e65e3d443f0fc24f7f782022be0a/src/renderer/assets/img/la-2x.png -------------------------------------------------------------------------------- /src/renderer/assets/img/lo-2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MoeFE/GoogleTranslate/312282049236e65e3d443f0fc24f7f782022be0a/src/renderer/assets/img/lo-2x.png -------------------------------------------------------------------------------- /src/renderer/assets/img/lt-2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MoeFE/GoogleTranslate/312282049236e65e3d443f0fc24f7f782022be0a/src/renderer/assets/img/lt-2x.png -------------------------------------------------------------------------------- /src/renderer/assets/img/lv-2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MoeFE/GoogleTranslate/312282049236e65e3d443f0fc24f7f782022be0a/src/renderer/assets/img/lv-2x.png -------------------------------------------------------------------------------- /src/renderer/assets/img/mg-2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MoeFE/GoogleTranslate/312282049236e65e3d443f0fc24f7f782022be0a/src/renderer/assets/img/mg-2x.png -------------------------------------------------------------------------------- /src/renderer/assets/img/mi-2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MoeFE/GoogleTranslate/312282049236e65e3d443f0fc24f7f782022be0a/src/renderer/assets/img/mi-2x.png -------------------------------------------------------------------------------- /src/renderer/assets/img/mk-2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MoeFE/GoogleTranslate/312282049236e65e3d443f0fc24f7f782022be0a/src/renderer/assets/img/mk-2x.png -------------------------------------------------------------------------------- /src/renderer/assets/img/ml-2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MoeFE/GoogleTranslate/312282049236e65e3d443f0fc24f7f782022be0a/src/renderer/assets/img/ml-2x.png -------------------------------------------------------------------------------- /src/renderer/assets/img/mn-2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MoeFE/GoogleTranslate/312282049236e65e3d443f0fc24f7f782022be0a/src/renderer/assets/img/mn-2x.png -------------------------------------------------------------------------------- /src/renderer/assets/img/mr-2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MoeFE/GoogleTranslate/312282049236e65e3d443f0fc24f7f782022be0a/src/renderer/assets/img/mr-2x.png -------------------------------------------------------------------------------- /src/renderer/assets/img/ms-2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MoeFE/GoogleTranslate/312282049236e65e3d443f0fc24f7f782022be0a/src/renderer/assets/img/ms-2x.png -------------------------------------------------------------------------------- /src/renderer/assets/img/mt-2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MoeFE/GoogleTranslate/312282049236e65e3d443f0fc24f7f782022be0a/src/renderer/assets/img/mt-2x.png -------------------------------------------------------------------------------- /src/renderer/assets/img/my-2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MoeFE/GoogleTranslate/312282049236e65e3d443f0fc24f7f782022be0a/src/renderer/assets/img/my-2x.png -------------------------------------------------------------------------------- /src/renderer/assets/img/ne-2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MoeFE/GoogleTranslate/312282049236e65e3d443f0fc24f7f782022be0a/src/renderer/assets/img/ne-2x.png -------------------------------------------------------------------------------- /src/renderer/assets/img/nl-2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MoeFE/GoogleTranslate/312282049236e65e3d443f0fc24f7f782022be0a/src/renderer/assets/img/nl-2x.png -------------------------------------------------------------------------------- /src/renderer/assets/img/no-2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MoeFE/GoogleTranslate/312282049236e65e3d443f0fc24f7f782022be0a/src/renderer/assets/img/no-2x.png -------------------------------------------------------------------------------- /src/renderer/assets/img/ny-2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MoeFE/GoogleTranslate/312282049236e65e3d443f0fc24f7f782022be0a/src/renderer/assets/img/ny-2x.png -------------------------------------------------------------------------------- /src/renderer/assets/img/pa-2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MoeFE/GoogleTranslate/312282049236e65e3d443f0fc24f7f782022be0a/src/renderer/assets/img/pa-2x.png -------------------------------------------------------------------------------- /src/renderer/assets/img/pl-2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MoeFE/GoogleTranslate/312282049236e65e3d443f0fc24f7f782022be0a/src/renderer/assets/img/pl-2x.png -------------------------------------------------------------------------------- /src/renderer/assets/img/pt-BR-2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MoeFE/GoogleTranslate/312282049236e65e3d443f0fc24f7f782022be0a/src/renderer/assets/img/pt-BR-2x.png -------------------------------------------------------------------------------- /src/renderer/assets/img/pt-PT-2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MoeFE/GoogleTranslate/312282049236e65e3d443f0fc24f7f782022be0a/src/renderer/assets/img/pt-PT-2x.png -------------------------------------------------------------------------------- /src/renderer/assets/img/ro-2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MoeFE/GoogleTranslate/312282049236e65e3d443f0fc24f7f782022be0a/src/renderer/assets/img/ro-2x.png -------------------------------------------------------------------------------- /src/renderer/assets/img/ru-2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MoeFE/GoogleTranslate/312282049236e65e3d443f0fc24f7f782022be0a/src/renderer/assets/img/ru-2x.png -------------------------------------------------------------------------------- /src/renderer/assets/img/si-2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MoeFE/GoogleTranslate/312282049236e65e3d443f0fc24f7f782022be0a/src/renderer/assets/img/si-2x.png -------------------------------------------------------------------------------- /src/renderer/assets/img/sk-2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MoeFE/GoogleTranslate/312282049236e65e3d443f0fc24f7f782022be0a/src/renderer/assets/img/sk-2x.png -------------------------------------------------------------------------------- /src/renderer/assets/img/sl-2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MoeFE/GoogleTranslate/312282049236e65e3d443f0fc24f7f782022be0a/src/renderer/assets/img/sl-2x.png -------------------------------------------------------------------------------- /src/renderer/assets/img/so-2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MoeFE/GoogleTranslate/312282049236e65e3d443f0fc24f7f782022be0a/src/renderer/assets/img/so-2x.png -------------------------------------------------------------------------------- /src/renderer/assets/img/sq-2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MoeFE/GoogleTranslate/312282049236e65e3d443f0fc24f7f782022be0a/src/renderer/assets/img/sq-2x.png -------------------------------------------------------------------------------- /src/renderer/assets/img/sr-2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MoeFE/GoogleTranslate/312282049236e65e3d443f0fc24f7f782022be0a/src/renderer/assets/img/sr-2x.png -------------------------------------------------------------------------------- /src/renderer/assets/img/st-2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MoeFE/GoogleTranslate/312282049236e65e3d443f0fc24f7f782022be0a/src/renderer/assets/img/st-2x.png -------------------------------------------------------------------------------- /src/renderer/assets/img/su-2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MoeFE/GoogleTranslate/312282049236e65e3d443f0fc24f7f782022be0a/src/renderer/assets/img/su-2x.png -------------------------------------------------------------------------------- /src/renderer/assets/img/sv-2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MoeFE/GoogleTranslate/312282049236e65e3d443f0fc24f7f782022be0a/src/renderer/assets/img/sv-2x.png -------------------------------------------------------------------------------- /src/renderer/assets/img/sw-2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MoeFE/GoogleTranslate/312282049236e65e3d443f0fc24f7f782022be0a/src/renderer/assets/img/sw-2x.png -------------------------------------------------------------------------------- /src/renderer/assets/img/ta-2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MoeFE/GoogleTranslate/312282049236e65e3d443f0fc24f7f782022be0a/src/renderer/assets/img/ta-2x.png -------------------------------------------------------------------------------- /src/renderer/assets/img/te-2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MoeFE/GoogleTranslate/312282049236e65e3d443f0fc24f7f782022be0a/src/renderer/assets/img/te-2x.png -------------------------------------------------------------------------------- /src/renderer/assets/img/tg-2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MoeFE/GoogleTranslate/312282049236e65e3d443f0fc24f7f782022be0a/src/renderer/assets/img/tg-2x.png -------------------------------------------------------------------------------- /src/renderer/assets/img/th-2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MoeFE/GoogleTranslate/312282049236e65e3d443f0fc24f7f782022be0a/src/renderer/assets/img/th-2x.png -------------------------------------------------------------------------------- /src/renderer/assets/img/tl-2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MoeFE/GoogleTranslate/312282049236e65e3d443f0fc24f7f782022be0a/src/renderer/assets/img/tl-2x.png -------------------------------------------------------------------------------- /src/renderer/assets/img/tr-2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MoeFE/GoogleTranslate/312282049236e65e3d443f0fc24f7f782022be0a/src/renderer/assets/img/tr-2x.png -------------------------------------------------------------------------------- /src/renderer/assets/img/uk-2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MoeFE/GoogleTranslate/312282049236e65e3d443f0fc24f7f782022be0a/src/renderer/assets/img/uk-2x.png -------------------------------------------------------------------------------- /src/renderer/assets/img/ur-2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MoeFE/GoogleTranslate/312282049236e65e3d443f0fc24f7f782022be0a/src/renderer/assets/img/ur-2x.png -------------------------------------------------------------------------------- /src/renderer/assets/img/uz-2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MoeFE/GoogleTranslate/312282049236e65e3d443f0fc24f7f782022be0a/src/renderer/assets/img/uz-2x.png -------------------------------------------------------------------------------- /src/renderer/assets/img/vi-2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MoeFE/GoogleTranslate/312282049236e65e3d443f0fc24f7f782022be0a/src/renderer/assets/img/vi-2x.png -------------------------------------------------------------------------------- /src/renderer/assets/img/yi-2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MoeFE/GoogleTranslate/312282049236e65e3d443f0fc24f7f782022be0a/src/renderer/assets/img/yi-2x.png -------------------------------------------------------------------------------- /src/renderer/assets/img/yo-2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MoeFE/GoogleTranslate/312282049236e65e3d443f0fc24f7f782022be0a/src/renderer/assets/img/yo-2x.png -------------------------------------------------------------------------------- /src/renderer/assets/img/zh-CN-2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MoeFE/GoogleTranslate/312282049236e65e3d443f0fc24f7f782022be0a/src/renderer/assets/img/zh-CN-2x.png -------------------------------------------------------------------------------- /src/renderer/assets/img/zh-HK-2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MoeFE/GoogleTranslate/312282049236e65e3d443f0fc24f7f782022be0a/src/renderer/assets/img/zh-HK-2x.png -------------------------------------------------------------------------------- /src/renderer/assets/img/zh-TW-2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MoeFE/GoogleTranslate/312282049236e65e3d443f0fc24f7f782022be0a/src/renderer/assets/img/zh-TW-2x.png -------------------------------------------------------------------------------- /src/renderer/assets/img/zu-2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MoeFE/GoogleTranslate/312282049236e65e3d443f0fc24f7f782022be0a/src/renderer/assets/img/zu-2x.png -------------------------------------------------------------------------------- /src/renderer/components/Country.tsx: -------------------------------------------------------------------------------- 1 | import * as Vue from 'vue-tsx-support'; 2 | import Component from 'vue-class-component'; 3 | import { Prop } from 'vue-property-decorator'; 4 | 5 | export interface CountryProps { 6 | ssl?: boolean; 7 | code?: string; 8 | retina?: boolean; 9 | local?: boolean; 10 | } 11 | 12 | export interface CountryEvents { 13 | onClick: MouseEvent; 14 | } 15 | 16 | @Component 17 | export default class Country extends Vue.Component< 18 | CountryProps, 19 | CountryEvents 20 | > { 21 | @Prop({ type: Boolean, required: false, default: false }) 22 | private readonly ssl!: boolean; 23 | 24 | @Prop({ type: String, required: false, default: 'auto' }) 25 | private readonly code!: string; 26 | 27 | @Prop({ type: Boolean, required: false, default: true }) 28 | private readonly retina!: boolean; 29 | 30 | @Prop({ type: Boolean, required: false, default: true }) 31 | private readonly local!: boolean; 32 | 33 | private get src() { 34 | return this.local 35 | ? require(`assets/img/${this.code}-2x.png`) // eslint-disable-line 36 | : `http://${this.ssl ? 'ssl-' : ''}api.itranslateapp.com/flags/${this.code}${this.retina ? '-2x' : ''}.png`; // prettier-ignore 37 | } 38 | 39 | private handleClick(e: MouseEvent) { 40 | this.$emit('click', e); 41 | } 42 | 43 | render() { 44 | return ; 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /src/renderer/components/Header.tsx: -------------------------------------------------------------------------------- 1 | import Vue from 'vue'; 2 | import Component from 'vue-class-component'; 3 | import styled from 'vue-emotion'; 4 | import * as Layout from './Layout'; 5 | 6 | const H1 = styled.h1` 7 | margin: 0; 8 | font-family: google; 9 | font-weight: 500; 10 | text-align: center; 11 | flex: 1; 12 | i { 13 | display: inline-block; 14 | font-style: normal; 15 | transform: rotate(-10deg); 16 | } 17 | `; 18 | 19 | @Component 20 | export default class Header extends Vue { 21 | render() { 22 | return ( 23 | 24 | {this.$slots.left ?
{this.$slots.left}
: null} 25 | {/* prettier-ignore */} 26 |

Google Translate

27 | {this.$slots.right ? ( 28 |
{this.$slots.right}
29 | ) : null} 30 |
31 | ); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /src/renderer/components/Icon.tsx: -------------------------------------------------------------------------------- 1 | import * as Vue from 'vue-tsx-support'; 2 | import Component from 'vue-class-component'; 3 | import { Prop } from 'vue-property-decorator'; 4 | import styled from 'vue-emotion'; 5 | 6 | const Ico = styled.i` 7 | display: inline-block; 8 | `; 9 | 10 | export interface IconProps { 11 | type: string; 12 | rotate?: number; 13 | tabindex?: number; 14 | disabled?: boolean; 15 | } 16 | 17 | export interface IconEvents { 18 | onClick: (e: MouseEvent) => void; 19 | onFocus: (e: FocusEvent) => void; 20 | } 21 | 22 | @Component 23 | export default class Icon extends Vue.Component { 24 | @Prop({ type: String, required: true }) 25 | private readonly type!: string; 26 | 27 | @Prop({ type: Number, required: false }) 28 | private readonly rotate!: number; 29 | 30 | private handleClick(e: MouseEvent) { 31 | this.$emit('click', e); 32 | } 33 | 34 | private handleFocus(e: FocusEvent) { 35 | this.$emit('focus', e); 36 | } 37 | 38 | render() { 39 | const { type, rotate } = this; 40 | 41 | return ( 42 | 48 | ); 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /src/renderer/components/Input.tsx: -------------------------------------------------------------------------------- 1 | import * as Vue from 'vue-tsx-support'; 2 | import Component from 'vue-class-component'; 3 | import { Prop } from 'vue-property-decorator'; 4 | import { css } from 'vue-emotion'; 5 | 6 | export interface InputProps { 7 | value?: string; 8 | type?: string; 9 | placeholder?: string; 10 | autofocus?: boolean; 11 | } 12 | 13 | export interface InputEvents { 14 | onInput: string; 15 | onEnter: KeyboardEvent; 16 | onBlur: FocusEvent; 17 | } 18 | 19 | @Component 20 | export default class Input extends Vue.Component { 21 | @Prop({ type: String, required: false, default: '' }) 22 | private readonly value!: string; 23 | 24 | private isComposition: boolean = false; 25 | 26 | private get text(): string { 27 | return this.value; 28 | } 29 | 30 | private set text(value: string) { 31 | if (!this.isComposition) this.$emit('input', value); 32 | } 33 | 34 | private handleKeydown(e: KeyboardEvent) { 35 | if (e.keyCode === 13) { 36 | e.preventDefault(); 37 | this.$emit('enter', e); 38 | } 39 | } 40 | 41 | private handleBlur(e: FocusEvent) { 42 | this.$emit('blur', e); 43 | } 44 | 45 | private handleComposition(e: CompositionEvent) { 46 | this.isComposition = e.type !== 'compositionend'; 47 | } 48 | 49 | render() { 50 | return ( 51 | 71 | ); 72 | } 73 | } 74 | -------------------------------------------------------------------------------- /src/renderer/components/InputShortcutKeys.tsx: -------------------------------------------------------------------------------- 1 | /* eslint-disable no-nested-ternary */ 2 | import * as Vue from 'vue-tsx-support'; 3 | import Component from 'vue-class-component'; 4 | import { Prop } from 'vue-property-decorator'; 5 | import styled from 'vue-emotion'; 6 | import keycode from 'keycode'; 7 | import anime from 'animejs'; 8 | import Icon from './Icon'; 9 | 10 | // #region stylesheet 11 | const Input = styled.div` 12 | display: flex; 13 | align-items: center; 14 | position: relative; 15 | appearance: none; 16 | outline: 0; 17 | border: 1px solid transparent; 18 | border-radius: 4px; 19 | font-size: 12px; 20 | font-weight: 300; 21 | width: 100%; 22 | height: 55px; 23 | padding: 5px; 24 | background: #fff; 25 | box-shadow: 0 0.5px 0.5px rgba(0, 0, 0, 0.1); 26 | box-sizing: border-box; 27 | -webkit-user-modify: read-only; 28 | &:focus { 29 | border: 1px solid #199bff; 30 | &:empty:before { 31 | content: attr(focusPlaceholder); 32 | color: #bbb; 33 | padding: 0 10px; 34 | } 35 | } 36 | &:empty:before { 37 | content: attr(placeholder); 38 | color: #bbb; 39 | padding: 0 10px; 40 | } 41 | .icon { 42 | outline: none; 43 | &.icon-clear { 44 | position: absolute; 45 | right: 12px; 46 | color: #fff; 47 | background: #ccc; 48 | border-radius: 50%; 49 | width: 16px; 50 | height: 16px; 51 | font-size: 12px; 52 | font-weight: bold; 53 | &:before { 54 | position: absolute; 55 | top: 50%; 56 | left: 50%; 57 | transform: translate3d(-50%, -50%, 0); 58 | } 59 | &:hover { 60 | background: #bbb; 61 | } 62 | } 63 | } 64 | `; 65 | 66 | const Shortcut = styled.div` 67 | display: inline-flex; 68 | flex-direction: column; 69 | justify-content: space-around; 70 | align-items: center; 71 | position: relative; 72 | width: 45px; 73 | height: 45px; 74 | border-radius: 5px; 75 | margin-right: 10px; 76 | padding: 0 3px; 77 | border: 1px solid #c2c7cc; 78 | box-shadow: 0 0 2px rgba(0, 0, 0, 0.1); 79 | box-sizing: border-box; 80 | color: #000; 81 | background: #fff; 82 | font-weight: 500; 83 | `; 84 | 85 | const Key = styled.span` 86 | font-size: 24px; 87 | font-family: arial; 88 | `; 89 | 90 | const Badge = styled.span` 91 | font-size: 18px; 92 | align-self: flex-end; 93 | + ${Key.toString()} { 94 | font-size: 9px; 95 | align-self: flex-end; 96 | font-family: inherit; 97 | } 98 | `; 99 | // #endregion 100 | 101 | interface IKeyMap { 102 | icon: string; 103 | text: string; 104 | sort: number; 105 | } 106 | 107 | const keyMap: { 108 | [index: string]: IKeyMap; 109 | } = { 110 | Alt: { icon: '⌥', text: 'alt', sort: 1 }, 111 | Control: { icon: '⌃', text: 'ctrl', sort: 2 }, 112 | Meta: { icon: '⌘', text: 'cmd', sort: 0 }, 113 | Shift: { icon: '⇧', text: 'shift', sort: 3 }, 114 | Enter: { icon: '', text: '↩', sort: 4 }, 115 | Backspace: { icon: '', text: '⌫', sort: 4 }, 116 | ArrowUp: { icon: '', text: '↑', sort: 4 }, 117 | ArrowRight: { icon: '', text: '→', sort: 4 }, 118 | ArrowDown: { icon: '', text: '↓', sort: 4 }, 119 | ArrowLeft: { icon: '', text: '←', sort: 4 }, 120 | ' ': { icon: ' ', text: 'space', sort: 4 }, 121 | }; 122 | 123 | const banList = ['CapsLock', 'Escape']; 124 | 125 | interface ShortcutKeysProps { 126 | value: string; 127 | } 128 | 129 | @Component 130 | class ShortcutKeys extends Vue.Component { 131 | @Prop({ type: String, required: true }) 132 | private readonly value!: string; 133 | 134 | private get keyCombinations() { 135 | return keyMap[this.value] || {}; 136 | } 137 | 138 | render() { 139 | const { icon, text = this.value } = this.keyCombinations; 140 | return ( 141 | 142 | {icon ? {icon} : null} 143 | {text} 144 | 145 | ); 146 | } 147 | } 148 | 149 | export interface InputShortcutKeysProps { 150 | value?: string; 151 | placeholder?: string; 152 | focusPlaceholder?: string; 153 | } 154 | 155 | export interface InputShortcutKeysEvents { 156 | input: string; 157 | } 158 | 159 | @Component 160 | export default class InputShortcutKeys extends Vue.Component< 161 | InputShortcutKeysProps, 162 | InputShortcutKeysEvents 163 | > { 164 | public readonly $refs!: { 165 | input: HTMLDivElement; 166 | }; 167 | 168 | @Prop({ type: String, required: false }) 169 | private readonly value!: string; 170 | 171 | private cacheKeys: string[] = []; 172 | 173 | private get keys(): string[] { 174 | this.$nextTick().then(() => { 175 | anime({ 176 | targets: this.$refs.input.children, 177 | easing: 'easeOutQuart', 178 | duration: 300, 179 | translateX: 0, 180 | translateZ: 0, 181 | }); 182 | }); 183 | return this.value ? this.value.replace('Cmd', 'Meta').split('+') : []; 184 | } 185 | 186 | private set keys(value: string[]) { 187 | const keys = Object.keys(keyMap).splice(0, 4); 188 | if (value.length <= 0 || value.some(key => !keys.includes(key))) { 189 | this.$emit('input', value.join('+').replace('Meta', 'Cmd')); 190 | } 191 | } 192 | 193 | private get distinctKeys() { 194 | return [...new Set(this.keys)].sort((a, b) => { 195 | if (!keyMap[a] || !keyMap[b]) return -1; 196 | return keyMap[a].sort - keyMap[b].sort; 197 | }); 198 | } 199 | 200 | private handleFocus() { 201 | this.keys = []; 202 | this.cacheKeys = []; 203 | } 204 | 205 | private handleClear(e: FocusEvent) { 206 | e.stopPropagation(); 207 | this.handleFocus(); 208 | } 209 | 210 | private async handleKeydown(e: KeyboardEvent) { 211 | const { altKey, shiftKey, key, keyCode, target } = e; 212 | if (banList.includes(key)) return; 213 | const keyChar = keycode(e); // String.fromCharCode(keyCode); 214 | const isKeyCombinations = Object.keys(keyMap) 215 | .splice(0, 4) 216 | .includes(key); 217 | 218 | this.cacheKeys.push( 219 | altKey && !isKeyCombinations 220 | ? shiftKey 221 | ? keyChar.toUpperCase() 222 | : keyChar.toLowerCase() 223 | : shiftKey && !isKeyCombinations 224 | ? key.toUpperCase() 225 | : key, 226 | ); 227 | 228 | if (!isKeyCombinations) { 229 | this.keys = this.cacheKeys; 230 | if (target) (target as HTMLDivElement).blur(); 231 | } 232 | } 233 | 234 | render() { 235 | return ( 236 | 243 | {this.distinctKeys.map((key, index) => ( 244 | 251 | ))} 252 | {this.distinctKeys.length > 0 ? ( 253 | 254 | ) : null} 255 | 256 | ); 257 | } 258 | } 259 | -------------------------------------------------------------------------------- /src/renderer/components/Language.tsx: -------------------------------------------------------------------------------- 1 | import * as Vue from 'vue-tsx-support'; 2 | import Component from 'vue-class-component'; 3 | import { Prop, Inject } from 'vue-property-decorator'; 4 | import styled from 'vue-emotion'; 5 | import Icon from './Icon'; 6 | import Country from './Country'; 7 | import Loading from './Loading'; 8 | import TextBox from './TextBox'; 9 | 10 | // #region stylesheet 11 | const CountryWrapper = styled.div` 12 | position: relative; 13 | width: 44px; 14 | height: 44px; 15 | img { 16 | position: relative; 17 | z-index: 2; 18 | width: 100%; 19 | height: 100%; 20 | } 21 | &:after { 22 | content: '\\e602'; 23 | color: #3e83f8; 24 | font-family: icon; 25 | font-weight: bold; 26 | position: absolute; 27 | z-index: 1; 28 | left: 50%; 29 | bottom: -5px; 30 | opacity: 0; 31 | transition: transform 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275); 32 | transform: translate3d(-50%, -20px, 0); 33 | pointer-events: none; 34 | } 35 | &:hover:after { 36 | opacity: 1; 37 | transform: translate3d(-50%, 0, 0); 38 | } 39 | `; 40 | 41 | const Lang = styled.div` 42 | display: flex; 43 | align-items: flex-start; 44 | padding: 0 10px; 45 | .icon { 46 | align-self: center; 47 | color: #ccc; 48 | font-size: 22px; 49 | margin: 0 5px; 50 | &:hover { 51 | color: #bbb; 52 | } 53 | &.icon-clear { 54 | position: relative; 55 | color: #fff; 56 | background: #ccc; 57 | border-radius: 50%; 58 | width: 18px; 59 | height: 18px; 60 | font-size: 14px; 61 | &:before { 62 | position: absolute; 63 | top: 50%; 64 | left: 50%; 65 | transform: translate3d(-50%, -50%, 0); 66 | } 67 | &:hover { 68 | background: #bbb; 69 | } 70 | } 71 | } 72 | `; 73 | 74 | const Action = styled.div` 75 | display: flex; 76 | align-self: flex-start; 77 | justify-content: flex-end; 78 | align-items: center; 79 | margin: 10px 0; 80 | width: 60px; 81 | `; 82 | 83 | const Progress = styled(Action)` 84 | margin: 8px 0; 85 | padding-right: 5px; 86 | box-sizing: border-box; 87 | `; 88 | // #endregion 89 | 90 | export interface LanguageProps { 91 | value?: string; 92 | country?: string; 93 | action?: boolean; 94 | loading?: boolean; 95 | error?: boolean; 96 | allowClear?: boolean; 97 | readOnly?: boolean; 98 | } 99 | 100 | export interface LanguageEvents { 101 | onInput: string; 102 | onClick: MouseEvent; 103 | onSpeak: MouseEvent; 104 | onEnter: KeyboardEvent; 105 | } 106 | 107 | @Component 108 | export default class Language extends Vue.Component< 109 | LanguageProps, 110 | LanguageEvents 111 | > { 112 | public readonly $refs!: { 113 | tbox: TextBox; 114 | }; 115 | 116 | @Prop({ type: String, required: false }) 117 | private readonly value!: string; 118 | 119 | @Prop({ type: String, required: false, default: 'auto' }) 120 | private readonly country!: string; 121 | 122 | @Prop({ type: Boolean, required: false, default: true }) 123 | private readonly action!: boolean; 124 | 125 | @Prop({ type: Boolean, required: false, default: false }) 126 | private readonly loading!: boolean; 127 | 128 | @Prop({ type: Boolean, required: false, default: false }) 129 | private readonly error!: boolean; 130 | 131 | @Prop({ type: Boolean, required: false, default: false }) 132 | private readonly allowClear!: boolean; 133 | 134 | @Prop({ type: Boolean, required: false, default: false }) 135 | private readonly readOnly!: boolean; 136 | 137 | @Inject() 138 | private readonly localeProvider!: any; 139 | 140 | private get text(): string { 141 | return this.value; 142 | } 143 | 144 | private set text(value: string) { 145 | this.$emit('input', value); 146 | } 147 | 148 | public get tbox(): HTMLTextAreaElement { 149 | return this.$refs.tbox.$el as HTMLTextAreaElement; 150 | } 151 | 152 | private handleClear() { 153 | this.text = ''; 154 | } 155 | 156 | private handleClick(e: MouseEvent) { 157 | this.$emit('click', e); 158 | } 159 | 160 | private handleSpeak(e: MouseEvent) { 161 | this.$emit('speak', e); 162 | } 163 | 164 | private handleEnter(e: KeyboardEvent) { 165 | this.$emit('enter', e); 166 | } 167 | 168 | render() { 169 | const { country, loading, action, allowClear, readOnly } = this; 170 | const { languages } = this.localeProvider; 171 | 172 | return ( 173 | 174 | 175 | 176 | 177 | {loading ? ( 178 | 179 | ) : ( 180 | 188 | )} 189 | 190 | {allowClear ? : null} 191 | 196 | 197 | {this.$slots.progress ? ( 198 | {this.$slots.progress} 199 | ) : null} 200 | 201 | ); 202 | } 203 | } 204 | -------------------------------------------------------------------------------- /src/renderer/components/Layout.tsx: -------------------------------------------------------------------------------- 1 | import styled from 'vue-emotion'; 2 | 3 | export default styled.section` 4 | display: flex; 5 | flex-direction: column; 6 | margin: auto; 7 | width: calc(100% - 20px); 8 | height: calc(100% - 19px); 9 | border-radius: 6px; 10 | box-shadow: 0 0 10px rgba(0, 0, 0, 0.3); 11 | overflow: hidden; 12 | `; 13 | 14 | export const Header = styled.header` 15 | display: flex; 16 | align-items: center; 17 | position: relative; 18 | z-index: 9; 19 | color: #fff; 20 | background: #4286f5; 21 | padding: 10px; 22 | border-radius: 6px 6px 0 0; 23 | * { 24 | font-size: 18px; 25 | } 26 | .left, 27 | .right { 28 | position: absolute; 29 | } 30 | .left { 31 | left: 10px; 32 | } 33 | .right { 34 | right: 10px; 35 | } 36 | .icon { 37 | color: #fff; 38 | text-shadow: 0 0 10px rgba(255, 255, 255, 0); 39 | transition: 0.3s; 40 | &:hover { 41 | text-shadow: 0 0 10px rgba(255, 255, 255, 0.5); 42 | } 43 | } 44 | `; 45 | 46 | export const Main = styled.main` 47 | flex: 1; 48 | display: flex; 49 | flex-direction: column; 50 | align-items: center; 51 | position: relative; 52 | background: #fff; 53 | box-sizing: border-box; 54 | border-radius: 0 0 6px 6px; 55 | overflow: hidden; 56 | &:before { 57 | content: ''; 58 | position: absolute; 59 | top: 0px; 60 | left: 0px; 61 | width: calc(100% - 1px); 62 | height: calc(100% - 1px); 63 | border-radius: 0 0 6px 6px; 64 | box-shadow: 0 0 0.5px; 65 | transform: translate(0.5px, 0.5px); 66 | pointer-events: none; 67 | } 68 | `; 69 | 70 | export const Close = styled.button` 71 | display: flex; 72 | align-items: center; 73 | appearance: none; 74 | text-decoration: none; 75 | position: absolute; 76 | top: 0; 77 | right: 0; 78 | height: 100%; 79 | color: #fff; 80 | background: inherit; 81 | outline: 0; 82 | border: 0; 83 | border-radius: 0 6px 0 0; 84 | padding: 0 20px; 85 | font-size: 14px !important; 86 | font-weight: 500; 87 | transition: 0.3s; 88 | cursor: default; 89 | &:active { 90 | box-shadow: 0px 0px 30px rgba(0, 0, 0, 0.2) inset; 91 | } 92 | &:before { 93 | content: ''; 94 | position: absolute; 95 | top: 0; 96 | left: 0; 97 | width: 1px; 98 | height: 100%; 99 | background: #357df3; 100 | } 101 | `; 102 | 103 | export const Panel = { 104 | Layout: styled.div` 105 | position: relative; 106 | padding: 15px 20px; 107 | margin-bottom: 20px; 108 | width: 100%; 109 | border-radius: 6px; 110 | background: #ededed; 111 | box-sizing: border-box; 112 | `, 113 | Title: styled.h3` 114 | color: #333; 115 | font-size: 16px; 116 | font-weight: 500; 117 | margin: 0; 118 | margin-bottom: 10px; 119 | `, 120 | Body: styled.div` 121 | color: #666; 122 | font-size: 14px; 123 | margin: 0; 124 | `, 125 | }; 126 | 127 | export const Switch = { 128 | Layout: styled.div` 129 | position: relative; 130 | width: 50px; 131 | height: 30px; 132 | border: 1px solid ${(props: any) => (props.active ? '#4cd964' : '#bebebe')}; 133 | background: ${(props: any) => (props.active ? '#4cd964' : 'transparent')}; 134 | border-radius: 30px; 135 | transition: 0.2s ease-in-out; 136 | box-sizing: border-box; 137 | `, 138 | Handle: styled.div` 139 | display: inline-block; 140 | position: absolute; 141 | z-index: 1; 142 | top: 0; 143 | left: ${(props: any) => (props.active && props.dragging ? -7 : 0)}px; 144 | width: ${(props: any) => (props.dragging ? 35 : 28)}px; 145 | height: 28px; 146 | border-radius: 28px; 147 | background: #fff; 148 | box-shadow: 0 2px 5px rgba(0, 0, 0, 0.4); 149 | transition-duration: ${(props: any) => (props.dragging ? 0.2 : 0.3)}s; 150 | transition-timing-function: ${(props: any) => 151 | (props.dragging 152 | ? 'ease-in-out' 153 | : 'cubic-bezier(0.175, 0.885, 0.32, 1.275)')}; 154 | transform: translate3d( 155 | ${(props: any) => (props.active ? '19px' : 0)}, 156 | 0, 157 | 0 158 | ); 159 | `, 160 | }; 161 | 162 | export const Radio = { 163 | Layout: styled.label` 164 | display: inline-flex; 165 | justify-content: center; 166 | align-items: center; 167 | &:not(:nth-last-of-type(1)) { 168 | margin-right: 10px; 169 | } 170 | input[type='radio'] { 171 | display: none; 172 | &:checked + i { 173 | background: linear-gradient(to right, #3497ff, #3497ff); 174 | border-color: transparent; 175 | &:before { 176 | transform: scale(1); 177 | } 178 | } 179 | } 180 | `, 181 | Button: styled.i` 182 | display: inline-block; 183 | position: relative; 184 | width: 14px; 185 | height: 14px; 186 | border: 1px solid #cdcdcd; 187 | border-radius: 14px; 188 | background: #fff; 189 | margin-right: 5px; 190 | box-sizing: border-box; 191 | box-shadow: 0 1px 1px rgba(0, 0, 0, 0.1) inset; 192 | &:before { 193 | content: ''; 194 | position: absolute; 195 | top: 4px; 196 | left: 4px; 197 | width: 4px; 198 | height: 4px; 199 | border-radius: 4px; 200 | background: #fff; 201 | box-shadow: 1px 1px 1px rgba(0, 0, 0, 0.1); 202 | transition: 0.1s ease-in-out; 203 | transform: scale(0); 204 | } 205 | `, 206 | }; 207 | -------------------------------------------------------------------------------- /src/renderer/components/Link.tsx: -------------------------------------------------------------------------------- 1 | import { remote } from 'electron'; 2 | 3 | import * as Vue from 'vue-tsx-support'; 4 | import Component from 'vue-class-component'; 5 | import { Prop } from 'vue-property-decorator'; 6 | import { css } from 'vue-emotion'; 7 | 8 | export interface LinkProps { 9 | href?: string; 10 | } 11 | 12 | @Component 13 | export default class Link extends Vue.Component { 14 | @Prop({ type: String, required: false, default: 'javascript:;' }) // eslint-disable-line no-script-url 15 | private readonly href!: string; 16 | 17 | private handleClick(e: MouseEvent) { 18 | e.preventDefault(); 19 | remote.shell.openExternal(this.href); 20 | } 21 | 22 | render() { 23 | return ( 24 | 34 | {this.$slots.default} 35 | 36 | ); 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /src/renderer/components/Loading.tsx: -------------------------------------------------------------------------------- 1 | import Vue from 'vue'; 2 | import Component from 'vue-class-component'; 3 | import styled from 'vue-emotion'; 4 | 5 | const Indicator = styled.div` 6 | flex: 1; 7 | display: flex; 8 | align-items: center; 9 | align-self: center; 10 | > i { 11 | display: inline-block; 12 | width: 4px; 13 | height: 4px; 14 | border-radius: 4px; 15 | margin: 0 3px; 16 | opacity: 0.5; 17 | background: #3e83f8; 18 | &:nth-of-type(1) { 19 | animation: loading 0.6s cubic-bezier(0.165, 0.84, 0.44, 1) 0.1s infinite; 20 | } 21 | &:nth-of-type(2) { 22 | animation: loading 0.6s cubic-bezier(0.165, 0.84, 0.44, 1) 0.2s infinite; 23 | } 24 | &:nth-of-type(3) { 25 | animation: loading 0.6s cubic-bezier(0.165, 0.84, 0.44, 1) 0.3s infinite; 26 | } 27 | } 28 | @keyframes loading { 29 | 0% { 30 | opacity: 0.5; 31 | transform: scale(1); 32 | } 33 | 25% { 34 | opacity: 0.75; 35 | transform: scale(1.5); 36 | } 37 | 50% { 38 | opacity: 1; 39 | transform: scale(2); 40 | } 41 | 100% { 42 | opacity: 0.5; 43 | transform: scale(1); 44 | } 45 | } 46 | `; 47 | 48 | @Component 49 | export default class Loading extends Vue { 50 | render() { 51 | return ( 52 | 53 | {[...Array(3)].map(() => ( 54 | 55 | ))} 56 | 57 | ); 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /src/renderer/components/LocaleProvider.tsx: -------------------------------------------------------------------------------- 1 | import fs from 'fs'; 2 | import path from 'path'; 3 | 4 | import * as Vue from 'vue-tsx-support'; 5 | import Component from 'vue-class-component'; 6 | import { Prop, Provide, Watch } from 'vue-property-decorator'; 7 | 8 | export interface LocaleProviderProps { 9 | locale?: string; 10 | } 11 | 12 | @Component 13 | export default class LocaleProvider extends Vue.Component { 14 | public languages = {}; 15 | public localizable = {}; 16 | 17 | @Prop({ type: String, required: false, default: 'zh-CN' }) 18 | private readonly locale!: string; 19 | 20 | @Provide() 21 | private get localeProvider() { 22 | return this; 23 | } 24 | 25 | @Watch('locale', { immediate: true }) 26 | private async handleChangeLocale() { 27 | const exists = fs.existsSync(path.join(__static, `i18n/${this.locale}`)); 28 | const locale = exists ? this.locale : 'zh-CN'; 29 | const filename = path.join(__static, `/i18n/${locale}/languages.json`); 30 | this.languages = JSON.parse(fs.readFileSync(filename).toString()); 31 | } 32 | 33 | render() { 34 | return
{this.$slots.default}
; 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /src/renderer/components/Progress.tsx: -------------------------------------------------------------------------------- 1 | import * as Vue from 'vue-tsx-support'; 2 | import Component from 'vue-class-component'; 3 | import { Prop } from 'vue-property-decorator'; 4 | import styled from 'vue-emotion'; 5 | 6 | // #region stylesheet 7 | const ProgressBar = styled.div` 8 | position: relative; 9 | display: inline-block; 10 | width: 28px; 11 | height: 28px; 12 | `; 13 | 14 | const Pause = styled.i` 15 | display: flex; 16 | position: absolute; 17 | top: 50%; 18 | left: 50%; 19 | transform: translate(-50%, -50%); 20 | font-size: 0; 21 | &:before, 22 | &:after { 23 | content: ''; 24 | display: inline-block; 25 | width: 3px; 26 | height: 12px; 27 | margin: 0 2px; 28 | background: #3e83f8; 29 | } 30 | `; 31 | 32 | export const Spin = styled.div` 33 | position: relative; 34 | width: 28px; 35 | height: 28px; 36 | border-radius: 28px; 37 | border: 2px solid transparent; 38 | border-top-color: #3e83f8; 39 | border-right-color: #3e83f8; 40 | border-bottom-color: rgba(62, 131, 248, 0); 41 | border-left-color: rgba(62, 131, 248, 0); 42 | box-sizing: border-box; 43 | background: #fff; 44 | background-clip: padding-box; 45 | animation: spin-loading 0.8s linear infinite; 46 | @keyframes spin-loading { 47 | 0% { 48 | transform: rotate(0deg); 49 | } 50 | 100% { 51 | transform: rotate(360deg); 52 | } 53 | } 54 | `; 55 | // #endregion 56 | 57 | export interface ProgressProps { 58 | value?: number; 59 | strokeWidth?: number; 60 | duration?: number; 61 | easing?: string; 62 | } 63 | 64 | export interface ProgressEvents { 65 | onPause: MouseEvent; 66 | } 67 | 68 | @Component 69 | export default class Progress extends Vue.Component< 70 | ProgressProps, 71 | ProgressEvents 72 | > { 73 | @Prop({ type: Number, required: false, default: 0 }) 74 | private readonly value!: number; 75 | 76 | @Prop({ type: Number, required: false, default: 7 }) 77 | private readonly strokeWidth!: number; 78 | 79 | @Prop({ type: Number, required: false, default: 1000 }) 80 | private readonly duration!: number; 81 | 82 | @Prop({ type: String, required: false, default: 'linear' }) 83 | private readonly easing!: string; 84 | 85 | private path: string = 'M 50,50 m 0,-47 a 47,47 0 1 1 0,94 a 47,47 0 1 1 0,-94'; // prettier-ignore 86 | 87 | private get strokeDashoffset() { 88 | return (1 - this.value) * 295.416; 89 | } 90 | 91 | private handlePause(e: MouseEvent) { 92 | this.$emit('pause', e); 93 | } 94 | 95 | render() { 96 | const { path, strokeWidth, strokeDashoffset } = this; 97 | 98 | return ( 99 | 100 | 101 | 107 | 117 | 118 | 119 | 120 | ); 121 | } 122 | } 123 | -------------------------------------------------------------------------------- /src/renderer/components/Radio.tsx: -------------------------------------------------------------------------------- 1 | import * as Vue from 'vue-tsx-support'; 2 | import Component from 'vue-class-component'; 3 | import { Prop } from 'vue-property-decorator'; 4 | import { Radio as radio } from './Layout'; 5 | 6 | const { Layout, Button } = radio; 7 | 8 | export interface RadioProps { 9 | checked?: boolean; 10 | value?: string; 11 | name?: string; // eslint-disable-line no-restricted-globals 12 | } 13 | 14 | export interface RadioEvents { 15 | onChange: string; 16 | } 17 | 18 | @Component 19 | export default class Radio extends Vue.Component { 20 | @Prop({ type: Boolean, required: false, default: false }) 21 | private readonly checked!: boolean; 22 | 23 | @Prop({ type: String, required: false }) 24 | private readonly value!: string; 25 | 26 | @Prop({ type: String, required: false }) 27 | private readonly name!: string; // eslint-disable-line no-restricted-globals 28 | 29 | private handleChange(e: Event) { 30 | if (e.target) { 31 | this.$emit('change', (e.target as HTMLInputElement).value); 32 | } 33 | } 34 | 35 | render() { 36 | return ( 37 | 38 | 45 |