fix(csms): fix lint errors, clean up imports and improve code formatting
This commit is contained in:
@@ -4,7 +4,7 @@ const CSMS_INTERNAL_URL =
|
||||
process.env.CSMS_INTERNAL_URL ?? process.env.NEXT_PUBLIC_CSMS_URL ?? "http://localhost:3001";
|
||||
|
||||
/** 检查 CSMS 是否已完成初始化(有用户存在)。 */
|
||||
async function isInitialized(request: NextRequest): Promise<boolean> {
|
||||
async function isInitialized(): Promise<boolean> {
|
||||
try {
|
||||
const res = await fetch(`${CSMS_INTERNAL_URL}/api/setup`, {
|
||||
method: "GET",
|
||||
@@ -25,7 +25,7 @@ export async function proxy(request: NextRequest) {
|
||||
|
||||
// /setup 页面:已初始化则跳转登录
|
||||
if (pathname === "/setup") {
|
||||
if (await isInitialized(request)) {
|
||||
if (await isInitialized()) {
|
||||
return NextResponse.redirect(new URL("/login", request.url));
|
||||
}
|
||||
return NextResponse.next();
|
||||
@@ -33,7 +33,7 @@ export async function proxy(request: NextRequest) {
|
||||
|
||||
// /dashboard 路由:检查 session,未登录跳转 /login
|
||||
if (pathname.startsWith("/dashboard")) {
|
||||
if (!(await isInitialized(request))) {
|
||||
if (!(await isInitialized())) {
|
||||
return NextResponse.redirect(new URL("/setup", request.url));
|
||||
}
|
||||
|
||||
@@ -53,7 +53,7 @@ export async function proxy(request: NextRequest) {
|
||||
|
||||
// /login 路由:未初始化则跳转 /setup
|
||||
if (pathname === "/login") {
|
||||
if (!(await isInitialized(request))) {
|
||||
if (!(await isInitialized())) {
|
||||
return NextResponse.redirect(new URL("/setup", request.url));
|
||||
}
|
||||
return NextResponse.next();
|
||||
|
||||
Reference in New Issue
Block a user