Spaces:
Runtime error
Runtime error
Download client/src/shared/lang/contentLoader.ts from IdealDestructor/InfoLens: direct link, hf CLI and curl.
- Browser
- Download file 1.02 kB
-
https://huggingface.co/spaces/IdealDestructor/InfoLens/resolve/main/client/src/shared/lang/contentLoader.ts
- Command line
-
hf download hf://spaces/IdealDestructor/InfoLens/client/src/shared/lang/contentLoader.ts
-
curl -L -o contentLoader.ts https://huggingface.co/spaces/IdealDestructor/InfoLens/resolve/main/client/src/shared/lang/contentLoader.ts
1.02 kB
| /** | |
| * 外部内容加载器 | |
| * 用于加载独立的 HTML 内容文件(如首页介绍等大段文本) | |
| */ | |
| import { getCurrentLanguage } from './i18n-lite'; | |
| import homeContentEn from '../../assets/content/home.en.html'; | |
| import homeContentZh from '../../assets/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; | |
| } | |