mirror of
https://github.com/FranP-code/ChatGPT.git
synced 2025-10-13 00:13:25 +00:00
chore: build
This commit is contained in:
@@ -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]
|
||||
|
||||
@@ -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");
|
||||
|
||||
@@ -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())
|
||||
|
||||
@@ -10,18 +10,6 @@ pub fn get_tauri_conf() -> Option<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 {
|
||||
Path::new(path).exists()
|
||||
}
|
||||
|
||||
@@ -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": []
|
||||
|
||||
@@ -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
|
||||
}
|
||||
Reference in New Issue
Block a user