mirror of
https://github.com/FranP-code/ChatGPT.git
synced 2025-10-13 00:13:25 +00:00
Compare commits
8 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
59c5a9932d | ||
|
|
7c0003f823 | ||
|
|
a798a8a784 | ||
|
|
4f03487a53 | ||
|
|
ef3820fad8 | ||
|
|
f0c635bd3b | ||
|
|
6d950c09e6 | ||
|
|
26bd845a72 |
20
.github/workflows/release.yml
vendored
20
.github/workflows/release.yml
vendored
@@ -90,13 +90,13 @@ jobs:
|
|||||||
publish_dir: ./updater
|
publish_dir: ./updater
|
||||||
force_orphan: true
|
force_orphan: true
|
||||||
|
|
||||||
publish-winget:
|
# publish-winget:
|
||||||
# Action can only be run on windows
|
# # Action can only be run on windows
|
||||||
runs-on: windows-latest
|
# runs-on: windows-latest
|
||||||
needs: [create-release, build-tauri]
|
# needs: [create-release, build-tauri]
|
||||||
steps:
|
# steps:
|
||||||
- uses: vedantmgoyal2009/winget-releaser@v1
|
# - uses: vedantmgoyal2009/winget-releaser@v1
|
||||||
with:
|
# with:
|
||||||
identifier: lencx.ChatGPT
|
# identifier: lencx.ChatGPT
|
||||||
token: ${{ secrets.WINGET_TOKEN }}
|
# token: ${{ secrets.WINGET_TOKEN }}
|
||||||
version: ${{ env.version }}
|
# version: ${{ env.version }}
|
||||||
|
|||||||
@@ -24,22 +24,22 @@
|
|||||||
|
|
||||||
### Windows
|
### Windows
|
||||||
|
|
||||||
- [ChatGPT_0.8.1_x64_en-US.msi](https://github.com/lencx/ChatGPT/releases/download/v0.8.1/ChatGPT_0.8.1_x64_en-US.msi):
|
- [ChatGPT_0.9.2_x64_en-US.msi](https://github.com/lencx/ChatGPT/releases/download/v0.9.2/ChatGPT_0.9.2_x64_en-US.msi):
|
||||||
- 使用 [winget](https://winstall.app/apps/lencx.ChatGPT):
|
- 使用 [winget](https://winstall.app/apps/lencx.ChatGPT):
|
||||||
```bash
|
```bash
|
||||||
# install the latest version
|
# install the latest version
|
||||||
winget install --id=lencx.ChatGPT -e
|
winget install --id=lencx.ChatGPT -e
|
||||||
|
|
||||||
# install the specified version
|
# install the specified version
|
||||||
winget install --id=lencx.ChatGPT -e --version 0.8.1
|
winget install --id=lencx.ChatGPT -e --version 0.9.0
|
||||||
```
|
```
|
||||||
|
|
||||||
**注意:如果安装路径和应用名称相同,会导致冲突 ([#142](https://github.com/lencx/ChatGPT/issues/142#issuecomment-0.8.1))**
|
**注意:如果安装路径和应用名称相同,会导致冲突 ([#142](https://github.com/lencx/ChatGPT/issues/142#issuecomment-0.9.2))**
|
||||||
|
|
||||||
### Mac
|
### Mac
|
||||||
|
|
||||||
- [ChatGPT_0.8.1_x64.dmg](https://github.com/lencx/ChatGPT/releases/download/v0.8.1/ChatGPT_0.8.1_x64.dmg)
|
- [ChatGPT_0.9.2_x64.dmg](https://github.com/lencx/ChatGPT/releases/download/v0.9.2/ChatGPT_0.9.2_x64.dmg)
|
||||||
- [ChatGPT.app.tar.gz](https://github.com/lencx/ChatGPT/releases/download/v0.8.1/ChatGPT.app.tar.gz)
|
- [ChatGPT.app.tar.gz](https://github.com/lencx/ChatGPT/releases/download/v0.9.2/ChatGPT.app.tar.gz)
|
||||||
- Homebrew \
|
- Homebrew \
|
||||||
_[Homebrew 快捷安装](https://brew.sh) ([Cask](https://docs.brew.sh/Cask-Cookbook)):_
|
_[Homebrew 快捷安装](https://brew.sh) ([Cask](https://docs.brew.sh/Cask-Cookbook)):_
|
||||||
```sh
|
```sh
|
||||||
@@ -55,8 +55,8 @@
|
|||||||
|
|
||||||
### Linux
|
### Linux
|
||||||
|
|
||||||
- [chat-gpt_0.8.1_amd64.deb](https://github.com/lencx/ChatGPT/releases/download/v0.8.1/chat-gpt_0.8.1_amd64.deb)
|
- [chat-gpt_0.9.2_amd64.deb](https://github.com/lencx/ChatGPT/releases/download/v0.9.2/chat-gpt_0.9.2_amd64.deb)
|
||||||
- [chat-gpt_0.8.1_amd64.AppImage](https://github.com/lencx/ChatGPT/releases/download/v0.8.1/chat-gpt_0.8.1_amd64.AppImage): **工作可靠,`.deb` 运行失败时可以尝试它**
|
- [chat-gpt_0.9.2_amd64.AppImage](https://github.com/lencx/ChatGPT/releases/download/v0.9.2/chat-gpt_0.9.2_amd64.AppImage): **工作可靠,`.deb` 运行失败时可以尝试它**
|
||||||
- 使用 [AUR](https://aur.archlinux.org/packages/chatgpt-desktop-bin):
|
- 使用 [AUR](https://aur.archlinux.org/packages/chatgpt-desktop-bin):
|
||||||
```bash
|
```bash
|
||||||
yay -S chatgpt-desktop-bin
|
yay -S chatgpt-desktop-bin
|
||||||
|
|||||||
14
README.md
14
README.md
@@ -26,22 +26,22 @@
|
|||||||
|
|
||||||
### Windows
|
### Windows
|
||||||
|
|
||||||
- [ChatGPT_0.8.1_x64_en-US.msi](https://github.com/lencx/ChatGPT/releases/download/v0.8.1/ChatGPT_0.8.1_x64_en-US.msi): Direct download installer
|
- [ChatGPT_0.9.2_x64_en-US.msi](https://github.com/lencx/ChatGPT/releases/download/v0.9.2/ChatGPT_0.9.2_x64_en-US.msi): Direct download installer
|
||||||
- Use [winget](https://winstall.app/apps/lencx.ChatGPT):
|
- Use [winget](https://winstall.app/apps/lencx.ChatGPT):
|
||||||
```bash
|
```bash
|
||||||
# install the latest version
|
# install the latest version
|
||||||
winget install --id=lencx.ChatGPT -e
|
winget install --id=lencx.ChatGPT -e
|
||||||
|
|
||||||
# install the specified version
|
# install the specified version
|
||||||
winget install --id=lencx.ChatGPT -e --version 0.8.1
|
winget install --id=lencx.ChatGPT -e --version 0.9.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.8.1))**
|
**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.9.2))**
|
||||||
|
|
||||||
### Mac
|
### Mac
|
||||||
|
|
||||||
- [ChatGPT_0.8.1_x64.dmg](https://github.com/lencx/ChatGPT/releases/download/v0.8.1/ChatGPT_0.8.1_x64.dmg): Direct download installer
|
- [ChatGPT_0.9.2_x64.dmg](https://github.com/lencx/ChatGPT/releases/download/v0.9.2/ChatGPT_0.9.2_x64.dmg): Direct download installer
|
||||||
- [ChatGPT.app.tar.gz](https://github.com/lencx/ChatGPT/releases/download/v0.8.1/ChatGPT.app.tar.gz): Download the `.app` installer
|
- [ChatGPT.app.tar.gz](https://github.com/lencx/ChatGPT/releases/download/v0.9.2/ChatGPT.app.tar.gz): Download the `.app` installer
|
||||||
- Homebrew \
|
- Homebrew \
|
||||||
Or you can install with _[Homebrew](https://brew.sh) ([Cask](https://docs.brew.sh/Cask-Cookbook)):_
|
Or you can install with _[Homebrew](https://brew.sh) ([Cask](https://docs.brew.sh/Cask-Cookbook)):_
|
||||||
```sh
|
```sh
|
||||||
@@ -57,8 +57,8 @@
|
|||||||
|
|
||||||
### Linux
|
### Linux
|
||||||
|
|
||||||
- [chat-gpt_0.8.1_amd64.deb](https://github.com/lencx/ChatGPT/releases/download/v0.8.1/chat-gpt_0.8.1_amd64.deb): Download `.deb` installer, advantage small size, disadvantage poor compatibility
|
- [chat-gpt_0.9.2_amd64.deb](https://github.com/lencx/ChatGPT/releases/download/v0.9.2/chat-gpt_0.9.2_amd64.deb): Download `.deb` installer, advantage small size, disadvantage poor compatibility
|
||||||
- [chat-gpt_0.8.1_amd64.AppImage](https://github.com/lencx/ChatGPT/releases/download/v0.8.1/chat-gpt_0.8.1_amd64.AppImage): Works reliably, you can try it if `.deb` fails to run
|
- [chat-gpt_0.9.2_amd64.AppImage](https://github.com/lencx/ChatGPT/releases/download/v0.9.2/chat-gpt_0.9.2_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.
|
- 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.
|
||||||
|
|
||||||
<!-- download end -->
|
<!-- download end -->
|
||||||
|
|||||||
@@ -1,5 +1,13 @@
|
|||||||
# UPDATE LOG
|
# UPDATE LOG
|
||||||
|
|
||||||
|
## v0.9.2
|
||||||
|
|
||||||
|
fix: slash command does not work
|
||||||
|
|
||||||
|
## v0.9.1
|
||||||
|
|
||||||
|
fix: slash command does not work
|
||||||
|
|
||||||
## v0.9.0
|
## v0.9.0
|
||||||
|
|
||||||
fix:
|
fix:
|
||||||
|
|||||||
4
scripts/download.js
vendored
4
scripts/download.js
vendored
@@ -13,7 +13,9 @@ async function rewrite(filename) {
|
|||||||
flag = true;
|
flag = true;
|
||||||
}
|
}
|
||||||
if (flag) {
|
if (flag) {
|
||||||
content[i] = content[i].replace(/(\d+).(\d+).(\d+)/g, argv[0]);
|
if (!/winget install --id=lencx.ChatGPT -e --version/.test(content[i])) {
|
||||||
|
content[i] = content[i].replace(/(\d+).(\d+).(\d+)/g, argv[0]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (endRe.test(content[i])) {
|
if (endRe.test(content[i])) {
|
||||||
break;
|
break;
|
||||||
|
|||||||
@@ -61,7 +61,6 @@ pub fn init(app: &mut App) -> std::result::Result<(), Box<dyn std::error::Error>
|
|||||||
.always_on_top(chat_conf.stay_on_top)
|
.always_on_top(chat_conf.stay_on_top)
|
||||||
.title_bar_style(ChatConfJson::titlebar())
|
.title_bar_style(ChatConfJson::titlebar())
|
||||||
.initialization_script(&utils::user_script())
|
.initialization_script(&utils::user_script())
|
||||||
.initialization_script(include_str!("../vendors/jq.js"))
|
|
||||||
.initialization_script(include_str!("../vendors/floating-ui-core.js"))
|
.initialization_script(include_str!("../vendors/floating-ui-core.js"))
|
||||||
.initialization_script(include_str!("../vendors/floating-ui-dom.js"))
|
.initialization_script(include_str!("../vendors/floating-ui-dom.js"))
|
||||||
.initialization_script(include_str!("../vendors/html2canvas.js"))
|
.initialization_script(include_str!("../vendors/html2canvas.js"))
|
||||||
@@ -86,7 +85,6 @@ pub fn init(app: &mut App) -> std::result::Result<(), Box<dyn std::error::Error>
|
|||||||
.theme(theme)
|
.theme(theme)
|
||||||
.always_on_top(chat_conf.stay_on_top)
|
.always_on_top(chat_conf.stay_on_top)
|
||||||
.initialization_script(&utils::user_script())
|
.initialization_script(&utils::user_script())
|
||||||
.initialization_script(include_str!("../vendors/jq.js"))
|
|
||||||
.initialization_script(include_str!("../vendors/floating-ui-core.js"))
|
.initialization_script(include_str!("../vendors/floating-ui-core.js"))
|
||||||
.initialization_script(include_str!("../vendors/floating-ui-dom.js"))
|
.initialization_script(include_str!("../vendors/floating-ui-dom.js"))
|
||||||
.initialization_script(include_str!("../vendors/html2canvas.js"))
|
.initialization_script(include_str!("../vendors/html2canvas.js"))
|
||||||
|
|||||||
@@ -18,7 +18,6 @@ pub fn tray_window(handle: &tauri::AppHandle) {
|
|||||||
.always_on_top(true)
|
.always_on_top(true)
|
||||||
.theme(theme)
|
.theme(theme)
|
||||||
.initialization_script(&utils::user_script())
|
.initialization_script(&utils::user_script())
|
||||||
.initialization_script(include_str!("../vendors/jq.js"))
|
|
||||||
.initialization_script(include_str!("../vendors/floating-ui-core.js"))
|
.initialization_script(include_str!("../vendors/floating-ui-core.js"))
|
||||||
.initialization_script(include_str!("../vendors/floating-ui-dom.js"))
|
.initialization_script(include_str!("../vendors/floating-ui-dom.js"))
|
||||||
.initialization_script(include_str!("../scripts/core.js"))
|
.initialization_script(include_str!("../scripts/core.js"))
|
||||||
@@ -74,7 +73,6 @@ pub fn dalle2_window(
|
|||||||
.inner_size(800.0, 600.0)
|
.inner_size(800.0, 600.0)
|
||||||
.always_on_top(false)
|
.always_on_top(false)
|
||||||
.theme(theme)
|
.theme(theme)
|
||||||
.initialization_script(include_str!("../vendors/jq.js"))
|
|
||||||
.initialization_script(include_str!("../scripts/core.js"))
|
.initialization_script(include_str!("../scripts/core.js"))
|
||||||
.initialization_script(&query)
|
.initialization_script(&query)
|
||||||
.initialization_script(include_str!("../scripts/dalle2.js"))
|
.initialization_script(include_str!("../scripts/dalle2.js"))
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ pub const DEFAULT_CHAT_CONF: &str = r#"{
|
|||||||
"theme": "Light",
|
"theme": "Light",
|
||||||
"tray": true,
|
"tray": true,
|
||||||
"titlebar": true,
|
"titlebar": true,
|
||||||
"popup_search": true,
|
"popup_search": false,
|
||||||
"global_shortcut": "",
|
"global_shortcut": "",
|
||||||
"hide_dock_icon": false,
|
"hide_dock_icon": false,
|
||||||
"default_origin": "https://chat.openai.com",
|
"default_origin": "https://chat.openai.com",
|
||||||
@@ -37,7 +37,7 @@ pub const DEFAULT_CHAT_CONF_MAC: &str = r#"{
|
|||||||
"theme": "Light",
|
"theme": "Light",
|
||||||
"tray": true,
|
"tray": true,
|
||||||
"titlebar": false,
|
"titlebar": false,
|
||||||
"popup_search": true,
|
"popup_search": false,
|
||||||
"global_shortcut": "",
|
"global_shortcut": "",
|
||||||
"hide_dock_icon": false,
|
"hide_dock_icon": false,
|
||||||
"default_origin": "https://chat.openai.com",
|
"default_origin": "https://chat.openai.com",
|
||||||
|
|||||||
337
src-tauri/src/scripts/cmd.js
vendored
337
src-tauri/src/scripts/cmd.js
vendored
@@ -1,6 +1,6 @@
|
|||||||
// *** Core Script - CMD ***
|
// *** Core Script - CMD ***
|
||||||
|
|
||||||
$(function() {
|
function init() {
|
||||||
const styleDom = document.createElement('style');
|
const styleDom = document.createElement('style');
|
||||||
styleDom.innerHTML = `form {
|
styleDom.innerHTML = `form {
|
||||||
position: relative;
|
position: relative;
|
||||||
@@ -87,185 +87,210 @@ $(function() {
|
|||||||
clearInterval(window.formInterval);
|
clearInterval(window.formInterval);
|
||||||
}
|
}
|
||||||
window.formInterval = setInterval(() => {
|
window.formInterval = setInterval(() => {
|
||||||
const form = document.querySelector("form");
|
const form = document.querySelector("form textarea");
|
||||||
if (!form) return;
|
if (!form) return;
|
||||||
clearInterval(window.formInterval);
|
clearInterval(window.formInterval);
|
||||||
cmdTip();
|
cmdTip();
|
||||||
}, 200);
|
new MutationObserver(function (mutationsList) {
|
||||||
});
|
for (const mutation of mutationsList) {
|
||||||
|
if (mutation.target.getAttribute('id') === '__next') {
|
||||||
|
initDom();
|
||||||
|
cmdTip();
|
||||||
|
}
|
||||||
|
if (mutation.target.getAttribute('class') === 'chat-model-cmd-list') {
|
||||||
|
// The `chatgpt prompt` fill can be done by clicking on the event.
|
||||||
|
const searchDom = document.querySelector("form .chat-model-cmd-list>div");
|
||||||
|
const searchInput = document.querySelector('form textarea');
|
||||||
|
if (!searchDom) return;
|
||||||
|
searchDom.addEventListener('click', (event) => {
|
||||||
|
const item = event.target.closest("div");
|
||||||
|
if (item) {
|
||||||
|
const val = decodeURIComponent(item.getAttribute('data-prompt'));
|
||||||
|
searchInput.value = val;
|
||||||
|
document.querySelector('form textarea').focus();
|
||||||
|
initDom();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}).observe(document.body, {
|
||||||
|
childList: true,
|
||||||
|
subtree: true,
|
||||||
|
});
|
||||||
|
}, 300);
|
||||||
|
}
|
||||||
|
|
||||||
async function cmdTip() {
|
async function cmdTip() {
|
||||||
|
initDom();
|
||||||
const chatModelJson = await invoke('get_chat_model_cmd') || {};
|
const chatModelJson = await invoke('get_chat_model_cmd') || {};
|
||||||
const data = chatModelJson.data;
|
const data = chatModelJson.data;
|
||||||
if (data.length <= 0) return;
|
if (data.length <= 0) return;
|
||||||
|
|
||||||
const modelDom = document.createElement('div');
|
let modelDom = document.querySelector('.chat-model-cmd-list');
|
||||||
modelDom.classList.add('chat-model-cmd-list');
|
if (!modelDom) {
|
||||||
|
const dom = document.createElement('div');
|
||||||
|
dom.classList.add('chat-model-cmd-list');
|
||||||
|
document.querySelector('form').appendChild(dom);
|
||||||
|
modelDom = document.querySelector('.chat-model-cmd-list');
|
||||||
|
|
||||||
// fix: tray window
|
// fix: tray window
|
||||||
if (__TAURI_METADATA__.__currentWindow.label === 'tray') {
|
if (__TAURI_METADATA__.__currentWindow.label === 'tray') {
|
||||||
modelDom.style.bottom = '54px';
|
modelDom.style.bottom = '54px';
|
||||||
}
|
|
||||||
|
|
||||||
document.querySelector('form').appendChild(modelDom);
|
|
||||||
const itemDom = (v) => `<div class="cmd-item" title="${v.prompt}" data-cmd="${v.cmd}" data-prompt="${encodeURIComponent(v.prompt)}"><b title="${v.cmd}">/${v.cmd}</b><i>${v.act}</i></div>`;
|
|
||||||
const renderList = (v) => {
|
|
||||||
modelDom.innerHTML = `<div>${v.map(itemDom).join('')}</div>`;
|
|
||||||
window.__CHAT_MODEL_CMD_PROMPT__ = v[0]?.prompt.trim();
|
|
||||||
window.__CHAT_MODEL_CMD__ = v[0]?.cmd.trim();
|
|
||||||
window.__list = modelDom.querySelectorAll('.cmd-item');
|
|
||||||
window.__index = 0;
|
|
||||||
window.__list[window.__index].classList.add('selected');
|
|
||||||
};
|
|
||||||
const setPrompt = (v = '') => {
|
|
||||||
if (v.trim()) {
|
|
||||||
window.__CHAT_MODEL_CMD_PROMPT__ = window.__CHAT_MODEL_CMD_PROMPT__?.replace(/\{([^{}]*)\}/, `{${v.trim()}}`);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
const searchInput = document.querySelector('form textarea');
|
|
||||||
|
|
||||||
// Enter a command starting with `/` and press a space to automatically fill `chatgpt prompt`.
|
|
||||||
// If more than one command appears in the search results, the first one will be used by default.
|
|
||||||
searchInput.addEventListener('keydown', (event) => {
|
|
||||||
if (!window.__CHAT_MODEL_CMD_PROMPT__) {
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------ Keyboard scrolling (ArrowUp | ArrowDown) --------------------------
|
const itemDom = (v) => `<div class="cmd-item" title="${v.prompt}" data-cmd="${v.cmd}" data-prompt="${encodeURIComponent(v.prompt)}"><b title="${v.cmd}">/${v.cmd}</b><i>${v.act}</i></div>`;
|
||||||
if (event.keyCode === 38 && window.__index > 0) { // ArrowUp
|
const renderList = (v) => {
|
||||||
window.__list[window.__index].classList.remove('selected');
|
initDom();
|
||||||
window.__index = window.__index - 1;
|
modelDom.innerHTML = `<div>${v.map(itemDom).join('')}</div>`;
|
||||||
window.__list[window.__index].classList.add('selected');
|
window.__CHAT_MODEL_CMD_PROMPT__ = v[0]?.prompt.trim();
|
||||||
window.__CHAT_MODEL_CMD_PROMPT__ = decodeURIComponent(window.__list[window.__index].getAttribute('data-prompt'));
|
window.__CHAT_MODEL_CMD__ = v[0]?.cmd.trim();
|
||||||
searchInput.value = `/${window.__list[window.__index].getAttribute('data-cmd')}`;
|
window.__cmd_list = modelDom.querySelectorAll('.cmd-item');
|
||||||
event.preventDefault();
|
window.__cmd_index = 0;
|
||||||
}
|
window.__cmd_list[window.__cmd_index].classList.add('selected');
|
||||||
|
};
|
||||||
if (event.keyCode === 40 && window.__index < window.__list.length - 1) { // ArrowDown
|
const setPrompt = (v = '') => {
|
||||||
window.__list[window.__index].classList.remove('selected');
|
if (v.trim()) {
|
||||||
window.__index = window.__index + 1;
|
window.__CHAT_MODEL_CMD_PROMPT__ = window.__CHAT_MODEL_CMD_PROMPT__?.replace(/\{([^{}]*)\}/, `{${v.trim()}}`);
|
||||||
window.__list[window.__index].classList.add('selected');
|
|
||||||
window.__CHAT_MODEL_CMD_PROMPT__ = decodeURIComponent(window.__list[window.__index].getAttribute('data-prompt'));
|
|
||||||
searchInput.value = `/${window.__list[window.__index].getAttribute('data-cmd')}`;
|
|
||||||
event.preventDefault();
|
|
||||||
}
|
|
||||||
|
|
||||||
const containerHeight = modelDom.offsetHeight;
|
|
||||||
const itemHeight = window.__list[0].offsetHeight + 1;
|
|
||||||
|
|
||||||
const itemTop = window.__list[window.__index].offsetTop;
|
|
||||||
const itemBottom = itemTop + itemHeight;
|
|
||||||
if (itemTop < modelDom.scrollTop || itemBottom > modelDom.scrollTop + containerHeight) {
|
|
||||||
modelDom.scrollTop = itemTop;
|
|
||||||
}
|
|
||||||
|
|
||||||
// ------------------ TAB key replaces `{q}` tag content -------------------------------
|
|
||||||
// feat: https://github.com/lencx/ChatGPT/issues/54
|
|
||||||
if (event.keyCode === 9 && !window.__CHAT_MODEL_STATUS__) {
|
|
||||||
const strGroup = window.__CHAT_MODEL_CMD_PROMPT__.match(/\{([^{}]*)\}/) || [];
|
|
||||||
|
|
||||||
if (strGroup[1]) {
|
|
||||||
searchInput.value = `/${window.__CHAT_MODEL_CMD__}` + ` {${strGroup[1]}}` + ' |-> ';
|
|
||||||
window.__CHAT_MODEL_STATUS__ = 1;
|
|
||||||
}
|
}
|
||||||
event.preventDefault();
|
|
||||||
}
|
}
|
||||||
|
const searchInput = document.querySelector('form textarea');
|
||||||
|
|
||||||
if (window.__CHAT_MODEL_STATUS__ === 1 && event.keyCode === 9) { // TAB
|
// Enter a command starting with `/` and press a space to automatically fill `chatgpt prompt`.
|
||||||
const data = searchInput.value.split('|->');
|
// If more than one command appears in the search results, the first one will be used by default.
|
||||||
if (data[1]?.trim()) {
|
function cmdKeydown(event) {
|
||||||
setPrompt(data[1]);
|
if (!window.__CHAT_MODEL_CMD_PROMPT__) {
|
||||||
window.__CHAT_MODEL_STATUS__ = 2;
|
return;
|
||||||
}
|
}
|
||||||
event.preventDefault();
|
|
||||||
}
|
|
||||||
|
|
||||||
// input text
|
// ------------------ Keyboard scrolling (ArrowUp | ArrowDown) --------------------------
|
||||||
if (window.__CHAT_MODEL_STATUS__ === 2 && event.keyCode === 9) { // TAB
|
if (event.keyCode === 38 && window.__cmd_index > 0) { // ArrowUp
|
||||||
searchInput.value = window.__CHAT_MODEL_CMD_PROMPT__;
|
window.__cmd_list[window.__cmd_index].classList.remove('selected');
|
||||||
modelDom.innerHTML = '';
|
window.__cmd_index = window.__cmd_index - 1;
|
||||||
delete window.__CHAT_MODEL_STATUS__;
|
window.__cmd_list[window.__cmd_index].classList.add('selected');
|
||||||
event.preventDefault();
|
window.__CHAT_MODEL_CMD_PROMPT__ = decodeURIComponent(window.__cmd_list[window.__cmd_index].getAttribute('data-prompt'));
|
||||||
}
|
searchInput.value = `/${window.__cmd_list[window.__cmd_index].getAttribute('data-cmd')}`;
|
||||||
|
event.preventDefault();
|
||||||
|
}
|
||||||
|
|
||||||
// ------------------ type in a space to complete the fill ------------------------------------
|
if (event.keyCode === 40 && window.__cmd_index < window.__cmd_list.length - 1) { // ArrowDown
|
||||||
if (event.keyCode === 32) {
|
window.__cmd_list[window.__cmd_index].classList.remove('selected');
|
||||||
searchInput.value = window.__CHAT_MODEL_CMD_PROMPT__;
|
window.__cmd_index = window.__cmd_index + 1;
|
||||||
modelDom.innerHTML = '';
|
window.__cmd_list[window.__cmd_index].classList.add('selected');
|
||||||
delete window.__CHAT_MODEL_CMD_PROMPT__;
|
window.__CHAT_MODEL_CMD_PROMPT__ = decodeURIComponent(window.__cmd_list[window.__cmd_index].getAttribute('data-prompt'));
|
||||||
}
|
searchInput.value = `/${window.__cmd_list[window.__cmd_index].getAttribute('data-cmd')}`;
|
||||||
|
event.preventDefault();
|
||||||
|
}
|
||||||
|
|
||||||
// ------------------ send --------------------------------------------------------------------
|
const containerHeight = modelDom.offsetHeight;
|
||||||
if (event.keyCode === 13 && window.__CHAT_MODEL_CMD_PROMPT__) { // Enter
|
const itemHeight = window.__cmd_list[0].offsetHeight + 1;
|
||||||
const data = searchInput.value.split('|->');
|
|
||||||
setPrompt(data[1]);
|
|
||||||
|
|
||||||
searchInput.value = window.__CHAT_MODEL_CMD_PROMPT__;
|
const itemTop = window.__cmd_list[window.__cmd_index].offsetTop;
|
||||||
modelDom.innerHTML = '';
|
const itemBottom = itemTop + itemHeight;
|
||||||
delete window.__CHAT_MODEL_CMD_PROMPT__;
|
if (itemTop < modelDom.scrollTop || itemBottom > modelDom.scrollTop + containerHeight) {
|
||||||
delete window.__CHAT_MODEL_CMD__;
|
modelDom.scrollTop = itemTop;
|
||||||
delete window.__CHAT_MODEL_STATUS__;
|
}
|
||||||
event.preventDefault();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
searchInput.addEventListener('input', () => {
|
// ------------------ TAB key replaces `{q}` tag content -------------------------------
|
||||||
if (searchInput.value === '') {
|
// feat: https://github.com/lencx/ChatGPT/issues/54
|
||||||
delete window.__CHAT_MODEL_CMD_PROMPT__;
|
if (event.keyCode === 9 && !window.__CHAT_MODEL_STATUS__) {
|
||||||
delete window.__CHAT_MODEL_CMD__;
|
const strGroup = window.__CHAT_MODEL_CMD_PROMPT__.match(/\{([^{}]*)\}/) || [];
|
||||||
delete window.__CHAT_MODEL_STATUS__;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (window.__CHAT_MODEL_STATUS__) return;
|
if (strGroup[1]) {
|
||||||
|
searchInput.value = `/${window.__CHAT_MODEL_CMD__}` + ` {${strGroup[1]}}` + ' |-> ';
|
||||||
|
window.__CHAT_MODEL_STATUS__ = 1;
|
||||||
|
} else {
|
||||||
|
searchInput.value = window.__CHAT_MODEL_CMD_PROMPT__;
|
||||||
|
initDom();
|
||||||
|
}
|
||||||
|
event.preventDefault();
|
||||||
|
}
|
||||||
|
|
||||||
const query = searchInput.value;
|
if (window.__CHAT_MODEL_STATUS__ === 1 && event.keyCode === 9) { // TAB
|
||||||
if (!query || !/^\//.test(query)) {
|
const data = searchInput.value.split('|->');
|
||||||
modelDom.innerHTML = '';
|
if (data[1]?.trim()) {
|
||||||
return;
|
setPrompt(data[1]);
|
||||||
}
|
window.__CHAT_MODEL_STATUS__ = 2;
|
||||||
|
}
|
||||||
|
event.preventDefault();
|
||||||
|
}
|
||||||
|
|
||||||
// all cmd result
|
// input text
|
||||||
if (query === '/') {
|
if (window.__CHAT_MODEL_STATUS__ === 2 && event.keyCode === 9) { // TAB
|
||||||
renderList(data);
|
searchInput.value = window.__CHAT_MODEL_CMD_PROMPT__;
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
const result = data.filter(i => new RegExp(query.substring(1)).test(i.cmd));
|
|
||||||
if (result.length > 0) {
|
|
||||||
renderList(result);
|
|
||||||
} else {
|
|
||||||
modelDom.innerHTML = '';
|
|
||||||
delete window.__CHAT_MODEL_CMD_PROMPT__;
|
|
||||||
delete window.__CHAT_MODEL_CMD__;
|
|
||||||
delete window.__CHAT_MODEL_STATUS__;
|
|
||||||
}
|
|
||||||
}, {
|
|
||||||
capture: false,
|
|
||||||
passive: true,
|
|
||||||
once: false
|
|
||||||
});
|
|
||||||
|
|
||||||
if (window.searchInterval) {
|
|
||||||
clearInterval(window.searchInterval);
|
|
||||||
}
|
|
||||||
window.searchInterval = setInterval(() => {
|
|
||||||
// The `chatgpt prompt` fill can be done by clicking on the event.
|
|
||||||
const searchDom = document.querySelector("form .chat-model-cmd-list>div");
|
|
||||||
if (!searchDom) return;
|
|
||||||
searchDom.addEventListener('click', (event) => {
|
|
||||||
// .cmd-item
|
|
||||||
const item = event.target.closest("div");
|
|
||||||
if (item) {
|
|
||||||
const val = decodeURIComponent(item.getAttribute('data-prompt'));
|
|
||||||
searchInput.value = val;
|
|
||||||
document.querySelector('form textarea').focus();
|
|
||||||
window.__CHAT_MODEL_CMD_PROMPT__ = val;
|
|
||||||
modelDom.innerHTML = '';
|
modelDom.innerHTML = '';
|
||||||
|
delete window.__CHAT_MODEL_STATUS__;
|
||||||
|
event.preventDefault();
|
||||||
}
|
}
|
||||||
}, {
|
|
||||||
capture: false,
|
// ------------------ type in a space to complete the fill ------------------------------------
|
||||||
passive: true,
|
if (event.keyCode === 32) {
|
||||||
once: false
|
searchInput.value = window.__CHAT_MODEL_CMD_PROMPT__;
|
||||||
});
|
modelDom.innerHTML = '';
|
||||||
}, 200);
|
delete window.__CHAT_MODEL_CMD_PROMPT__;
|
||||||
|
}
|
||||||
|
|
||||||
|
// ------------------ send --------------------------------------------------------------------
|
||||||
|
if (event.keyCode === 13 && window.__CHAT_MODEL_CMD_PROMPT__) { // Enter
|
||||||
|
const data = searchInput.value.split('|->');
|
||||||
|
setPrompt(data[1]);
|
||||||
|
|
||||||
|
searchInput.value = window.__CHAT_MODEL_CMD_PROMPT__;
|
||||||
|
|
||||||
|
initDom();
|
||||||
|
event.preventDefault();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
searchInput.removeEventListener('keydown', cmdKeydown, { capture: true });
|
||||||
|
searchInput.addEventListener('keydown', cmdKeydown, { capture: true });
|
||||||
|
|
||||||
|
function cmdInput() {
|
||||||
|
if (searchInput.value === '') {
|
||||||
|
initDom();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (window.__CHAT_MODEL_STATUS__) return;
|
||||||
|
|
||||||
|
const query = searchInput.value;
|
||||||
|
if (!query || !/^\//.test(query)) {
|
||||||
|
initDom();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// all cmd result
|
||||||
|
if (query === '/') {
|
||||||
|
renderList(data);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const result = data.filter(i => new RegExp(query.substring(1)).test(i.cmd));
|
||||||
|
if (result.length > 0) {
|
||||||
|
renderList(result);
|
||||||
|
} else {
|
||||||
|
initDom();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
searchInput.removeEventListener('input', cmdInput);
|
||||||
|
searchInput.addEventListener('input', cmdInput);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function initDom() {
|
||||||
|
const modelDom = document.querySelector('.chat-model-cmd-list');
|
||||||
|
if (modelDom) {
|
||||||
|
modelDom.innerHTML = '';
|
||||||
|
}
|
||||||
|
delete window.__CHAT_MODEL_CMD_PROMPT__;
|
||||||
|
delete window.__CHAT_MODEL_CMD__;
|
||||||
|
delete window.__CHAT_MODEL_STATUS__;
|
||||||
|
delete window.__cmd_list;
|
||||||
|
delete window.__cmd_index;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (
|
||||||
|
document.readyState === "complete" ||
|
||||||
|
document.readyState === "interactive"
|
||||||
|
) {
|
||||||
|
init();
|
||||||
|
} else {
|
||||||
|
document.addEventListener("DOMContentLoaded", init);
|
||||||
|
}
|
||||||
13
src-tauri/src/scripts/core.js
vendored
13
src-tauri/src/scripts/core.js
vendored
@@ -40,7 +40,7 @@ window.uid = uid;
|
|||||||
window.invoke = invoke;
|
window.invoke = invoke;
|
||||||
window.transformCallback = transformCallback;
|
window.transformCallback = transformCallback;
|
||||||
|
|
||||||
$(async function () {
|
async function init() {
|
||||||
if (__TAURI_METADATA__.__currentWindow.label === 'tray') {
|
if (__TAURI_METADATA__.__currentWindow.label === 'tray') {
|
||||||
document.getElementsByTagName('html')[0].style['font-size'] = '70%';
|
document.getElementsByTagName('html')[0].style['font-size'] = '70%';
|
||||||
}
|
}
|
||||||
@@ -91,4 +91,13 @@ $(async function () {
|
|||||||
window.__sync_prompts = async function() {
|
window.__sync_prompts = async function() {
|
||||||
await invoke('sync_prompts', { time: Date.now() });
|
await invoke('sync_prompts', { time: Date.now() });
|
||||||
}
|
}
|
||||||
});
|
}
|
||||||
|
|
||||||
|
if (
|
||||||
|
document.readyState === "complete" ||
|
||||||
|
document.readyState === "interactive"
|
||||||
|
) {
|
||||||
|
init();
|
||||||
|
} else {
|
||||||
|
document.addEventListener("DOMContentLoaded", init);
|
||||||
|
}
|
||||||
13
src-tauri/src/scripts/dalle2.js
vendored
13
src-tauri/src/scripts/dalle2.js
vendored
@@ -1,6 +1,6 @@
|
|||||||
// *** Core Script - DALL·E 2 ***
|
// *** Core Script - DALL·E 2 ***
|
||||||
|
|
||||||
$(function () {
|
function init() {
|
||||||
document.addEventListener("click", (e) => {
|
document.addEventListener("click", (e) => {
|
||||||
const origin = e.target.closest("a");
|
const origin = e.target.closest("a");
|
||||||
if (!origin || !origin.target) return;
|
if (!origin || !origin.target) return;
|
||||||
@@ -28,4 +28,13 @@ $(function () {
|
|||||||
searchInput.value = query;
|
searchInput.value = query;
|
||||||
}
|
}
|
||||||
}, 200)
|
}, 200)
|
||||||
})
|
}
|
||||||
|
|
||||||
|
if (
|
||||||
|
document.readyState === "complete" ||
|
||||||
|
document.readyState === "interactive"
|
||||||
|
) {
|
||||||
|
init();
|
||||||
|
} else {
|
||||||
|
document.addEventListener("DOMContentLoaded", init);
|
||||||
|
}
|
||||||
18
src-tauri/src/scripts/export.js
vendored
18
src-tauri/src/scripts/export.js
vendored
@@ -1,8 +1,7 @@
|
|||||||
// *** Core Script - Export ***
|
// *** Core Script - Export ***
|
||||||
|
|
||||||
const buttonOuterHTMLFallback = `<button class="btn flex justify-center gap-2 btn-neutral" id="download-png-button">Try Again</button>`;
|
async function init() {
|
||||||
|
const buttonOuterHTMLFallback = `<button class="btn flex justify-center gap-2 btn-neutral" id="download-png-button">Try Again</button>`;
|
||||||
$(async function () {
|
|
||||||
if (window.innerWidth < 767) return;
|
if (window.innerWidth < 767) return;
|
||||||
const chatConf = await invoke('get_chat_conf') || {};
|
const chatConf = await invoke('get_chat_conf') || {};
|
||||||
if (window.buttonsInterval) {
|
if (window.buttonsInterval) {
|
||||||
@@ -25,7 +24,7 @@ $(async function () {
|
|||||||
removeButtons();
|
removeButtons();
|
||||||
}
|
}
|
||||||
}, 1000);
|
}, 1000);
|
||||||
})
|
}
|
||||||
|
|
||||||
const Format = {
|
const Format = {
|
||||||
PNG: "png",
|
PNG: "png",
|
||||||
@@ -190,7 +189,7 @@ async function handlePdf(imgData, canvas, pixelRatio) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function getName() {
|
function getName() {
|
||||||
const id = uid().toString(36);
|
const id = window.crypto.getRandomValues(new Uint32Array(1))[0].toString(36);
|
||||||
const name = document.querySelector('nav .overflow-y-auto a.hover\\:bg-gray-800')?.innerText?.trim() || '';
|
const name = document.querySelector('nav .overflow-y-auto a.hover\\:bg-gray-800')?.innerText?.trim() || '';
|
||||||
return { filename: name ? name : id, id, pathname: 'chat.download.json' };
|
return { filename: name ? name : id, id, pathname: 'chat.download.json' };
|
||||||
}
|
}
|
||||||
@@ -272,3 +271,12 @@ function setIcon(type) {
|
|||||||
md: `<svg class="chatappico md" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="1380" width="200" height="200"><path d="M128 128h768a42.666667 42.666667 0 0 1 42.666667 42.666667v682.666666a42.666667 42.666667 0 0 1-42.666667 42.666667H128a42.666667 42.666667 0 0 1-42.666667-42.666667V170.666667a42.666667 42.666667 0 0 1 42.666667-42.666667z m170.666667 533.333333v-170.666666l85.333333 85.333333 85.333333-85.333333v170.666666h85.333334v-298.666666h-85.333334l-85.333333 85.333333-85.333333-85.333333H213.333333v298.666666h85.333334z m469.333333-128v-170.666666h-85.333333v170.666666h-85.333334l128 128 128-128h-85.333333z" p-id="1381" fill="currentColor"></path></svg>`
|
md: `<svg class="chatappico md" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="1380" width="200" height="200"><path d="M128 128h768a42.666667 42.666667 0 0 1 42.666667 42.666667v682.666666a42.666667 42.666667 0 0 1-42.666667 42.666667H128a42.666667 42.666667 0 0 1-42.666667-42.666667V170.666667a42.666667 42.666667 0 0 1 42.666667-42.666667z m170.666667 533.333333v-170.666666l85.333333 85.333333 85.333333-85.333333v170.666666h85.333334v-298.666666h-85.333334l-85.333333 85.333333-85.333333-85.333333H213.333333v298.666666h85.333334z m469.333333-128v-170.666666h-85.333333v170.666666h-85.333334l128 128 128-128h-85.333333z" p-id="1381" fill="currentColor"></path></svg>`
|
||||||
}[type];
|
}[type];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (
|
||||||
|
document.readyState === "complete" ||
|
||||||
|
document.readyState === "interactive"
|
||||||
|
) {
|
||||||
|
init();
|
||||||
|
} else {
|
||||||
|
document.addEventListener("DOMContentLoaded", init);
|
||||||
|
}
|
||||||
|
|||||||
20
src-tauri/src/scripts/popup.core.js
vendored
20
src-tauri/src/scripts/popup.core.js
vendored
@@ -1,6 +1,6 @@
|
|||||||
// *** Core Script - DALL·E 2 Core ***
|
// *** Core Script - DALL·E 2 Core ***
|
||||||
|
|
||||||
$(async function () {
|
async function init() {
|
||||||
const chatConf = await invoke('get_chat_conf') || {};
|
const chatConf = await invoke('get_chat_conf') || {};
|
||||||
if (!chatConf.popup_search) return;
|
if (!chatConf.popup_search) return;
|
||||||
if (!window.FloatingUIDOM) return;
|
if (!window.FloatingUIDOM) return;
|
||||||
@@ -16,9 +16,9 @@ $(async function () {
|
|||||||
background: #4a4a4a;
|
background: #4a4a4a;
|
||||||
color: white;
|
color: white;
|
||||||
font-weight: bold;
|
font-weight: bold;
|
||||||
padding: 5px 8px;
|
padding: 3px 5px;
|
||||||
border-radius: 4px;
|
border-radius: 2px;
|
||||||
font-size: 12px;
|
font-size: 10px;
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
}
|
}
|
||||||
`;
|
`;
|
||||||
@@ -31,6 +31,7 @@ $(async function () {
|
|||||||
const { computePosition, flip, offset, shift } = window.FloatingUIDOM;
|
const { computePosition, flip, offset, shift } = window.FloatingUIDOM;
|
||||||
|
|
||||||
document.body.addEventListener('mousedown', async (e) => {
|
document.body.addEventListener('mousedown', async (e) => {
|
||||||
|
selectionMenu.style.display = 'none';
|
||||||
if (e.target.id === 'chagpt-selection-menu') {
|
if (e.target.id === 'chagpt-selection-menu') {
|
||||||
await invoke('dalle2_window', { query: encodeURIComponent(window.__DALLE2_CONTENT__) });
|
await invoke('dalle2_window', { query: encodeURIComponent(window.__DALLE2_CONTENT__) });
|
||||||
} else {
|
} else {
|
||||||
@@ -71,4 +72,13 @@ $(async function () {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
})
|
}
|
||||||
|
|
||||||
|
if (
|
||||||
|
document.readyState === "complete" ||
|
||||||
|
document.readyState === "interactive"
|
||||||
|
) {
|
||||||
|
init();
|
||||||
|
} else {
|
||||||
|
document.addEventListener("DOMContentLoaded", init);
|
||||||
|
}
|
||||||
|
|||||||
2
src-tauri/src/vendors/jq.js
vendored
2
src-tauri/src/vendors/jq.js
vendored
File diff suppressed because one or more lines are too long
@@ -7,7 +7,7 @@
|
|||||||
},
|
},
|
||||||
"package": {
|
"package": {
|
||||||
"productName": "ChatGPT",
|
"productName": "ChatGPT",
|
||||||
"version": "0.9.0"
|
"version": "0.9.2"
|
||||||
},
|
},
|
||||||
"tauri": {
|
"tauri": {
|
||||||
"allowlist": {
|
"allowlist": {
|
||||||
|
|||||||
10
src/hooks/useColumns.tsx
vendored
10
src/hooks/useColumns.tsx
vendored
@@ -53,25 +53,25 @@ interface EditRowProps {
|
|||||||
}
|
}
|
||||||
export const EditRow: FC<EditRowProps> = ({ rowKey, row, actions }) => {
|
export const EditRow: FC<EditRowProps> = ({ rowKey, row, actions }) => {
|
||||||
const [isEdit, setEdit] = useState(false);
|
const [isEdit, setEdit] = useState(false);
|
||||||
const [val, setVal] = useState(row[rowKey]);
|
const [val, setVal] = useState(row[rowKey] || '');
|
||||||
const handleEdit = () => {
|
const handleEdit = () => {
|
||||||
setEdit(true);
|
setEdit(true);
|
||||||
};
|
};
|
||||||
const handleChange = (e: React.ChangeEvent<HTMLTextAreaElement>) => {
|
const handleChange = (e: React.ChangeEvent<HTMLInputElement>) => {
|
||||||
setVal(e.target.value)
|
setVal(e.target.value)
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleSave = () => {
|
const handleSave = () => {
|
||||||
setEdit(false);
|
setEdit(false);
|
||||||
row[rowKey] = val;
|
row[rowKey] = val?.trim();
|
||||||
actions?.setRecord(row, 'rowedit')
|
actions?.setRecord(row, 'rowedit')
|
||||||
};
|
};
|
||||||
|
|
||||||
return isEdit
|
return isEdit
|
||||||
? (
|
? (
|
||||||
<Input.TextArea
|
<Input
|
||||||
value={val}
|
value={val}
|
||||||
rows={1}
|
autoFocus
|
||||||
onChange={handleChange}
|
onChange={handleChange}
|
||||||
{...DISABLE_AUTO_COMPLETE}
|
{...DISABLE_AUTO_COMPLETE}
|
||||||
onPressEnter={handleSave}
|
onPressEnter={handleSave}
|
||||||
|
|||||||
2
src/view/download/index.tsx
vendored
2
src/view/download/index.tsx
vendored
@@ -69,7 +69,6 @@ export default function Download() {
|
|||||||
const downloadDir = await path.join(await chatRoot(), 'download');
|
const downloadDir = await path.join(await chatRoot(), 'download');
|
||||||
await fs.removeDir(downloadDir, { recursive: true });
|
await fs.removeDir(downloadDir, { recursive: true });
|
||||||
await handleRefresh();
|
await handleRefresh();
|
||||||
rowReset();
|
|
||||||
message.success('All files have been cleared!');
|
message.success('All files have been cleared!');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -88,6 +87,7 @@ export default function Download() {
|
|||||||
|
|
||||||
const handleRefresh = async () => {
|
const handleRefresh = async () => {
|
||||||
await invoke('download_list', { pathname: CHAT_DOWNLOAD_JSON, dir: 'download' });
|
await invoke('download_list', { pathname: CHAT_DOWNLOAD_JSON, dir: 'download' });
|
||||||
|
rowReset();
|
||||||
const data = await refreshJson();
|
const data = await refreshJson();
|
||||||
opInit(data);
|
opInit(data);
|
||||||
};
|
};
|
||||||
|
|||||||
3
src/view/notes/index.tsx
vendored
3
src/view/notes/index.tsx
vendored
@@ -65,7 +65,6 @@ export default function Notes() {
|
|||||||
const notesDir = await path.join(await chatRoot(), 'notes');
|
const notesDir = await path.join(await chatRoot(), 'notes');
|
||||||
await fs.removeDir(notesDir, { recursive: true });
|
await fs.removeDir(notesDir, { recursive: true });
|
||||||
await handleRefresh();
|
await handleRefresh();
|
||||||
rowReset();
|
|
||||||
message.success('All files have been cleared!');
|
message.success('All files have been cleared!');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -83,6 +82,7 @@ export default function Notes() {
|
|||||||
|
|
||||||
const handleRefresh = async () => {
|
const handleRefresh = async () => {
|
||||||
await invoke('download_list', { pathname: CHAT_NOTES_JSON, dir: 'notes' });
|
await invoke('download_list', { pathname: CHAT_NOTES_JSON, dir: 'notes' });
|
||||||
|
rowReset();
|
||||||
const data = await refreshJson();
|
const data = await refreshJson();
|
||||||
opInit(data);
|
opInit(data);
|
||||||
};
|
};
|
||||||
@@ -135,6 +135,7 @@ export default function Notes() {
|
|||||||
>
|
>
|
||||||
<ReactMarkdown
|
<ReactMarkdown
|
||||||
children={source}
|
children={source}
|
||||||
|
linkTarget="_blank"
|
||||||
components={{
|
components={{
|
||||||
code({node, inline, className, children, ...props}) {
|
code({node, inline, className, children, ...props}) {
|
||||||
const match = /language-(\w+)/.exec(className || '')
|
const match = /language-(\w+)/.exec(className || '')
|
||||||
|
|||||||
Reference in New Issue
Block a user