File size: 1,002 Bytes
494c9e4
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
/**
 * 外部内容加载器
 * 用于加载独立的 HTML 内容文件(如首页介绍等大段文本)
 */

import { getCurrentLanguage } from './i18n-lite';
import homeContentEn from '../../content/home.en.html';
import homeContentZh from '../../content/home.zh.html';

interface ContentMap {
    en: string;
    zh: string;
}

const homeContent: ContentMap = {
    en: homeContentEn,
    zh: homeContentZh
};

/**
 * 获取首页介绍内容
 */
export function getHomeContent(): string {
    const lang = getCurrentLanguage();
    return homeContent[lang] || homeContent.en;
}

/**
 * 加载首页介绍内容到指定容器
 * @param containerId 容器元素的 ID
 */
export function loadHomeContent(containerId: string): void {
    const container = document.getElementById(containerId);
    if (!container) {
        console.error(`Container element with id "${containerId}" not found`);
        return;
    }
    
    const content = getHomeContent();
    container.innerHTML = content;
}