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 | |
|---|---|---|---|
|
|
e86bf42cc1 | ||
|
|
09b8643d99 | ||
|
|
c07fd1e0b8 | ||
|
|
4366b8ee8a | ||
|
|
7505311a2c | ||
|
|
680100801f | ||
|
|
ee0836cb07 | ||
|
|
91cebe82db |
@@ -22,9 +22,9 @@
|
||||
|
||||
**最新版:**
|
||||
|
||||
- `Mac`: [ChatGPT_0.4.0_x64.dmg](https://github.com/lencx/ChatGPT/releases/download/v0.4.0/ChatGPT_0.4.0_x64.dmg)
|
||||
- `Linux`: [chat-gpt_0.4.0_amd64.deb](https://github.com/lencx/ChatGPT/releases/download/v0.4.0/chat-gpt_0.4.0_amd64.deb)
|
||||
- `Windows`: [ChatGPT_0.4.0_x64_en-US.msi](https://github.com/lencx/ChatGPT/releases/download/v0.4.0/ChatGPT_0.4.0_x64_en-US.msi)
|
||||
- `Mac`: [ChatGPT_0.4.2_x64.dmg](https://github.com/lencx/ChatGPT/releases/download/v0.4.2/ChatGPT_0.4.2_x64.dmg)
|
||||
- `Linux`: [chat-gpt_0.4.2_amd64.deb](https://github.com/lencx/ChatGPT/releases/download/v0.4.2/chat-gpt_0.4.2_amd64.deb)
|
||||
- `Windows`: [ChatGPT_0.4.2_x64_en-US.msi](https://github.com/lencx/ChatGPT/releases/download/v0.4.2/ChatGPT_0.4.2_x64_en-US.msi)
|
||||
|
||||
[其他版本...](https://github.com/lencx/ChatGPT/releases)
|
||||
|
||||
|
||||
@@ -23,9 +23,9 @@
|
||||
|
||||
**Latest:**
|
||||
|
||||
- `Mac`: [ChatGPT_0.4.0_x64.dmg](https://github.com/lencx/ChatGPT/releases/download/v0.4.0/ChatGPT_0.4.0_x64.dmg)
|
||||
- `Linux`: [chat-gpt_0.4.0_amd64.deb](https://github.com/lencx/ChatGPT/releases/download/v0.4.0/chat-gpt_0.4.0_amd64.deb)
|
||||
- `Windows`: [ChatGPT_0.4.0_x64_en-US.msi](https://github.com/lencx/ChatGPT/releases/download/v0.4.0/ChatGPT_0.4.0_x64_en-US.msi)
|
||||
- `Mac`: [ChatGPT_0.4.2_x64.dmg](https://github.com/lencx/ChatGPT/releases/download/v0.4.2/ChatGPT_0.4.2_x64.dmg)
|
||||
- `Linux`: [chat-gpt_0.4.2_amd64.deb](https://github.com/lencx/ChatGPT/releases/download/v0.4.2/chat-gpt_0.4.2_amd64.deb)
|
||||
- `Windows`: [ChatGPT_0.4.2_x64_en-US.msi](https://github.com/lencx/ChatGPT/releases/download/v0.4.2/ChatGPT_0.4.2_x64_en-US.msi)
|
||||
|
||||
[Other version...](https://github.com/lencx/ChatGPT/releases)
|
||||
|
||||
@@ -75,6 +75,7 @@ In the chatgpt text input area, type a character starting with `/` to bring up t
|
||||
- Common shortcut keys
|
||||
- System tray hover window
|
||||
- Powerful menu items
|
||||
- Shortcut command typing chatgpt prompt
|
||||
|
||||
### MenuItem
|
||||
|
||||
@@ -103,7 +104,7 @@ In the chatgpt text input area, type a character starting with `/` to bring up t
|
||||
## TODO
|
||||
|
||||
- Web access capability ([#20](https://github.com/lencx/ChatGPT/issues/20))
|
||||
- Shortcut command typing chatgpt prompt
|
||||
- `Control Center` - Feature Enhancements
|
||||
- ...
|
||||
|
||||
## 👀 Preview
|
||||
|
||||
@@ -1,5 +1,14 @@
|
||||
# UPDATE LOG
|
||||
|
||||
## v0.4.2
|
||||
|
||||
add chatgpt log (path: `~/.chatgpt/chatgpt.log`)
|
||||
|
||||
## v0.4.1
|
||||
|
||||
fix:
|
||||
- tray window style optimization
|
||||
|
||||
## v0.4.0
|
||||
|
||||
feat:
|
||||
|
||||
@@ -19,6 +19,12 @@ serde_json = "1.0"
|
||||
serde = { version = "1.0", features = ["derive"] }
|
||||
tauri = { version = "1.2.2", features = ["api-all", "devtools", "system-tray", "updater"] }
|
||||
tauri-plugin-positioner = { version = "1.0.4", features = ["system-tray"] }
|
||||
log = "0.4.17"
|
||||
|
||||
[dependencies.tauri-plugin-log]
|
||||
git = "https://github.com/tauri-apps/tauri-plugin-log"
|
||||
branch = "dev"
|
||||
features = ["colored"]
|
||||
|
||||
[features]
|
||||
# by default Tauri runs in production mode
|
||||
|
||||
@@ -70,4 +70,4 @@ pub fn get_chat_model() -> serde_json::Value {
|
||||
let path = utils::chat_root().join("chat.model.json");
|
||||
let content = fs::read_to_string(path).unwrap_or_else(|_| r#"{"data":[]}"#.to_string());
|
||||
serde_json::from_str(&content).unwrap()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@ use crate::{
|
||||
};
|
||||
use tauri::{
|
||||
AboutMetadata, AppHandle, CustomMenuItem, Manager, Menu, MenuItem, Submenu, SystemTray,
|
||||
SystemTrayEvent, SystemTrayMenu, WindowMenuEvent, SystemTrayMenuItem,
|
||||
SystemTrayEvent, SystemTrayMenu, SystemTrayMenuItem, WindowMenuEvent,
|
||||
};
|
||||
use tauri_plugin_positioner::{on_tray_event, Position, WindowExt};
|
||||
|
||||
@@ -138,6 +138,10 @@ pub fn init() -> Menu {
|
||||
let help_menu = Submenu::new(
|
||||
"Help",
|
||||
Menu::new()
|
||||
.add_item(CustomMenuItem::new(
|
||||
"chatgpt_log".to_string(),
|
||||
"ChatGPT Log",
|
||||
))
|
||||
.add_item(CustomMenuItem::new("update_log".to_string(), "Update Log"))
|
||||
.add_item(CustomMenuItem::new("report_bug".to_string(), "Report Bug"))
|
||||
.add_item(
|
||||
@@ -226,6 +230,7 @@ pub fn menu_handler(event: WindowMenuEvent<tauri::Wry>) {
|
||||
)
|
||||
.unwrap(),
|
||||
// Help
|
||||
"chatgpt_log" => utils::open_file(utils::chat_root().join("chatgpt.log")),
|
||||
"update_log" => open(&app, conf::UPDATE_LOG_URL.to_string()),
|
||||
"report_bug" => open(&app, conf::ISSUES_URL.to_string()),
|
||||
"dev_tools" => {
|
||||
@@ -240,11 +245,20 @@ pub fn menu_handler(event: WindowMenuEvent<tauri::Wry>) {
|
||||
pub fn tray_menu() -> SystemTray {
|
||||
SystemTray::new().with_menu(
|
||||
SystemTrayMenu::new()
|
||||
.add_item(CustomMenuItem::new("control_center".to_string(), "Control Center"))
|
||||
.add_item(CustomMenuItem::new("show_dock_icon".to_string(), "Show Dock Icon"))
|
||||
.add_item(CustomMenuItem::new("hide_dock_icon".to_string(), "Hide Dock Icon"))
|
||||
.add_item(CustomMenuItem::new(
|
||||
"control_center".to_string(),
|
||||
"Control Center",
|
||||
))
|
||||
.add_item(CustomMenuItem::new(
|
||||
"show_dock_icon".to_string(),
|
||||
"Show Dock Icon",
|
||||
))
|
||||
.add_item(CustomMenuItem::new(
|
||||
"hide_dock_icon".to_string(),
|
||||
"Hide Dock Icon",
|
||||
))
|
||||
.add_native_item(SystemTrayMenuItem::Separator)
|
||||
.add_item(CustomMenuItem::new("quit".to_string(), "Quit ChatGPT"))
|
||||
.add_item(CustomMenuItem::new("quit".to_string(), "Quit ChatGPT")),
|
||||
)
|
||||
}
|
||||
|
||||
@@ -276,25 +290,19 @@ pub fn tray_handler(handle: &AppHandle, event: SystemTrayEvent) {
|
||||
"control_center" => app.get_window("main").unwrap().show().unwrap(),
|
||||
"restart" => tauri::api::process::restart(&handle.env()),
|
||||
"show_dock_icon" => {
|
||||
ChatConfJson::amend(
|
||||
&serde_json::json!({ "hide_dock_icon": false }),
|
||||
Some(app),
|
||||
)
|
||||
.unwrap();
|
||||
},
|
||||
ChatConfJson::amend(&serde_json::json!({ "hide_dock_icon": false }), Some(app))
|
||||
.unwrap();
|
||||
}
|
||||
"hide_dock_icon" => {
|
||||
let chat_conf = conf::ChatConfJson::get_chat_conf();
|
||||
if !chat_conf.hide_dock_icon {
|
||||
ChatConfJson::amend(
|
||||
&serde_json::json!({ "hide_dock_icon": true }),
|
||||
Some(app),
|
||||
)
|
||||
.unwrap();
|
||||
ChatConfJson::amend(&serde_json::json!({ "hide_dock_icon": true }), Some(app))
|
||||
.unwrap();
|
||||
}
|
||||
},
|
||||
}
|
||||
"quit" => std::process::exit(0),
|
||||
_ => (),
|
||||
}
|
||||
},
|
||||
_ => (),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -34,7 +34,8 @@ pub fn init(app: &mut App) -> std::result::Result<(), Box<dyn std::error::Error>
|
||||
.initialization_script(include_str!("../assets/export.js"))
|
||||
.initialization_script(include_str!("../assets/cmd.js"))
|
||||
.user_agent(&chat_conf.ua_window)
|
||||
.build().unwrap();
|
||||
.build()
|
||||
.unwrap();
|
||||
|
||||
#[cfg(not(target_os = "macos"))]
|
||||
WindowBuilder::new(&app, "core", WindowUrl::App(url.into()))
|
||||
@@ -51,7 +52,8 @@ pub fn init(app: &mut App) -> std::result::Result<(), Box<dyn std::error::Error>
|
||||
.initialization_script(include_str!("../assets/export.js"))
|
||||
.initialization_script(include_str!("../assets/cmd.js"))
|
||||
.user_agent(&chat_conf.ua_window)
|
||||
.build().unwrap();
|
||||
.build()
|
||||
.unwrap();
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
15
src-tauri/src/assets/cmd.js
vendored
15
src-tauri/src/assets/cmd.js
vendored
@@ -7,7 +7,6 @@ function init() {
|
||||
}
|
||||
.chat-model-cmd-list {
|
||||
position: absolute;
|
||||
width: 400px;
|
||||
bottom: 60px;
|
||||
max-height: 100px;
|
||||
overflow: auto;
|
||||
@@ -31,13 +30,17 @@ function init() {
|
||||
}
|
||||
.chat-model-cmd-list .cmd-item b {
|
||||
display: inline-block;
|
||||
width: 120px;
|
||||
width: 100px;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
border-radius: 4px;
|
||||
margin-right: 10px;
|
||||
color: #2a2a2a;
|
||||
}
|
||||
.chat-model-cmd-list .cmd-item i {
|
||||
width: 270px;
|
||||
width: 100%;
|
||||
max-width: 200px;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
@@ -64,6 +67,12 @@ async function cmdTip() {
|
||||
|
||||
const modelDom = document.createElement('div');
|
||||
modelDom.classList.add('chat-model-cmd-list');
|
||||
|
||||
// fix: tray window
|
||||
if (__TAURI_METADATA__.__currentWindow.label === 'tray') {
|
||||
modelDom.style.bottom = '40px';
|
||||
}
|
||||
|
||||
document.querySelector('form').appendChild(modelDom);
|
||||
const itemDom = (v) => `<div class="cmd-item" data-prompt="${encodeURIComponent(v.prompt)}"><b>/${v.cmd}</b><i>${v.act}</i></div>`;
|
||||
const searchInput = document.querySelector('form textarea');
|
||||
|
||||
@@ -9,13 +9,29 @@ mod utils;
|
||||
|
||||
use app::{cmd, menu, setup};
|
||||
use conf::{ChatConfJson, ChatState};
|
||||
use tauri::api::path;
|
||||
use tauri_plugin_log::{fern::colors::ColoredLevelConfig, LogTarget, LoggerBuilder};
|
||||
|
||||
fn main() {
|
||||
ChatConfJson::init();
|
||||
let chat_conf = ChatConfJson::get_chat_conf();
|
||||
let context = tauri::generate_context!();
|
||||
let colors = ColoredLevelConfig::default();
|
||||
|
||||
tauri::Builder::default()
|
||||
// https://github.com/tauri-apps/tauri/pull/2736
|
||||
.plugin(
|
||||
LoggerBuilder::new()
|
||||
.with_colors(colors)
|
||||
.targets([
|
||||
// LogTarget::LogDir,
|
||||
// LOG PATH: ~/.chatgpt/ChatGPT.log
|
||||
LogTarget::Folder(path::home_dir().unwrap().join(".chatgpt")),
|
||||
LogTarget::Stdout,
|
||||
LogTarget::Webview,
|
||||
])
|
||||
.build(),
|
||||
)
|
||||
.manage(ChatState::default(chat_conf))
|
||||
.invoke_handler(tauri::generate_handler![
|
||||
cmd::drag_window,
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
use anyhow::Result;
|
||||
use log::info;
|
||||
use std::{
|
||||
fs::{self, File},
|
||||
path::{Path, PathBuf},
|
||||
@@ -48,6 +49,7 @@ pub fn user_script() -> String {
|
||||
}
|
||||
|
||||
pub fn open_file(path: PathBuf) {
|
||||
info!("open_file: {}", path.to_string_lossy());
|
||||
#[cfg(target_os = "macos")]
|
||||
Command::new("open").arg("-R").arg(path).spawn().unwrap();
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
},
|
||||
"package": {
|
||||
"productName": "ChatGPT",
|
||||
"version": "0.4.0"
|
||||
"version": "0.4.2"
|
||||
},
|
||||
"tauri": {
|
||||
"allowlist": {
|
||||
|
||||
12
src/view/LanguageModel/index.tsx
vendored
12
src/view/LanguageModel/index.tsx
vendored
@@ -2,6 +2,7 @@ import { useState, useRef, useEffect } from 'react';
|
||||
import { Table, Button, Modal, message } from 'antd';
|
||||
import { invoke } from '@tauri-apps/api';
|
||||
|
||||
import useInit from '@/hooks/useInit';
|
||||
import useChatModel from '@/hooks/useChatModel';
|
||||
import useColumns from '@/hooks/useColumns';
|
||||
import useData from '@/hooks/useData';
|
||||
@@ -30,6 +31,11 @@ export default function LanguageModel() {
|
||||
}
|
||||
}, [opInfo.opType, formRef]);
|
||||
|
||||
useInit(async () => {
|
||||
const path = await chatModelPath();
|
||||
setChatModelPath(path);
|
||||
})
|
||||
|
||||
const hide = () => {
|
||||
setVisible(false);
|
||||
opInfo.resetRecord();
|
||||
@@ -53,10 +59,8 @@ export default function LanguageModel() {
|
||||
})
|
||||
};
|
||||
|
||||
const handleOpenFile = async () => {
|
||||
const path = await chatModelPath();
|
||||
setChatModelPath(path);
|
||||
invoke('open_file', { path });
|
||||
const handleOpenFile = () => {
|
||||
invoke('open_file', { path: modelPath });
|
||||
};
|
||||
|
||||
const modalTitle = `${({ new: 'Create', edit: 'Edit' })[opInfo.opType]} Language Model`;
|
||||
|
||||
Reference in New Issue
Block a user