File size: 741 Bytes
676fc08 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
"use client";
import Script from "next/script";
import { useLayoutEffect } from "react";
import { useSettingStore } from "@/store/setting";
declare global {
interface Window {
eruda: any;
}
}
function Debugger() {
const { debug } = useSettingStore();
function setup() {
window.eruda.init({
tool: ["console", "network", "info"],
});
}
useLayoutEffect(() => {
const eruda = window.eruda;
if (eruda) {
if (debug === "disable") {
eruda.destroy();
} else {
setup();
}
}
}, [debug]);
return debug === "enable" ? (
<Script
id="eruda"
src="./scripts/eruda.min.js"
onLoad={() => setup()}
></Script>
) : null;
}
export default Debugger;
|