Compare commits
21 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c6f8a45027 | ||
|
|
6ec16e1f98 | ||
|
|
40adf85b20 | ||
|
|
4c78f469c1 | ||
|
|
55af58faac | ||
|
|
4200caa641 | ||
|
|
0ac06f8e3d | ||
|
|
966c78fb16 | ||
|
|
5c5a35d3bb | ||
|
|
2c24214f48 | ||
|
|
67d9e70b3c | ||
|
|
000a55f43b | ||
|
|
4096a6976c | ||
|
|
df4c4ebd50 | ||
|
|
b43bd4e0e2 | ||
|
|
2660dbf866 | ||
|
|
e0b7c60099 | ||
|
|
536b58bf67 | ||
|
|
6bb742f828 | ||
|
|
72742e5e12 | ||
|
|
3667e0a509 |
7
.env
7
.env
@@ -2,7 +2,7 @@ GENERATE_SOURCEMAP=false
|
|||||||
|
|
||||||
REACT_APP_NAME=KISS Translator
|
REACT_APP_NAME=KISS Translator
|
||||||
REACT_APP_NAME_CN=简约翻译
|
REACT_APP_NAME_CN=简约翻译
|
||||||
REACT_APP_VERSION=1.6.2
|
REACT_APP_VERSION=1.6.7
|
||||||
|
|
||||||
REACT_APP_HOMEPAGE=https://github.com/fishjar/kiss-translator
|
REACT_APP_HOMEPAGE=https://github.com/fishjar/kiss-translator
|
||||||
|
|
||||||
@@ -13,8 +13,9 @@ REACT_APP_OPTIONSPAGE_DEV=http://localhost:3000/options.html
|
|||||||
REACT_APP_LOGOURL=https://fishjar.github.io/kiss-translator/images/logo192.png
|
REACT_APP_LOGOURL=https://fishjar.github.io/kiss-translator/images/logo192.png
|
||||||
REACT_APP_LOGOURL2=https://kiss-translator.rayjar.com/images/logo192.png
|
REACT_APP_LOGOURL2=https://kiss-translator.rayjar.com/images/logo192.png
|
||||||
|
|
||||||
REACT_APP_RULESURL=https://fishjar.github.io/kiss-translator/kiss-translator-rules.json
|
REACT_APP_RULESURL=https://fishjar.github.io/kiss-rules/kiss-rules.json
|
||||||
REACT_APP_RULESURL2=https://kiss-translator.rayjar.com/kiss-translator-rules.json
|
REACT_APP_RULESURL_ON=https://fishjar.github.io/kiss-rules/kiss-rules-on.json
|
||||||
|
REACT_APP_RULESURL_OFF=https://fishjar.github.io/kiss-rules/kiss-rules-off.json
|
||||||
|
|
||||||
REACT_APP_VERSIONFILE=https://fishjar.github.io/kiss-translator/version.txt
|
REACT_APP_VERSIONFILE=https://fishjar.github.io/kiss-translator/version.txt
|
||||||
REACT_APP_VERSIONFILE2=https://kiss-translator.rayjar.com/version.txt
|
REACT_APP_VERSIONFILE2=https://kiss-translator.rayjar.com/version.txt
|
||||||
|
|||||||
34
README.en.md
34
README.en.md
@@ -18,6 +18,34 @@ If you also like a little more simplicity, welcome to pick it up.
|
|||||||
|
|
||||||
- Keep it simple, smart
|
- Keep it simple, smart
|
||||||
|
|
||||||
|
## Associated ProjectS
|
||||||
|
|
||||||
|
- Data synchronization service: [https://github.com/fishjar/kiss-worker](https://github.com/fishjar/kiss-worker)
|
||||||
|
- Data synchronization service available for this project.
|
||||||
|
- You can also share your own private rule list.
|
||||||
|
- Deploy by yourself, manage by yourself, data is private.
|
||||||
|
- Community subscription rules: [https://github.com/fishjar/kiss-rules](https://github.com/fishjar/kiss-rules)
|
||||||
|
- Provides the latest and most complete list of subscription rules maintained by the community.
|
||||||
|
- Help with rules-related issues.
|
||||||
|
- Web page correction script: [https://github.com/fishjar/kiss-webfixer](https://github.com/fishjar/kiss-webfixer)
|
||||||
|
- Fixed scripts for some special sites.
|
||||||
|
- So that the translation software can get better display effect.
|
||||||
|
- Translation interface agent: [https://github.com/fishjar/kiss-proxy](https://github.com/fishjar/kiss-proxy)
|
||||||
|
- If you encounter network problems when accessing a certain translation interface, this proxy service may help you.
|
||||||
|
- Deploy and manage by yourself.
|
||||||
|
- Minimalistic Dictionary Plugin: [https://github.com/fishjar/kiss-dictionary](https://github.com/fishjar/kiss-dictionary)
|
||||||
|
- A word-marking translation plug-in used with this project.
|
||||||
|
- Supports query of English words, sentences and Chinese characters.
|
||||||
|
- Supports history records and word collections.
|
||||||
|
|
||||||
|
## Description
|
||||||
|
|
||||||
|
### Support shortcut keys
|
||||||
|
|
||||||
|
- `Alt+Q` Toggle Translation
|
||||||
|
- `Alt+C` Toggle Styles
|
||||||
|
- `Alt+K` Open Menu
|
||||||
|
|
||||||
## Schedule
|
## Schedule
|
||||||
|
|
||||||
- [x] Provide trial installation package
|
- [x] Provide trial installation package
|
||||||
@@ -30,8 +58,8 @@ If you also like a little more simplicity, welcome to pick it up.
|
|||||||
- [x] Support translation services
|
- [x] Support translation services
|
||||||
- [x] Google
|
- [x] Google
|
||||||
- [x] Microsoft
|
- [x] Microsoft
|
||||||
|
- [x] DeepL
|
||||||
- [x] OpenAI
|
- [x] OpenAI
|
||||||
- [ ] DeepL
|
|
||||||
- [x] Upload to app Store
|
- [x] Upload to app Store
|
||||||
- [x] Chrome [Install Link](https://chrome.google.com/webstore/detail/kiss-translator/bdiifdefkgmcblbcghdlonllpjhhjgof)
|
- [x] Chrome [Install Link](https://chrome.google.com/webstore/detail/kiss-translator/bdiifdefkgmcblbcghdlonllpjhhjgof)
|
||||||
- [x] Edge [Install Link](https://microsoftedge.microsoft.com/addons/detail/kiss-translator/jemckldkclkinpjighnoilpbldbdmmlh)
|
- [x] Edge [Install Link](https://microsoftedge.microsoft.com/addons/detail/kiss-translator/jemckldkclkinpjighnoilpbldbdmmlh)
|
||||||
@@ -54,10 +82,6 @@ yarn install
|
|||||||
yarn build
|
yarn build
|
||||||
```
|
```
|
||||||
|
|
||||||
## Data Sync
|
|
||||||
|
|
||||||
Goto: [https://github.com/fishjar/kiss-worker](https://github.com/fishjar/kiss-worker)
|
|
||||||
|
|
||||||
## Discussion
|
## Discussion
|
||||||
|
|
||||||
- Join [Telegram Group](https://t.me/+RRCu_4oNwrM2NmFl)
|
- Join [Telegram Group](https://t.me/+RRCu_4oNwrM2NmFl)
|
||||||
|
|||||||
34
README.md
34
README.md
@@ -18,6 +18,34 @@
|
|||||||
|
|
||||||
- 保持简约
|
- 保持简约
|
||||||
|
|
||||||
|
## 关联项目
|
||||||
|
|
||||||
|
- 数据同步服务: [https://github.com/fishjar/kiss-worker](https://github.com/fishjar/kiss-worker)
|
||||||
|
- 可用于本项目的数据同步服务。
|
||||||
|
- 亦可用与分享个人的私有规则列表。
|
||||||
|
- 自己部署,自己管理,数据私有。
|
||||||
|
- 社区订阅规则: [https://github.com/fishjar/kiss-rules](https://github.com/fishjar/kiss-rules)
|
||||||
|
- 提供社区维护的,最新最全的订阅规则列表。
|
||||||
|
- 求助规则相关的问题。
|
||||||
|
- 网页修正脚本: [https://github.com/fishjar/kiss-webfixer](https://github.com/fishjar/kiss-webfixer)
|
||||||
|
- 针对一些特殊网站的修正脚本。
|
||||||
|
- 以便翻译软件得到更好的展示效果。
|
||||||
|
- 翻译接口代理: [https://github.com/fishjar/kiss-proxy](https://github.com/fishjar/kiss-proxy)
|
||||||
|
- 如果访问某个翻译接口遇到网络问题,这个代理服务也许可以帮你到你。
|
||||||
|
- 自己部署,自己管理。
|
||||||
|
- 简约词典插件: [https://github.com/fishjar/kiss-dictionary](https://github.com/fishjar/kiss-dictionary)
|
||||||
|
- 搭配本项目一起使用的划词翻译插件。
|
||||||
|
- 支持英文单词、句子、汉字的查询。
|
||||||
|
- 支持历史记录、单词收藏。
|
||||||
|
|
||||||
|
## 简要说明
|
||||||
|
|
||||||
|
### 支持快捷键
|
||||||
|
|
||||||
|
- `Alt+Q` 开启翻译
|
||||||
|
- `Alt+C` 切换样式
|
||||||
|
- `Alt+K` 打开菜单
|
||||||
|
|
||||||
## 进度
|
## 进度
|
||||||
|
|
||||||
- [x] 提供试用安装包
|
- [x] 提供试用安装包
|
||||||
@@ -30,8 +58,8 @@
|
|||||||
- [x] 支持翻译服务
|
- [x] 支持翻译服务
|
||||||
- [x] Google
|
- [x] Google
|
||||||
- [x] Microsoft
|
- [x] Microsoft
|
||||||
|
- [x] DeepL
|
||||||
- [x] OpenAI
|
- [x] OpenAI
|
||||||
- [ ] DeepL
|
|
||||||
- [x] 上架应用市场
|
- [x] 上架应用市场
|
||||||
- [x] Chrome [安装地址](https://chrome.google.com/webstore/detail/kiss-translator/bdiifdefkgmcblbcghdlonllpjhhjgof?hl=zh-CN)
|
- [x] Chrome [安装地址](https://chrome.google.com/webstore/detail/kiss-translator/bdiifdefkgmcblbcghdlonllpjhhjgof?hl=zh-CN)
|
||||||
- [x] Edge [安装地址](https://microsoftedge.microsoft.com/addons/detail/%E7%AE%80%E7%BA%A6%E7%BF%BB%E8%AF%91/jemckldkclkinpjighnoilpbldbdmmlh?hl=zh-CN)
|
- [x] Edge [安装地址](https://microsoftedge.microsoft.com/addons/detail/%E7%AE%80%E7%BA%A6%E7%BF%BB%E8%AF%91/jemckldkclkinpjighnoilpbldbdmmlh?hl=zh-CN)
|
||||||
@@ -54,10 +82,6 @@ yarn install
|
|||||||
yarn build
|
yarn build
|
||||||
```
|
```
|
||||||
|
|
||||||
## 数据同步
|
|
||||||
|
|
||||||
移步: [https://github.com/fishjar/kiss-worker](https://github.com/fishjar/kiss-worker)
|
|
||||||
|
|
||||||
## 交流
|
## 交流
|
||||||
|
|
||||||
- 加入 [Telegram 群](https://t.me/+RRCu_4oNwrM2NmFl)
|
- 加入 [Telegram 群](https://t.me/+RRCu_4oNwrM2NmFl)
|
||||||
|
|||||||
@@ -93,6 +93,8 @@ const userscriptWebpack = (config, env) => {
|
|||||||
// @connect translate.googleapis.com
|
// @connect translate.googleapis.com
|
||||||
// @connect api-edge.cognitive.microsofttranslator.com
|
// @connect api-edge.cognitive.microsofttranslator.com
|
||||||
// @connect edge.microsoft.com
|
// @connect edge.microsoft.com
|
||||||
|
// @connect api-free.deepl.com
|
||||||
|
// @connect api.deepl.com
|
||||||
// @connect api.openai.com
|
// @connect api.openai.com
|
||||||
// @connect openai.azure.com
|
// @connect openai.azure.com
|
||||||
// @connect workers.dev
|
// @connect workers.dev
|
||||||
@@ -100,6 +102,7 @@ const userscriptWebpack = (config, env) => {
|
|||||||
// @connect githubusercontent.com
|
// @connect githubusercontent.com
|
||||||
// @connect kiss-translator.rayjar.com
|
// @connect kiss-translator.rayjar.com
|
||||||
// @connect ghproxy.com
|
// @connect ghproxy.com
|
||||||
|
// @connect localhost:3000
|
||||||
// @run-at document-end
|
// @run-at document-end
|
||||||
// ==/UserScript==
|
// ==/UserScript==
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"name": "kiss-translator",
|
"name": "kiss-translator",
|
||||||
"description": "A minimalist bilingual translation Extension & Greasemonkey Script",
|
"description": "A minimalist bilingual translation Extension & Greasemonkey Script",
|
||||||
"version": "1.6.2",
|
"version": "1.6.7",
|
||||||
"author": "Gabe<yugang2002@gmail.com>",
|
"author": "Gabe<yugang2002@gmail.com>",
|
||||||
"private": true,
|
"private": true,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
@@ -26,10 +26,10 @@
|
|||||||
"build:edge": "rm -rf build/edge && cp -r build/chrome build/edge",
|
"build:edge": "rm -rf build/edge && cp -r build/chrome build/edge",
|
||||||
"build:firefox": "rm -rf build/firefox && cp -r build/chrome build/firefox && cat ./build/firefox/manifest.firefox.json > ./build/firefox/manifest.json",
|
"build:firefox": "rm -rf build/firefox && cp -r build/chrome build/firefox && cat ./build/firefox/manifest.firefox.json > ./build/firefox/manifest.json",
|
||||||
"build:web": "rm -rf build/web && BUILD_PATH=./build/web REACT_APP_CLIENT=userscript react-app-rewired build",
|
"build:web": "rm -rf build/web && BUILD_PATH=./build/web REACT_APP_CLIENT=userscript react-app-rewired build",
|
||||||
"build:userscript": "rm -rf build/userscript && mkdir build/userscript && cp build/web/kiss-translator.user.js build/userscript/kiss-translator.user.js",
|
"build:userscript-ios": "file1=build/web/kiss-translator.user.js file2=build/web/kiss-translator-ios-safari.user.js && cp $file1 $file2 && sed -i 's|// @grant unsafeWindow|// @inject-into content|g' $file2",
|
||||||
"build:userscript-ios": "file1=build/userscript/kiss-translator.user.js file2=build/userscript/kiss-translator-ios-safari.user.js && cp $file1 $file2 && sed -i 's|// @grant unsafeWindow|// @inject-into content|g' $file2",
|
"build:userscript": "rm -rf build/userscript && mkdir build/userscript && cp build/web/*.user.js build/userscript/",
|
||||||
"build:rules": "babel-node src/rules.js",
|
"build:rules": "babel-node src/rules.js",
|
||||||
"build": "yarn build:chrome && yarn build:edge && yarn build:firefox && yarn build:web && yarn build:userscript && yarn build:userscript-ios && yarn build:rules",
|
"build": "yarn build:chrome && yarn build:edge && yarn build:firefox && yarn build:web && yarn build:userscript-ios && yarn build:userscript && yarn build:rules",
|
||||||
"deploy:web": "wrangler pages deploy ./build/web --project-name kiss-translator",
|
"deploy:web": "wrangler pages deploy ./build/web --project-name kiss-translator",
|
||||||
"test": "react-app-rewired test",
|
"test": "react-app-rewired test",
|
||||||
"eject": "react-scripts eject"
|
"eject": "react-scripts eject"
|
||||||
|
|||||||
@@ -64,8 +64,25 @@
|
|||||||
<body>
|
<body>
|
||||||
<noscript>You need to enable JavaScript to run this app.</noscript>
|
<noscript>You need to enable JavaScript to run this app.</noscript>
|
||||||
<div id="root">
|
<div id="root">
|
||||||
|
<div id="content">
|
||||||
|
<p>You need to enable JavaScript to run <span>this app.</span></p>
|
||||||
|
The <span>embargo</span> has just lifted to confirm that AmpereOne is
|
||||||
|
coming to Google Cloud with the C3A instances.
|
||||||
|
<br />
|
||||||
|
But these upcoming instances for now are only in private preview form.
|
||||||
|
<br />
|
||||||
|
<br />
|
||||||
|
Needless to say I also haven't had any AmpereOne access to check out the
|
||||||
|
performance and power efficiency of these new Arm server processors from
|
||||||
|
Ampere Computing.
|
||||||
|
<br />
|
||||||
|
</div>
|
||||||
<h2>
|
<h2>
|
||||||
<p><span>React is a JavaScript library for building user interfaces.</span></p>
|
<p>
|
||||||
|
<span
|
||||||
|
>React is a JavaScript library for building user interfaces.</span
|
||||||
|
>
|
||||||
|
</p>
|
||||||
</h2>
|
</h2>
|
||||||
<div id="addtitle"></div>
|
<div id="addtitle"></div>
|
||||||
<h2>Shadow 1</h2>
|
<h2>Shadow 1</h2>
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
"manifest_version": 2,
|
"manifest_version": 2,
|
||||||
"name": "__MSG_app_name__",
|
"name": "__MSG_app_name__",
|
||||||
"description": "__MSG_app_description__",
|
"description": "__MSG_app_description__",
|
||||||
"version": "1.6.2",
|
"version": "1.6.7",
|
||||||
"default_locale": "en",
|
"default_locale": "en",
|
||||||
"author": "Gabe<yugang2002@gmail.com>",
|
"author": "Gabe<yugang2002@gmail.com>",
|
||||||
"homepage_url": "https://github.com/fishjar/kiss-translator",
|
"homepage_url": "https://github.com/fishjar/kiss-translator",
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
"manifest_version": 3,
|
"manifest_version": 3,
|
||||||
"name": "__MSG_app_name__",
|
"name": "__MSG_app_name__",
|
||||||
"description": "__MSG_app_description__",
|
"description": "__MSG_app_description__",
|
||||||
"version": "1.6.2",
|
"version": "1.6.7",
|
||||||
"default_locale": "en",
|
"default_locale": "en",
|
||||||
"author": "Gabe<yugang2002@gmail.com>",
|
"author": "Gabe<yugang2002@gmail.com>",
|
||||||
"homepage_url": "https://github.com/fishjar/kiss-translator",
|
"homepage_url": "https://github.com/fishjar/kiss-translator",
|
||||||
|
|||||||
@@ -284,9 +284,9 @@ export const I18N = {
|
|||||||
zh: `OpenAI 提示词`,
|
zh: `OpenAI 提示词`,
|
||||||
en: `OpenAI Prompt`,
|
en: `OpenAI Prompt`,
|
||||||
},
|
},
|
||||||
clear_cache: {
|
if_clear_cache: {
|
||||||
zh: `是否清除缓存`,
|
zh: `是否清除缓存 (仅用于扩展)`,
|
||||||
en: `Whether clear cache`,
|
en: `Whether clear cache (only for extension)`,
|
||||||
},
|
},
|
||||||
clear_cache_never: {
|
clear_cache_never: {
|
||||||
zh: `不清除缓存`,
|
zh: `不清除缓存`,
|
||||||
@@ -308,13 +308,13 @@ export const I18N = {
|
|||||||
zh: `数据同步测试`,
|
zh: `数据同步测试`,
|
||||||
en: `Data Sync Test`,
|
en: `Data Sync Test`,
|
||||||
},
|
},
|
||||||
data_sync_success: {
|
sync_success: {
|
||||||
zh: `数据同步成功!`,
|
zh: `同步成功!`,
|
||||||
en: `Data Sync Success`,
|
en: `Sync Success`,
|
||||||
},
|
},
|
||||||
data_sync_error: {
|
sync_failed: {
|
||||||
zh: `数据同步失败!`,
|
zh: `同步失败!`,
|
||||||
en: `Data Sync Error`,
|
en: `Sync Error`,
|
||||||
},
|
},
|
||||||
error_got_some_wrong: {
|
error_got_some_wrong: {
|
||||||
zh: `抱歉,出错了!`,
|
zh: `抱歉,出错了!`,
|
||||||
@@ -324,4 +324,40 @@ export const I18N = {
|
|||||||
zh: `您的同步设置未填写,无法在线分享。`,
|
zh: `您的同步设置未填写,无法在线分享。`,
|
||||||
en: `Your sync settings are missing and cannot be shared online.`,
|
en: `Your sync settings are missing and cannot be shared online.`,
|
||||||
},
|
},
|
||||||
|
click_test: {
|
||||||
|
zh: `点击测试`,
|
||||||
|
en: `Click Test`,
|
||||||
|
},
|
||||||
|
test_success: {
|
||||||
|
zh: `测试成功`,
|
||||||
|
en: `Test success`,
|
||||||
|
},
|
||||||
|
test_failed: {
|
||||||
|
zh: `测试失败`,
|
||||||
|
en: `Test failed`,
|
||||||
|
},
|
||||||
|
clear_all_cache_now: {
|
||||||
|
zh: `立即清除全部缓存`,
|
||||||
|
en: `Clear all cache now`,
|
||||||
|
},
|
||||||
|
clear_cache: {
|
||||||
|
zh: `清除缓存`,
|
||||||
|
en: `Clear Cache`,
|
||||||
|
},
|
||||||
|
clear_success: {
|
||||||
|
zh: `清除成功`,
|
||||||
|
en: `Clear success`,
|
||||||
|
},
|
||||||
|
clear_failed: {
|
||||||
|
zh: `清除失败`,
|
||||||
|
en: `Clear failed`,
|
||||||
|
},
|
||||||
|
share: {
|
||||||
|
zh: `分享`,
|
||||||
|
en: `Share`,
|
||||||
|
},
|
||||||
|
help: {
|
||||||
|
zh: `求助`,
|
||||||
|
en: `Help`,
|
||||||
|
},
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -58,6 +58,9 @@ export const THEME_DARK = "dark";
|
|||||||
|
|
||||||
export const URL_KISS_WORKER = "https://github.com/fishjar/kiss-worker";
|
export const URL_KISS_WORKER = "https://github.com/fishjar/kiss-worker";
|
||||||
export const URL_KISS_PROXY = "https://github.com/fishjar/kiss-proxy";
|
export const URL_KISS_PROXY = "https://github.com/fishjar/kiss-proxy";
|
||||||
|
export const URL_KISS_RULES = "https://github.com/fishjar/kiss-rules";
|
||||||
|
export const URL_KISS_RULES_NEW_ISSUE =
|
||||||
|
"https://github.com/fishjar/kiss-rules/issues/new";
|
||||||
export const URL_RAW_PREFIX =
|
export const URL_RAW_PREFIX =
|
||||||
"https://raw.githubusercontent.com/fishjar/kiss-translator/master";
|
"https://raw.githubusercontent.com/fishjar/kiss-translator/master";
|
||||||
export const URL_MICROSOFT_AUTH = "https://edge.microsoft.com/translate/auth";
|
export const URL_MICROSOFT_AUTH = "https://edge.microsoft.com/translate/auth";
|
||||||
@@ -183,10 +186,14 @@ export const GLOBLA_RULE = {
|
|||||||
export const DEFAULT_SUBRULES_LIST = [
|
export const DEFAULT_SUBRULES_LIST = [
|
||||||
{
|
{
|
||||||
url: process.env.REACT_APP_RULESURL,
|
url: process.env.REACT_APP_RULESURL,
|
||||||
|
selected: false,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
url: process.env.REACT_APP_RULESURL_ON,
|
||||||
selected: true,
|
selected: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
url: process.env.REACT_APP_RULESURL2,
|
url: process.env.REACT_APP_RULESURL_OFF,
|
||||||
selected: false,
|
selected: false,
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|||||||
@@ -177,7 +177,9 @@ const RULES = [
|
|||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
export const BUILTIN_RULES = RULES.map((item) => ({
|
export const BUILTIN_RULES = RULES.sort((a, b) =>
|
||||||
|
a.pattern.localeCompare(b.pattern)
|
||||||
|
).map((item) => ({
|
||||||
...DEFAULT_RULE,
|
...DEFAULT_RULE,
|
||||||
...item,
|
...item,
|
||||||
transOpen: "true",
|
transOpen: "true",
|
||||||
|
|||||||
@@ -83,7 +83,9 @@ const fetchApi = async ({ input, init = {}, translator, token }) => {
|
|||||||
} else {
|
} else {
|
||||||
info = GM.info;
|
info = GM.info;
|
||||||
}
|
}
|
||||||
const connects = info?.script?.connects || [];
|
// Tampermonkey --> .connects
|
||||||
|
// Violentmonkey --> .connect
|
||||||
|
const connects = info?.script?.connects || info?.script?.connect || [];
|
||||||
const url = new URL(input);
|
const url = new URL(input);
|
||||||
const isSafe = connects.find((item) => url.hostname.endsWith(item));
|
const isSafe = connects.find((item) => url.hostname.endsWith(item));
|
||||||
if (isSafe) {
|
if (isSafe) {
|
||||||
|
|||||||
@@ -1,18 +1,15 @@
|
|||||||
import Paper from "@mui/material/Paper";
|
import Paper from "@mui/material/Paper";
|
||||||
import Box from "@mui/material/Box";
|
|
||||||
import Fab from "@mui/material/Fab";
|
import Fab from "@mui/material/Fab";
|
||||||
import TranslateIcon from "@mui/icons-material/Translate";
|
import TranslateIcon from "@mui/icons-material/Translate";
|
||||||
import ThemeProvider from "../../hooks/Theme";
|
import ThemeProvider from "../../hooks/Theme";
|
||||||
import Draggable from "./Draggable";
|
import Draggable from "./Draggable";
|
||||||
import IconButton from "@mui/material/IconButton";
|
|
||||||
import CloseIcon from "@mui/icons-material/Close";
|
|
||||||
import Stack from "@mui/material/Stack";
|
|
||||||
import { useEffect, useState, useMemo, useCallback } from "react";
|
import { useEffect, useState, useMemo, useCallback } from "react";
|
||||||
import { SettingProvider } from "../../hooks/Setting";
|
import { SettingProvider } from "../../hooks/Setting";
|
||||||
import Popup from "../Popup";
|
import Popup from "../Popup";
|
||||||
import { debounce } from "../../libs/utils";
|
import { debounce } from "../../libs/utils";
|
||||||
import * as shortcut from "@violentmonkey/shortcut";
|
import * as shortcut from "@violentmonkey/shortcut";
|
||||||
import { isGm } from "../../libs/client";
|
import { isGm } from "../../libs/client";
|
||||||
|
import Header from "../Popup/Header";
|
||||||
|
|
||||||
export default function Action({ translator, fab }) {
|
export default function Action({ translator, fab }) {
|
||||||
const fabWidth = 40;
|
const fabWidth = 40;
|
||||||
@@ -161,23 +158,7 @@ export default function Action({ translator, fab }) {
|
|||||||
onMove={handleMove}
|
onMove={handleMove}
|
||||||
handler={
|
handler={
|
||||||
<Paper style={{ cursor: "move" }} elevation={3}>
|
<Paper style={{ cursor: "move" }} elevation={3}>
|
||||||
<Stack
|
<Header setShowPopup={setShowPopup} />
|
||||||
direction="row"
|
|
||||||
justifyContent="space-between"
|
|
||||||
alignItems="center"
|
|
||||||
spacing={2}
|
|
||||||
>
|
|
||||||
<Box style={{ marginLeft: 16 }}>
|
|
||||||
{`${process.env.REACT_APP_NAME} v${process.env.REACT_APP_VERSION}`}
|
|
||||||
</Box>
|
|
||||||
<IconButton
|
|
||||||
onClick={() => {
|
|
||||||
setShowPopup(false);
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<CloseIcon />
|
|
||||||
</IconButton>
|
|
||||||
</Stack>
|
|
||||||
</Paper>
|
</Paper>
|
||||||
}
|
}
|
||||||
>
|
>
|
||||||
|
|||||||
@@ -17,6 +17,7 @@ import styled from "styled-components";
|
|||||||
|
|
||||||
const LineSpan = styled.span`
|
const LineSpan = styled.span`
|
||||||
opacity: 0.6;
|
opacity: 0.6;
|
||||||
|
-webkit-opacity: 0.6;
|
||||||
text-decoration-line: underline;
|
text-decoration-line: underline;
|
||||||
text-decoration-style: ${(props) => props.$lineStyle};
|
text-decoration-style: ${(props) => props.$lineStyle};
|
||||||
text-decoration-color: ${(props) => props.$lineColor};
|
text-decoration-color: ${(props) => props.$lineColor};
|
||||||
@@ -29,23 +30,22 @@ const LineSpan = styled.span`
|
|||||||
-webkit-text-underline-offset: 0.3em;
|
-webkit-text-underline-offset: 0.3em;
|
||||||
&:hover {
|
&:hover {
|
||||||
opacity: 1;
|
opacity: 1;
|
||||||
|
-webkit-opacity: 1;
|
||||||
}
|
}
|
||||||
`;
|
`;
|
||||||
|
|
||||||
const FuzzySpan = styled.span`
|
const FuzzySpan = styled.span`
|
||||||
filter: blur(5px);
|
filter: blur(5px);
|
||||||
transition: filter 0.2s ease-in-out;
|
-webkit-filter: blur(5px);
|
||||||
&hover: {
|
&:hover {
|
||||||
filter: none;
|
filter: none;
|
||||||
|
-webkit-filter: none;
|
||||||
}
|
}
|
||||||
`;
|
`;
|
||||||
|
|
||||||
const HighlightSpan = styled.span`
|
const HighlightSpan = styled.span`
|
||||||
color: #fff;
|
color: #fff;
|
||||||
background-color: ${(props) => props.$bgColor};
|
background-color: ${(props) => props.$bgColor};
|
||||||
&hover: {
|
|
||||||
filter: none;
|
|
||||||
}
|
|
||||||
`;
|
`;
|
||||||
|
|
||||||
const DiySpan = styled.span`
|
const DiySpan = styled.span`
|
||||||
|
|||||||
13
src/views/Options/DarkModeButton.js
Normal file
13
src/views/Options/DarkModeButton.js
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
import IconButton from "@mui/material/IconButton";
|
||||||
|
import { useDarkMode } from "../../hooks/ColorMode";
|
||||||
|
import LightModeIcon from "@mui/icons-material/LightMode";
|
||||||
|
import DarkModeIcon from "@mui/icons-material/DarkMode";
|
||||||
|
|
||||||
|
export default function DarkModeButton() {
|
||||||
|
const { darkMode, toggleDarkMode } = useDarkMode();
|
||||||
|
return (
|
||||||
|
<IconButton onClick={toggleDarkMode} color="inherit">
|
||||||
|
{darkMode ? <LightModeIcon /> : <DarkModeIcon />}
|
||||||
|
</IconButton>
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -4,16 +4,13 @@ import IconButton from "@mui/material/IconButton";
|
|||||||
import MenuIcon from "@mui/icons-material/Menu";
|
import MenuIcon from "@mui/icons-material/Menu";
|
||||||
import Toolbar from "@mui/material/Toolbar";
|
import Toolbar from "@mui/material/Toolbar";
|
||||||
import Box from "@mui/material/Box";
|
import Box from "@mui/material/Box";
|
||||||
import { useDarkMode } from "../../hooks/ColorMode";
|
|
||||||
import LightModeIcon from "@mui/icons-material/LightMode";
|
|
||||||
import DarkModeIcon from "@mui/icons-material/DarkMode";
|
|
||||||
import Link from "@mui/material/Link";
|
import Link from "@mui/material/Link";
|
||||||
import { useI18n } from "../../hooks/I18n";
|
import { useI18n } from "../../hooks/I18n";
|
||||||
|
import DarkModeButton from "./DarkModeButton";
|
||||||
|
|
||||||
function Header(props) {
|
function Header(props) {
|
||||||
const i18n = useI18n();
|
const i18n = useI18n();
|
||||||
const { onDrawerToggle } = props;
|
const { onDrawerToggle } = props;
|
||||||
const { darkMode, toggleDarkMode } = useDarkMode();
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<AppBar
|
<AppBar
|
||||||
@@ -39,11 +36,10 @@ function Header(props) {
|
|||||||
underline="none"
|
underline="none"
|
||||||
color="inherit"
|
color="inherit"
|
||||||
href={process.env.REACT_APP_HOMEPAGE}
|
href={process.env.REACT_APP_HOMEPAGE}
|
||||||
|
target="_blank"
|
||||||
>{`${i18n("app_name")} v${process.env.REACT_APP_VERSION}`}</Link>
|
>{`${i18n("app_name")} v${process.env.REACT_APP_VERSION}`}</Link>
|
||||||
</Box>
|
</Box>
|
||||||
<IconButton onClick={toggleDarkMode} color="inherit">
|
<DarkModeButton />
|
||||||
{darkMode ? <LightModeIcon /> : <DarkModeIcon />}
|
|
||||||
</IconButton>
|
|
||||||
</Toolbar>
|
</Toolbar>
|
||||||
</AppBar>
|
</AppBar>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ import {
|
|||||||
OPT_STYLE_ALL,
|
OPT_STYLE_ALL,
|
||||||
OPT_STYLE_DIY,
|
OPT_STYLE_DIY,
|
||||||
OPT_STYLE_USE_COLOR,
|
OPT_STYLE_USE_COLOR,
|
||||||
|
URL_KISS_RULES_NEW_ISSUE,
|
||||||
} from "../../config";
|
} from "../../config";
|
||||||
import { useState, useRef, useEffect, useMemo } from "react";
|
import { useState, useRef, useEffect, useMemo } from "react";
|
||||||
import { useI18n } from "../../hooks/I18n";
|
import { useI18n } from "../../hooks/I18n";
|
||||||
@@ -35,6 +36,7 @@ import Radio from "@mui/material/Radio";
|
|||||||
import RadioGroup from "@mui/material/RadioGroup";
|
import RadioGroup from "@mui/material/RadioGroup";
|
||||||
import DeleteIcon from "@mui/icons-material/Delete";
|
import DeleteIcon from "@mui/icons-material/Delete";
|
||||||
import IconButton from "@mui/material/IconButton";
|
import IconButton from "@mui/material/IconButton";
|
||||||
|
import HelpIcon from "@mui/icons-material/Help";
|
||||||
import ShareIcon from "@mui/icons-material/Share";
|
import ShareIcon from "@mui/icons-material/Share";
|
||||||
import SyncIcon from "@mui/icons-material/Sync";
|
import SyncIcon from "@mui/icons-material/Sync";
|
||||||
import { useSubRules } from "../../hooks/SubRules";
|
import { useSubRules } from "../../hooks/SubRules";
|
||||||
@@ -470,7 +472,23 @@ function ShareButton({ rules, injectRules, selectedUrl }) {
|
|||||||
onClick={handleClick}
|
onClick={handleClick}
|
||||||
startIcon={<ShareIcon />}
|
startIcon={<ShareIcon />}
|
||||||
>
|
>
|
||||||
{"分享"}
|
{i18n("share")}
|
||||||
|
</Button>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
function HelpButton() {
|
||||||
|
const i18n = useI18n();
|
||||||
|
return (
|
||||||
|
<Button
|
||||||
|
size="small"
|
||||||
|
variant="outlined"
|
||||||
|
onClick={() => {
|
||||||
|
window.open(URL_KISS_RULES_NEW_ISSUE, "_blank");
|
||||||
|
}}
|
||||||
|
startIcon={<HelpIcon />}
|
||||||
|
>
|
||||||
|
{i18n("help")}
|
||||||
</Button>
|
</Button>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -552,6 +570,8 @@ function UserRules({ subRules }) {
|
|||||||
selectedUrl={selectedUrl}
|
selectedUrl={selectedUrl}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
|
<HelpButton />
|
||||||
|
|
||||||
<FormControlLabel
|
<FormControlLabel
|
||||||
control={
|
control={
|
||||||
<Switch
|
<Switch
|
||||||
@@ -715,6 +735,7 @@ function SubRulesEdit({ subList, addSub }) {
|
|||||||
>
|
>
|
||||||
{i18n("add")}
|
{i18n("add")}
|
||||||
</Button>
|
</Button>
|
||||||
|
<HelpButton />
|
||||||
</Stack>
|
</Stack>
|
||||||
|
|
||||||
{showInput && (
|
{showInput && (
|
||||||
|
|||||||
@@ -6,14 +6,64 @@ import MenuItem from "@mui/material/MenuItem";
|
|||||||
import FormControl from "@mui/material/FormControl";
|
import FormControl from "@mui/material/FormControl";
|
||||||
import Select from "@mui/material/Select";
|
import Select from "@mui/material/Select";
|
||||||
import Link from "@mui/material/Link";
|
import Link from "@mui/material/Link";
|
||||||
|
import FormHelperText from "@mui/material/FormHelperText";
|
||||||
import { useSetting } from "../../hooks/Setting";
|
import { useSetting } from "../../hooks/Setting";
|
||||||
import { limitNumber } from "../../libs/utils";
|
import { limitNumber } from "../../libs/utils";
|
||||||
import { useI18n } from "../../hooks/I18n";
|
import { useI18n } from "../../hooks/I18n";
|
||||||
import { UI_LANGS, URL_KISS_PROXY, TRANS_NEWLINE_LENGTH } from "../../config";
|
import { apiTranslate } from "../../apis";
|
||||||
|
import { useAlert } from "../../hooks/Alert";
|
||||||
|
import CircularProgress from "@mui/material/CircularProgress";
|
||||||
|
import {
|
||||||
|
UI_LANGS,
|
||||||
|
URL_KISS_PROXY,
|
||||||
|
TRANS_NEWLINE_LENGTH,
|
||||||
|
CACHE_NAME,
|
||||||
|
OPT_TRANS_GOOGLE,
|
||||||
|
OPT_TRANS_DEEPL,
|
||||||
|
OPT_TRANS_OPENAI,
|
||||||
|
} from "../../config";
|
||||||
|
import { useState } from "react";
|
||||||
|
|
||||||
|
function TestLink({ translator, setting }) {
|
||||||
|
const i18n = useI18n();
|
||||||
|
const alert = useAlert();
|
||||||
|
const [loading, setLoading] = useState(false);
|
||||||
|
const handleApiTest = async () => {
|
||||||
|
try {
|
||||||
|
setLoading(true);
|
||||||
|
const [text] = await apiTranslate({
|
||||||
|
translator,
|
||||||
|
q: "hello world",
|
||||||
|
fromLang: "en",
|
||||||
|
toLang: "zh-CN",
|
||||||
|
setting,
|
||||||
|
});
|
||||||
|
if (!text) {
|
||||||
|
throw new Error("empty reault");
|
||||||
|
}
|
||||||
|
alert.success(i18n("test_success"));
|
||||||
|
} catch (err) {
|
||||||
|
alert.error(`${i18n("test_failed")}: ${err.message}`);
|
||||||
|
} finally {
|
||||||
|
setLoading(false);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
if (loading) {
|
||||||
|
return <CircularProgress sx={{ marginLeft: "2em" }} size={12} />;
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Link sx={{ marginLeft: "1em" }} component="button" onClick={handleApiTest}>
|
||||||
|
{i18n("click_test")}
|
||||||
|
</Link>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
export default function Settings() {
|
export default function Settings() {
|
||||||
const i18n = useI18n();
|
const i18n = useI18n();
|
||||||
const { setting, updateSetting } = useSetting();
|
const { setting, updateSetting } = useSetting();
|
||||||
|
const alert = useAlert();
|
||||||
|
|
||||||
const handleChange = (e) => {
|
const handleChange = (e) => {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
@@ -41,6 +91,15 @@ export default function Settings() {
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const handleClearCache = () => {
|
||||||
|
try {
|
||||||
|
caches.delete(CACHE_NAME);
|
||||||
|
alert.success(i18n("clear_success"));
|
||||||
|
} catch (err) {
|
||||||
|
console.log("[clear cache]", err);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
const {
|
const {
|
||||||
uiLang,
|
uiLang,
|
||||||
googleUrl,
|
googleUrl,
|
||||||
@@ -123,32 +182,53 @@ export default function Settings() {
|
|||||||
/>
|
/>
|
||||||
|
|
||||||
<FormControl size="small">
|
<FormControl size="small">
|
||||||
<InputLabel>{i18n("clear_cache")}</InputLabel>
|
<InputLabel>{i18n("if_clear_cache")}</InputLabel>
|
||||||
<Select
|
<Select
|
||||||
name="clearCache"
|
name="clearCache"
|
||||||
value={clearCache}
|
value={clearCache}
|
||||||
label={i18n("clear_cache")}
|
label={i18n("if_clear_cache")}
|
||||||
onChange={handleChange}
|
onChange={handleChange}
|
||||||
>
|
>
|
||||||
<MenuItem value={false}>{i18n("clear_cache_never")}</MenuItem>
|
<MenuItem value={false}>{i18n("clear_cache_never")}</MenuItem>
|
||||||
<MenuItem value={true}>{i18n("clear_cache_restart")}</MenuItem>
|
<MenuItem value={true}>{i18n("clear_cache_restart")}</MenuItem>
|
||||||
</Select>
|
</Select>
|
||||||
|
<FormHelperText>
|
||||||
|
<Link component="button" onClick={handleClearCache}>
|
||||||
|
{i18n("clear_all_cache_now")}
|
||||||
|
</Link>
|
||||||
|
</FormHelperText>
|
||||||
</FormControl>
|
</FormControl>
|
||||||
|
|
||||||
<TextField
|
<TextField
|
||||||
size="small"
|
size="small"
|
||||||
label={i18n("google_api")}
|
label={
|
||||||
|
<>
|
||||||
|
{i18n("google_api")}
|
||||||
|
{googleUrl && (
|
||||||
|
<TestLink translator={OPT_TRANS_GOOGLE} setting={setting} />
|
||||||
|
)}
|
||||||
|
</>
|
||||||
|
}
|
||||||
name="googleUrl"
|
name="googleUrl"
|
||||||
value={googleUrl}
|
value={googleUrl}
|
||||||
onChange={handleChange}
|
onChange={handleChange}
|
||||||
helperText={
|
helperText={
|
||||||
<Link href={URL_KISS_PROXY}>{i18n("about_api_proxy")}</Link>
|
<Link href={URL_KISS_PROXY} target="_blank">
|
||||||
|
{i18n("about_api_proxy")}
|
||||||
|
</Link>
|
||||||
}
|
}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<TextField
|
<TextField
|
||||||
size="small"
|
size="small"
|
||||||
label={i18n("deepl_api")}
|
label={
|
||||||
|
<>
|
||||||
|
{i18n("deepl_api")}
|
||||||
|
{deeplUrl && (
|
||||||
|
<TestLink translator={OPT_TRANS_DEEPL} setting={setting} />
|
||||||
|
)}
|
||||||
|
</>
|
||||||
|
}
|
||||||
name="deeplUrl"
|
name="deeplUrl"
|
||||||
value={deeplUrl}
|
value={deeplUrl}
|
||||||
onChange={handleChange}
|
onChange={handleChange}
|
||||||
@@ -164,12 +244,21 @@ export default function Settings() {
|
|||||||
|
|
||||||
<TextField
|
<TextField
|
||||||
size="small"
|
size="small"
|
||||||
label={i18n("openai_api")}
|
label={
|
||||||
|
<>
|
||||||
|
{i18n("openai_api")}
|
||||||
|
{openaiUrl && openaiPrompt && (
|
||||||
|
<TestLink translator={OPT_TRANS_OPENAI} setting={setting} />
|
||||||
|
)}
|
||||||
|
</>
|
||||||
|
}
|
||||||
name="openaiUrl"
|
name="openaiUrl"
|
||||||
value={openaiUrl}
|
value={openaiUrl}
|
||||||
onChange={handleChange}
|
onChange={handleChange}
|
||||||
helperText={
|
helperText={
|
||||||
<Link href={URL_KISS_PROXY}>{i18n("about_api_proxy")}</Link>
|
<Link href={URL_KISS_PROXY} target="_blank">
|
||||||
|
{i18n("about_api_proxy")}
|
||||||
|
</Link>
|
||||||
}
|
}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
|
|||||||
@@ -35,10 +35,10 @@ export default function SyncSetting() {
|
|||||||
setLoading(true);
|
setLoading(true);
|
||||||
await syncSettingAndRules();
|
await syncSettingAndRules();
|
||||||
await reloadSetting();
|
await reloadSetting();
|
||||||
alert.success(i18n("data_sync_success"));
|
alert.success(i18n("sync_success"));
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.log("[sync all]", err);
|
console.log("[sync all]", err);
|
||||||
alert.error(i18n("data_sync_error"));
|
alert.error(i18n("sync_failed"));
|
||||||
} finally {
|
} finally {
|
||||||
setLoading(false);
|
setLoading(false);
|
||||||
}
|
}
|
||||||
@@ -58,7 +58,9 @@ export default function SyncSetting() {
|
|||||||
value={syncUrl}
|
value={syncUrl}
|
||||||
onChange={handleChange}
|
onChange={handleChange}
|
||||||
helperText={
|
helperText={
|
||||||
<Link href={URL_KISS_WORKER}>{i18n("about_sync_api")}</Link>
|
<Link href={URL_KISS_WORKER} target="_blank">
|
||||||
|
{i18n("about_sync_api")}
|
||||||
|
</Link>
|
||||||
}
|
}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
|
|||||||
42
src/views/Popup/Header.js
Normal file
42
src/views/Popup/Header.js
Normal file
@@ -0,0 +1,42 @@
|
|||||||
|
import Box from "@mui/material/Box";
|
||||||
|
import IconButton from "@mui/material/IconButton";
|
||||||
|
import CloseIcon from "@mui/icons-material/Close";
|
||||||
|
import HomeIcon from "@mui/icons-material/Home";
|
||||||
|
import Stack from "@mui/material/Stack";
|
||||||
|
import DarkModeButton from "../Options/DarkModeButton";
|
||||||
|
|
||||||
|
export default function Header({ setShowPopup }) {
|
||||||
|
const handleHomepage = () => {
|
||||||
|
window.open(process.env.REACT_APP_HOMEPAGE, "_blank");
|
||||||
|
};
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Stack
|
||||||
|
direction="row"
|
||||||
|
justifyContent="space-between"
|
||||||
|
alignItems="center"
|
||||||
|
spacing={2}
|
||||||
|
>
|
||||||
|
<Stack direction="row" justifyContent="flex-start" alignItems="center">
|
||||||
|
<IconButton onClick={handleHomepage}>
|
||||||
|
<HomeIcon />
|
||||||
|
</IconButton>
|
||||||
|
<Box>
|
||||||
|
{`${process.env.REACT_APP_NAME} v${process.env.REACT_APP_VERSION}`}
|
||||||
|
</Box>
|
||||||
|
</Stack>
|
||||||
|
|
||||||
|
{setShowPopup ? (
|
||||||
|
<IconButton
|
||||||
|
onClick={() => {
|
||||||
|
setShowPopup(false);
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<CloseIcon />
|
||||||
|
</IconButton>
|
||||||
|
) : (
|
||||||
|
<DarkModeButton />
|
||||||
|
)}
|
||||||
|
</Stack>
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -10,6 +10,8 @@ import { browser } from "../../libs/browser";
|
|||||||
import { isExt } from "../../libs/client";
|
import { isExt } from "../../libs/client";
|
||||||
import { useI18n } from "../../hooks/I18n";
|
import { useI18n } from "../../hooks/I18n";
|
||||||
import TextField from "@mui/material/TextField";
|
import TextField from "@mui/material/TextField";
|
||||||
|
import Divider from "@mui/material/Divider";
|
||||||
|
import Header from "./Header";
|
||||||
import {
|
import {
|
||||||
MSG_TRANS_TOGGLE,
|
MSG_TRANS_TOGGLE,
|
||||||
MSG_TRANS_GETRULE,
|
MSG_TRANS_GETRULE,
|
||||||
@@ -19,6 +21,7 @@ import {
|
|||||||
OPT_LANGS_TO,
|
OPT_LANGS_TO,
|
||||||
OPT_STYLE_ALL,
|
OPT_STYLE_ALL,
|
||||||
OPT_STYLE_USE_COLOR,
|
OPT_STYLE_USE_COLOR,
|
||||||
|
CACHE_NAME,
|
||||||
} from "../../config";
|
} from "../../config";
|
||||||
import { sendIframeMsg } from "../../libs/iframe";
|
import { sendIframeMsg } from "../../libs/iframe";
|
||||||
|
|
||||||
@@ -66,6 +69,14 @@ export default function Popup({ setShowPopup, translator: tran }) {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const handleClearCache = () => {
|
||||||
|
try {
|
||||||
|
caches.delete(CACHE_NAME);
|
||||||
|
} catch (err) {
|
||||||
|
console.log("[clear cache]", err);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!isExt) {
|
if (!isExt) {
|
||||||
return;
|
return;
|
||||||
@@ -84,8 +95,14 @@ export default function Popup({ setShowPopup, translator: tran }) {
|
|||||||
|
|
||||||
if (!rule) {
|
if (!rule) {
|
||||||
return (
|
return (
|
||||||
<Box minWidth={300} sx={{ p: 2 }}>
|
<Box minWidth={300}>
|
||||||
<Stack spacing={3}>
|
{isExt && (
|
||||||
|
<>
|
||||||
|
<Header />
|
||||||
|
<Divider />
|
||||||
|
</>
|
||||||
|
)}
|
||||||
|
<Stack sx={{ p: 2 }} spacing={3}>
|
||||||
<Button variant="text" onClick={handleOpenSetting}>
|
<Button variant="text" onClick={handleOpenSetting}>
|
||||||
{i18n("setting")}
|
{i18n("setting")}
|
||||||
</Button>
|
</Button>
|
||||||
@@ -97,17 +114,35 @@ export default function Popup({ setShowPopup, translator: tran }) {
|
|||||||
const { transOpen, translator, fromLang, toLang, textStyle, bgColor } = rule;
|
const { transOpen, translator, fromLang, toLang, textStyle, bgColor } = rule;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Box minWidth={300} sx={{ p: 2 }}>
|
<Box minWidth={300}>
|
||||||
<Stack spacing={2}>
|
{isExt && (
|
||||||
<FormControlLabel
|
<>
|
||||||
control={
|
<Header />
|
||||||
<Switch
|
<Divider />
|
||||||
checked={transOpen === "true"}
|
</>
|
||||||
onChange={handleTransToggle}
|
)}
|
||||||
/>
|
<Stack sx={{ p: 2 }} spacing={2}>
|
||||||
}
|
<Stack
|
||||||
label={i18n("translate_alt")}
|
direction="row"
|
||||||
/>
|
justifyContent="space-between"
|
||||||
|
alignItems="center"
|
||||||
|
spacing={2}
|
||||||
|
>
|
||||||
|
<FormControlLabel
|
||||||
|
control={
|
||||||
|
<Switch
|
||||||
|
checked={transOpen === "true"}
|
||||||
|
onChange={handleTransToggle}
|
||||||
|
/>
|
||||||
|
}
|
||||||
|
label={i18n("translate_alt")}
|
||||||
|
/>
|
||||||
|
{!isExt && (
|
||||||
|
<Button variant="text" onClick={handleClearCache}>
|
||||||
|
{i18n("clear_cache")}
|
||||||
|
</Button>
|
||||||
|
)}
|
||||||
|
</Stack>
|
||||||
|
|
||||||
<TextField
|
<TextField
|
||||||
select
|
select
|
||||||
|
|||||||
Reference in New Issue
Block a user