'init'
This commit is contained in:
23
config/domain.config.ts
Normal file
23
config/domain.config.ts
Normal file
@@ -0,0 +1,23 @@
|
||||
/**
|
||||
* 域名与 payjsapi 地址配置
|
||||
* 生产环境必须设置 PAYMENT_API_URL 或 ROOT_DOMAIN,否则无法连接 payjsapi
|
||||
*/
|
||||
|
||||
const isDev = process.env.NODE_ENV === "development";
|
||||
|
||||
export const ROOT_DOMAIN =
|
||||
process.env.ROOT_DOMAIN || process.env.NEXT_PUBLIC_ROOT_DOMAIN || "hackrobot.cn";
|
||||
|
||||
/** 支付 API 默认地址。生产环境使用 api 子域,避免 127.0.0.1 导致连接失败 */
|
||||
export const DEFAULT_PAYMENT_API_URL = isDev
|
||||
? "http://127.0.0.1:8007"
|
||||
: `https://api.${ROOT_DOMAIN}`;
|
||||
|
||||
/** 若 PAYMENT_API_URL 指向 localhost,生产环境自动使用 api 子域 */
|
||||
export function resolvePaymentApiUrl(): string {
|
||||
const url = process.env.PAYMENT_API_URL || DEFAULT_PAYMENT_API_URL;
|
||||
if (!isDev && /^(https?:\/\/)?(127\.0\.0\.1|localhost)(:\d+)?(\/|$)/i.test(url)) {
|
||||
return `https://api.${ROOT_DOMAIN}`;
|
||||
}
|
||||
return url.replace(/\/$/, "");
|
||||
}
|
||||
43
config/home.config.ts
Normal file
43
config/home.config.ts
Normal file
@@ -0,0 +1,43 @@
|
||||
export const HOME_STATS = {
|
||||
cities: "18",
|
||||
nomads: "5,000+",
|
||||
meetups: "8+",
|
||||
homeMeetups: "50+",
|
||||
cost: "¥3,000",
|
||||
};
|
||||
|
||||
export const COMMUNITY_STATS = {
|
||||
onlineMembers: "3,200+",
|
||||
messagesPerMonth: "3,200+",
|
||||
};
|
||||
|
||||
export const MEMBER_PHOTOS = [
|
||||
{ name: "林晓", photo: "https://i.pravatar.cc/150?img=5" },
|
||||
{ name: "张浩", photo: "https://i.pravatar.cc/150?img=3" },
|
||||
{ name: "陈悦", photo: "https://i.pravatar.cc/150?img=9" },
|
||||
{ name: "周杰", photo: "https://i.pravatar.cc/150?img=7" },
|
||||
{ name: "吴婷", photo: "https://i.pravatar.cc/150?img=1" },
|
||||
];
|
||||
|
||||
export const MEETUPS = [
|
||||
{ city: "大理", emoji: "🏯", date: "3月9日", count: 12 },
|
||||
{ city: "成都", emoji: "🐼", date: "3月12日", count: 8 },
|
||||
{ city: "深圳", emoji: "🌃", date: "3月14日", count: 15 },
|
||||
];
|
||||
|
||||
export const ROUTES = [
|
||||
{
|
||||
titleZh: "云南慢生活线",
|
||||
titleEn: "Yunnan Slow Life",
|
||||
citiesZh: ["昆明", "大理", "丽江"],
|
||||
citiesEn: ["Kunming", "Dali", "Lijiang"],
|
||||
emojis: ["🌸", "🏯", "🏔️"],
|
||||
durationZh: "3-6个月",
|
||||
durationEn: "3-6 months",
|
||||
costZh: "¥3,200/月起",
|
||||
costEn: "From ¥3,200/month",
|
||||
descZh: "从春城昆明出发,感受最纯粹的慢生活",
|
||||
descEn: "From Kunming, experience the purest slow life",
|
||||
gradient: "from-purple-500 to-pink-500",
|
||||
},
|
||||
];
|
||||
66
config/services.config.ts
Normal file
66
config/services.config.ts
Normal file
@@ -0,0 +1,66 @@
|
||||
/**
|
||||
* salon 服务配置 - PocketBase、支付
|
||||
* 使用 site_id=salon,支付调用 payjsapi /salon/*
|
||||
*/
|
||||
|
||||
import { resolvePaymentApiUrl } from "./domain.config";
|
||||
|
||||
const isDev = process.env.NODE_ENV === "development";
|
||||
const PAYJSAPI_PORT = process.env.PAYJSAPI_PORT || "8007";
|
||||
|
||||
export const SITE_ID = "salon";
|
||||
|
||||
export const MEETUP_JOIN_AMOUNT = 8800;
|
||||
|
||||
export function getApiUrlFromRequest(hostHeader: string | null): string | null {
|
||||
if (!hostHeader) return null;
|
||||
if (!isDev) return resolvePaymentApiUrl();
|
||||
const hostname = hostHeader.split(":")[0];
|
||||
return `http://${hostname}:${PAYJSAPI_PORT}`;
|
||||
}
|
||||
|
||||
export interface PocketBaseConfig {
|
||||
enabled: boolean;
|
||||
url: string;
|
||||
usersCollection: string;
|
||||
joinCollection: string;
|
||||
}
|
||||
|
||||
export interface PaymentConfig {
|
||||
enabled: boolean;
|
||||
apiUrl: string;
|
||||
provider: "zpay" | "xorpay";
|
||||
defaultAmount: number;
|
||||
defaultType: string;
|
||||
zpaySubmitUrl: string;
|
||||
}
|
||||
|
||||
export function getPocketBaseConfig(): PocketBaseConfig {
|
||||
return {
|
||||
enabled: true,
|
||||
url:
|
||||
process.env.NEXT_PUBLIC_POCKETBASE_URL ||
|
||||
process.env.POCKETBASE_URL ||
|
||||
"http://127.0.0.1:8090",
|
||||
usersCollection: "users",
|
||||
joinCollection: "solanRed",
|
||||
};
|
||||
}
|
||||
|
||||
export function getPaymentConfig(): PaymentConfig {
|
||||
return {
|
||||
enabled: true,
|
||||
apiUrl: resolvePaymentApiUrl(),
|
||||
provider: (process.env.PAYMENT_PROVIDER as "zpay" | "xorpay") || "zpay",
|
||||
defaultAmount: Number(process.env.PAYMENT_DEFAULT_AMOUNT) || 8800,
|
||||
defaultType: "salon",
|
||||
zpaySubmitUrl: process.env.ZPAY_SUBMIT_URL || "https://zpayz.cn/submit.php",
|
||||
};
|
||||
}
|
||||
|
||||
export function getJoinPaymentConfig(): { amount: number; type: string } {
|
||||
return {
|
||||
amount: Number(process.env.PAYMENT_JOIN_AMOUNT) || MEETUP_JOIN_AMOUNT,
|
||||
type: "salon",
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user