From 1f573102d3eddc66ed7af3594e5f6138db0bcec1 Mon Sep 17 00:00:00 2001 From: lencx Date: Mon, 23 Jan 2023 20:29:05 +0800 Subject: [PATCH] chore: about --- package.json | 2 + src-tauri/src/app/cmd.rs | 14 +++++ src-tauri/src/main.rs | 1 + src/components/Markdown/index.scss | 6 ++ src/components/Markdown/index.tsx | 2 + src/routes.tsx | 12 +++- src/utils.ts | 1 + src/view/about/index.scss | 18 ++++++ src/view/about/index.tsx | 88 ++++++++++++++++++++++++++++++ 9 files changed, 143 insertions(+), 1 deletion(-) create mode 100644 src/view/about/index.scss create mode 100644 src/view/about/index.tsx diff --git a/package.json b/package.json index 96e77cd..387d4e8 100644 --- a/package.json +++ b/package.json @@ -50,6 +50,8 @@ "react-resizable-panels": "^0.0.33", "react-router-dom": "^6.4.5", "react-syntax-highlighter": "^15.5.0", + "rehype-raw": "^6.1.1", + "remark-comment-config": "^7.0.1", "remark-gfm": "^3.0.1", "uuid": "^9.0.0" }, diff --git a/src-tauri/src/app/cmd.rs b/src-tauri/src/app/cmd.rs index 2127af8..0867256 100644 --- a/src-tauri/src/app/cmd.rs +++ b/src-tauri/src/app/cmd.rs @@ -354,6 +354,20 @@ pub async fn sync_prompts(app: AppHandle, time: u64) -> Option> None } +#[command] +pub async fn get_data(app: AppHandle, url: String, is_msg: Option) -> Option { + let is_msg = is_msg.unwrap_or(false); + let res = if is_msg { + utils::get_data(&url, Some(&app)).await + } else { + utils::get_data(&url, None).await + }; + res.unwrap_or_else(|err| { + info!("chatgpt_client_http_error: {}", err); + None + }) +} + #[command] pub async fn sync_user_prompts(url: String, data_type: String) -> Option> { let res = utils::get_data(&url, None).await.unwrap_or_else(|err| { diff --git a/src-tauri/src/main.rs b/src-tauri/src/main.rs index 0468ac8..2be1464 100644 --- a/src-tauri/src/main.rs +++ b/src-tauri/src/main.rs @@ -78,6 +78,7 @@ async fn main() { cmd::cmd_list, cmd::download_list, cmd::get_download_list, + cmd::get_data, fs_extra::metadata, ]) .setup(setup::init) diff --git a/src/components/Markdown/index.scss b/src/components/Markdown/index.scss index 5c0bc57..64745c0 100644 --- a/src/components/Markdown/index.scss +++ b/src/components/Markdown/index.scss @@ -13,6 +13,12 @@ code { font-family: monospace, monospace; } + + code { + background-color: rgba(200, 200, 200, 0.4); + padding: 2px 4px; + border-radius: 5px; + } } .md-main { diff --git a/src/components/Markdown/index.tsx b/src/components/Markdown/index.tsx index 7277ebf..c77bc0b 100644 --- a/src/components/Markdown/index.tsx +++ b/src/components/Markdown/index.tsx @@ -2,6 +2,7 @@ import { FC } from 'react'; import clsx from 'clsx'; import ReactMarkdown from 'react-markdown'; import remarkGfm from 'remark-gfm'; +import rehypeRaw from 'rehype-raw'; import SyntaxHighlighter from 'react-syntax-highlighter'; import agate from 'react-syntax-highlighter/dist/esm/styles/hljs/agate'; @@ -20,6 +21,7 @@ const Markdown: FC = ({ children, className }) => { children={children} linkTarget="_blank" remarkPlugins={[remarkGfm]} + rehypePlugins={[rehypeRaw]} components={{ code({ node, inline, className, children, ...props }) { const match = /language-(\w+)/.exec(className || ''); diff --git a/src/routes.tsx b/src/routes.tsx index 3ce6080..f3e711f 100644 --- a/src/routes.tsx +++ b/src/routes.tsx @@ -8,10 +8,12 @@ import { DownloadOutlined, FormOutlined, GlobalOutlined, + InfoCircleOutlined, } from '@ant-design/icons'; import type { MenuProps } from 'antd'; import Settings from '@/view/settings'; +import About from '@/view/about'; import Awesome from '@/view/awesome'; import UserCustom from '@/view/model/UserCustom'; import SyncPrompts from '@/view/model/SyncPrompts'; @@ -96,7 +98,7 @@ export const routes: Array = [ ], }, { - path: 'download', + path: '/download', element: , meta: { label: 'Download', @@ -111,6 +113,14 @@ export const routes: Array = [ icon: , }, }, + { + path: '/about', + element: , + meta: { + label: 'About', + icon: , + }, + }, ]; type MenuItem = Required['items'][number]; diff --git a/src/utils.ts b/src/utils.ts index e5b2451..7582c68 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -11,6 +11,7 @@ export const CHAT_NOTES_JSON = 'chat.notes.json'; export const CHAT_PROMPTS_CSV = 'chat.prompts.csv'; export const GITHUB_PROMPTS_CSV_URL = 'https://raw.githubusercontent.com/f/awesome-chatgpt-prompts/main/prompts.csv'; +export const GITHUB_LOG_URL = 'https://raw.githubusercontent.com/lencx/ChatGPT/main/UPDATE_LOG.md'; export const DISABLE_AUTO_COMPLETE = { autoCapitalize: 'off', diff --git a/src/view/about/index.scss b/src/view/about/index.scss new file mode 100644 index 0000000..53cd372 --- /dev/null +++ b/src/view/about/index.scss @@ -0,0 +1,18 @@ +.about { + .log-tab { + font-size: 14px; + + h2 { + font-size: 16px; + } + } + + .about-tab { + .imgs { + img { + max-width: 200px; + margin-bottom: 20px; + } + } + } +} diff --git a/src/view/about/index.tsx b/src/view/about/index.tsx new file mode 100644 index 0000000..9a82e62 --- /dev/null +++ b/src/view/about/index.tsx @@ -0,0 +1,88 @@ +import { useState } from 'react'; +import { invoke } from '@tauri-apps/api'; +import { Tabs, Tag } from 'antd'; + +import { GITHUB_LOG_URL } from '@/utils'; +import useInit from '@/hooks/useInit'; +import Markdown from '@/components/Markdown'; +import './index.scss'; + +export default function About() { + const [logContent, setLogContent] = useState(''); + + useInit(async () => { + const data = (await invoke('get_data', { url: GITHUB_LOG_URL })) || ''; + setLogContent(data as string); + }); + + return ( +
+ }, + { label: 'Update Log', key: 'log', children: }, + ]} + /> +
+ ); +} + +const AboutChatGPT = () => { + return ( +
+ ChatGPT Desktop Application (Mac, Windows and Linux) +

+ 🕒 History versions:{' '} + + lencx/ChatGPT/releases + +

+

+ It is just a wrapper for the + + {' '} + OpenAI ChatGPT{' '} + + website, no other data transfer exists (you can check the{' '} + + {' '} + source code{' '} + + ). The development and maintenance of this software has taken up a lot of my time. If it + helps you, you can buy me a cup of coffee (Chinese users can use WeChat to scan the code), + thanks! +

+

+ + Buy Me A Coffee + {' '} +
+ +

+
+ ); +}; + +const LogTab = ({ content }: { content: string }) => { + return ( +
+

+ Ref:{' '} + + lencx/ChatGPT/UPDATE_LOG.md + +

+ +
+ ); +};