From 8581195d4df84cd52c7537f73f6b789b26c83bde Mon Sep 17 00:00:00 2001 From: Xi Xu Date: Tue, 22 Jul 2025 19:56:00 +0800 Subject: [PATCH] Refactor config and update homepage styles Refactored src/config/index.js to export a structured CONFIG object with application and security settings, and moved platform definitions to a separate import. Updated src/homepage.js to improve and align styles, enhance section structure, and synchronize UI/UX with the new config and design direction. --- src/config/index.js | 888 ++------------------------------------------ src/homepage.js | 740 ++++++++++++++++++------------------ 2 files changed, 408 insertions(+), 1220 deletions(-) diff --git a/src/config/index.js b/src/config/index.js index 41be420..c33b2ba 100644 --- a/src/config/index.js +++ b/src/config/index.js @@ -1,864 +1,32 @@ +import { PLATFORMS } from "./platforms"; + /** - * Generates the modern homepage HTML for Xget - * @returns {string} The complete HTML page + * @typedef {Object} SecurityConfig + * @property {string[]} ALLOWED_METHODS - List of allowed HTTP methods + * @property {string[]} ALLOWED_ORIGINS - List of allowed CORS origins + * @property {number} MAX_PATH_LENGTH - Maximum allowed URL path length */ -export function generateHomepage() { - return ` - - - - - Xget - 高性能代理服务 - - - - - - - - - - - - - - - - - - - - -
- -
- -
-
-
-
-

Xget

-

一个高性能、安全的代理服务,专为加速 GitHub、GitLab 和 Hugging Face 的文件下载和 Git 操作而设计。

- 立即开始 -
-
-
- -
-
-
-

URL 转换器

-
-
- -
- -
-
- -
-
- 加速链接: -
- -
-
-
-
- -
-
-

🌟 核心特性

-
-
- ⚡ -

全球边缘分发

-

基于 Cloudflare 全球 CDN,200+ 城市边缘节点,就近响应用户请求,显著提升下载速度。

-
-
- 🌐 -

多平台集成

-

完美支持 GitHub、GitLab、Hugging Face,智能路径转换,无缝访问各平台资源。

-
-
- 🔒 -

企业级安全

-

多层安全标头保护,请求验证机制,超时保护,确保安全可靠的代理服务。

-
-
- 🎯 -

Git 完全兼容

-

支持 git clone、push、pull 等所有 Git 操作,智能协议检测,无需修改工作流。

-
-
- 📱 -

生态系统集成

-

专用浏览器扩展,完美兼容 wget、curl、aria2 等下载工具,CI/CD 环境友好。

-
-
- 🚀 -

现代架构

-

智能重试机制,高效缓存策略,性能监控系统,提供稳定可靠的服务体验。

-
-
-
-
- -
-
-

🌐 支持平台

-
-
- -

GitHub

-

加速 Releases、Archives、Raw 文件下载,完整支持 Git 协议操作。

-
-
前缀: /gh/
示例: xget.xi-xu.me/gh/...
-
-
-
- -

GitLab

-

全面适配 GitLab.com 的文件下载和版本控制功能。

-
-
前缀: /gl/
示例: xget.xi-xu.me/gl/...
-
-
-
- -

Hugging Face

-

针对大型模型文件和数据集进行专门优化,支持高速下载。

-
-
前缀: /hf/
示例: xget.xi-xu.me/hf/...
-
-
-
-
-
- -
-
-

📖 使用示例

-
-
- - - - -
- -
-
-

🎯 Git 版本控制操作

-

Xget 完全兼容 Git 协议,支持所有标准 Git 操作:

-
-
# 克隆仓库
-git clone https://xget.xi-xu.me/gh/microsoft/vscode.git
-
-# 克隆指定分支
-git clone -b main https://xget.xi-xu.me/gh/facebook/react.git
-
-# 浅克隆(仅最新提交)
-git clone --depth 1 https://xget.xi-xu.me/gh/torvalds/linux.git
-
-
- -
-

⬇️ 主流下载工具集成

-

完美支持 wget、curl、aria2 等下载工具:

-
-
# wget 下载
-wget https://xget.xi-xu.me/gh/microsoft/vscode/archive/refs/heads/main.zip
-
-# curl 下载
-curl -L -O https://xget.xi-xu.me/gh/golang/go/archive/refs/tags/go1.22.0.tar.gz
-
-# aria2 多线程下载
-aria2c -x 16 -s 16 https://xget.xi-xu.me/hf/microsoft/DialoGPT-large/resolve/main/pytorch_model.bin
-
-
- -
-

🐍 Python 环境中的应用

-

作为 Hugging Face 镜像使用:

-
-
# 设置环境变量,让 transformers 库自动使用 Xget 镜像
-import os
-os.environ['HF_ENDPOINT'] = 'https://xget.xi-xu.me'
-
-from transformers import AutoModel
-
-# 现在所有模型下载都会通过 Xget 加速
-model = AutoModel.from_pretrained('bert-base-uncased')
-
-
- -
-

🔄 CI/CD 环境集成

-

在 GitHub Actions 中使用 Xget:

-
-
name: Download Dependencies
-on: [push]
-
-jobs:
-  build:
-    runs-on: ubuntu-latest
-    steps:
-    - name: Download model files
-      run: |
-        wget https://xget.xi-xu.me/hf/microsoft/DialoGPT-medium/resolve/main/pytorch_model.bin
-          
-    - name: Clone dependency repo
-      run: |
-        git clone https://xget.xi-xu.me/gh/some-dependency/repo.git
-
-
-
-
-
-
-
- - - - - -`; -} +/** @type {ApplicationConfig} */ +export const CONFIG = { + TIMEOUT_SECONDS: 30, + MAX_RETRIES: 3, + RETRY_DELAY_MS: 1000, + CACHE_DURATION: 1800, // 30 minutes + SECURITY: { + ALLOWED_METHODS: ["GET", "HEAD"], // POST is allowed dynamically for Git operations + ALLOWED_ORIGINS: ["*"], + MAX_PATH_LENGTH: 2048, + }, + PLATFORMS, +}; diff --git a/src/homepage.js b/src/homepage.js index 222202a..41be420 100644 --- a/src/homepage.js +++ b/src/homepage.js @@ -27,12 +27,6 @@ export function generateHomepage() {
@@ -499,18 +558,18 @@ export function generateHomepage() {
-
+

Xget

-

一个高性能、安全的代理服务,专为加速 GitHub、GitLab 和 Hugging Face 的文件下载和 Git 操作而设计

+

一个高性能、安全的代理服务,专为加速 GitHub、GitLab 和 Hugging Face 的文件下载和 Git 操作而设计。

立即开始
-
+
-
-

URL 转换器

+
+

URL 转换器

@@ -528,166 +587,159 @@ export function generateHomepage() {
加速链接:
- +
-
+
-

🌟 核心特性

+

🌟 核心特性

-
-
⚡
+
+ ⚡

全球边缘分发

-

基于 Cloudflare 全球 CDN,200+ 城市边缘节点,就近响应用户请求,显著提升下载速度

+

基于 Cloudflare 全球 CDN,200+ 城市边缘节点,就近响应用户请求,显著提升下载速度。

-
-
🌐
+
+ 🌐

多平台集成

-

完美支持 GitHub、GitLab、Hugging Face,智能路径转换,无缝访问各平台资源

+

完美支持 GitHub、GitLab、Hugging Face,智能路径转换,无缝访问各平台资源。

-
-
🔒
+
+ 🔒

企业级安全

-

多层安全标头保护,请求验证机制,超时保护,确保安全可靠的代理服务

+

多层安全标头保护,请求验证机制,超时保护,确保安全可靠的代理服务。

-
-
🎯
+
+ 🎯

Git 完全兼容

-

支持 git clone、push、pull 等所有 Git 操作,智能协议检测,无需修改工作流

+

支持 git clone、push、pull 等所有 Git 操作,智能协议检测,无需修改工作流。

-
-
📱
+
+ 📱

生态系统集成

-

专用浏览器扩展,完美兼容 wget、curl、aria2 等下载工具,CI/CD 环境友好

+

专用浏览器扩展,完美兼容 wget、curl、aria2 等下载工具,CI/CD 环境友好。

-
-
🚀
+
+ 🚀

现代架构

-

智能重试机制,高效缓存策略,性能监控系统,提供稳定可靠的服务体验

+

智能重试机制,高效缓存策略,性能监控系统,提供稳定可靠的服务体验。

-
+
-

🌐 支持平台

+

🌐 支持平台

-
+

GitHub

-

加速 Releases、Archives、Raw 文件下载,完整支持 Git 协议操作

+

加速 Releases、Archives、Raw 文件下载,完整支持 Git 协议操作。

- 前缀: /gh/
- 示例: xget.xi-xu.me/gh/microsoft/vscode/archive/main.zip +
前缀: /gh/
示例: xget.xi-xu.me/gh/...
-
+

GitLab

-

全面适配 GitLab.com 的文件下载和版本控制功能

+

全面适配 GitLab.com 的文件下载和版本控制功能。

- 前缀: /gl/
- 示例: xget.xi-xu.me/gl/gitlab-org/gitlab/-/archive/master/gitlab-master.zip +
前缀: /gl/
示例: xget.xi-xu.me/gl/...
-
+

Hugging Face

-

针对大型模型文件和数据集进行专门优化,支持高速下载

+

针对大型模型文件和数据集进行专门优化,支持高速下载。

- 前缀: /hf/
- 示例: xget.xi-xu.me/hf/microsoft/DialoGPT-medium/resolve/main/pytorch_model.bin +
前缀: /hf/
示例: xget.xi-xu.me/hf/...
-
+
-

📖 使用示例

-
- - - - -
- -
-

🎯 Git 版本控制操作

-

Xget 完全兼容 Git 协议,支持所有标准 Git 操作:

-
-# 克隆仓库 +

📖 使用示例

+
+
+ + + + +
+ +
+
+

🎯 Git 版本控制操作

+

Xget 完全兼容 Git 协议,支持所有标准 Git 操作:

+
+
# 克隆仓库
 git clone https://xget.xi-xu.me/gh/microsoft/vscode.git
 
-# 克隆指定分支
+# 克隆指定分支
 git clone -b main https://xget.xi-xu.me/gh/facebook/react.git
 
-# 浅克隆(仅最新提交)
-git clone --depth 1 https://xget.xi-xu.me/gh/torvalds/linux.git
-
-# 添加远程仓库
-git remote add upstream https://xget.xi-xu.me/gh/[用户名]/[仓库名].git
-                    
-
- -
-

⬇️ 主流下载工具集成

-

完美支持 wget、curl、aria2 等下载工具:

-
-# wget 下载 +# 浅克隆(仅最新提交) +git clone --depth 1 https://xget.xi-xu.me/gh/torvalds/linux.git +
+
+ +
+

⬇️ 主流下载工具集成

+

完美支持 wget、curl、aria2 等下载工具:

+
+
# wget 下载
 wget https://xget.xi-xu.me/gh/microsoft/vscode/archive/refs/heads/main.zip
 
-# curl 下载
+# curl 下载
 curl -L -O https://xget.xi-xu.me/gh/golang/go/archive/refs/tags/go1.22.0.tar.gz
 
-# aria2 多线程下载
-aria2c -x 16 -s 16 https://xget.xi-xu.me/hf/microsoft/DialoGPT-large/resolve/main/pytorch_model.bin
-                    
-
- -
-

🐍 Python 环境中的应用

-

作为 Hugging Face 镜像使用:

-
+# aria2 多线程下载 +aria2c -x 16 -s 16 https://xget.xi-xu.me/hf/microsoft/DialoGPT-large/resolve/main/pytorch_model.bin +
+
+ +
+

🐍 Python 环境中的应用

+

作为 Hugging Face 镜像使用:

+
+
# 设置环境变量,让 transformers 库自动使用 Xget 镜像
 import os
-from transformers import AutoTokenizer, AutoModelForCausalLM
+os.environ['HF_ENDPOINT'] = 'https://xget.xi-xu.me'
 
-# 设置环境变量,让 transformers 库自动使用 Xget 镜像
-os.environ['HF_ENDPOINT'] = 'https://xget.xi-xu.me/hf'
+from transformers import AutoModel
 
-# 现在所有模型下载都会通过 Xget 加速
-model_name = 'microsoft/DialoGPT-medium'
-tokenizer = AutoTokenizer.from_pretrained(model_name)
-model = AutoModelForCausalLM.from_pretrained(model_name)
-                    
-
- -
-

🔄 CI/CD 环境集成

-

在 GitHub Actions 中使用 Xget:

-
-name: Download Dependencies +# 现在所有模型下载都会通过 Xget 加速 +model = AutoModel.from_pretrained('bert-base-uncased') +
+
+ +
+

🔄 CI/CD 环境集成

+

在 GitHub Actions 中使用 Xget:

+
+
name: Download Dependencies
 on: [push]
 
 jobs:
   build:
     runs-on: ubuntu-latest
     steps:
-      - name: Checkout code
-        uses: actions/checkout@v4
-      
-      - name: Download model files
-        run: |
-          wget https://xget.xi-xu.me/hf/microsoft/DialoGPT-medium/resolve/main/pytorch_model.bin
+    - name: Download model files
+      run: |
+        wget https://xget.xi-xu.me/hf/microsoft/DialoGPT-medium/resolve/main/pytorch_model.bin
           
-      - name: Clone dependency repo
-        run: |
-          git clone https://xget.xi-xu.me/gh/[依赖项目]/[仓库名].git
+    - name: Clone dependency repo
+      run: |
+        git clone https://xget.xi-xu.me/gh/some-dependency/repo.git
+
+
@@ -697,146 +749,114 @@ jobs: