chore: build

This commit is contained in:
lencx
2022-12-07 20:02:31 +08:00
parent 6fe765dafa
commit 65442f4489
13 changed files with 87 additions and 38 deletions

View File

@@ -28,7 +28,7 @@ jobs:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with: with:
tag_name: '${{ steps.get_version.outputs.VERSION }}' 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.' body: 'See the assets to download this version and install.'
build-tauri: build-tauri:

6
.gitignore vendored
View File

@@ -1,7 +1,9 @@
.DS_Store .DS_Store
*.lock
package-lock.json
node_modules/ node_modules/
target/ yarn.lock
target/
Cargo.lock Cargo.lock
yarn.lock

View File

@@ -1,2 +1,23 @@
# ChatGPT <p align="center">
ChatGPT Desktop Application <img width="180" src="./logo.png" alt="ChatGPT">
<h1 align="center">ChatGPT</h1>
</p>
> ChatGPT Desktop Application
## Features
- multi-platform: `macOS` `Linux` `Windows`
- inject script
- auto updater
- hotkey
## Preview
<img width="600" src="./assets/install.png" alt="install">
<img width="600" src="./assets/chat.png" alt="chat">
## TODO
- [ ] export chat history
- [ ] ...

5
UPDATE_LOG.md Normal file
View File

@@ -0,0 +1,5 @@
# UPDATE LOG
## v0.1.0
initialization

BIN
assets/chat.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 754 KiB

BIN
assets/install.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 218 KiB

View File

@@ -1,8 +1,6 @@
{ {
"name": "chatgpt", "name": "chatgpt",
"private": true,
"version": "0.0.0", "version": "0.0.0",
"type": "module",
"scripts": { "scripts": {
"dev": "yarn tauri dev", "dev": "yarn tauri dev",
"build": "yarn tauri build", "build": "yarn tauri build",
@@ -11,8 +9,17 @@
"tr": "tr", "tr": "tr",
"tauri": "tauri" "tauri": "tauri"
}, },
"license": "MIT",
"author": "lencx <cxin1314@gmail.com>",
"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": { "devDependencies": {
"@tauri-apps/cli": "^1.2.1", "@tauri-apps/cli": "^1.2.1",
"@tauri-release/cli": "^0.2.0" "@tauri-release/cli": "^0.2.1"
} }
} }

View File

@@ -11,12 +11,12 @@ rust-version = "1.57"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[build-dependencies] [build-dependencies]
tauri-build = {version = "1.2", features = [] } tauri-build = {version = "1.2.1", features = [] }
[dependencies] [dependencies]
serde_json = "1.0" serde_json = "1.0"
serde = { version = "1.0", features = ["derive"] } 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" anyhow = "1.0.66"
[features] [features]

View File

@@ -1,5 +1,41 @@
// *** Core Script *** // *** Core Script ***
document.addEventListener('DOMContentLoaded', async () => { 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"); 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;}`; 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); document.head.appendChild(topStyleDom);
@@ -7,9 +43,9 @@ document.addEventListener('DOMContentLoaded', async () => {
topDom.id = "chatgpt-app-window-top"; topDom.id = "chatgpt-app-window-top";
document.body.appendChild(topDom); document.body.appendChild(topDom);
topDom.addEventListener("mousedown", () => __TAURI_INVOKE__("drag_window")); topDom.addEventListener("mousedown", () => invoke("drag_window"));
topDom.addEventListener("touchstart", () => __TAURI_INVOKE__("drag_window")); topDom.addEventListener("touchstart", () => invoke("drag_window"));
topDom.addEventListener("dblclick", () => __TAURI_INVOKE__("fullscreen")); topDom.addEventListener("dblclick", () => invoke("fullscreen"));
document.addEventListener("click", (e) => { document.addEventListener("click", (e) => {
const origin = e.target.closest("a"); const origin = e.target.closest("a");

View File

@@ -13,7 +13,7 @@ fn main() {
let context = tauri::generate_context!(); let context = tauri::generate_context!();
tauri::Builder::default() 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) .setup(setup::init)
.menu(menu::init(&context)) .menu(menu::init(&context))
.system_tray(SystemTray::new()) .system_tray(SystemTray::new())

View File

@@ -10,18 +10,6 @@ pub fn get_tauri_conf() -> Option<Config> {
Some(config) 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 { pub fn exists(path: &Path) -> bool {
Path::new(path).exists() Path::new(path).exists()
} }

View File

@@ -7,7 +7,7 @@
}, },
"package": { "package": {
"productName": "ChatGPT", "productName": "ChatGPT",
"version": "../package.json" "version": "0.0.0"
}, },
"tauri": { "tauri": {
"allowlist": { "allowlist": {
@@ -19,7 +19,7 @@
}, },
"bundle": { "bundle": {
"active": true, "active": true,
"category": "ChatGPT", "category": "DeveloperTool",
"copyright": "", "copyright": "",
"deb": { "deb": {
"depends": [] "depends": []

View File

@@ -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
}