diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 653ec69..a598742 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -28,7 +28,7 @@ jobs: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} with: tag_name: '${{ steps.get_version.outputs.VERSION }}' - release_name: 'WA+ ${{ steps.get_version.outputs.VERSION }}' + release_name: 'ChatGPT ${{ steps.get_version.outputs.VERSION }}' body: 'See the assets to download this version and install.' build-tauri: diff --git a/.gitignore b/.gitignore index fe07b46..20036f9 100644 --- a/.gitignore +++ b/.gitignore @@ -1,7 +1,9 @@ .DS_Store +*.lock +package-lock.json node_modules/ -target/ +yarn.lock +target/ Cargo.lock -yarn.lock \ No newline at end of file diff --git a/README.md b/README.md index aaa695a..ffacf50 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,23 @@ -# ChatGPT -ChatGPT Desktop Application +

+ ChatGPT +

ChatGPT

+

+ +> ChatGPT Desktop Application + +## Features + +- multi-platform: `macOS` `Linux` `Windows` +- inject script +- auto updater +- hotkey + +## Preview + +install +chat + +## TODO + +- [ ] export chat history +- [ ] ... diff --git a/UPDATE_LOG.md b/UPDATE_LOG.md new file mode 100644 index 0000000..4cad83c --- /dev/null +++ b/UPDATE_LOG.md @@ -0,0 +1,5 @@ +# UPDATE LOG + +## v0.1.0 + +initialization diff --git a/assets/chat.png b/assets/chat.png new file mode 100644 index 0000000..f9c5254 Binary files /dev/null and b/assets/chat.png differ diff --git a/assets/install.png b/assets/install.png new file mode 100644 index 0000000..5fdc7b5 Binary files /dev/null and b/assets/install.png differ diff --git a/package.json b/package.json index c9df345..8958cbf 100644 --- a/package.json +++ b/package.json @@ -1,8 +1,6 @@ { "name": "chatgpt", - "private": true, "version": "0.0.0", - "type": "module", "scripts": { "dev": "yarn tauri dev", "build": "yarn tauri build", @@ -11,8 +9,17 @@ "tr": "tr", "tauri": "tauri" }, + "license": "MIT", + "author": "lencx ", + "keywords": ["chatgpt", "app", "desktop", "tauri", "macos", "linux", "windows"], + "homepage": "https://github.com/lencx/ChatGPT", + "bugs": "https://github.com/lencx/ChatGPT/issues", + "repository": { + "type": "git", + "url": "https://github.com/lencx/ChatGPT" + }, "devDependencies": { "@tauri-apps/cli": "^1.2.1", - "@tauri-release/cli": "^0.2.0" + "@tauri-release/cli": "^0.2.1" } } diff --git a/src-tauri/Cargo.toml b/src-tauri/Cargo.toml index 1992f09..9ab48c8 100644 --- a/src-tauri/Cargo.toml +++ b/src-tauri/Cargo.toml @@ -11,12 +11,12 @@ rust-version = "1.57" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [build-dependencies] -tauri-build = {version = "1.2", features = [] } +tauri-build = {version = "1.2.1", features = [] } [dependencies] serde_json = "1.0" serde = { version = "1.0", features = ["derive"] } -tauri = {version = "1.2", features = ["api-all", "system-tray"] } +tauri = { version = "1.2.1", features = ["api-all", "devtools", "system-tray", "updater"] } anyhow = "1.0.66" [features] diff --git a/src-tauri/src/core.js b/src-tauri/src/core.js index ef68c96..4d65e28 100644 --- a/src-tauri/src/core.js +++ b/src-tauri/src/core.js @@ -1,5 +1,41 @@ // *** Core Script *** document.addEventListener('DOMContentLoaded', async () => { + const uid = () => window.crypto.getRandomValues(new Uint32Array(1))[0]; + function transformCallback(callback = () => {}, once = false) { + const identifier = uid(); + const prop = `_${identifier}`; + Object.defineProperty(window, prop, { + value: (result) => { + if (once) { + Reflect.deleteProperty(window, prop); + } + return callback(result) + }, + writable: false, + configurable: true, + }) + return identifier; + } + async function invoke(cmd, args) { + return new Promise((resolve, reject) => { + if (!window.__TAURI_POST_MESSAGE__) reject('__TAURI_POST_MESSAGE__ does not exist!'); + const callback = transformCallback((e) => { + resolve(e); + Reflect.deleteProperty(window, `_${error}`); + }, true) + const error = transformCallback((e) => { + reject(e); + Reflect.deleteProperty(window, `_${callback}`); + }, true) + window.__TAURI_POST_MESSAGE__({ + cmd, + callback, + error, + ...args + }); + }); + } + 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); @@ -7,9 +43,9 @@ document.addEventListener('DOMContentLoaded', async () => { topDom.id = "chatgpt-app-window-top"; document.body.appendChild(topDom); - topDom.addEventListener("mousedown", () => __TAURI_INVOKE__("drag_window")); - topDom.addEventListener("touchstart", () => __TAURI_INVOKE__("drag_window")); - topDom.addEventListener("dblclick", () => __TAURI_INVOKE__("fullscreen")); + 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/src/main.rs b/src-tauri/src/main.rs index f8dd9ca..349b234 100644 --- a/src-tauri/src/main.rs +++ b/src-tauri/src/main.rs @@ -13,7 +13,7 @@ fn main() { let context = tauri::generate_context!(); tauri::Builder::default() - .invoke_handler(tauri::generate_handler![cmd::drag_window, cmd::fullscreen,]) + .invoke_handler(tauri::generate_handler![cmd::drag_window, cmd::fullscreen]) .setup(setup::init) .menu(menu::init(&context)) .system_tray(SystemTray::new()) diff --git a/src-tauri/src/utils.rs b/src-tauri/src/utils.rs index 3fab710..cdbe2f4 100644 --- a/src-tauri/src/utils.rs +++ b/src-tauri/src/utils.rs @@ -10,18 +10,6 @@ pub fn get_tauri_conf() -> Option { Some(config) } -#[derive(serde::Serialize, serde::Deserialize, Debug)] -pub struct WaJson { - pub url: String, - pub resizable: bool, - pub theme: tauri::Theme, - pub mode: String, - pub title: String, - pub always_on_top: bool, - pub hidden_title: bool, - pub hide_title_bar: bool, -} - pub fn exists(path: &Path) -> bool { Path::new(path).exists() } diff --git a/src-tauri/tauri.conf.json b/src-tauri/tauri.conf.json index baa7127..f996d84 100644 --- a/src-tauri/tauri.conf.json +++ b/src-tauri/tauri.conf.json @@ -7,7 +7,7 @@ }, "package": { "productName": "ChatGPT", - "version": "../package.json" + "version": "0.0.0" }, "tauri": { "allowlist": { @@ -19,7 +19,7 @@ }, "bundle": { "active": true, - "category": "ChatGPT", + "category": "DeveloperTool", "copyright": "", "deb": { "depends": [] diff --git a/src-tauri/wa.json b/src-tauri/wa.json deleted file mode 100644 index 2bb4742..0000000 --- a/src-tauri/wa.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "url": "https://weread.qq.com", - "resizable": true, - "theme": "Light", - "mode": "PC", - "title": "WA", - "always_on_top": false, - "hidden_title": true, - "hide_title_bar": true -} \ No newline at end of file