's'调试支付

This commit is contained in:
eric
2026-03-08 06:43:48 -05:00
parent b99fba1c5a
commit 1f4473cb04
35 changed files with 1794 additions and 178 deletions

86
app/lib/theme-data.ts Normal file
View File

@@ -0,0 +1,86 @@
/**
* 主题数据加载器 - 根据 CURRENT_THEME 加载对应主题的内容
* 新增主题1. 在 config/site.config.ts 添加 THEME_CONFIGS
* 2. 在 content/themes/[theme-id]/ 下添加 messages 和 data
* 3. 在本文件 switch 中添加 case
*/
import { CURRENT_THEME, THEME_IDS, type ThemeId } from "@/config";
export type Locale = "zh" | "en";
export type ToolsCategory = {
id: string;
icon: string;
title: string;
color: string;
bg: string;
text: string;
tools: Array<{ name: string; desc: string; href: string }>;
};
/** 加载当前主题的 messages */
export async function getThemeMessages(
locale: Locale
): Promise<Record<string, unknown>> {
const theme = CURRENT_THEME;
switch (theme) {
case "digital-nomad": {
const mod =
locale === "zh"
? await import("@/content/themes/digital-nomad/messages/zh.json")
: await import("@/content/themes/digital-nomad/messages/en.json");
return mod.default;
}
case "solo-company":
case "tiktok-ops":
case "indie-dev":
// 新主题暂无内容时回退到 digital-nomad
return getThemeMessagesFallback(locale);
default:
return getThemeMessagesFallback(locale);
}
}
async function getThemeMessagesFallback(
locale: Locale
): Promise<Record<string, unknown>> {
const mod =
locale === "zh"
? await import("@/content/themes/digital-nomad/messages/zh.json")
: await import("@/content/themes/digital-nomad/messages/en.json");
return mod.default;
}
/** 加载当前主题的 tools 数据 */
export async function getThemeToolsData(): Promise<{
categories: ToolsCategory[];
}> {
const theme = CURRENT_THEME;
switch (theme) {
case "digital-nomad": {
const mod = await import(
"@/content/themes/digital-nomad/data/tools.json"
);
return mod.default;
}
case "solo-company":
case "tiktok-ops":
case "indie-dev":
return getThemeToolsDataFallback();
default:
return getThemeToolsDataFallback();
}
}
async function getThemeToolsDataFallback(): Promise<{
categories: ToolsCategory[];
}> {
const mod = await import(
"@/content/themes/digital-nomad/data/tools.json"
);
return mod.default;
}
export { CURRENT_THEME, THEME_IDS };
export type { ThemeId };