's'
This commit is contained in:
@@ -9,9 +9,8 @@ import { IS_DEVELOPMENT } from "../runtime-env";
|
||||
import {
|
||||
resolvePaymentApiUrl,
|
||||
DEFAULT_POCKETBASE_URL,
|
||||
DEFAULT_MINIO_HOST,
|
||||
DEFAULT_MINIO_PUBLIC_HOST,
|
||||
} from "./domain.config";
|
||||
import { resolveMinioConnection, resolvePocketBaseUrl } from "../remote-services";
|
||||
|
||||
export interface PocketBaseConfig {
|
||||
enabled: boolean;
|
||||
@@ -88,7 +87,7 @@ export function getPocketBaseConfig(themeOverride?: { joinCollection?: string })
|
||||
"solan";
|
||||
return {
|
||||
enabled: true,
|
||||
url: process.env.NEXT_PUBLIC_POCKETBASE_URL || process.env.POCKETBASE_URL || DEFAULT_POCKETBASE_URL,
|
||||
url: resolvePocketBaseUrl() || DEFAULT_POCKETBASE_URL,
|
||||
usersCollection: "users",
|
||||
joinCollection,
|
||||
};
|
||||
@@ -113,25 +112,20 @@ export function getPaymentConfig(themeOverride?: { amount?: number; type?: strin
|
||||
|
||||
/** 获取 MinIO 配置(可传入主题覆盖 bucket/prefix) */
|
||||
export function getMinioConfig(themeOverride?: { bucket?: string; uploadPrefix?: string }): MinioConfig {
|
||||
const endPoint = process.env.MINIO_ENDPOINT || DEFAULT_MINIO_HOST;
|
||||
const port = parseInt(process.env.MINIO_PORT || "9100", 10);
|
||||
const useSSL = process.env.MINIO_USE_SSL === "true";
|
||||
const bucket = themeOverride?.bucket || process.env.MINIO_BUCKET || "hackrobot";
|
||||
const publicUrl =
|
||||
process.env.MINIO_PUBLIC_URL ||
|
||||
`https://${DEFAULT_MINIO_PUBLIC_HOST}/${bucket}`;
|
||||
const conn = resolveMinioConnection({ bucket });
|
||||
const uploadPrefix = themeOverride?.uploadPrefix || process.env.MINIO_UPLOAD_PREFIX || "joins";
|
||||
|
||||
return {
|
||||
enabled: true,
|
||||
endPoint,
|
||||
port,
|
||||
useSSL,
|
||||
bucket,
|
||||
endPoint: conn.endPoint,
|
||||
port: conn.port,
|
||||
useSSL: conn.useSSL,
|
||||
bucket: conn.bucket,
|
||||
accessKey: process.env.MINIO_ACCESS_KEY || "nomadro",
|
||||
secretKey: process.env.MINIO_SECRET_KEY || "Xiao4669805@",
|
||||
region: process.env.MINIO_REGION || "china",
|
||||
publicUrl: publicUrl.replace(/\/$/, ""),
|
||||
publicUrl: conn.publicUrl,
|
||||
uploadPrefix,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -3,13 +3,14 @@
|
||||
*/
|
||||
|
||||
export interface NavLink {
|
||||
labelKey: "cities" | "dashboard" | "travel" | "community" | "tools" | "ai" | "gigs" | "pricing" | "explore";
|
||||
labelKey: "cities" | "guide" | "dashboard" | "travel" | "community" | "tools" | "ai" | "gigs" | "pricing" | "explore";
|
||||
icon: string;
|
||||
href: string;
|
||||
}
|
||||
|
||||
export const NAV_LINKS: NavLink[] = [
|
||||
{ labelKey: "cities", icon: "🏙️", href: "/" },
|
||||
{ labelKey: "guide", icon: "🧭", href: "/digital" },
|
||||
{ labelKey: "dashboard", icon: "📍", href: "/dashboard" },
|
||||
{ labelKey: "travel", icon: "✈️", href: "/meetups" },
|
||||
{ labelKey: "community", icon: "💬", href: "/dating" },
|
||||
|
||||
95
config/remote-services.ts
Normal file
95
config/remote-services.ts
Normal file
@@ -0,0 +1,95 @@
|
||||
/**
|
||||
* Windows 本地开发时,如何连接 Linux 线上服务。
|
||||
*
|
||||
* 线上服务器(82.157.112.245 / nomadro.cn)架构:
|
||||
* - PocketBase:公网 https://pocketbase.nomadro.cn → 内网 127.0.0.1:8090
|
||||
* - FastAPI:公网 http://api.nomadro.cn → 内网 127.0.0.1:8000
|
||||
* - MinIO S3 API:仅内网 127.0.0.1:9100;公网 https://minio.nomadro.cn/hackrobot/ 只代理读路径
|
||||
* - MinIO 公开文件 URL:https://minio.nomadro.cn/hackrobot/{key}
|
||||
*
|
||||
* Windows 本地推荐:
|
||||
* 1. 跑本地 Next.js + FastAPI
|
||||
* 2. POCKETBASE_URL 用 https://pocketbase.nomadro.cn
|
||||
* 3. MinIO 用 scripts/dev-tunnel.py 把本地 9100 隧道到服务器 9100
|
||||
*/
|
||||
|
||||
import { IS_DEVELOPMENT } from "./runtime-env";
|
||||
|
||||
export const REMOTE_ROOT_DOMAIN =
|
||||
process.env.ROOT_DOMAIN || process.env.NEXT_PUBLIC_ROOT_DOMAIN || "nomadro.cn";
|
||||
|
||||
export const REMOTE_SERVICE_URLS = {
|
||||
pocketbase: `https://pocketbase.${REMOTE_ROOT_DOMAIN}`,
|
||||
api: `http://api.${REMOTE_ROOT_DOMAIN}`,
|
||||
minioPublic: `https://minio.${REMOTE_ROOT_DOMAIN}/hackrobot`,
|
||||
site: `https://${REMOTE_ROOT_DOMAIN}`,
|
||||
mirotalk: `https://mirotalk.${REMOTE_ROOT_DOMAIN}`,
|
||||
lounge: `https://lounge.${REMOTE_ROOT_DOMAIN}`,
|
||||
} as const;
|
||||
|
||||
/** 当前是否为「本地前端 + 远程服务」开发模式 */
|
||||
export function isRemoteDevMode(): boolean {
|
||||
if (!IS_DEVELOPMENT) return false;
|
||||
const pb = (process.env.POCKETBASE_URL || "").trim();
|
||||
const minio = (process.env.MINIO_ENDPOINT || "").trim();
|
||||
return (
|
||||
pb.includes("nomadro.cn") ||
|
||||
pb.includes("pocketbase.") ||
|
||||
minio === "127.0.0.1" ||
|
||||
minio.includes("nomadro.cn")
|
||||
);
|
||||
}
|
||||
|
||||
export function resolvePocketBaseUrl(): string {
|
||||
return (
|
||||
process.env.POCKETBASE_URL ||
|
||||
process.env.NEXT_PUBLIC_POCKETBASE_URL ||
|
||||
REMOTE_SERVICE_URLS.pocketbase
|
||||
).replace(/\/$/, "");
|
||||
}
|
||||
|
||||
export function resolveMinioEndpoint(): {
|
||||
endPoint: string;
|
||||
port: number;
|
||||
useSSL: boolean;
|
||||
} {
|
||||
const host = (process.env.MINIO_ENDPOINT || "127.0.0.1").replace(/^https?:\/\//, "");
|
||||
const isLocalHost = host === "127.0.0.1" || host === "localhost";
|
||||
const isDomain = host.includes(".");
|
||||
|
||||
if (isDomain && !isLocalHost) {
|
||||
return {
|
||||
endPoint: host,
|
||||
port: Number(process.env.MINIO_PORT || "443"),
|
||||
useSSL: process.env.MINIO_USE_SSL !== "false",
|
||||
};
|
||||
}
|
||||
|
||||
return {
|
||||
endPoint: host,
|
||||
port: Number(process.env.MINIO_PORT || "9100"),
|
||||
useSSL: process.env.MINIO_USE_SSL === "true",
|
||||
};
|
||||
}
|
||||
|
||||
export function resolveMinioConnection(options?: { bucket?: string }): {
|
||||
endPoint: string;
|
||||
port: number;
|
||||
useSSL: boolean;
|
||||
bucket: string;
|
||||
publicUrl: string;
|
||||
} {
|
||||
const bucket = options?.bucket || process.env.MINIO_BUCKET || "hackrobot";
|
||||
const conn = resolveMinioEndpoint();
|
||||
const publicUrl = (
|
||||
process.env.MINIO_PUBLIC_URL ||
|
||||
process.env.NEXT_PUBLIC_MINIO_PUBLIC_URL ||
|
||||
`${REMOTE_SERVICE_URLS.minioPublic}`
|
||||
).replace(/\/$/, "");
|
||||
|
||||
return {
|
||||
...conn,
|
||||
bucket,
|
||||
publicUrl,
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user