### Theme Information JSON Example Source: https://github.com/anzhiyu-c/anheyu-docs/blob/main/content/docs/theme-development.mdx A complete example of the 'theme.json' file, detailing essential metadata for a theme. Ensure all required fields like name, displayName, version, description, and author are correctly populated. ```json { "name": "theme-example-blog", "displayName": "示例博客主题", "version": "1.0.0", "description": "这是一个示例博客主题,展示了主题开发的基本结构和功能。", "author": { "name": "安知鱼", "email": "anzhiy@anheyu.com", "url": "https://anheyu.com" }, "license": "MIT", "homepage": "https://github.com/anzhiyu-c/theme-example-blog", "repository": { "type": "git", "url": "https://github.com/anzhiyu-c/theme-example-blog.git" }, "keywords": ["博客", "响应式", "现代化", "简洁"], "category": "blog", "screenshots": "https://upload-bbs.miyoushe.com/upload/2025/09/18/125766904/359dbf5b0ce07e56a960b31063c44280_4491727436207297404.png", "engines": { "anheyu": ">=1.0.0" }, "features": ["responsive-design", "dark-mode", "seo-friendly", "customizable-colors"] } ``` -------------------------------- ### Anheyu Configuration Example Source: https://github.com/anzhiyu-c/anheyu-docs/blob/main/content/docs/getting-started.mdx This is an example of the Anheyu configuration file, showing settings for port, debug mode, database, and optional Redis configuration. ```ini Port = 8091 Debug = false [Database] Type = mysql Host = 127.0.0.1 Port = 3306 User = root Password = root Name = anheyu_app Debug = false # Redis 配置(可选) # 如果不配置或留空 Addr,系统将自动使用内存缓存 # 推荐生产环境使用 Redis 以获得更好的性能 [Redis] Addr = localhost:6379 Password = DB = 10 ``` -------------------------------- ### Install Project Dependencies Source: https://github.com/anzhiyu-c/anheyu-docs/blob/main/content/docs/theming.mdx Install all necessary project dependencies using pnpm. This ensures the development environment is set up correctly. ```bash pnpm install ``` -------------------------------- ### Theme File Structure Example Source: https://github.com/anzhiyu-c/anheyu-docs/blob/main/content/docs/theme-development.mdx Illustrates the mandatory and recommended file and directory structure for a theme package. Ensure 'theme.json', 'index.html', and 'static/' are present. ```tree theme-name.zip ├── theme.json # 主题信息约定文件(必需) ├── index.html # 主题入口文件(必需) ├── static/ # 静态资源目录(必需) │ ├── css/ # 样式文件 │ │ ├── *.css # CSS文件 │ │ ├── *.scss # SCSS文件(可选) │ │ ├── *.sass # SASS文件(可选) │ │ └── *.less # LESS文件(可选) │ ├── js/ # 脚本文件 │ │ ├── *.js # JavaScript文件 │ │ ├── *.ts # TypeScript文件(可选) │ │ └── *.gz # 压缩文件(可选) │ ├── images/ # 图片资源 │ │ ├── *.jpg/.jpeg/.png/.gif/.webp/.svg # 图片文件 │ │ └── *.ico # 图标文件 │ └── fonts/ # 字体文件 │ └── *.ttf/.otf/.woff/.woff2/.eot # 字体文件 ├── preview.jpg # 主题预览图(推荐,用于商城展示) ├── screenshots/ # 截图目录(可选) │ ├── screenshot-1.jpg # 额外截图 │ └── screenshot-2.jpg # 额外截图 └── README.md # 说明文档(推荐) ``` -------------------------------- ### Docker Compose Quick Reference Source: https://github.com/anzhiyu-c/anheyu-docs/blob/main/content/docs/theming.mdx Steps to clone the repository, build the frontend, and start services using Docker Compose. Optionally, mount a static directory for static mode. ```bash git clone --recurse-submodules https://github.com/anzhiyu-c/anheyu-app.git cd anheyu-app make frontend-build # Build image and docker compose up as per main repository Makefile / Dockerfile ``` -------------------------------- ### Run Development Server Source: https://github.com/anzhiyu-c/anheyu-docs/blob/main/content/docs/theming.mdx Start the local development server to preview changes in real-time. The server typically runs on http://localhost:3000. ```bash pnpm run dev ``` -------------------------------- ### Run Anheyu Community Edition (Foreground) Source: https://github.com/anzhiyu-c/anheyu-docs/blob/main/content/docs/getting-started.mdx This command starts the Anheyu Community Edition directly in the foreground. It's recommended for the first use as it automatically creates the default configuration file and database if they don't exist. ```bash # 零配置直接运行 (推荐首次使用) ./anheyu # 首次运行时会看到类似输出: # 提示: 未找到 data/conf.ini,将创建默认配置文件。 # ✅ 已创建默认配置文件: data/conf.ini # 从 data/conf.ini 文件加载了默认配置。 # ✅ 配置加载器初始化完成。 # 【提示】SQLite 数据库路径: data/anheyu_app.db # ✅ Sqlite 数据库连接池创建成功! # 应用程序启动成功,正在监听端口: 8091 ``` -------------------------------- ### Start Anheyu with Docker Compose Source: https://github.com/anzhiyu-c/anheyu-docs/blob/main/content/docs/getting-started.mdx Run this command in the directory containing your docker-compose.yml file to start Anheyu in detached mode. ```bash docker compose up -d ``` -------------------------------- ### Enable and Manage Anheyu Systemd Service Source: https://github.com/anzhiyu-c/anheyu-docs/blob/main/content/docs/getting-started.mdx These bash commands are used to manage the Anheyu systemd service after creating the service file. They enable the service to start on boot, start the service immediately, and check its status. ```bash sudo systemctl daemon-reload sudo systemctl enable anheyu sudo systemctl start anheyu sudo systemctl status anheyu ``` -------------------------------- ### Nova Theme Full Configuration Example Source: https://github.com/anzhiyu-c/anheyu-docs/blob/main/content/docs/theme-config.mdx A comprehensive JSON structure detailing all settings for the Nova theme, including style, layout, and footer options. ```json { "name": "theme-anheyu-nova", "displayName": "Nova", "version": "2.0.0", "settings": [ { "group": "style", "label": "外观设置", "fields": [ { "name": "primaryColor", "label": "主题色", "type": "color", "default": "#3b82f6", "description": "网站的主要颜色" }, { "name": "defaultTheme", "label": "默认主题", "type": "select", "default": "system", "options": [ { "label": "跟随系统", "value": "system" }, { "label": "浅色模式", "value": "light" }, { "label": "深色模式", "value": "dark" } ], "description": "访客首次访问时使用的主题模式" }, { "name": "enableAnimation", "label": "启用动画", "type": "switch", "default": true, "description": "是否启用页面过渡动画效果" } ] }, { "group": "layout", "label": "布局设置", "fields": [ { "name": "sidebarPosition", "label": "侧边栏位置", "type": "select", "default": "right", "options": [ { "label": "左侧", "value": "left" }, { "label": "右侧", "value": "right" }, { "label": "隐藏", "value": "none" } ], "description": "文章页面侧边栏的显示位置" }, { "name": "articlesPerPage", "label": "每页文章数", "type": "number", "default": 10, "validation": { "min": 5, "max": 50, "message": "每页文章数应在 5-50 之间" }, "description": "文章列表每页显示的文章数量" } ] }, { "group": "footer", "label": "页脚设置", "fields": [ { "name": "showRuntime", "label": "显示运行时间", "type": "switch", "default": true, "description": "是否在页脚显示网站运行时间" }, { "name": "customFooterHtml", "label": "自定义页脚内容", "type": "textarea", "default": "", "placeholder": "支持 HTML 代码", "description": "在页脚添加自定义内容,如备案号、版权声明等" } ] } ] } ``` -------------------------------- ### Minimal Theme Configuration (theme.json) Source: https://github.com/anzhiyu-c/anheyu-docs/blob/main/content/docs/theme-development.mdx A basic example of a theme's configuration file (theme.json). It includes essential metadata like name, display name, version, description, author, license, category, keywords, and features. ```json { "name": "theme-minimal", "displayName": "极简主题", "version": "1.0.0", "description": "一个简洁优雅的博客主题", "author": { "name": "安知鱼", "email": "anzhiy@anheyu.com", "url": "https://anheyu.com" }, "license": "MIT", "category": "minimal", "keywords": ["简洁", "博客", "响应式"], "features": ["responsive-design", "dark-mode", "seo-friendly"] } ``` -------------------------------- ### Engines Field Example in theme.json Source: https://github.com/anzhiyu-c/anheyu-docs/blob/main/content/docs/theme-development.mdx Example of the 'engines' field in 'theme.json', specifying system version requirements for the theme. ```json "engines": { "anheyu": ">=1.0.0" } ``` -------------------------------- ### Check Node.js Version Source: https://github.com/anzhiyu-c/anheyu-docs/blob/main/content/docs/getting-started.mdx Verify that Node.js version 20.0.0 or higher is installed, which is required for the Next.js frontend. ```bash # 检查 Node.js 版本 node -v # 需要 v20.0.0 或更高 # 如果未安装,请参考 https://nodejs.org/ 安装 ``` -------------------------------- ### Features Field Example in theme.json Source: https://github.com/anzhiyu-c/anheyu-docs/blob/main/content/docs/theme-development.mdx Example of the 'features' field in 'theme.json', listing the supported functional characteristics of the theme. ```json "features": [ "responsive-design", "dark-mode", "seo-friendly", "customizable-colors" ] ``` -------------------------------- ### Environment Variable Password Configuration Source: https://github.com/anzhiyu-c/anheyu-docs/blob/main/content/docs/getting-started.mdx Example of creating a .env file to manage sensitive passwords for database and Redis in a production environment. ```bash ANHEYU_DATABASE_PASSWORD=你的数据库密码 ANHEYU_REDIS_PASSWORD=你的Redis密码 ``` -------------------------------- ### Example Theme Directory Structure Source: https://github.com/anzhiyu-c/anheyu-docs/blob/main/content/docs/theme-development.mdx Illustrates the allowed and disallowed directory structures for a theme. It highlights the importance of keeping files within the theme's root directory and avoiding malicious file types or paths. ```bash # 允许的目录结构 theme-name/ ├── theme.json ✅ 根目录配置文件 ├── index.html ✅ 根目录HTML文件 └── static/ ✅ 静态资源目录 ├── css/ ✅ 样式文件目录 ├── js/ ✅ 脚本文件目录 ├── images/ ✅ 图片资源目录 └── fonts/ ✅ 字体文件目录 # 禁止的目录结构 theme-name/ ├── ../config.php ❌ 路径遍历 ├── /etc/passwd ❌ 绝对路径 └── scripts/ └── malware.exe ❌ 可执行文件 ``` -------------------------------- ### Run Anheyu Community Edition with Docker Source: https://github.com/anzhiyu-c/anheyu-docs/blob/main/content/docs/getting-started.mdx This command starts the Anheyu community edition using Docker. It specifies the database path for persistence. Environment variables can be used to configure database type, Redis, and frontend URL. ```bash docker run -d \ -p 8090:8090 \ -e ANHEYU_DATABASE_PATH=/anheyu/data/anheyu.db \ anheyu/anheyu-backend:latest ``` -------------------------------- ### Build Anheyu Frontend and Backend Source: https://github.com/anzhiyu-c/anheyu-docs/blob/main/content/docs/getting-started.mdx These commands are used to build the Anheyu project after cloning the source code. It first installs Go module dependencies, then builds the Next.js frontend, and finally compiles the Go backend executable. ```bash # 安装 Go 模块依赖 go mod tidy # 构建 Next.js 前端 cd frontend npm ci npm run build cd .. # 构建后端项目 go build -ldflags="-s -w" -o anheyu-app main.go ``` -------------------------------- ### Run Anheyu Community Edition with Redis Source: https://github.com/anzhiyu-c/anheyu-docs/blob/main/content/docs/getting-started.mdx This command starts the Anheyu community edition container, using a separate Redis container. It maps ports, mounts volumes, and sets environment variables for SQLite database and Redis connection. ```bash # 启动 Redis docker run -d \ --name anheyu-redis \ -p 6379:6379 \ redis:latest # 启动 Anheyu(使用 Redis) docker run -d \ --name anheyu-app \ -p 8091:8091 \ -v ~/anheyu/data:/anheyu/data \ -v ~/anheyu/themes:/anheyu/themes \ -v ~/anheyu/static:/anheyu/static \ -v ~/anheyu/backup:/anheyu/backup \ -e ANHEYU_DATABASE_TYPE=sqlite \ -e ANHEYU_DATABASE_PATH=/anheyu/data/anheyu.db \ -e ANHEYU_REDIS_ADDR=host.docker.internal:6379 \ anheyu/anheyu-backend:latest ``` -------------------------------- ### Fetch Theme Configuration API Source: https://github.com/anzhiyu-c/anheyu-docs/blob/main/content/docs/theme-config.mdx Use this GET endpoint to retrieve the current theme's configuration values from the frontend. ```bash GET /api/public/theme/config ``` -------------------------------- ### Example API Response for Theme Config Source: https://github.com/anzhiyu-c/anheyu-docs/blob/main/content/docs/theme-config.mdx This JSON structure represents the data returned by the theme configuration API. ```json { "code": 200, "data": { "primaryColor": "#3b82f6", "defaultTheme": "system", "enableAnimation": true, "sidebarPosition": "right", "articlesPerPage": 10 } } ``` -------------------------------- ### Theme Update Flow Diagram Source: https://github.com/anzhiyu-c/anheyu-docs/blob/main/content/docs/theme-development.mdx Visualizes the process of uploading a theme, verifying files, detecting versions, and handling updates or new installations. ```mermaid graph TD A[上传主题] --> B[验证文件] B --> C[检测版本] C --> D{是否已存在?} D -->|否| E[新安装] D -->|是| F[版本比较] F --> G{版本更高?} G -->|是| H[询问用户更新] G -->|否| I[显示版本警告] H --> J[用户确认] J -->|确认| K[覆盖安装] J -->|取消| L[取消上传] ``` -------------------------------- ### Integrate Theme Config in Next.js App Source: https://github.com/anzhiyu-c/anheyu-docs/blob/main/content/docs/theme-config.mdx Example of fetching theme configuration and applying it to the HTML root element in a Next.js application. ```typescript // lib/api/services.ts export async function getThemeConfig() { const response = await fetch(`${API_BASE_URL}/api/public/theme/config`); const data = await response.json(); return data.data; } // app/layout.tsx export default async function RootLayout({ children }) { const themeConfig = await getThemeConfig(); return ( {children} ); } ``` -------------------------------- ### Run Anheyu Community Edition without Redis Source: https://github.com/anzhiyu-c/anheyu-docs/blob/main/content/docs/getting-started.mdx This command starts the Anheyu community edition container without a dedicated Redis instance, relying on in-memory caching. It maps ports, mounts volumes, and sets environment variables for SQLite database. ```bash # 启动 Anheyu(不配置 Redis) docker run -d \ --name anheyu-app \ -p 8091:8091 \ -v ~/anheyu/data:/anheyu/data \ -v ~/anheyu/themes:/anheyu/themes \ -v ~/anheyu/static:/anheyu/static \ -v ~/anheyu/backup:/anheyu/backup \ -e ANHEYU_DATABASE_TYPE=sqlite \ ``` -------------------------------- ### Pro Edition Docker Compose Configuration Source: https://github.com/anzhiyu-c/anheyu-docs/blob/main/content/docs/getting-started.mdx Example docker-compose.yml for the Pro edition, featuring a single container for backend and frontend, with PostgreSQL and Redis dependencies. Requires ANHEYU_LICENSE_KEY. ```yaml # 内置模式(推荐): Go + Next.js 单容器,只暴露 8091 即可 services: anheyu: image: anheyu/pro:latest container_name: anheyu-backend depends_on: anheyu_postgresql: condition: service_healthy anheyu_redis: condition: service_healthy restart: always ports: - 8091:8091 environment: - ANHEYU_DATABASE_TYPE=postgres - ANHEYU_DATABASE_HOST=anheyu_postgresql - ANHEYU_DATABASE_USER=anheyu - ANHEYU_DATABASE_NAME=anheyu - ANHEYU_DATABASE_PORT=5432 - ANHEYU_DATABASE_PASSWORD=${ANHEYU_DATABASE_PASSWORD:-} - ANHEYU_REDIS_ADDR=anheyu_redis:6379 - ANHEYU_REDIS_DB=0 - ANHEYU_LICENSE_KEY=${ANHEYU_LICENSE_KEY} # 不设置 ANHEYU_FRONTEND_URL = 使用内置 Next.js(推荐) # 若用独立前端容器可设: ANHEYU_FRONTEND_URL=http://anheyu-frontend:3000 # - ANHEYU_FRONTEND_URL=${ANHEYU_FRONTEND_URL:-} ``` -------------------------------- ### Clone Frontend Source Code Source: https://github.com/anzhiyu-c/anheyu-docs/blob/main/content/docs/theming.mdx Clone the main application repository, ensuring submodules are included to get the frontend source code. Navigate into the frontend directory. ```bash git clone --recurse-submodules https://github.com/anzhiyu-c/anheyu-app.git cd anheyu-app/frontend ``` -------------------------------- ### Community Edition Docker Compose Configuration Source: https://github.com/anzhiyu-c/anheyu-docs/blob/main/content/docs/getting-started.mdx Example docker-compose.yml for the community edition, including Anheyu backend, PostgreSQL, and optional Redis. Ensure to configure passwords via environment variables or a .env file for production. ```yaml services: anheyu: image: anheyu/anheyu-backend:latest container_name: anheyu-backend depends_on: - anheyu_postgresql # Redis 是可选的,如果不需要可以注释掉下面这行 - anheyu_redis restart: always ports: - 8091:8091 environment: - ANHEYU_DATABASE_TYPE=postgres - ANHEYU_DATABASE_HOST=anheyu_postgresql - ANHEYU_DATABASE_USER=anheyu - ANHEYU_DATABASE_NAME=anheyu - ANHEYU_DATABASE_PORT=5432 - ANHEYU_DATABASE_PASSWORD=${ANHEYU_DATABASE_PASSWORD:-changeme} # Redis 配置(可选) # 如果想使用 Redis,保持下面两行;如果不想使用,注释掉即可 # 不配置时应用会自动降级到内存缓存 - ANHEYU_REDIS_ADDR=anheyu_redis:6379 - ANHEYU_REDIS_PASSWORD=${ANHEYU_REDIS_PASSWORD:-changeme} # 前端配置(可选,v1.8.0+) # 默认使用内置 Next.js 前端,无需配置 # 如需指向独立部署的前端服务,取消注释下面这行 # - ANHEYU_FRONTEND_URL=http://your-frontend:3000 volumes: - ./data:/anheyu/data - ./themes:/anheyu/themes - ./static:/anheyu/static - ./backup:/anheyu/backup anheyu_postgresql: image: postgres:17 container_name: anheyu_postgresql expose: - "5432" environment: - POSTGRES_USER=anheyu - POSTGRES_DB=anheyu - POSTGRES_PASSWORD=${ANHEYU_DATABASE_PASSWORD:-changeme} volumes: - database_postgres:/var/lib/postgresql/data # Redis 服务(可选) # 如果不需要 Redis,可以注释掉整个 anheyu_redis 服务 anheyu_redis: image: redis:latest container_name: anheyu_redis command: > redis-server --requirepass ${ANHEYU_REDIS_PASSWORD:-changeme} expose: - "6379" volumes: - redis_data:/data volumes: database_postgres: redis_data: ``` -------------------------------- ### Run Anheyu Pro in Foreground Source: https://github.com/anzhiyu-c/anheyu-docs/blob/main/content/docs/getting-started.mdx Use this method for zero-configuration startup with a license key. It automatically creates configuration files and databases on the first run. Other methods include using environment variables. ```bash # Zero-configuration startup for Pro version (recommended) ./anheyu --license-key "your license key" # On first run, you will see output similar to: # Hint: data/conf.ini not found, default configuration will be created. # ✅ Default configuration created: data/conf.ini # Default configuration loaded from data/conf.ini file. # ✅ Configuration loader initialized. # 【Hint】SQLite database path: data/anheyu_app.db # ✅ Sqlite database connection pool created successfully! # Application started successfully, listening on port: 8091 # Other startup methods: # Method 2: Using environment variables export ANHEYU_LICENSE_KEY=your license key ./anheyu # Method 3: Set environment variable and run on the same line ANHEYU_LICENSE_KEY=your license key ./anheyu ``` -------------------------------- ### Binary File Deployment Quick Reference Source: https://github.com/anzhiyu-c/anheyu-docs/blob/main/content/docs/theming.mdx Instructions for running an application deployed as a binary file. Ensure the frontend directory is included in the release package. Environment variables can be used to specify frontend and static directories or URLs. ```bash # The release package must include frontend/ (with .next/standalone) alongside the binary cd ~/anheyu ./anheyu ``` -------------------------------- ### Run Anheyu Pro Edition with License Key (Command Line) Source: https://github.com/anzhiyu-c/anheyu-docs/blob/main/content/docs/getting-started.mdx This command demonstrates how to run the Anheyu Pro Edition with a license key provided as a command-line argument. This method is recommended for setting the license key. ```bash # Example command (replace with actual license key and path) ./anheyu --license-key YOUR_LICENSE_KEY ``` -------------------------------- ### Run Anheyu with Custom Frontend (Binary Deployment) Source: https://github.com/anzhiyu-c/anheyu-docs/blob/main/content/docs/theming.mdx Run the Anheyu binary application. Ensure the custom frontend directory, including the standalone build, is present in the deployment directory or specified via ANHEYU_FRONTEND_DIR. ```bash cd ~/anheyu # 目录中应有:anheyu、frontend/.next/standalone/... ./anheyu ``` -------------------------------- ### 前端获取主题配置 API Source: https://github.com/anzhiyu-c/anheyu-docs/blob/main/content/docs/ssr-theme-deploy.mdx 展示了用于在前端获取主题配置的 GET 请求接口及其返回示例。 ```bash GET /api/public/theme/config ``` ```json { "code": 200, "data": { "primaryColor": "#3b82f6", "defaultTheme": "system", "enableAnimation": true, "sidebarPosition": "right", "articlesPerPage": 10 } } ``` -------------------------------- ### Unordered List Source: https://github.com/anzhiyu-c/anheyu-docs/blob/main/content/docs/article-editor.mdx Create bulleted lists for non-sequential items. Each item starts with a hyphen or asterisk. ```markdown - So even though we face the difficulties of today and tomorrow, I still have a dream. - It is a dream deeply rooted in the American dream. - I have a dream that one day this nation will rise up. ``` -------------------------------- ### Ordered List Source: https://github.com/anzhiyu-c/anheyu-docs/blob/main/content/docs/article-editor.mdx Create numbered lists for sequential items. Each item starts with a number followed by a period. ```markdown 1. So even though we face the difficulties of today and tomorrow, I still have a dream. 2. It is a dream deeply rooted in the American dream. 3. I have a dream that one day this nation will rise up. ``` -------------------------------- ### Create Anheyu Working Directory and Move Binary Source: https://github.com/anzhiyu-c/anheyu-docs/blob/main/content/docs/getting-started.mdx Optional steps to create a dedicated directory for Anheyu and move the downloaded binary into it. The data directory will be created automatically on first run. ```bash # 可选:创建专门的安装目录 mkdir -p ~/anheyu cd ~/anheyu # 移动二进制文件到工作目录 mv /path/to/downloaded/anheyu-* ./anheyu # 注意:data 目录会在首次运行时自动创建 ``` -------------------------------- ### Run Anheyu Pro Edition with License Key (Environment Variable) Source: https://github.com/anzhiyu-c/anheyu-docs/blob/main/content/docs/getting-started.mdx This method shows how to run the Anheyu Pro Edition by setting the license key via an environment variable. The license key is specified as `ANHEYU_LICENSE_KEY`. ```bash # Example command (replace with actual license key) export ANHEYU_LICENSE_KEY=YOUR_LICENSE_KEY ./anheyu ``` -------------------------------- ### Theme Status Types Source: https://github.com/anzhiyu-c/anheyu-docs/blob/main/content/docs/theme-development.mdx Defines the different status types for installed themes, indicated by specific flags and visual cues. ```bash # 主题状态类型 - 当前使用 (is_current: true) - 绿色标识 - 已安装 (is_installed: true) - 普通显示 - 官方主题 (isOfficial: true) - 特殊标识 ``` -------------------------------- ### Build Custom Frontend and Backend (Source Deployment) Source: https://github.com/anzhiyu-c/anheyu-docs/blob/main/content/docs/theming.mdx Build the custom Next.js frontend and then compile the backend Go application from source. Ensure the frontend directory is preserved for runtime. ```bash cd /path/to/anheyu-app make frontend-build go build -ldflags="-s -w" -o anheyu-app . ./anheyu-app ``` -------------------------------- ### Download and Run Anheyu Community Edition (Linux AMD64) Source: https://github.com/anzhiyu-c/anheyu-docs/blob/main/content/docs/getting-started.mdx This command downloads the Anheyu community edition binary for Linux AMD64, makes it executable, and runs it. The application will automatically create configuration and database files. ```bash # 下载并运行(以 Linux AMD64 为例) wget https://github.com/anzhiyu-c/anheyu-app/releases/latest/download/anheyu-app-linux-amd64 chmod +x anheyu-app-linux-amd64 ./anheyu-app-linux-amd64 # 应用将自动: # ✅ 创建 data/conf.ini 配置文件(使用 SQLite) # ✅ 创建 data/anheyu_app.db 数据库文件 # ✅ 启动服务在 http://localhost:8091 ``` -------------------------------- ### Create Data Directories Source: https://github.com/anzhiyu-c/anheyu-docs/blob/main/content/docs/getting-started.mdx Use these commands to create the necessary data directories for Anheyu. ```bash # 创建必要的目录 mkdir -p data/storage data/temp # 复制默认文件 (如果希望有的话可以用,一般不需要) cp -r default_files/* data/ ``` -------------------------------- ### Restart Binary File Application Source: https://github.com/anzhiyu-c/anheyu-docs/blob/main/content/docs/theming.mdx Instructions for restarting applications deployed as binary files. Covers both foreground and background execution, as well as systemd service management. Verify startup by checking logs. ```bash # If running in the foreground: Stop with Ctrl+C, then restart ./anheyu ``` ```bash # If running in the background: # Stop the application pkill anheyu # Restart nohup ./anheyu > ./data/anheyu.log 2>&1 & # Check process status ps aux | grep anheyu ``` ```bash # Restart service sudo systemctl restart anheyu # View service status sudo systemctl status anheyu # View service logs sudo journalctl -u anheyu -f ``` ```bash tail -f ./data/anheyu.log ``` -------------------------------- ### Theme Name Validation Regex Source: https://github.com/anzhiyu-c/anheyu-docs/blob/main/content/docs/theme-development.mdx Use this regex to validate theme names. It ensures the name starts with 'theme-' and contains only lowercase letters, numbers, and hyphens. ```regex ^theme-[a-z0-9\-]+$ ``` -------------------------------- ### Configure Anheyu Pro as a Systemd Service Source: https://github.com/anzhiyu-c/anheyu-docs/blob/main/content/docs/getting-started.mdx Set up Anheyu Pro to run as a systemd service for robust background operation. Two methods are provided: using command-line arguments or environment variables for the license key. Ensure correct file permissions for security. ```ini [Unit] Description=Anheyu Pro Service After=network.target [Service] Type=simple User=anheyu WorkingDirectory=/home/anheyu/anheyu ExecStart=/home/anheyu/anheyu/anheyu --license-key "your license key" Restart=always RestartSec=3 [Install] WantedBy=multi-user.target ``` ```ini [Unit] Description=Anheyu Pro Service After=network.target [Service] Type=simple User=anheyu WorkingDirectory=/home/anheyu/anheyu Environment=ANHEYU_LICENSE_KEY=your license key ExecStart=/home/anheyu/anheyu/anheyu Restart=always RestartSec=3 [Install] WantedBy=multi-user.target ``` ```bash sudo systemctl daemon-reload sudo systemctl enable anheyu sudo systemctl start anheyu sudo systemctl status anheyu ``` ```bash sudo chmod 600 /etc/systemd/system/anheyu.service ``` -------------------------------- ### Modify Theme Colors Source: https://github.com/anzhiyu-c/anheyu-docs/blob/main/content/docs/theming.mdx Customize theme colors by editing CSS variables in global styles or Tailwind CSS configuration files. This example shows how to change the primary theme color. ```css :root { --anzhiyu-theme: #163bf2; --anzhiyu-theme-op: #4259ef23; --anzhiyu-theme-op-deep: #4259efdd; --anzhiyu-theme-op-light: #4259ef0d; } ``` -------------------------------- ### Make Pro Edition Binary Executable Source: https://github.com/anzhiyu-c/anheyu-docs/blob/main/content/docs/getting-started.mdx After downloading the Pro edition binary, use this command to add execute permissions. ```bash chmod +x anheyu-pro-* ``` -------------------------------- ### Run Anheyu with Static Mount (Docker) Source: https://github.com/anzhiyu-c/anheyu-docs/blob/main/content/docs/theming.mdx Run the Anheyu Docker container, mounting a local directory as the static assets volume. This is for deploying a custom static site. ```bash mkdir -p ~/anheyu/static docker run -d \ --name anheyu-app \ -p 8091:8091 \ -v ~/anheyu/data:/anheyu/data \ -v ~/anheyu/static:/anheyu/static \ anheyu/anheyu-backend:latest ``` -------------------------------- ### Prepare Static Directory (Docker Compose) Source: https://github.com/anzhiyu-c/anheyu-docs/blob/main/content/docs/theming.mdx Prepare a directory on the host machine to be mounted as the static assets volume for Docker Compose deployments. This is used for the static site mode. ```bash mkdir -p ~/anheyu/static ``` -------------------------------- ### Run Anheyu Pro with PostgreSQL and Redis Source: https://github.com/anzhiyu-c/anheyu-docs/blob/main/content/docs/getting-started.mdx This command deploys Anheyu Pro using Docker, requiring PostgreSQL for database and Redis for caching. Ensure PostgreSQL and Redis are running and accessible. Replace '你的授权密钥' with your actual license key. ```bash # 启动 PostgreSQL(使用 pgvector 镜像以支持向量搜索) docker run -d \ --name anheyu-postgres \ -e POSTGRES_USER=anheyu \ -e POSTGRES_DB=anheyu \ -e POSTGRES_HOST_AUTH_METHOD=trust \ -v anheyu_pgdata:/var/lib/postgresql/data \ -p 5432:5432 \ pgvector/pgvector:pg17 # 启动 Redis docker run -d \ --name anheyu-redis \ -p 6379:6379 \ redis:7.2-alpine # 启动 Anheyu Pro(使用 Redis) docker run -d \ --name anheyu-pro \ -p 8091:8091 \ -v ~/anheyu/data:/anheyu/data \ -v ~/anheyu/themes:/anheyu/themes \ -v ~/anheyu/static:/anheyu/static \ -v ~/anheyu/backup:/anheyu/backup \ -e ANHEYU_DATABASE_TYPE=postgres \ -e ANHEYU_DATABASE_HOST=host.docker.internal \ -e ANHEYU_DATABASE_USER=anheyu \ -e ANHEYU_DATABASE_NAME=anheyu \ -e ANHEYU_DATABASE_PORT=5432 \ -e ANHEYU_DATABASE_PASSWORD= \ -e ANHEYU_REDIS_ADDR=host.docker.internal:6379 \ -e ANHEYU_REDIS_DB=0 \ -e ANHEYU_LICENSE_KEY=你的授权密钥 \ anheyu/pro:latest ``` -------------------------------- ### Create Data Directory for Docker Source: https://github.com/anzhiyu-c/anheyu-docs/blob/main/content/docs/getting-started.mdx Before running Anheyu with Docker, create the necessary data directory on your host machine. ```bash mkdir -p ~/anheyu/data ``` -------------------------------- ### Update Anheyu from Source Code Source: https://github.com/anzhiyu-c/anheyu-docs/blob/main/content/docs/getting-started.mdx Follow these steps to update Anheyu when deploying from source. This includes pulling the latest code, updating dependencies, building the frontend, and recompiling the binary. ```bash # 1. Get the latest code git pull origin main # 2. Update dependencies go mod tidy # 3. Build Next.js frontend cd frontend npm ci npm run build cd .. # 4. Rebuild the binary go build -ldflags="-s -w" -o anheyu-app main.go # 5. Restart the application (example) pkill anheyu-app # or systemctl restart anheyu nohup ./anheyu-app > anheyu.log 2>&1 & ``` -------------------------------- ### Run Anheyu Pro with PostgreSQL (No Redis) Source: https://github.com/anzhiyu-c/anheyu-docs/blob/main/content/docs/getting-started.mdx This command deploys Anheyu Pro using Docker with PostgreSQL but without Redis. It will automatically fall back to in-memory caching. Ensure PostgreSQL is running and accessible. Replace '你的授权密钥' with your actual license key. ```bash # 启动 PostgreSQL docker run -d \ --name anheyu-postgres \ -e POSTGRES_USER=anheyu \ -e POSTGRES_DB=anheyu \ -e POSTGRES_HOST_AUTH_METHOD=trust \ -v anheyu_pgdata:/var/lib/postgresql/data \ -p 5432:5432 \ pgvector/pgvector:pg17 # 启动 Anheyu Pro(不配置 Redis) docker run -d \ --name anheyu-pro \ -p 8091:8091 \ -v ~/anheyu/data:/anheyu/data \ -v ~/anheyu/themes:/anheyu/themes \ -v ~/anheyu/static:/anheyu/static \ -v ~/anheyu/backup:/anheyu/backup \ -e ANHEYU_DATABASE_TYPE=postgres \ -e ANHEYU_DATABASE_HOST=host.docker.internal \ -e ANHEYU_DATABASE_USER=anheyu \ -e ANHEYU_DATABASE_NAME=anheyu \ -e ANHEYU_DATABASE_PORT=5432 \ -e ANHEYU_DATABASE_PASSWORD= \ -e ANHEYU_LICENSE_KEY=你的授权密钥 \ anheyu/pro:latest ``` -------------------------------- ### Docker Single Container Quick Reference Source: https://github.com/anzhiyu-c/anheyu-docs/blob/main/content/docs/theming.mdx Commands for running a single Docker container. This includes options for customizing Next.js or using a static mount. Ensure data and static directories are correctly mounted. ```bash # Customize Next: local make frontend-build then docker build, or use ANHEYU_FRONTEND_URL # Optional static mount: mkdir -p ~/anheyu/static docker run -d --name anheyu-app -p 8091:8091 \ -v ~/anheyu/data:/anheyu/data \ -v ~/anheyu/static:/anheyu/static \ anheyu/anheyu-backend:latest ``` -------------------------------- ### Update Anheyu using Binary Files Source: https://github.com/anzhiyu-c/anheyu-docs/blob/main/content/docs/getting-started.mdx Instructions for updating Anheyu by downloading and replacing the official pre-built executable. This involves stopping the current application, backing it up, downloading the new version, and restarting. ```bash # 1. Stop the current running application pkill anheyu # or sudo systemctl stop anheyu # 2. Backup the current version cp anheyu anheyu.backup # 3. Download new version and replace (choose appropriate package for your platform) wget -O anheyu https://github.com/anzhiyu-c/anheyu-app/releases/latest/download/anheyu-app-linux-amd64 chmod +x anheyu # 4. Restart ./anheyu # or sudo systemctl start anheyu ``` -------------------------------- ### 导出和使用自定义静态资源 Source: https://github.com/anzhiyu-c/anheyu-docs/blob/main/content/docs/configuration.mdx 使用 `--export-assets` 参数导出内置静态资源,并配置 Docker 卷挂载以使用自定义资源。 ```bash # 社区版 ./anheyu-app --export-assets ./static # Pro 版(无需授权码) ./anheyu-pro --export-assets ./static ``` ```yaml # docker-compose.yml volumes: - ./static:/anheyu/static ``` -------------------------------- ### Configure Anheyu as a Systemd Service Source: https://github.com/anzhiyu-c/anheyu-docs/blob/main/content/docs/getting-started.mdx This configuration file sets up Anheyu as a systemd service. It defines the service's description, dependencies, execution commands, and restart policies, suitable for production environments. ```ini [Unit] Description=Anheyu Service After=network.target [Service] Type=simple User=anheyu WorkingDirectory=/home/anheyu/anheyu ExecStart=/home/anheyu/anheyu/anheyu Restart=always RestartSec=3 [Install] WantedBy=multi-user.target ``` -------------------------------- ### 描边样式按钮 Source: https://github.com/anzhiyu-c/anheyu-docs/blob/main/content/docs/article-editor.mdx 使用 style=outline 参数创建描边样式的按钮。 ```markdown {btn url=# text=描边按钮 style=outline color=blue}{/btn} ``` -------------------------------- ### Configure Static Volume Mount (Docker Compose) Source: https://github.com/anzhiyu-c/anheyu-docs/blob/main/content/docs/theming.mdx Configure the Docker Compose file to mount the prepared static directory into the Anheyu service. This enables the static site mode. ```yaml services: anheyu: volumes: - ./data:/anheyu/data - ./static:/anheyu/static ``` -------------------------------- ### Build Production Version Source: https://github.com/anzhiyu-c/anheyu-docs/blob/main/content/docs/theming.mdx After completing custom modifications, build the production-ready version of the frontend. This generates standalone artifacts for deployment. ```bash pnpm run build ``` -------------------------------- ### Download Anheyu Community Edition Binaries Source: https://github.com/anzhiyu-c/anheyu-docs/blob/main/content/docs/getting-started.mdx Provides download commands for Anheyu community edition binaries across different operating systems and architectures. ```bash # Linux AMD64 wget https://github.com/anzhiyu-c/anheyu-app/releases/latest/download/anheyu-app-linux-amd64 chmod +x anheyu-app-linux-amd64 # Linux ARM64 wget https://github.com/anzhiyu-c/anheyu-app/releases/latest/download/anheyu-app-linux-arm64 chmod +x anheyu-app-linux-arm64 # macOS Intel wget https://github.com/anzhiyu-c/anheyu-app/releases/latest/download/anheyu-app-darwin-amd64 chmod +x anheyu-app-darwin-amd64 # macOS Apple Silicon wget https://github.com/anzhiyu-c/anheyu-app/releases/latest/download/anheyu-app-darwin-arm64 chmod +x anheyu-app-darwin-arm64 ``` -------------------------------- ### Create Docker Compose Directory Source: https://github.com/anzhiyu-c/anheyu-docs/blob/main/content/docs/getting-started.mdx Create a directory to store your Docker Compose file and navigate into it. ```bash mkdir -p ~/anheyu cd ~/anheyu ``` -------------------------------- ### Update Anheyu Pro Application Source: https://github.com/anzhiyu-c/anheyu-docs/blob/main/content/docs/getting-started.mdx Instructions for updating Anheyu Pro to the latest version. This involves stopping the current application, backing up the existing binary, downloading the new version, making it executable, and restarting the application. ```bash # Stop the currently running application pkill anheyu # or sudo systemctl stop anheyu # Backup the current version cp anheyu anheyu.backup # Download the new version and replace wget -O anheyu https://github.com/anzhiyu-c/anheyu-app/releases/latest/download/anheyu-app-linux-amd64 chmod +x anheyu # Restart ./anheyu # or sudo systemctl start anheyu ``` -------------------------------- ### Tip Box Basic Usage (Hover) Source: https://github.com/anzhiyu-c/anheyu-docs/blob/main/content/docs/article-editor.mdx Create a basic tip box that displays content on mouse hover. This is ideal for providing supplementary information without cluttering the main content. ```markdown {tip text=鼠标悬停提示 content=这是一个基础的悬停提示}{/tip} ``` -------------------------------- ### 默认展开的折叠框 Source: https://github.com/anzhiyu-c/anheyu-docs/blob/main/content/docs/article-editor.mdx 在 :::folding 后添加 open 参数,使折叠框默认展开。 ```markdown :::folding open 默认展开的折叠框 这个折叠框默认是展开状态。 ::: ``` -------------------------------- ### Clone Repository with Submodules Source: https://github.com/anzhiyu-c/anheyu-docs/blob/main/README.md Clone the AnHeYu App repository, ensuring all Git submodules (like the frontend) are included. Use this command if you are cloning the project for the first time. ```bash git clone --recurse-submodules https://github.com/anzhiyu-c/anheyu-app.git cd anheyu-app ``` -------------------------------- ### Tip Block Source: https://github.com/anzhiyu-c/anheyu-docs/blob/main/content/docs/article-editor.mdx Highlight tips or suggestions using the `!!! tip` syntax. This is for helpful advice or best practices. ```markdown !!! tip 提示 这是「提示」样式。 !!! ``` -------------------------------- ### 行内隐藏内容 Source: https://github.com/anzhiyu-c/anheyu-docs/blob/main/content/docs/article-editor.mdx 使用 {hide} 和 {/hide} 标签包裹行内需要隐藏的内容,并通过 display 参数控制按钮文字。 ```markdown 这是一段文字,{hide display=查看}这部分内容被隐藏了{/hide},点击按钮查看。 自定义颜色:{hide display=答案 bg=#42b983 color=#fff}正确答案是 42{/hide} ``` -------------------------------- ### Task List Source: https://github.com/anzhiyu-c/anheyu-docs/blob/main/content/docs/article-editor.mdx Create lists with checkboxes for tracking tasks. Use `[ ]` for unchecked and `[x]` for checked items. ```markdown - [ ] 周五 - [ ] 周六 - [x] 周天 ``` -------------------------------- ### Docker Compose 配置 Source: https://github.com/anzhiyu-c/anheyu-docs/blob/main/content/docs/configuration.mdx 在 Docker Compose 文件中配置 Anheyu 服务。确保与 Nginx 等反向代理的集成配置正确。 ```yaml # docker-compose.yml services: anheyu: image: anheyu/anheyu-app:latest ports: - "8080:8080" # ...其他配置 ``` -------------------------------- ### 块级布局按钮 Source: https://github.com/anzhiyu-c/anheyu-docs/blob/main/content/docs/article-editor.mdx 使用 layout=block 参数使按钮占据整行宽度,并可通过 position 参数控制对齐方式。 ```markdown {btn url=# text=块级按钮 layout=block}{/btn} {btn url=# text=居中按钮 layout=block position=center}{/btn} {btn url=# text=右对齐按钮 layout=block position=right}{/btn} ``` -------------------------------- ### Build Custom Next.js Frontend (Docker Compose) Source: https://github.com/anzhiyu-c/anheyu-docs/blob/main/content/docs/theming.mdx Build the custom Next.js frontend within the main repository for Docker Compose deployments. This command should be run in the repository root. ```bash cd /path/to/anheyu-app make frontend-build ``` -------------------------------- ### Select Dropdown Configuration Source: https://github.com/anzhiyu-c/anheyu-docs/blob/main/content/docs/theme-config.mdx Configure a select dropdown for theme settings, allowing users to choose from predefined options. The 'value' is stored. ```json { "name": "defaultTheme", "label": "默认主题", "type": "select", "default": "system", "options": [ { "label": "跟随系统", "value": "system" }, { "label": "浅色模式", "value": "light" }, { "label": "深色模式", "value": "dark" } ] } ``` -------------------------------- ### 基础按钮 Source: https://github.com/anzhiyu-c/anheyu-docs/blob/main/content/docs/article-editor.mdx 使用 {btn} 标签创建按钮,通过 url 和 text 参数指定链接和按钮文字。 ```markdown {btn url=https://blog.anheyu.com text=访问博客}{/btn} ```