mirror of
https://github.com/Termix-SSH/Termix.git
synced 2026-07-15 04:43:36 +00:00
fix: show electron change server header for localserver
This commit is contained in:
@@ -1,7 +1,12 @@
|
|||||||
const fs = require("node:fs");
|
const fs = require("node:fs");
|
||||||
const path = require("node:path");
|
const path = require("node:path");
|
||||||
|
|
||||||
const betterSqlite3Dir = path.join(__dirname, "..", "node_modules", "better-sqlite3");
|
const betterSqlite3Dir = path.join(
|
||||||
|
__dirname,
|
||||||
|
"..",
|
||||||
|
"node_modules",
|
||||||
|
"better-sqlite3",
|
||||||
|
);
|
||||||
const macrosPath = path.join(betterSqlite3Dir, "src", "util", "macros.cpp");
|
const macrosPath = path.join(betterSqlite3Dir, "src", "util", "macros.cpp");
|
||||||
const helpersPath = path.join(betterSqlite3Dir, "src", "util", "helpers.cpp");
|
const helpersPath = path.join(betterSqlite3Dir, "src", "util", "helpers.cpp");
|
||||||
const entryPath = path.join(betterSqlite3Dir, "src", "better_sqlite3.cpp");
|
const entryPath = path.join(betterSqlite3Dir, "src", "better_sqlite3.cpp");
|
||||||
@@ -91,7 +96,11 @@ const entryPatched = patchFile(entryPath, [
|
|||||||
]);
|
]);
|
||||||
|
|
||||||
if (macrosPatched || helpersPatched || entryPatched) {
|
if (macrosPatched || helpersPatched || entryPatched) {
|
||||||
console.log("[patch-better-sqlite3] Applied compatibility patches for newer Electron/V8");
|
console.log(
|
||||||
|
"[patch-better-sqlite3] Applied compatibility patches for newer Electron/V8",
|
||||||
|
);
|
||||||
} else {
|
} else {
|
||||||
console.log("[patch-better-sqlite3] Already patched or target code not found");
|
console.log(
|
||||||
|
"[patch-better-sqlite3] Already patched or target code not found",
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
+12
-5
@@ -45,7 +45,12 @@ const nanHeaderPatched = patchFile(path.join(nanDir, "nan.h"), [
|
|||||||
|
|
||||||
// cpu-features binding.cc includes <node.h> before <nan.h>, so the nan.h patch
|
// cpu-features binding.cc includes <node.h> before <nan.h>, so the nan.h patch
|
||||||
// above is too late. Patch binding.cc directly to inject the compat define first.
|
// above is too late. Patch binding.cc directly to inject the compat define first.
|
||||||
const cpuFeaturesDir = path.join(__dirname, "..", "node_modules", "cpu-features");
|
const cpuFeaturesDir = path.join(
|
||||||
|
__dirname,
|
||||||
|
"..",
|
||||||
|
"node_modules",
|
||||||
|
"cpu-features",
|
||||||
|
);
|
||||||
const bindingPath = path.join(cpuFeaturesDir, "src", "binding.cc");
|
const bindingPath = path.join(cpuFeaturesDir, "src", "binding.cc");
|
||||||
const bindingPatched = patchFile(bindingPath, [
|
const bindingPatched = patchFile(bindingPath, [
|
||||||
{
|
{
|
||||||
@@ -70,11 +75,11 @@ if (fs.existsSync(implPath)) {
|
|||||||
if (!src.includes(TAG)) {
|
if (!src.includes(TAG)) {
|
||||||
src = src.replace(
|
src = src.replace(
|
||||||
/v8::External::New\(v8::Isolate::GetCurrent\(\),\s*value\)/g,
|
/v8::External::New\(v8::Isolate::GetCurrent\(\),\s*value\)/g,
|
||||||
`v8::External::New(v8::Isolate::GetCurrent(), value, ${TAG})`
|
`v8::External::New(v8::Isolate::GetCurrent(), value, ${TAG})`,
|
||||||
);
|
);
|
||||||
src = src.replace(
|
src = src.replace(
|
||||||
/v8::External::New\(isolate,\s*reinterpret_cast<void \*>\(callback\)\)/g,
|
/v8::External::New\(isolate,\s*reinterpret_cast<void \*>\(callback\)\)/g,
|
||||||
`v8::External::New(isolate, reinterpret_cast<void *>(callback), ${TAG})`
|
`v8::External::New(isolate, reinterpret_cast<void *>(callback), ${TAG})`,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -97,7 +102,7 @@ if (fs.existsSync(callbacksPath)) {
|
|||||||
// Pattern: .As<v8::External>()->Value()) — always followed by ))
|
// Pattern: .As<v8::External>()->Value()) — always followed by ))
|
||||||
src = src.replace(
|
src = src.replace(
|
||||||
/\.As<v8::External>\(\)->Value\(\)\)/g,
|
/\.As<v8::External>\(\)->Value\(\)\)/g,
|
||||||
`.As<v8::External>()->Value(${TAG}))`
|
`.As<v8::External>()->Value(${TAG}))`,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -108,7 +113,9 @@ if (fs.existsSync(callbacksPath)) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (nanHeaderPatched || bindingPatched || implPatched || callbacksPatched) {
|
if (nanHeaderPatched || bindingPatched || implPatched || callbacksPatched) {
|
||||||
console.log("[patch-nan] Applied compatibility patches for Electron 42 / V8 13+");
|
console.log(
|
||||||
|
"[patch-nan] Applied compatibility patches for Electron 42 / V8 13+",
|
||||||
|
);
|
||||||
} else {
|
} else {
|
||||||
console.log("[patch-nan] Already patched or target code not found");
|
console.log("[patch-nan] Already patched or target code not found");
|
||||||
}
|
}
|
||||||
|
|||||||
+32
-6
@@ -758,7 +758,7 @@ export function Auth({ onLogin }: AuthProps) {
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
if (currentServerUrl && !webviewAuthSuccess)
|
if (!webviewAuthSuccess && showServerConfig === false && currentServerUrl)
|
||||||
return (
|
return (
|
||||||
<div className="w-full h-screen flex items-center justify-center p-4 bg-background">
|
<div className="w-full h-screen flex items-center justify-center p-4 bg-background">
|
||||||
<div className="w-full max-w-4xl h-[90vh]">
|
<div className="w-full max-w-4xl h-[90vh]">
|
||||||
@@ -858,7 +858,23 @@ export function Auth({ onLogin }: AuthProps) {
|
|||||||
];
|
];
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="fixed inset-0 flex bg-background overflow-hidden">
|
<div className="fixed inset-0 flex flex-col bg-background overflow-hidden">
|
||||||
|
{isElectron() && !isInElectronWebView() && showServerConfig === false && (
|
||||||
|
<div className="flex items-center justify-between px-4 py-3 border-b border-border shrink-0">
|
||||||
|
<button
|
||||||
|
onClick={() => setShowServerConfig(true)}
|
||||||
|
className="flex items-center gap-2 text-sm text-muted-foreground hover:text-foreground transition-colors"
|
||||||
|
>
|
||||||
|
<ArrowLeft className="size-4" />
|
||||||
|
{t("serverConfig.changeServer")}
|
||||||
|
</button>
|
||||||
|
<span className="text-xs text-muted-foreground">
|
||||||
|
{t("serverConfig.localServer")}
|
||||||
|
</span>
|
||||||
|
<div className="w-20" />
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
<div className="flex flex-1 overflow-hidden">
|
||||||
{/* Left decorative panel */}
|
{/* Left decorative panel */}
|
||||||
<div className="hidden lg:flex flex-col w-[420px] shrink-0 bg-sidebar border-r border-border relative overflow-hidden select-none">
|
<div className="hidden lg:flex flex-col w-[420px] shrink-0 bg-sidebar border-r border-border relative overflow-hidden select-none">
|
||||||
<div
|
<div
|
||||||
@@ -887,7 +903,9 @@ export function Auth({ onLogin }: AuthProps) {
|
|||||||
{view === "totp" && (
|
{view === "totp" && (
|
||||||
<div className="flex flex-col gap-5">
|
<div className="flex flex-col gap-5">
|
||||||
<div className="flex flex-col gap-1">
|
<div className="flex flex-col gap-1">
|
||||||
<h1 className="text-xl font-bold">{t("auth.twoFactorAuth")}</h1>
|
<h1 className="text-xl font-bold">
|
||||||
|
{t("auth.twoFactorAuth")}
|
||||||
|
</h1>
|
||||||
<p className="text-xs text-muted-foreground">
|
<p className="text-xs text-muted-foreground">
|
||||||
{t("auth.enterCode")}
|
{t("auth.enterCode")}
|
||||||
</p>
|
</p>
|
||||||
@@ -1021,7 +1039,9 @@ export function Auth({ onLogin }: AuthProps) {
|
|||||||
className="w-full bg-accent-brand hover:bg-accent-brand/90 text-background font-bold"
|
className="w-full bg-accent-brand hover:bg-accent-brand/90 text-background font-bold"
|
||||||
disabled={loading || resetCode.length !== 6}
|
disabled={loading || resetCode.length !== 6}
|
||||||
>
|
>
|
||||||
{loading ? t("common.loading") : t("auth.verifyCodeButton")}
|
{loading
|
||||||
|
? t("common.loading")
|
||||||
|
: t("auth.verifyCodeButton")}
|
||||||
</Button>
|
</Button>
|
||||||
<Button
|
<Button
|
||||||
type="button"
|
type="button"
|
||||||
@@ -1073,7 +1093,9 @@ export function Auth({ onLogin }: AuthProps) {
|
|||||||
)}
|
)}
|
||||||
|
|
||||||
{/* Login / Register / External */}
|
{/* Login / Register / External */}
|
||||||
{(view === "login" || view === "register" || view === "external") && (
|
{(view === "login" ||
|
||||||
|
view === "register" ||
|
||||||
|
view === "external") && (
|
||||||
<div className="flex flex-col gap-5">
|
<div className="flex flex-col gap-5">
|
||||||
<div className="flex border border-border overflow-hidden">
|
<div className="flex border border-border overflow-hidden">
|
||||||
{TAB_ITEMS.filter((item) => item.show).map((item) => (
|
{TAB_ITEMS.filter((item) => item.show).map((item) => (
|
||||||
@@ -1206,7 +1228,10 @@ export function Auth({ onLogin }: AuthProps) {
|
|||||||
)}
|
)}
|
||||||
|
|
||||||
{view === "register" && (
|
{view === "register" && (
|
||||||
<form onSubmit={handleRegister} className="flex flex-col gap-4">
|
<form
|
||||||
|
onSubmit={handleRegister}
|
||||||
|
className="flex flex-col gap-4"
|
||||||
|
>
|
||||||
<Field label={t("common.username")} htmlFor="reg-user">
|
<Field label={t("common.username")} htmlFor="reg-user">
|
||||||
<div className="relative">
|
<div className="relative">
|
||||||
<User className="absolute left-2.5 top-1/2 -translate-y-1/2 size-4 text-muted-foreground pointer-events-none" />
|
<User className="absolute left-2.5 top-1/2 -translate-y-1/2 size-4 text-muted-foreground pointer-events-none" />
|
||||||
@@ -1308,5 +1333,6 @@ export function Auth({ onLogin }: AuthProps) {
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user