Skip to content

Commit

Permalink
feat: 绑定 WebView Console
Browse files Browse the repository at this point in the history
  • Loading branch information
mslxl committed Nov 26, 2023
1 parent 77aed40 commit 09cd8ec
Show file tree
Hide file tree
Showing 8 changed files with 99 additions and 31 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@
"styled-components": "^6.1.1",
"tailwind-merge": "^2.0.0",
"tailwindcss-animate": "^1.0.7",
"tauri-plugin-log-api": "github:tauri-apps/tauri-plugin-log#v1",
"vscode-languageserver-protocol": "^3.17.5",
"zod": "^3.22.4"
},
Expand Down
11 changes: 11 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

59 changes: 59 additions & 0 deletions src-tauri/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 8 additions & 1 deletion src-tauri/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,13 @@ edition = "2021"
tauri-build = { version = "1.5", features = [] }

[dependencies]
tauri = { version = "1.5", features = [ "path-all", "dialog-all", "fs-all", "shell-open", "devtools"] }
tauri = { version = "1.5", features = [
"path-all",
"dialog-all",
"fs-all",
"shell-open",
"devtools",
] }
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"
uuid = "1.5.0"
Expand All @@ -29,6 +35,7 @@ rand = "0.8.5"
sha256 = "1.4.0"
once_cell = "1.18.0"
fancy-regex = "0.12.0"
tauri-plugin-log = { git = "https://github.com/tauri-apps/plugins-workspace", branch = "v1" }

[features]
# this feature is used for production builds or when `devPath` points to the filesystem
Expand Down
10 changes: 7 additions & 3 deletions src-tauri/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,20 @@ use ipc::{
rt::{compiler::CompilerState, runner::RunnerState, checker::CheckerState},
};
use tauri::Manager;
use util::logger::SimpleLogger;
use tauri_plugin_log::{LogTarget};


pub mod ipc;
pub mod util;

static LOGGER: SimpleLogger = SimpleLogger;
fn main() {
let _ = log::set_logger(&LOGGER).map(|()| log::set_max_level(log::LevelFilter::Info));

tauri::Builder::default()
.plugin(tauri_plugin_log::Builder::default().targets([
LogTarget::LogDir,
LogTarget::Stdout,
LogTarget::Webview,
]).build())
.setup(|app| {
app.manage(LSPState::default());
app.manage(CompetitiveCompanionState::default());
Expand Down
16 changes: 0 additions & 16 deletions src-tauri/src/util/logger.rs

This file was deleted.

1 change: 0 additions & 1 deletion src-tauri/src/util/mod.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
pub mod console;
pub mod error;
pub mod keylock;
pub mod logger;
23 changes: 13 additions & 10 deletions src/main.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,18 @@ import "./styles.css"
import Router from "./router"
import { DndProvider } from "react-dnd"
import { HTML5Backend } from "react-dnd-html5-backend"
import {DevTools} from 'jotai-devtools'
import { DevTools } from "jotai-devtools"
import { attachConsole } from "tauri-plugin-log-api"

document.oncontextmenu = (event) => event.preventDefault();
document.oncontextmenu = (event) => event.preventDefault()

ReactDOM.createRoot(document.getElementById("root") as HTMLElement).render(
<React.StrictMode>
<DndProvider backend={HTML5Backend}>
<Router />
</DndProvider>
<DevTools/>
</React.StrictMode>,
)
attachConsole().then(() => {
ReactDOM.createRoot(document.getElementById("root") as HTMLElement).render(
<React.StrictMode>
<DndProvider backend={HTML5Backend}>
<Router />
</DndProvider>
<DevTools />
</React.StrictMode>,
)
})

0 comments on commit 09cd8ec

Please sign in to comment.