Skip to content

Commit

Permalink
3.0.3
Browse files Browse the repository at this point in the history
  • Loading branch information
Pylogmon committed Jun 26, 2024
1 parent ff9629c commit cc77765
Show file tree
Hide file tree
Showing 11 changed files with 96 additions and 19 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
## 3.0.2 (2024-06-24)
## 3.0.3 (2024-06-26)

### Break Change:

Expand All @@ -9,6 +9,7 @@

- support multiple instance service
- use javascript plugin system
- enable dev tools

### Bugs fixed:

Expand Down
24 changes: 23 additions & 1 deletion com.pot_app.pot.metainfo.xml
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,29 @@
</screenshot>
</screenshots>
<releases>
<release version="3.0.2" date="2024-06-24">
<release version="3.0.3" date="2024-06-26">
<url type="details">https://github.com/pot-app/pot-desktop/releases/tag/3.0.3</url>
<description>
<p>Break Change:</p>
<ul>
<li>After version 3.x, old plugins will no longer be available. They will be automatically deleted upon upgrade. Please visit the plugin repository to download and install the new versions. If the plugin developers have not yet updated their plugins, please contact them to request an upgrade.</li>
<li xml:lang="zh-Hans">3.x版本之后旧版插件不再可用,升级后会自动删除旧版插件,请前往插件仓库下载安装新版插件使用,若插件开发者还没适配新版插件,请联系插件开发者升级插件。</li>
</ul>
<p>New feature:</p>
<ul>
<li>Support multiple instance services</li>
<li>Use Javascript plugin system</li>
<li>Enable dev tools</li>
</ul>
<p>Bugs fixed:</p>
<ul>
<li>Recognize failed</li>
<li>TTS failed</li>
<li>Collection failed</li>
</ul>
</description>
</release>
<release version="3.0.2" date="2024-06-24">
<url type="details">https://github.com/pot-app/pot-desktop/releases/tag/3.0.2</url>
<description>
<p>Break Change:</p>
Expand Down
2 changes: 1 addition & 1 deletion src-tauri/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ tauri-build = { version = "1.5", features = [] }

[dependencies]

tauri = { version = "1.6", features = [ "dialog-save", "dialog-open", "fs-all", "protocol-asset", "shell-all", "clipboard-all", "os-all", "http-all", "http-multipart", "updater", "notification-all", "global-shortcut-all", "window-all", "path-all", "system-tray"] }
tauri = { version = "1.6", features = [ "dialog-save", "dialog-open", "fs-all", "protocol-asset", "shell-all", "clipboard-all", "os-all", "http-all", "http-multipart", "updater", "notification-all", "global-shortcut-all", "window-all", "path-all", "system-tray", "devtools"] }
tauri-plugin-single-instance = { git = "https://github.com/tauri-apps/plugins-workspace", branch = "v1" }
tauri-plugin-autostart = { git = "https://github.com/tauri-apps/plugins-workspace", branch = "v1" }
tauri-plugin-fs-watch = { git = "https://github.com/tauri-apps/plugins-workspace", branch = "v1" }
Expand Down
9 changes: 9 additions & 0 deletions src-tauri/src/cmd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -216,3 +216,12 @@ pub fn font_list() -> Result<Vec<String>, Error> {

Ok(source.all_families()?)
}

#[tauri::command]
pub fn open_devtools(window: tauri::Window) {
if !window.is_devtools_open() {
window.open_devtools();
} else {
window.close_devtools();
}
}
1 change: 1 addition & 0 deletions src-tauri/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ fn main() {
set_proxy,
unset_proxy,
run_binary,
open_devtools,
register_shortcut_by_frontend,
update_tray,
updater_window,
Expand Down
2 changes: 1 addition & 1 deletion src-tauri/tauri.conf.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
},
"package": {
"productName": "pot",
"version": "3.0.2"
"version": "3.0.3"
},
"tauri": {
"allowlist": {
Expand Down
46 changes: 45 additions & 1 deletion src/App.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { warn } from 'tauri-plugin-log-api';
import React, { useEffect } from 'react';
import { useTheme } from 'next-themes';

import { invoke } from '@tauri-apps/api/tauri';
import Screenshot from './window/Screenshot';
import Translate from './window/Translate';
import Recognize from './window/Recognize';
Expand All @@ -24,6 +25,7 @@ const windowMap = {
};

export default function App() {
const [devMode] = useConfig('dev_mode', false);
const [appTheme] = useConfig('app_theme', 'system');
const [appLanguage] = useConfig('app_language', 'en');
const [appFont] = useConfig('app_font', 'default');
Expand All @@ -34,6 +36,42 @@ export default function App() {

useEffect(() => {
store.load();
}, []);

useEffect(() => {
if (devMode !== null && devMode) {
document.addEventListener('keydown', async (e) => {
let allowKeys = ['c', 'v', 'x', 'a', 'z', 'y'];
if (e.ctrlKey && !allowKeys.includes(e.key.toLowerCase())) {
e.preventDefault();
}
if (e.key === 'F12') {
await invoke('open_devtools');
}
if (e.key.startsWith('F') && e.key.length > 1) {
e.preventDefault();
}
if (e.key === 'Escape') {
await appWindow.close();
}
});
} else {
document.addEventListener('keydown', async (e) => {
let allowKeys = ['c', 'v', 'x', 'a', 'z', 'y'];
if (e.ctrlKey && !allowKeys.includes(e.key.toLowerCase())) {
e.preventDefault();
}
if (e.key.startsWith('F') && e.key.length > 1) {
e.preventDefault();
}
if (e.key === 'Escape') {
await appWindow.close();
}
});
}
}, [devMode]);

useEffect(() => {
if (appTheme !== null) {
if (appTheme !== 'system') {
setTheme(appTheme);
Expand All @@ -56,9 +94,15 @@ export default function App() {
}
}
}
}, [appTheme]);

useEffect(() => {
if (appLanguage !== null) {
i18n.changeLanguage(appLanguage);
}
}, [appLanguage]);

useEffect(() => {
if (appFont !== null && appFallbackFont !== null) {
document.documentElement.style.fontFamily = `"${appFont === 'default' ? 'sans-serif' : appFont}","${
appFallbackFont === 'default' ? 'sans-serif' : appFallbackFont
Expand All @@ -67,7 +111,7 @@ export default function App() {
if (appFontSize !== null) {
document.documentElement.style.fontSize = `${appFontSize}px`;
}
}, [appTheme, appLanguage, appFont, appFallbackFont, appFontSize]);
}, [appFont, appFallbackFont, appFontSize]);

return <BrowserRouter>{windowMap[appWindow.label]}</BrowserRouter>;
}
1 change: 1 addition & 0 deletions src/i18n/locales/en_US.json
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@
"system": "System"
},
"transparent": "Transparent Effect",
"dev_mode": "Developer Mode",
"proxy": {
"title": "Proxy",
"host": "Host",
Expand Down
1 change: 1 addition & 0 deletions src/i18n/locales/zh_CN.json
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@
"system": "跟随系统"
},
"transparent": "透明效果",
"dev_mode": "开发模式",
"proxy": {
"title": "网络代理",
"host": "代理地址",
Expand Down
13 changes: 0 additions & 13 deletions src/main.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,19 +14,6 @@ if (import.meta.env.PROD) {
});
}

document.addEventListener('keydown', async (e) => {
let allowKeys = ['c', 'v', 'x', 'a', 'z', 'y'];
if (e.ctrlKey && !allowKeys.includes(e.key.toLowerCase())) {
e.preventDefault();
}
if (e.key.startsWith('F') && e.key.length > 1) {
e.preventDefault();
}
if (e.key === 'Escape') {
await appWindow.close();
}
});

initStore().then(async () => {
await initEnv();
const rootElement = document.getElementById('root');
Expand Down
13 changes: 12 additions & 1 deletion src/window/Config/pages/General/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ export default function General() {
const [appFallbackFont, setAppFallbackFont] = useConfig('app_fallback_font', 'default');
const [appFontSize, setAppFontSize] = useConfig('app_font_size', 16);
const [transparent, setTransparent] = useConfig('transparent', true);
const [devMode, setDevMode] = useConfig('dev_mode', false);
const [trayClickEvent, setTrayClickEvent] = useConfig('tray_click_event', 'config');
const [proxyEnable, setProxyEnable] = useConfig('proxy_enable', false);
const [proxyHost, setProxyHost] = useConfig('proxy_host', '');
Expand Down Expand Up @@ -128,7 +129,6 @@ export default function General() {
});
}, 1000);
}
console.log(v);
if (v === '') {
setServerPort(0);
} else if (parseInt(v) > 65535) {
Expand Down Expand Up @@ -465,6 +465,17 @@ export default function General() {
/>
)}
</div>
<div className='config-item'>
<h3>{t('config.general.dev_mode')}</h3>
{devMode !== null && (
<Switch
isSelected={devMode}
onValueChange={(v) => {
setDevMode(v);
}}
/>
)}
</div>
</CardBody>
</Card>
<Card>
Expand Down

0 comments on commit cc77765

Please sign in to comment.