fix: add devtools support and enhance development experience
This commit is contained in:
@@ -10,6 +10,8 @@
|
|||||||
],
|
],
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"tauri": "tauri",
|
"tauri": "tauri",
|
||||||
|
"tauri:dev": "tauri dev --features devtools",
|
||||||
|
"tauri:build": "tauri build",
|
||||||
"dev": "vite dev --host 127.0.0.1 --port 1421",
|
"dev": "vite dev --host 127.0.0.1 --port 1421",
|
||||||
"build": "vite build",
|
"build": "vite build",
|
||||||
"preview": "vite preview --host 127.0.0.1 --port 5051",
|
"preview": "vite preview --host 127.0.0.1 --port 5051",
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ function spawnProcess(command, args, opts = {}) {
|
|||||||
async function main() {
|
async function main() {
|
||||||
await startCli();
|
await startCli();
|
||||||
|
|
||||||
const tauriProcess = spawnProcess('pnpm', ['-C', desktopDir, 'tauri', 'dev']);
|
const tauriProcess = spawnProcess('pnpm', ['-C', desktopDir, 'tauri', 'dev', '--features', 'devtools']);
|
||||||
|
|
||||||
let cleaning = false;
|
let cleaning = false;
|
||||||
|
|
||||||
|
|||||||
@@ -12,6 +12,10 @@ path = "src/lib.rs"
|
|||||||
name = "openchamber-desktop"
|
name = "openchamber-desktop"
|
||||||
path = "src/main.rs"
|
path = "src/main.rs"
|
||||||
|
|
||||||
|
[features]
|
||||||
|
default = []
|
||||||
|
devtools = ["tauri/devtools"]
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
anyhow = "1.0.86"
|
anyhow = "1.0.86"
|
||||||
axum = { version = "0.8.4", features = ["macros"] }
|
axum = { version = "0.8.4", features = ["macros"] }
|
||||||
@@ -33,7 +37,7 @@ reqwest = { version = "0.12.4", default-features = false, features = ["json", "s
|
|||||||
serde = { version = "1.0.210", features = ["derive"] }
|
serde = { version = "1.0.210", features = ["derive"] }
|
||||||
serde_json = "1.0.143"
|
serde_json = "1.0.143"
|
||||||
serde_yaml = "0.9"
|
serde_yaml = "0.9"
|
||||||
tauri = { version = "2.9.4", features = ["macos-private-api", "devtools" ] }
|
tauri = { version = "2.9.4", features = ["macos-private-api"] }
|
||||||
tauri-plugin-dialog = "2.4.2"
|
tauri-plugin-dialog = "2.4.2"
|
||||||
tauri-plugin-fs = "2.4.4"
|
tauri-plugin-fs = "2.4.4"
|
||||||
tauri-plugin-log = "2.7.1"
|
tauri-plugin-log = "2.7.1"
|
||||||
|
|||||||
@@ -47,7 +47,9 @@ use portpicker::pick_unused_port;
|
|||||||
use reqwest::{header, Body as ReqwestBody, Client};
|
use reqwest::{header, Body as ReqwestBody, Client};
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use serde_json::Value;
|
use serde_json::Value;
|
||||||
use tauri::{Emitter, Manager, WebviewWindow};
|
use tauri::{Emitter, Manager};
|
||||||
|
#[cfg(feature = "devtools")]
|
||||||
|
use tauri::WebviewWindow;
|
||||||
use tauri_plugin_dialog::init as dialog_plugin;
|
use tauri_plugin_dialog::init as dialog_plugin;
|
||||||
use tauri_plugin_fs::init as fs_plugin;
|
use tauri_plugin_fs::init as fs_plugin;
|
||||||
use tauri_plugin_log::{Target, TargetKind};
|
use tauri_plugin_log::{Target, TargetKind};
|
||||||
@@ -212,6 +214,7 @@ async fn desktop_restart_opencode(state: tauri::State<'_, DesktopRuntime>) -> Re
|
|||||||
.map_err(|err| err.to_string())
|
.map_err(|err| err.to_string())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(feature = "devtools")]
|
||||||
#[tauri::command]
|
#[tauri::command]
|
||||||
async fn desktop_open_devtools(window: WebviewWindow) -> Result<(), String> {
|
async fn desktop_open_devtools(window: WebviewWindow) -> Result<(), String> {
|
||||||
window.open_devtools();
|
window.open_devtools();
|
||||||
@@ -309,6 +312,7 @@ fn main() {
|
|||||||
.invoke_handler(tauri::generate_handler![
|
.invoke_handler(tauri::generate_handler![
|
||||||
desktop_server_info,
|
desktop_server_info,
|
||||||
desktop_restart_opencode,
|
desktop_restart_opencode,
|
||||||
|
#[cfg(feature = "devtools")]
|
||||||
desktop_open_devtools,
|
desktop_open_devtools,
|
||||||
load_settings,
|
load_settings,
|
||||||
save_settings,
|
save_settings,
|
||||||
|
|||||||
@@ -22,6 +22,21 @@ if (!(window as typeof globalThis & { process?: unknown }).process) {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (import.meta.env.PROD) {
|
||||||
|
document.addEventListener('keydown', (e) => {
|
||||||
|
if ((e.metaKey || e.ctrlKey) && e.key === 'r') {
|
||||||
|
e.preventDefault();
|
||||||
|
}
|
||||||
|
if ((e.metaKey || e.ctrlKey) && e.shiftKey && e.key === 'r') {
|
||||||
|
e.preventDefault();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
document.addEventListener('contextmenu', (e) => {
|
||||||
|
e.preventDefault();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
declare global {
|
declare global {
|
||||||
interface Window {
|
interface Window {
|
||||||
__OPENCHAMBER_RUNTIME_APIS__?: RuntimeAPIs;
|
__OPENCHAMBER_RUNTIME_APIS__?: RuntimeAPIs;
|
||||||
|
|||||||
Reference in New Issue
Block a user