From dd51ffbf1d2b86d9c8d6df25aa6449e07b879198 Mon Sep 17 00:00:00 2001 From: lencx Date: Wed, 7 Dec 2022 22:04:12 +0800 Subject: [PATCH] v0.1.3 --- UPDATE_LOG.md | 8 ++++++-- src-tauri/src/core.js | 28 +++++++++++++++++++--------- src-tauri/tauri.conf.json | 2 +- 3 files changed, 26 insertions(+), 12 deletions(-) diff --git a/UPDATE_LOG.md b/UPDATE_LOG.md index a57fa9e..3e06358 100644 --- a/UPDATE_LOG.md +++ b/UPDATE_LOG.md @@ -1,12 +1,16 @@ # UPDATE LOG +## v0.1.3 + +fix: only mac supports `TitleBarStyle` + ## v0.1.2 -- initialization +initialization ## v0.1.1 -- initialization +initialization ## v0.1.0 diff --git a/src-tauri/src/core.js b/src-tauri/src/core.js index 4d65e28..1aff7ee 100644 --- a/src-tauri/src/core.js +++ b/src-tauri/src/core.js @@ -36,16 +36,26 @@ document.addEventListener('DOMContentLoaded', async () => { }); } - 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); + async function platform() { + return invoke('platform', { + __tauriModule: 'Os', + message: { cmd: 'platform' } + }); + } - topDom.addEventListener("mousedown", () => invoke("drag_window")); - topDom.addEventListener("touchstart", () => invoke("drag_window")); - topDom.addEventListener("dblclick", () => invoke("fullscreen")); + const _platform = await platform(); + if (/darwin/.test(_platform)) { + 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); + + topDom.addEventListener("mousedown", () => invoke("drag_window")); + topDom.addEventListener("touchstart", () => invoke("drag_window")); + topDom.addEventListener("dblclick", () => invoke("fullscreen")); + } document.addEventListener("click", (e) => { const origin = e.target.closest("a"); diff --git a/src-tauri/tauri.conf.json b/src-tauri/tauri.conf.json index e189d7b..dd7adbd 100644 --- a/src-tauri/tauri.conf.json +++ b/src-tauri/tauri.conf.json @@ -7,7 +7,7 @@ }, "package": { "productName": "ChatGPT", - "version": "0.1.2" + "version": "0.1.3" }, "tauri": { "allowlist": {