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 + ); };