From f7335d9162774afafeb4489bda07dabc2c83d759 Mon Sep 17 00:00:00 2001 From: tk103331 Date: Thu, 5 Jan 2023 11:52:23 +0800 Subject: [PATCH 1/5] control center theme --- src-tauri/src/app/cmd.rs | 7 ++++++- src-tauri/src/main.rs | 1 + src/layout/index.tsx | 21 ++++++++++++++------- 3 files changed, 21 insertions(+), 8 deletions(-) diff --git a/src-tauri/src/app/cmd.rs b/src-tauri/src/app/cmd.rs index 677827b..ae0e903 100644 --- a/src-tauri/src/app/cmd.rs +++ b/src-tauri/src/app/cmd.rs @@ -4,7 +4,7 @@ use crate::{ }; use log::info; use std::{collections::HashMap, fs, path::PathBuf}; -use tauri::{api, command, AppHandle, Manager}; +use tauri::{api, command, AppHandle, Manager, Theme}; #[command] pub fn drag_window(app: AppHandle) { @@ -38,6 +38,11 @@ pub fn get_chat_conf() -> ChatConfJson { ChatConfJson::get_chat_conf() } +#[command] +pub fn get_theme() -> String { + ChatConfJson::theme().unwrap_or(Theme::Light).to_string() +} + #[command] pub fn reset_chat_conf() -> ChatConfJson { ChatConfJson::reset_chat_conf() diff --git a/src-tauri/src/main.rs b/src-tauri/src/main.rs index 05e9161..fc218f5 100644 --- a/src-tauri/src/main.rs +++ b/src-tauri/src/main.rs @@ -56,6 +56,7 @@ async fn main() { cmd::download, cmd::open_link, cmd::get_chat_conf, + cmd::get_theme, cmd::reset_chat_conf, cmd::run_check_update, cmd::form_cancel, diff --git a/src/layout/index.tsx b/src/layout/index.tsx index 82cf74a..06ab0ad 100644 --- a/src/layout/index.tsx +++ b/src/layout/index.tsx @@ -1,5 +1,5 @@ import { FC, useState } from 'react'; -import {Layout, Menu, Button, Tooltip, message} from 'antd'; +import {Layout, Menu, Button, Tooltip, message, ConfigProvider, theme, Tag} from 'antd'; import { SyncOutlined } from '@ant-design/icons'; import { useNavigate, useLocation } from 'react-router-dom'; import { getName, getVersion } from '@tauri-apps/api/app'; @@ -12,7 +12,8 @@ const { Content, Footer, Sider } = Layout; const appName = await getName(); const appVersion = await getVersion(); - +const appTheme = await invoke("get_theme"); +console.log("theme:"+appTheme); interface ChatLayoutProps { children?: React.ReactNode; } @@ -27,9 +28,10 @@ const ChatLayout: FC = ({ children }) => { } return ( + setCollapsed(value)} @@ -45,21 +47,25 @@ const ChatLayout: FC = ({ children }) => { >
- {appName} + {appName}
+ {appVersion} { - - - + + + } + +
= ({ children }) => { ChatGPT Desktop Application ©2022 Created by lencx + ); }; From 1dee42dc79faa968e96b23f74f9aaf3c41528072 Mon Sep 17 00:00:00 2001 From: yixinBC Date: Thu, 5 Jan 2023 12:40:21 +0800 Subject: [PATCH 2/5] readme: AUR installation --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index ccbc88a..8e8d91c 100644 --- a/README.md +++ b/README.md @@ -53,6 +53,7 @@ - [chat-gpt_0.7.4_amd64.deb](https://github.com/lencx/ChatGPT/releases/download/v0.7.4/chat-gpt_0.7.4_amd64.deb) - [chat-gpt_0.7.4_amd64.AppImage](https://github.com/lencx/ChatGPT/releases/download/v0.7.4/chat-gpt_0.7.4_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. [History versions...](https://github.com/lencx/ChatGPT/releases) From 9f3c72ec6d4f1d46f50ee74b77ddff85710ab5ab Mon Sep 17 00:00:00 2001 From: lencx Date: Thu, 5 Jan 2023 13:18:35 +0800 Subject: [PATCH 3/5] chore: style --- .github/workflows/release.yml | 4 ++-- src-tauri/src/app/menu.rs | 38 +++++++++++++++++++++-------------- src/layout/index.scss | 16 +++++++++------ src/layout/index.tsx | 28 ++++++++------------------ src/main.scss | 2 +- src/view/General.tsx | 24 ++++++++++------------ 6 files changed, 55 insertions(+), 57 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 7157e56..ce843c4 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -57,8 +57,8 @@ jobs: - name: Install app dependencies and build it run: yarn && yarn build:fe - - name: Rewrite tauri.conf.json - run: yarn fix:conf + # - name: Rewrite tauri.conf.json + # run: yarn fix:conf - name: fix tray icon if: matrix.platform != 'macos-latest' diff --git a/src-tauri/src/app/menu.rs b/src-tauri/src/app/menu.rs index b5ef78d..f39d295 100644 --- a/src-tauri/src/app/menu.rs +++ b/src-tauri/src/app/menu.rs @@ -103,14 +103,13 @@ pub fn init() -> Menu { update_silent.selected() } else { update_silent - }) - // .add_item(if chat_conf.auto_update == "Disable" { - // update_disable.selected() - // } else { - // update_disable - // }) - , - ).into(), + }), // .add_item(if chat_conf.auto_update == "Disable" { + // update_disable.selected() + // } else { + // update_disable + // }) + ) + .into(), stay_on_top_menu.into(), #[cfg(target_os = "macos")] titlebar_menu.into(), @@ -273,22 +272,31 @@ pub fn menu_handler(event: WindowMenuEvent) { ChatConfJson::amend(&serde_json::json!({ "theme": theme }), Some(app)).unwrap(); } "update_prompt" | "update_silent" | "update_disable" => { - for id in ["update_prompt" , "update_silent" , "update_disable"] { + for id in ["update_prompt", "update_silent", "update_disable"] { menu_handle.get_item(id).set_selected(false).unwrap(); } let auto_update = match menu_id { "update_silent" => { - menu_handle.get_item("update_silent").set_selected(true).unwrap(); + menu_handle + .get_item("update_silent") + .set_selected(true) + .unwrap(); "Silent" - }, + } "update_disable" => { - menu_handle.get_item("update_disable").set_selected(true).unwrap(); + menu_handle + .get_item("update_disable") + .set_selected(true) + .unwrap(); "Disable" - }, + } _ => { - menu_handle.get_item("update_prompt").set_selected(true).unwrap(); + menu_handle + .get_item("update_prompt") + .set_selected(true) + .unwrap(); "Prompt" - }, + } }; ChatConfJson::amend(&serde_json::json!({ "auto_update": auto_update }), None).unwrap(); } diff --git a/src/layout/index.scss b/src/layout/index.scss index 00ef8bf..07d5cf5 100644 --- a/src/layout/index.scss +++ b/src/layout/index.scss @@ -1,16 +1,23 @@ .chat-logo { text-align: center; - padding: 5px 0; + height: 48px; img { - width: 48px; - height: 48px; + width: 44px; + height: 44px; + margin-top: 4px; } } + .chat-info { text-align: center; font-weight: bold; + + .ant-tag { + margin: 2px; + } } + .ant-layout-sider-trigger { user-select: none; -webkit-user-select: none; @@ -24,9 +31,6 @@ .ant-menu { user-select: none; -webkit-user-select: none; - .ant-menu-item { - background-color: #f8f8f8; - } } .ant-layout-footer { diff --git a/src/layout/index.tsx b/src/layout/index.tsx index 06ab0ad..99f70d4 100644 --- a/src/layout/index.tsx +++ b/src/layout/index.tsx @@ -1,5 +1,5 @@ -import { FC, useState } from 'react'; -import {Layout, Menu, Button, Tooltip, message, ConfigProvider, theme, Tag} from 'antd'; +import { useState } from 'react'; +import {Layout, Menu, Tooltip, ConfigProvider, theme, Tag } from 'antd'; import { SyncOutlined } from '@ant-design/icons'; import { useNavigate, useLocation } from 'react-router-dom'; import { getName, getVersion } from '@tauri-apps/api/app'; @@ -13,25 +13,21 @@ const { Content, Footer, Sider } = Layout; const appName = await getName(); const appVersion = await getVersion(); const appTheme = await invoke("get_theme"); -console.log("theme:"+appTheme); -interface ChatLayoutProps { - children?: React.ReactNode; -} -const ChatLayout: FC = ({ children }) => { +export default function ChatLayout() { const [collapsed, setCollapsed] = useState(false); const location = useLocation(); const go = useNavigate(); const checkAppUpdate = async () => { - await invoke('run_check_update', {silent: false}); + await invoke('run_check_update', { silent: false }); } return ( setCollapsed(value)} @@ -47,19 +43,13 @@ const ChatLayout: FC = ({ children }) => { >
- {appName} -
-
+ {appName} - {appVersion} - - { + {appVersion} - } -
= ({ children }) => { ); -}; - -export default ChatLayout; \ No newline at end of file +}; \ No newline at end of file diff --git a/src/main.scss b/src/main.scss index 96ebea4..afba087 100644 --- a/src/main.scss +++ b/src/main.scss @@ -63,7 +63,7 @@ html, body { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; - color: #2a2a2a; + // color: #2a2a2a; } span { diff --git a/src/view/General.tsx b/src/view/General.tsx index 1291baf..ce4416e 100644 --- a/src/view/General.tsx +++ b/src/view/General.tsx @@ -114,20 +114,23 @@ export default function General() { labelCol={{ span: 8 }} wrapperCol={{ span: 15, offset: 1 }} > + + + + {platformInfo === 'darwin' && ( + + + + )} Light Dark - { - (["darwin", "windows"].includes(platformInfo) ) && ( - System - ) - } + {["darwin", "windows"].includes(platformInfo) && ( + System + )} - - - } name="auto_update"> Prompt @@ -138,11 +141,6 @@ export default function General() { } name="global_shortcut"> - {platformInfo === 'darwin' && ( - - - - )} } name="origin"> From a87654e42791b76a4bfff7429f203c9b306646a2 Mon Sep 17 00:00:00 2001 From: lencx Date: Thu, 5 Jan 2023 13:32:41 +0800 Subject: [PATCH 4/5] readme --- README-ZH_CN.md | 5 +++-- README.md | 6 +++--- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/README-ZH_CN.md b/README-ZH_CN.md index a3486a4..4df9c2c 100644 --- a/README-ZH_CN.md +++ b/README-ZH_CN.md @@ -24,8 +24,8 @@ - [ChatGPT_0.7.4_x64_en-US.msi](https://github.com/lencx/ChatGPT/releases/download/v0.7.4/ChatGPT_0.7.4_x64_en-US.msi) - 或者使用 [winget](https://learn.microsoft.com/en-us/windows/package-manager/winget/): - - `winget install --id=lencx.ChatGPT -e` - - `winget install --id=lencx.ChatGPT -e --version 0.7.4` + - `winget install --id=lencx.ChatGPT -e` + - `winget install --id=lencx.ChatGPT -e --version 0.7.4` **注意:如果安装路径和应用名称相同,会导致冲突 ([#142](https://github.com/lencx/ChatGPT/issues/142#issuecomment-1371166972))** @@ -50,6 +50,7 @@ - [chat-gpt_0.7.4_amd64.deb](https://github.com/lencx/ChatGPT/releases/download/v0.7.4/chat-gpt_0.7.4_amd64.deb) - [chat-gpt_0.7.4_amd64.AppImage](https://github.com/lencx/ChatGPT/releases/download/v0.7.4/chat-gpt_0.7.4_amd64.AppImage): **工作可靠,`.deb` 运行失败时可以尝试它** +- [chatgpt-desktop-bin](https://aur.archlinux.org/packages/chatgpt-desktop-bin): 使用 AUR 来安装 diff --git a/README.md b/README.md index 8e8d91c..25aea6c 100644 --- a/README.md +++ b/README.md @@ -27,8 +27,8 @@ - From our github releases: [ChatGPT_0.7.4_x64_en-US.msi](https://github.com/lencx/ChatGPT/releases/download/v0.7.4/ChatGPT_0.7.4_x64_en-US.msi) - Or install with [winget](https://learn.microsoft.com/en-us/windows/package-manager/winget/): - - `winget install --id=lencx.ChatGPT -e` - - `winget install --id=lencx.ChatGPT -e --version 0.7.4` + - `winget install --id=lencx.ChatGPT -e` + - `winget install --id=lencx.ChatGPT -e --version 0.7.4` **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-1371166972))** @@ -53,7 +53,7 @@ - [chat-gpt_0.7.4_amd64.deb](https://github.com/lencx/ChatGPT/releases/download/v0.7.4/chat-gpt_0.7.4_amd64.deb) - [chat-gpt_0.7.4_amd64.AppImage](https://github.com/lencx/ChatGPT/releases/download/v0.7.4/chat-gpt_0.7.4_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. [History versions...](https://github.com/lencx/ChatGPT/releases) From a0896c979962ce37499fed9feedb44f009b5c93d Mon Sep 17 00:00:00 2001 From: lencx Date: Thu, 5 Jan 2023 14:57:50 +0800 Subject: [PATCH 5/5] readme --- README-ZH_CN.md | 7 ++++--- README.md | 5 ++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/README-ZH_CN.md b/README-ZH_CN.md index 4df9c2c..7582711 100644 --- a/README-ZH_CN.md +++ b/README-ZH_CN.md @@ -16,7 +16,8 @@ ## 📦 安装 -[📝 更新日志](./UPDATE_LOG.md) +- [📝 更新日志](./UPDATE_LOG.md) +- [🕒 历史版本...](https://github.com/lencx/ChatGPT/releases) @@ -135,7 +136,7 @@ 目前同步自定文件仅支持 json 和 csv,且需要满足以下格式,否则会导致应用异常: -> JSON 格式 +`JSON 格式` ```json [ @@ -152,7 +153,7 @@ ] ``` -> CSV 格式 +`CSV 格式` ```csv "cmd","act","prompt" diff --git a/README.md b/README.md index 25aea6c..9afc75f 100644 --- a/README.md +++ b/README.md @@ -19,7 +19,8 @@ ## 📦 Install -[📝 Update Log](./UPDATE_LOG.md) +- [📝 Update Log](./UPDATE_LOG.md) +- [🕒 History versions...](https://github.com/lencx/ChatGPT/releases) @@ -55,8 +56,6 @@ - [chat-gpt_0.7.4_amd64.AppImage](https://github.com/lencx/ChatGPT/releases/download/v0.7.4/chat-gpt_0.7.4_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. -[History versions...](https://github.com/lencx/ChatGPT/releases) - ---