refactor: serve static frontend with Go APIs
This commit is contained in:
1 parent
763d2f0648
commit
b14b4fced7
101 files changed
+963
-3928
No files matched your search
@@ -1,11 +1,5 @@
|
||||
import { redirect } from "next/navigation";
|
||||
import { ClientRedirect } from "@/components/browser-auth";
|
||||
|
||||
export default async function AdminLoginPage({
|
||||
searchParams
|
||||
}: {
|
||||
searchParams?: Promise<Record<string, string | string[] | undefined>>;
|
||||
}) {
|
||||
const params = await searchParams;
|
||||
const next = Array.isArray(params?.next) ? params?.next[0] : params?.next;
|
||||
redirect(next ? `/auth/login?next=${encodeURIComponent(next)}` : "/auth/login");
|
||||
export default function AdminLoginPage() {
|
||||
return <ClientRedirect to="/auth/login" forwardNext />;
|
||||
}
|
||||
+2
-36
@@ -1,38 +1,4 @@
|
||||
import { redirect } from "next/navigation";
|
||||
import { AuthLoginPanel } from "@/components/auth-login-panel";
|
||||
import { getAuthRuntimeConfig, safeNextPath } from "@/lib/auth/config";
|
||||
import { getOptionalAuthSession } from "@/lib/server/auth/current-user";
|
||||
|
||||
const errorMessages: Record<string, string> = {
|
||||
auth_not_configured: "账号认证配置不完整,请联系管理员。",
|
||||
callback_failed: "登录失败,请重新登录。",
|
||||
state_invalid: "登录状态已失效,请重新登录。"
|
||||
};
|
||||
|
||||
export default async function LoginPage({
|
||||
searchParams
|
||||
}: {
|
||||
searchParams?: Promise<Record<string, string | string[] | undefined>>;
|
||||
}) {
|
||||
const params = await searchParams;
|
||||
const next = safeNextPath(singleParam(params?.next));
|
||||
const session = await getOptionalAuthSession();
|
||||
if (session) redirect(next);
|
||||
|
||||
const config = getAuthRuntimeConfig();
|
||||
const errorCode = singleParam(params?.error);
|
||||
const message = errorCode ? errorMessages[errorCode] || "登录失败,请重新登录。" : null;
|
||||
|
||||
return (
|
||||
<AuthLoginPanel
|
||||
next={next}
|
||||
configured={config.configured}
|
||||
message={message}
|
||||
missing={!config.configured && config.required ? config.missing : []}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
function singleParam(value: string | string[] | undefined): string | undefined {
|
||||
return Array.isArray(value) ? value[0] : value;
|
||||
export default function LoginPage() {
|
||||
return <AuthLoginPanel />;
|
||||
}
|
||||
Reference in new issue
Block a user