fix(dx): merge script and fix host rewrite
Signed-off-by: Innei <tukon479@gmail.com>
This commit is contained in:
parent
a60db7eda6
commit
3fa3bd5fc5
|
|
@ -1,39 +1,6 @@
|
|||
<!doctype html>
|
||||
<html>
|
||||
<head>
|
||||
<script type="module">
|
||||
const searchParams = new URLSearchParams(window.location.search)
|
||||
const debugHost = searchParams.get("debug-host")
|
||||
|
||||
const resetSessionStorage = () => {
|
||||
sessionStorage.removeItem("debug-host")
|
||||
}
|
||||
|
||||
const resetParams = searchParams.delete("debug-host")
|
||||
if (resetParams) {
|
||||
resetSessionStorage()
|
||||
}
|
||||
|
||||
const debugHostInSessionStorage = sessionStorage.getItem("debug-host")
|
||||
|
||||
const host = debugHost || debugHostInSessionStorage || "https://localhost:2233"
|
||||
if (debugHost) {
|
||||
sessionStorage.setItem("debug-host", debugHost)
|
||||
}
|
||||
|
||||
const createRefreshRuntimeScript = `
|
||||
import RefreshRuntime from "${host}/@react-refresh";
|
||||
RefreshRuntime.injectIntoGlobalHook(window);
|
||||
window.$RefreshReg$ = () => {};
|
||||
window.$RefreshSig$ = () => (type) => type;
|
||||
window.__vite_plugin_react_preamble_installed__ = true;
|
||||
`
|
||||
const $script = document.createElement("script")
|
||||
$script.innerHTML = createRefreshRuntimeScript
|
||||
$script.type = "module"
|
||||
document.head.appendChild($script)
|
||||
</script>
|
||||
|
||||
<title>Debug Proxy</title>
|
||||
<script type="module" src="./__debug_proxy.ts"></script>
|
||||
</head>
|
||||
|
|
|
|||
|
|
@ -1,7 +1,36 @@
|
|||
const host = "https://localhost:2233"
|
||||
|
||||
globalThis["__DEBUG_PROXY__"] = true
|
||||
|
||||
const searchParams = new URLSearchParams(window.location.search)
|
||||
const debugHost = searchParams.get("debug-host")
|
||||
|
||||
const resetSessionStorage = () => {
|
||||
sessionStorage.removeItem("debug-host")
|
||||
}
|
||||
|
||||
const resetParams = searchParams.get("reset")
|
||||
if (resetParams) {
|
||||
resetSessionStorage()
|
||||
}
|
||||
|
||||
const debugHostInSessionStorage = sessionStorage.getItem("debug-host")
|
||||
|
||||
const host = debugHost || debugHostInSessionStorage || "https://localhost:2233"
|
||||
if (debugHost) {
|
||||
sessionStorage.setItem("debug-host", debugHost)
|
||||
}
|
||||
|
||||
const createRefreshRuntimeScript = `
|
||||
import RefreshRuntime from "${host}/@react-refresh";
|
||||
RefreshRuntime.injectIntoGlobalHook(window);
|
||||
window.$RefreshReg$ = () => {};
|
||||
window.$RefreshSig$ = () => (type) => type;
|
||||
window.__vite_plugin_react_preamble_installed__ = true;
|
||||
`
|
||||
const $script = document.createElement("script")
|
||||
$script.innerHTML = createRefreshRuntimeScript
|
||||
$script.type = "module"
|
||||
document.head.append($script)
|
||||
|
||||
fetch(`${host}`)
|
||||
.then((res) => res.text())
|
||||
.then((html) => {
|
||||
|
|
|
|||
Loading…
Reference in New Issue