From 041ffb7462eef86f12c0fa4a82ba02ab6b6d5669 Mon Sep 17 00:00:00 2001 From: lencx Date: Fri, 3 Feb 2023 01:11:56 +0800 Subject: [PATCH 1/5] fix: conf error (#295) --- src-tauri/src/conf.rs | 9 ++++++++- src-tauri/src/scripts/export.js | 13 +++++++++---- 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/src-tauri/src/conf.rs b/src-tauri/src/conf.rs index 99349d2..56e0439 100644 --- a/src-tauri/src/conf.rs +++ b/src-tauri/src/conf.rs @@ -76,7 +76,14 @@ impl AppConf { pub fn read() -> Self { match std::fs::read_to_string(Self::file_path()) { - Ok(v) => serde_json::from_str::(&v).unwrap(), + Ok(v) => { + if let Ok(v2) = serde_json::from_str::(&v) { + v2 + } else { + error!("conf_read_parse_error"); + Self::default() + } + } Err(err) => { error!("conf_read_error: {}", err); Self::default() diff --git a/src-tauri/src/scripts/export.js b/src-tauri/src/scripts/export.js index 08bf45b..fc96abd 100644 --- a/src-tauri/src/scripts/export.js +++ b/src-tauri/src/scripts/export.js @@ -274,7 +274,8 @@ function setIcon(type) { png: ``, pdf: ``, md: ``, - copy: `` + copy: ``, + cpok: `` }[type]; } @@ -289,12 +290,14 @@ function copyBtns() { btn.innerHTML = setIcon('copy'); i.querySelector('.self-end').appendChild(btn); btn.onclick = () => { - copyToClipboard(i?.innerText?.trim() || ''); + copyToClipboard(i?.innerText?.trim() || '', btn); } }) } -function copyToClipboard(text) { +function copyToClipboard(text, btn) { + window.clearTimeout(window.__cpTimeout); + btn.innerHTML = setIcon('cpok'); if (navigator.clipboard) { navigator.clipboard.writeText(text); } else { @@ -308,7 +311,9 @@ function copyToClipboard(text) { document.execCommand('copy', true); document.body.removeChild(textarea); } - message('Copied to clipboard'); + window.__cpTimeout = setTimeout(() => { + btn.innerHTML = setIcon('copy'); + }, 1000); } if ( From 4847bb6fac51ac845b0d065eda97494878a8f98c Mon Sep 17 00:00:00 2001 From: lencx Date: Fri, 3 Feb 2023 01:30:03 +0800 Subject: [PATCH 2/5] chore: copy --- src-tauri/src/scripts/cmd.js | 4 ++++ src-tauri/src/scripts/export.js | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src-tauri/src/scripts/cmd.js b/src-tauri/src/scripts/cmd.js index 9a7f727..385b4fb 100644 --- a/src-tauri/src/scripts/cmd.js +++ b/src-tauri/src/scripts/cmd.js @@ -79,6 +79,10 @@ function init() { width: 16px; height: 16px; } + .chatappico.cpok { + width: 16px; + height: 16px; + } @media screen and (max-width: 767px) { #download-png-button, #download-pdf-button, #download-html-button { display: none; diff --git a/src-tauri/src/scripts/export.js b/src-tauri/src/scripts/export.js index fc96abd..5a0b727 100644 --- a/src-tauri/src/scripts/export.js +++ b/src-tauri/src/scripts/export.js @@ -275,7 +275,7 @@ function setIcon(type) { pdf: ``, md: ``, copy: ``, - cpok: `` + cpok: `` }[type]; } From 70aac07f8ea9504fc6f740bcdb561f4fd18736c9 Mon Sep 17 00:00:00 2001 From: lencx Date: Fri, 3 Feb 2023 12:22:15 +0800 Subject: [PATCH 3/5] feat: markdown export (#233) --- UPDATE_LOG.md | 11 +++++++++++ src-tauri/src/scripts/export.js | 9 ++++++++- src-tauri/src/scripts/markdown.export.js | 4 +++- 3 files changed, 22 insertions(+), 2 deletions(-) diff --git a/UPDATE_LOG.md b/UPDATE_LOG.md index ccc4cc9..3e58e50 100644 --- a/UPDATE_LOG.md +++ b/UPDATE_LOG.md @@ -1,5 +1,16 @@ # UPDATE LOG +## v0.10.3 + +Fix: + +- Incompatible configuration data causes program crashes (https://github.com/lencx/ChatGPT/issues/295) +- Silent copy text + +Feat: + +- markdown export support distinguishes between users and bots (https://github.com/lencx/ChatGPT/issues/233) + ## v0.10.2 Fix: diff --git a/src-tauri/src/scripts/export.js b/src-tauri/src/scripts/export.js index 5a0b727..6924bf6 100644 --- a/src-tauri/src/scripts/export.js +++ b/src-tauri/src/scripts/export.js @@ -137,7 +137,14 @@ function addActionsButtons(actionsArea, TryAgainButton) { } async function exportMarkdown() { - const data = ExportMD.turndown(document.querySelector("main div>div>div").innerHTML); + const content = Array.from(document.querySelectorAll("main >div>div>div>div")).map(i => { + let j = i.cloneNode(true); + if (/dark\:bg-gray-800/.test(i.getAttribute('class'))) { + j.innerHTML = `
${i.innerHTML}
`; + } + return j.innerHTML; + }).join('
'); + const data = ExportMD.turndown(content); const { id, filename } = getName(); await invoke('save_file', { name: `notes/${id}.md`, content: data }); await invoke('download_list', { pathname: 'chat.notes.json', filename, id, dir: 'notes' }); diff --git a/src-tauri/src/scripts/markdown.export.js b/src-tauri/src/scripts/markdown.export.js index 651eebc..4c9d5fb 100644 --- a/src-tauri/src/scripts/markdown.export.js +++ b/src-tauri/src/scripts/markdown.export.js @@ -2,7 +2,9 @@ var ExportMD = (function () { if (!TurndownService || !turndownPluginGfm) return; const hljsREG = /^.*(hljs).*(language-[a-z0-9]+).*$/i; const gfm = turndownPluginGfm.gfm - const turndownService = new TurndownService() + const turndownService = new TurndownService({ + hr: '---' + }) .use(gfm) .addRule('code', { filter: (node) => { From 01c6e11e8c30336d6db4107647130f0b1057cd2c Mon Sep 17 00:00:00 2001 From: lencx Date: Fri, 3 Feb 2023 13:33:26 +0800 Subject: [PATCH 4/5] release --- README-ZH_CN.md | 12 ++++++------ README.md | 12 ++++++------ UPDATE_LOG.md | 6 ++++-- 3 files changed, 16 insertions(+), 14 deletions(-) diff --git a/README-ZH_CN.md b/README-ZH_CN.md index 395fb03..e7c1d0b 100644 --- a/README-ZH_CN.md +++ b/README-ZH_CN.md @@ -24,7 +24,7 @@ ### Windows -- [ChatGPT_0.10.2_x64_en-US.msi](https://github.com/lencx/ChatGPT/releases/download/v0.10.2/ChatGPT_0.10.2_x64_en-US.msi): +- [ChatGPT_0.10.3_x64_en-US.msi](https://github.com/lencx/ChatGPT/releases/download/v0.10.3/ChatGPT_0.10.3_x64_en-US.msi): - 使用 [winget](https://winstall.app/apps/lencx.ChatGPT): ```bash @@ -35,12 +35,12 @@ winget install --id=lencx.ChatGPT -e --version 0.10.0 ``` -**注意:如果安装路径和应用名称相同,会导致冲突 ([#142](https://github.com/lencx/ChatGPT/issues/142#issuecomment-0.10.2))** +**注意:如果安装路径和应用名称相同,会导致冲突 ([#142](https://github.com/lencx/ChatGPT/issues/142#issuecomment-0.10.3))** ### Mac -- [ChatGPT_0.10.2_x64.dmg](https://github.com/lencx/ChatGPT/releases/download/v0.10.2/ChatGPT_0.10.2_x64.dmg) -- [ChatGPT.app.tar.gz](https://github.com/lencx/ChatGPT/releases/download/v0.10.2/ChatGPT.app.tar.gz) +- [ChatGPT_0.10.3_x64.dmg](https://github.com/lencx/ChatGPT/releases/download/v0.10.3/ChatGPT_0.10.3_x64.dmg) +- [ChatGPT.app.tar.gz](https://github.com/lencx/ChatGPT/releases/download/v0.10.3/ChatGPT.app.tar.gz) - Homebrew \ _[Homebrew 快捷安装](https://brew.sh) ([Cask](https://docs.brew.sh/Cask-Cookbook)):_ ```sh @@ -56,8 +56,8 @@ ### Linux -- [chat-gpt_0.10.2_amd64.deb](https://github.com/lencx/ChatGPT/releases/download/v0.10.2/chat-gpt_0.10.2_amd64.deb) -- [chat-gpt_0.10.2_amd64.AppImage](https://github.com/lencx/ChatGPT/releases/download/v0.10.2/chat-gpt_0.10.2_amd64.AppImage): **工作可靠,`.deb` 运行失败时可以尝试它** +- [chat-gpt_0.10.3_amd64.deb](https://github.com/lencx/ChatGPT/releases/download/v0.10.3/chat-gpt_0.10.3_amd64.deb) +- [chat-gpt_0.10.3_amd64.AppImage](https://github.com/lencx/ChatGPT/releases/download/v0.10.3/chat-gpt_0.10.3_amd64.AppImage): **工作可靠,`.deb` 运行失败时可以尝试它** - 使用 [AUR](https://aur.archlinux.org/packages/chatgpt-desktop-bin): ```bash yay -S chatgpt-desktop-bin diff --git a/README.md b/README.md index 4365bce..f07a2d7 100644 --- a/README.md +++ b/README.md @@ -27,7 +27,7 @@ ### Windows -- [ChatGPT_0.10.2_x64_en-US.msi](https://github.com/lencx/ChatGPT/releases/download/v0.10.2/ChatGPT_0.10.2_x64_en-US.msi): Direct download installer +- [ChatGPT_0.10.3_x64_en-US.msi](https://github.com/lencx/ChatGPT/releases/download/v0.10.3/ChatGPT_0.10.3_x64_en-US.msi): Direct download installer - Use [winget](https://winstall.app/apps/lencx.ChatGPT): ```bash @@ -38,12 +38,12 @@ winget install --id=lencx.ChatGPT -e --version 0.10.0 ``` -**Note: If the installation path and application name are the same, it will lead to conflict ([#142](https://github.com/lencx/ChatGPT/issues/142#issuecomment-0.10.2))** +**Note: If the installation path and application name are the same, it will lead to conflict ([#142](https://github.com/lencx/ChatGPT/issues/142#issuecomment-0.10.3))** ### Mac -- [ChatGPT_0.10.2_x64.dmg](https://github.com/lencx/ChatGPT/releases/download/v0.10.2/ChatGPT_0.10.2_x64.dmg): Direct download installer -- [ChatGPT.app.tar.gz](https://github.com/lencx/ChatGPT/releases/download/v0.10.2/ChatGPT.app.tar.gz): Download the `.app` installer +- [ChatGPT_0.10.3_x64.dmg](https://github.com/lencx/ChatGPT/releases/download/v0.10.3/ChatGPT_0.10.3_x64.dmg): Direct download installer +- [ChatGPT.app.tar.gz](https://github.com/lencx/ChatGPT/releases/download/v0.10.3/ChatGPT.app.tar.gz): Download the `.app` installer - Homebrew \ Or you can install with _[Homebrew](https://brew.sh) ([Cask](https://docs.brew.sh/Cask-Cookbook)):_ ```sh @@ -59,8 +59,8 @@ ### Linux -- [chat-gpt_0.10.2_amd64.deb](https://github.com/lencx/ChatGPT/releases/download/v0.10.2/chat-gpt_0.10.2_amd64.deb): Download `.deb` installer, advantage small size, disadvantage poor compatibility -- [chat-gpt_0.10.2_amd64.AppImage](https://github.com/lencx/ChatGPT/releases/download/v0.10.2/chat-gpt_0.10.2_amd64.AppImage): Works reliably, you can try it if `.deb` fails to run +- [chat-gpt_0.10.3_amd64.deb](https://github.com/lencx/ChatGPT/releases/download/v0.10.3/chat-gpt_0.10.3_amd64.deb): Download `.deb` installer, advantage small size, disadvantage poor compatibility +- [chat-gpt_0.10.3_amd64.AppImage](https://github.com/lencx/ChatGPT/releases/download/v0.10.3/chat-gpt_0.10.3_amd64.AppImage): Works reliably, you can try it if `.deb` fails to run - Available on [AUR](https://aur.archlinux.org/packages/chatgpt-desktop-bin) with the package name `chatgpt-desktop-bin`, and you can use your favourite AUR package manager to install it. diff --git a/UPDATE_LOG.md b/UPDATE_LOG.md index 3e58e50..4f0a39f 100644 --- a/UPDATE_LOG.md +++ b/UPDATE_LOG.md @@ -2,14 +2,16 @@ ## v0.10.3 +> Note: As of now the ChatGPT desktop app has added a lot of exciting features and it continues to improve, as the app grows it has gone far beyond what ChatGPT was intended for. I want to make it the ultimate goal that any website can be easily wrapped to the desktop through user customization. So it needed an international user guide to guide users to use it more professionally. And https://app.nofwl.com is the manual for the app, which will be built into the app (`Menu -> Window -> ChatGPT User's Guide`) so you can access it anytime. It's just starting at the moment, so stay tuned. + Fix: - Incompatible configuration data causes program crashes (https://github.com/lencx/ChatGPT/issues/295) -- Silent copy text Feat: -- markdown export support distinguishes between users and bots (https://github.com/lencx/ChatGPT/issues/233) +- Silent copy text +- Markdown export support distinguishes between users and bots (https://github.com/lencx/ChatGPT/issues/233) ## v0.10.2 From c6efaec58662df1c5c2e798673cadd18679c542c Mon Sep 17 00:00:00 2001 From: lencx Date: Fri, 3 Feb 2023 13:34:42 +0800 Subject: [PATCH 5/5] v0.10.3 --- src-tauri/tauri.conf.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src-tauri/tauri.conf.json b/src-tauri/tauri.conf.json index e2b3bdb..5b46b0d 100644 --- a/src-tauri/tauri.conf.json +++ b/src-tauri/tauri.conf.json @@ -7,7 +7,7 @@ }, "package": { "productName": "ChatGPT", - "version": "0.10.2" + "version": "0.10.3" }, "tauri": { "allowlist": {