's'调试支付
This commit is contained in:
16
config/index.ts
Normal file
16
config/index.ts
Normal file
@@ -0,0 +1,16 @@
|
||||
export {
|
||||
CURRENT_THEME,
|
||||
THEME_IDS,
|
||||
THEME_CONFIGS,
|
||||
getThemeConfig,
|
||||
type ThemeId,
|
||||
type ThemeConfig,
|
||||
} from "./site.config";
|
||||
|
||||
export {
|
||||
getPocketBaseConfig,
|
||||
getPaymentConfig,
|
||||
getJoinPaymentConfig,
|
||||
getServicesConfig,
|
||||
} from "./services.config";
|
||||
export type { PocketBaseConfig, PaymentConfig, ServicesConfig } from "./services.config";
|
||||
137
config/services.config.ts
Normal file
137
config/services.config.ts
Normal file
@@ -0,0 +1,137 @@
|
||||
/**
|
||||
* 服务配置 - PocketBase、支付等第三方服务
|
||||
* 可通过环境变量覆盖,不同主题可配置不同集合/金额
|
||||
*/
|
||||
|
||||
import { getThemeConfig } from "./site.config";
|
||||
|
||||
export interface PocketBaseConfig {
|
||||
enabled: boolean;
|
||||
/** PocketBase 服务地址 */
|
||||
url: string;
|
||||
/** 用户认证集合 */
|
||||
usersCollection: string;
|
||||
/** 申请/加入表单集合(如 solan、applications) */
|
||||
joinCollection: string;
|
||||
}
|
||||
|
||||
export interface PaymentConfig {
|
||||
enabled: boolean;
|
||||
/** 支付 API 地址(payjsapi) */
|
||||
apiUrl: string;
|
||||
/** 支付提供商:zpay | xorpay */
|
||||
provider: "zpay" | "xorpay";
|
||||
/** 默认金额(分) */
|
||||
defaultAmount: number;
|
||||
/** 默认订单类型 */
|
||||
defaultType: string;
|
||||
/** ZPAY 提交地址 */
|
||||
zpaySubmitUrl: string;
|
||||
}
|
||||
|
||||
export interface MinioConfig {
|
||||
enabled: boolean;
|
||||
/** MinIO 服务端点 */
|
||||
endPoint: string;
|
||||
/** 端口 */
|
||||
port: number;
|
||||
/** 是否使用 SSL */
|
||||
useSSL: boolean;
|
||||
/** 存储桶 */
|
||||
bucket: string;
|
||||
/** Access Key */
|
||||
accessKey: string;
|
||||
/** Secret Key */
|
||||
secretKey: string;
|
||||
/** 区域 */
|
||||
region: string;
|
||||
/** 公开访问 URL(用于生成文件链接) */
|
||||
publicUrl: string;
|
||||
/** 上传路径前缀(如 joins、uploads) */
|
||||
uploadPrefix: string;
|
||||
}
|
||||
|
||||
export interface ServicesConfig {
|
||||
pocketbase: PocketBaseConfig;
|
||||
payment: PaymentConfig;
|
||||
minio: MinioConfig;
|
||||
}
|
||||
|
||||
const isDev = process.env.NODE_ENV === "development";
|
||||
|
||||
/** 获取 PocketBase 配置(可传入主题覆盖) */
|
||||
export function getPocketBaseConfig(themeOverride?: { joinCollection?: string }): PocketBaseConfig {
|
||||
const joinCollection =
|
||||
themeOverride?.joinCollection ||
|
||||
process.env.POCKETBASE_JOIN_COLLECTION ||
|
||||
"solan";
|
||||
return {
|
||||
enabled: true,
|
||||
url: process.env.NEXT_PUBLIC_POCKETBASE_URL || process.env.POCKETBASE_URL || "https://pocketbase.hackrobot.cn",
|
||||
usersCollection: "users",
|
||||
joinCollection,
|
||||
};
|
||||
}
|
||||
|
||||
/** 获取支付配置(可传入主题覆盖,如 join 金额/类型) */
|
||||
export function getPaymentConfig(themeOverride?: { amount?: number; type?: string }): PaymentConfig {
|
||||
const base = {
|
||||
enabled: true,
|
||||
apiUrl:
|
||||
process.env.PAYMENT_API_URL ||
|
||||
(isDev ? "http://127.0.0.1:8700" : "https://api.hackrobot.cn"),
|
||||
provider: (process.env.PAYMENT_PROVIDER as "zpay" | "xorpay") || "zpay",
|
||||
defaultAmount: Number(process.env.PAYMENT_DEFAULT_AMOUNT) || 80,
|
||||
defaultType: process.env.PAYMENT_DEFAULT_TYPE || "meetup",
|
||||
zpaySubmitUrl: process.env.ZPAY_SUBMIT_URL || "https://zpayz.cn/submit.php",
|
||||
};
|
||||
if (themeOverride) {
|
||||
if (themeOverride.amount != null) base.defaultAmount = themeOverride.amount;
|
||||
if (themeOverride.type) base.defaultType = themeOverride.type;
|
||||
}
|
||||
return base;
|
||||
}
|
||||
|
||||
/** 获取 MinIO 配置(可传入主题覆盖 bucket/prefix) */
|
||||
export function getMinioConfig(themeOverride?: { bucket?: string; uploadPrefix?: string }): MinioConfig {
|
||||
const endPoint = process.env.MINIO_ENDPOINT || "minioweb.hackrobot.cn";
|
||||
const port = parseInt(process.env.MINIO_PORT || "9035", 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://${endPoint}/${bucket}`;
|
||||
const uploadPrefix = themeOverride?.uploadPrefix || process.env.MINIO_UPLOAD_PREFIX || "joins";
|
||||
|
||||
return {
|
||||
enabled: true,
|
||||
endPoint,
|
||||
port,
|
||||
useSSL,
|
||||
bucket,
|
||||
accessKey: process.env.MINIO_ACCESS_KEY || "6i56HHfg4zPfYItCZtnp",
|
||||
secretKey: process.env.MINIO_SECRET_KEY || "vDJCqEit3ejH5UmWKAZnvqhziNfbVsoOlBW12G8Q",
|
||||
region: process.env.MINIO_REGION || "china",
|
||||
publicUrl: publicUrl.replace(/\/$/, ""),
|
||||
uploadPrefix,
|
||||
};
|
||||
}
|
||||
|
||||
/** 获取完整服务配置 */
|
||||
export function getServicesConfig(): ServicesConfig {
|
||||
return {
|
||||
pocketbase: getPocketBaseConfig(),
|
||||
payment: getPaymentConfig(),
|
||||
minio: getMinioConfig(),
|
||||
};
|
||||
}
|
||||
|
||||
/** 获取「加入/申请」场景的支付配置(含主题覆盖) */
|
||||
export function getJoinPaymentConfig(): { amount: number; type: string } {
|
||||
const theme = getThemeConfig();
|
||||
const payment = getPaymentConfig();
|
||||
return {
|
||||
amount: theme.services?.join?.amount ?? payment.defaultAmount,
|
||||
type: theme.services?.join?.type ?? payment.defaultType,
|
||||
};
|
||||
}
|
||||
165
config/site.config.ts
Normal file
165
config/site.config.ts
Normal file
@@ -0,0 +1,165 @@
|
||||
/**
|
||||
* 站点模板配置 - 切换主题只需修改 CURRENT_THEME
|
||||
* 克隆新主题:复制 themes/digital-nomad 为 themes/your-theme,修改配置和内容
|
||||
*/
|
||||
|
||||
export const THEME_IDS = [
|
||||
"digital-nomad",
|
||||
"solo-company",
|
||||
"tiktok-ops",
|
||||
"indie-dev",
|
||||
] as const;
|
||||
|
||||
export type ThemeId = (typeof THEME_IDS)[number];
|
||||
|
||||
export const CURRENT_THEME: ThemeId =
|
||||
(process.env.NEXT_PUBLIC_THEME as ThemeId) || "digital-nomad";
|
||||
|
||||
export interface ThemeConfig {
|
||||
id: ThemeId;
|
||||
name: string;
|
||||
nameEn: string;
|
||||
tagline: string;
|
||||
taglineEn: string;
|
||||
/** SEO 元数据 */
|
||||
meta: {
|
||||
title: string;
|
||||
description: string;
|
||||
};
|
||||
/** 功能开关 */
|
||||
features: {
|
||||
roadmap: boolean;
|
||||
tools: boolean;
|
||||
community: boolean;
|
||||
join: boolean;
|
||||
course: boolean;
|
||||
ebook: boolean;
|
||||
};
|
||||
/** 品牌色 - Tailwind 类名 */
|
||||
colors: {
|
||||
primary: string;
|
||||
accent: string;
|
||||
};
|
||||
/** 服务配置覆盖(可选) */
|
||||
services?: {
|
||||
/** 加入/申请支付 */
|
||||
join?: {
|
||||
amount?: number;
|
||||
type?: string;
|
||||
};
|
||||
/** PocketBase 申请集合名 */
|
||||
pocketbaseJoinCollection?: string;
|
||||
/** MinIO 存储(可选) */
|
||||
minio?: {
|
||||
bucket?: string;
|
||||
uploadPrefix?: string;
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
export const THEME_CONFIGS: Record<ThemeId, ThemeConfig> = {
|
||||
"digital-nomad": {
|
||||
id: "digital-nomad",
|
||||
name: "数字游民指南",
|
||||
nameEn: "Digital Nomad Guide",
|
||||
tagline: "开源免费的数字游民资源平台",
|
||||
taglineEn: "Open-source digital nomad resource platform",
|
||||
meta: {
|
||||
title: "数字游民指南 | Digital Nomad Guide",
|
||||
description:
|
||||
"从零开始,7天开启你的数字游民生活。远程工作、地点自由、技能变现 —— 一站式数字游民资源平台。",
|
||||
},
|
||||
features: {
|
||||
roadmap: true,
|
||||
tools: true,
|
||||
community: true,
|
||||
join: true,
|
||||
course: true,
|
||||
ebook: true,
|
||||
},
|
||||
colors: {
|
||||
primary: "sky",
|
||||
accent: "amber",
|
||||
},
|
||||
services: {
|
||||
join: { amount: 80, type: "meetup" },
|
||||
pocketbaseJoinCollection: "solan",
|
||||
},
|
||||
},
|
||||
"solo-company": {
|
||||
id: "solo-company",
|
||||
name: "一人公司指南",
|
||||
nameEn: "Solo Company Guide",
|
||||
tagline: "一人公司创业与运营指南",
|
||||
taglineEn: "Guide to building and running a solo company",
|
||||
meta: {
|
||||
title: "一人公司指南 | Solo Company Guide",
|
||||
description:
|
||||
"从零到一,打造属于你的一人公司。产品、营销、运营 —— 一人公司全流程指南。",
|
||||
},
|
||||
features: {
|
||||
roadmap: true,
|
||||
tools: true,
|
||||
community: true,
|
||||
join: false,
|
||||
course: false,
|
||||
ebook: true,
|
||||
},
|
||||
colors: {
|
||||
primary: "violet",
|
||||
accent: "emerald",
|
||||
},
|
||||
},
|
||||
"tiktok-ops": {
|
||||
id: "tiktok-ops",
|
||||
name: "TikTok 运营指南",
|
||||
nameEn: "TikTok Operations Guide",
|
||||
tagline: "TikTok 出海运营与变现指南",
|
||||
taglineEn: "TikTok operations and monetization guide",
|
||||
meta: {
|
||||
title: "TikTok 运营指南 | TikTok Operations Guide",
|
||||
description:
|
||||
"TikTok 账号运营、内容创作、广告投放、跨境变现 —— 一站式 TikTok 出海指南。",
|
||||
},
|
||||
features: {
|
||||
roadmap: true,
|
||||
tools: true,
|
||||
community: true,
|
||||
join: false,
|
||||
course: true,
|
||||
ebook: true,
|
||||
},
|
||||
colors: {
|
||||
primary: "pink",
|
||||
accent: "cyan",
|
||||
},
|
||||
},
|
||||
"indie-dev": {
|
||||
id: "indie-dev",
|
||||
name: "独立开发指南",
|
||||
nameEn: "Indie Developer Guide",
|
||||
tagline: "独立开发者产品与变现指南",
|
||||
taglineEn: "Indie developer product and monetization guide",
|
||||
meta: {
|
||||
title: "独立开发指南 | Indie Developer Guide",
|
||||
description:
|
||||
"从想法到产品,独立开发全流程。技术选型、产品设计、上线运营 —— 独立开发者必备指南。",
|
||||
},
|
||||
features: {
|
||||
roadmap: true,
|
||||
tools: true,
|
||||
community: true,
|
||||
join: false,
|
||||
course: false,
|
||||
ebook: true,
|
||||
},
|
||||
colors: {
|
||||
primary: "indigo",
|
||||
accent: "orange",
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
export function getThemeConfig(): ThemeConfig {
|
||||
return THEME_CONFIGS[CURRENT_THEME];
|
||||
}
|
||||
Reference in New Issue
Block a user