diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index c6f2d4e..889af2f 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -90,13 +90,13 @@ jobs: publish_dir: ./updater force_orphan: true - publish-winget: - # Action can only be run on windows - runs-on: windows-latest - needs: [create-release, build-tauri] - steps: - - uses: vedantmgoyal2009/winget-releaser@v1 - with: - identifier: lencx.ChatGPT - token: ${{ secrets.WINGET_TOKEN }} - version: ${{ env.version }} + # publish-winget: + # # Action can only be run on windows + # runs-on: windows-latest + # needs: [create-release, build-tauri] + # steps: + # - uses: vedantmgoyal2009/winget-releaser@v1 + # with: + # identifier: lencx.ChatGPT + # token: ${{ secrets.WINGET_TOKEN }} + # version: ${{ env.version }} diff --git a/README-ZH_CN.md b/README-ZH_CN.md index 46a671a..2a3761d 100644 --- a/README-ZH_CN.md +++ b/README-ZH_CN.md @@ -24,7 +24,7 @@ ### Windows -- [ChatGPT_0.10.0_x64_en-US.msi](https://github.com/lencx/ChatGPT/releases/download/v0.10.0/ChatGPT_0.10.0_x64_en-US.msi): +- [ChatGPT_0.10.1_x64_en-US.msi](https://github.com/lencx/ChatGPT/releases/download/v0.10.1/ChatGPT_0.10.1_x64_en-US.msi): - 使用 [winget](https://winstall.app/apps/lencx.ChatGPT): ```bash @@ -32,15 +32,15 @@ winget install --id=lencx.ChatGPT -e # install the specified version - winget install --id=lencx.ChatGPT -e --version 0.9.0 + winget install --id=lencx.ChatGPT -e --version 0.10.0 ``` -**注意:如果安装路径和应用名称相同,会导致冲突 ([#142](https://github.com/lencx/ChatGPT/issues/142#issuecomment-0.10.0))** +**注意:如果安装路径和应用名称相同,会导致冲突 ([#142](https://github.com/lencx/ChatGPT/issues/142#issuecomment-0.10.1))** ### Mac -- [ChatGPT_0.10.0_x64.dmg](https://github.com/lencx/ChatGPT/releases/download/v0.10.0/ChatGPT_0.10.0_x64.dmg) -- [ChatGPT.app.tar.gz](https://github.com/lencx/ChatGPT/releases/download/v0.10.0/ChatGPT.app.tar.gz) +- [ChatGPT_0.10.1_x64.dmg](https://github.com/lencx/ChatGPT/releases/download/v0.10.1/ChatGPT_0.10.1_x64.dmg) +- [ChatGPT.app.tar.gz](https://github.com/lencx/ChatGPT/releases/download/v0.10.1/ChatGPT.app.tar.gz) - Homebrew \ _[Homebrew 快捷安装](https://brew.sh) ([Cask](https://docs.brew.sh/Cask-Cookbook)):_ ```sh @@ -56,8 +56,8 @@ ### Linux -- [chat-gpt_0.10.0_amd64.deb](https://github.com/lencx/ChatGPT/releases/download/v0.10.0/chat-gpt_0.10.0_amd64.deb) -- [chat-gpt_0.10.0_amd64.AppImage](https://github.com/lencx/ChatGPT/releases/download/v0.10.0/chat-gpt_0.10.0_amd64.AppImage): **工作可靠,`.deb` 运行失败时可以尝试它** +- [chat-gpt_0.10.1_amd64.deb](https://github.com/lencx/ChatGPT/releases/download/v0.10.1/chat-gpt_0.10.1_amd64.deb) +- [chat-gpt_0.10.1_amd64.AppImage](https://github.com/lencx/ChatGPT/releases/download/v0.10.1/chat-gpt_0.10.1_amd64.AppImage): **工作可靠,`.deb` 运行失败时可以尝试它** - 使用 [AUR](https://aur.archlinux.org/packages/chatgpt-desktop-bin): ```bash yay -S chatgpt-desktop-bin diff --git a/README.md b/README.md index a6e5bce..9027611 100644 --- a/README.md +++ b/README.md @@ -26,7 +26,7 @@ ### Windows -- [ChatGPT_0.10.0_x64_en-US.msi](https://github.com/lencx/ChatGPT/releases/download/v0.10.0/ChatGPT_0.10.0_x64_en-US.msi): Direct download installer +- [ChatGPT_0.10.1_x64_en-US.msi](https://github.com/lencx/ChatGPT/releases/download/v0.10.1/ChatGPT_0.10.1_x64_en-US.msi): Direct download installer - Use [winget](https://winstall.app/apps/lencx.ChatGPT): ```bash @@ -34,15 +34,15 @@ winget install --id=lencx.ChatGPT -e # install the specified version - winget install --id=lencx.ChatGPT -e --version 0.9.0 + winget install --id=lencx.ChatGPT -e --version 0.10.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.10.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.10.1))** ### Mac -- [ChatGPT_0.10.0_x64.dmg](https://github.com/lencx/ChatGPT/releases/download/v0.10.0/ChatGPT_0.10.0_x64.dmg): Direct download installer -- [ChatGPT.app.tar.gz](https://github.com/lencx/ChatGPT/releases/download/v0.10.0/ChatGPT.app.tar.gz): Download the `.app` installer +- [ChatGPT_0.10.1_x64.dmg](https://github.com/lencx/ChatGPT/releases/download/v0.10.1/ChatGPT_0.10.1_x64.dmg): Direct download installer +- [ChatGPT.app.tar.gz](https://github.com/lencx/ChatGPT/releases/download/v0.10.1/ChatGPT.app.tar.gz): Download the `.app` installer - Homebrew \ Or you can install with _[Homebrew](https://brew.sh) ([Cask](https://docs.brew.sh/Cask-Cookbook)):_ ```sh @@ -58,8 +58,8 @@ ### Linux -- [chat-gpt_0.10.0_amd64.deb](https://github.com/lencx/ChatGPT/releases/download/v0.10.0/chat-gpt_0.10.0_amd64.deb): Download `.deb` installer, advantage small size, disadvantage poor compatibility -- [chat-gpt_0.10.0_amd64.AppImage](https://github.com/lencx/ChatGPT/releases/download/v0.10.0/chat-gpt_0.10.0_amd64.AppImage): Works reliably, you can try it if `.deb` fails to run +- [chat-gpt_0.10.1_amd64.deb](https://github.com/lencx/ChatGPT/releases/download/v0.10.1/chat-gpt_0.10.1_amd64.deb): Download `.deb` installer, advantage small size, disadvantage poor compatibility +- [chat-gpt_0.10.1_amd64.AppImage](https://github.com/lencx/ChatGPT/releases/download/v0.10.1/chat-gpt_0.10.1_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. diff --git a/UPDATE_LOG.md b/UPDATE_LOG.md index e4322b6..affbc85 100644 --- a/UPDATE_LOG.md +++ b/UPDATE_LOG.md @@ -1,5 +1,17 @@ # UPDATE LOG +## v0.10.1 + +Fix: + +- Program exception when `Awesome` data is empty (https://github.com/lencx/ChatGPT/issues/248) + +Feat: + +- New shortcut key to change zoom level (30% - 200%), `+` or `-` 10% each time, `0` will be reset to 100% (https://github.com/lencx/ChatGPT/issues/202) + - Windows: `Ctrl +`, `Ctrl -`, `Ctrl 0` + - MacOS: `Cmd +`, `Cmd -`, `Cmd 0` + ## v0.10.0 Fix: diff --git a/src-tauri/src/app/menu.rs b/src-tauri/src/app/menu.rs index e507613..450e027 100644 --- a/src-tauri/src/app/menu.rs +++ b/src-tauri/src/app/menu.rs @@ -175,6 +175,12 @@ pub fn init() -> Menu { .accelerator("CmdOrCtrl+Down"), ) .add_native_item(MenuItem::Separator) + .add_item( + CustomMenuItem::new("zoom_0".to_string(), "Zoom to Actual Size").accelerator("CmdOrCtrl+0"), + ) + .add_item(CustomMenuItem::new("zoom_out".to_string(), "Zoom Out").accelerator("CmdOrCtrl+-")) + .add_item(CustomMenuItem::new("zoom_in".to_string(), "Zoom In").accelerator("CmdOrCtrl+Plus")) + .add_native_item(MenuItem::Separator) .add_item( CustomMenuItem::new("reload".to_string(), "Refresh the Screen").accelerator("CmdOrCtrl+R"), ), @@ -337,6 +343,9 @@ pub fn menu_handler(event: WindowMenuEvent) { // Window "dalle2" => window::dalle2_window(&app, None, None, Some(false)), // View + "zoom_0" => win.eval("window.__zoom0 && window.__zoom0()").unwrap(), + "zoom_out" => win.eval("window.__zoomOut && window.__zoomOut()").unwrap(), + "zoom_in" => win.eval("window.__zoomIn && window.__zoomIn()").unwrap(), "reload" => win.eval("window.location.reload()").unwrap(), "go_back" => win.eval("window.history.go(-1)").unwrap(), "go_forward" => win.eval("window.history.go(1)").unwrap(), diff --git a/src-tauri/src/app/setup.rs b/src-tauri/src/app/setup.rs index f596ec3..236e696 100644 --- a/src-tauri/src/app/setup.rs +++ b/src-tauri/src/app/setup.rs @@ -66,7 +66,8 @@ pub fn init(app: &mut App) -> std::result::Result<(), Box .initialization_script(include_str!("../scripts/core.js")) .user_agent(&chat_conf.ua_window); - if cfg!(target_os = "macos") { + #[cfg(target_os = "macos")] + { main_win = main_win .title_bar_style(ChatConfJson::titlebar()) .hidden_title(true); diff --git a/src-tauri/src/scripts/core.js b/src-tauri/src/scripts/core.js index dd930b1..c054687 100644 --- a/src-tauri/src/scripts/core.js +++ b/src-tauri/src/scripts/core.js @@ -45,8 +45,6 @@ async function init() { document.getElementsByTagName('html')[0].style['font-size'] = '70%'; } - if (__TAURI_METADATA__.__currentWindow.label !== 'core') return; - async function platform() { return invoke('platform', { __tauriModule: 'Os', @@ -54,29 +52,31 @@ async function init() { }); } - const _platform = await platform(); - const chatConf = await invoke('get_chat_conf') || {}; - if (/darwin/.test(_platform) && !chatConf.titlebar) { - const topStyleDom = document.createElement("style"); - topStyleDom.innerHTML = `#chatgpt-app-window-top{position:fixed;top:0;z-index:999999999;width:100%;height:24px;background:transparent;cursor:grab;cursor:-webkit-grab;user-select:none;-webkit-user-select:none;}#chatgpt-app-window-top:active {cursor:grabbing;cursor:-webkit-grabbing;}`; - document.head.appendChild(topStyleDom); - const topDom = document.createElement("div"); - topDom.id = "chatgpt-app-window-top"; - document.body.appendChild(topDom); + if (__TAURI_METADATA__.__currentWindow.label !== 'tray') { + const _platform = await platform(); + const chatConf = await invoke('get_chat_conf') || {}; + if (/darwin/.test(_platform) && !chatConf.titlebar) { + const topStyleDom = document.createElement("style"); + topStyleDom.innerHTML = `#chatgpt-app-window-top{position:fixed;top:0;z-index:999999999;width:100%;height:24px;background:transparent;cursor:grab;cursor:-webkit-grab;user-select:none;-webkit-user-select:none;}#chatgpt-app-window-top:active {cursor:grabbing;cursor:-webkit-grabbing;}`; + document.head.appendChild(topStyleDom); + const topDom = document.createElement("div"); + topDom.id = "chatgpt-app-window-top"; + document.body.appendChild(topDom); - if (window.location.host === 'chat.openai.com') { - const nav = document.body.querySelector('nav'); - if (nav) { - const currentPaddingTop = parseInt(window.getComputedStyle(document.querySelector('nav'), null).getPropertyValue('padding-top').replace('px', ''), 10); - const navStyleDom = document.createElement("style"); - navStyleDom.innerHTML = `nav{padding-top:${currentPaddingTop + topDom.clientHeight}px !important}`; - document.head.appendChild(navStyleDom); + if (window.location.host === 'chat.openai.com') { + const nav = document.body.querySelector('nav'); + if (nav) { + const currentPaddingTop = parseInt(window.getComputedStyle(document.querySelector('nav'), null).getPropertyValue('padding-top').replace('px', ''), 10); + const navStyleDom = document.createElement("style"); + navStyleDom.innerHTML = `nav{padding-top:${currentPaddingTop + topDom.clientHeight}px !important}`; + document.head.appendChild(navStyleDom); + } } - } - topDom.addEventListener("mousedown", () => invoke("drag_window")); - topDom.addEventListener("touchstart", () => invoke("drag_window")); - topDom.addEventListener("dblclick", () => invoke("fullscreen")); + topDom.addEventListener("mousedown", () => invoke("drag_window")); + topDom.addEventListener("touchstart", () => invoke("drag_window")); + topDom.addEventListener("dblclick", () => invoke("fullscreen")); + } } document.addEventListener("click", (e) => { @@ -98,9 +98,76 @@ async function init() { } }); - window.__sync_prompts = async function() { - await invoke('sync_prompts', { time: Date.now() }); + if (window.location.host === 'chat.openai.com') { + window.__sync_prompts = async function() { + await invoke('sync_prompts', { time: Date.now() }); + } } + + coreZoom(); +} + +function coreZoom() { + const styleDom = document.createElement('style'); + styleDom.innerHTML = ` + #ZoomTopTip { + display: none; + position: fixed; + top: 0; + right: 20px; + background: #2a2a2a; + color: #fafafa; + padding: 20px 15px; + border-bottom-left-radius: 5px; + border-bottom-right-radius: 5px; + font-size: 16px; + font-weight: bold; + z-index: 999999; + box-shadow: 0 2px 2px 2px #d8d8d8; + } + .ZoomTopTipAni { + transition: opacity 200ms, display 200ms; + display: none; + opacity: 0; + } + `; + document.head.append(styleDom); + const zoomTipDom = document.createElement('div'); + zoomTipDom.id = 'ZoomTopTip'; + document.body.appendChild(zoomTipDom); + function zoom(callback) { + if (window.zoomSetTimeout) clearTimeout(window.zoomSetTimeout); + const htmlZoom = window.localStorage.getItem("htmlZoom") || "100%"; + const html = document.getElementsByTagName("html")[0]; + const zoom = callback(htmlZoom); + html.style.zoom = zoom; + window.localStorage.setItem("htmlZoom", zoom); + zoomTipDom.innerHTML = zoom; + zoomTipDom.style.display = 'block'; + zoomTipDom.classList.remove('ZoomTopTipAni'); + window.zoomSetTimeout = setTimeout(() => { + zoomTipDom.classList.add('ZoomTopTipAni'); + }, 2500); + } + function zoomDefault() { + const htmlZoom = window.localStorage.getItem("htmlZoom"); + if (htmlZoom) { + document.getElementsByTagName("html")[0].style.zoom = htmlZoom; + } + } + function zoomIn() { + zoom((htmlZoom) => `${Math.min(parseInt(htmlZoom) + 10, 200)}%`); + } + function zoomOut() { + zoom((htmlZoom) => `${Math.max(parseInt(htmlZoom) - 10, 30)}%`); + } + function zoom0() { + zoom(() => `100%`); + } + zoomDefault(); + window.__zoomIn = zoomIn; + window.__zoomOut = zoomOut; + window.__zoom0 = zoom0; } if ( diff --git a/src-tauri/tauri.conf.json b/src-tauri/tauri.conf.json index 970c87f..dd3cfd7 100644 --- a/src-tauri/tauri.conf.json +++ b/src-tauri/tauri.conf.json @@ -7,7 +7,7 @@ }, "package": { "productName": "ChatGPT", - "version": "0.10.0" + "version": "0.10.1" }, "tauri": { "allowlist": { diff --git a/src/components/SwitchOrigin/index.tsx b/src/components/SwitchOrigin/index.tsx index e9fd427..dd910a3 100644 --- a/src/components/SwitchOrigin/index.tsx +++ b/src/components/SwitchOrigin/index.tsx @@ -18,6 +18,11 @@ const SwitchOrigin: FC = ({ name }) => { const originName = `${name}_origin`; const isEnable = Form.useWatch(dashboardName, form); + let urlList = [{ title: 'ChatGPT', url: 'https://chat.openai.com', init: true }]; + if (Array.isArray(list)) { + urlList = urlList.concat(list); + } + return ( <> = ({ name }) => { name={originName} > diff --git a/src/view/about/index.scss b/src/view/about/index.scss index 408924f..2e2cfee 100644 --- a/src/view/about/index.scss +++ b/src/view/about/index.scss @@ -7,6 +7,10 @@ } } + .markdown-body { + background-color: unset; + } + .about-tab { .imgs { img { diff --git a/src/view/dashboard/index.tsx b/src/view/dashboard/index.tsx index 1b97d41..ef5a8a1 100644 --- a/src/view/dashboard/index.tsx +++ b/src/view/dashboard/index.tsx @@ -29,15 +29,19 @@ export default function Dashboard() { if (!json) return; const categories = new Map(); - json?.forEach((i) => { - if (!i.enable) return; - if (!categories.has(i.category)) { - categories.set(i.category, []); - } - categories.get(i?.category).push(i); - }); - setList(Array.from(categories)); - }, [json?.length]); + if (Array.isArray(json)) { + json?.forEach((i) => { + if (!i.enable) return; + if (!categories.has(i.category)) { + categories.set(i.category, []); + } + categories.get(i?.category).push(i); + }); + setList(Array.from(categories) || []); + } else { + setList([]); + } + }, [JSON.stringify(json)]); const handleLink = async (item: Record) => { await invoke('wa_window', {