<?xml version="1.0" encoding="utf-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" version="2.0"><channel><title>Chen’Blog</title><link>https://blog.smallhao.fun/</link><description>道阻且长，行则将至；行而不辍，未来可期</description><item><title>Claude Code常用MCP、Skill</title><link>https://blog.smallhao.fun/?id=53</link><description>&lt;head&gt;&lt;/head&gt;&lt;body&gt;&lt;h1 id=&quot;h1-Claude20Code20u5E38u752820MCPu3001Skill20u5168u6307u5357-1&quot;&gt;&lt;a class=&quot;reference-link&quot; name=&quot;Claude Code 常用 MCP、Skill 全指南&quot;&gt;&lt;/a&gt;&lt;span class=&quot;header-link octicon octicon-link&quot;&gt;&lt;/span&gt;Claude Code 常用 MCP、Skill 全指南&lt;/h1&gt;&lt;h2 id=&quot;h2-uD83CuDFAF20u4F60u7684u5168u6808u5F00u53D1u5DE5u4F5Cu6D41-3&quot;&gt;&lt;a class=&quot;reference-link&quot; name=&quot;🎯 你的全栈开发工作流&quot;&gt;&lt;/a&gt;&lt;span class=&quot;header-link octicon octicon-link&quot;&gt;&lt;/span&gt;🎯 你的全栈开发工作流&lt;/h2&gt;&lt;p&gt;作为一名全栈开发工程师，你的工作流可以拆分为 &lt;strong&gt;5 个阶段&lt;/strong&gt;：&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;原型图设计 → 前后端代码编写 → 部署上线 → AI浏览器排查问题 → 文档输出
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Claude Code 的扩展生态（&lt;strong&gt;MCP&lt;/strong&gt;、&lt;strong&gt;Skill&lt;/strong&gt;、&lt;strong&gt;LSP&lt;/strong&gt;、&lt;strong&gt;Hook&lt;/strong&gt;）可以在这 5 个阶段的每一个环节提供自动化辅助。本文整理了 &lt;strong&gt;59 个常用插件&lt;/strong&gt;，按你的工作流阶段进行筛选和匹配，标注了每个插件的相关性等级，并包含详细的用途介绍、安装命令、官网地址和 CC Switch 配置方式。&lt;/p&gt;&lt;p style=&quot;text-align: center;&quot;&gt;&lt;img src=&quot;https://blog.smallhao.fun/zb_users/upload/zltheme_20260520/563979e87ef5839594f500b712628415.jpg&quot; alt=&quot;Claude Code常用MCP、Skill&quot; /&gt;&lt;/p&gt;
&lt;blockquote&gt;&lt;p&gt;💡 &lt;strong&gt;相关性等级说明&lt;/strong&gt;：★ 核心必备（6 个）→ ☆ 强烈推荐（13 个）→ △ 按需选择（40 个）&lt;/p&gt;
&lt;/blockquote&gt;&lt;hr&gt;
&lt;h2 id=&quot;h2-uD83DuDCCA20u5DE5u4F5Cu6D4120D720u63D2u4EF6u5339u914Du5168u89C8-17&quot;&gt;&lt;a class=&quot;reference-link&quot; name=&quot;📊 工作流 × 插件匹配全览&quot;&gt;&lt;/a&gt;&lt;span class=&quot;header-link octicon octicon-link&quot;&gt;&lt;/span&gt;📊 工作流 × 插件匹配全览&lt;/h2&gt;&lt;p&gt;下表帮你快速判断每个插件在工作流中的位置和重要性：&lt;/p&gt;
&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;插件名&lt;/th&gt;
&lt;th&gt;类型&lt;/th&gt;
&lt;th&gt;适用阶段&lt;/th&gt;
&lt;th&gt;相关性&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Context7&lt;/td&gt;
&lt;td&gt;MCP&lt;/td&gt;
&lt;td&gt;前后端编码&lt;/td&gt;
&lt;td&gt;★ 核心&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Sequential Thinking&lt;/td&gt;
&lt;td&gt;MCP&lt;/td&gt;
&lt;td&gt;全局（推理分析）&lt;/td&gt;
&lt;td&gt;★ 核心&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Playwright&lt;/td&gt;
&lt;td&gt;MCP&lt;/td&gt;
&lt;td&gt;排查问题 + 测试&lt;/td&gt;
&lt;td&gt;★ 核心&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Frontend Design&lt;/td&gt;
&lt;td&gt;Skill&lt;/td&gt;
&lt;td&gt;原型设计 + 前端&lt;/td&gt;
&lt;td&gt;★ 核心&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Feature Dev&lt;/td&gt;
&lt;td&gt;Skill&lt;/td&gt;
&lt;td&gt;前后端编码 + 文档&lt;/td&gt;
&lt;td&gt;★ 核心&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Planning with Files&lt;/td&gt;
&lt;td&gt;Skill&lt;/td&gt;
&lt;td&gt;全局（任务管理）+ 文档&lt;/td&gt;
&lt;td&gt;★ 核心&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Figma&lt;/td&gt;
&lt;td&gt;MCP+Skill&lt;/td&gt;
&lt;td&gt;原型设计&lt;/td&gt;
&lt;td&gt;☆ 推荐&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;GitHub&lt;/td&gt;
&lt;td&gt;MCP&lt;/td&gt;
&lt;td&gt;前后端编码&lt;/td&gt;
&lt;td&gt;☆ 推荐&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Serena&lt;/td&gt;
&lt;td&gt;MCP&lt;/td&gt;
&lt;td&gt;前后端编码&lt;/td&gt;
&lt;td&gt;☆ 推荐&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Superpowers&lt;/td&gt;
&lt;td&gt;Skill&lt;/td&gt;
&lt;td&gt;前后端编码&lt;/td&gt;
&lt;td&gt;☆ 推荐&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;PR Review Toolkit&lt;/td&gt;
&lt;td&gt;Skill+Agent&lt;/td&gt;
&lt;td&gt;前后端编码（评审）&lt;/td&gt;
&lt;td&gt;☆ 推荐&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Semgrep&lt;/td&gt;
&lt;td&gt;MCP+Skill+Hook&lt;/td&gt;
&lt;td&gt;前后端编码（安全）&lt;/td&gt;
&lt;td&gt;☆ 推荐&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Sentry&lt;/td&gt;
&lt;td&gt;MCP+Skill&lt;/td&gt;
&lt;td&gt;排查问题 + 监控&lt;/td&gt;
&lt;td&gt;☆ 推荐&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Vercel&lt;/td&gt;
&lt;td&gt;Skill&lt;/td&gt;
&lt;td&gt;部署上线&lt;/td&gt;
&lt;td&gt;☆ 推荐&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Code Review&lt;/td&gt;
&lt;td&gt;Skill&lt;/td&gt;
&lt;td&gt;前后端编码（评审）&lt;/td&gt;
&lt;td&gt;☆ 推荐&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Commit Commands&lt;/td&gt;
&lt;td&gt;Skill&lt;/td&gt;
&lt;td&gt;前后端编码（Git）&lt;/td&gt;
&lt;td&gt;☆ 推荐&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Security Guidance&lt;/td&gt;
&lt;td&gt;Hook&lt;/td&gt;
&lt;td&gt;前后端编码（安全）&lt;/td&gt;
&lt;td&gt;☆ 推荐&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Ralph Loop&lt;/td&gt;
&lt;td&gt;Skill+Hook&lt;/td&gt;
&lt;td&gt;前后端编码（迭代）&lt;/td&gt;
&lt;td&gt;☆ 推荐&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Hookify&lt;/td&gt;
&lt;td&gt;Skill+Agent+Hook&lt;/td&gt;
&lt;td&gt;全局（自动化）&lt;/td&gt;
&lt;td&gt;☆ 推荐&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Postman&lt;/td&gt;
&lt;td&gt;MCP+Skill+Agent&lt;/td&gt;
&lt;td&gt;后端（API开发）&lt;/td&gt;
&lt;td&gt;△ 按技术栈&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Supabase&lt;/td&gt;
&lt;td&gt;MCP&lt;/td&gt;
&lt;td&gt;后端（数据库）+ 部署&lt;/td&gt;
&lt;td&gt;△ 按技术栈&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Firebase&lt;/td&gt;
&lt;td&gt;MCP&lt;/td&gt;
&lt;td&gt;后端 + 部署&lt;/td&gt;
&lt;td&gt;△ 按技术栈&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Pinecone&lt;/td&gt;
&lt;td&gt;MCP+Skill&lt;/td&gt;
&lt;td&gt;后端（向量数据库）&lt;/td&gt;
&lt;td&gt;△ 按技术栈&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Stripe&lt;/td&gt;
&lt;td&gt;MCP+Skill&lt;/td&gt;
&lt;td&gt;后端（支付）&lt;/td&gt;
&lt;td&gt;△ 按技术栈&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Laravel Boost&lt;/td&gt;
&lt;td&gt;MCP&lt;/td&gt;
&lt;td&gt;后端（Laravel）&lt;/td&gt;
&lt;td&gt;△ 按技术栈&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;HuggingFace&lt;/td&gt;
&lt;td&gt;MCP+Skill&lt;/td&gt;
&lt;td&gt;后端（AI模型集成）&lt;/td&gt;
&lt;td&gt;△ 按技术栈&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Greptile&lt;/td&gt;
&lt;td&gt;MCP&lt;/td&gt;
&lt;td&gt;前后端编码（代码搜索）&lt;/td&gt;
&lt;td&gt;△ 按技术栈&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Firecrawl&lt;/td&gt;
&lt;td&gt;Skill&lt;/td&gt;
&lt;td&gt;前后端编码（数据抓取）&lt;/td&gt;
&lt;td&gt;△ 按技术栈&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Qodo Skills&lt;/td&gt;
&lt;td&gt;Skill&lt;/td&gt;
&lt;td&gt;前后端编码（质量/测试）&lt;/td&gt;
&lt;td&gt;△ 按技术栈&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Coderabbit&lt;/td&gt;
&lt;td&gt;Skill+Agent&lt;/td&gt;
&lt;td&gt;前后端编码（评审）&lt;/td&gt;
&lt;td&gt;△ 按技术栈&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;PostHog&lt;/td&gt;
&lt;td&gt;MCP+Skill+Agent&lt;/td&gt;
&lt;td&gt;排查问题（产品分析）&lt;/td&gt;
&lt;td&gt;△ 按技术栈&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;PagerDuty&lt;/td&gt;
&lt;td&gt;MCP+Skill&lt;/td&gt;
&lt;td&gt;部署上线（风险评分）&lt;/td&gt;
&lt;td&gt;△ 按技术栈&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Sonatype Guide&lt;/td&gt;
&lt;td&gt;MCP&lt;/td&gt;
&lt;td&gt;前后端编码（依赖安全）&lt;/td&gt;
&lt;td&gt;△ 按技术栈&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Agent SDK Dev&lt;/td&gt;
&lt;td&gt;Skill+Agent&lt;/td&gt;
&lt;td&gt;特定（Agent SDK开发）&lt;/td&gt;
&lt;td&gt;△ 特定场景&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Plugin Dev&lt;/td&gt;
&lt;td&gt;Skill+Agent&lt;/td&gt;
&lt;td&gt;特定（插件开发）&lt;/td&gt;
&lt;td&gt;△ 特定场景&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Skill Creator&lt;/td&gt;
&lt;td&gt;Skill&lt;/td&gt;
&lt;td&gt;特定（Skill开发）&lt;/td&gt;
&lt;td&gt;△ 特定场景&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Code Simplifier&lt;/td&gt;
&lt;td&gt;Agent&lt;/td&gt;
&lt;td&gt;前后端编码（重构）&lt;/td&gt;
&lt;td&gt;△ 按需&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Playground&lt;/td&gt;
&lt;td&gt;Skill&lt;/td&gt;
&lt;td&gt;原型设计（HTML演示）&lt;/td&gt;
&lt;td&gt;△ 按需&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Claude Code Setup&lt;/td&gt;
&lt;td&gt;Skill&lt;/td&gt;
&lt;td&gt;全局（初始化配置）&lt;/td&gt;
&lt;td&gt;△ 按需&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Claude MD Management&lt;/td&gt;
&lt;td&gt;Skill&lt;/td&gt;
&lt;td&gt;全局（配置维护）&lt;/td&gt;
&lt;td&gt;△ 按需&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Explanatory Output Style&lt;/td&gt;
&lt;td&gt;Hook&lt;/td&gt;
&lt;td&gt;全局（学习/教学）&lt;/td&gt;
&lt;td&gt;△ 按需&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Learning Output Style&lt;/td&gt;
&lt;td&gt;Hook&lt;/td&gt;
&lt;td&gt;全局（学习/教学）&lt;/td&gt;
&lt;td&gt;△ 按需&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Linear&lt;/td&gt;
&lt;td&gt;MCP&lt;/td&gt;
&lt;td&gt;全局（项目管理）&lt;/td&gt;
&lt;td&gt;△ 按团队工具&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Atlassian&lt;/td&gt;
&lt;td&gt;MCP+Skill&lt;/td&gt;
&lt;td&gt;全局（项目管理）&lt;/td&gt;
&lt;td&gt;△ 按团队工具&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Asana&lt;/td&gt;
&lt;td&gt;MCP&lt;/td&gt;
&lt;td&gt;全局（项目管理）&lt;/td&gt;
&lt;td&gt;△ 按团队工具&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Notion&lt;/td&gt;
&lt;td&gt;MCP+Skill&lt;/td&gt;
&lt;td&gt;全局（文档协作）&lt;/td&gt;
&lt;td&gt;△ 按团队工具&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Slack&lt;/td&gt;
&lt;td&gt;MCP+Skill&lt;/td&gt;
&lt;td&gt;全局（沟通协作）&lt;/td&gt;
&lt;td&gt;△ 按团队工具&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;GitLab&lt;/td&gt;
&lt;td&gt;MCP&lt;/td&gt;
&lt;td&gt;全局（代码托管）&lt;/td&gt;
&lt;td&gt;△ 按团队工具&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Circleback&lt;/td&gt;
&lt;td&gt;MCP&lt;/td&gt;
&lt;td&gt;全局（会议/邮件）&lt;/td&gt;
&lt;td&gt;△ 按团队工具&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;TypeScript LSP&lt;/td&gt;
&lt;td&gt;LSP&lt;/td&gt;
&lt;td&gt;前后端编码&lt;/td&gt;
&lt;td&gt;△ 按语言&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Pyright LSP&lt;/td&gt;
&lt;td&gt;LSP&lt;/td&gt;
&lt;td&gt;后端（Python）&lt;/td&gt;
&lt;td&gt;△ 按语言&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Gopls LSP&lt;/td&gt;
&lt;td&gt;LSP&lt;/td&gt;
&lt;td&gt;后端（Go）&lt;/td&gt;
&lt;td&gt;△ 按语言&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Rust Analyzer LSP&lt;/td&gt;
&lt;td&gt;LSP&lt;/td&gt;
&lt;td&gt;后端（Rust）&lt;/td&gt;
&lt;td&gt;△ 按语言&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;ClangD LSP&lt;/td&gt;
&lt;td&gt;LSP&lt;/td&gt;
&lt;td&gt;前后端（C/C++）&lt;/td&gt;
&lt;td&gt;△ 按语言&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;PHP LSP&lt;/td&gt;
&lt;td&gt;LSP&lt;/td&gt;
&lt;td&gt;后端（PHP）&lt;/td&gt;
&lt;td&gt;△ 按语言&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Swift LSP&lt;/td&gt;
&lt;td&gt;LSP&lt;/td&gt;
&lt;td&gt;原生（Swift）&lt;/td&gt;
&lt;td&gt;△ 按语言&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Kotlin LSP&lt;/td&gt;
&lt;td&gt;LSP&lt;/td&gt;
&lt;td&gt;原生（Kotlin）&lt;/td&gt;
&lt;td&gt;△ 按语言&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;C# LSP&lt;/td&gt;
&lt;td&gt;LSP&lt;/td&gt;
&lt;td&gt;后端（C#）&lt;/td&gt;
&lt;td&gt;△ 按语言&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;JDTLS LSP&lt;/td&gt;
&lt;td&gt;LSP&lt;/td&gt;
&lt;td&gt;后端（Java）&lt;/td&gt;
&lt;td&gt;△ 按语言&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Lua LSP&lt;/td&gt;
&lt;td&gt;LSP&lt;/td&gt;
&lt;td&gt;特定（Lua）&lt;/td&gt;
&lt;td&gt;△ 按语言&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Ruby LSP&lt;/td&gt;
&lt;td&gt;LSP&lt;/td&gt;
&lt;td&gt;后端（Ruby）&lt;/td&gt;
&lt;td&gt;△ 按语言&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;blockquote&gt;&lt;p&gt;💡 综上，我的核心建议是：&lt;strong&gt;优先装 6 个核心（★），再按你的技术栈从推荐（☆）和按需（△）中选配&lt;/strong&gt;。不必全装——每个插件都会消耗上下文窗口和启动时间，保持 2-3 个 MCP + 3-5 个 Skill 活跃即可。&lt;/p&gt;
&lt;/blockquote&gt;&lt;hr&gt;
&lt;h2 id=&quot;h2-u2B5020u6838u5FC3u5FC5u5907uFF08620u4E2A20u201420u5EFAu8BAEu6700u5148u5B89u88C5uFF09-89&quot;&gt;&lt;a class=&quot;reference-link&quot; name=&quot;⭐ 核心必备（6 个 — 建议最先安装）&quot;&gt;&lt;/a&gt;&lt;span class=&quot;header-link octicon octicon-link&quot;&gt;&lt;/span&gt;⭐ 核心必备（6 个 — 建议最先安装）&lt;/h2&gt;&lt;h3 id=&quot;h3-u2605201.20Context720u201420u5B9Eu65F6u6700u65B0u6846u67B6u6587u6863-91&quot;&gt;&lt;a class=&quot;reference-link&quot; name=&quot;★ 1. Context7 — 实时最新框架文档&quot;&gt;&lt;/a&gt;&lt;span class=&quot;header-link octicon octicon-link&quot;&gt;&lt;/span&gt;★ 1. Context7 — 实时最新框架文档&lt;/h3&gt;&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;类型&lt;/strong&gt;：MCP&lt;/li&gt;&lt;li&gt;&lt;strong&gt;提供方&lt;/strong&gt;：第三方（Upstash 开源）&lt;/li&gt;&lt;li&gt;&lt;strong&gt;适用阶段&lt;/strong&gt;：前后端编码&lt;/li&gt;&lt;li&gt;&lt;strong&gt;用途&lt;/strong&gt;：根据你项目中实际安装的框架和库版本，&lt;strong&gt;自动拉取版本匹配的最新官方文档&lt;/strong&gt;并注入对话上下文。当你使用 React 19、Next.js 15、Prisma 6 等大版本更新频繁的框架时，Context7 确保 Claude 给出的是&lt;strong&gt;对的 API、对的参数、对的用法&lt;/strong&gt;，而不是基于过时训练数据的幻觉代码。&lt;/li&gt;&lt;/ul&gt;
&lt;blockquote&gt;&lt;p&gt;✅ &lt;strong&gt;推荐理由&lt;/strong&gt;：API 幻觉是 AI 编程最大的坑之一。Context7 直接解决了”你训练数据里的 API 已经废弃了”这个问题。&lt;/p&gt;
&lt;/blockquote&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot;&gt;# Claude Code 安装
claude mcp add --scope user \
  --header &quot;CONTEXT7_API_KEY: YOUR_API_KEY&quot; \
  --transport http \
  context7 https://mcp.context7.com/mcp
&lt;/code&gt;&lt;/pre&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;CC Switch 安装&lt;/strong&gt;：MCP 页签 → 添加 → 类型选 HTTP → URL 填 &lt;code&gt;https://mcp.context7.com/mcp&lt;/code&gt; → Headers 添加 &lt;code&gt;CONTEXT7_API_KEY: 你的Key&lt;/code&gt;&lt;/li&gt;&lt;li&gt;🔗 &lt;strong&gt;官网&lt;/strong&gt;：&lt;a href=&quot;https://context7.com&quot;&gt;https://context7.com&lt;/a&gt;&lt;/li&gt;&lt;/ul&gt;
&lt;hr&gt;
&lt;h3 id=&quot;h3-u2605202.20Sequential20Thinking20u201420u7ED3u6784u5316u5206u6B65u63A8u7406-113&quot;&gt;&lt;a class=&quot;reference-link&quot; name=&quot;★ 2. Sequential Thinking — 结构化分步推理&quot;&gt;&lt;/a&gt;&lt;span class=&quot;header-link octicon octicon-link&quot;&gt;&lt;/span&gt;★ 2. Sequential Thinking — 结构化分步推理&lt;/h3&gt;&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;类型&lt;/strong&gt;：MCP&lt;/li&gt;&lt;li&gt;&lt;strong&gt;提供方&lt;/strong&gt;：Anthropic 官方（Model Context Protocol 项目）&lt;/li&gt;&lt;li&gt;&lt;strong&gt;适用阶段&lt;/strong&gt;：全局（架构设计、Bug分析、复杂算法都需要）&lt;/li&gt;&lt;li&gt;&lt;strong&gt;用途&lt;/strong&gt;：为 Claude 提供&lt;strong&gt;结构化的分步推理框架&lt;/strong&gt;。当你面对复杂问题时（比如设计架构、分析深层 Bug、优化算法），它让 Claude 像人类专家一样”一步一步想”——支持思维分叉探索不同方向、回溯修正之前的错误判断、动态调整思考深度。显著减少复杂场景下的逻辑跳跃和结论错误。&lt;/li&gt;&lt;/ul&gt;
&lt;blockquote&gt;&lt;p&gt;💡 &lt;strong&gt;适用场景&lt;/strong&gt;：架构选型、Bug 根因分析、算法优化、多方案对比——凡是需要”想清楚再做”的任务都应该开它。&lt;/p&gt;
&lt;/blockquote&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot;&gt;# Claude Code 安装
claude mcp add sequential-thinking -s user \
  -- npx -y @modelcontextprotocol/server-sequential-thinking
&lt;/code&gt;&lt;/pre&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;CC Switch 安装&lt;/strong&gt;：MCP 页签 → 添加 → 类型选 stdio → 命令 &lt;code&gt;npx&lt;/code&gt; → 参数 &lt;code&gt;-y &lt;a class=&quot;at-link&quot; title=&quot;@modelcontextprotocol&quot; href=&quot;https://github.com/modelcontextprotocol&quot;&gt;@modelcontextprotocol&lt;/a&gt;/server-sequential-thinking&lt;/code&gt;&lt;/li&gt;&lt;li&gt;🔗 &lt;strong&gt;官网&lt;/strong&gt;：&lt;a href=&quot;https://github.com/modelcontextprotocol/servers&quot;&gt;https://github.com/modelcontextprotocol/servers&lt;/a&gt;&lt;/li&gt;&lt;/ul&gt;
&lt;hr&gt;
&lt;h3 id=&quot;h3-u2605203.20Playwright20u201420u6D4Fu89C8u5668u81EAu52A8u5316u6D4Bu8BD5u4E0EUIu6392u67E5-133&quot;&gt;&lt;a class=&quot;reference-link&quot; name=&quot;★ 3. Playwright — 浏览器自动化测试与UI排查&quot;&gt;&lt;/a&gt;&lt;span class=&quot;header-link octicon octicon-link&quot;&gt;&lt;/span&gt;★ 3. Playwright — 浏览器自动化测试与UI排查&lt;/h3&gt;&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;类型&lt;/strong&gt;：MCP&lt;/li&gt;&lt;li&gt;&lt;strong&gt;提供方&lt;/strong&gt;：第三方（Microsoft）&lt;/li&gt;&lt;li&gt;&lt;strong&gt;适用阶段&lt;/strong&gt;：排查问题 + 测试（你的第4阶段核心工具）&lt;/li&gt;&lt;li&gt;&lt;strong&gt;用途&lt;/strong&gt;：让 Claude &lt;strong&gt;直接操控真实浏览器&lt;/strong&gt;——导航页面、点击按钮、填写表单、截图对比、抓取网络请求、检查控制台错误。在你”AI控制浏览器排查开发期间的问题”这个阶段，Playwright 就是你的手和眼睛；开发期可以自动验证 UI 是否正确渲染，调试期可以复现 Bug 场景，测试期可以执行端到端测试。&lt;/li&gt;&lt;/ul&gt;
&lt;blockquote&gt;&lt;p&gt;✅ &lt;strong&gt;推荐理由&lt;/strong&gt;：你的工作流第 4 阶段（AI浏览器排查问题）的核心工具。不用再手动开 DevTools 了。&lt;/p&gt;
&lt;/blockquote&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot;&gt;# Claude Code 安装
claude mcp add playwright -- npx -y @anthropic-ai/playwright-mcp
&lt;/code&gt;&lt;/pre&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;CC Switch 安装&lt;/strong&gt;：MCP 页签 → 添加 → 类型选 stdio → 命令 &lt;code&gt;npx&lt;/code&gt; → 参数 &lt;code&gt;-y &lt;a class=&quot;at-link&quot; title=&quot;@anthropic&quot; href=&quot;https://github.com/anthropic&quot;&gt;@anthropic&lt;/a&gt;-ai/playwright-mcp&lt;/code&gt;&lt;/li&gt;&lt;li&gt;🔗 &lt;strong&gt;官网&lt;/strong&gt;：&lt;a href=&quot;https://playwright.dev&quot;&gt;https://playwright.dev&lt;/a&gt;&lt;/li&gt;&lt;/ul&gt;
&lt;hr&gt;
&lt;h3 id=&quot;h3-u2605204.20Frontend20Design20u201420u751Fu4EA7u7EA7u524Du7AEFUIu751Fu6210-152&quot;&gt;&lt;a class=&quot;reference-link&quot; name=&quot;★ 4. Frontend Design — 生产级前端UI生成&quot;&gt;&lt;/a&gt;&lt;span class=&quot;header-link octicon octicon-link&quot;&gt;&lt;/span&gt;★ 4. Frontend Design — 生产级前端UI生成&lt;/h3&gt;&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;类型&lt;/strong&gt;：Skill&lt;/li&gt;&lt;li&gt;&lt;strong&gt;提供方&lt;/strong&gt;：Anthropic 官方（52.7K+ 安装量）&lt;/li&gt;&lt;li&gt;&lt;strong&gt;适用阶段&lt;/strong&gt;：原型设计 + 前端编码&lt;/li&gt;&lt;li&gt;&lt;strong&gt;用途&lt;/strong&gt;：专门用于生成&lt;strong&gt;有独特设计感、可直接投产的前端界面&lt;/strong&gt;。不同于普通 AI 生成的千篇一律的 UI（”AI 味审美”），它会根据项目的用途定位、目标用户、品牌基调、设计约束来生成差异化的界面代码。内置 67 种 UI 风格预设和 100 条设计推理规则——当你告诉它”做一个面向中国茶饮品牌的会员小程序”，它会生成有东方美学调性的设计，而非泛泛的蓝色按钮+白色背景。&lt;/li&gt;&lt;/ul&gt;
&lt;blockquote&gt;&lt;p&gt;💡 &lt;strong&gt;适用场景&lt;/strong&gt;：快速出原型、需要设计感的页面、避免”AI slop”风格的 UI。&lt;/p&gt;
&lt;/blockquote&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot;&gt;# Claude Code 安装
/plugin install frontend-design@claude-plugins-official
&lt;/code&gt;&lt;/pre&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;CC Switch 安装&lt;/strong&gt;：Skills 页签 → 搜索 &lt;code&gt;frontend-design&lt;/code&gt; → 一键安装&lt;/li&gt;&lt;li&gt;🔗 &lt;strong&gt;官网&lt;/strong&gt;：&lt;a href=&quot;https://github.com/anthropics/frontend-design&quot;&gt;https://github.com/anthropics/frontend-design&lt;/a&gt;&lt;/li&gt;&lt;/ul&gt;
&lt;hr&gt;
&lt;h3 id=&quot;h3-u2605205.20Feature20Dev20u2014207u9636u6BB5u529Fu80FDu5F00u53D1u5168u6D41u7A0B-171&quot;&gt;&lt;a class=&quot;reference-link&quot; name=&quot;★ 5. Feature Dev — 7阶段功能开发全流程&quot;&gt;&lt;/a&gt;&lt;span class=&quot;header-link octicon octicon-link&quot;&gt;&lt;/span&gt;★ 5. Feature Dev — 7阶段功能开发全流程&lt;/h3&gt;&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;类型&lt;/strong&gt;：Skill + Agent&lt;/li&gt;&lt;li&gt;&lt;strong&gt;提供方&lt;/strong&gt;：Anthropic 官方（89K+ 安装量）&lt;/li&gt;&lt;li&gt;&lt;strong&gt;适用阶段&lt;/strong&gt;：前后端编码 + 文档输出&lt;/li&gt;&lt;li&gt;&lt;strong&gt;用途&lt;/strong&gt;：把”从想法到可交付代码”的整个流程标准化为 &lt;strong&gt;7 个阶段&lt;/strong&gt;：需求探索 → 技术选型 → 架构设计 → 代码实现 → 测试编写 → 代码评审 → 文档生成。对于全栈开发来说，这意味着你不必在每一步都手动写 prompt 告诉 Claude 该做什么——Feature Dev 内置了每个阶段的检查清单和最佳实践，Claude 会自动按流程推进，并把每个阶段的产出物（架构图、接口文档、测试报告）保存下来。&lt;/li&gt;&lt;/ul&gt;
&lt;blockquote&gt;&lt;p&gt;✅ &lt;strong&gt;推荐理由&lt;/strong&gt;：89K+ 安装量的爆款 Skill，把你的工作流第 2-5 阶段全部覆盖了。&lt;/p&gt;
&lt;/blockquote&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot;&gt;# Claude Code 安装
/plugin install feature-dev@claude-plugins-official
&lt;/code&gt;&lt;/pre&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;CC Switch 安装&lt;/strong&gt;：Skills 页签 → 搜索 &lt;code&gt;feature-dev&lt;/code&gt; → 一键安装&lt;/li&gt;&lt;li&gt;🔗 &lt;strong&gt;官网&lt;/strong&gt;：&lt;a href=&quot;https://github.com/anthropics/feature-dev&quot;&gt;https://github.com/anthropics/feature-dev&lt;/a&gt;&lt;/li&gt;&lt;/ul&gt;
&lt;hr&gt;
&lt;h3 id=&quot;h3-u2605206.20Planning20with20Files20u201420u8DE8u4F1Au8BDDu6301u4E45u5316u4EFBu52A1u89C4u5212-190&quot;&gt;&lt;a class=&quot;reference-link&quot; name=&quot;★ 6. Planning with Files — 跨会话持久化任务规划&quot;&gt;&lt;/a&gt;&lt;span class=&quot;header-link octicon octicon-link&quot;&gt;&lt;/span&gt;★ 6. Planning with Files — 跨会话持久化任务规划&lt;/h3&gt;&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;类型&lt;/strong&gt;：Skill&lt;/li&gt;&lt;li&gt;&lt;strong&gt;提供方&lt;/strong&gt;：第三方（OthmanAdi，20K+ GitHub Stars）&lt;/li&gt;&lt;li&gt;&lt;strong&gt;适用阶段&lt;/strong&gt;：全局任务管理 + 文档输出（你的第5阶段）&lt;/li&gt;&lt;li&gt;&lt;strong&gt;用途&lt;/strong&gt;：实现 &lt;strong&gt;Manus 风格的持久化工作规划&lt;/strong&gt;——自动维护 3 个 Markdown 文件：&lt;code&gt;task_plan.md&lt;/code&gt;（目标与任务清单）、&lt;code&gt;findings.md&lt;/code&gt;（研究发现与调研笔记）、&lt;code&gt;progress.md&lt;/code&gt;（操作日志与遇到的错误）。这个插件的核心价值是&lt;strong&gt;解决了长任务上下文丢失的问题&lt;/strong&gt;：当 Claude Code 的上下文窗口满了触发 compaction 后，它可以从这 3 个文件中恢复之前的工作状态，不用从头开始。特别适合需要跨多个会话完成的复杂全栈项目。&lt;/li&gt;&lt;/ul&gt;
&lt;blockquote&gt;&lt;p&gt;⚠️ &lt;strong&gt;重要&lt;/strong&gt;：长任务（跨多会话）必备。如果你经常遇到”Claude 忘了之前做了什么”的情况，装它。支持中文版 &lt;code&gt;planning-with-files-zh&lt;/code&gt;。&lt;/p&gt;
&lt;/blockquote&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot;&gt;# Claude Code 安装
npx skills add OthmanAdi/planning-with-files --skill planning-with-files -g

# 或通过市场
/plugin marketplace add OthmanAdi/planning-with-files
/plugin install planning-with-files@planning-with-files
&lt;/code&gt;&lt;/pre&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;CC Switch 安装&lt;/strong&gt;：Skills 页签 → 搜索 &lt;code&gt;planning-with-files&lt;/code&gt; → 一键安装（中文版用 &lt;code&gt;planning-with-files-zh&lt;/code&gt;）&lt;/li&gt;&lt;li&gt;🔗 &lt;strong&gt;官网&lt;/strong&gt;：&lt;a href=&quot;https://github.com/OthmanAdi/planning-with-files&quot;&gt;https://github.com/OthmanAdi/planning-with-files&lt;/a&gt;&lt;/li&gt;&lt;/ul&gt;
&lt;hr&gt;
&lt;h2 id=&quot;h2-u260620u5F3Au70C8u63A8u8350uFF081320u4E2A20u201420u88C5u4E0Au540Eu6548u7387u7FFBu500DuFF09-213&quot;&gt;&lt;a class=&quot;reference-link&quot; name=&quot;☆ 强烈推荐（13 个 — 装上后效率翻倍）&quot;&gt;&lt;/a&gt;&lt;span class=&quot;header-link octicon octicon-link&quot;&gt;&lt;/span&gt;☆ 强烈推荐（13 个 — 装上后效率翻倍）&lt;/h2&gt;&lt;h3 id=&quot;h3-u2606207.20Figma20u201420u8BBEu8BA1u7A3Fu5230u4EE3u7801u7684u6865u6881-215&quot;&gt;&lt;a class=&quot;reference-link&quot; name=&quot;☆ 7. Figma — 设计稿到代码的桥梁&quot;&gt;&lt;/a&gt;&lt;span class=&quot;header-link octicon octicon-link&quot;&gt;&lt;/span&gt;☆ 7. Figma — 设计稿到代码的桥梁&lt;/h3&gt;&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;类型&lt;/strong&gt;：MCP + Skill&lt;/li&gt;&lt;li&gt;&lt;strong&gt;提供方&lt;/strong&gt;：第三方（Figma 官方）&lt;/li&gt;&lt;li&gt;&lt;strong&gt;适用阶段&lt;/strong&gt;：原型设计（你的第1阶段）&lt;/li&gt;&lt;li&gt;&lt;strong&gt;用途&lt;/strong&gt;：直接读取 Figma 设计文件中的&lt;strong&gt;图层结构、颜色 token、字体样式、间距系统、组件属性&lt;/strong&gt;等信息，让 Claude 生成高度还原设计稿的前端代码。不再是”凭描述猜设计”，而是基于真实的设计数据进行代码生成，打通”设计师出图 → 开发者写代码”的效率瓶颈。&lt;/li&gt;&lt;/ul&gt;
&lt;pre&gt;&lt;code class=&quot;language-bash&quot;&gt;# Claude Code 安装
claude mcp add --transport http figma https://mcp.figma.com/mcp
&lt;/code&gt;&lt;/pre&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;CC Switch 安装&lt;/strong&gt;：MCP 页签 → 添加 → 类型选 HTTP → URL 填 &lt;code&gt;https://mcp.figma.com/mcp&lt;/code&gt; → 首次使用需 OAuth 认证&lt;/li&gt;&lt;li&gt;🔗 &lt;strong&gt;官网&lt;/strong&gt;：&lt;a href=&quot;https://www.figma.com&quot;&gt;https://www.figma.com&lt;/a&gt;&lt;/li&gt;&lt;/ul&gt;
&lt;hr&gt;
&lt;h3 id=&quot;h3-u2606208.20GitHub20u201420u4EE3u7801u4ED3u5E93u5168u64CDu4F5C-232&quot;&gt;&lt;a class=&quot;reference-link&quot; name=&quot;☆ 8. GitHub — 代码仓库全操作&quot;&gt;&lt;/a&gt;&lt;span class=&quot;header-link octicon octicon-link&quot;&gt;&lt;/span&gt;☆ 8. GitHub — 代码仓库全操作&lt;/h3&gt;&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;类型&lt;/strong&gt;：MCP&lt;/li&gt;&lt;li&gt;&lt;strong&gt;提供方&lt;/strong&gt;：第三方（GitHub 官方）&lt;/li&gt;&lt;li&gt;&lt;strong&gt;适用阶段&lt;/strong&gt;：前后端编码&lt;/li&gt;&lt;li&gt;&lt;strong&gt;用途&lt;/strong&gt;：在 Claude Code 中直接&lt;strong&gt;操作 GitHub 的几乎所有功能&lt;/strong&gt;：创建和管理 Issue、提交和审查 Pull Request、搜索代码库、查看 Actions CI/CD 状态、管理分支和保护规则。省去在终端和浏览器之间频繁切换的麻烦，你的代码管理和 AI 编程在同一个界面完成。&lt;/li&gt;&lt;/ul&gt;
&lt;pre&gt;&lt;code class=&quot;language-bash&quot;&gt;# Claude Code 安装
claude mcp add-json github &#039;{&quot;type&quot;:&quot;http&quot;,&quot;url&quot;:&quot;https://api.githubcopilot.com/mcp&quot;,&quot;headers&quot;:{&quot;Authorization&quot;:&quot;Bearer YOUR_GITHUB_PAT&quot;}}&#039;
&lt;/code&gt;&lt;/pre&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;CC Switch 安装&lt;/strong&gt;：MCP 页签 → 添加 → 类型选 HTTP → URL 填 GitHub MCP 端点 → Headers 配置 PAT Token&lt;/li&gt;&lt;li&gt;🔗 &lt;strong&gt;官网&lt;/strong&gt;：&lt;a href=&quot;https://github.com&quot;&gt;https://github.com&lt;/a&gt;&lt;/li&gt;&lt;/ul&gt;
&lt;hr&gt;
&lt;h3 id=&quot;h3-u2606209.20Serena20u201420u8BEDu4E49u7EA7u4EE3u7801u5206u6790u4E0Eu7F16u8F91-249&quot;&gt;&lt;a class=&quot;reference-link&quot; name=&quot;☆ 9. Serena — 语义级代码分析与编辑&quot;&gt;&lt;/a&gt;&lt;span class=&quot;header-link octicon octicon-link&quot;&gt;&lt;/span&gt;☆ 9. Serena — 语义级代码分析与编辑&lt;/h3&gt;&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;类型&lt;/strong&gt;：MCP&lt;/li&gt;&lt;li&gt;&lt;strong&gt;提供方&lt;/strong&gt;：第三方（Oraios AI，2900+ Stars，MIT 开源）&lt;/li&gt;&lt;li&gt;&lt;strong&gt;适用阶段&lt;/strong&gt;：前后端编码&lt;/li&gt;&lt;li&gt;&lt;strong&gt;用途&lt;/strong&gt;：基于 &lt;strong&gt;LSP 协议&lt;/strong&gt;提供 IDE 级别的语义代码理解能力——&lt;strong&gt;按符号查找、查找所有引用、替换符号定义、按符号位置插入/删除代码&lt;/strong&gt;。与传统的关键词搜索不同，Serena 理解代码的语义结构（比如它知道 &lt;code&gt;UserService.create()&lt;/code&gt; 是一个类的实例方法、继承了哪个基类、被哪些文件调用）。在大型项目中，Serena 能节省 30 倍以上的 token 消耗（不需要把整个文件读进来找函数），同时还提供 Web 仪表盘和跨会话项目记忆。&lt;/li&gt;&lt;/ul&gt;
&lt;blockquote&gt;&lt;p&gt;⚠️ &lt;strong&gt;前置依赖&lt;/strong&gt;：需要先安装 uv（&lt;code&gt;curl -LsSf https://astral.sh/uv/install.sh | sh&lt;/code&gt;）&lt;/p&gt;
&lt;/blockquote&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot;&gt;# Claude Code 安装
claude mcp add serena -- uvx --from git+https://github.com/oraios/serena \
  serena start-mcp-server --context ide-assistant --project &quot;$(pwd)&quot;
&lt;/code&gt;&lt;/pre&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;CC Switch 安装&lt;/strong&gt;：MCP 页签 → 类型选 stdio → 命令 &lt;code&gt;uvx&lt;/code&gt; → 按上述参数配置&lt;/li&gt;&lt;li&gt;🔗 &lt;strong&gt;官网&lt;/strong&gt;：&lt;a href=&quot;https://github.com/oraios/serena&quot;&gt;https://github.com/oraios/serena&lt;/a&gt;&lt;/li&gt;&lt;/ul&gt;
&lt;hr&gt;
&lt;h3 id=&quot;h3-u26062010.20Superpowers20u201420u5DE5u7A0Bu65B9u6CD5u8BBAu6280u80FDu5305-269&quot;&gt;&lt;a class=&quot;reference-link&quot; name=&quot;☆ 10. Superpowers — 工程方法论技能包&quot;&gt;&lt;/a&gt;&lt;span class=&quot;header-link octicon octicon-link&quot;&gt;&lt;/span&gt;☆ 10. Superpowers — 工程方法论技能包&lt;/h3&gt;&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;类型&lt;/strong&gt;：Skill + Agent + Hook&lt;/li&gt;&lt;li&gt;&lt;strong&gt;提供方&lt;/strong&gt;：第三方（Jesse Vincent/obra，20K+ GitHub Stars）&lt;/li&gt;&lt;li&gt;&lt;strong&gt;适用阶段&lt;/strong&gt;：前后端编码&lt;/li&gt;&lt;li&gt;&lt;strong&gt;用途&lt;/strong&gt;：一套让 AI &lt;strong&gt;遵循严格软件工程方法&lt;/strong&gt;的技能集合，包含 20+ 个技能：&lt;strong&gt;交互式头脑风暴&lt;/strong&gt;（不直接写代码，先讨论方案优劣）、&lt;strong&gt;TDD 驱动开发&lt;/strong&gt;（先写测试再写实现）、&lt;strong&gt;系统化调试&lt;/strong&gt;（按二分法定位问题而非随机猜测）、&lt;strong&gt;计划后执行&lt;/strong&gt;（先出计划再批量实现）。&lt;/li&gt;&lt;/ul&gt;
&lt;blockquote&gt;&lt;p&gt;💡 &lt;strong&gt;核心理念&lt;/strong&gt;：”让 AI 像有经验的工程师一样工作，而不是像实习生一样随手写代码。”&lt;/p&gt;
&lt;/blockquote&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot;&gt;# Claude Code 安装
/plugin marketplace add obra/superpowers-marketplace
/plugin install superpowers@superpowers-marketplace

# 常用命令
/superpowers:brainstorm      # 交互式头脑风暴
/superpowers:write-plan      # 编写执行计划
/superpowers:execute-plan    # 按计划执行
&lt;/code&gt;&lt;/pre&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;CC Switch 安装&lt;/strong&gt;：Skills 页签 → 搜索 &lt;code&gt;superpowers&lt;/code&gt; → 一键安装&lt;/li&gt;&lt;li&gt;🔗 &lt;strong&gt;官网&lt;/strong&gt;：&lt;a href=&quot;https://github.com/obra/superpowers&quot;&gt;https://github.com/obra/superpowers&lt;/a&gt;&lt;/li&gt;&lt;/ul&gt;
&lt;hr&gt;
&lt;h3 id=&quot;h3-u26062011.20PR20Review20Toolkit20u2014206u7EF4u5EA6u4E13u4E1Au4EE3u7801u8BC4u5BA1-294&quot;&gt;&lt;a class=&quot;reference-link&quot; name=&quot;☆ 11. PR Review Toolkit — 6维度专业代码评审&quot;&gt;&lt;/a&gt;&lt;span class=&quot;header-link octicon octicon-link&quot;&gt;&lt;/span&gt;☆ 11. PR Review Toolkit — 6维度专业代码评审&lt;/h3&gt;&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;类型&lt;/strong&gt;：Skill + Agent&lt;/li&gt;&lt;li&gt;&lt;strong&gt;提供方&lt;/strong&gt;：Anthropic 官方&lt;/li&gt;&lt;li&gt;&lt;strong&gt;适用阶段&lt;/strong&gt;：前后端编码（代码评审）&lt;/li&gt;&lt;li&gt;&lt;strong&gt;用途&lt;/strong&gt;：内含 &lt;strong&gt;6 个专业评审 Agent&lt;/strong&gt;，每个负责一个维度 —— &lt;strong&gt;Comment Analyzer&lt;/strong&gt;（检查注释和文档质量）、&lt;strong&gt;PR Test Analyzer&lt;/strong&gt;（分析测试覆盖率和用例质量）、&lt;strong&gt;Silent Failure Hunter&lt;/strong&gt;（发现被吞掉的异常和边界情况）、&lt;strong&gt;Type Design Analyzer&lt;/strong&gt;（评估类型定义的完整性和约束）、&lt;strong&gt;Code Reviewer&lt;/strong&gt;（综合代码质量评审）、&lt;strong&gt;Code Simplifier&lt;/strong&gt;（提出简化建议）。支持并行评审（6 个 Agent 同时跑），大幅缩短 PR 等待时间。&lt;/li&gt;&lt;/ul&gt;
&lt;pre&gt;&lt;code class=&quot;language-bash&quot;&gt;# Claude Code 安装
/plugin install pr-review-toolkit@claude-plugins-official

# 使用方式
/pr-review-toolkit:review-pr all parallel   # 全维度并行评审
&lt;/code&gt;&lt;/pre&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;CC Switch 安装&lt;/strong&gt;：Skills 页签 → 搜索 &lt;code&gt;pr-review-toolkit&lt;/code&gt; → 一键安装（需配套 &lt;code&gt;gh&lt;/code&gt; CLI）&lt;/li&gt;&lt;li&gt;🔗 &lt;strong&gt;官网&lt;/strong&gt;：&lt;a href=&quot;https://github.com/anthropics/claude-plugins-official&quot;&gt;https://github.com/anthropics/claude-plugins-official&lt;/a&gt;&lt;/li&gt;&lt;/ul&gt;
&lt;hr&gt;
&lt;h3 id=&quot;h3-u26062012.20Semgrep20u201420u5B9Eu65F6u5B89u5168u6F0Fu6D1Eu626Bu63CF-314&quot;&gt;&lt;a class=&quot;reference-link&quot; name=&quot;☆ 12. Semgrep — 实时安全漏洞扫描&quot;&gt;&lt;/a&gt;&lt;span class=&quot;header-link octicon octicon-link&quot;&gt;&lt;/span&gt;☆ 12. Semgrep — 实时安全漏洞扫描&lt;/h3&gt;&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;类型&lt;/strong&gt;：MCP + Skill + Hook&lt;/li&gt;&lt;li&gt;&lt;strong&gt;提供方&lt;/strong&gt;：第三方（Semgrep 官方）&lt;/li&gt;&lt;li&gt;&lt;strong&gt;适用阶段&lt;/strong&gt;：前后端编码（安全）&lt;/li&gt;&lt;li&gt;&lt;strong&gt;用途&lt;/strong&gt;：在 Claude &lt;strong&gt;每次编辑代码后自动触发安全扫描&lt;/strong&gt;，集成三大引擎 —— &lt;strong&gt;SAST&lt;/strong&gt;（静态代码分析，检测 OWASP Top 10 漏洞、SQL 注入、XSS、命令注入等）、&lt;strong&gt;SCA&lt;/strong&gt;（供应链依赖漏洞检测）、&lt;strong&gt;Secrets Detection&lt;/strong&gt;（密钥和敏感信息泄露检测）。发现问题后自动提示 Claude 重新生成代码直到扫描结果干净。&lt;/li&gt;&lt;/ul&gt;
&lt;blockquote&gt;&lt;p&gt;⚠️ &lt;strong&gt;注意&lt;/strong&gt;：需要先安装 Semgrep CLI（&lt;code&gt;brew install semgrep&lt;/code&gt; 或 &lt;code&gt;pipx install semgrep&lt;/code&gt;），然后在 Claude Code 中运行 &lt;code&gt;/setup-semgrep-plugin&lt;/code&gt; 完成配置。&lt;/p&gt;
&lt;/blockquote&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot;&gt;# 先安装 Semgrep CLI
brew install semgrep       # macOS
pipx install semgrep       # 跨平台

# 在 Claude Code 中安装插件
/plugin                    # → Discover → 搜索 Semgrep → Install
&lt;/code&gt;&lt;/pre&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;CC Switch 安装&lt;/strong&gt;：MCP 页签 → 添加 → 类型选 stdio → 命令 &lt;code&gt;semgrep&lt;/code&gt;，或在 Skills 页签搜索安装&lt;/li&gt;&lt;li&gt;🔗 &lt;strong&gt;官网&lt;/strong&gt;：&lt;a href=&quot;https://semgrep.dev&quot;&gt;https://semgrep.dev&lt;/a&gt;&lt;/li&gt;&lt;/ul&gt;
&lt;hr&gt;
&lt;h3 id=&quot;h3-u26062013.20Sentry20u201420u7EBFu4E0Au9519u8BEFu76D1u63A7-337&quot;&gt;&lt;a class=&quot;reference-link&quot; name=&quot;☆ 13. Sentry — 线上错误监控&quot;&gt;&lt;/a&gt;&lt;span class=&quot;header-link octicon octicon-link&quot;&gt;&lt;/span&gt;☆ 13. Sentry — 线上错误监控&lt;/h3&gt;&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;类型&lt;/strong&gt;：MCP + Skill&lt;/li&gt;&lt;li&gt;&lt;strong&gt;提供方&lt;/strong&gt;：第三方（Sentry 官方）&lt;/li&gt;&lt;li&gt;&lt;strong&gt;适用阶段&lt;/strong&gt;：排查问题 + 监控（你的第4阶段）&lt;/li&gt;&lt;li&gt;&lt;strong&gt;用途&lt;/strong&gt;：在 Claude Code 中&lt;strong&gt;直接查看 Sentry 的错误报告&lt;/strong&gt;——堆栈跟踪、错误上下文、影响用户数、首次出现时间。当你在排查线上问题时，不需要切到 Sentry 网页在浏览器和代码之间来回看，Claude 可以直接读取错误详情并结合代码上下文给出修复方案。&lt;/li&gt;&lt;/ul&gt;
&lt;pre&gt;&lt;code class=&quot;language-bash&quot;&gt;# Claude Code 安装
claude mcp add --transport http sentry https://mcp.sentry.dev/mcp
&lt;/code&gt;&lt;/pre&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;CC Switch 安装&lt;/strong&gt;：MCP 页签 → 添加 → 类型选 HTTP → URL 填 &lt;code&gt;https://mcp.sentry.dev/mcp&lt;/code&gt; → 配置 Auth Token&lt;/li&gt;&lt;li&gt;🔗 &lt;strong&gt;官网&lt;/strong&gt;：&lt;a href=&quot;https://sentry.io&quot;&gt;https://sentry.io&lt;/a&gt;&lt;/li&gt;&lt;/ul&gt;
&lt;hr&gt;
&lt;h3 id=&quot;h3-u26062014.20Vercel20u201420u4E00u952Eu90E8u7F72-354&quot;&gt;&lt;a class=&quot;reference-link&quot; name=&quot;☆ 14. Vercel — 一键部署&quot;&gt;&lt;/a&gt;&lt;span class=&quot;header-link octicon octicon-link&quot;&gt;&lt;/span&gt;☆ 14. Vercel — 一键部署&lt;/h3&gt;&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;类型&lt;/strong&gt;：Skill&lt;/li&gt;&lt;li&gt;&lt;strong&gt;提供方&lt;/strong&gt;：第三方（Vercel 官方）&lt;/li&gt;&lt;li&gt;&lt;strong&gt;适用阶段&lt;/strong&gt;：部署上线（你的第3阶段）&lt;/li&gt;&lt;li&gt;&lt;strong&gt;用途&lt;/strong&gt;：在 Claude Code 中&lt;strong&gt;管理 Vercel 部署全流程&lt;/strong&gt;——触发构建、查看构建日志、配置环境变量、管理域名和 DNS、查看部署历史。开发完成后不需要离开终端就可以完成部署和验证。同时包含 React/Next.js 最佳实践规则。&lt;/li&gt;&lt;/ul&gt;
&lt;pre&gt;&lt;code class=&quot;language-bash&quot;&gt;# Claude Code 安装
/plugin install vercel-labs/agent-skills
&lt;/code&gt;&lt;/pre&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;CC Switch 安装&lt;/strong&gt;：Skills 页签 → 搜索 &lt;code&gt;vercel&lt;/code&gt; → 一键安装&lt;/li&gt;&lt;li&gt;🔗 &lt;strong&gt;官网&lt;/strong&gt;：&lt;a href=&quot;https://vercel.com&quot;&gt;https://vercel.com&lt;/a&gt; ｜ &lt;a href=&quot;https://github.com/vercel-labs/agent-skills&quot;&gt;GitHub&lt;/a&gt;&lt;/li&gt;&lt;/ul&gt;
&lt;hr&gt;
&lt;h3 id=&quot;h3-u26062015.20Code20Review20u201420u5E26u8BC4u5206u7684u81EAu52A8u4EE3u7801u8BC4u5BA1-371&quot;&gt;&lt;a class=&quot;reference-link&quot; name=&quot;☆ 15. Code Review — 带评分的自动代码评审&quot;&gt;&lt;/a&gt;&lt;span class=&quot;header-link octicon octicon-link&quot;&gt;&lt;/span&gt;☆ 15. Code Review — 带评分的自动代码评审&lt;/h3&gt;&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;类型&lt;/strong&gt;：Skill&lt;/li&gt;&lt;li&gt;&lt;strong&gt;提供方&lt;/strong&gt;：Anthropic 官方&lt;/li&gt;&lt;li&gt;&lt;strong&gt;适用阶段&lt;/strong&gt;：前后端编码（评审）&lt;/li&gt;&lt;li&gt;&lt;strong&gt;用途&lt;/strong&gt;：对代码进行&lt;strong&gt;多维度量化评分（0-100）&lt;/strong&gt;——安全性、性能、可维护性、正确性、可读性——并给出每个维度的具体改进建议。&lt;/li&gt;&lt;/ul&gt;
&lt;blockquote&gt;&lt;p&gt;💡 &lt;strong&gt;与 PR Review Toolkit 的区别&lt;/strong&gt;：Code Review 更适合日常开发中”写完一个功能就快速检查一下”的轻量场景；PR Review Toolkit 适合正式的 PR 合并前的全面评审。&lt;/p&gt;
&lt;/blockquote&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot;&gt;# Claude Code 安装
/plugin install code-review@claude-plugins-official
&lt;/code&gt;&lt;/pre&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;CC Switch 安装&lt;/strong&gt;：Skills 页签 → 搜索 &lt;code&gt;code-review&lt;/code&gt; → 一键安装&lt;/li&gt;&lt;li&gt;🔗 &lt;strong&gt;官网&lt;/strong&gt;：&lt;a href=&quot;https://github.com/anthropics/claude-plugins-official&quot;&gt;https://github.com/anthropics/claude-plugins-official&lt;/a&gt;&lt;/li&gt;&lt;/ul&gt;
&lt;hr&gt;
&lt;h3 id=&quot;h3-u26062016.20Commit20Commands20u201420u667Au80FDGitu5DE5u4F5Cu6D41-390&quot;&gt;&lt;a class=&quot;reference-link&quot; name=&quot;☆ 16. Commit Commands — 智能Git工作流&quot;&gt;&lt;/a&gt;&lt;span class=&quot;header-link octicon octicon-link&quot;&gt;&lt;/span&gt;☆ 16. Commit Commands — 智能Git工作流&lt;/h3&gt;&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;类型&lt;/strong&gt;：Skill&lt;/li&gt;&lt;li&gt;&lt;strong&gt;提供方&lt;/strong&gt;：Anthropic 官方&lt;/li&gt;&lt;li&gt;&lt;strong&gt;适用阶段&lt;/strong&gt;：前后端编码（Git 操作）&lt;/li&gt;&lt;li&gt;&lt;strong&gt;用途&lt;/strong&gt;：&lt;strong&gt;自动生成语义化 commit message、智能分组提交文件、一键推送和创建 PR&lt;/strong&gt;。遵循 Conventional Commits 规范（&lt;code&gt;feat:&lt;/code&gt; / &lt;code&gt;fix:&lt;/code&gt; / &lt;code&gt;refactor:&lt;/code&gt; / &lt;code&gt;docs:&lt;/code&gt; 等前缀），不再需要手动想 commit message 怎么写。&lt;/li&gt;&lt;/ul&gt;
&lt;pre&gt;&lt;code class=&quot;language-bash&quot;&gt;# Claude Code 安装
/plugin install commit-commands@claude-plugins-official
&lt;/code&gt;&lt;/pre&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;CC Switch 安装&lt;/strong&gt;：Skills 页签 → 搜索 &lt;code&gt;commit-commands&lt;/code&gt; → 一键安装&lt;/li&gt;&lt;li&gt;🔗 &lt;strong&gt;官网&lt;/strong&gt;：&lt;a href=&quot;https://github.com/anthropics/claude-plugins-official&quot;&gt;https://github.com/anthropics/claude-plugins-official&lt;/a&gt;&lt;/li&gt;&lt;/ul&gt;
&lt;hr&gt;
&lt;h3 id=&quot;h3-u26062017.20Security20Guidance20u201420u5B9Eu65F6u5B89u5168u8B66u544A-407&quot;&gt;&lt;a class=&quot;reference-link&quot; name=&quot;☆ 17. Security Guidance — 实时安全警告&quot;&gt;&lt;/a&gt;&lt;span class=&quot;header-link octicon octicon-link&quot;&gt;&lt;/span&gt;☆ 17. Security Guidance — 实时安全警告&lt;/h3&gt;&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;类型&lt;/strong&gt;：Hook&lt;/li&gt;&lt;li&gt;&lt;strong&gt;提供方&lt;/strong&gt;：Anthropic 官方&lt;/li&gt;&lt;li&gt;&lt;strong&gt;适用阶段&lt;/strong&gt;：前后端编码（安全）&lt;/li&gt;&lt;li&gt;&lt;strong&gt;用途&lt;/strong&gt;：在 Claude &lt;strong&gt;编辑代码时&lt;/strong&gt;自动检测潜在的&lt;strong&gt;命令注入、XSS 跨站脚本、SQL 注入、路径遍历&lt;/strong&gt;等安全风险模式，给出即时警告。&lt;/li&gt;&lt;/ul&gt;
&lt;blockquote&gt;&lt;p&gt;💡 &lt;strong&gt;与 Semgrep 的区别&lt;/strong&gt;：Security Guidance 在”代码还在键盘上”的时候就拦截危险操作（预防）；Semgrep 在代码写完后做完整扫描（检测）。两者互补。&lt;/p&gt;
&lt;/blockquote&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot;&gt;# Claude Code 安装
/plugin install security-guidance@claude-plugins-official
&lt;/code&gt;&lt;/pre&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;CC Switch 安装&lt;/strong&gt;：Skills 页签 → 搜索 &lt;code&gt;security-guidance&lt;/code&gt; → 一键安装（Hook 类型）&lt;/li&gt;&lt;li&gt;🔗 &lt;strong&gt;官网&lt;/strong&gt;：&lt;a href=&quot;https://github.com/anthropics/claude-plugins-official&quot;&gt;https://github.com/anthropics/claude-plugins-official&lt;/a&gt;&lt;/li&gt;&lt;/ul&gt;
&lt;hr&gt;
&lt;h3 id=&quot;h3-u26062018.20Ralph20Loop20u201420u8FEDu4EE3u6539u8FDBu5FAAu73AF-426&quot;&gt;&lt;a class=&quot;reference-link&quot; name=&quot;☆ 18. Ralph Loop — 迭代改进循环&quot;&gt;&lt;/a&gt;&lt;span class=&quot;header-link octicon octicon-link&quot;&gt;&lt;/span&gt;☆ 18. Ralph Loop — 迭代改进循环&lt;/h3&gt;&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;类型&lt;/strong&gt;：Skill + Hook&lt;/li&gt;&lt;li&gt;&lt;strong&gt;提供方&lt;/strong&gt;：Anthropic 官方&lt;/li&gt;&lt;li&gt;&lt;strong&gt;适用阶段&lt;/strong&gt;：前后端编码（迭代开发）&lt;/li&gt;&lt;li&gt;&lt;strong&gt;用途&lt;/strong&gt;：让 Claude &lt;strong&gt;循环执行同一个任务直到满足完成标准&lt;/strong&gt;。灵感来自《辛普森一家》的 Ralph Wiggum 角色——“屡败屡战”的精神。适合有明确验证标准的迭代型任务，比如”修复所有 TypeScript 类型错误”或”让所有单元测试通过”。&lt;/li&gt;&lt;/ul&gt;
&lt;pre&gt;&lt;code class=&quot;language-bash&quot;&gt;# Claude Code 安装
/plugin install ralph-loop@claude-plugins-official

# 使用方式
/ralph-loop &quot;你的任务描述&quot; --max-iterations 20 --completion-promise &quot;DONE&quot;
&lt;/code&gt;&lt;/pre&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;CC Switch 安装&lt;/strong&gt;：Skills 页签 → 搜索 &lt;code&gt;ralph-loop&lt;/code&gt; → 一键安装&lt;/li&gt;&lt;li&gt;🔗 &lt;strong&gt;官网&lt;/strong&gt;：&lt;a href=&quot;https://github.com/anthropics/claude-code&quot;&gt;https://github.com/anthropics/claude-code&lt;/a&gt;&lt;/li&gt;&lt;/ul&gt;
&lt;hr&gt;
&lt;h3 id=&quot;h3-u26062019.20Hookify20u201420u81EAu52A8u751Fu6210u81EAu5B9Au4E49Hook-446&quot;&gt;&lt;a class=&quot;reference-link&quot; name=&quot;☆ 19. Hookify — 自动生成自定义Hook&quot;&gt;&lt;/a&gt;&lt;span class=&quot;header-link octicon octicon-link&quot;&gt;&lt;/span&gt;☆ 19. Hookify — 自动生成自定义Hook&lt;/h3&gt;&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;类型&lt;/strong&gt;：Skill + Agent + Hook&lt;/li&gt;&lt;li&gt;&lt;strong&gt;提供方&lt;/strong&gt;：Anthropic 官方&lt;/li&gt;&lt;li&gt;&lt;strong&gt;适用阶段&lt;/strong&gt;：全局自动化&lt;/li&gt;&lt;li&gt;&lt;strong&gt;用途&lt;/strong&gt;：&lt;strong&gt;分析你与 Claude 的交互模式，自动生成自动化 Hook&lt;/strong&gt;。比如你总是让 Claude 在编辑完文件后运行 &lt;code&gt;npx prettier --write&lt;/code&gt;，Hookify 会发现这个模式并生成一个 PostToolUse Hook，从此自动化执行。把”我每次都重复说的那句话”变成”系统自动遵守的规则”。&lt;/li&gt;&lt;/ul&gt;
&lt;pre&gt;&lt;code class=&quot;language-bash&quot;&gt;# Claude Code 安装
/plugin install hookify@claude-plugins-official
&lt;/code&gt;&lt;/pre&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;CC Switch 安装&lt;/strong&gt;：Skills 页签 → 搜索 &lt;code&gt;hookify&lt;/code&gt; → 一键安装&lt;/li&gt;&lt;li&gt;🔗 &lt;strong&gt;官网&lt;/strong&gt;：&lt;a href=&quot;https://github.com/anthropics/claude-plugins-official&quot;&gt;https://github.com/anthropics/claude-plugins-official&lt;/a&gt;&lt;/li&gt;&lt;/ul&gt;
&lt;hr&gt;
&lt;h2 id=&quot;h2-uD83DuDD2720u6309u4F60u7684u6280u672Fu6808u9009u62E9-463&quot;&gt;&lt;a class=&quot;reference-link&quot; name=&quot;🔧 按你的技术栈选择&quot;&gt;&lt;/a&gt;&lt;span class=&quot;header-link octicon octicon-link&quot;&gt;&lt;/span&gt;🔧 按你的技术栈选择&lt;/h2&gt;&lt;p&gt;以下是&lt;strong&gt;和你的技术栈强相关&lt;/strong&gt;的插件——不需要全装，按你实际使用的技术选配。&lt;/p&gt;
&lt;h3 id=&quot;h3-uD83DuDDC4uFE0F20u540Eu7AEFu6280u672Fu6808-467&quot;&gt;&lt;a class=&quot;reference-link&quot; name=&quot;🗄️ 后端技术栈&quot;&gt;&lt;/a&gt;&lt;span class=&quot;header-link octicon octicon-link&quot;&gt;&lt;/span&gt;🗄️ 后端技术栈&lt;/h3&gt;&lt;p&gt;&lt;strong&gt;△ Postman — API全生命周期管理&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;类型&lt;/strong&gt;：MCP + Skill + Agent&lt;/li&gt;&lt;li&gt;&lt;strong&gt;用途&lt;/strong&gt;：在 Claude Code 中直接调用 Postman Collection 测试 API 端点、查看请求/响应、管理 API 文档。如果你主力做 RESTful API 或微服务架构开发，Postman MCP 把 API 调试也融入了 AI 编程流程。&lt;/li&gt;&lt;li&gt;&lt;strong&gt;安装&lt;/strong&gt;：&lt;code&gt;claude mcp add --transport http postman https://mcp.postman.com/mcp&lt;/code&gt;&lt;/li&gt;&lt;li&gt;🔗 &lt;strong&gt;官网&lt;/strong&gt;：&lt;a href=&quot;https://www.postman.com&quot;&gt;https://www.postman.com&lt;/a&gt;&lt;/li&gt;&lt;/ul&gt;
&lt;p&gt;&lt;strong&gt;△ Supabase — 开源BaaS后端&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;类型&lt;/strong&gt;：MCP&lt;/li&gt;&lt;li&gt;&lt;strong&gt;用途&lt;/strong&gt;：管理 Supabase 的 &lt;strong&gt;PostgreSQL 数据库（查询/Schema/RLS策略）、用户认证（邮箱/OAuth/SSO）、文件存储、Edge Functions&lt;/strong&gt;。如果你用 Supabase 做后端，这个 MCP 让你的 Claude 可以直接操作数据库和执行迁移。&lt;/li&gt;&lt;li&gt;&lt;strong&gt;安装&lt;/strong&gt;：&lt;code&gt;claude mcp add supabase -- npx -y supabase-mcp-server&lt;/code&gt;&lt;/li&gt;&lt;li&gt;🔗 &lt;strong&gt;官网&lt;/strong&gt;：&lt;a href=&quot;https://supabase.com&quot;&gt;https://supabase.com&lt;/a&gt;&lt;/li&gt;&lt;/ul&gt;
&lt;p&gt;&lt;strong&gt;△ Firebase — Google后端即服务&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;类型&lt;/strong&gt;：MCP&lt;/li&gt;&lt;li&gt;&lt;strong&gt;用途&lt;/strong&gt;：管理 Firebase 的 Firestore 数据库、Cloud Functions、Authentication、Hosting。Google 生态的全栈项目首选。&lt;/li&gt;&lt;li&gt;&lt;strong&gt;安装&lt;/strong&gt;：&lt;code&gt;claude mcp add firebase -- npx -y firebase-mcp-server&lt;/code&gt;&lt;/li&gt;&lt;li&gt;🔗 &lt;strong&gt;官网&lt;/strong&gt;：&lt;a href=&quot;https://firebase.google.com&quot;&gt;https://firebase.google.com&lt;/a&gt;&lt;/li&gt;&lt;/ul&gt;
&lt;p&gt;&lt;strong&gt;△ Pinecone — 向量数据库&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;类型&lt;/strong&gt;：MCP + Skill&lt;/li&gt;&lt;li&gt;&lt;strong&gt;用途&lt;/strong&gt;：管理向量索引、插入/查询向量数据、实现语义搜索和 RAG（检索增强生成）。如果你在做 AI 应用（如智能客服、知识库问答），Pinecone 是构建 RAG Pipeline 的关键组件。&lt;/li&gt;&lt;li&gt;&lt;strong&gt;安装&lt;/strong&gt;：&lt;code&gt;claude mcp add pinecone -- npx -y pinecone-mcp-server&lt;/code&gt;&lt;/li&gt;&lt;li&gt;🔗 &lt;strong&gt;官网&lt;/strong&gt;：&lt;a href=&quot;https://www.pinecone.io&quot;&gt;https://www.pinecone.io&lt;/a&gt;&lt;/li&gt;&lt;/ul&gt;
&lt;p&gt;&lt;strong&gt;△ Stripe — 支付系统开发&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;类型&lt;/strong&gt;：MCP + Skill&lt;/li&gt;&lt;li&gt;&lt;strong&gt;用途&lt;/strong&gt;：Stripe 支付集成——支付意图创建、订阅管理、Webhook 测试。做电商、SaaS 订阅等需要支付的项目时使用。&lt;/li&gt;&lt;li&gt;&lt;strong&gt;安装&lt;/strong&gt;：通过 Stripe 官方插件市场&lt;/li&gt;&lt;li&gt;🔗 &lt;strong&gt;官网&lt;/strong&gt;：&lt;a href=&quot;https://stripe.com&quot;&gt;https://stripe.com&lt;/a&gt;&lt;/li&gt;&lt;/ul&gt;
&lt;p&gt;&lt;strong&gt;△ Laravel Boost — Laravel开发辅助&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;类型&lt;/strong&gt;：MCP&lt;/li&gt;&lt;li&gt;&lt;strong&gt;用途&lt;/strong&gt;：专为 Laravel 开发者打造——Artisan 命令智能提示、Eloquent ORM 关系辅助、路由文件生成、迁移文件管理、Blade 模板提示。PHP/Laravel 技术栈必备。&lt;/li&gt;&lt;li&gt;&lt;strong&gt;安装&lt;/strong&gt;：&lt;code&gt;claude mcp add laravel-boost -- npx -y laravel-boost-mcp&lt;/code&gt;&lt;/li&gt;&lt;li&gt;🔗 &lt;strong&gt;官网&lt;/strong&gt;：npm 包 &lt;code&gt;laravel-boost-mcp&lt;/code&gt;&lt;/li&gt;&lt;/ul&gt;
&lt;p&gt;&lt;strong&gt;△ HuggingFace Skills — AI模型与数据集&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;类型&lt;/strong&gt;：MCP + Skill&lt;/li&gt;&lt;li&gt;&lt;strong&gt;用途&lt;/strong&gt;：连接 HuggingFace 生态——搜索开源 AI 模型、数据集、Spaces 应用。当你的项目需要集成 AI 模型（文本分类、图像识别、语音处理等）时，可以直接在 Claude Code 中查找和引用 HuggingFace 模型。&lt;/li&gt;&lt;li&gt;&lt;strong&gt;安装&lt;/strong&gt;：通过 HuggingFace MCP 接入&lt;/li&gt;&lt;li&gt;🔗 &lt;strong&gt;官网&lt;/strong&gt;：&lt;a href=&quot;https://huggingface.co&quot;&gt;https://huggingface.co&lt;/a&gt;&lt;/li&gt;&lt;/ul&gt;
&lt;hr&gt;
&lt;h3 id=&quot;h3-uD83DuDD0D20u4EE3u7801u641Cu7D22u4E0Eu5206u6790-513&quot;&gt;&lt;a class=&quot;reference-link&quot; name=&quot;🔍 代码搜索与分析&quot;&gt;&lt;/a&gt;&lt;span class=&quot;header-link octicon octicon-link&quot;&gt;&lt;/span&gt;🔍 代码搜索与分析&lt;/h3&gt;&lt;p&gt;&lt;strong&gt;△ Greptile — 自然语言代码搜索&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;类型&lt;/strong&gt;：MCP&lt;/li&gt;&lt;li&gt;&lt;strong&gt;用途&lt;/strong&gt;：用&lt;strong&gt;自然语言（中文也行）搜索和理解大型代码库&lt;/strong&gt;。不需要知道确切的函数名——问”用户注册流程在哪些文件里？”就能找到相关代码。适合大型单体项目或多仓库场景。&lt;/li&gt;&lt;li&gt;&lt;strong&gt;安装&lt;/strong&gt;：&lt;code&gt;npx greptile-mcp-server --api-key=YOUR_KEY --github-token=YOUR_TOKEN&lt;/code&gt;&lt;/li&gt;&lt;li&gt;🔗 &lt;strong&gt;官网&lt;/strong&gt;：&lt;a href=&quot;https://app.greptile.com&quot;&gt;https://app.greptile.com&lt;/a&gt;&lt;/li&gt;&lt;/ul&gt;
&lt;hr&gt;
&lt;h3 id=&quot;h3-uD83DuDD77uFE0F20u6570u636Eu6293u53D6-523&quot;&gt;&lt;a class=&quot;reference-link&quot; name=&quot;🕷️ 数据抓取&quot;&gt;&lt;/a&gt;&lt;span class=&quot;header-link octicon octicon-link&quot;&gt;&lt;/span&gt;🕷️ 数据抓取&lt;/h3&gt;&lt;p&gt;&lt;strong&gt;△ Firecrawl — 网页转Markdown&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;类型&lt;/strong&gt;：Skill&lt;/li&gt;&lt;li&gt;&lt;strong&gt;用途&lt;/strong&gt;：&lt;strong&gt;将任意网站转换为 LLM 友好的 Markdown 格式&lt;/strong&gt;——支持搜索、单页抓取、整站爬取、页面交互。当你需要让 Claude 参考某个网站的内容或文档时（比如爬取竞争对手的公开页面做竞品分析），Firecrawl 把网络变成知识源。&lt;/li&gt;&lt;li&gt;&lt;strong&gt;安装&lt;/strong&gt;：&lt;code&gt;npx -y firecrawl-cli&lt;a class=&quot;at-link&quot; title=&quot;@latest&quot; href=&quot;https://github.com/latest&quot;&gt;@latest&lt;/a&gt; init -y --browser&lt;/code&gt;&lt;/li&gt;&lt;li&gt;🔗 &lt;strong&gt;官网&lt;/strong&gt;：&lt;a href=&quot;https://www.firecrawl.dev&quot;&gt;https://www.firecrawl.dev&lt;/a&gt;&lt;/li&gt;&lt;/ul&gt;
&lt;hr&gt;
&lt;h3 id=&quot;h3-u270520u4EE3u7801u8D28u91CFu589Eu5F3A-533&quot;&gt;&lt;a class=&quot;reference-link&quot; name=&quot;✅ 代码质量增强&quot;&gt;&lt;/a&gt;&lt;span class=&quot;header-link octicon octicon-link&quot;&gt;&lt;/span&gt;✅ 代码质量增强&lt;/h3&gt;&lt;p&gt;&lt;strong&gt;△ Qodo Skills — 代码质量/测试/安全/合规&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;类型&lt;/strong&gt;：Skill&lt;/li&gt;&lt;li&gt;&lt;strong&gt;用途&lt;/strong&gt;：一组专注于&lt;strong&gt;代码质量、测试用例生成、安全检查和合规性&lt;/strong&gt;的技能。帮助 Claude 写出更健壮的测试（边界情况覆盖）、检查代码规范一致性、确保行业合规要求（如 GDPR、SOC2）。&lt;/li&gt;&lt;li&gt;&lt;strong&gt;安装&lt;/strong&gt;：&lt;code&gt;/plugin install qodo-skills&lt;a class=&quot;at-link&quot; title=&quot;@claude&quot; href=&quot;https://github.com/claude&quot;&gt;@claude&lt;/a&gt;-plugins-official&lt;/code&gt;&lt;/li&gt;&lt;li&gt;🔗 &lt;strong&gt;官网&lt;/strong&gt;：&lt;a href=&quot;https://www.qodo.ai&quot;&gt;https://www.qodo.ai&lt;/a&gt;&lt;/li&gt;&lt;/ul&gt;
&lt;p&gt;&lt;strong&gt;△ Coderabbit — 40+分析器的AI代码评审（免费）&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;类型&lt;/strong&gt;：Skill + Agent&lt;/li&gt;&lt;li&gt;&lt;strong&gt;用途&lt;/strong&gt;：聚合 &lt;strong&gt;40+ 个静态分析器&lt;/strong&gt;（包括各语言的 Linter、安全扫描器、复杂度分析器）的结果，由 AI 整合成一份综合评审报告。免费使用，提供比单一工具更全面的代码质量画像。&lt;/li&gt;&lt;li&gt;&lt;strong&gt;安装&lt;/strong&gt;：通过 Coderabbit MCP 接入&lt;/li&gt;&lt;li&gt;🔗 &lt;strong&gt;官网&lt;/strong&gt;：&lt;a href=&quot;https://www.coderabbit.ai&quot;&gt;https://www.coderabbit.ai&lt;/a&gt;&lt;/li&gt;&lt;/ul&gt;
&lt;hr&gt;
&lt;h3 id=&quot;h3-uD83DuDCC820u76D1u63A7u4E0Eu4EA7u54C1u5206u6790-549&quot;&gt;&lt;a class=&quot;reference-link&quot; name=&quot;📈 监控与产品分析&quot;&gt;&lt;/a&gt;&lt;span class=&quot;header-link octicon octicon-link&quot;&gt;&lt;/span&gt;📈 监控与产品分析&lt;/h3&gt;&lt;p&gt;&lt;strong&gt;△ PostHog — 产品分析&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;类型&lt;/strong&gt;：MCP + Skill + Agent&lt;/li&gt;&lt;li&gt;&lt;strong&gt;用途&lt;/strong&gt;：查询用户行为数据、管理 Feature Flags（功能开关灰度发布）、查看 A/B 测试结果。在部署上线后验证新功能的效果——多少用户点击了新按钮、转化率有没有提升。&lt;/li&gt;&lt;li&gt;&lt;strong&gt;安装&lt;/strong&gt;：&lt;code&gt;claude mcp add --transport http posthog https://mcp.posthog.com/mcp&lt;/code&gt;&lt;/li&gt;&lt;li&gt;🔗 &lt;strong&gt;官网&lt;/strong&gt;：&lt;a href=&quot;https://posthog.com&quot;&gt;https://posthog.com&lt;/a&gt;&lt;/li&gt;&lt;/ul&gt;
&lt;p&gt;&lt;strong&gt;△ PagerDuty — 部署风险评分&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;类型&lt;/strong&gt;：MCP + Skill&lt;/li&gt;&lt;li&gt;&lt;strong&gt;用途&lt;/strong&gt;：在 git commit / push 前&lt;strong&gt;对比 PagerDuty 的历史告警数据和当前变更 diff&lt;/strong&gt;，预估部署风险。如果当前变更的文件最近在生产环境出过事故，它会给出高风险提示。&lt;/li&gt;&lt;li&gt;&lt;strong&gt;安装&lt;/strong&gt;：通过 PagerDuty MCP 接入&lt;/li&gt;&lt;li&gt;🔗 &lt;strong&gt;官网&lt;/strong&gt;：&lt;a href=&quot;https://www.pagerduty.com&quot;&gt;https://www.pagerduty.com&lt;/a&gt;&lt;/li&gt;&lt;/ul&gt;
&lt;p&gt;&lt;strong&gt;△ Sonatype Guide — 依赖漏洞分析&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;类型&lt;/strong&gt;：MCP&lt;/li&gt;&lt;li&gt;&lt;strong&gt;用途&lt;/strong&gt;：扫描项目依赖的&lt;strong&gt;已知 CVE 漏洞&lt;/strong&gt;，推荐安全升级版本。基于 Sonatype 的全球最大漏洞数据库之一，确保供应链安全。&lt;/li&gt;&lt;li&gt;&lt;strong&gt;安装&lt;/strong&gt;：通过 Sonatype MCP 接入&lt;/li&gt;&lt;li&gt;🔗 &lt;strong&gt;官网&lt;/strong&gt;：&lt;a href=&quot;https://www.sonatype.com&quot;&gt;https://www.sonatype.com&lt;/a&gt;&lt;/li&gt;&lt;/ul&gt;
&lt;hr&gt;
&lt;h2 id=&quot;h2-uD83DuDC6520u6309u4F60u7684u56E2u961Fu5DE5u5177u9009u62E9-571&quot;&gt;&lt;a class=&quot;reference-link&quot; name=&quot;👥 按你的团队工具选择&quot;&gt;&lt;/a&gt;&lt;span class=&quot;header-link octicon octicon-link&quot;&gt;&lt;/span&gt;👥 按你的团队工具选择&lt;/h2&gt;&lt;p&gt;以下插件用来连接你团队已经在用的协作工具——没有对应的工具就不用装。&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;△ Linear&lt;/strong&gt;：Linear Issue 管理、Sprint 看板。&lt;strong&gt;MCP，HTTP 类型&lt;/strong&gt;。🔗 &lt;a href=&quot;https://linear.app&quot;&gt;linear.app&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;strong&gt;△ Atlassian&lt;/strong&gt;：Jira Issue + Confluence 文档。&lt;strong&gt;MCP+Skill，HTTP 类型&lt;/strong&gt;。🔗 &lt;a href=&quot;https://www.atlassian.com&quot;&gt;atlassian.com&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;strong&gt;△ Asana&lt;/strong&gt;：Asana 任务和项目管理。&lt;strong&gt;MCP，HTTP 类型&lt;/strong&gt;。🔗 &lt;a href=&quot;https://asana.com&quot;&gt;asana.com&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;strong&gt;△ Notion&lt;/strong&gt;：Notion 页面和数据库操作。&lt;strong&gt;MCP+Skill，HTTP 类型&lt;/strong&gt;。🔗 &lt;a href=&quot;https://www.notion.so&quot;&gt;notion.so&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;strong&gt;△ Slack&lt;/strong&gt;：Slack 消息搜索、频道浏览。&lt;strong&gt;MCP+Skill，HTTP 类型&lt;/strong&gt;。🔗 &lt;a href=&quot;https://slack.com&quot;&gt;slack.com&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;strong&gt;△ GitLab&lt;/strong&gt;：GitLab 仓库、MR、CI/CD。&lt;strong&gt;MCP，HTTP 类型&lt;/strong&gt;。🔗 &lt;a href=&quot;https://gitlab.com&quot;&gt;gitlab.com&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;strong&gt;△ Circleback&lt;/strong&gt;：会议记录、邮件、日历检索。&lt;strong&gt;MCP，HTTP 类型&lt;/strong&gt;。🔗 &lt;a href=&quot;https://circleback.ai&quot;&gt;circleback.ai&lt;/a&gt;&lt;/li&gt;&lt;/ul&gt;
&lt;blockquote&gt;&lt;p&gt;💡 安装方式均为：&lt;code&gt;claude mcp add --transport http &amp;lt;名称&amp;gt; &amp;lt;MCP端点URL&amp;gt;&lt;/code&gt;，在 CC Switch 的 MCP 页签中添加对应 HTTP 类型服务器。&lt;/p&gt;
&lt;/blockquote&gt;&lt;hr&gt;
&lt;h2 id=&quot;h2-uD83DuDCDD20LSPu8BEDu8A00u670Du52A1u5668uFF081220u4E2A20u201420u6309u4F60u7684u7F16u7A0Bu8BEDu8A00u9009u62E9uFF09-587&quot;&gt;&lt;a class=&quot;reference-link&quot; name=&quot;📝 LSP语言服务器（12 个 — 按你的编程语言选择）&quot;&gt;&lt;/a&gt;&lt;span class=&quot;header-link octicon octicon-link&quot;&gt;&lt;/span&gt;📝 LSP语言服务器（12 个 — 按你的编程语言选择）&lt;/h2&gt;&lt;p&gt;LSP 服务器为 Claude Code 提供&lt;strong&gt;真实的 IDE 级类型检查、智能补全和跳转定义&lt;/strong&gt;能力。按你的项目语言选对应的一个即可，不需要全装：&lt;/p&gt;
&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;LSP 名称&lt;/th&gt;
&lt;th&gt;适用语言&lt;/th&gt;
&lt;th&gt;Claude Code 安装&lt;/th&gt;
&lt;th&gt;官网&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;TypeScript LSP&lt;/td&gt;
&lt;td&gt;TypeScript / JavaScript&lt;/td&gt;
&lt;td&gt;&lt;code&gt;/lsp add typescript&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;TypeScript 官方&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Pyright LSP&lt;/td&gt;
&lt;td&gt;Python&lt;/td&gt;
&lt;td&gt;&lt;code&gt;/lsp add pyright&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;a href=&quot;https://github.com/microsoft/pyright&quot;&gt;Pyright&lt;/a&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Gopls LSP&lt;/td&gt;
&lt;td&gt;Go&lt;/td&gt;
&lt;td&gt;&lt;code&gt;/lsp add gopls&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;a href=&quot;https://github.com/golang/tools&quot;&gt;gopls&lt;/a&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Rust Analyzer LSP&lt;/td&gt;
&lt;td&gt;Rust&lt;/td&gt;
&lt;td&gt;&lt;code&gt;/lsp add rust-analyzer&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;a href=&quot;https://github.com/rust-lang/rust-analyzer&quot;&gt;rust-analyzer&lt;/a&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;ClangD LSP&lt;/td&gt;
&lt;td&gt;C / C++&lt;/td&gt;
&lt;td&gt;&lt;code&gt;/lsp add clangd&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;a href=&quot;https://clangd.llvm.org/&quot;&gt;clangd&lt;/a&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;PHP LSP&lt;/td&gt;
&lt;td&gt;PHP&lt;/td&gt;
&lt;td&gt;&lt;code&gt;/lsp add php&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;a href=&quot;https://intelephense.com/&quot;&gt;Intelephense&lt;/a&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Swift LSP&lt;/td&gt;
&lt;td&gt;Swift&lt;/td&gt;
&lt;td&gt;&lt;code&gt;/lsp add swift&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;a href=&quot;https://github.com/apple/sourcekit-lsp&quot;&gt;SourceKit-LSP&lt;/a&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Kotlin LSP&lt;/td&gt;
&lt;td&gt;Kotlin&lt;/td&gt;
&lt;td&gt;&lt;code&gt;/lsp add kotlin&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Kotlin 官方&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;C# LSP&lt;/td&gt;
&lt;td&gt;C#&lt;/td&gt;
&lt;td&gt;&lt;code&gt;/lsp add csharp&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;.NET 官方&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;JDTLS LSP&lt;/td&gt;
&lt;td&gt;Java&lt;/td&gt;
&lt;td&gt;&lt;code&gt;/lsp add jdtls&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;a href=&quot;https://github.com/eclipse-jdtls/eclipse.jdt.ls&quot;&gt;Eclipse JDT.LS&lt;/a&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Lua LSP&lt;/td&gt;
&lt;td&gt;Lua&lt;/td&gt;
&lt;td&gt;&lt;code&gt;/lsp add lua&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Lua 社区&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Ruby LSP&lt;/td&gt;
&lt;td&gt;Ruby&lt;/td&gt;
&lt;td&gt;&lt;code&gt;/lsp add ruby&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Ruby 社区&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;blockquote&gt;&lt;p&gt;💡 &lt;strong&gt;CC Switch 配置&lt;/strong&gt;：所有 LSP 可在 CC Switch 的 LSP 管理页签中一键启用/禁用。&lt;/p&gt;
&lt;/blockquote&gt;&lt;hr&gt;
&lt;h2 id=&quot;h2-uD83EuDDE920u5176u4ED6u8F85u52A9u7C7B-610&quot;&gt;&lt;a class=&quot;reference-link&quot; name=&quot;🧩 其他辅助类&quot;&gt;&lt;/a&gt;&lt;span class=&quot;header-link octicon octicon-link&quot;&gt;&lt;/span&gt;🧩 其他辅助类&lt;/h2&gt;&lt;p&gt;以下插件用于特定场景——创建插件/自定义 Skill、教学引导、配置管理：&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;△ Agent SDK Dev&lt;/strong&gt;：Claude Agent SDK 应用开发脚手架（TypeScript/Python）。&lt;strong&gt;Skill+Agent&lt;/strong&gt;。&lt;code&gt;/plugin install agent-sdk-dev&lt;a class=&quot;at-link&quot; title=&quot;@claude&quot; href=&quot;https://github.com/claude&quot;&gt;@claude&lt;/a&gt;-plugins-official&lt;/code&gt;&lt;/li&gt;&lt;li&gt;&lt;strong&gt;△ Plugin Dev&lt;/strong&gt;：Claude Code 插件开发套件（含 7 个子 Skill：MCP集成/Hook/Skill创建/测试/安全审计/发布）。&lt;strong&gt;Skill+Agent&lt;/strong&gt;。&lt;code&gt;/plugin install plugin-dev&lt;a class=&quot;at-link&quot; title=&quot;@claude&quot; href=&quot;https://github.com/claude&quot;&gt;@claude&lt;/a&gt;-plugins-official&lt;/code&gt;&lt;/li&gt;&lt;li&gt;&lt;strong&gt;△ Skill Creator&lt;/strong&gt;：自定义 Skill 的创建、改进和效果评估工具。&lt;strong&gt;Skill&lt;/strong&gt;。&lt;code&gt;/plugin install skill-creator&lt;a class=&quot;at-link&quot; title=&quot;@claude&quot; href=&quot;https://github.com/claude&quot;&gt;@claude&lt;/a&gt;-plugins-official&lt;/code&gt;&lt;/li&gt;&lt;li&gt;&lt;strong&gt;△ Code Simplifier&lt;/strong&gt;：3 个并行 Agent（复用检查/质量检查/效率检查）重构最近变更。&lt;strong&gt;Agent&lt;/strong&gt;。内置命令 &lt;code&gt;/simplify&lt;/code&gt;&lt;/li&gt;&lt;li&gt;&lt;strong&gt;△ Playground&lt;/strong&gt;：生成交互式 HTML/CSS/JS 原型演示页面。&lt;strong&gt;Skill&lt;/strong&gt;。&lt;code&gt;/plugin install playground&lt;a class=&quot;at-link&quot; title=&quot;@claude&quot; href=&quot;https://github.com/claude&quot;&gt;@claude&lt;/a&gt;-plugins-official&lt;/code&gt;&lt;/li&gt;&lt;li&gt;&lt;strong&gt;△ Claude Code Setup&lt;/strong&gt;：自动分析代码库并推荐最优的 MCP/Skill/Hook 配置。&lt;strong&gt;Skill&lt;/strong&gt;。&lt;code&gt;/plugin install claude-code-setup&lt;a class=&quot;at-link&quot; title=&quot;@claude&quot; href=&quot;https://github.com/claude&quot;&gt;@claude&lt;/a&gt;-plugins-official&lt;/code&gt;&lt;/li&gt;&lt;li&gt;&lt;strong&gt;△ Claude MD Management&lt;/strong&gt;：CLAUDE.md 文件的定期质量审计和自动更新。&lt;strong&gt;Skill&lt;/strong&gt;。&lt;code&gt;/plugin install claude-md-management&lt;a class=&quot;at-link&quot; title=&quot;@claude&quot; href=&quot;https://github.com/claude&quot;&gt;@claude&lt;/a&gt;-plugins-official&lt;/code&gt;&lt;/li&gt;&lt;li&gt;&lt;strong&gt;△ Explanatory Output Style&lt;/strong&gt;：教学模式——Claude 会解释每个实现选择背后的”为什么”。&lt;strong&gt;Hook&lt;/strong&gt;。&lt;code&gt;/plugin install explanatory-output-style&lt;a class=&quot;at-link&quot; title=&quot;@claude&quot; href=&quot;https://github.com/claude&quot;&gt;@claude&lt;/a&gt;-plugins-official&lt;/code&gt;&lt;/li&gt;&lt;li&gt;&lt;strong&gt;△ Learning Output Style&lt;/strong&gt;：在关键决策点暂停，引导你主动编写代码。&lt;strong&gt;Hook&lt;/strong&gt;。&lt;code&gt;/plugin install learning-output-style&lt;a class=&quot;at-link&quot; title=&quot;@claude&quot; href=&quot;https://github.com/claude&quot;&gt;@claude&lt;/a&gt;-plugins-official&lt;/code&gt;&lt;/li&gt;&lt;/ul&gt;
&lt;hr&gt;
&lt;h2 id=&quot;h2-uD83DuDE8020u63A8u8350u5B89u88C5u987Au5E8F-626&quot;&gt;&lt;a class=&quot;reference-link&quot; name=&quot;🚀 推荐安装顺序&quot;&gt;&lt;/a&gt;&lt;span class=&quot;header-link octicon octicon-link&quot;&gt;&lt;/span&gt;🚀 推荐安装顺序&lt;/h2&gt;&lt;h3 id=&quot;h3-uD83DuDCC520u7B2Cu4E00u5929uFF1Au6700u5C0Fu53EFu7528uFF08620u4E2Au6838u5FC3uFF09-628&quot;&gt;&lt;a class=&quot;reference-link&quot; name=&quot;📅 第一天：最小可用（6 个核心）&quot;&gt;&lt;/a&gt;&lt;span class=&quot;header-link octicon octicon-link&quot;&gt;&lt;/span&gt;📅 第一天：最小可用（6 个核心）&lt;/h3&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot;&gt;# === MCP ===
claude mcp add sequential-thinking -s user -- npx -y @modelcontextprotocol/server-sequential-thinking
claude mcp add context7 --transport http --header &quot;CONTEXT7_API_KEY: xxx&quot; context7 https://mcp.context7.com/mcp
claude mcp add playwright -- npx -y @anthropic-ai/playwright-mcp

# === Skill ===
/plugin install frontend-design@claude-plugins-official
/plugin install feature-dev@claude-plugins-official
npx skills add OthmanAdi/planning-with-files --skill planning-with-files-zh -g
&lt;/code&gt;&lt;/pre&gt;
&lt;h3 id=&quot;h3-uD83DuDCC520u7B2Cu4E00u5468uFF1Au52A0u4E0Au63A8u8350uFF08u5171201920u4E2AuFF09-642&quot;&gt;&lt;a class=&quot;reference-link&quot; name=&quot;📅 第一周：加上推荐（共 19 个）&quot;&gt;&lt;/a&gt;&lt;span class=&quot;header-link octicon octicon-link&quot;&gt;&lt;/span&gt;📅 第一周：加上推荐（共 19 个）&lt;/h3&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot;&gt;# === MCP ===
claude mcp add --transport http figma https://mcp.figma.com/mcp
claude mcp add --transport http sentry https://mcp.sentry.dev/mcp

# === Skill ===
/plugin marketplace add obra/superpowers-marketplace &amp;amp;&amp;amp; /plugin install superpowers@superpowers-marketplace
/plugin install pr-review-toolkit@claude-plugins-official
/plugin install code-review@claude-plugins-official
/plugin install commit-commands@claude-plugins-official
/plugin install security-guidance@claude-plugins-official
/plugin install ralph-loop@claude-plugins-official
/plugin install hookify@claude-plugins-official
/plugin install vercel-labs/agent-skills

# === LSP ===
/lsp add typescript    # 或你用的语言
&lt;/code&gt;&lt;/pre&gt;
&lt;h3 id=&quot;h3-uD83DuDCC520u540Eu7EEDuFF1Au6309u9700u6DFBu52A0-663&quot;&gt;&lt;a class=&quot;reference-link&quot; name=&quot;📅 后续：按需添加&quot;&gt;&lt;/a&gt;&lt;span class=&quot;header-link octicon octicon-link&quot;&gt;&lt;/span&gt;📅 后续：按需添加&lt;/h3&gt;&lt;p&gt;每个迭代回顾：哪个环节重复劳动最多？装对应的插件。&lt;/p&gt;
&lt;hr&gt;
&lt;blockquote&gt;&lt;p&gt;💡 综上，我的核心建议是：**不要追求”装全”**。每个 MCP/Skill 都会消耗上下文窗口和启动时间。建议保持 &lt;strong&gt;2-3 个 MCP + 3-5 个 Skill&lt;/strong&gt; 处于活跃状态。一个精心编写的 &lt;code&gt;CLAUDE.md&lt;/code&gt;（定义你的项目规范、技术栈、代码风格）比 20 个插件更有价值。&lt;/p&gt;
&lt;/blockquote&gt;&lt;/body&gt;&lt;/p&gt;</description><pubDate>Mon, 18 May 2026 16:42:26 +0800</pubDate></item><item><title>Claude Code使用</title><link>https://blog.smallhao.fun/?id=51</link><description>&lt;head&gt;&lt;/head&gt;&lt;body&gt;&lt;h2 id=&quot;h2-1u30012020CCSwicth-1&quot;&gt;&lt;a class=&quot;reference-link&quot; name=&quot;1、  CCSwicth&quot;&gt;&lt;/a&gt;&lt;span class=&quot;header-link octicon octicon-link&quot;&gt;&lt;/span&gt;1、&lt;a title=&quot;CCSwicth&quot; href=&quot;https://github.com/farion1231/cc-switch/releases&quot;&gt;CCSwicth&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;CC-Switch项目介绍&lt;br&gt;✨ 核心特性&lt;br&gt;CC-Switch从最初的简单API提供商切换工具，已经发展成功能完善的AI CLI管理平台，主要特性包括：&lt;/p&gt;
&lt;p&gt;• 🚀 一键切换配置 ：点击即可切换不同API配置，从5分钟缩短到5秒，效率提升60倍&lt;br&gt;• ☁️ 云端同步配置 （本文重点）：通过坚果云/OneDrive/Dropbox实现多设备自动同步，配置永不丢失&lt;br&gt;• 🎯 多工具支持 ：完美支持Claude Code、Codex、Gemini CLI三大AI编程工具&lt;br&gt;• 🔧 MCP服务器管理 ：统一管理Model Context Protocol服务器，支持stdio、HTTP、SSE三种传输类型&lt;br&gt;• ⚡ API速度测试 ：内置端点测试功能，自动识别最快的API提供商&lt;br&gt;• 📦 配置导入导出 ：一键导出配置分享给团队，自动备份最近10个版本&lt;br&gt;• 💾 双层架构 ：SQLite + JSON双层设计，同步效率高性能好&lt;br&gt;• 🌍 多平台支持 ：完整支持Windows、macOS、Linux（包括WSL）&lt;/p&gt;
&lt;h2 id=&quot;h2-2u3001MCP-15&quot;&gt;&lt;a class=&quot;reference-link&quot; name=&quot;2、MCP&quot;&gt;&lt;/a&gt;&lt;span class=&quot;header-link octicon octicon-link&quot;&gt;&lt;/span&gt;2、MCP&lt;/h2&gt;&lt;blockquote&gt;&lt;p&gt;通过CCSwicth 进行安装&lt;/p&gt;
&lt;/blockquote&gt;&lt;p&gt;&lt;img style=&quot;max-width:100%;&quot; title=&quot;常用MCP&quot; alt=&quot;null&quot; src=&quot;https://blog.smallhao.fun/zb_users/upload/2026/05/202605081602557974533.jpg&quot;&gt;&lt;/p&gt;
&lt;p&gt;&lt;a title=&quot;Claude Code推荐MCP&quot; href=&quot;https://blog.csdn.net/m0_37988015/article/details/160581087&quot;&gt;Claude Code推荐MCP&lt;/a&gt;&lt;/p&gt;
&lt;h2 id=&quot;h2-3u3001skills-24&quot;&gt;&lt;a class=&quot;reference-link&quot; name=&quot;3、skills&quot;&gt;&lt;/a&gt;&lt;span class=&quot;header-link octicon octicon-link&quot;&gt;&lt;/span&gt;3、skills&lt;/h2&gt;&lt;p&gt;1、&lt;a title=&quot;ui-ux-pro-max&quot; href=&quot;https://github.com/nextlevelbuilder/ui-ux-pro-max-skill&quot;&gt;ui-ux-pro-max&lt;/a&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;67 种 UI 风格——玻璃化、黏土化、极简主义、粗犷主义、拟物化、Bento 网格、暗黑模式、AI 原生 UI 等等&lt;/li&gt;&lt;li&gt;161 种颜色方案- 与 161 种产品类型一一对应的行业特定颜色方案&lt;/li&gt;&lt;li&gt;57 种字体搭配- 精选的字体组合，并导入了 Google Fonts 字体&lt;/li&gt;&lt;li&gt;25 种图表类型- 仪表盘和分析的建议&lt;/li&gt;&lt;li&gt;15 种技术栈- React、Next.js、Astro、Vue、Nuxt.js、Nuxt UI、Svelte、SwiftUI、React Native、Flutter、HTML+Tailwind、shadcn/ui、Jetpack Compose、Angular、Laravel&lt;/li&gt;&lt;li&gt;99 条用户体验指南——最佳实践、反模式和无障碍规则&lt;/li&gt;&lt;li&gt;161 条推理规则- 行业特定设计系统生成（v2.0 新增）&lt;/li&gt;&lt;/ul&gt;
&lt;/body&gt;</description><pubDate>Fri, 08 May 2026 15:58:13 +0800</pubDate></item><item><title>V2Ray 自建节点教程</title><link>https://blog.smallhao.fun/?id=50</link><description>&lt;head&gt;&lt;/head&gt;&lt;body&gt;&lt;h1 id=&quot;h1-V2Ray20u81EAu5EFAu8282u70B9u6559u7A0B-1&quot;&gt;&lt;a class=&quot;reference-link&quot; name=&quot;V2Ray 自建节点教程&quot;&gt;&lt;/a&gt;&lt;span class=&quot;header-link octicon octicon-link&quot;&gt;&lt;/span&gt;V2Ray 自建节点教程&lt;/h1&gt;&lt;h2 id=&quot;h2-u76EEu5F55-3&quot;&gt;&lt;a class=&quot;reference-link&quot; name=&quot;目录&quot;&gt;&lt;/a&gt;&lt;span class=&quot;header-link octicon octicon-link&quot;&gt;&lt;/span&gt;目录&lt;/h2&gt;&lt;ol&gt;
&lt;li&gt;&lt;a href=&quot;#1-前期准备&quot;&gt;前期准备&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;#2-服务器配置选择&quot;&gt;服务器配置选择&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;#3-自建节点手动配置&quot;&gt;自建节点（手动配置）&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;#4-3x-ui-一键部署&quot;&gt;3X-UI 一键部署&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;#5-公共部分&quot;&gt;公共部分&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;#6-问题清单与解决方案&quot;&gt;问题清单与解决方案&lt;/a&gt;&lt;/li&gt;&lt;/ol&gt;
&lt;hr&gt;
&lt;h2 id=&quot;h2-1.20u524Du671Fu51C6u5907-14&quot;&gt;&lt;a class=&quot;reference-link&quot; name=&quot;1. 前期准备&quot;&gt;&lt;/a&gt;&lt;span class=&quot;header-link octicon octicon-link&quot;&gt;&lt;/span&gt;1. 前期准备&lt;/h2&gt;&lt;h3 id=&quot;h3-1.120u6240u9700u6750u6599-16&quot;&gt;&lt;a class=&quot;reference-link&quot; name=&quot;1.1 所需材料&quot;&gt;&lt;/a&gt;&lt;span class=&quot;header-link octicon octicon-link&quot;&gt;&lt;/span&gt;1.1 所需材料&lt;/h3&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;材料&lt;/th&gt;
&lt;th&gt;说明&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;云服务器&lt;/td&gt;
&lt;td&gt;支持 Linux（推荐 Ubuntu 20.04+ 或 Debian 11+）&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;SSH 工具&lt;/td&gt;
&lt;td&gt;FinalShell、Xshell、PuTTY 或 PowerShell&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;h3 id=&quot;h3-1.220u670Du52A1u5668u8981u6C42-23&quot;&gt;&lt;a class=&quot;reference-link&quot; name=&quot;1.2 服务器要求&quot;&gt;&lt;/a&gt;&lt;span class=&quot;header-link octicon octicon-link&quot;&gt;&lt;/span&gt;1.2 服务器要求&lt;/h3&gt;&lt;pre&gt;&lt;code&gt;最低配置：
- CPU: 1核
- 内存: 512MB
- 带宽: 1Mbps+
- 硬盘: 10GB+

推荐配置：
- CPU: 1核
- 内存: 1GB+
- 带宽: 5Mbps+
- 硬盘: 20GB+
&lt;/code&gt;&lt;/pre&gt;
&lt;h3 id=&quot;h3-1.320u8FDEu63A5u670Du52A1u5668-39&quot;&gt;&lt;a class=&quot;reference-link&quot; name=&quot;1.3 连接服务器&quot;&gt;&lt;/a&gt;&lt;span class=&quot;header-link octicon octicon-link&quot;&gt;&lt;/span&gt;1.3 连接服务器&lt;/h3&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot;&gt;# Windows 使用 PuTTY 或 PowerShell
ssh root@你的服务器IP

# macOS/Linux 终端直接连接
ssh root@你的服务器IP -p 22
&lt;/code&gt;&lt;/pre&gt;
&lt;h3 id=&quot;h3-1.420u5F00u653Eu7AEFu53E3-49&quot;&gt;&lt;a class=&quot;reference-link&quot; name=&quot;1.4 开放端口&quot;&gt;&lt;/a&gt;&lt;span class=&quot;header-link octicon octicon-link&quot;&gt;&lt;/span&gt;1.4 开放端口&lt;/h3&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot;&gt;# 防火墙放行常用端口
ufw allow 22/tcp    # SSH
ufw allow 80/tcp    # HTTP（证书申请）
ufw allow 443/tcp   # HTTPS/TLS
&lt;/code&gt;&lt;/pre&gt;
&lt;hr&gt;
&lt;h2 id=&quot;h2-2.20u670Du52A1u5668u914Du7F6Eu9009u62E9-60&quot;&gt;&lt;a class=&quot;reference-link&quot; name=&quot;2. 服务器配置选择&quot;&gt;&lt;/a&gt;&lt;span class=&quot;header-link octicon octicon-link&quot;&gt;&lt;/span&gt;2. 服务器配置选择&lt;/h2&gt;&lt;h3 id=&quot;h3-2.120u534Fu8BAEu5BF9u6BD4-62&quot;&gt;&lt;a class=&quot;reference-link&quot; name=&quot;2.1 协议对比&quot;&gt;&lt;/a&gt;&lt;span class=&quot;header-link octicon octicon-link&quot;&gt;&lt;/span&gt;2.1 协议对比&lt;/h3&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;协议&lt;/th&gt;
&lt;th&gt;安全性&lt;/th&gt;
&lt;th&gt;速度&lt;/th&gt;
&lt;th&gt;抗封锁&lt;/th&gt;
&lt;th&gt;配置难度&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;VMess&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;高&lt;/td&gt;
&lt;td&gt;中&lt;/td&gt;
&lt;td&gt;中&lt;/td&gt;
&lt;td&gt;中&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;VLESS&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;高&lt;/td&gt;
&lt;td&gt;快&lt;/td&gt;
&lt;td&gt;中&lt;/td&gt;
&lt;td&gt;中&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Trojan&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;高&lt;/td&gt;
&lt;td&gt;快&lt;/td&gt;
&lt;td&gt;高&lt;/td&gt;
&lt;td&gt;中&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Shadowsocks&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;中&lt;/td&gt;
&lt;td&gt;快&lt;/td&gt;
&lt;td&gt;中&lt;/td&gt;
&lt;td&gt;低&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;WebSocket+TLS&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;高&lt;/td&gt;
&lt;td&gt;快&lt;/td&gt;
&lt;td&gt;高&lt;/td&gt;
&lt;td&gt;高&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;h3 id=&quot;h3-2.220u4F20u8F93u65B9u5F0Fu5BF9u6BD4-72&quot;&gt;&lt;a class=&quot;reference-link&quot; name=&quot;2.2 传输方式对比&quot;&gt;&lt;/a&gt;&lt;span class=&quot;header-link octicon octicon-link&quot;&gt;&lt;/span&gt;2.2 传输方式对比&lt;/h3&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;传输方式&lt;/th&gt;
&lt;th&gt;伪装程度&lt;/th&gt;
&lt;th&gt;速度&lt;/th&gt;
&lt;th&gt;抗封锁&lt;/th&gt;
&lt;th&gt;适用场景&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;TCP&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;无&lt;/td&gt;
&lt;td&gt;快&lt;/td&gt;
&lt;td&gt;中&lt;/td&gt;
&lt;td&gt;低审查环境&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;WebSocket&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;高（像浏览流量）&lt;/td&gt;
&lt;td&gt;中&lt;/td&gt;
&lt;td&gt;高&lt;/td&gt;
&lt;td&gt;高审查环境&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;HTTP/2&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;高&lt;/td&gt;
&lt;td&gt;快&lt;/td&gt;
&lt;td&gt;高&lt;/td&gt;
&lt;td&gt;中等审查环境&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;gRPC&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;高&lt;/td&gt;
&lt;td&gt;快&lt;/td&gt;
&lt;td&gt;高&lt;/td&gt;
&lt;td&gt;高审查环境&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;h3 id=&quot;h3-2.320u63A8u8350u7EC4u5408-81&quot;&gt;&lt;a class=&quot;reference-link&quot; name=&quot;2.3 推荐组合&quot;&gt;&lt;/a&gt;&lt;span class=&quot;header-link octicon octicon-link&quot;&gt;&lt;/span&gt;2.3 推荐组合&lt;/h3&gt;&lt;pre&gt;&lt;code&gt;推荐指数：★★★★★  最佳选择（有域名）
VLESS + WebSocket + TLS + Cloudflare

推荐指数：★★★★★  极致性能+抗封锁
VLESS + XTLS + REALITY（无需域名，最强伪装）

推荐指数：★★★★☆  无域名方案（自签名证书）
VLESS + WebSocket + TLS（自签名证书）
客户端需开启&quot;允许不安全连接&quot;

推荐指数：★★★★☆  入门选择
Shadowsocks + chacha20-poly1305

推荐指数：★★★☆☆  快速测试
VLESS + TCP（最简单，但隐蔽性差）

推荐指数：★★★☆☆  V2Ray 5.x 用户
VLESS + TCP (V2Ray 5.x 不再支持 VMess)
&lt;/code&gt;&lt;/pre&gt;
&lt;h3 id=&quot;h3-2.420VLESS20+20XTLS20+20REALITYuFF08u8FDBu9636u65B9u6848uFF09-104&quot;&gt;&lt;a class=&quot;reference-link&quot; name=&quot;2.4 VLESS + XTLS + REALITY（进阶方案）&quot;&gt;&lt;/a&gt;&lt;span class=&quot;header-link octicon octicon-link&quot;&gt;&lt;/span&gt;2.4 VLESS + XTLS + REALITY（进阶方案）&lt;/h3&gt;&lt;blockquote&gt;&lt;p&gt;如果你追求极致的性能和抗封锁能力，推荐使用 &lt;strong&gt;VLESS + XTLS + REALITY&lt;/strong&gt; 组合。它是目前公认的、抗封锁能力最强的方案之一。&lt;/p&gt;
&lt;/blockquote&gt;&lt;h4 id=&quot;h4-u6838u5FC3u539Fu7406-108&quot;&gt;&lt;a class=&quot;reference-link&quot; name=&quot;核心原理&quot;&gt;&lt;/a&gt;&lt;span class=&quot;header-link octicon octicon-link&quot;&gt;&lt;/span&gt;核心原理&lt;/h4&gt;&lt;p&gt;&lt;strong&gt;REALITY（伪装）&lt;/strong&gt;&lt;/p&gt;&lt;p style=&quot;text-align: center;&quot;&gt;&lt;img src=&quot;https://blog.smallhao.fun/zb_users/upload/zltheme_20260515/f25526f85db65fa642ee3fe6f956f907.jpg&quot; alt=&quot;V2Ray 自建节点教程&quot; /&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;不再需要域名和 TLS 证书&lt;/li&gt;&lt;li&gt;直接”借用”真实网站的证书和 TLS 指纹&lt;/li&gt;&lt;li&gt;通过模仿 &lt;code&gt;www.microsoft.com&lt;/code&gt;、&lt;code&gt;www.apple.com&lt;/code&gt; 等网站的 TLS 握手&lt;/li&gt;&lt;li&gt;流量与访问这些官网完全一致，无法识别和封锁&lt;/li&gt;&lt;/ul&gt;
&lt;p&gt;&lt;strong&gt;XTLS（加速）&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;消除”二次加解密”冗余（TLS 加密 + WebSocket 封装）&lt;/li&gt;&lt;li&gt;穿透已加密流量，降低 CPU 负载&lt;/li&gt;&lt;li&gt;显著提升传输速度和降低延迟&lt;/li&gt;&lt;/ul&gt;
&lt;h4 id=&quot;h4-u65B9u6848u5BF9u6BD4-121&quot;&gt;&lt;a class=&quot;reference-link&quot; name=&quot;方案对比&quot;&gt;&lt;/a&gt;&lt;span class=&quot;header-link octicon octicon-link&quot;&gt;&lt;/span&gt;方案对比&lt;/h4&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th style=&quot;text-align:left&quot;&gt;特性&lt;/th&gt;
&lt;th style=&quot;text-align:left&quot;&gt;VLESS + WS + TLS&lt;/th&gt;
&lt;th style=&quot;text-align:left&quot;&gt;VLESS + XTLS + REALITY&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td style=&quot;text-align:left&quot;&gt;&lt;strong&gt;性能&lt;/strong&gt;&lt;/td&gt;
&lt;td style=&quot;text-align:left&quot;&gt;相对较低，有额外性能开销&lt;/td&gt;
&lt;td style=&quot;text-align:left&quot;&gt;&lt;strong&gt;极高&lt;/strong&gt;，XTLS 避免二次加解密&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&quot;text-align:left&quot;&gt;&lt;strong&gt;隐蔽性&lt;/strong&gt;&lt;/td&gt;
&lt;td style=&quot;text-align:left&quot;&gt;较强，但 WebSocket 特征可能被识别&lt;/td&gt;
&lt;td style=&quot;text-align:left&quot;&gt;&lt;strong&gt;极强&lt;/strong&gt;，最先进伪装技术之一&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&quot;text-align:left&quot;&gt;&lt;strong&gt;端口&lt;/strong&gt;&lt;/td&gt;
&lt;td style=&quot;text-align:left&quot;&gt;通常需要 443 端口&lt;/td&gt;
&lt;td style=&quot;text-align:left&quot;&gt;可用任意端口（如 8443），更灵活&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&quot;text-align:left&quot;&gt;&lt;strong&gt;证书&lt;/strong&gt;&lt;/td&gt;
&lt;td style=&quot;text-align:left&quot;&gt;需要域名和证书&lt;/td&gt;
&lt;td style=&quot;text-align:left&quot;&gt;&lt;strong&gt;无需域名&lt;/strong&gt;，无需管理证书&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&quot;text-align:left&quot;&gt;&lt;strong&gt;CDN 支持&lt;/strong&gt;&lt;/td&gt;
&lt;td style=&quot;text-align:left&quot;&gt;可以套 CDN 隐藏真实 IP&lt;/td&gt;
&lt;td style=&quot;text-align:left&quot;&gt;无法套 CDN，会破坏伪装&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&quot;text-align:left&quot;&gt;&lt;strong&gt;部署难度&lt;/strong&gt;&lt;/td&gt;
&lt;td style=&quot;text-align:left&quot;&gt;简单&lt;/td&gt;
&lt;td style=&quot;text-align:left&quot;&gt;略复杂（需生成密钥、配置目标网站）&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;h4 id=&quot;h4-u98CEu9669u4E0Eu5E94u5BF9-132&quot;&gt;&lt;a class=&quot;reference-link&quot; name=&quot;风险与应对&quot;&gt;&lt;/a&gt;&lt;span class=&quot;header-link octicon octicon-link&quot;&gt;&lt;/span&gt;风险与应对&lt;/h4&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;风险&lt;/th&gt;
&lt;th&gt;降低方法&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;DNS 白名单检测&lt;/td&gt;
&lt;td&gt;选择大型、IP 段多的网站作为 Target（如 microsoft.com、apple.com、Cloudflare 域名）&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;中间人攻击检测&lt;/td&gt;
&lt;td&gt;定期更换 REALITY 公钥/私钥&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;单点故障&lt;/td&gt;
&lt;td&gt;保留 VLESS+WS+TLS 节点作为备用，两者搭配使用&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;h4 id=&quot;h4-u624Bu52A8u914Du7F6EuFF08JSONuFF09-140&quot;&gt;&lt;a class=&quot;reference-link&quot; name=&quot;手动配置（JSON）&quot;&gt;&lt;/a&gt;&lt;span class=&quot;header-link octicon octicon-link&quot;&gt;&lt;/span&gt;手动配置（JSON）&lt;/h4&gt;&lt;pre&gt;&lt;code class=&quot;language-json&quot;&gt;{
  &quot;inbounds&quot;: [
    {
      &quot;listen&quot;: &quot;0.0.0.0&quot;,
      &quot;port&quot;: 36606,
      &quot;protocol&quot;: &quot;vless&quot;,
      &quot;settings&quot;: {
        &quot;clients&quot;: [
          {
            &quot;id&quot;: &quot;你的UUID&quot;,
            &quot;flow&quot;: &quot;xtls-rprx-vision&quot;
          }
        ],
        &quot;decryption&quot;: &quot;none&quot;
      },
      &quot;streamSettings&quot;: {
        &quot;network&quot;: &quot;tcp&quot;
      },
      &quot;security&quot;: &quot;reality&quot;,
      &quot;realitySettings&quot;: {
        &quot;show&quot;: false,
        &quot;dest&quot;: &quot;www.apple.com:443&quot;,
        &quot;xver&quot;: 0,
        &quot;serverNames&quot;: [&quot;www.apple.com&quot;],
        &quot;privateKey&quot;: &quot;你的私钥&quot;,
        &quot;publicKey&quot;: &quot;你的公钥&quot;,
        &quot;shortId&quot;: &quot;abc123&quot;
      }
    }
  ],
  &quot;outbounds&quot;: [
    {
      &quot;protocol&quot;: &quot;freedom&quot;,
      &quot;tag&quot;: &quot;direct&quot;
    }
  ]
}
&lt;/code&gt;&lt;/pre&gt;
&lt;h4 id=&quot;h4-u5BC6u94A5u751Fu6210-182&quot;&gt;&lt;a class=&quot;reference-link&quot; name=&quot;密钥生成&quot;&gt;&lt;/a&gt;&lt;span class=&quot;header-link octicon octicon-link&quot;&gt;&lt;/span&gt;密钥生成&lt;/h4&gt;&lt;p&gt;在 Linux 服务器上生成密钥对：&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-bash&quot;&gt;# 生成私钥（32字节，Base64编码）
openssl rand -base64 32

# 生成公钥（25519椭圆曲线）
# Xray 会根据私钥自动生成公钥
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;或在 3X-UI 面板中点击 &lt;strong&gt;“Generate key”&lt;/strong&gt; 自动生成。&lt;/p&gt;
&lt;h4 id=&quot;h4-u5BA2u6237u7AEFu914Du7F6Eu8981u70B9-196&quot;&gt;&lt;a class=&quot;reference-link&quot; name=&quot;客户端配置要点&quot;&gt;&lt;/a&gt;&lt;span class=&quot;header-link octicon octicon-link&quot;&gt;&lt;/span&gt;客户端配置要点&lt;/h4&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;参数&lt;/th&gt;
&lt;th&gt;值&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;协议&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;VLESS&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;地址&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;服务器 IP&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;端口&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;你设置的端口（如 36606）&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;UUID&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;服务端配置的 UUID&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Flow&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;xtls-rprx-vision&lt;/code&gt;（启用 XTLS）&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;传输&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;TCP（不是 WebSocket）&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;安全&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;REALITY&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;SNI&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;与 Target 域名一致（如 &lt;a href=&quot;http://www.apple.com）&quot;&gt;www.apple.com）&lt;/a&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;uTLS&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;chrome&lt;/code&gt; / &lt;code&gt;firefox&lt;/code&gt; / &lt;code&gt;safari&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;blockquote&gt;&lt;p&gt;&lt;strong&gt;注意&lt;/strong&gt;：客户端的 Flow 参数 &lt;code&gt;xtls-rprx-vision&lt;/code&gt; 是启用 XTLS 加速的关键，必须填写。&lt;/p&gt;
&lt;/blockquote&gt;&lt;h3 id=&quot;h3-2.520u65E0u57DFu540Du65B9u6848u8BF4u660E-212&quot;&gt;&lt;a class=&quot;reference-link&quot; name=&quot;2.5 无域名方案说明&quot;&gt;&lt;/a&gt;&lt;span class=&quot;header-link octicon octicon-link&quot;&gt;&lt;/span&gt;2.5 无域名方案说明&lt;/h3&gt;&lt;p&gt;&lt;strong&gt;适用场景：&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;没有域名&lt;/li&gt;&lt;li&gt;不想使用 Cloudflare&lt;/li&gt;&lt;li&gt;快速部署&lt;/li&gt;&lt;/ul&gt;
&lt;p&gt;&lt;strong&gt;配置要点：&lt;/strong&gt;&lt;/p&gt;
&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;节点类型&lt;/th&gt;
&lt;th&gt;端口&lt;/th&gt;
&lt;th&gt;TLS&lt;/th&gt;
&lt;th&gt;说明&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;TCP&lt;/td&gt;
&lt;td&gt;10086&lt;/td&gt;
&lt;td&gt;关闭&lt;/td&gt;
&lt;td&gt;最简单，但容易被封锁&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;WS+TLS&lt;/td&gt;
&lt;td&gt;443&lt;/td&gt;
&lt;td&gt;自签名&lt;/td&gt;
&lt;td&gt;较安全，客户端需 allowInsecure&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;p&gt;&lt;strong&gt;客户端配置：&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;自签名证书需要勾选”允许不安全连接”&lt;/li&gt;&lt;li&gt;使用 IP 地址而非域名&lt;/li&gt;&lt;/ul&gt;
&lt;h3 id=&quot;h3-2.620u6709u57DFu540Du65B9u6848uFF08CloudflareuFF09-230&quot;&gt;&lt;a class=&quot;reference-link&quot; name=&quot;2.6 有域名方案（Cloudflare）&quot;&gt;&lt;/a&gt;&lt;span class=&quot;header-link octicon octicon-link&quot;&gt;&lt;/span&gt;2.6 有域名方案（Cloudflare）&lt;/h3&gt;&lt;p&gt;&lt;strong&gt;适用场景：&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;已有域名&lt;/li&gt;&lt;li&gt;需要更好隐蔽性&lt;/li&gt;&lt;li&gt;不想暴露服务器真实 IP&lt;/li&gt;&lt;/ul&gt;
&lt;p&gt;&lt;strong&gt;配置要点：&lt;/strong&gt;&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;将域名接入 Cloudflare&lt;/li&gt;&lt;li&gt;DNS 解析到服务器 IP，开启代理（橙色云）&lt;/li&gt;&lt;li&gt;申请 Let’s Encrypt 证书或使用 Cloudflare Origin Certificate&lt;/li&gt;&lt;li&gt;配置 Nginx 反向代理&lt;/li&gt;&lt;/ol&gt;
&lt;p&gt;&lt;strong&gt;优势：&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Cloudflare 隐藏真实服务器 IP&lt;/li&gt;&lt;li&gt;CDN 加速&lt;/li&gt;&lt;li&gt;更好的抗封锁能力&lt;/li&gt;&lt;/ul&gt;
&lt;hr&gt;
&lt;h2 id=&quot;h2-3.20u81EAu5EFAu8282u70B9uFF08u624Bu52A8u914Du7F6EuFF09-251&quot;&gt;&lt;a class=&quot;reference-link&quot; name=&quot;3. 自建节点（手动配置）&quot;&gt;&lt;/a&gt;&lt;span class=&quot;header-link octicon octicon-link&quot;&gt;&lt;/span&gt;3. 自建节点（手动配置）&lt;/h2&gt;&lt;blockquote&gt;&lt;p&gt;本章节适用于不使用图形面板，直接手动配置 V2Ray 的用户。&lt;br&gt;如果使用 3X-UI，请跳转到下一章节。&lt;/p&gt;
&lt;/blockquote&gt;&lt;h3 id=&quot;h3-3.120UUID20u8BE6u89E3-256&quot;&gt;&lt;a class=&quot;reference-link&quot; name=&quot;3.1 UUID 详解&quot;&gt;&lt;/a&gt;&lt;span class=&quot;header-link octicon octicon-link&quot;&gt;&lt;/span&gt;3.1 UUID 详解&lt;/h3&gt;&lt;p&gt;&lt;strong&gt;UUID 是什么？&lt;/strong&gt;&lt;br&gt;UUID 是 VLESS 协议的用户身份标识，像一把钥匙：&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;服务器配置允许的 UUID 列表&lt;/li&gt;&lt;li&gt;客户端连接时提供自己的 UUID&lt;/li&gt;&lt;li&gt;服务器验证 UUID 是否在白名单中&lt;/li&gt;&lt;/ul&gt;
&lt;p&gt;&lt;strong&gt;格式示例：&lt;/strong&gt;&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;40552b9c-80f4-419f-b112-a6bba2b99338
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;strong&gt;生成方法：&lt;/strong&gt;&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-bash&quot;&gt;cat /proc/sys/kernel/random/uuid
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;strong&gt;配置示例：&lt;/strong&gt;&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-json&quot;&gt;{
  &quot;inbounds&quot;: [{
    &quot;port&quot;: 10086,
    &quot;protocol&quot;: &quot;vless&quot;,
    &quot;settings&quot;: {
      &quot;clients&quot;: [
        {&quot;id&quot;: &quot;你的UUID&quot;, &quot;email&quot;: &quot;user1&quot;},
        {&quot;id&quot;: &quot;他的UUID&quot;, &quot;email&quot;: &quot;user2&quot;}
      ],
      &quot;decryption&quot;: &quot;none&quot;
    }
  }]
}
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;strong&gt;说明：&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;email&lt;/code&gt; 字段不是必填，可省略（仅用于标识用户）&lt;/li&gt;&lt;li&gt;可以添加多个 UUID，支持多人共用&lt;/li&gt;&lt;li&gt;删除某个 UUID 即可禁止对应用户访问&lt;/li&gt;&lt;li&gt;TCP 和 WS+TLS 节点的 UUID 可以共用或分开&lt;/li&gt;&lt;/ul&gt;
&lt;p&gt;&lt;strong&gt;管理多人访问：&lt;/strong&gt;&lt;/p&gt;
&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;需求&lt;/th&gt;
&lt;th&gt;操作&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;添加新用户&lt;/td&gt;
&lt;td&gt;在 clients 中添加新 UUID，重启服务&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;禁止某用户&lt;/td&gt;
&lt;td&gt;删除对应 UUID，重启服务&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;限制来源 IP&lt;/td&gt;
&lt;td&gt;使用 ufw 防火墙规则&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;hr&gt;
&lt;h3 id=&quot;h3-3.220u4E00u952Eu5B89u88C520V2RayuFF08u5B98u65B9u811Au672CuFF09-306&quot;&gt;&lt;a class=&quot;reference-link&quot; name=&quot;3.2 一键安装 V2Ray（官方脚本）&quot;&gt;&lt;/a&gt;&lt;span class=&quot;header-link octicon octicon-link&quot;&gt;&lt;/span&gt;3.2 一键安装 V2Ray（官方脚本）&lt;/h3&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot;&gt;# 下载安装脚本
bash &amp;lt;(curl -L https://raw.githubusercontent.com/v2fly/fhs-install-v2ray/master/install-release.sh)

# 启动服务
systemctl start v2ray
systemctl enable v2ray

# 查看状态
systemctl status v2ray
&lt;/code&gt;&lt;/pre&gt;
&lt;h3 id=&quot;h3-3.320u5B89u88C520V2Ray205.xuFF08u624Bu52A8u5B89u88C5uFF09-320&quot;&gt;&lt;a class=&quot;reference-link&quot; name=&quot;3.3 安装 V2Ray 5.x（手动安装）&quot;&gt;&lt;/a&gt;&lt;span class=&quot;header-link octicon octicon-link&quot;&gt;&lt;/span&gt;3.3 安装 V2Ray 5.x（手动安装）&lt;/h3&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot;&gt;# 下载 V2Ray 5.x
wget https://github.com/v2fly/v2ray-core/releases/download/v5.10.0/v2ray-linux-64.zip
unzip v2ray-linux-64.zip
mv v2ray /usr/local/bin/
mv v2ctl /usr/local/bin/
chmod +x /usr/local/bin/v2ray /usr/local/bin/v2ctl

# 创建 systemd 服务文件（一键创建）
cat &amp;gt; /etc/systemd/system/v2ray.service &amp;lt;&amp;lt; &#039;EOF&#039;
[Unit]
Description=V2Ray Service
After=network.target

[Service]
ExecStart=/usr/local/bin/v2ray run -config /etc/v2ray/config.json
Restart=on-failure

[Install]
WantedBy=multi-user.target
EOF

# 重载服务
systemctl daemon-reload
systemctl enable v2ray
systemctl start v2ray
&lt;/code&gt;&lt;/pre&gt;
&lt;h3 id=&quot;h3-3.420VLESS20+20TCP20u914Du7F6E-350&quot;&gt;&lt;a class=&quot;reference-link&quot; name=&quot;3.4 VLESS + TCP 配置&quot;&gt;&lt;/a&gt;&lt;span class=&quot;header-link octicon octicon-link&quot;&gt;&lt;/span&gt;3.4 VLESS + TCP 配置&lt;/h3&gt;&lt;pre&gt;&lt;code class=&quot;language-json&quot;&gt;{
  &quot;inbounds&quot;: [
    {
      &quot;listen&quot;: &quot;0.0.0.0&quot;,
      &quot;port&quot;: 10086,
      &quot;protocol&quot;: &quot;vless&quot;,
      &quot;settings&quot;: {
        &quot;clients&quot;: [
          {
            &quot;id&quot;: &quot;你的UUID&quot;,
            &quot;flow&quot;: &quot;&quot;
          }
        ],
        &quot;decryption&quot;: &quot;none&quot;
      },
      &quot;streamSettings&quot;: {
        &quot;network&quot;: &quot;tcp&quot;
      }
    }
  ],
  &quot;outbounds&quot;: [
    {
      &quot;protocol&quot;: &quot;freedom&quot;,
      &quot;tag&quot;: &quot;direct&quot;
    }
  ]
}
&lt;/code&gt;&lt;/pre&gt;
&lt;h3 id=&quot;h3-3.520VLESS20+20WebSocket20+20TLS20u914Du7F6E-382&quot;&gt;&lt;a class=&quot;reference-link&quot; name=&quot;3.5 VLESS + WebSocket + TLS 配置&quot;&gt;&lt;/a&gt;&lt;span class=&quot;header-link octicon octicon-link&quot;&gt;&lt;/span&gt;3.5 VLESS + WebSocket + TLS 配置&lt;/h3&gt;&lt;p&gt;&lt;strong&gt;方案一：无域名（自签名证书）&lt;/strong&gt;&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-json&quot;&gt;{
  &quot;log&quot;: {&quot;loglevel&quot;: &quot;warning&quot;},
  &quot;inbounds&quot;: [
    {
      &quot;port&quot;: 443,
      &quot;listen&quot;: &quot;0.0.0.0&quot;,
      &quot;protocol&quot;: &quot;vless&quot;,
      &quot;settings&quot;: {
        &quot;clients&quot;: [{&quot;id&quot;: &quot;你的UUID&quot;}],
        &quot;decryption&quot;: &quot;none&quot;
      },
      &quot;streamSettings&quot;: {
        &quot;network&quot;: &quot;ws&quot;,
        &quot;wsSettings&quot;: {
          &quot;path&quot;: &quot;/v2ray&quot;
        },
        &quot;security&quot;: &quot;tls&quot;,
        &quot;tlsSettings&quot;: {
          &quot;certificates&quot;: [
            {
              &quot;certificateFile&quot;: &quot;/etc/ssl/certs/cert.pem&quot;,
              &quot;keyFile&quot;: &quot;/etc/ssl/private/key.pem&quot;
            }
          ]
        }
      }
    }
  ],
  &quot;outbounds&quot;: [{&quot;protocol&quot;: &quot;freedom&quot;}]
}
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;strong&gt;方案二：有域名（Let’s Encrypt/CF 证书）&lt;/strong&gt;&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-json&quot;&gt;{
  &quot;log&quot;: {&quot;loglevel&quot;: &quot;warning&quot;},
  &quot;inbounds&quot;: [
    {
      &quot;port&quot;: 443,
      &quot;listen&quot;: &quot;0.0.0.0&quot;,
      &quot;protocol&quot;: &quot;vless&quot;,
      &quot;settings&quot;: {
        &quot;clients&quot;: [{&quot;id&quot;: &quot;你的UUID&quot;}],
        &quot;decryption&quot;: &quot;none&quot;
      },
      &quot;streamSettings&quot;: {
        &quot;network&quot;: &quot;ws&quot;,
        &quot;wsSettings&quot;: {
          &quot;path&quot;: &quot;/v2ray&quot;
        },
        &quot;security&quot;: &quot;tls&quot;,
        &quot;tlsSettings&quot;: {
          &quot;serverName&quot;: &quot;你的域名&quot;,
          &quot;alpn&quot;: [&quot;h2&quot;, &quot;http/1.1&quot;]
        }
      }
    }
  ],
  &quot;outbounds&quot;: [{&quot;protocol&quot;: &quot;freedom&quot;}]
}
&lt;/code&gt;&lt;/pre&gt;
&lt;h3 id=&quot;h3-3.620u53CCu8282u70B9u914Du7F6EuFF08u540Cu65F6u76D1u542C20TCP20+20WS+TLSuFF09-450&quot;&gt;&lt;a class=&quot;reference-link&quot; name=&quot;3.6 双节点配置（同时监听 TCP + WS+TLS）&quot;&gt;&lt;/a&gt;&lt;span class=&quot;header-link octicon octicon-link&quot;&gt;&lt;/span&gt;3.6 双节点配置（同时监听 TCP + WS+TLS）&lt;/h3&gt;&lt;p&gt;同时启用 TCP 和 WebSocket+TLS 两种节点：&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-json&quot;&gt;{
    &quot;log&quot;: {&quot;loglevel&quot;: &quot;warning&quot;},
    &quot;inbounds&quot;: [
        {
            &quot;port&quot;: 10086,
            &quot;listen&quot;: &quot;0.0.0.0&quot;,
            &quot;protocol&quot;: &quot;vless&quot;,
            &quot;settings&quot;: {
                &quot;clients&quot;: [{&quot;id&quot;: &quot;第一个UUID&quot;}],
                &quot;decryption&quot;: &quot;none&quot;
            },
            &quot;streamSettings&quot;: {
                &quot;network&quot;: &quot;tcp&quot;
            }
        },
        {
            &quot;port&quot;: 443,
            &quot;listen&quot;: &quot;0.0.0.0&quot;,
            &quot;protocol&quot;: &quot;vless&quot;,
            &quot;settings&quot;: {
                &quot;clients&quot;: [{&quot;id&quot;: &quot;第二个UUID&quot;}],
                &quot;decryption&quot;: &quot;none&quot;
            },
            &quot;streamSettings&quot;: {
                &quot;network&quot;: &quot;ws&quot;,
                &quot;wsSettings&quot;: {
                    &quot;path&quot;: &quot;/v2ray&quot;
                },
                &quot;security&quot;: &quot;tls&quot;,
                &quot;tlsSettings&quot;: {
                    &quot;certificates&quot;: [
                        {
                            &quot;certificateFile&quot;: &quot;/etc/ssl/certs/cert.pem&quot;,
                            &quot;keyFile&quot;: &quot;/etc/ssl/private/key.pem&quot;
                        }
                    ]
                }
            }
        }
    ],
    &quot;outbounds&quot;: [{&quot;protocol&quot;: &quot;freedom&quot;}]
}
&lt;/code&gt;&lt;/pre&gt;
&lt;h3 id=&quot;h3-3.720VMess20+20TCP20u914Du7F6EuFF08V2Ray204.x20u65E7u7248uFF09-499&quot;&gt;&lt;a class=&quot;reference-link&quot; name=&quot;3.7 VMess + TCP 配置（V2Ray 4.x 旧版）&quot;&gt;&lt;/a&gt;&lt;span class=&quot;header-link octicon octicon-link&quot;&gt;&lt;/span&gt;3.7 VMess + TCP 配置（V2Ray 4.x 旧版）&lt;/h3&gt;&lt;pre&gt;&lt;code class=&quot;language-json&quot;&gt;{
  &quot;inbounds&quot;: [
    {
      &quot;listen&quot;: &quot;0.0.0.0&quot;,
      &quot;port&quot;: 10086,
      &quot;protocol&quot;: &quot;vmess&quot;,
      &quot;settings&quot;: {
        &quot;clients&quot;: [
          {
            &quot;id&quot;: &quot;你的UUID&quot;,
            &quot;alterId&quot;: 0
          }
        ]
      },
      &quot;streamSettings&quot;: {
        &quot;network&quot;: &quot;tcp&quot;
      }
    }
  ],
  &quot;outbounds&quot;: [
    {
      &quot;protocol&quot;: &quot;freedom&quot;,
      &quot;tag&quot;: &quot;direct&quot;
    }
  ]
}
&lt;/code&gt;&lt;/pre&gt;
&lt;h3 id=&quot;h3-3.820Shadowsocks20u670Du52A1u5668u642Du5EFA-530&quot;&gt;&lt;a class=&quot;reference-link&quot; name=&quot;3.8 Shadowsocks 服务器搭建&quot;&gt;&lt;/a&gt;&lt;span class=&quot;header-link octicon octicon-link&quot;&gt;&lt;/span&gt;3.8 Shadowsocks 服务器搭建&lt;/h3&gt;&lt;h4 id=&quot;h4-3.8.120u5B89u88C520ShadowsocksuFF08u5355u7528u6237uFF09-532&quot;&gt;&lt;a class=&quot;reference-link&quot; name=&quot;3.8.1 安装 Shadowsocks（单用户）&quot;&gt;&lt;/a&gt;&lt;span class=&quot;header-link octicon octicon-link&quot;&gt;&lt;/span&gt;3.8.1 安装 Shadowsocks（单用户）&lt;/h4&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot;&gt;# Ubuntu/Debian
apt update
apt install -y shadowsocks-libev

# 启动
ss-server -c /etc/shadowsocks-libev/config.json
&lt;/code&gt;&lt;/pre&gt;
&lt;h4 id=&quot;h4-3.8.220u5B89u88C520simple-obfsuFF08u6DF7u6DC6u63D2u4EF6uFF09-543&quot;&gt;&lt;a class=&quot;reference-link&quot; name=&quot;3.8.2 安装 simple-obfs（混淆插件）&quot;&gt;&lt;/a&gt;&lt;span class=&quot;header-link octicon octicon-link&quot;&gt;&lt;/span&gt;3.8.2 安装 simple-obfs（混淆插件）&lt;/h4&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot;&gt;# 安装依赖
apt install -y build-essential autoconf libtool

# 下载编译
git clone https://github.com/shadowsocks/simple-obfs.git
cd simple-obfs
./autogen.sh
./configure &amp;amp;&amp;amp; make
make install

# 配置使用插件
&lt;/code&gt;&lt;/pre&gt;
&lt;h4 id=&quot;h4-3.8.320Shadowsocks20+20chacha20-poly130520u914Du7F6E-559&quot;&gt;&lt;a class=&quot;reference-link&quot; name=&quot;3.8.3 Shadowsocks + chacha20-poly1305 配置&quot;&gt;&lt;/a&gt;&lt;span class=&quot;header-link octicon octicon-link&quot;&gt;&lt;/span&gt;3.8.3 Shadowsocks + chacha20-poly1305 配置&lt;/h4&gt;&lt;pre&gt;&lt;code class=&quot;language-json&quot;&gt;{
  &quot;server&quot;: &quot;0.0.0.0&quot;,
  &quot;server_port&quot;: 8388,
  &quot;password&quot;: &quot;你的密码&quot;,
  &quot;method&quot;: &quot;chacha20-ietf-poly1305&quot;,
  &quot;timeout&quot;: 300,
  &quot;fast_open&quot;: true
}
&lt;/code&gt;&lt;/pre&gt;
&lt;h4 id=&quot;h4-3.8.420Shadowsocks20+20TLS20u63D2u4EF6u914Du7F6E-572&quot;&gt;&lt;a class=&quot;reference-link&quot; name=&quot;3.8.4 Shadowsocks + TLS 插件配置&quot;&gt;&lt;/a&gt;&lt;span class=&quot;header-link octicon octicon-link&quot;&gt;&lt;/span&gt;3.8.4 Shadowsocks + TLS 插件配置&lt;/h4&gt;&lt;pre&gt;&lt;code class=&quot;language-json&quot;&gt;{
  &quot;server&quot;: &quot;0.0.0.0&quot;,
  &quot;server_port&quot;: 8388,
  &quot;password&quot;: &quot;你的密码&quot;,
  &quot;method&quot;: &quot;chacha20-ietf-poly1305&quot;,
  &quot;timeout&quot;: 300,
  &quot;fast_open&quot;: true,
  &quot;plugin&quot;: &quot;obfs-local&quot;,
  &quot;plugin_opts&quot;: &quot;obfs=tls;failover=你的域名;failover=127.0.0.1&quot;
}
&lt;/code&gt;&lt;/pre&gt;
&lt;h4 id=&quot;h4-3.8.520u542Fu52A8u547Du4EE4-587&quot;&gt;&lt;a class=&quot;reference-link&quot; name=&quot;3.8.5 启动命令&quot;&gt;&lt;/a&gt;&lt;span class=&quot;header-link octicon octicon-link&quot;&gt;&lt;/span&gt;3.8.5 启动命令&lt;/h4&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot;&gt;# 前台运行
ss-server -c /etc/shadowsocks-libev/config.json

# 后台运行
nohup ss-server -c /etc/shadowsocks-libev/config.json &amp;amp;

# 查看运行状态
ps aux | grep ss-server
netstat -tlnp | grep 8388
&lt;/code&gt;&lt;/pre&gt;
&lt;h3 id=&quot;h3-3.920Trojan20u670Du52A1u5668u642Du5EFA-601&quot;&gt;&lt;a class=&quot;reference-link&quot; name=&quot;3.9 Trojan 服务器搭建&quot;&gt;&lt;/a&gt;&lt;span class=&quot;header-link octicon octicon-link&quot;&gt;&lt;/span&gt;3.9 Trojan 服务器搭建&lt;/h3&gt;&lt;h4 id=&quot;h4-3.9.120u7AEFu53E3u51B2u7A81u8BF4u660E-603&quot;&gt;&lt;a class=&quot;reference-link&quot; name=&quot;3.9.1 端口冲突说明&quot;&gt;&lt;/a&gt;&lt;span class=&quot;header-link octicon octicon-link&quot;&gt;&lt;/span&gt;3.9.1 端口冲突说明&lt;/h4&gt;&lt;p&gt;&lt;strong&gt;冲突原因：&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;V2Ray WS+TLS 默认用 &lt;strong&gt;443&lt;/strong&gt; 端口&lt;/li&gt;&lt;li&gt;Trojan 默认也用 &lt;strong&gt;443&lt;/strong&gt; 端口&lt;/li&gt;&lt;li&gt;两者不能同时使用 443&lt;/li&gt;&lt;/ul&gt;
&lt;p&gt;&lt;strong&gt;解决方案：&lt;/strong&gt;&lt;/p&gt;
&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;方案&lt;/th&gt;
&lt;th&gt;V2Ray WS+TLS&lt;/th&gt;
&lt;th&gt;Trojan&lt;/th&gt;
&lt;th&gt;说明&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;方案一&lt;/td&gt;
&lt;td&gt;改用 8443&lt;/td&gt;
&lt;td&gt;用 443&lt;/td&gt;
&lt;td&gt;Trojan 优先&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;方案二&lt;/td&gt;
&lt;td&gt;用 80 端口（无TLS）&lt;/td&gt;
&lt;td&gt;用 443&lt;/td&gt;
&lt;td&gt;V2Ray 无加密&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;方案三&lt;/td&gt;
&lt;td&gt;保持 443&lt;/td&gt;
&lt;td&gt;不用&lt;/td&gt;
&lt;td&gt;推荐，只用 V2Ray&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;p&gt;&lt;strong&gt;推荐：&lt;/strong&gt; 如果只用 VLESS，不需要 Trojan，用方案一让 V2Ray WS+TLS 改端口。&lt;/p&gt;
&lt;hr&gt;
&lt;h4 id=&quot;h4-3.9.220u5B89u88C520Trojan-622&quot;&gt;&lt;a class=&quot;reference-link&quot; name=&quot;3.9.2 安装 Trojan&quot;&gt;&lt;/a&gt;&lt;span class=&quot;header-link octicon octicon-link&quot;&gt;&lt;/span&gt;3.9.2 安装 Trojan&lt;/h4&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot;&gt;# 下载
wget https://github.com/trojan-gfw/trojan/releases/download/v1.16.0/trojan-1.16.0-linux-amd64.tar.xz
tar xf trojan-1.16.0-linux-amd64.tar.xz
mv trojan /usr/local/bin/

# 创建配置目录
mkdir -p /etc/trojan
&lt;/code&gt;&lt;/pre&gt;
&lt;h4 id=&quot;h4-3.9.320u914Du7F6Eu6587u4EF620/etc/trojan/config.json-634&quot;&gt;&lt;a class=&quot;reference-link&quot; name=&quot;3.9.3 配置文件 /etc/trojan/config.json&quot;&gt;&lt;/a&gt;&lt;span class=&quot;header-link octicon octicon-link&quot;&gt;&lt;/span&gt;3.9.3 配置文件 /etc/trojan/config.json&lt;/h4&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot;&gt;cat &amp;gt; /etc/trojan/config.json &amp;lt;&amp;lt; &#039;EOF&#039;
{
    &quot;run_type&quot;: &quot;server&quot;,
    &quot;local_addr&quot;: &quot;0.0.0.0&quot;,
    &quot;local_port&quot;: 443,
    &quot;remote_addr&quot;: &quot;127.0.0.1&quot;,
    &quot;remote_port&quot;: 80,
    &quot;password&quot;: [
        &quot;你的密码&quot;
    ],
    &quot;ssl&quot;: {
        &quot;cert&quot;: &quot;/etc/ssl/certs/cert.pem&quot;,
        &quot;key&quot;: &quot;/etc/ssl/private/key.pem&quot;,
        &quot;sni&quot;: &quot;example.com&quot;,
        &quot;alpn&quot;: [&quot;h2&quot;, &quot;http/1.1&quot;]
    }
}
EOF
&lt;/code&gt;&lt;/pre&gt;
&lt;h4 id=&quot;h4-3.9.420u542Fu52A820Trojan-657&quot;&gt;&lt;a class=&quot;reference-link&quot; name=&quot;3.9.4 启动 Trojan&quot;&gt;&lt;/a&gt;&lt;span class=&quot;header-link octicon octicon-link&quot;&gt;&lt;/span&gt;3.9.4 启动 Trojan&lt;/h4&gt;&lt;p&gt;&lt;strong&gt;方法一：前台运行（测试用）&lt;/strong&gt;&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-bash&quot;&gt;/usr/local/bin/trojan -c /etc/trojan/config.json
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;strong&gt;方法二：后台运行&lt;/strong&gt;&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-bash&quot;&gt;nohup /usr/local/bin/trojan -c /etc/trojan/config.json &amp;amp;
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;strong&gt;方法三：systemd 服务（推荐）&lt;/strong&gt;&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-bash&quot;&gt;cat &amp;gt; /etc/systemd/system/trojan.service &amp;lt;&amp;lt; &#039;EOF&#039;
[Unit]
Description=Trojan Service
After=network.target

[Service]
ExecStart=/usr/local/bin/trojan -c /etc/trojan/config.json
Restart=on-failure

[Install]
WantedBy=multi-user.target
EOF

systemctl daemon-reload
systemctl enable trojan
systemctl start trojan
systemctl status trojan
&lt;/code&gt;&lt;/pre&gt;
&lt;h4 id=&quot;h4-3.9.520u5BA2u6237u7AEFu8FDEu63A5u4FE1u606F-690&quot;&gt;&lt;a class=&quot;reference-link&quot; name=&quot;3.9.5 客户端连接信息&quot;&gt;&lt;/a&gt;&lt;span class=&quot;header-link octicon octicon-link&quot;&gt;&lt;/span&gt;3.9.5 客户端连接信息&lt;/h4&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;项目&lt;/th&gt;
&lt;th&gt;值&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;地址&lt;/td&gt;
&lt;td&gt;服务器IP&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;端口&lt;/td&gt;
&lt;td&gt;443&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;密码&lt;/td&gt;
&lt;td&gt;你设置的密码&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;TLS&lt;/td&gt;
&lt;td&gt;开启&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;p&gt;&lt;strong&gt;导入链接：&lt;/strong&gt;&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;trojan://你的密码@服务器IP:443#Trojan
&lt;/code&gt;&lt;/pre&gt;
&lt;h4 id=&quot;h4-3.9.620u7BA1u7406u591Au7528u6237-704&quot;&gt;&lt;a class=&quot;reference-link&quot; name=&quot;3.9.6 管理多用户&quot;&gt;&lt;/a&gt;&lt;span class=&quot;header-link octicon octicon-link&quot;&gt;&lt;/span&gt;3.9.6 管理多用户&lt;/h4&gt;&lt;p&gt;编辑 &lt;code&gt;/etc/trojan/config.json&lt;/code&gt;，在 &lt;code&gt;password&lt;/code&gt; 数组中添加多个密码：&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-json&quot;&gt;{
    &quot;password&quot;: [
        &quot;密码1&quot;,
        &quot;密码2&quot;,
        &quot;密码3&quot;
    ]
}
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;添加后重启：&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-bash&quot;&gt;systemctl restart trojan
&lt;/code&gt;&lt;/pre&gt;
&lt;h4 id=&quot;h4-3.9.720u5E38u7528u547Du4EE4-723&quot;&gt;&lt;a class=&quot;reference-link&quot; name=&quot;3.9.7 常用命令&quot;&gt;&lt;/a&gt;&lt;span class=&quot;header-link octicon octicon-link&quot;&gt;&lt;/span&gt;3.9.7 常用命令&lt;/h4&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot;&gt;# 启动/停止/重启
systemctl start trojan
systemctl stop trojan
systemctl restart trojan

# 查看状态
systemctl status trojan

# 查看端口
netstat -tlnp | grep trojan

# 查看运行
ps aux | grep trojan
&lt;/code&gt;&lt;/pre&gt;
&lt;hr&gt;
&lt;h2 id=&quot;h2-4.203X-UI20u4E00u952Eu90E8u7F72-743&quot;&gt;&lt;a class=&quot;reference-link&quot; name=&quot;4. 3X-UI 一键部署&quot;&gt;&lt;/a&gt;&lt;span class=&quot;header-link octicon octicon-link&quot;&gt;&lt;/span&gt;4. 3X-UI 一键部署&lt;/h2&gt;&lt;blockquote&gt;&lt;p&gt;3X-UI 是图形化管理面板，自带 Xray 内核，无需单独安装 V2Ray。&lt;/p&gt;
&lt;/blockquote&gt;&lt;h3 id=&quot;h3-4.120u9762u677Fu63A8u8350u5BF9u6BD4-747&quot;&gt;&lt;a class=&quot;reference-link&quot; name=&quot;4.1 面板推荐对比&quot;&gt;&lt;/a&gt;&lt;span class=&quot;header-link octicon octicon-link&quot;&gt;&lt;/span&gt;4.1 面板推荐对比&lt;/h3&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;面板&lt;/th&gt;
&lt;th&gt;基于&lt;/th&gt;
&lt;th&gt;特点&lt;/th&gt;
&lt;th&gt;安装难度&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;3X-UI&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Xray&lt;/td&gt;
&lt;td&gt;功能完整，界面友好&lt;/td&gt;
&lt;td&gt;简单&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;x-ui&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Xray&lt;/td&gt;
&lt;td&gt;轻量级，简单易用&lt;/td&gt;
&lt;td&gt;简单&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Marzban&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Xray&lt;/td&gt;
&lt;td&gt;支持订阅、流量限制、多用户&lt;/td&gt;
&lt;td&gt;中等&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;s-ui&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;sing-box&lt;/td&gt;
&lt;td&gt;现代化界面&lt;/td&gt;
&lt;td&gt;简单&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;h3 id=&quot;h3-4.2203X-UI20u5B89u88C5-756&quot;&gt;&lt;a class=&quot;reference-link&quot; name=&quot;4.2 3X-UI 安装&quot;&gt;&lt;/a&gt;&lt;span class=&quot;header-link octicon octicon-link&quot;&gt;&lt;/span&gt;4.2 3X-UI 安装&lt;/h3&gt;&lt;p&gt;&lt;strong&gt;适用场景：&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;需要图形化界面管理节点&lt;/li&gt;&lt;li&gt;需要 SSL 证书配置&lt;/li&gt;&lt;li&gt;需要流量统计和用户管理&lt;/li&gt;&lt;li&gt;不想手动编辑配置文件&lt;/li&gt;&lt;/ul&gt;
&lt;p&gt;&lt;strong&gt;安装命令：&lt;/strong&gt;&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-bash&quot;&gt;sudo apt update &amp;amp;&amp;amp; sudo apt upgrade -y
sudo apt install curl -y


bash &amp;lt;(curl -Ls https://raw.githubusercontent.com/mhsanaei/3x-ui/master/install.sh)
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;strong&gt;安装交互设置：&lt;/strong&gt;&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;是否自定义面板端口：&lt;code&gt;y&lt;/code&gt; → 如 &lt;code&gt;54321&lt;/code&gt;&lt;/li&gt;&lt;li&gt;设置用户名、密码&lt;/li&gt;&lt;li&gt;面板路径：默认回车&lt;/li&gt;&lt;li&gt;SSL：先选 &lt;code&gt;2&lt;/code&gt;（自签）或 &lt;code&gt;3&lt;/code&gt;（稍后配置）&lt;/li&gt;&lt;/ol&gt;
&lt;p&gt;&lt;strong&gt;访问地址：&lt;/strong&gt;&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;http://服务器IP:54321
https://域名:54321
&lt;/code&gt;&lt;/pre&gt;
&lt;h3 id=&quot;h3-4.3203X-UI20u5E38u7528u547Du4EE4-786&quot;&gt;&lt;a class=&quot;reference-link&quot; name=&quot;4.3 3X-UI 常用命令&quot;&gt;&lt;/a&gt;&lt;span class=&quot;header-link octicon octicon-link&quot;&gt;&lt;/span&gt;4.3 3X-UI 常用命令&lt;/h3&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot;&gt;# 面板服务
systemctl start x-ui    # 启动
systemctl stop x-ui     # 停止
systemctl restart x-ui  # 重启
systemctl status x-ui   # 状态

# 实时日志
journalctl -u x-ui -f
&lt;/code&gt;&lt;/pre&gt;
&lt;h3 id=&quot;h3-4.4203X-UI20u914Du7F6E20SSL20u8BC1u4E66-799&quot;&gt;&lt;a class=&quot;reference-link&quot; name=&quot;4.4 3X-UI 配置 SSL 证书&quot;&gt;&lt;/a&gt;&lt;span class=&quot;header-link octicon octicon-link&quot;&gt;&lt;/span&gt;4.4 3X-UI 配置 SSL 证书&lt;/h3&gt;&lt;p&gt;&lt;strong&gt;1. 安装 acme.sh&lt;/strong&gt;&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-bash&quot;&gt;curl https://get.acme.sh | sh
source ~/.bashrc
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;strong&gt;2. 注册邮箱（必须）&lt;/strong&gt;&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-bash&quot;&gt;acme.sh --register-account -m 你的邮箱
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;strong&gt;3. 放行 80 端口&lt;/strong&gt;&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-bash&quot;&gt;sudo ufw allow 80/tcp
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;strong&gt;4. 申请证书（standalone 模式）&lt;/strong&gt;&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-bash&quot;&gt;acme.sh --issue -d 你的域名 --standalone
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;strong&gt;5. 证书默认路径&lt;/strong&gt;&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;/root/.acme.sh/你的域名_ecc/
├── fullchain.cer  # 证书链
├── 你的域名.key   # 私钥
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;strong&gt;6. 创建证书目录并复制&lt;/strong&gt;&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-bash&quot;&gt;mkdir -p /etc/3x-ui/certs

cp /root/.acme.sh/你的域名_ecc/fullchain.cer /etc/3x-ui/certs/cert.pem
cp /root/.acme.sh/你的域名_ecc/你的域名.key /etc/3x-ui/certs/key.pem
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;strong&gt;7. 设置安全权限&lt;/strong&gt;&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-bash&quot;&gt;chmod 644 /etc/3x-ui/certs/cert.pem
chmod 600 /etc/3x-ui/certs/key.pem
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;strong&gt;8. 面板配置&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;面板设置 → SSL证书设置&lt;/li&gt;&lt;li&gt;证书路径：&lt;code&gt;/etc/3x-ui/certs/cert.pem&lt;/code&gt;&lt;/li&gt;&lt;li&gt;私钥路径：&lt;code&gt;/etc/3x-ui/certs/key.pem&lt;/code&gt;&lt;/li&gt;&lt;/ul&gt;
&lt;p&gt;&lt;strong&gt;9. 重启面板&lt;/strong&gt;&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-bash&quot;&gt;systemctl restart x-ui
&lt;/code&gt;&lt;/pre&gt;
&lt;h3 id=&quot;h3-4.5203X-UI20u6DFBu52A0u5165u7AD9uFF08VLESS+WS+TLSuFF09-853&quot;&gt;&lt;a class=&quot;reference-link&quot; name=&quot;4.5 3X-UI 添加入站（VLESS+WS+TLS）&quot;&gt;&lt;/a&gt;&lt;span class=&quot;header-link octicon octicon-link&quot;&gt;&lt;/span&gt;4.5 3X-UI 添加入站（VLESS+WS+TLS）&lt;/h3&gt;&lt;p&gt;&lt;strong&gt;入站配置步骤：&lt;/strong&gt;&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;基本信息&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;协议：&lt;code&gt;vless&lt;/code&gt;&lt;/li&gt;&lt;li&gt;端口：&lt;code&gt;443&lt;/code&gt;&lt;/li&gt;&lt;li&gt;监听：&lt;code&gt;0.0.0.0&lt;/code&gt;&lt;/li&gt;&lt;li&gt;备注：&lt;code&gt;VLESS-WS-TLS&lt;/code&gt;&lt;/li&gt;&lt;/ul&gt;
&lt;/li&gt;&lt;li&gt;&lt;p&gt;&lt;strong&gt;传输配置&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Network：&lt;code&gt;ws&lt;/code&gt;&lt;/li&gt;&lt;li&gt;路径：&lt;code&gt;/v2ray&lt;/code&gt;&lt;/li&gt;&lt;li&gt;Host：你的域名&lt;/li&gt;&lt;/ul&gt;
&lt;/li&gt;&lt;li&gt;&lt;p&gt;&lt;strong&gt;TLS 配置&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;启用TLS：勾选&lt;/li&gt;&lt;li&gt;证书/私钥路径：同上&lt;/li&gt;&lt;/ul&gt;
&lt;/li&gt;&lt;li&gt;&lt;p&gt;&lt;strong&gt;客户配置&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Add Client → 生成 UUID&lt;/li&gt;&lt;li&gt;Flow：&lt;code&gt;none&lt;/code&gt;&lt;/li&gt;&lt;li&gt;Encryption：&lt;code&gt;none&lt;/code&gt;&lt;/li&gt;&lt;/ul&gt;
&lt;/li&gt;&lt;li&gt;&lt;p&gt;&lt;strong&gt;验证端口监听&lt;/strong&gt;&lt;/p&gt;
&lt;/li&gt;&lt;/ol&gt;
&lt;pre&gt;&lt;code class=&quot;language-bash&quot;&gt;netstat -tlnp | grep 443
&lt;/code&gt;&lt;/pre&gt;
&lt;h3 id=&quot;h3-4.6203X-UI20u6DFBu52A0u5165u7AD9uFF08VLESS+XTLS+REALITYuFF09-882&quot;&gt;&lt;a class=&quot;reference-link&quot; name=&quot;4.6 3X-UI 添加入站（VLESS+XTLS+REALITY）&quot;&gt;&lt;/a&gt;&lt;span class=&quot;header-link octicon octicon-link&quot;&gt;&lt;/span&gt;4.6 3X-UI 添加入站（VLESS+XTLS+REALITY）&lt;/h3&gt;&lt;blockquote&gt;&lt;p&gt;如果追求极致性能和抗封锁能力，推荐使用 VLESS+XTLS+REALITY。无需域名和证书，通过借用真实网站的 TLS 指纹实现最强伪装。&lt;/p&gt;
&lt;/blockquote&gt;&lt;h4 id=&quot;h4-u5165u7AD9u914Du7F6Eu6B65u9AA4-886&quot;&gt;&lt;a class=&quot;reference-link&quot; name=&quot;入站配置步骤&quot;&gt;&lt;/a&gt;&lt;span class=&quot;header-link octicon octicon-link&quot;&gt;&lt;/span&gt;入站配置步骤&lt;/h4&gt;&lt;ol&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;基本信息&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;协议：&lt;code&gt;vless&lt;/code&gt;&lt;/li&gt;&lt;li&gt;端口：&lt;code&gt;36606&lt;/code&gt;（或自定义高位端口）&lt;/li&gt;&lt;li&gt;监听：&lt;code&gt;0.0.0.0&lt;/code&gt;&lt;/li&gt;&lt;li&gt;备注：&lt;code&gt;VLESS-XTLS-REALITY&lt;/code&gt;&lt;/li&gt;&lt;/ul&gt;
&lt;/li&gt;&lt;li&gt;&lt;p&gt;&lt;strong&gt;传输配置&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Network：&lt;code&gt;TCP (RAW)&lt;/code&gt;（不是 WebSocket/XHTTP）&lt;/li&gt;&lt;/ul&gt;
&lt;/li&gt;&lt;li&gt;&lt;p&gt;&lt;strong&gt;安全设置&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;安全：选择 &lt;code&gt;Reality&lt;/code&gt;&lt;/li&gt;&lt;/ul&gt;
&lt;/li&gt;&lt;li&gt;&lt;p&gt;&lt;strong&gt;REALITY 参数&lt;/strong&gt;&lt;/p&gt;
&lt;/li&gt;&lt;/ol&gt;
&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;参数&lt;/th&gt;
&lt;th&gt;说明&lt;/th&gt;
&lt;th&gt;示例&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;uTLS&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;模仿的浏览器指纹&lt;/td&gt;
&lt;td&gt;&lt;code&gt;chrome&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Target&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;借用的目标网站（必须是真实 HTTPS）&lt;/td&gt;
&lt;td&gt;&lt;code&gt;www.apple.com:443&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;SNI&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;必须与 Target 的域名一致&lt;/td&gt;
&lt;td&gt;&lt;code&gt;www.apple.com&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Public Key&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;点击生成&lt;/td&gt;
&lt;td&gt;（自动生成）&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Private Key&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;服务器端保留&lt;/td&gt;
&lt;td&gt;（自动生成）&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Short IDs&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;可留空或填短字符串&lt;/td&gt;
&lt;td&gt;&lt;code&gt;abc123&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;ol&gt;
&lt;li&gt;&lt;strong&gt;客户端配置&lt;/strong&gt;&lt;ul&gt;
&lt;li&gt;Add Client → 生成 UUID&lt;/li&gt;&lt;li&gt;Flow：&lt;code&gt;xtls-rprx-vision&lt;/code&gt;（启用 XTLS 加速的关键）&lt;/li&gt;&lt;li&gt;Encryption：&lt;code&gt;none&lt;/code&gt;&lt;/li&gt;&lt;/ul&gt;
&lt;/li&gt;&lt;/ol&gt;
&lt;h4 id=&quot;h4-Target20u53C2u6570u8BF4u660E-916&quot;&gt;&lt;a class=&quot;reference-link&quot; name=&quot;Target 参数说明&quot;&gt;&lt;/a&gt;&lt;span class=&quot;header-link octicon octicon-link&quot;&gt;&lt;/span&gt;Target 参数说明&lt;/h4&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;参数&lt;/th&gt;
&lt;th&gt;含义&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Target&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;REALITY 借用的外部真实网站（固定 443 端口）&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;你的代理端口&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;客户端连接的端口（如 36606）&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;blockquote&gt;&lt;p&gt;&lt;strong&gt;注意&lt;/strong&gt;：Target 保持 &lt;code&gt;www.apple.com:443&lt;/code&gt;（或类似），不要改为你的代理端口！&lt;/p&gt;
&lt;/blockquote&gt;&lt;h4 id=&quot;h4-u98CEu9669u4E0Eu5E94u5BF9-925&quot;&gt;&lt;a class=&quot;reference-link&quot; name=&quot;风险与应对&quot;&gt;&lt;/a&gt;&lt;span class=&quot;header-link octicon octicon-link&quot;&gt;&lt;/span&gt;风险与应对&lt;/h4&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;风险&lt;/th&gt;
&lt;th&gt;降低方法&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;DNS 白名单检测&lt;/td&gt;
&lt;td&gt;选择大型网站作为 Target（如 microsoft.com、apple.com）&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;中间人攻击检测&lt;/td&gt;
&lt;td&gt;定期更换 REALITY 公钥/私钥&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;单点故障&lt;/td&gt;
&lt;td&gt;保留 VLESS+WS+TLS 节点作为备用&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;h4 id=&quot;h4-v2rayN20u5BA2u6237u7AEFu914Du7F6E-933&quot;&gt;&lt;a class=&quot;reference-link&quot; name=&quot;v2rayN 客户端配置&quot;&gt;&lt;/a&gt;&lt;span class=&quot;header-link octicon octicon-link&quot;&gt;&lt;/span&gt;v2rayN 客户端配置&lt;/h4&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;参数&lt;/th&gt;
&lt;th&gt;值&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;协议&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;VLESS&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;地址&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;服务器 IP&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;端口&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;36606&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;UUID&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;面板生成的 UUID&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Flow&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;xtls-rprx-vision&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;传输&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;TCP&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;安全&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;REALITY&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;SNI&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;www.apple.com&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;uTLS&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;chrome&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;h3 id=&quot;h3-4.7203X-UI20u7AEFu53E32044320u51B2u7A81u89E3u51B3-947&quot;&gt;&lt;a class=&quot;reference-link&quot; name=&quot;4.7 3X-UI 端口 443 冲突解决&quot;&gt;&lt;/a&gt;&lt;span class=&quot;header-link octicon octicon-link&quot;&gt;&lt;/span&gt;4.7 3X-UI 端口 443 冲突解决&lt;/h3&gt;&lt;p&gt;&lt;strong&gt;现象：&lt;/strong&gt;&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;Failed to listen on 0.0.0.0:443
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;strong&gt;排查命令：&lt;/strong&gt;&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-bash&quot;&gt;sudo lsof -i :443
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;strong&gt;解决方案（手动 V2Ray 占用）：&lt;/strong&gt;&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-bash&quot;&gt;systemctl stop v2ray
systemctl disable v2ray
systemctl restart x-ui
&lt;/code&gt;&lt;/pre&gt;
&lt;h3 id=&quot;h3-4.8203X-UI20u5BA2u6237u7AEFu914Du7F6EuFF08v2rayNuFF09-966&quot;&gt;&lt;a class=&quot;reference-link&quot; name=&quot;4.8 3X-UI 客户端配置（v2rayN）&quot;&gt;&lt;/a&gt;&lt;span class=&quot;header-link octicon octicon-link&quot;&gt;&lt;/span&gt;4.8 3X-UI 客户端配置（v2rayN）&lt;/h3&gt;&lt;ol&gt;
&lt;li&gt;面板入站 → 操作 → 查看配置 → 复制链接&lt;/li&gt;&lt;li&gt;v2rayN → 从剪贴板导入&lt;/li&gt;&lt;li&gt;右键节点 → 编辑 → TLS&lt;ul&gt;
&lt;li&gt;勾选：跳过证书验证（allowInsecure）&lt;/li&gt;&lt;li&gt;SNI：填写域名&lt;/li&gt;&lt;/ul&gt;
&lt;/li&gt;&lt;li&gt;测试连通性&lt;/li&gt;&lt;/ol&gt;
&lt;h3 id=&quot;h3-4.920Marzban20u5B89u88C5uFF08u5907u9009uFF09-975&quot;&gt;&lt;a class=&quot;reference-link&quot; name=&quot;4.9 Marzban 安装（备选）&quot;&gt;&lt;/a&gt;&lt;span class=&quot;header-link octicon octicon-link&quot;&gt;&lt;/span&gt;4.9 Marzban 安装（备选）&lt;/h3&gt;&lt;p&gt;&lt;strong&gt;安装命令：&lt;/strong&gt;&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-bash&quot;&gt;# 一键安装
bash &amp;lt;(curl -s https://raw.githubusercontent.com/Gozargah/Marzban-scripts/master/marzban.sh)
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;strong&gt;基本命令：&lt;/strong&gt;&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-bash&quot;&gt;# 查看状态
marzban status

# 启动/停止/重启
marzban start
marzban stop
marzban restart

# 查看日志
marzban logs
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;strong&gt;访问面板：&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;默认端口：&lt;strong&gt;8000&lt;/strong&gt;&lt;/li&gt;&lt;li&gt;用户名：&lt;strong&gt;admin&lt;/strong&gt;&lt;/li&gt;&lt;li&gt;密码：安装时生成&lt;/li&gt;&lt;/ul&gt;
&lt;p&gt;&lt;strong&gt;特点：&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;支持 VLESS、Trojan、Shadowsocks、VMess&lt;/li&gt;&lt;li&gt;支持订阅、流量限制、到期时间&lt;/li&gt;&lt;li&gt;支持 API 可对接 otherpanel 等前端&lt;/li&gt;&lt;/ul&gt;
&lt;h3 id=&quot;h3-4.1020u9762u677Fu5E38u7528u547Du4EE4u901Fu67E5-1007&quot;&gt;&lt;a class=&quot;reference-link&quot; name=&quot;4.10 面板常用命令速查&quot;&gt;&lt;/a&gt;&lt;span class=&quot;header-link octicon octicon-link&quot;&gt;&lt;/span&gt;4.10 面板常用命令速查&lt;/h3&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot;&gt;# 面板服务（3X-UI/x-ui）
systemctl start x-ui
systemctl stop x-ui
systemctl restart x-ui
systemctl status x-ui

# 实时日志
journalctl -u x-ui -f

# 端口监听
netstat -tlnp | grep 443
netstat -tlnp | grep 54321

# 防火墙放行
sudo ufw allow 80/tcp
sudo ufw allow 443/tcp
sudo ufw allow 54321/tcp

# 证书复制通用模板
cp ~/.acme.sh/域名_ecc/fullchain.cer /etc/3x-ui/certs/cert.pem
cp ~/.acme.sh/域名_ecc/域名.key /etc/3x-ui/certs/key.pem
&lt;/code&gt;&lt;/pre&gt;
&lt;hr&gt;
&lt;h2 id=&quot;h2-5.20u516Cu5171u90E8u5206-1035&quot;&gt;&lt;a class=&quot;reference-link&quot; name=&quot;5. 公共部分&quot;&gt;&lt;/a&gt;&lt;span class=&quot;header-link octicon octicon-link&quot;&gt;&lt;/span&gt;5. 公共部分&lt;/h2&gt;&lt;h3 id=&quot;h3-5.120u57DFu540Du8D2Du4E70u4E0Eu89E3u6790-1037&quot;&gt;&lt;a class=&quot;reference-link&quot; name=&quot;5.1 域名购买与解析&quot;&gt;&lt;/a&gt;&lt;span class=&quot;header-link octicon octicon-link&quot;&gt;&lt;/span&gt;5.1 域名购买与解析&lt;/h3&gt;&lt;p&gt;&lt;strong&gt;域名注册商：&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Namesilo（性价比高）&lt;/li&gt;&lt;li&gt;阿里云&lt;/li&gt;&lt;li&gt;Cloudflare（免费）&lt;/li&gt;&lt;/ul&gt;
&lt;p&gt;&lt;strong&gt;添加 DNS 解析：&lt;/strong&gt;&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;登录域名管理后台&lt;/li&gt;&lt;li&gt;添加 A 记录：&lt;ul&gt;
&lt;li&gt;主机记录：&lt;code&gt;@&lt;/code&gt; 或 &lt;code&gt;www&lt;/code&gt;&lt;/li&gt;&lt;li&gt;记录值：服务器公网 IP&lt;/li&gt;&lt;/ul&gt;
&lt;/li&gt;&lt;li&gt;验证解析：&lt;/li&gt;&lt;/ol&gt;
&lt;pre&gt;&lt;code class=&quot;language-bash&quot;&gt;ping 你的域名
&lt;/code&gt;&lt;/pre&gt;
&lt;h3 id=&quot;h3-5.220TLS20u8BC1u4E66u7533u8BF7uFF08acme.shuFF09-1055&quot;&gt;&lt;a class=&quot;reference-link&quot; name=&quot;5.2 TLS 证书申请（acme.sh）&quot;&gt;&lt;/a&gt;&lt;span class=&quot;header-link octicon octicon-link&quot;&gt;&lt;/span&gt;5.2 TLS 证书申请（acme.sh）&lt;/h3&gt;&lt;p&gt;&lt;strong&gt;安装 acme.sh：&lt;/strong&gt;&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-bash&quot;&gt;curl https://get.acme.sh | sh
source ~/.bashrc
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;strong&gt;注册账号：&lt;/strong&gt;&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-bash&quot;&gt;acme.sh --register-account -m 你的邮箱
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;strong&gt;申请证书（standalone 模式）：&lt;/strong&gt;&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-bash&quot;&gt;# 放行80端口
ufw allow 80/tcp

# 申请
acme.sh --issue -d 你的域名 --standalone
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;strong&gt;证书路径：&lt;/strong&gt;&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;/root/.acme.sh/你的域名_ecc/
├── fullchain.cer  # 证书链
├── 你的域名.key   # 私钥
&lt;/code&gt;&lt;/pre&gt;
&lt;h3 id=&quot;h3-5.320u5BA2u6237u7AEFu914Du7F6Eu751Fu6210u89C4u5219-1084&quot;&gt;&lt;a class=&quot;reference-link&quot; name=&quot;5.3 客户端配置生成规则&quot;&gt;&lt;/a&gt;&lt;span class=&quot;header-link octicon octicon-link&quot;&gt;&lt;/span&gt;5.3 客户端配置生成规则&lt;/h3&gt;&lt;h4 id=&quot;h4-VMess20u94FEu63A5u683Cu5F0F-1086&quot;&gt;&lt;a class=&quot;reference-link&quot; name=&quot;VMess 链接格式&quot;&gt;&lt;/a&gt;&lt;span class=&quot;header-link octicon octicon-link&quot;&gt;&lt;/span&gt;VMess 链接格式&lt;/h4&gt;&lt;pre&gt;&lt;code&gt;vmess://base64({&quot;v&quot;: &quot;2&quot;, &quot;ps&quot;: &quot;名称&quot;, &quot;add&quot;: &quot;IP&quot;, &quot;port&quot;: &quot;端口&quot;, &quot;id&quot;: &quot;UUID&quot;, &quot;aid&quot;: 0, &quot;net&quot;: &quot;tcp/ws&quot;, &quot;type&quot;: &quot;none&quot;, &quot;host&quot;: &quot;&quot;, &quot;path&quot;: &quot;/路径&quot;, &quot;tls&quot;: &quot;tls/aio&quot;})
&lt;/code&gt;&lt;/pre&gt;
&lt;h4 id=&quot;h4-VLESS20u94FEu63A5u683Cu5F0F-1091&quot;&gt;&lt;a class=&quot;reference-link&quot; name=&quot;VLESS 链接格式&quot;&gt;&lt;/a&gt;&lt;span class=&quot;header-link octicon octicon-link&quot;&gt;&lt;/span&gt;VLESS 链接格式&lt;/h4&gt;&lt;pre&gt;&lt;code&gt;vless://UUID@IP:端口?encryption=none&amp;amp;type=tcp/ws&amp;amp;path=/路径#名称
&lt;/code&gt;&lt;/pre&gt;
&lt;h4 id=&quot;h4-Trojan20u94FEu63A5u683Cu5F0F-1096&quot;&gt;&lt;a class=&quot;reference-link&quot; name=&quot;Trojan 链接格式&quot;&gt;&lt;/a&gt;&lt;span class=&quot;header-link octicon octicon-link&quot;&gt;&lt;/span&gt;Trojan 链接格式&lt;/h4&gt;&lt;pre&gt;&lt;code&gt;trojan://密码@IP:端口#名称
&lt;/code&gt;&lt;/pre&gt;
&lt;h4 id=&quot;h4-Shadowsocks20u94FEu63A5u683Cu5F0F-1101&quot;&gt;&lt;a class=&quot;reference-link&quot; name=&quot;Shadowsocks 链接格式&quot;&gt;&lt;/a&gt;&lt;span class=&quot;header-link octicon octicon-link&quot;&gt;&lt;/span&gt;Shadowsocks 链接格式&lt;/h4&gt;&lt;pre&gt;&lt;code&gt;ss://base64(method:password@IP:端口)#名称
&lt;/code&gt;&lt;/pre&gt;
&lt;h3 id=&quot;h3-5.420u5E38u7528u7AEFu53E3-1106&quot;&gt;&lt;a class=&quot;reference-link&quot; name=&quot;5.4 常用端口&quot;&gt;&lt;/a&gt;&lt;span class=&quot;header-link octicon octicon-link&quot;&gt;&lt;/span&gt;5.4 常用端口&lt;/h3&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;端口&lt;/th&gt;
&lt;th&gt;用途&lt;/th&gt;
&lt;th&gt;备注&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;80&lt;/td&gt;
&lt;td&gt;HTTP&lt;/td&gt;
&lt;td&gt;可用于 ACME 申请证书&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;443&lt;/td&gt;
&lt;td&gt;HTTPS/TLS&lt;/td&gt;
&lt;td&gt;常用伪装端口&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;8443&lt;/td&gt;
&lt;td&gt;自定义 TLS&lt;/td&gt;
&lt;td&gt;可替代 443&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;10086&lt;/td&gt;
&lt;td&gt;VMess/VLESS TCP&lt;/td&gt;
&lt;td&gt;自定义端口&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;54321&lt;/td&gt;
&lt;td&gt;3X-UI 面板&lt;/td&gt;
&lt;td&gt;默认面板端口&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;8000&lt;/td&gt;
&lt;td&gt;Marzban 面板&lt;/td&gt;
&lt;td&gt;默认面板端口&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;8388&lt;/td&gt;
&lt;td&gt;Shadowsocks&lt;/td&gt;
&lt;td&gt;默认端口&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;h3 id=&quot;h3-5.520u5BA2u6237u7AEFu4E0Bu8F7Du4E0Eu914Du7F6E-1118&quot;&gt;&lt;a class=&quot;reference-link&quot; name=&quot;5.5 客户端下载与配置&quot;&gt;&lt;/a&gt;&lt;span class=&quot;header-link octicon octicon-link&quot;&gt;&lt;/span&gt;5.5 客户端下载与配置&lt;/h3&gt;&lt;h4 id=&quot;h4-u5404u5E73u53F0u63A8u8350u5BA2u6237u7AEF-1120&quot;&gt;&lt;a class=&quot;reference-link&quot; name=&quot;各平台推荐客户端&quot;&gt;&lt;/a&gt;&lt;span class=&quot;header-link octicon octicon-link&quot;&gt;&lt;/span&gt;各平台推荐客户端&lt;/h4&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th style=&quot;text-align:left&quot;&gt;操作系统&lt;/th&gt;
&lt;th style=&quot;text-align:left&quot;&gt;推荐客户端&lt;/th&gt;
&lt;th style=&quot;text-align:left&quot;&gt;下载来源&lt;/th&gt;
&lt;th style=&quot;text-align:left&quot;&gt;简要特点&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td style=&quot;text-align:left&quot;&gt;&lt;strong&gt;Windows&lt;/strong&gt;&lt;/td&gt;
&lt;td style=&quot;text-align:left&quot;&gt;&lt;strong&gt;v2rayN&lt;/strong&gt;&lt;/td&gt;
&lt;td style=&quot;text-align:left&quot;&gt;&lt;a href=&quot;https://github.com/2dust/v2rayN/releases&quot;&gt;GitHub Releases&lt;/a&gt;&lt;/td&gt;
&lt;td style=&quot;text-align:left&quot;&gt;功能强大，图形化界面，支持多种协议和订阅&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&quot;text-align:left&quot;&gt;&lt;/td&gt;
&lt;td style=&quot;text-align:left&quot;&gt;Clash for Windows&lt;/td&gt;
&lt;td style=&quot;text-align:left&quot;&gt;&lt;a href=&quot;https://github.com/Fndroid/clash_for_windows_pkg/releases&quot;&gt;GitHub Releases&lt;/a&gt;&lt;/td&gt;
&lt;td style=&quot;text-align:left&quot;&gt;界面美观，基于规则分流，对新手友好&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&quot;text-align:left&quot;&gt;&lt;strong&gt;macOS&lt;/strong&gt;&lt;/td&gt;
&lt;td style=&quot;text-align:left&quot;&gt;&lt;strong&gt;V2rayU&lt;/strong&gt;&lt;/td&gt;
&lt;td style=&quot;text-align:left&quot;&gt;&lt;a href=&quot;https://github.com/yanue/V2rayU/releases&quot;&gt;GitHub Releases&lt;/a&gt; 或 &lt;code&gt;brew install --cask v2rayu&lt;/code&gt;&lt;/td&gt;
&lt;td style=&quot;text-align:left&quot;&gt;经典 macOS 客户端，稳定易用&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&quot;text-align:left&quot;&gt;&lt;/td&gt;
&lt;td style=&quot;text-align:left&quot;&gt;ClashX&lt;/td&gt;
&lt;td style=&quot;text-align:left&quot;&gt;&lt;a href=&quot;https://github.com/yichengchen/clashX/releases&quot;&gt;GitHub Releases&lt;/a&gt;&lt;/td&gt;
&lt;td style=&quot;text-align:left&quot;&gt;轻量简洁，macOS 热门选择&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&quot;text-align:left&quot;&gt;&lt;strong&gt;Android&lt;/strong&gt;&lt;/td&gt;
&lt;td style=&quot;text-align:left&quot;&gt;&lt;strong&gt;v2rayNG&lt;/strong&gt;&lt;/td&gt;
&lt;td style=&quot;text-align:left&quot;&gt;&lt;a href=&quot;https://play.google.com/store/apps/details?id=com.v2ray.ang&quot;&gt;Google Play&lt;/a&gt; 或 &lt;a href=&quot;https://github.com/2dust/v2rayNG/releases&quot;&gt;GitHub&lt;/a&gt;&lt;/td&gt;
&lt;td style=&quot;text-align:left&quot;&gt;功能全面，支持二维码扫描和订阅&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&quot;text-align:left&quot;&gt;&lt;strong&gt;iOS&lt;/strong&gt;&lt;/td&gt;
&lt;td style=&quot;text-align:left&quot;&gt;Shadowrocket&lt;/td&gt;
&lt;td style=&quot;text-align:left&quot;&gt;App Store (付费)&lt;/td&gt;
&lt;td style=&quot;text-align:left&quot;&gt;功能强大，iOS 主流选择&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&quot;text-align:left&quot;&gt;&lt;/td&gt;
&lt;td style=&quot;text-align:left&quot;&gt;Quantumult X&lt;/td&gt;
&lt;td style=&quot;text-align:left&quot;&gt;App Store (付费)&lt;/td&gt;
&lt;td style=&quot;text-align:left&quot;&gt;专业复杂，适合高阶用户&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&quot;text-align:left&quot;&gt;&lt;strong&gt;Linux&lt;/strong&gt;&lt;/td&gt;
&lt;td style=&quot;text-align:left&quot;&gt;&lt;strong&gt;v2rayL&lt;/strong&gt;&lt;/td&gt;
&lt;td style=&quot;text-align:left&quot;&gt;&lt;a href=&quot;https://github.com/jiangxufeng/v2rayL/releases&quot;&gt;GitHub Releases&lt;/a&gt;&lt;/td&gt;
&lt;td style=&quot;text-align:left&quot;&gt;图形化界面，对 Linux 桌面用户友好&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&quot;text-align:left&quot;&gt;&lt;/td&gt;
&lt;td style=&quot;text-align:left&quot;&gt;Qv2ray&lt;/td&gt;
&lt;td style=&quot;text-align:left&quot;&gt;&lt;a href=&quot;https://github.com/Qv2ray/Qv2ray/releases&quot;&gt;GitHub Releases&lt;/a&gt;&lt;/td&gt;
&lt;td style=&quot;text-align:left&quot;&gt;跨平台，功能强大（已停止维护）&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;blockquote&gt;&lt;p&gt;&lt;strong&gt;核心提示&lt;/strong&gt;：上述客户端基本免费且开源，务必从官方 GitHub 下载最新版本。&lt;/p&gt;
&lt;/blockquote&gt;&lt;h4 id=&quot;h4-u4E0Bu8F7Du6B65u9AA4uFF08u4EE520v2rayN20u4E3Au4F8BuFF09-1136&quot;&gt;&lt;a class=&quot;reference-link&quot; name=&quot;下载步骤（以 v2rayN 为例）&quot;&gt;&lt;/a&gt;&lt;span class=&quot;header-link octicon octicon-link&quot;&gt;&lt;/span&gt;下载步骤（以 v2rayN 为例）&lt;/h4&gt;&lt;ol&gt;
&lt;li&gt;&lt;strong&gt;访问发布页面&lt;/strong&gt;：打开 &lt;code&gt;github.com/2dust/v2rayN/releases&lt;/code&gt;&lt;/li&gt;&lt;li&gt;&lt;strong&gt;选择版本&lt;/strong&gt;：下载最新的 &lt;code&gt;.zip&lt;/code&gt; 或 &lt;code&gt;.7z&lt;/code&gt; 压缩包（解压即用版）&lt;/li&gt;&lt;li&gt;&lt;strong&gt;运行客户端&lt;/strong&gt;：解压后运行 &lt;code&gt;v2rayN.exe&lt;/code&gt; 即可&lt;/li&gt;&lt;/ol&gt;
&lt;h4 id=&quot;h4-u5BA2u6237u7AEFu914Du7F6Eu6B65u9AA4-1142&quot;&gt;&lt;a class=&quot;reference-link&quot; name=&quot;客户端配置步骤&quot;&gt;&lt;/a&gt;&lt;span class=&quot;header-link octicon octicon-link&quot;&gt;&lt;/span&gt;客户端配置步骤&lt;/h4&gt;&lt;ol&gt;
&lt;li&gt;&lt;strong&gt;添加节点&lt;/strong&gt;：手动输入或扫描二维码导入节点信息&lt;/li&gt;&lt;li&gt;&lt;strong&gt;填写服务端信息&lt;/strong&gt;：&lt;ul&gt;
&lt;li&gt;类型：VLESS&lt;/li&gt;&lt;li&gt;地址：你的服务器 IP 或域名&lt;/li&gt;&lt;li&gt;端口：10086（TCP）或 443（WS+TLS）&lt;/li&gt;&lt;li&gt;UUID：服务端配置的 UUID&lt;/li&gt;&lt;li&gt;传输：TCP 或 WebSocket&lt;/li&gt;&lt;li&gt;TLS：TCP 节点关闭，WS+TLS 节点开启&lt;/li&gt;&lt;li&gt;允许不安全连接：仅 WS+TLS（自签名证书）时需要&lt;/li&gt;&lt;/ul&gt;
&lt;/li&gt;&lt;li&gt;&lt;strong&gt;测试连接&lt;/strong&gt;：点击”使用”或直接启动代理测试&lt;/li&gt;&lt;/ol&gt;
&lt;h4 id=&quot;h4-u6CE8u610Fu4E8Bu9879-1155&quot;&gt;&lt;a class=&quot;reference-link&quot; name=&quot;注意事项&quot;&gt;&lt;/a&gt;&lt;span class=&quot;header-link octicon octicon-link&quot;&gt;&lt;/span&gt;注意事项&lt;/h4&gt;&lt;p&gt;&lt;strong&gt;时间同步：&lt;/strong&gt;&lt;br&gt;V2Ray 对时间同步有严格要求，客户端和服务器的系统时间误差不能超过 1 分钟，否则可能无法连接。请在设备设置中开启”自动设置时间”功能。&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;网络环境：&lt;/strong&gt;&lt;br&gt;访问 GitHub 网站有时可能不太稳定，这是正常现象，可能需要一些耐心。&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;macOS 安全警告：&lt;/strong&gt;&lt;br&gt;首次打开非 App Store 下载的应用时，可能会提示”文件已损坏”。这时需要在”系统设置” &amp;gt; “隐私与安全性”中手动允许运行该应用。&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;客户端使用前提：&lt;/strong&gt;&lt;br&gt;客户端本身只是一个工具，需要配合可用的服务器节点或订阅链接才能使用。&lt;/p&gt;
&lt;hr&gt;
&lt;h2 id=&quot;h2-6.20u95EEu9898u6E05u5355u4E0Eu89E3u51B3u65B9u6848-1171&quot;&gt;&lt;a class=&quot;reference-link&quot; name=&quot;6. 问题清单与解决方案&quot;&gt;&lt;/a&gt;&lt;span class=&quot;header-link octicon octicon-link&quot;&gt;&lt;/span&gt;6. 问题清单与解决方案&lt;/h2&gt;&lt;h3 id=&quot;h3-u95EEu9898201uFF1Ageoip.dat20u6587u4EF6u635Fu574F-1173&quot;&gt;&lt;a class=&quot;reference-link&quot; name=&quot;问题 1：geoip.dat 文件损坏&quot;&gt;&lt;/a&gt;&lt;span class=&quot;header-link octicon octicon-link&quot;&gt;&lt;/span&gt;问题 1：geoip.dat 文件损坏&lt;/h3&gt;&lt;p&gt;&lt;strong&gt;现象：&lt;/strong&gt;&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;Failed to load geoip.dat: Not Found
或
geoip.dat only has 9 bytes
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;strong&gt;原因：&lt;/strong&gt;&lt;br&gt;geoip.dat 文件下载不完整或服务器返回了 404 页面&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;解决方案：&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;方法一：重新下载 geoip.dat&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-bash&quot;&gt;wget https://github.com/v2fly/geoip/raw/master/geoip.dat
mv geoip.dat /etc/v2ray/geoip.dat
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;方法二：使用域名路由（绕过 geoip）&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;在路由规则中使用 &lt;code&gt;domainStrategy: &quot;AsIs&quot;&lt;/code&gt;&lt;/li&gt;&lt;li&gt;使用 Cloudflare 等 CDN 隐藏服务器 IP&lt;/li&gt;&lt;li&gt;配置国内直连规则时不依赖 geoip&lt;/li&gt;&lt;/ul&gt;
&lt;p&gt;&lt;strong&gt;排查方法：&lt;/strong&gt;&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-bash&quot;&gt;# 检查文件大小
ls -la /etc/v2ray/geoip.dat

# 正确大小应该 &amp;gt; 1MB
# 如果是 9 bytes 则是下载失败
&lt;/code&gt;&lt;/pre&gt;
&lt;hr&gt;
&lt;h3 id=&quot;h3-u95EEu9898202uFF1AV2Ray205.x20u4E0Du652Fu630120VMess20u534Fu8BAE-1209&quot;&gt;&lt;a class=&quot;reference-link&quot; name=&quot;问题 2：V2Ray 5.x 不支持 VMess 协议&quot;&gt;&lt;/a&gt;&lt;span class=&quot;header-link octicon octicon-link&quot;&gt;&lt;/span&gt;问题 2：V2Ray 5.x 不支持 VMess 协议&lt;/h3&gt;&lt;p&gt;&lt;strong&gt;现象：&lt;/strong&gt;&lt;/p&gt;
&lt;pre&gt;&lt;code&gt; VLESS tick/tack required
 or
 VMess not supported after V2Ray 5.0
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;strong&gt;原因：&lt;/strong&gt;&lt;br&gt;V2Ray 5.x 版本移除了 VMess 协议支持，必须使用 VLESS&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;解决方案：&lt;/strong&gt;&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;服务器端改用 VLESS 协议&lt;/li&gt;&lt;/ol&gt;
&lt;pre&gt;&lt;code class=&quot;language-json&quot;&gt;{
  &quot;inbounds&quot;: [{
    &quot;protocol&quot;: &quot;vless&quot;,
    &quot;settings&quot;: {
      &quot;clients&quot;: [{
        &quot;id&quot;: &quot;你的UUID&quot;,
        &quot;flow&quot;: &quot;&quot;
      }]
    }
  }]
}
&lt;/code&gt;&lt;/pre&gt;
&lt;ol&gt;
&lt;li&gt;&lt;p&gt;客户端也必须选择 VLESS 类型&lt;/p&gt;
&lt;/li&gt;&lt;li&gt;&lt;p&gt;或降级到 V2Ray 4.x&lt;/p&gt;
&lt;/li&gt;&lt;/ol&gt;
&lt;pre&gt;&lt;code class=&quot;language-bash&quot;&gt;bash &amp;lt;(curl -L https://raw.githubusercontent.com/v2fly/fhs-install-v2ray/master/install-release.sh) --version 4.45.2
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;strong&gt;排查方法：&lt;/strong&gt;&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-bash&quot;&gt;# 检查 V2Ray 版本
v2ray version
# 或
/usr/local/bin/v2ray version
&lt;/code&gt;&lt;/pre&gt;
&lt;hr&gt;
&lt;h3 id=&quot;h3-u95EEu9898203uFF1AV2Ray205.x20u547Du4EE4u884Cu53C2u6570u53D8u66F4-1255&quot;&gt;&lt;a class=&quot;reference-link&quot; name=&quot;问题 3：V2Ray 5.x 命令行参数变更&quot;&gt;&lt;/a&gt;&lt;span class=&quot;header-link octicon octicon-link&quot;&gt;&lt;/span&gt;问题 3：V2Ray 5.x 命令行参数变更&lt;/h3&gt;&lt;p&gt;&lt;strong&gt;现象：&lt;/strong&gt;&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;unknown flag: -config
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;strong&gt;原因：&lt;/strong&gt;&lt;br&gt;V2Ray 5.x 更改了命令语法，从 &lt;code&gt;-config&lt;/code&gt; 改为 &lt;code&gt;run -config&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;解决方案：&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;V2Ray 4.x：&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-bash&quot;&gt;v2ray -config /etc/v2ray/config.json
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;V2Ray 5.x：&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-bash&quot;&gt;v2ray run -config /etc/v2ray/config.json
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;strong&gt;排查方法：&lt;/strong&gt;&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-bash&quot;&gt;# 查看帮助
v2ray help
v2ray run --help
&lt;/code&gt;&lt;/pre&gt;
&lt;hr&gt;
&lt;h3 id=&quot;h3-u95EEu9898204uFF1Au7AEFu53E320108020u88ABu5360u7528-1286&quot;&gt;&lt;a class=&quot;reference-link&quot; name=&quot;问题 4：端口 1080 被占用&quot;&gt;&lt;/a&gt;&lt;span class=&quot;header-link octicon octicon-link&quot;&gt;&lt;/span&gt;问题 4：端口 1080 被占用&lt;/h3&gt;&lt;p&gt;&lt;strong&gt;现象：&lt;/strong&gt;&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;port is already in use
listen tcp 0.0.0.0:1080: bind: address already in use
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;strong&gt;原因：&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;其他程序占用了 1080 端口（如 v2rayN、Shadowrocket 等）&lt;/li&gt;&lt;li&gt;系统中已有其他代理程序&lt;/li&gt;&lt;/ul&gt;
&lt;p&gt;&lt;strong&gt;解决方案：&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;方法一：更改代理端口&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;客户端使用其他端口如 10808、2080 等&lt;/li&gt;&lt;/ul&gt;
&lt;p&gt;方法二：查找占用进程&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-bash&quot;&gt;# Windows
netstat -ano | findstr :1080
tasklist | findstr PID

# Linux
lsof -i :1080
netstat -tlnp | grep 1080
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;方法三：关闭占用程序&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-bash&quot;&gt;# Windows 结束进程
taskkill /PID 进程ID /F
&lt;/code&gt;&lt;/pre&gt;
&lt;hr&gt;
&lt;h3 id=&quot;h3-u95EEu9898205uFF1Asystemd20u542Fu52A8u5931u8D25u4F46u624Bu52A8u8FD0u884Cu6210u529F-1322&quot;&gt;&lt;a class=&quot;reference-link&quot; name=&quot;问题 5：systemd 启动失败但手动运行成功&quot;&gt;&lt;/a&gt;&lt;span class=&quot;header-link octicon octicon-link&quot;&gt;&lt;/span&gt;问题 5：systemd 启动失败但手动运行成功&lt;/h3&gt;&lt;p&gt;&lt;strong&gt;现象：&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;systemctl start v2ray&lt;/code&gt; 失败，状态 &lt;code&gt;failed (Result: exit-code)&lt;/code&gt;&lt;/li&gt;&lt;li&gt;日志显示 &lt;code&gt;Failed to build TLS config&lt;/code&gt;&lt;/li&gt;&lt;li&gt;但直接运行 &lt;code&gt;/usr/local/bin/v2ray run -config ...&lt;/code&gt; 成功&lt;/li&gt;&lt;/ul&gt;
&lt;p&gt;&lt;strong&gt;原因：&lt;/strong&gt;&lt;br&gt;&lt;code&gt;/etc/ssl/private/&lt;/code&gt; 目录权限为 &lt;code&gt;700&lt;/code&gt;，systemd 运行时（nobody 用户）无法进入，导致无法读取 &lt;code&gt;key.pem&lt;/code&gt;。&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;解决：&lt;/strong&gt;&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-bash&quot;&gt;chmod 755 /etc/ssl/private/
systemctl restart v2ray
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;strong&gt;排查方法：&lt;/strong&gt;&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-bash&quot;&gt;# 查看详细日志
journalctl -u v2ray -n 50

# 检查进程
ps aux | grep v2ray

# 手动运行测试
/usr/local/bin/v2ray run -config /usr/local/etc/v2ray/config.json
&lt;/code&gt;&lt;/pre&gt;
&lt;hr&gt;
&lt;h3 id=&quot;h3-u95EEu9898206uFF1Acurl20u6D4Bu8BD5u8FD4u56DEu7ED3u679Cu89E3u8BFB-1352&quot;&gt;&lt;a class=&quot;reference-link&quot; name=&quot;问题 6：curl 测试返回结果解读&quot;&gt;&lt;/a&gt;&lt;span class=&quot;header-link octicon octicon-link&quot;&gt;&lt;/span&gt;问题 6：curl 测试返回结果解读&lt;/h3&gt;&lt;p&gt;&lt;strong&gt;WS+TLS 节点：&lt;/strong&gt;&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-bash&quot;&gt;curl -k https://服务器IP/v2ray -v
HTTP/1.1 400 Bad Request
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;这是&lt;strong&gt;正常&lt;/strong&gt;的！说明 443 端口正常，正在等待 WebSocket 握手。&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;TCP 节点：&lt;/strong&gt;&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-bash&quot;&gt;curl http://服务器IP:10086 -v
curl: (52) Empty reply from server
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;这也是&lt;strong&gt;正常&lt;/strong&gt;的！VLESS TCP 不是 HTTP 服务器，curl 无法完整测试。&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;结论：&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;curl 返回 Bad Request = 端口正常&lt;/li&gt;&lt;li&gt;curl 返回 Empty reply = 端口正常&lt;/li&gt;&lt;li&gt;使用客户端（v2rayN）测试连接&lt;/li&gt;&lt;/ul&gt;
&lt;hr&gt;
&lt;h3 id=&quot;h3-u95EEu9898207uFF1AWebSocket20u8DEFu5F84u4E0Du6B63u786E-1375&quot;&gt;&lt;a class=&quot;reference-link&quot; name=&quot;问题 7：WebSocket 路径不正确&quot;&gt;&lt;/a&gt;&lt;span class=&quot;header-link octicon octicon-link&quot;&gt;&lt;/span&gt;问题 7：WebSocket 路径不正确&lt;/h3&gt;&lt;p&gt;&lt;strong&gt;现象：&lt;/strong&gt;&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;websocket: connection refused
或
failed to handshake
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;strong&gt;原因：&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;服务器 path 与客户端不匹配&lt;/li&gt;&lt;li&gt;Nginx/Caddy 未正确代理 WebSocket&lt;/li&gt;&lt;/ul&gt;
&lt;p&gt;&lt;strong&gt;解决方案：&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;服务器 Nginx 配置：&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-nginx&quot;&gt;location /v2ray {
    proxy_pass http://127.0.0.1:10086;
    proxy_http_version 1.1;
    proxy_set_header Upgrade $http_upgrade;
    proxy_set_header Connection &quot;upgrade&quot;;
    proxy_set_header Host $host;
    keepalive_timeout 60s;
}
&lt;/code&gt;&lt;/pre&gt;
&lt;hr&gt;
&lt;h3 id=&quot;h3-u95EEu9898208uFF1ATLS20u8BC1u4E66u9A8Cu8BC1u5931u8D25-1404&quot;&gt;&lt;a class=&quot;reference-link&quot; name=&quot;问题 8：TLS 证书验证失败&quot;&gt;&lt;/a&gt;&lt;span class=&quot;header-link octicon octicon-link&quot;&gt;&lt;/span&gt;问题 8：TLS 证书验证失败&lt;/h3&gt;&lt;p&gt;&lt;strong&gt;现象：&lt;/strong&gt;&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;tls: failed to verify certificate
或
certificate not trusted
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;strong&gt;原因：&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;证书过期&lt;/li&gt;&lt;li&gt;证书与域名不匹配&lt;/li&gt;&lt;li&gt;证书链不完整&lt;/li&gt;&lt;/ul&gt;
&lt;p&gt;&lt;strong&gt;解决方案：&lt;/strong&gt;&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;检查证书有效期&lt;/li&gt;&lt;/ol&gt;
&lt;pre&gt;&lt;code class=&quot;language-bash&quot;&gt;openssl x509 -in cert.pem -noout -dates
&lt;/code&gt;&lt;/pre&gt;
&lt;ol&gt;
&lt;li&gt;重新申请证书&lt;/li&gt;&lt;/ol&gt;
&lt;pre&gt;&lt;code class=&quot;language-bash&quot;&gt;~/.acme.sh/acme.sh --renew -d 你的域名 --force
&lt;/code&gt;&lt;/pre&gt;
&lt;ol&gt;
&lt;li&gt;客户端跳过证书验证（仅测试用）&lt;/li&gt;&lt;/ol&gt;
&lt;pre&gt;&lt;code class=&quot;language-json&quot;&gt;{
  &quot;tlsSettings&quot;: {
    &quot;allowInsecure&quot;: true
  }
}
&lt;/code&gt;&lt;/pre&gt;
&lt;hr&gt;
&lt;h3 id=&quot;h3-u95EEu9898209uFF1Ageoip.dat20u8DEFu7531u89C4u5219u4E0Du751Fu6548-1441&quot;&gt;&lt;a class=&quot;reference-link&quot; name=&quot;问题 9：geoip.dat 路由规则不生效&quot;&gt;&lt;/a&gt;&lt;span class=&quot;header-link octicon octicon-link&quot;&gt;&lt;/span&gt;问题 9：geoip.dat 路由规则不生效&lt;/h3&gt;&lt;p&gt;&lt;strong&gt;现象：&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;国内 IP 未走直连&lt;/li&gt;&lt;li&gt;国外 IP 未走代理&lt;/li&gt;&lt;/ul&gt;
&lt;p&gt;&lt;strong&gt;原因：&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;geoip.dat 文件损坏或版本过旧&lt;/li&gt;&lt;li&gt;路由规则配置错误&lt;/li&gt;&lt;/ul&gt;
&lt;p&gt;&lt;strong&gt;解决方案：&lt;/strong&gt;&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;更新 geoip.dat&lt;/li&gt;&lt;/ol&gt;
&lt;pre&gt;&lt;code class=&quot;language-bash&quot;&gt;wget https://github.com/v2fly/geoip/raw/master/geoip.dat -O /etc/v2ray/geoip.dat
systemctl restart v2ray
&lt;/code&gt;&lt;/pre&gt;
&lt;ol&gt;
&lt;li&gt;使用域名规则替代&lt;/li&gt;&lt;/ol&gt;
&lt;pre&gt;&lt;code class=&quot;language-json&quot;&gt;&quot;routing&quot;: {
  &quot;domainStrategy&quot;: &quot;IPIfNonMatch&quot;,
  &quot;rules&quot;: [
    {
      &quot;type&quot;: &quot;field&quot;,
      &quot;outboundTag&quot;: &quot;direct&quot;,
      &quot;domain&quot;: [&quot;geosite:cn&quot;]
    },
    {
      &quot;type&quot;: &quot;field&quot;,
      &quot;outboundTag&quot;: &quot;direct&quot;,
      &quot;ip&quot;: [&quot;geoip:private&quot;, &quot;geoip:cn&quot;]
    }
  ]
}
&lt;/code&gt;&lt;/pre&gt;
&lt;hr&gt;
&lt;h3 id=&quot;h3-u95EEu98982010uFF1AShadowsocks20u5BC6u7801u9519u8BEF-1480&quot;&gt;&lt;a class=&quot;reference-link&quot; name=&quot;问题 10：Shadowsocks 密码错误&quot;&gt;&lt;/a&gt;&lt;span class=&quot;header-link octicon octicon-link&quot;&gt;&lt;/span&gt;问题 10：Shadowsocks 密码错误&lt;/h3&gt;&lt;p&gt;&lt;strong&gt;现象：&lt;/strong&gt;&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;failed to handshake: cipher method chacha20-ietf-poly1305 not supported
或
authentication error
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;strong&gt;原因：&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;客户端与服务端密码不一致&lt;/li&gt;&lt;li&gt;加密方式不支持&lt;/li&gt;&lt;/ul&gt;
&lt;p&gt;&lt;strong&gt;解决方案：&lt;/strong&gt;&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;确保密码完全一致&lt;/li&gt;&lt;li&gt;确认加密方式两端匹配&lt;/li&gt;&lt;/ol&gt;
&lt;p&gt;服务端配置：&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-json&quot;&gt;{
  &quot;server&quot;: &quot;0.0.0.0&quot;,
  &quot;password&quot;: &quot;你的密码&quot;,
  &quot;method&quot;: &quot;chacha20-ietf-poly1305&quot;
}
&lt;/code&gt;&lt;/pre&gt;
&lt;hr&gt;
&lt;h3 id=&quot;h3-u95EEu98982011uFF1Au670Du52A1u5668u5E26u5BBDu4E0Du8DB3-1509&quot;&gt;&lt;a class=&quot;reference-link&quot; name=&quot;问题 11：服务器带宽不足&quot;&gt;&lt;/a&gt;&lt;span class=&quot;header-link octicon octicon-link&quot;&gt;&lt;/span&gt;问题 11：服务器带宽不足&lt;/h3&gt;&lt;p&gt;&lt;strong&gt;现象：&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;速度慢、卡顿&lt;/li&gt;&lt;li&gt;延迟高&lt;/li&gt;&lt;/ul&gt;
&lt;p&gt;&lt;strong&gt;原因：&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;服务器带宽限制&lt;/li&gt;&lt;li&gt;网络拥堵&lt;/li&gt;&lt;li&gt;线路不稳定&lt;/li&gt;&lt;/ul&gt;
&lt;p&gt;&lt;strong&gt;解决方案：&lt;/strong&gt;&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;选择优质线路（CN2、CN2 GIA）&lt;/li&gt;&lt;li&gt;开启 BBR 加速&lt;/li&gt;&lt;/ol&gt;
&lt;pre&gt;&lt;code class=&quot;language-bash&quot;&gt;echo &quot;net.core.default_qdisc=fq&quot; &amp;gt;&amp;gt; /etc/sysctl.conf
echo &quot;net.ipv4.tcp_congestion_control=bbr&quot; &amp;gt;&amp;gt; /etc/sysctl.conf
sysctl -p
&lt;/code&gt;&lt;/pre&gt;
&lt;ol&gt;
&lt;li&gt;使用 Cloudflare CDN 加速&lt;/li&gt;&lt;/ol&gt;
&lt;hr&gt;
&lt;h3 id=&quot;h3-u95EEu98982012uFF1Au5BA2u6237u7AEFu5BFCu5165u8282u70B9u683Cu5F0Fu4E0Du88ABu8BC6u522B-1534&quot;&gt;&lt;a class=&quot;reference-link&quot; name=&quot;问题 12：客户端导入节点格式不被识别&quot;&gt;&lt;/a&gt;&lt;span class=&quot;header-link octicon octicon-link&quot;&gt;&lt;/span&gt;问题 12：客户端导入节点格式不被识别&lt;/h3&gt;&lt;p&gt;&lt;strong&gt;现象：&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;导入 vmess:// 链接无效&lt;/li&gt;&lt;li&gt;导入后节点信息不完整&lt;/li&gt;&lt;/ul&gt;
&lt;p&gt;&lt;strong&gt;原因：&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;链接格式不正确&lt;/li&gt;&lt;li&gt;Base64 编码错误&lt;/li&gt;&lt;/ul&gt;
&lt;p&gt;&lt;strong&gt;解决方案：&lt;/strong&gt;&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;使用正确的链接格式&lt;/li&gt;&lt;li&gt;检查 Base64 编码是否正确&lt;/li&gt;&lt;li&gt;手动填写节点信息&lt;/li&gt;&lt;/ol&gt;
&lt;p&gt;Base64 解码验证：&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-bash&quot;&gt;# Linux/macOS
echo &quot;base64字符串&quot; | base64 -d

# 在线工具
# https://www.base64decode.org/
&lt;/code&gt;&lt;/pre&gt;
&lt;hr&gt;
&lt;h3 id=&quot;h3-u95EEu98982013uFF1AVLESS20u534Fu8BAE20UUID20u683Cu5F0Fu9519u8BEF-1561&quot;&gt;&lt;a class=&quot;reference-link&quot; name=&quot;问题 13：VLESS 协议 UUID 格式错误&quot;&gt;&lt;/a&gt;&lt;span class=&quot;header-link octicon octicon-link&quot;&gt;&lt;/span&gt;问题 13：VLESS 协议 UUID 格式错误&lt;/h3&gt;&lt;p&gt;&lt;strong&gt;现象：&lt;/strong&gt;&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;Invalid user
或
UUID format error
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;strong&gt;原因：&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;UUID 格式不符合标准&lt;/li&gt;&lt;li&gt;客户端与服务端 UUID 不一致&lt;/li&gt;&lt;/ul&gt;
&lt;p&gt;&lt;strong&gt;解决方案：&lt;/strong&gt;&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;生成标准 UUID&lt;/li&gt;&lt;/ol&gt;
&lt;pre&gt;&lt;code class=&quot;language-bash&quot;&gt;# Linux
uuidgen

# 在线生成
# https://www.uuidgenerator.net/

# 标准格式：xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
# 例如：40552b9c-80f4-419f-b112-a6bba2b99338
&lt;/code&gt;&lt;/pre&gt;
&lt;ol&gt;
&lt;li&gt;确保客户端与服务端 UUID 完全一致&lt;/li&gt;&lt;/ol&gt;
&lt;hr&gt;
&lt;h3 id=&quot;h3-u95EEu98982014uFF1Au65B0u589E20VLESS+WS+TLS20u8282u70B9u65E0u6CD5u8FDEu63A5uFF08UUID20u4E0Du751Fu6548uFF09-1592&quot;&gt;&lt;a class=&quot;reference-link&quot; name=&quot;问题 14：新增 VLESS+WS+TLS 节点无法连接（UUID 不生效）&quot;&gt;&lt;/a&gt;&lt;span class=&quot;header-link octicon octicon-link&quot;&gt;&lt;/span&gt;问题 14：新增 VLESS+WS+TLS 节点无法连接（UUID 不生效）&lt;/h3&gt;&lt;p&gt;&lt;strong&gt;现象：&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;服务器已配置双节点（TCP 和 WS+TLS），原有 WS+TLS 节点（UUID A）正常工作&lt;/li&gt;&lt;li&gt;新增一个 WS+TLS 节点（UUID B），客户端配置正确但无法连接，延迟测试显示 &lt;code&gt;-1&lt;/code&gt;&lt;/li&gt;&lt;li&gt;将客户端 UUID 改为 UUID A 后可以正常连接&lt;/li&gt;&lt;li&gt;服务器配置文件中已添加 UUID B，&lt;code&gt;systemctl status v2ray&lt;/code&gt; 显示服务运行正常&lt;/li&gt;&lt;/ul&gt;
&lt;p&gt;&lt;strong&gt;排查流程：&lt;/strong&gt;&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;确认客户端配置正确&lt;/strong&gt;：复制正常工作的节点，仅修改 UUID，仍无法连接 → 排除客户端传输配置问题&lt;/p&gt;
&lt;/li&gt;&lt;li&gt;&lt;p&gt;&lt;strong&gt;交换 UUID 测试&lt;/strong&gt;：&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;将正常节点的 UUID 改为 UUID B → 无法连接&lt;/li&gt;&lt;li&gt;将异常节点的 UUID 改为 UUID A → 可以连接&lt;/li&gt;&lt;li&gt;结论：UUID B 在服务端未生效&lt;/li&gt;&lt;/ul&gt;
&lt;/li&gt;&lt;li&gt;&lt;p&gt;&lt;strong&gt;检查服务端配置文件&lt;/strong&gt;：&lt;code&gt;cat /etc/v2ray/config.json&lt;/code&gt; 显示 UUID B 已正确添加&lt;/p&gt;
&lt;/li&gt;&lt;li&gt;&lt;p&gt;&lt;strong&gt;检查服务实际使用的配置文件路径&lt;/strong&gt;：&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-bash&quot;&gt;systemctl status v2ray
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;输出显示：&lt;code&gt;/usr/local/bin/v2ray run -config /usr/local/etc/v2ray/config.json&lt;/code&gt;&lt;br&gt;→ 发现服务实际读取的是 &lt;code&gt;/usr/local/etc/v2ray/config.json&lt;/code&gt;，而非 &lt;code&gt;/etc/v2ray/config.json&lt;/code&gt;&lt;/p&gt;
&lt;/li&gt;&lt;li&gt;&lt;p&gt;&lt;strong&gt;检查实际配置文件内容&lt;/strong&gt;：&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-bash&quot;&gt;cat /usr/local/etc/v2ray/config.json | grep -E &#039;&quot;id&quot;:&#039;
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;发现该文件中只有 UUID A，没有 UUID B&lt;/p&gt;
&lt;/li&gt;&lt;li&gt;&lt;p&gt;&lt;strong&gt;修改正确的配置文件&lt;/strong&gt;，添加 UUID B，重启服务后问题解决&lt;/p&gt;
&lt;/li&gt;&lt;/ol&gt;
&lt;p&gt;&lt;strong&gt;排查命令汇总：&lt;/strong&gt;&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-bash&quot;&gt;# 查看服务实际使用的配置文件路径
systemctl status v2ray

# 检查实际配置文件中的 UUID 列表
cat /usr/local/etc/v2ray/config.json | grep -E &#039;&quot;id&quot;:&#039;

# 检查服务监听的端口
ss -tlnp | grep v2ray

# 查看服务日志（无错误不代表配置被加载）
journalctl -u v2ray -n 50 --no-pager
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;strong&gt;原因：&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;系统中存在多个 V2Ray 配置文件（&lt;code&gt;/etc/v2ray/config.json&lt;/code&gt; 和 &lt;code&gt;/usr/local/etc/v2ray/config.json&lt;/code&gt;）&lt;/li&gt;&lt;li&gt;systemd 服务单元中指定的配置文件路径是 &lt;code&gt;/usr/local/etc/v2ray/config.json&lt;/code&gt;&lt;/li&gt;&lt;li&gt;用户修改了错误的配置文件（&lt;code&gt;/etc/v2ray/config.json&lt;/code&gt;），导致修改未生效&lt;/li&gt;&lt;/ul&gt;
&lt;p&gt;&lt;strong&gt;解决办法：&lt;/strong&gt;&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;确认服务实际使用的配置文件路径&lt;/strong&gt;：&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-bash&quot;&gt;systemctl status v2ray | grep &quot;config&quot;
&lt;/code&gt;&lt;/pre&gt;
&lt;/li&gt;&lt;li&gt;&lt;p&gt;&lt;strong&gt;编辑正确的配置文件&lt;/strong&gt;（例如 &lt;code&gt;/usr/local/etc/v2ray/config.json&lt;/code&gt;）：&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-bash&quot;&gt;sudo nano /usr/local/etc/v2ray/config.json
&lt;/code&gt;&lt;/pre&gt;
&lt;/li&gt;&lt;li&gt;&lt;p&gt;&lt;strong&gt;添加新 UUID 到 &lt;code&gt;clients&lt;/code&gt; 数组&lt;/strong&gt;：&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-json&quot;&gt;&quot;clients&quot;: [
  {&quot;id&quot;: &quot;原有UUID&quot;, &quot;email&quot;: &quot;1&quot;},
  {&quot;id&quot;: &quot;新UUID&quot;, &quot;email&quot;: &quot;2&quot;}
],
&lt;/code&gt;&lt;/pre&gt;
&lt;/li&gt;&lt;li&gt;&lt;p&gt;&lt;strong&gt;检查 JSON 格式&lt;/strong&gt;：&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-bash&quot;&gt;cat /usr/local/etc/v2ray/config.json | python3 -m json.tool &amp;gt; /dev/null &amp;amp;&amp;amp; echo &quot;OK&quot;
&lt;/code&gt;&lt;/pre&gt;
&lt;/li&gt;&lt;li&gt;&lt;p&gt;&lt;strong&gt;重启 V2Ray 服务&lt;/strong&gt;：&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-bash&quot;&gt;sudo systemctl restart v2ray
sudo systemctl status v2ray   # 确认 active (running)
&lt;/code&gt;&lt;/pre&gt;
&lt;/li&gt;&lt;li&gt;&lt;p&gt;&lt;strong&gt;客户端使用新 UUID 测试连接&lt;/strong&gt;&lt;/p&gt;
&lt;/li&gt;&lt;/ol&gt;
&lt;p&gt;&lt;strong&gt;预防措施：&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;安装 V2Ray 时注意官方脚本默认配置文件路径为 &lt;code&gt;/usr/local/etc/v2ray/config.json&lt;/code&gt;&lt;/li&gt;&lt;li&gt;手动安装时若自定义 systemd 服务文件，需明确 &lt;code&gt;-config&lt;/code&gt; 参数指定的路径&lt;/li&gt;&lt;li&gt;修改配置前先用 &lt;code&gt;systemctl status v2ray&lt;/code&gt; 确认实际使用的配置文件位置&lt;/li&gt;&lt;li&gt;建议将所有配置统一存放在一个路径，避免混淆&lt;/li&gt;&lt;/ul&gt;
&lt;p&gt;&lt;strong&gt;相关命令速查：&lt;/strong&gt;&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-bash&quot;&gt;# 查找所有可能的配置文件
find /etc /usr/local/etc -name &quot;config.json&quot; 2&amp;gt;/dev/null

# 对比文件差异
diff /etc/v2ray/config.json /usr/local/etc/v2ray/config.json
&lt;/code&gt;&lt;/pre&gt;
&lt;hr&gt;
&lt;h3 id=&quot;h3-u95EEu98982015uFF1A3X-UI20u9762u677Fu65E0u6CD5u8BBFu95EE-1711&quot;&gt;&lt;a class=&quot;reference-link&quot; name=&quot;问题 15：3X-UI 面板无法访问&quot;&gt;&lt;/a&gt;&lt;span class=&quot;header-link octicon octicon-link&quot;&gt;&lt;/span&gt;问题 15：3X-UI 面板无法访问&lt;/h3&gt;&lt;p&gt;&lt;strong&gt;现象：&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;浏览器无法打开面板地址&lt;/li&gt;&lt;li&gt;连接超时&lt;/li&gt;&lt;/ul&gt;
&lt;p&gt;&lt;strong&gt;排查方向：&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;防火墙/安全组未放行端口&lt;/li&gt;&lt;/ul&gt;
&lt;p&gt;&lt;strong&gt;解决方案：&lt;/strong&gt;&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-bash&quot;&gt;# 检查防火墙状态
ufw status

# 放行面板端口（如 54321）
ufw allow 54321/tcp

# 如果是云服务器，还需在安全组开放端口
&lt;/code&gt;&lt;/pre&gt;
&lt;hr&gt;
&lt;h3 id=&quot;h3-u95EEu98982016uFF1AXray20u548Cu624Bu52A820V2Ray20u7AEFu53E3u51B2u7A81-1733&quot;&gt;&lt;a class=&quot;reference-link&quot; name=&quot;问题 16：Xray 和手动 V2Ray 端口冲突&quot;&gt;&lt;/a&gt;&lt;span class=&quot;header-link octicon octicon-link&quot;&gt;&lt;/span&gt;问题 16：Xray 和手动 V2Ray 端口冲突&lt;/h3&gt;&lt;p&gt;&lt;strong&gt;现象：&lt;/strong&gt;&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;Failed to start: app/proxyman/inbound: failed to listen TCP on 443
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;strong&gt;原因：&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;3X-UI 自带 Xray 1.4.2，和手动安装的 V2Ray 同时占用 443 端口&lt;/li&gt;&lt;/ul&gt;
&lt;p&gt;&lt;strong&gt;解决方案：&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;方案一：停止手动的 V2Ray（推荐）&lt;/strong&gt;&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-bash&quot;&gt;systemctl stop v2ray
systemctl disable v2ray
systemctl restart x-ui
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;strong&gt;方案二：给 Xray 分配不同端口&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;在 3X-UI 中将 WS+TLS 节点改为其他端口（如 8443）&lt;/li&gt;&lt;/ul&gt;
&lt;hr&gt;
&lt;h2 id=&quot;h2-u9644u5F55u4E00u3001u914Du7F6Eu5B9Eu4F8BuFF08u65E0u57DFu540Du65B9u6848uFF09-1757&quot;&gt;&lt;a class=&quot;reference-link&quot; name=&quot;附录一、配置实例（无域名方案）&quot;&gt;&lt;/a&gt;&lt;span class=&quot;header-link octicon octicon-link&quot;&gt;&lt;/span&gt;附录一、配置实例（无域名方案）&lt;/h2&gt;&lt;h3 id=&quot;h3-1.20u73AFu5883u4FE1u606F-1759&quot;&gt;&lt;a class=&quot;reference-link&quot; name=&quot;1. 环境信息&quot;&gt;&lt;/a&gt;&lt;span class=&quot;header-link octicon octicon-link&quot;&gt;&lt;/span&gt;1. 环境信息&lt;/h3&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;项目&lt;/th&gt;
&lt;th&gt;值&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;服务器&lt;/td&gt;
&lt;td&gt;阿里云轻量应用服务器&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;系统&lt;/td&gt;
&lt;td&gt;Ubuntu 22.04&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;公网 IP&lt;/td&gt;
&lt;td&gt;（填入你的服务器IP）&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;V2Ray 版本&lt;/td&gt;
&lt;td&gt;5.48.0&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;h3 id=&quot;h3-2.20u4E24u4E2Au8282u70B9u4FE1u606F-1768&quot;&gt;&lt;a class=&quot;reference-link&quot; name=&quot;2. 两个节点信息&quot;&gt;&lt;/a&gt;&lt;span class=&quot;header-link octicon octicon-link&quot;&gt;&lt;/span&gt;2. 两个节点信息&lt;/h3&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;节点名称&lt;/th&gt;
&lt;th&gt;端口&lt;/th&gt;
&lt;th&gt;协议&lt;/th&gt;
&lt;th&gt;UUID&lt;/th&gt;
&lt;th&gt;传输方式&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;TCP 节点&lt;/td&gt;
&lt;td&gt;10086&lt;/td&gt;
&lt;td&gt;VLESS&lt;/td&gt;
&lt;td&gt;&lt;code&gt;cat /proc/sys/kernel/random/uuid&lt;/code&gt; 命令生成&lt;/td&gt;
&lt;td&gt;TCP&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;WS+TLS 节点&lt;/td&gt;
&lt;td&gt;443&lt;/td&gt;
&lt;td&gt;VLESS&lt;/td&gt;
&lt;td&gt;&lt;code&gt;cat /proc/sys/kernel/random/uuid&lt;/code&gt; 命令生成&lt;/td&gt;
&lt;td&gt;WebSocket + TLS&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;h3 id=&quot;h3-3.20u5BA2u6237u7AEFu5BFCu5165u94FEu63A5-1775&quot;&gt;&lt;a class=&quot;reference-link&quot; name=&quot;3. 客户端导入链接&quot;&gt;&lt;/a&gt;&lt;span class=&quot;header-link octicon octicon-link&quot;&gt;&lt;/span&gt;3. 客户端导入链接&lt;/h3&gt;&lt;p&gt;&lt;strong&gt;TCP 节点：&lt;/strong&gt;&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;vless://你的UUID@服务器IP:10086?encryption=none&amp;amp;type=tcp#VLESS-TCP
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;strong&gt;WS+TLS 节点：&lt;/strong&gt;&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;vless://你的UUID@服务器IP:443?encryption=none&amp;amp;type=ws&amp;amp;path=/v2ray&amp;amp;security=tls&amp;amp;allowInsecure=true#VLESS-WS-TLS
&lt;/code&gt;&lt;/pre&gt;
&lt;h3 id=&quot;h3-4.20u751Fu6210u81EAu7B7Eu540Du8BC1u4E66-1787&quot;&gt;&lt;a class=&quot;reference-link&quot; name=&quot;4. 生成自签名证书&quot;&gt;&lt;/a&gt;&lt;span class=&quot;header-link octicon octicon-link&quot;&gt;&lt;/span&gt;4. 生成自签名证书&lt;/h3&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot;&gt;mkdir -p /etc/ssl/private /etc/ssl/certs

openssl req -x509 -nodes -newkey rsa:2048 \
  -keyout /etc/ssl/private/key.pem \
  -out /etc/ssl/certs/cert.pem \
  -subj &quot;/CN=example.com&quot; \
  -days 3650

# 修复目录权限（否则 systemd 无法读取）
chmod 755 /etc/ssl/private/
&lt;/code&gt;&lt;/pre&gt;
&lt;hr&gt;
&lt;h2 id=&quot;h2-u53C2u8003u94FEu63A5-1804&quot;&gt;&lt;a class=&quot;reference-link&quot; name=&quot;参考链接&quot;&gt;&lt;/a&gt;&lt;span class=&quot;header-link octicon octicon-link&quot;&gt;&lt;/span&gt;参考链接&lt;/h2&gt;&lt;ul&gt;
&lt;li&gt;&lt;a href=&quot;https://www.v2fly.org/&quot;&gt;V2Ray 官方文档&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;https://github.com/v2fly/v2ray-core&quot;&gt;V2Ray GitHub&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;https://github.com/mhsanaei/3x-ui&quot;&gt;3X-UI GitHub&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;https://github.com/Gozargah/Marzban-scripts&quot;&gt;Marzban GitHub&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;https://shadowsocks.org/&quot;&gt;Shadowsocks&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;https://www.cloudflare.com/&quot;&gt;Cloudflare&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;https://letsencrypt.org/&quot;&gt;Let’s Encrypt&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;https://github.com/acmesh-official/acme.sh&quot;&gt;acme.sh&lt;/a&gt;&lt;/li&gt;&lt;/ul&gt;
&lt;/body&gt;&lt;/p&gt;</description><pubDate>Thu, 16 Apr 2026 17:23:14 +0800</pubDate></item><item><title>Ollama 安装指南</title><link>https://blog.smallhao.fun/?id=49</link><description>&lt;head&gt;&lt;/head&gt;&lt;body&gt;&lt;p&gt;在 Windows 系统上，Ollama 的安装位置可以通过命令行参数自定义，避免默认安装到 C 盘。以下是具体操作方法：&lt;/p&gt;
&lt;h2 id=&quot;h2-1u3001u81EAu5B9Au4E4920Ollama20u5B89u88C5u8DEFu5F84-3&quot;&gt;&lt;a class=&quot;reference-link&quot; name=&quot;1、自定义 Ollama 安装路径&quot;&gt;&lt;/a&gt;&lt;span class=&quot;header-link octicon octicon-link&quot;&gt;&lt;/span&gt;1、自定义 Ollama 安装路径&lt;/h2&gt;&lt;ol&gt;
&lt;li&gt;下载安装包：从 Ollama 官网下载 &lt;code&gt;OllamaSetup.exe&lt;/code&gt; 安装包。&lt;/li&gt;&lt;li&gt;准备目标目录：创建一个你希望安装 Ollama 的目录，例如&lt;span style=&quot;background: #ecaa04&quot;&gt; &lt;code&gt;D:\Ollama&lt;/code&gt;&lt;/span&gt;。&lt;/li&gt;&lt;li&gt;以管理员身份打开命令行：打开 PowerShell 或命令提示符（CMD），并切换到&lt;span style=&quot;background: #ecaa04&quot;&gt;安装包所在目录&lt;/span&gt;。&lt;/li&gt;&lt;li&gt;执行安装命令：使用 &lt;span style=&quot;background: #ecaa04&quot;&gt;&lt;code&gt;/DIR&lt;/code&gt; &lt;/span&gt;参数指定目标路径。例如，要将 Ollama 安装到 &lt;code&gt;D:\Ollama&lt;/code&gt;，请运行以下命令：&lt;pre&gt;&lt;code class=&quot;language-powershell&quot;&gt;    OllamaSetup.exe /DIR=D:\Ollama
&lt;/code&gt;&lt;/pre&gt;
&lt;/li&gt;&lt;/ol&gt;
&lt;h2 id=&quot;h2-2u3001u81EAu5B9Au4E49u6A21u578Bu5B58u50A8u8DEFu5F84-13&quot;&gt;&lt;a class=&quot;reference-link&quot; name=&quot;2、自定义模型存储路径&quot;&gt;&lt;/a&gt;&lt;span class=&quot;header-link octicon octicon-link&quot;&gt;&lt;/span&gt;2、自定义模型存储路径&lt;/h2&gt;&lt;p&gt;Ollama 拉取的模型文件默认存储在用户目录下（如 &lt;code&gt;C:\Users\&amp;lt;用户名&amp;gt;\.ollama\models&lt;/code&gt;），为节省 C 盘空间，建议同时修改模型存储路径：&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;创建模型存储目录：在目标磁盘上创建一个目录，例如 &lt;code&gt;D:\AI\Models\Ollama&lt;/code&gt;。&lt;/li&gt;&lt;li&gt;设置环境变量：&lt;ul&gt;
&lt;li&gt;按下 &lt;code&gt;Win + R&lt;/code&gt;，输入 &lt;code&gt;sysdm.cpl&lt;/code&gt;，打开“系统属性”。&lt;/li&gt;&lt;li&gt;点击“高级”选项卡下的“环境变量”。&lt;/li&gt;&lt;li&gt;在“系统变量”区域，点击“新建”。&lt;/li&gt;&lt;li&gt;变量名输入：&lt;code&gt;OLLAMA_MODELS&lt;/code&gt;&lt;/li&gt;&lt;li&gt;变量值输入：你创建的模型存储路径，例如 &lt;code&gt;D:\AI\Models\Ollama&lt;/code&gt;。&lt;/li&gt;&lt;li&gt;点击“确定”保存。&lt;br&gt;&lt;img style=&quot;max-width:100%;&quot; title=&quot;定义操作&quot; alt=&quot;定义操作&quot; src=&quot;https://blog.smallhao.fun/zb_users/upload/2026/01/202601271946456399781.png&quot;&gt;&lt;/li&gt;&lt;/ul&gt;
&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;background: #ecaa04&quot;&gt;重启终端：&lt;/span&gt;关闭并重新打开命令行窗口，使环境变量生效。&lt;/li&gt;&lt;/ol&gt;
&lt;/body&gt;</description><pubDate>Tue, 27 Jan 2026 19:17:35 +0800</pubDate></item><item><title>本地部署 AI 大模型</title><link>https://blog.smallhao.fun/?id=48</link><description>&lt;head&gt;&lt;/head&gt;&lt;body&gt;&lt;h1 id=&quot;h1-DeepSeek20u5927u6A21u578Bu672Cu5730u90E8u7F72u6307u5357uFF08Ollama+ChatboxuFF09-1&quot;&gt;&lt;a class=&quot;reference-link&quot; name=&quot;DeepSeek 大模型本地部署指南（Ollama+Chatbox）&quot;&gt;&lt;/a&gt;&lt;span class=&quot;header-link octicon octicon-link&quot;&gt;&lt;/span&gt;DeepSeek 大模型本地部署指南（Ollama+Chatbox）&lt;/h1&gt;&lt;h2 id=&quot;h2-u4E00u3001u5B89u88C520Ollama-3&quot;&gt;&lt;a class=&quot;reference-link&quot; name=&quot;一、安装 Ollama&quot;&gt;&lt;/a&gt;&lt;span class=&quot;header-link octicon octicon-link&quot;&gt;&lt;/span&gt;一、安装 Ollama&lt;/h2&gt;&lt;h3 id=&quot;h3-Windows20u7CFBu7EDF-5&quot;&gt;&lt;a class=&quot;reference-link&quot; name=&quot;Windows 系统&quot;&gt;&lt;/a&gt;&lt;span class=&quot;header-link octicon octicon-link&quot;&gt;&lt;/span&gt;Windows 系统&lt;/h3&gt;&lt;ol&gt;
&lt;li&gt;&lt;p&gt;访问 &lt;a href=&quot;https://ollama.com/&quot;&gt;Ollama 官网&lt;/a&gt; 下载安装包（约 100MB）&lt;/p&gt;
&lt;/li&gt;&lt;li&gt;&lt;p&gt;双击安装，默认路径为 &lt;code&gt;C:\Program Files\Ollama&lt;/code&gt;，自动添加环境变量&lt;/p&gt;
&lt;/li&gt;&lt;li&gt;&lt;p&gt;验证安装：&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-Bash&quot;&gt;
ollama --version  # 输出版本号即成功
&lt;/code&gt;&lt;/pre&gt;
&lt;/li&gt;&lt;/ol&gt;
&lt;h3 id=&quot;h3-Linux20u7CFBu7EDF-18&quot;&gt;&lt;a class=&quot;reference-link&quot; name=&quot;Linux 系统&quot;&gt;&lt;/a&gt;&lt;span class=&quot;header-link octicon octicon-link&quot;&gt;&lt;/span&gt;Linux 系统&lt;/h3&gt;&lt;pre&gt;&lt;code class=&quot;language-Bash&quot;&gt;
curl -fsSL https://ollama.com/install.sh | sh  # 自动安装并启动服务
systemctl status ollama  # 检查服务状态
&lt;/code&gt;&lt;/pre&gt;
&lt;h2 id=&quot;h2-u4E8Cu3001u4E0Bu8F7D20DeepSeek20u6A21u578B-26&quot;&gt;&lt;a class=&quot;reference-link&quot; name=&quot;二、下载 DeepSeek 模型&quot;&gt;&lt;/a&gt;&lt;span class=&quot;header-link octicon octicon-link&quot;&gt;&lt;/span&gt;二、下载 DeepSeek 模型&lt;/h2&gt;&lt;h3 id=&quot;h3-7B20u6A21u578BuFF08u6D41u7545u8FD0u884CuFF0Cu63A8u8350uFF09-28&quot;&gt;&lt;a class=&quot;reference-link&quot; name=&quot;7B 模型（流畅运行，推荐）&quot;&gt;&lt;/a&gt;&lt;span class=&quot;header-link octicon octicon-link&quot;&gt;&lt;/span&gt;7B 模型（流畅运行，推荐）&lt;/h3&gt;&lt;pre&gt;&lt;code class=&quot;language-Bash&quot;&gt;
ollama pull deepseek-r1:7b
&lt;/code&gt;&lt;/pre&gt;
&lt;h3 id=&quot;h3-33B20u6A21u578BuFF08u9700u91CFu5316uFF0Cu663Eu5B58u5360u7528u7EA62018GBuFF09-35&quot;&gt;&lt;a class=&quot;reference-link&quot; name=&quot;33B 模型（需量化，显存占用约 18GB）&quot;&gt;&lt;/a&gt;&lt;span class=&quot;header-link octicon octicon-link&quot;&gt;&lt;/span&gt;33B 模型（需量化，显存占用约 18GB）&lt;/h3&gt;&lt;pre&gt;&lt;code class=&quot;language-Bash&quot;&gt;
ollama pull deepseek-coder:33b --quantize q4_0  # INT4 量化
# 拉取 q4 量化版本（推荐）
ollama pull deepseek-coder:33b-instruct-q4_K_M
&lt;/code&gt;&lt;/pre&gt;
&lt;h3 id=&quot;h3-1.5B20u6A21u578BuFF08u4F4Eu914Du8BBEu5907u9002u7528uFF09-44&quot;&gt;&lt;a class=&quot;reference-link&quot; name=&quot;1.5B 模型（低配设备适用）&quot;&gt;&lt;/a&gt;&lt;span class=&quot;header-link octicon octicon-link&quot;&gt;&lt;/span&gt;1.5B 模型（低配设备适用）&lt;/h3&gt;&lt;pre&gt;&lt;code class=&quot;language-Bash&quot;&gt;
ollama pull deepseek-r1:1.5b
&lt;/code&gt;&lt;/pre&gt;
&lt;h3 id=&quot;h3-u9A8Cu8BC1u4E0Bu8F7D-51&quot;&gt;&lt;a class=&quot;reference-link&quot; name=&quot;验证下载&quot;&gt;&lt;/a&gt;&lt;span class=&quot;header-link octicon octicon-link&quot;&gt;&lt;/span&gt;验证下载&lt;/h3&gt;&lt;pre&gt;&lt;code class=&quot;language-Bash&quot;&gt;
ollama list  # 显示已下载模型
&lt;/code&gt;&lt;/pre&gt;
&lt;h2 id=&quot;h2-u4E09u3001u542Fu52A8u6A21u578Bu5E76u6D4Bu8BD5-58&quot;&gt;&lt;a class=&quot;reference-link&quot; name=&quot;三、启动模型并测试&quot;&gt;&lt;/a&gt;&lt;span class=&quot;header-link octicon octicon-link&quot;&gt;&lt;/span&gt;三、启动模型并测试&lt;/h2&gt;&lt;h3 id=&quot;h3-u547Du4EE4u884Cu4EA4u4E92-60&quot;&gt;&lt;a class=&quot;reference-link&quot; name=&quot;命令行交互&quot;&gt;&lt;/a&gt;&lt;span class=&quot;header-link octicon octicon-link&quot;&gt;&lt;/span&gt;命令行交互&lt;/h3&gt;&lt;pre&gt;&lt;code class=&quot;language-Bash&quot;&gt;
ollama run deepseek-r1:7b  # 输入问题测试（如&quot;写一首诗&quot;）
&lt;/code&gt;&lt;/pre&gt;
&lt;h3 id=&quot;h3-API20u8C03u7528uFF08u96C6u6210u5230u9879u76EEuFF09-67&quot;&gt;&lt;a class=&quot;reference-link&quot; name=&quot;API 调用（集成到项目）&quot;&gt;&lt;/a&gt;&lt;span class=&quot;header-link octicon octicon-link&quot;&gt;&lt;/span&gt;API 调用（集成到项目）&lt;/h3&gt;&lt;pre&gt;&lt;code class=&quot;language-Python&quot;&gt;
import requests
response = requests.post(
    &quot;http://localhost:11434/api/generate&quot;,
    json={&quot;model&quot;: &quot;deepseek-r1:7b&quot;, &quot;prompt&quot;: &quot;你好&quot;}
)
print(response.json())
&lt;/code&gt;&lt;/pre&gt;
&lt;h2 id=&quot;h2-u56DBu3001u542Fu52A820Chatbox20u5E76u8FDEu63A520Ollama-79&quot;&gt;&lt;a class=&quot;reference-link&quot; name=&quot;四、启动 Chatbox 并连接 Ollama&quot;&gt;&lt;/a&gt;&lt;span class=&quot;header-link octicon octicon-link&quot;&gt;&lt;/span&gt;四、启动 Chatbox 并连接 Ollama&lt;/h2&gt;&lt;h3 id=&quot;h3-u6B65u9AA41uFF1Au4E0Bu8F7D20Chatbox-81&quot;&gt;&lt;a class=&quot;reference-link&quot; name=&quot;步骤1：下载 Chatbox&quot;&gt;&lt;/a&gt;&lt;span class=&quot;header-link octicon octicon-link&quot;&gt;&lt;/span&gt;步骤1：下载 Chatbox&lt;/h3&gt;&lt;p&gt;访问 Chatbox GitHub 仓库或 &lt;a href=&quot;https://chatboxai.app/&quot;&gt;Chatbox 官网&lt;/a&gt;，下载对应系统的版本。&lt;/p&gt;
&lt;h3 id=&quot;h3-u6B65u9AA42uFF1Au914Du7F6E20Ollama20u8FDEu63A5-85&quot;&gt;&lt;a class=&quot;reference-link&quot; name=&quot;步骤2：配置 Ollama 连接&quot;&gt;&lt;/a&gt;&lt;span class=&quot;header-link octicon octicon-link&quot;&gt;&lt;/span&gt;步骤2：配置 Ollama 连接&lt;/h3&gt;&lt;ol&gt;
&lt;li&gt;&lt;p&gt;打开 Chatbox，进入设置界面；&lt;/p&gt;
&lt;/li&gt;&lt;li&gt;&lt;p&gt;在“模型提供方”中选择“Ollama”；&lt;/p&gt;
&lt;/li&gt;&lt;li&gt;&lt;p&gt;输入 Ollama 的 API 地址（默认为 &lt;code&gt;http://localhost:11434&lt;/code&gt;）。&lt;/p&gt;
&lt;/li&gt;&lt;/ol&gt;
&lt;h3 id=&quot;h3-u6B65u9AA43uFF1Au9009u62E9u6A21u578Bu5E76u5F00u59CBu5BF9u8BDD-93&quot;&gt;&lt;a class=&quot;reference-link&quot; name=&quot;步骤3：选择模型并开始对话&quot;&gt;&lt;/a&gt;&lt;span class=&quot;header-link octicon octicon-link&quot;&gt;&lt;/span&gt;步骤3：选择模型并开始对话&lt;/h3&gt;&lt;ol&gt;
&lt;li&gt;&lt;p&gt;在模型列表中选择已下载的 &lt;code&gt;deepseek-r1:7b&lt;/code&gt;；&lt;/p&gt;
&lt;/li&gt;&lt;li&gt;&lt;p&gt;在输入框中输入问题（如“解释量子计算的基本原理”），点击发送。&lt;/p&gt;
&lt;/li&gt;&lt;/ol&gt;
&lt;h2 id=&quot;h2-u4E94u3001u8FDBu9636u4F7Fu7528u6280u5DE7-99&quot;&gt;&lt;a class=&quot;reference-link&quot; name=&quot;五、进阶使用技巧&quot;&gt;&lt;/a&gt;&lt;span class=&quot;header-link octicon octicon-link&quot;&gt;&lt;/span&gt;五、进阶使用技巧&lt;/h2&gt;&lt;h3 id=&quot;h3-1.20u81EAu5B9Au4E49u6A21u578Bu53C2u6570-101&quot;&gt;&lt;a class=&quot;reference-link&quot; name=&quot;1. 自定义模型参数&quot;&gt;&lt;/a&gt;&lt;span class=&quot;header-link octicon octicon-link&quot;&gt;&lt;/span&gt;1. 自定义模型参数&lt;/h3&gt;&lt;pre&gt;&lt;code class=&quot;language-Bash&quot;&gt;
ollama run deepseek-r1:7b --temperature 0.7 --top-p 0.9
&lt;/code&gt;&lt;/pre&gt;
&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;--temperature&lt;/code&gt;：控制输出随机性（0-1，值越高越创意）；&lt;/p&gt;
&lt;/li&gt;&lt;li&gt;&lt;p&gt;&lt;code&gt;--top-p&lt;/code&gt;：限制输出词汇的累积概率（0-1，值越低越保守）。&lt;/p&gt;
&lt;/li&gt;&lt;/ul&gt;
&lt;h3 id=&quot;h3-2.20u6279u91CFu5904u7406u4EFBu52A1-112&quot;&gt;&lt;a class=&quot;reference-link&quot; name=&quot;2. 批量处理任务&quot;&gt;&lt;/a&gt;&lt;span class=&quot;header-link octicon octicon-link&quot;&gt;&lt;/span&gt;2. 批量处理任务&lt;/h3&gt;&lt;ol&gt;
&lt;li&gt;&lt;p&gt;在 Chatbox 设置中启用“批量模式”；&lt;/p&gt;
&lt;/li&gt;&lt;li&gt;&lt;p&gt;将问题以换行符分隔的文本粘贴至输入框；&lt;/p&gt;
&lt;/li&gt;&lt;li&gt;&lt;p&gt;点击发送，系统将逐条回答并显示进度。&lt;/p&gt;
&lt;/li&gt;&lt;/ol&gt;
&lt;h3 id=&quot;h3-3.20u6A21u578Bu5FAEu8C03uFF08u53EFu9009uFF09-120&quot;&gt;&lt;a class=&quot;reference-link&quot; name=&quot;3. 模型微调（可选）&quot;&gt;&lt;/a&gt;&lt;span class=&quot;header-link octicon octicon-link&quot;&gt;&lt;/span&gt;3. 模型微调（可选）&lt;/h3&gt;&lt;ol&gt;
&lt;li&gt;&lt;p&gt;准备训练数据（格式为 JSONL，每行包含 &lt;code&gt;prompt&lt;/code&gt; 和 &lt;code&gt;response&lt;/code&gt;）；&lt;/p&gt;
&lt;/li&gt;&lt;li&gt;&lt;p&gt;执行微调命令：&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-Bash&quot;&gt;
ollama fine-tune deepseek-r1:7b --data training_data.jsonl
&lt;/code&gt;&lt;/pre&gt;
&lt;/li&gt;&lt;/ol&gt;
&lt;h3 id=&quot;h3-4.20u8FDBu9636u914Du7F6E-131&quot;&gt;&lt;a class=&quot;reference-link&quot; name=&quot;4. 进阶配置&quot;&gt;&lt;/a&gt;&lt;span class=&quot;header-link octicon octicon-link&quot;&gt;&lt;/span&gt;4. 进阶配置&lt;/h3&gt;&lt;h4 id=&quot;h4-u591A20GPU20u652Fu6301-133&quot;&gt;&lt;a class=&quot;reference-link&quot; name=&quot;多 GPU 支持&quot;&gt;&lt;/a&gt;&lt;span class=&quot;header-link octicon octicon-link&quot;&gt;&lt;/span&gt;多 GPU 支持&lt;/h4&gt;&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Linux：&lt;code&gt;export CUDA_VISIBLE_DEVICES=0,1&lt;/code&gt;&lt;/p&gt;
&lt;/li&gt;&lt;li&gt;&lt;p&gt;Windows 命令提示符：&lt;code&gt;set CUDA_VISIBLE_DEVICES=0,1&lt;/code&gt;&lt;/p&gt;
&lt;/li&gt;&lt;/ul&gt;
&lt;h4 id=&quot;h4-u5176u4ED6u56FEu5F62u5316u754Cu9762-139&quot;&gt;&lt;a class=&quot;reference-link&quot; name=&quot;其他图形化界面&quot;&gt;&lt;/a&gt;&lt;span class=&quot;header-link octicon octicon-link&quot;&gt;&lt;/span&gt;其他图形化界面&lt;/h4&gt;&lt;p&gt;安装 &lt;a href=&quot;https://openwebui.com/&quot;&gt;Open WebUI&lt;/a&gt;，配置 API 地址为 &lt;code&gt;http://localhost:11434&lt;/code&gt;&lt;/p&gt;
&lt;h2 id=&quot;h2-u516Du3001u5E38u89C1u95EEu9898u4E0Eu89E3u51B3u65B9u6848-143&quot;&gt;&lt;a class=&quot;reference-link&quot; name=&quot;六、常见问题与解决方案&quot;&gt;&lt;/a&gt;&lt;span class=&quot;header-link octicon octicon-link&quot;&gt;&lt;/span&gt;六、常见问题与解决方案&lt;/h2&gt;&lt;h3 id=&quot;h3-1.20u6A21u578Bu4E0Bu8F7Du5931u8D25-145&quot;&gt;&lt;a class=&quot;reference-link&quot; name=&quot;1. 模型下载失败&quot;&gt;&lt;/a&gt;&lt;span class=&quot;header-link octicon octicon-link&quot;&gt;&lt;/span&gt;1. 模型下载失败&lt;/h3&gt;&lt;ul&gt;
&lt;li&gt;&lt;p&gt;原因：网络不稳定或 Ollama 服务器繁忙；&lt;/p&gt;
&lt;/li&gt;&lt;li&gt;&lt;p&gt;解决：&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;&lt;p&gt;使用代理工具加速下载；&lt;/p&gt;
&lt;/li&gt;&lt;li&gt;&lt;p&gt;尝试更换模型版本（如从 7b 换为 3b）；&lt;/p&gt;
&lt;/li&gt;&lt;li&gt;&lt;p&gt;手动下载模型文件（Linux 示例）：&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-Bash&quot;&gt;
wget https://huggingface.co/deepseek-ai/deepseek-r1-7b/resolve/main/ggml-model-q4_0.bin
ollama create deepseek-r1 -f Modelfile  # 自定义模型指向本地文件
&lt;/code&gt;&lt;/pre&gt;
&lt;/li&gt;&lt;/ol&gt;
&lt;/li&gt;&lt;/ul&gt;
&lt;h3 id=&quot;h3-2.20u5185u5B58u4E0Du8DB3u9519u8BEF-163&quot;&gt;&lt;a class=&quot;reference-link&quot; name=&quot;2. 内存不足错误&quot;&gt;&lt;/a&gt;&lt;span class=&quot;header-link octicon octicon-link&quot;&gt;&lt;/span&gt;2. 内存不足错误&lt;/h3&gt;&lt;ul&gt;
&lt;li&gt;&lt;p&gt;现象：终端显示 &lt;code&gt;out of memory&lt;/code&gt;；&lt;/p&gt;
&lt;/li&gt;&lt;li&gt;&lt;p&gt;解决：&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;&lt;p&gt;关闭其他占用内存的程序；&lt;/p&gt;
&lt;/li&gt;&lt;li&gt;&lt;p&gt;降低模型参数（如换用 3b 版本）；&lt;/p&gt;
&lt;/li&gt;&lt;li&gt;&lt;p&gt;在 Linux/macOS 下启用交换空间（swap）。&lt;/p&gt;
&lt;/li&gt;&lt;/ol&gt;
&lt;/li&gt;&lt;/ul&gt;
&lt;h3 id=&quot;h3-3.20Chatbox20u65E0u6CD5u8FDEu63A520Ollama-175&quot;&gt;&lt;a class=&quot;reference-link&quot; name=&quot;3. Chatbox 无法连接 Ollama&quot;&gt;&lt;/a&gt;&lt;span class=&quot;header-link octicon octicon-link&quot;&gt;&lt;/span&gt;3. Chatbox 无法连接 Ollama&lt;/h3&gt;&lt;ul&gt;
&lt;li&gt;&lt;p&gt;检查点：&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;&lt;p&gt;确认 Ollama 服务已启动（终端输入 &lt;code&gt;ollama serve&lt;/code&gt;）；&lt;/p&gt;
&lt;/li&gt;&lt;li&gt;&lt;p&gt;检查防火墙设置，允许 11434 端口的入站连接；&lt;/p&gt;
&lt;/li&gt;&lt;li&gt;&lt;p&gt;重启 Chatbox 和 Ollama。&lt;/p&gt;
&lt;/li&gt;&lt;/ol&gt;
&lt;/li&gt;&lt;/ul&gt;
&lt;h2 id=&quot;h2-u4E03u3001u9A8Cu8BC1u90E8u7F72u6210u529F-185&quot;&gt;&lt;a class=&quot;reference-link&quot; name=&quot;七、验证部署成功&quot;&gt;&lt;/a&gt;&lt;span class=&quot;header-link octicon octicon-link&quot;&gt;&lt;/span&gt;七、验证部署成功&lt;/h2&gt;&lt;h3 id=&quot;h3-1.20u5065u5EB7u68C0u67E5-187&quot;&gt;&lt;a class=&quot;reference-link&quot; name=&quot;1. 健康检查&quot;&gt;&lt;/a&gt;&lt;span class=&quot;header-link octicon octicon-link&quot;&gt;&lt;/span&gt;1. 健康检查&lt;/h3&gt;&lt;pre&gt;&lt;code class=&quot;language-Bash&quot;&gt;
curl http://localhost:11434  # 返回 {&quot;version&quot;: &quot;x.x.x&quot;, &quot;features&quot;: [&quot;models&quot;]} 即正常
&lt;/code&gt;&lt;/pre&gt;
&lt;h3 id=&quot;h3-2.20u6027u80FDu6D4Bu8BD5-194&quot;&gt;&lt;a class=&quot;reference-link&quot; name=&quot;2. 性能测试&quot;&gt;&lt;/a&gt;&lt;span class=&quot;header-link octicon octicon-link&quot;&gt;&lt;/span&gt;2. 性能测试&lt;/h3&gt;&lt;ul&gt;
&lt;li&gt;&lt;p&gt;7B 模型响应延迟应低于 20ms；&lt;/p&gt;
&lt;/li&gt;&lt;li&gt;&lt;p&gt;33B 模型（量化后）响应延迟约 50ms；&lt;/p&gt;
&lt;/li&gt;&lt;li&gt;&lt;p&gt;测试长文本处理：输入 64K 上下文（如《三体》章节），检查摘要生成质量。&lt;/p&gt;
&lt;/li&gt;&lt;/ul&gt;
&lt;h2 id=&quot;h2-u516Bu3001u9002u7528u573Au666Fu4E0Eu6269u5C55u5EFAu8BAE-202&quot;&gt;&lt;a class=&quot;reference-link&quot; name=&quot;八、适用场景与扩展建议&quot;&gt;&lt;/a&gt;&lt;span class=&quot;header-link octicon octicon-link&quot;&gt;&lt;/span&gt;八、适用场景与扩展建议&lt;/h2&gt;&lt;h3 id=&quot;h3-1.20u5178u578Bu5E94u7528u573Au666F-204&quot;&gt;&lt;a class=&quot;reference-link&quot; name=&quot;1. 典型应用场景&quot;&gt;&lt;/a&gt;&lt;span class=&quot;header-link octicon octicon-link&quot;&gt;&lt;/span&gt;1. 典型应用场景&lt;/h3&gt;&lt;ul&gt;
&lt;li&gt;&lt;p&gt;教育领域：部署于学校实验室，供学生练习 AI 对话；&lt;/p&gt;
&lt;/li&gt;&lt;li&gt;&lt;p&gt;中小企业：快速搭建客服系统，降低外包成本；&lt;/p&gt;
&lt;/li&gt;&lt;li&gt;&lt;p&gt;个人开发者：测试模型性能，为项目提供原型支持。&lt;/p&gt;
&lt;/li&gt;&lt;/ul&gt;
&lt;h3 id=&quot;h3-2.20u6269u5C55u65B9u5411-212&quot;&gt;&lt;a class=&quot;reference-link&quot; name=&quot;2. 扩展方向&quot;&gt;&lt;/a&gt;&lt;span class=&quot;header-link octicon octicon-link&quot;&gt;&lt;/span&gt;2. 扩展方向&lt;/h3&gt;&lt;ul&gt;
&lt;li&gt;&lt;p&gt;多模态支持：结合 Stable Diffusion 等工具，实现图文交互；&lt;/p&gt;
&lt;/li&gt;&lt;li&gt;&lt;p&gt;移动端适配：通过 Termux（Android）或 iSH（iOS）在手机上运行 Ollama；&lt;/p&gt;
&lt;/li&gt;&lt;li&gt;&lt;p&gt;企业级部署：使用 Docker 容器化 Ollama，实现集群化管理。&lt;/p&gt;
&lt;/li&gt;&lt;/ul&gt;
&lt;h2 id=&quot;h2-u4E5Du3001u603Bu7ED3u4E0Eu884Cu52A8u5EFAu8BAE-220&quot;&gt;&lt;a class=&quot;reference-link&quot; name=&quot;九、总结与行动建议&quot;&gt;&lt;/a&gt;&lt;span class=&quot;header-link octicon octicon-link&quot;&gt;&lt;/span&gt;九、总结与行动建议&lt;/h2&gt;&lt;ol&gt;
&lt;li&gt;&lt;p&gt;下载 Ollama 和 Chatbox，完成基础安装；&lt;/p&gt;
&lt;/li&gt;&lt;li&gt;&lt;p&gt;尝试运行 &lt;code&gt;deepseek-r1:3b&lt;/code&gt; 或 &lt;code&gt;deepseek-r1:7b&lt;/code&gt; 模型，体验基础对话功能；&lt;/p&gt;
&lt;/li&gt;&lt;li&gt;&lt;p&gt;根据需求调整参数或扩展功能（如批量处理、API 集成）。&lt;/p&gt;
&lt;/li&gt;&lt;/ol&gt;
&lt;p&gt;本地化 AI 的未来，正从这一步开始！&lt;/p&gt;
&lt;p&gt;注：文档部分内容由 AI 生成，实际操作以官方最新指南为准。&lt;/p&gt;
&lt;blockquote&gt;&lt;p&gt;（注：文档部分内容可能由 AI 生成）&lt;/p&gt;
&lt;/blockquote&gt;&lt;/body&gt;</description><pubDate>Tue, 27 Jan 2026 16:23:34 +0800</pubDate></item><item><title>Videojs 使用 Hls 对视频加密解码</title><link>https://blog.smallhao.fun/?id=44</link><description>&lt;head&gt;&lt;/head&gt;&lt;body&gt;&lt;h3 id=&quot;h3-u4E0Bu8F7DHls.js-1&quot;&gt;&lt;a class=&quot;reference-link&quot; name=&quot;下载Hls.js&quot;&gt;&lt;/a&gt;&lt;span class=&quot;header-link octicon octicon-link&quot;&gt;&lt;/span&gt;下载Hls.js&lt;/h3&gt;&lt;blockquote&gt;&lt;p&gt;npm install hls.js&lt;/p&gt;
&lt;/blockquote&gt;&lt;h4 id=&quot;h4-video20u64ADu653Eu7EC4u4EF6-5&quot;&gt;&lt;a class=&quot;reference-link&quot; name=&quot;video 播放组件&quot;&gt;&lt;/a&gt;&lt;span class=&quot;header-link octicon octicon-link&quot;&gt;&lt;/span&gt;video 播放组件&lt;/h4&gt;&lt;pre&gt;&lt;code class=&quot;language-vue&quot;&gt;&amp;lt;template&amp;gt;
  &amp;lt;div
    v-bind=&quot;$attrs&quot;
    class=&quot;videoPlayer&quot;
    ref=&quot;videoPlayerRef&quot;
    v-loading=&quot;loading&quot;
    element-loading-text=&quot;视频加载中&quot;
    element-loading-spinner=&quot;el-icon-loading&quot;
    element-loading-background=&quot;rgba(0, 0, 0, 0.8)&quot;
  &amp;gt;
    &amp;lt;video class=&quot;video-js&quot; ref=&quot;videoRef&quot; :id=&quot;id&quot; style=&quot;width: 100%; height: 100%;object-fit: cover;position: relative;&quot; :poster=&quot;poster&quot; controls&amp;gt;&amp;lt;/video&amp;gt;
  &amp;lt;/div&amp;gt;
&amp;lt;/template&amp;gt;

&amp;lt;script setup&amp;gt;
import { onMounted, onBeforeUnmount, watch, ref, nextTick } from &#039;vue&#039;
import { getVideoUrl } from &#039;./index&#039;
import { getToken } from &#039;@/utils/auth&#039;
import videojs from &#039;video.js&#039;
import &#039;video.js/dist/video-js.css&#039;
import &#039;videojs-flvjs-es6&#039;
import &#039;videojs-flash&#039;
import Hls from &#039;hls.js&#039;

const overrideNative = ref(false)
const props = defineProps({
  videoId: { type: String, default: &#039;&#039; },
})
const loading = ref(false)
const videoRef = ref(null)
const poster = ref(&#039;&#039;)

const videoID = ref(props.videoId)

// ============================================================

let player

const initPlayer = () =&amp;gt; {
  if (player) {
    player.dispose()
    player.value = null
  }
  try {
    player = videojs(videoRef.value, options(), playerReady)
  } catch (error) {}
}
const playerReady = () =&amp;gt; {
  emit(&#039;playerMounted&#039;, player)

  // 强制显示大播放按钮 及其样式自定义
  player.bigPlayButton.show()
  player.bigPlayButton.el().style.display = &#039;block&#039;
  player.bigPlayButton.el().style.opacity = &#039;1&#039;
  player.bigPlayButton.el().style.top = &#039;50%&#039;
  player.bigPlayButton.el().style.left = &#039;50%&#039;
  player.bigPlayButton.el().style.transform = &#039;translate(-50%, -50%)&#039;
  player.bigPlayButton.el().style.borderRadius = &#039;50%&#039;

  // 添加自定义播放控制
  player.ready(() =&amp;gt; {
    console.log(&#039;Video.js播放器准备就绪&#039;)
    loading.value = false
    
    // 监听视频可播放事件
    player.on(&#039;loadeddata&#039;, () =&amp;gt; {
      console.log(&#039;视频已加载，可以播放&#039;)
      emit(&#039;videoCanplaythrough&#039;)
    })
    
    // 处理播放错误
    player.on(&#039;error&#039;, (e) =&amp;gt; {
      console.error(&#039;播放错误:&#039;, player.error())
    })
  })
  // 大按钮点击事件（强制绑定）
  player.bigPlayButton.on(&#039;click&#039;, async () =&amp;gt; {
    videoRef.value.play()
    player.bigPlayButton.hide()
    emit(&#039;videoPlay&#039;)
  })

  player.on(&#039;canplaythrough&#039;, function () {
    videojs.log(&#039;视频可以播放&#039;)
    emit(&#039;videoCanplaythrough&#039;)
  })
  player.on(&#039;play&#039;, function () {
    videojs.log(&#039;视频准备播放&#039;)
    // 此代码导致无法拉动长度，换用挂在完毕之后外侧处理
    player.currentTime(props.videoProgress)
    emit(&#039;videoPlay&#039;)
  })
  player.on(&#039;playing&#039;, function () {
    player.bigPlayButton.hide()
    videojs.log(&#039;视频已开始播放&#039;)
    emit(&#039;videoPlaying&#039;)
  })
  player.on(&#039;pause&#039;, function (event) {
    player.bigPlayButton.show()
    videojs.log(&#039;视频已暂停播放&#039;)
    emit(&#039;videoPause&#039;, event.target.player.cache_?.currentTime)
  })
  player.on(&#039;seeked&#039;, function (event) {
    emit(&#039;videoSeeked&#039;, event.target.player.cache_?.currentTime)
  })
  // 监听视频播放结束事件
  player.on(&#039;ended&#039;, function () {
    emit(&#039;videoEnded&#039;)
  })
  player.on(&#039;timeupdate&#039;, function () {
    var playedSeconds = player.currentTime() // 获取当前播放的秒数
    var duration = player.duration() // 获取视频总长度
    // 你可以在这里编写代码来处理视频播放进度
    emit(&#039;videoTimeupdate&#039;, playedSeconds)
  })
}

// =========================== 方法一 ====================================

// 获取加密地址与密钥
const getVideoInfo = async () =&amp;gt; {
  loading.value = true
  getVideoUrl(videoID.value).then((res) =&amp;gt; {
    poster.value = res.data.posterUrl ? res.data.posterUrl : &#039;&#039;
    if (Hls.isSupported()) {
        const hls = new Hls({
            debug: false,
            xhrSetup: function(xhr, url) {
                // 自定义密钥请求
                if (url.includes(&#039;/key/&#039;)) {
                    xhr.setRequestHeader(&#039;Authorization&#039;, &#039;Bearer &#039; + getToken());
                }
            }
        });
        hls.loadSource(res.data.m3u8Url);
        hls.attachMedia(videoRef.value);
        nextTick(() =&amp;gt; {
          initPlayer() // 初始化播放器
          loading.value = false
        })
    } else if (videoRef.value.canPlayType(&#039;application/vnd.apple.mpegurl&#039;)) {
        // Safari原生支持
        videoRef.value.src = res.data.m3u8Url;
        player = videojs(videoRef.value, options());
        loading.value = false
    } else {
      console.log(&#039;您的浏览器不支持 HLS 播放&#039;)
    }
  })
}


// ======================================== 方法二 ==================================================
// const getVideoInfo = async () =&amp;gt; {
//   loading.value = true
//   getVideoUrl(videoID.value).then((res) =&amp;gt; {
//     poster.value = res.data.posterUrl ? res.data.posterUrl : &#039;&#039;
    
//     // 销毁现有播放器
//     if (player) {
//       player.dispose()
//       player = null
//     }
    
//     // 初始化Video.js播放器
//     player = videojs(videoRef.value, {
//       ...options(),
//       html5: {
//         hls: {
//           withCredentials: false,
//           // Video.js使用beforeRequest而不是xhrSetup
//           beforeRequest: function(options) {
            
//             // 判断是否是密钥请求
//             if (options.uri &amp;amp;&amp;amp; options.uri.includes(&#039;/key/&#039;)) {
//               const token = getToken()
              
//               if (!token) {
//                 console.error(&#039;Token为空！&#039;)
//                 // 可以跳转到登录页或刷新token
//               }
              
//               // 添加Authorization头
//               options.headers = options.headers || {}
//               options.headers[&#039;Authorization&#039;] = &#039;Bearer &#039; + token
//             }
//             return options
//           }
//         }
//       },
//       sources: [{
//         src: res.data.m3u8Url,
//         type: &#039;application/x-mpegURL&#039;
//       }],
//       autoplay: false
//     })
    
//     // 监听播放器准备事件
//     playerReady()
//     player.ready(() =&amp;gt; {
//     //   console.log(&#039;Video.js播放器准备就绪&#039;)
//     //   loading.value = false
      
//     //   // 监听错误事件
//     //   player.on(&#039;error&#039;, (e) =&amp;gt; {
//     //     console.error(&#039;播放错误:&#039;, player.error())
        
//     //     // 如果是401错误，说明token有问题
//     //     const error = player.error()
//     //     if (error &amp;amp;&amp;amp; error.code === 4) {
//     //       console.log(&#039;检测到权限错误(401)，可能是token过期&#039;)
//     //     }
//     //   })
      
//       // 监听网络请求
//       setupRequestInterceptor()
//     })
//   }).catch(error =&amp;gt; {
//     console.error(&#039;获取视频信息失败:&#039;, error)
//     loading.value = false
//   })
// }

// const setupRequestInterceptor = () =&amp;gt; {
//   // 方法1：拦截所有XMLHttpRequest
//   const originalXHROpen = XMLHttpRequest.prototype.open
//   const originalXHRSend = XMLHttpRequest.prototype.send
  
//   XMLHttpRequest.prototype.open = function(method, url) {
//     this._requestMethod = method
//     this._requestUrl = url
//     return originalXHROpen.apply(this, arguments)
//   }
  
//   XMLHttpRequest.prototype.send = function(body) {
//     // 拦截HLS相关请求
//     if (this._requestUrl &amp;amp;&amp;amp; 
//         (this._requestUrl.includes(&#039;.m3u8&#039;) || 
//          this._requestUrl.includes(&#039;.ts&#039;) || 
//          this._requestUrl.includes(&#039;/key/&#039;))) {
      
//       // console.log(&#039;拦截HLS请求:&#039;, this._requestUrl)
      
//       // 如果是密钥请求，添加token
//       if (this._requestUrl.includes(&#039;/key/&#039;)) {
//         const token = getToken()
//         // console.log(&#039;为密钥请求手动添加token&#039;)
//         this.setRequestHeader(&#039;Authorization&#039;, &#039;Bearer &#039; + token)
//       }
      
//       // 监听请求状态
//       this.addEventListener(&#039;readystatechange&#039;, function() {
//         if (this.readyState === 4) {
//           // console.log(&#039;HLS请求完成:&#039;, {
//           //   url: this._requestUrl,
//           //   status: this.status,
//           //   statusText: this.statusText
//           // })
          
//           if (this.status === 401) {
//             console.error(&#039;权限验证失败(401)，token可能无效&#039;)
//           }
//         }
//       })
//     }
    
//     return originalXHRSend.apply(this, arguments)
//   }
// }

watch(() =&amp;gt; props.videoId, (newVal) =&amp;gt; {
  if(!newVal) return
  getVideoInfo()
}, { immediate: true, deep: true })

const emit = defineEmits([
  // 播放器挂载完毕
  &#039;playerMounted&#039;,
  &#039;videoCanplaythrough&#039;,
  &#039;videoPlay&#039;,
  &#039;videoPlaying&#039;,
  &#039;videoPause&#039;,
  &#039;videoSeeked&#039;,
  &#039;videoEnded&#039;,
  &#039;videoTimeupdate&#039;
])
// VideoJs更多选项配置可以参考中文文档：
function options() {
  return {
    html5: {
      hls: {
        overrideNative: overrideNative
      },
      nativeVideoTracks: !overrideNative,
      nativeAudioTracks: !overrideNative,
      nativeTextTracks: !overrideNative
    },
    autoplay: false, // true,浏览器准备好时开始播放。
    muted: true, // 默认情况下将会消除音频。
    loop: false, // 导致视频一结束就重新开始。
    controls: true,
    preload: &#039;auto&#039;, // auto浏览器选择最佳行为,立即开始加载视频（如果浏览器支持）
    fluid: true, // 当true时，将按比例缩放以适应其容器。
    type: &#039;application/x-mpegURl&#039;,
    notSupportedMessage: &#039;此视频暂无法播放，请稍后再试&#039;, // 无法播放媒体源时显示的默认信息。
    textTrackDisplay: false,
    playbackRates: [0.5, 1, 1.5, 2], //倍速
  }
}

onBeforeUnmount(() =&amp;gt; {
  if (player) {
    player.dispose()
    player = null
  }
})


&amp;lt;/script&amp;gt;
&amp;lt;!-- scoped --&amp;gt;
&amp;lt;style lang=&quot;scss&quot;&amp;gt;
.videoPlayer {
  width: 100%;
  height: 100%;
  position: relative;
  overflow: hidden;  
}

.video-js {
  padding-top: 0 !important;
}
.video-js .vjs-time-control {
  display: block;
}
.video-js .vjs-remaining-time {
  display: none;
}
.vjs-playback-rate .vjs-playback-rate-value {
  font-size: 1em;
  line-height: 3em;
}
.vjs-poster {
  background-color: #00000000;
}
.video-js:hover .vjs-big-play-button{
  background-color: transparent;
  opacity: 1;
}
.video-js .vjs-big-play-button{
  background: transparent;
  width: 2em;
  height: 2em;
  font-size: 10em;
  background: rgba(0,0,0,0.1) url(./play.png) center / 100% 100% no-repeat !important;
  border: 0;
  border-radius: 50%;
  .vjs-icon-placeholder{
    display: none;
  }
}
&amp;lt;/style&amp;gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;strong&gt;方法一中 点击视频元素无法进行播放，只能点击播放按钮；方法二中所有元素都可点击控制播放&lt;/strong&gt;&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-vue&quot;&gt;// decode.vue
&amp;lt;template&amp;gt;
  &amp;lt;div class=&quot;content_box&quot;&amp;gt;
    &amp;lt;div class=&quot;wrapper&quot;&amp;gt;
      &amp;lt;div class=&quot;news-detail-title&quot;&amp;gt;
        {{ title }}
      &amp;lt;/div&amp;gt;
      &amp;lt;div class=&quot;news-detail-content&quot;&amp;gt;
        &amp;lt;VideoPlayer
          v-if=&quot;videoID&quot;
          :videoId=&quot;videoID&quot;
          style=&quot;width: 100%; height: 500px&quot;
        /&amp;gt;
      &amp;lt;/div&amp;gt;
    &amp;lt;/div&amp;gt;
  &amp;lt;/div&amp;gt;
&amp;lt;/template&amp;gt;
&amp;lt;script setup&amp;gt;
import { getVideoInfo } from &#039;./index.js&#039;
import VideoPlayer from &#039;@/components/DecodeVideo/index.vue&#039;

const route = useRoute()
const title = ref(&#039;&#039;)
const videoID = ref(&#039;&#039;)

const getVideoData = (id) =&amp;gt; {
  getVideoInfo(id).then((res) =&amp;gt; {
    title.value = res.data.title
    videoID.value = res.data.videoId
  })
}

onMounted(() =&amp;gt; {
  // 新版解码
  getVideoData(route.query.id)
})
&amp;lt;/script&amp;gt;

&amp;lt;style lang=&quot;scss&quot; scoped&amp;gt;
.content_box {
  width: 100%;
  height: 100%;
  background: #f1f4f9;
  padding: 20px 0px;
  box-sizing: border-box;

  .wrapper {
    background-color: #fff;
    padding: 20px;
    box-sizing: border-box;

    .news-detail-title {
      text-align: center;
      color: #0043b2;
      font-size: 30px;
      font-weight: bold;
      margin: 10px 85px;
    }

    .news-detail-post {
      text-align: center;
      margin: 0 120px;
      color: #999;
      height: 60px;
      line-height: 60px;
      border-bottom: 1px solid #999;
      font-size: 12px;

      span {
        margin-right: 10px;
      }
    }

    .news-detail-content {
      padding: 10px 50px;
      min-height: calc(100vh - 122px - 48px - 330px);
      margin: 0 80px;
      line-height: 36px;
    }
  }
}
&amp;lt;/style&amp;gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;h4 id=&quot;h4-u63A5u53E3u6587u4EF6-457&quot;&gt;&lt;a class=&quot;reference-link&quot; name=&quot;接口文件&quot;&gt;&lt;/a&gt;&lt;span class=&quot;header-link octicon octicon-link&quot;&gt;&lt;/span&gt;接口文件&lt;/h4&gt;&lt;pre&gt;&lt;code class=&quot;language-js&quot;&gt;import request from &#039;@/utils/request&#039;

export function getVideoKey(videoId) {
  return request({
    url: `/client/encrypted/video/key/${videoId}`,
    method: &#039;get&#039;,
    headers: {
      &#039;Content-Type&#039;: &#039;application/octet-stream&#039;
    }
  })
}

export function getVideoUrl(videoId) {
  return request({
    url: `/client/encrypted/video/playUrl/${videoId}`,
    method: &#039;get&#039;,
  })
}
&lt;/code&gt;&lt;/pre&gt;
&lt;/body&gt;</description><pubDate>Thu, 18 Dec 2025 15:55:26 +0800</pubDate></item><item><title>Vue3 + VueOffice 全家桶进行 多格式文件预览</title><link>https://blog.smallhao.fun/?id=45</link><description>&lt;head&gt;&lt;/head&gt;&lt;body&gt;&lt;h2 id=&quot;h2-vue-office-1&quot;&gt;&lt;a class=&quot;reference-link&quot; name=&quot;vue-office&quot;&gt;&lt;/a&gt;&lt;span class=&quot;header-link octicon octicon-link&quot;&gt;&lt;/span&gt;vue-office&lt;/h2&gt;&lt;p&gt;&lt;a title=&quot;Vue-Office&quot; href=&quot;https://www.npmjs.com/package/@vue-office/docx&quot;&gt;&lt;/a&gt;&lt;a title=&quot;Vue-Office&quot; href=&quot;https://www.npmjs.com/package/@vue-office/docx&quot;&gt;1&lt;/a&gt;Vue-Office预览的vue组件库，支持vue2/3。也支持非Vue框架的预览。&lt;/p&gt;
&lt;h2 id=&quot;h2-u51C6u5907u5DE5u4F5C-5&quot;&gt;&lt;a class=&quot;reference-link&quot; name=&quot;准备工作&quot;&gt;&lt;/a&gt;&lt;span class=&quot;header-link octicon octicon-link&quot;&gt;&lt;/span&gt;准备工作&lt;/h2&gt;&lt;pre&gt;&lt;code class=&quot;language-js&quot;&gt;#docx文档预览组件
npm install @vue-office/docx vue-demi@0.14.6

#excel文档预览组件
npm install @vue-office/excel vue-demi@0.14.6

#pdf文档预览组件
npm install @vue-office/pdf vue-demi@0.14.6

#pptx文档预览组件
npm install @vue-office/pptx vue-demi@0.14.6
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;strong&gt;如果是vue2.6版本或以下还需要额外安装 &lt;a class=&quot;at-link&quot; title=&quot;@vue&quot; href=&quot;https://github.com/vue&quot;&gt;@vue&lt;/a&gt;/composition-api&lt;/strong&gt;&lt;/p&gt;
&lt;blockquote&gt;&lt;blockquote&gt;&lt;p&gt;npm install &lt;a class=&quot;at-link&quot; title=&quot;@vue&quot; href=&quot;https://github.com/vue&quot;&gt;@vue&lt;/a&gt;/composition-api&lt;/p&gt;
&lt;/blockquote&gt;&lt;/blockquote&gt;&lt;h3 id=&quot;h3-u7EC4u4EF6u4EE3u7801u5982u4E0B-25&quot;&gt;&lt;a class=&quot;reference-link&quot; name=&quot;组件代码如下&quot;&gt;&lt;/a&gt;&lt;span class=&quot;header-link octicon octicon-link&quot;&gt;&lt;/span&gt;组件代码如下&lt;/h3&gt;&lt;pre&gt;&lt;code class=&quot;language-vue&quot;&gt;&amp;lt;template&amp;gt;
  &amp;lt;div
    class=&quot;office-viewer&quot;
    :class=&quot;{ dragging: isDragging, zoomable: zoomLevel &amp;gt; 1 }&quot;
    @wheel=&quot;handleWheel&quot;
    @mousedown=&quot;handleMouseDown&quot;
    @mousemove=&quot;handleMouseMove&quot;
    @mouseup=&quot;handleMouseUp&quot;
    @mouseleave=&quot;handleMouseLeave&quot;
    ref=&quot;viewerContainer&quot;
  &amp;gt;
    &amp;lt;!-- PDF预览 --&amp;gt;
    &amp;lt;VueOfficePdf
      v-if=&quot;trimmedType === &#039;pdf&#039;&quot;
      ref=&quot;pdfViewer&quot;
      :src=&quot;encodedSrc&quot;
      :style=&quot;{
        height: height,
        width: width,
      }&quot;
      @rendered=&quot;onRendered&quot;
      @error=&quot;onError&quot;
    /&amp;gt;

    &amp;lt;!-- Word文档预览 --&amp;gt;
    &amp;lt;VueOfficeDocx
      v-else-if=&quot;trimmedType === &#039;word&#039;&quot;
      ref=&quot;docxViewer&quot;
      :src=&quot;encodedSrc&quot;
      :style=&quot;{
        height: height,
        width: width,
      }&quot;
      @rendered=&quot;onRendered&quot;
      @error=&quot;onError&quot;
    /&amp;gt;

    &amp;lt;!-- Excel文档预览 --&amp;gt;
    &amp;lt;VueOfficeExcel
      v-else-if=&quot;trimmedType === &#039;excel&#039;&quot;
      ref=&quot;excelViewer&quot;
      :src=&quot;encodedSrc&quot;
      :style=&quot;{
        height: height,
        width: width,
      }&quot;
      @rendered=&quot;onRendered&quot;
      @error=&quot;onError&quot;
    /&amp;gt;

    &amp;lt;!-- PPT预览 --&amp;gt;
    &amp;lt;VueOfficePptx
      v-else-if=&quot;trimmedType === &#039;ppt&#039;&quot;
      ref=&quot;pptxViewer&quot;
      :src=&quot;encodedSrc&quot;
      :options=&quot;pptxOptions&quot;
      :style=&quot;{
        height: height,
        width: width,
        transformOrigin: &#039;top left&#039;,
      }&quot;
      @rendered=&quot;onPptxRendered&quot;
      @error=&quot;onPptxError&quot;
    /&amp;gt;

    &amp;lt;!-- 视频、图片预览 --&amp;gt;
    &amp;lt;div class=&quot;img_video_box&quot; v-else-if=&quot;trimmedType === &#039;video&#039; || trimmedType === &#039;img&#039;&quot;&amp;gt;
        &amp;lt;!-- 视频预览 --&amp;gt;
        &amp;lt;video
            v-if=&quot;trimmedType === &#039;video&#039;&quot;
            :src=&quot;encodedSrc&quot;
            :style=&quot;{ height: height, width: width }&quot;
            controls
        /&amp;gt;
        &amp;lt;!-- 图片预览 --&amp;gt;
        &amp;lt;img
            v-if=&quot;trimmedType === &#039;img&#039;&quot;
            :src=&quot;encodedSrc&quot;
            :style=&quot;{ height: height, width: width / 2 }&quot;
        /&amp;gt;
    &amp;lt;/div&amp;gt;

    &amp;lt;!-- 不支持的文件类型 --&amp;gt;
    &amp;lt;div v-else class=&quot;unsupported-type&quot;&amp;gt;
      &amp;lt;div class=&quot;error-message&quot;&amp;gt;
        &amp;lt;i class=&quot;el-icon-warning&quot;&amp;gt;&amp;lt;/i&amp;gt;
        &amp;lt;p&amp;gt;不支持的文件类型: {{ type }}&amp;lt;/p&amp;gt;
        &amp;lt;p&amp;gt;支持的格式: PDF, DOC, DOCX, XLS, XLSX, PPT, PPTX&amp;lt;/p&amp;gt;
      &amp;lt;/div&amp;gt;
    &amp;lt;/div&amp;gt;

    &amp;lt;!-- 加载状态 --&amp;gt;
    &amp;lt;div v-if=&quot;loading&quot; class=&quot;loading-overlay&quot;&amp;gt;
      &amp;lt;div class=&quot;loading-spinner&quot;&amp;gt;
        &amp;lt;el-icon class=&quot;el-icon-loading&quot;&amp;gt;&amp;lt;Loading /&amp;gt;&amp;lt;/el-icon&amp;gt;
        &amp;lt;p&amp;gt;文档加载中...&amp;lt;/p&amp;gt;
      &amp;lt;/div&amp;gt;
    &amp;lt;/div&amp;gt;

    &amp;lt;!-- 错误状态 --&amp;gt;
    &amp;lt;div v-if=&quot;error&quot; class=&quot;error-overlay&quot;&amp;gt;
      &amp;lt;div class=&quot;error-message&quot;&amp;gt;
        &amp;lt;i class=&quot;el-icon-warning&quot;&amp;gt;&amp;lt;/i&amp;gt;
        &amp;lt;p&amp;gt;文档加载失败&amp;lt;/p&amp;gt;
        &amp;lt;p&amp;gt;{{ errorMessage }}&amp;lt;/p&amp;gt;
        &amp;lt;button @click=&quot;retry&quot; class=&quot;retry-btn&quot;&amp;gt;重试&amp;lt;/button&amp;gt;
      &amp;lt;/div&amp;gt;
    &amp;lt;/div&amp;gt;

    &amp;lt;!-- 缩放控制提示 --&amp;gt;
    &amp;lt;div v-if=&quot;showZoomTip&quot; class=&quot;zoom-tip&quot;&amp;gt;
      &amp;lt;span&amp;gt;缩放: {{ Math.round(zoomLevel * 100) }}%&amp;lt;/span&amp;gt;
      &amp;lt;small&amp;gt;Ctrl+滚轮缩放，拖拽移动，双击重置&amp;lt;/small&amp;gt;
    &amp;lt;/div&amp;gt;

    &amp;lt;!-- 关闭按钮 --&amp;gt;
    &amp;lt;div class=&quot;close-btn&quot; @click=&quot;emit(&#039;close&#039;)&quot; title=&quot;关闭&quot;&amp;gt;
      &amp;lt;el-icon&amp;gt;&amp;lt;Close /&amp;gt;&amp;lt;/el-icon&amp;gt;
    &amp;lt;/div&amp;gt;
  &amp;lt;/div&amp;gt;
&amp;lt;/template&amp;gt;

&amp;lt;script setup&amp;gt;
import { ref, computed, watch, onMounted, readonly, nextTick } from &quot;vue&quot;;
//引入VueOfficeDocx组件
import VueOfficeDocx from &quot;@vue-office/docx&quot;;
//引入相关样式
import &quot;@vue-office/docx/lib/index.css&quot;;
//引入VueOfficeExcel组件
import VueOfficeExcel from &quot;@vue-office/excel&quot;;
//引入相关样式
import &quot;@vue-office/excel/lib/index.css&quot;;
//引入VueOfficePdf组件
import VueOfficePdf from &quot;@vue-office/pdf&quot;;
import VueOfficePptx from &quot;@vue-office/pptx&quot;;

// 定义组件属性
const props = defineProps({
  // 文件类型: pdf, docx, doc, xlsx, xls, ppt, pptx
  type: {
    type: String,
    required: true,
    validator: (value) =&amp;gt;
      [&quot;pdf&quot;, &quot;word&quot;, &quot;excel&quot;, &quot;ppt&quot;, &quot;video&quot;, &quot;img&quot;].includes(
        value.toLowerCase()
      ),
  },
  // 文件源地址
  src: {
    type: String,
    required: true,
  },
  // 容器高度
  height: {
    type: String,
    default: &quot;100%&quot;,
  },
  // 容器宽度
  width: {
    type: String,
    default: &quot;100%&quot;,
  },
  file: {
    type: Object,
    default: () =&amp;gt; ({
        type: &#039;&#039;,
        src: &#039;&#039;,
    }),
  }
});

// 定义事件
const emit = defineEmits([&quot;rendered&quot;, &quot;error&quot;, &quot;loading&quot;, &quot;close&quot;]);

// 响应式数据
const loading = ref(false);
const error = ref(false);
const errorMessage = ref(&quot;&quot;);
const zoomLevel = ref(1);
const showZoomTip = ref(false);
const viewerContainer = ref(null);
const pdfViewer = ref(null);
const docxViewer = ref(null);
const excelViewer = ref(null);
const pptxViewer = ref(null);
let zoomTipTimer = null;

// 拖拽相关状态
const isDragging = ref(false);
const dragStart = ref({ x: 0, y: 0 });
const dragOffset = ref({ x: 0, y: 0 });
const lastDragOffset = ref({ x: 0, y: 0 });

// 支持的文件类型
const supportedTypes = [&quot;pdf&quot;, &quot;word&quot;, &quot;excel&quot;, &quot;ppt&quot;, &quot;video&quot;, &quot;img&quot;];

// PPTX配置选项
const pptxOptions = ref({
  // 启用图片渲染
  enableImages: true,
  // 设置渲染模式
  renderMode: &quot;canvas&quot;,
  // 缩放比例
  scale: 1,
  // 启用调试模式
  debug: true,
});

// 处理去除空格的文件类型
const trimmedType = computed(() =&amp;gt; {
  return props.type.trim().toLowerCase();
});

// 检查文件类型是否支持
const isSupported = computed(() =&amp;gt; {
  return supportedTypes.includes(trimmedType.value);
});

// 对src进行URL编码
const encodedSrc = computed(() =&amp;gt; {
  return props.src;
});

// 文档渲染完成回调
const onRendered = () =&amp;gt; {
  loading.value = false;
  error.value = false;
  emit(&quot;rendered&quot;);
};

// 文档加载错误回调
const onError = (err) =&amp;gt; {
  loading.value = false;
  error.value = true;
  errorMessage.value = err.message || &quot;文档加载失败&quot;;
  emit(&quot;error&quot;, err);
};

// PPTX文档渲染完成回调
const onPptxRendered = () =&amp;gt; {
  console.log(&quot;PPTX文档渲染完成&quot;);
  console.log(&quot;当前src:&quot;, encodedSrc.value);
  console.log(&quot;文档类型:&quot;, trimmedType.value);
  loading.value = false;
  error.value = false;
  emit(&quot;rendered&quot;);
};

// PPTX文档加载错误回调
const onPptxError = (err) =&amp;gt; {
  console.error(&quot;PPTX文档渲染失败:&quot;, err);
  console.log(&quot;失败时的src:&quot;, encodedSrc.value);
  console.log(&quot;失败时的文档类型:&quot;, trimmedType.value);
  loading.value = false;
  error.value = true;
  errorMessage.value = err.message || &quot;PPTX文档加载失败&quot;;
  emit(&quot;error&quot;, err);
};

// 重试加载
const retry = () =&amp;gt; {
  error.value = false;
  errorMessage.value = &quot;&quot;;
  loading.value = true;
};

// 处理鼠标滚轮缩放（需要按住Ctrl键）
const handleWheel = (event) =&amp;gt; {
  // 只有按住Ctrl键时才进行缩放
  if (!event.ctrlKey) {
    return;
  }
  event.preventDefault();
  if(props.type == &#039;img&#039; || props.type == &#039;video&#039; || props.type == &#039;other&#039;) return

  

  const delta = event.deltaY &amp;gt; 0 ? -0.1 : 0.1;
  const newZoomLevel = Math.max(0.5, Math.min(3, zoomLevel.value + delta));

  zoomLevel.value = newZoomLevel;

  // 显示缩放提示
    showZoomTip.value = true

  // 清除之前的定时器
  if (zoomTipTimer) {
    clearTimeout(zoomTipTimer);
  }

  // 2秒后隐藏提示
  zoomTipTimer = setTimeout(() =&amp;gt; {
    showZoomTip.value = false;
  }, 2000);
};

// 双击重置缩放
const handleDoubleClick = () =&amp;gt; {
  zoomLevel.value = 1;
  dragOffset.value = { x: 0, y: 0 };
  lastDragOffset.value = { x: 0, y: 0 };
  showZoomTip.value = true;

  if (zoomTipTimer) {
    clearTimeout(zoomTipTimer);
  }

  zoomTipTimer = setTimeout(() =&amp;gt; {
    showZoomTip.value = false;
  }, 1000);
};

// 重置缩放级别
const resetZoom = () =&amp;gt; {
  zoomLevel.value = 1;
  // 重置拖拽偏移
  dragOffset.value = { x: 0, y: 0 };
  lastDragOffset.value = { x: 0, y: 0 };
};

// 重置vue-office组件内部滚动位置
const resetOfficeViewerScroll = () =&amp;gt; {
  // 使用nextTick确保组件已经渲染
  nextTick(() =&amp;gt; {
    // 重置PDF组件滚动位置
    if (pdfViewer.value &amp;amp;&amp;amp; pdfViewer.value.$el) {
      const pdfContainer =
        pdfViewer.value.$el.querySelector(&quot;.pdf-viewer&quot;) || pdfViewer.value.$el;
      if (pdfContainer) {
        pdfContainer.scrollTop = 0;
      }
    }

    // 重置Word组件滚动位置
    if (docxViewer.value &amp;amp;&amp;amp; docxViewer.value.$el) {
      const docxContainer =
        docxViewer.value.$el.querySelector(&quot;.docx-viewer&quot;) ||
        docxViewer.value.$el;
      if (docxContainer) {
        docxContainer.scrollTop = 0;
      }
    }

    // 重置Excel组件滚动位置
    if (excelViewer.value &amp;amp;&amp;amp; excelViewer.value.$el) {
      const excelContainer =
        excelViewer.value.$el.querySelector(&quot;.excel-viewer&quot;) ||
        excelViewer.value.$el;
      if (excelContainer) {
        excelContainer.scrollTop = 0;
      }
    }

    // 重置PPT组件滚动位置
    if (pptxViewer.value &amp;amp;&amp;amp; pptxViewer.value.$el) {
      const pptxContainer =
        pptxViewer.value.$el.querySelector(&quot;.pptx-viewer&quot;) ||
        pptxViewer.value.$el;
      if (pptxContainer) {
        pptxContainer.scrollTop = 0;
      }
    }
  });
};

// 处理鼠标按下事件（开始拖拽）
const handleMouseDown = (event) =&amp;gt; {
  if (zoomLevel.value &amp;gt; 1) {
    isDragging.value = true;
    dragStart.value = {
      x: event.clientX - dragOffset.value.x,
      y: event.clientY - dragOffset.value.y,
    };
    event.preventDefault();
  }
};

// 处理鼠标移动事件（拖拽中）
const handleMouseMove = (event) =&amp;gt; {
  if (isDragging.value &amp;amp;&amp;amp; zoomLevel.value &amp;gt; 1) {
    dragOffset.value = {
      x: event.clientX - dragStart.value.x,
      y: event.clientY - dragStart.value.y,
    };
    event.preventDefault();
  }
};

// 处理鼠标释放事件（结束拖拽）
const handleMouseUp = () =&amp;gt; {
  if (isDragging.value) {
    isDragging.value = false;
    lastDragOffset.value = { ...dragOffset.value };
  }
};

// 处理鼠标离开事件
const handleMouseLeave = () =&amp;gt; {
  if (isDragging.value) {
    isDragging.value = false;
    lastDragOffset.value = { ...dragOffset.value };
  }
};

// 监听src变化，重新加载文档
watch(
  () =&amp;gt; props.src,
  (newSrc) =&amp;gt; {
    if (newSrc) {
      loading.value = true;
      error.value = false;
      errorMessage.value = &quot;&quot;;
      // 重置滚动位置到顶部
      if (viewerContainer.value) {
        viewerContainer.value.scrollTop = 0;
      }
      // 重置vue-office组件内部滚动位置
      resetOfficeViewerScroll();
    }
  },
  { immediate: true }
);

// 监听type变化
watch(
  () =&amp;gt; props.type,
  (newType) =&amp;gt; {
    if (newType &amp;amp;&amp;amp; props.src) {
      loading.value = true;
      error.value = false;
      errorMessage.value = &quot;&quot;;
    }
  }
);

// 组件挂载时初始化
onMounted(() =&amp;gt; {
  if (props.src &amp;amp;&amp;amp; isSupported.value) {
    loading.value = true;
  } else {
    loading.value = false;
  }
  if(props.type == &#039;img&#039; || props.type == &#039;video&#039;){
    nextTick(() =&amp;gt; {
        loading.value = false
    })
  }

  // 添加双击事件监听
  if (viewerContainer.value) {
    viewerContainer.value.addEventListener(&quot;dblclick&quot;, handleDoubleClick);
  }
});

// 暴露方法供外部调用
defineExpose({
  resetZoom,
  resetOfficeViewerScroll,
  zoomLevel: readonly(zoomLevel),
  handleMouseDown,
  handleMouseMove,
  handleMouseUp,
  handleMouseLeave,
  onPptxRendered,
  onPptxError,
  pptxOptions,
});

const getTransform = computed(() =&amp;gt; {
    if(props.type == &#039;excel&#039; || props.type == &#039;ppt&#039;) {
        zoomLevel.value = 0.8
    }
    return `scale(${zoomLevel.value}) translate(${dragOffset.value.x}px, ${dragOffset.value.y}px)`
})
&amp;lt;/script&amp;gt;

&amp;lt;style lang=&quot;scss&quot; scoped&amp;gt;
.office-viewer {
  position: relative;
  width: 100%;
  height: 100%;
  background: transparent;
  border-radius: 4px;
  overflow: hidden;
  box-sizing: border-box;
  cursor: grab;
  user-select: none;
  overflow-y: auto;
  scrollbar-width: none;
  &amp;amp;:active {
    cursor: grabbing;
  }

  &amp;amp;.dragging {
    cursor: grabbing;
  }

  &amp;amp;.zoomable {
    cursor: grab;

    &amp;amp;:hover {
      cursor: grab;
    }
  }

  &amp;amp;:not(.zoomable) {
    cursor: default;
  }

  // 确保所有子元素都使用border-box
  * {
    box-sizing: border-box;
  }

  .img_video_box{
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: rgba(0, 0, 0, .5);
  }

  // 缩放提示样式
  .zoom-tip {
    position: absolute;
    top: 20px;
    right: 20px;
    background: rgba(0, 0, 0, 0.8);
    color: white;
    padding: 8px 12px;
    border-radius: 4px;
    font-size: 12px;
    z-index: 1001;
    pointer-events: none;
    transition: opacity 0.3s ease;

    span {
      display: block;
      font-weight: 500;
      margin-bottom: 2px;
    }

    small {
      opacity: 0.8;
      font-size: 10px;
    }
  }

  // 加载状态样式
  .loading-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: transparent !important;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;

    .loading-spinner {
      text-align: center;
      color: #409eff;

      i {
        font-size: 32px;
        margin-bottom: 10px;
        animation: rotate 2s linear infinite;
      }

      p {
        margin: 0;
        font-size: 14px;
        letter-spacing: 5px;
        color: #f7f8fb;
      }
    }
  }

  // 错误状态样式
  .error-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: transparent !important;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;

    .error-message {
      text-align: center;
      color: #f56c6c;

      i {
        font-size: 48px;
        margin-bottom: 16px;
        display: block;
      }

      p {
        margin: 8px 0;
        font-size: 14px;
        color: #f7f8fb;

        &amp;amp;:first-of-type {
          font-size: 16px;
          font-weight: 500;
          color: #f56c6c;
        }
      }

      .retry-btn {
        margin-top: 16px;
        padding: 8px 16px;
        background: #409eff;
        color: white;
        border: none;
        border-radius: 4px;
        cursor: pointer;
        font-size: 14px;
        transition: background-color 0.3s;

        &amp;amp;:hover {
          background: #66b1ff;
        }
      }
    }
  }

  // 不支持的文件类型样式
  .unsupported-type {
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, .5);

    .error-message {
      text-align: center;
      color: #e6a23c;

      i {
        font-size: 48px;
        margin-bottom: 16px;
        display: block;
      }

      p {
        margin: 8px 0;
        font-size: 14px;
        color: rgb(241, 241, 241, .7);

        &amp;amp;:first-of-type {
          font-size: 16px;
          font-weight: 500;
          color: #e6a23c;
        }
      }
    }
  }

  .close-btn{
    position: absolute;
    top: 20px;
    left: 20px;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.5);
    color: white;
    border-radius: 50%;
    font-size: 20px;
    z-index: 1001;
    transition: all 0.2s linear;
    cursor: pointer;
  }
  .close-btn:hover{
    background: rgba(0, 0, 0, 0.3);
  }
}

// 旋转动画
@keyframes rotate {
  from {
    transform: rotate(0deg);
  }
  to {
    transform: rotate(360deg);
  }
}

// pdf
::v-deep .vue-office-pdf-wrapper{
  background: transparent !important;
  scrollbar-width: none !important;
  padding: 20px !important;
  transform: v-bind(getTransform);
}
:deep(.vue-office-pdf) {
  background: rgba(0, 0, 0, .5) !important;
}

// excel
:deep(.vue-office-excel) {
  padding: 20px !important;
  background: rgba(0, 0, 0, .5) !important;
  scrollbar-width: none !important;
}
:deep(.vue-office-excel-main){
    width: 100% !important;
    height: 100% !important;
    overflow: auto !important;
    transform: v-bind(getTransform);
}

// word
:deep(.vue-office-docx) {
  width: 100% !important;
  height: 100% !important;
  background: rgba(0, 0, 0, .5) !important;
}
:deep(.docx-wrapper) {
 background: transparent !important;
 padding: 20px !important;
 transform: v-bind(getTransform);
}

// ppt 
::v-deep .vue-office-pptx{
  scrollbar-width: none !important;
  padding: 20px !important;
  scrollbar-width: none !important;
  background: rgba(0, 0, 0, .5) !important;
}
:deep(.pptx-preview-wrapper){
    transform: v-bind(getTransform);
    background: transparent !important;
}
&amp;lt;/style&amp;gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;/body&gt;</description><pubDate>Tue, 25 Nov 2025 15:04:43 +0800</pubDate></item><item><title>从文件名中提取文件类型后缀</title><link>https://blog.smallhao.fun/?id=43</link><description>&lt;head&gt;&lt;/head&gt;&lt;body&gt;&lt;h3 id=&quot;h3-u4EE3u7801-1&quot;&gt;&lt;a class=&quot;reference-link&quot; name=&quot;代码&quot;&gt;&lt;/a&gt;&lt;span class=&quot;header-link octicon octicon-link&quot;&gt;&lt;/span&gt;代码&lt;/h3&gt;&lt;pre&gt;&lt;code class=&quot;language-js&quot;&gt;/**
 * 从文件名中提取文件类型后缀
 * @param {string} fileName - 文件名（含后缀）
 * @returns {string} - 文件后缀（小写，无`.`；若无后缀返回空字符串）
 */
function getFileExtension(fileName) {
  // 校验参数：非字符串或空字符串直接返回空
  if (typeof fileName !== &#039;string&#039; || fileName.trim() === &#039;&#039;) {
    return &#039;&#039;;
  }

  // 找到最后一个点的索引
  const lastDotIndex = fileName.lastIndexOf(&#039;.&#039;);
  // 处理特殊情况：点在开头（如`.gitignore`）或无点，返回空
  if (lastDotIndex === -1 || lastDotIndex === 0) {
    return &#039;&#039;;
  }

  // 截取后缀并转为小写（统一格式，避免PNG/png混用）
  const extension = fileName.slice(lastDotIndex + 1).toLowerCase();
  return extension;
}
&lt;/code&gt;&lt;/pre&gt;
&lt;h3 id=&quot;h3-u6D4Bu8BD5-27&quot;&gt;&lt;a class=&quot;reference-link&quot; name=&quot;测试&quot;&gt;&lt;/a&gt;&lt;span class=&quot;header-link octicon octicon-link&quot;&gt;&lt;/span&gt;测试&lt;/h3&gt;&lt;pre&gt;&lt;code class=&quot;language-js&quot;&gt;// 测试示例
const fileName = &#039;3d49ffb0-ba4f-43ae-9b08-8aa9411db43d.png&#039;;
const extension = getFileExtension(fileName);
console.log(&#039;文件后缀：&#039;, extension); // 输出：png

// 更多测试用例
console.log(getFileExtension(&#039;document.pdf&#039;)); // pdf
console.log(getFileExtension(&#039;image.tar.gz&#039;)); // gz（处理多后缀，取最后一个）
console.log(getFileExtension(&#039;.env&#039;)); // 空（点在开头）
console.log(getFileExtension(&#039;无后缀文件&#039;)); // 空
console.log(getFileExtension(&#039;file.name.with.many.dots.jpg&#039;)); // jpg
&lt;/code&gt;&lt;/pre&gt;
&lt;/body&gt;</description><pubDate>Fri, 21 Nov 2025 10:18:18 +0800</pubDate></item><item><title>免费API</title><link>https://blog.smallhao.fun/?id=42</link><description>&lt;head&gt;&lt;/head&gt;&lt;body&gt;&lt;blockquote&gt;&lt;p&gt;获取图片&lt;br&gt;700 : 宽度；400高度&lt;br&gt;&lt;a href=&quot;https://loremflickr.com/700/400&quot;&gt;https://loremflickr.com/700/400&lt;/a&gt;&lt;/p&gt;
&lt;/blockquote&gt;&lt;pre&gt;&lt;code class=&quot;language-js&quot;&gt;/**
    * 将 Base64 字符串转换为 Blob 对象
    * @param {string} base64String - 完整的 Base64 字符串（含前缀）
    * @param {string} mimeType - 文件类型（如 &#039;image/png&#039;，可选，默认从 Base64 前缀提取）
    * @returns {Blob} 转换后的 Blob 对象
    */
    base64ToBlob(base64String, mimeType) {
      // 提取 Base64 数据部分（去除前缀）
      const base64Data = base64String.split(&#039;,&#039;)[1];
      // 解码 Base64 为二进制字符串
      const byteCharacters = atob(base64Data);
      // 转换为 Uint8Array 二进制数组
      const byteNumbers = new Array(byteCharacters.length);
      for (let i = 0; i &amp;lt; byteCharacters.length; i++) {
        byteNumbers[i] = byteCharacters.charCodeAt(i);
      }
      const byteArray = new Uint8Array(byteNumbers);

      // 确定 MIME 类型（优先使用传入的，否则从 Base64 前缀提取）
      const type = mimeType || base64String.split(&#039;;&#039;)[0].split(&#039;:&#039;)[1];
      
      // 生成 Blob 对象（可直接作为文件使用）
      return new Blob([byteArray], { type });
    },
&lt;/code&gt;&lt;/pre&gt;
&lt;/body&gt;</description><pubDate>Fri, 14 Nov 2025 10:24:22 +0800</pubDate></item><item><title>Canvas 绘制荣誉证书等（下载、自定义）</title><link>https://blog.smallhao.fun/?id=41</link><description>&lt;head&gt;&lt;/head&gt;&lt;body&gt;&lt;h3 id=&quot;h3-u4EE3u7801-1&quot;&gt;&lt;a class=&quot;reference-link&quot; name=&quot;代码&quot;&gt;&lt;/a&gt;&lt;span class=&quot;header-link octicon octicon-link&quot;&gt;&lt;/span&gt;代码&lt;/h3&gt;&lt;pre&gt;&lt;code class=&quot;language-js&quot;&gt;/**
 * Canvas图片生成器类（增强版）
 * 支持百分比坐标、元素宽度控制、CSS样式配置和高级文本布局
 * 支持多个内容模块循环渲染，类似Vue插槽的默认配置机制
 */
/**
 * Canvas图片生成器类（增强版）
 * 支持基于文本精确高度的自动定位
 */
class CanvasImageGenerator {
    /**
     * 构造函数
     * @param {Object} options 配置选项
     */
    constructor(options) {
        // 默认配置
        options = options || {};
        this.config = {
            width: 800,
            height: 500,
            backgroundColor: &#039;#3498db&#039;,
            backgroundPadding: 0 // 背景图片内边距
        };
        // 合并选项
        if (options.width !== undefined) this.config.width = options.width;
        if (options.height !== undefined) this.config.height = options.height;
        if (options.backgroundColor !== undefined) this.config.backgroundColor = options.backgroundColor;
        if (options.backgroundPadding !== undefined) this.config.backgroundPadding = options.backgroundPadding;
        
        // 创建Canvas元素
        this.canvas = document.createElement(&#039;canvas&#039;);
        this.canvas.width = this.config.width;
        this.canvas.height = this.config.height;
        this.ctx = this.canvas.getContext(&#039;2d&#039;);
        
        // 文字元素默认配置模板
        this.elementTemplates = {
            title: {
                text: &#039;结业证书&#039;,
                fontFamily: &#039;Arial, &quot;Microsoft YaHei&quot;, sans-serif&#039;,
                fontSize: 32,
                color: &#039;#ff6b6b&#039;,
                x: &#039;10%&#039;,
                y: &#039;28%&#039;,
                width: &#039;80%&#039;,
                bold: true,
                italic: false,
                shadow: false,
                textAlign: &#039;center&#039;,
                textBaseline: &#039;middle&#039;,
                overflow: &#039;wrap&#039;,
                lineHeight: 1.2,
                padding: 0,
                maxLines: 0,
                whiteSpace: &#039;normal&#039;,
                textIndent: 0,
                letterSpacing: 0,
                wordSpacing: &#039;50px&#039;,
                textAlignLast: &#039;start&#039;,
                enabled: true
            },
            content: {
                text: &#039;请在此处填写证书内容...&#039;,
                fontFamily: &#039;Arial, &quot;SimSun&quot;, sans-serif&#039;,
                fontSize: 18,
                color: &#039;#333&#039;,
                x: &#039;15%&#039;,
                y: &#039;33%&#039;,
                width: &#039;70%&#039;,
                bold: false,
                italic: false,
                shadow: false,
                textAlign: &#039;justify&#039;,
                textBaseline: &#039;top&#039;,
                overflow: &#039;wrap&#039;,
                lineHeight: 1.5,
                padding: 0,
                maxLines: 0,
                whiteSpace: &#039;normal&#039;,
                textIndent: 36,
                letterSpacing: 0,
                wordSpacing: 0,
                textAlignLast: &#039;start&#039;,
                enabled: true,
                autoPosition: true // 默认启用自动定位
            },
            date: {
                text: &#039;2023年1月1日&#039;,
                fontFamily: &#039;Arial, &quot;Microsoft YaHei&quot;, sans-serif&#039;,
                fontSize: 14,
                color: &#039;#666&#039;,
                x: &#039;60%&#039;,
                y: &#039;80%&#039;,
                width: &#039;40%&#039;,
                bold: false,
                italic: false,
                shadow: false,
                textAlign: &#039;left&#039;,
                textBaseline: &#039;middle&#039;,
                overflow: &#039;ellipsis&#039;,
                lineHeight: 1.2,
                padding: 0,
                maxLines: 1,
                whiteSpace: &#039;nowrap&#039;,
                textIndent: 0,
                letterSpacing: 0,
                wordSpacing: 0,
                textAlignLast: &#039;start&#039;,
                enabled: true
            },
            unit: {
                text: &#039;某某机构&#039;,
                fontFamily: &#039;Arial, &quot;Microsoft YaHei&quot;, sans-serif&#039;,
                fontSize: 14,
                color: &#039;#666&#039;,
                x: &#039;60%&#039;,
                y: &#039;75%&#039;,
                width: &#039;40%&#039;,
                bold: false,
                italic: false,
                shadow: false,
                textAlign: &#039;left&#039;,
                textBaseline: &#039;middle&#039;,
                overflow: &#039;ellipsis&#039;,
                lineHeight: 1.2,
                padding: 0,
                maxLines: 1,
                whiteSpace: &#039;nowrap&#039;,
                textIndent: 0,
                letterSpacing: 0,
                wordSpacing: 0,
                textAlignLast: &#039;start&#039;,
                enabled: true
            },
            certificateNo: {
                text: &#039;NO.20230001&#039;,
                fontFamily: &#039;Arial, &quot;Microsoft YaHei&quot;, sans-serif&#039;,
                fontSize: 14,
                color: &#039;#666&#039;,
                x: &#039;17%&#039;,
                y: &#039;80%&#039;,
                width: &#039;50%&#039;,
                bold: false,
                italic: false,
                shadow: false,
                textAlign: &#039;left&#039;,
                textBaseline: &#039;middle&#039;,
                overflow: &#039;ellipsis&#039;,
                lineHeight: 1.2,
                padding: 0,
                maxLines: 1,
                whiteSpace: &#039;nowrap&#039;,
                textIndent: 0,
                letterSpacing: 1,
                wordSpacing: 0,
                textAlignLast: &#039;start&#039;,
                enabled: true
            }
        };

        // 当前激活的元素配置
        this.elements = {};
        
        // 文本测量缓存
        this._textWidthCache = new Map();
        // 字体特性缓存
        this._fontMetricsCache = new Map();
    }
    
    /**
     * 生成图片（支持多个内容模块）
     * @param {Object} params 生成参数
     * @returns {Promise&amp;lt;string&amp;gt;} 图片DataURL
     */
    async generate(params) {
        try {
            // 合并参数
            params = params || {};
            const background = params.background;
            const title = params.title;
            const content = params.content;
            const date = params.date;
            const unit = params.unit;
            const certificateNo = params.certificateNo;
            const contents = params.contents || [];
            
            // 更新配置
            if (params.width) this.config.width = params.width;
            if (params.height) this.config.height = params.height;
            if (params.backgroundColor) this.config.backgroundColor = params.backgroundColor;
            if (params.backgroundPadding !== undefined) this.config.backgroundPadding = params.backgroundPadding;
            
            // 更新Canvas尺寸
            this.canvas.width = this.config.width;
            this.canvas.height = this.config.height;
            
            // 重置元素配置
            this.elements = {};
            
            // 处理单个元素配置
            if (title) this.addElement(&#039;title&#039;, title);
            if (content) this.addElement(&#039;content&#039;, content);
            if (date) this.addElement(&#039;date&#039;, date);
            if (unit) this.addElement(&#039;unit&#039;, unit);
            if (certificateNo) this.addElement(&#039;certificateNo&#039;, certificateNo);
            
            // 处理多个内容模块（核心改进：基于精确高度的自动定位）
            if (contents &amp;amp;&amp;amp; contents.length &amp;gt; 0) {
                this.processMultipleContents(contents);
            }
            
            // 绘制
            await this.drawBackground(background);
            this.drawAllElements();
            
            return this.canvas.toDataURL(&#039;image/png&#039;);
        } catch (error) {
            console.error(&#039;生成图片时出错:&#039;, error);
            throw error;
        }
    }
    
    /**
     * 处理多个内容模块（基于内容高度的智能定位）
     * @param {Array} contents 内容模块数组
     */
    processMultipleContents(contents) {
        // 计算起始Y位置（考虑顶部内容的高度）
        let currentY = this.calculateInitialYPosition();
        
        contents.forEach((contentConfig, index) =&amp;gt; {
            const elementKey = `content_${index}`;
            
            // 合并默认配置和自定义配置
            const mergedConfig = this.mergeWithTemplate(&#039;content&#039;, contentConfig);
            
            // 仅对启用自动定位的模块进行位置计算
            if (mergedConfig.autoPosition) {
                // 设置当前内容模块的位置为当前Y坐标
                mergedConfig.y = `${currentY}%`;
                
                // 计算当前内容模块的精确高度
                const contentHeight = this.calculateExactContentHeight(mergedConfig);
                
                // 累加当前模块高度和间距作为下一个模块的起始位置
                currentY += contentHeight + 3; // 3% 的间距
                console.log(`内容模块${index + 1} - Y位置: ${mergedConfig.y}, 高度: ${contentHeight}%, 下一模块起始Y: ${currentY}%`);
            } else {
                // 不启用自动定位时，保持原有Y坐标，但仍需计算其高度用于后续模块
                const contentHeight = this.calculateExactContentHeight(mergedConfig);
                currentY = parseFloat(mergedConfig.y) + contentHeight + 3;
                console.log(`内容模块${index + 1} (不自动定位) - Y位置: ${mergedConfig.y}, 高度: ${contentHeight}%, 下一模块起始Y: ${currentY}%`);
            }
            
            this.elements[elementKey] = mergedConfig;
        });
    }
    
    /**
     * 计算初始Y位置（考虑标题等顶部元素的高度）
     * @returns {number} 初始Y位置百分比
     */
    calculateInitialYPosition() {
        // 如果有标题元素，从标题下方开始
        if (this.elements.title &amp;amp;&amp;amp; this.elements.title.enabled) {
            const titleHeight = this.calculateExactContentHeight(this.elements.title);
            const titleY = parseFloat(this.elements.title.y);
            return titleY + titleHeight + 3; // 标题Y坐标 + 标题高度 + 3%间距
        }
        return 35; // 默认起始位置
    }
    
    /**
     * 计算内容模块的精确高度（修复首行缩进和高度计算问题）
     * @param {Object} config 内容配置
     * @returns {number} 高度百分比
     */
    calculateExactContentHeight(config) {
        // 保存当前字体设置
        const originalFont = this.ctx.font;
        
        // 设置当前配置的字体
        let fontStyle = &#039;&#039;;
        if (config.bold) fontStyle += &#039;bold &#039;;
        if (config.italic) fontStyle += &#039;italic &#039;;
        const font = `${fontStyle}${config.fontSize}px ${config.fontFamily}`;
        this.ctx.font = font;
        
        // 获取字体度量信息
        const fontMetrics = this.getFontMetrics(font, config.fontSize);
        
        const {
            text,
            lineHeight,
            maxLines,
            width,
            padding,
            textIndent,
            whiteSpace,
            overflow
        } = config;
        
        // 计算实际内容宽度（像素）
        const contentWidth = this.parseValueToPixel(width, &#039;width&#039;) - (padding || 0) * 2;
        
        // 关键修复：计算实际可用宽度时考虑首行缩进
        let firstLineMaxWidth = contentWidth;
        if (textIndent &amp;gt; 0) {
            firstLineMaxWidth = contentWidth - textIndent;
        }
        
        // 分割文本行（使用优化后的分割方法）
        let lines = [];
        let isEllipsisOrClip = overflow === &#039;ellipsis&#039; || overflow === &#039;clip&#039;;
        
        if (whiteSpace === &#039;nowrap&#039; || isEllipsisOrClip) {
            // 不换行、省略号或裁剪模式 - 只处理一行
            lines = [text];
        } else {
            // 按段落分割并使用严格换行逻辑
            const paragraphs = text.split(&#039;\n&#039;);
            paragraphs.forEach((paragraph, paraIndex) =&amp;gt; {
                if (paragraph.trim() === &#039;&#039;) {
                    lines.push(&#039;&#039;);
                    return;
                }
                
                // 处理每个段落，第一个段落的第一行考虑首行缩进
                let isFirstParaFirstLine = paraIndex === 0 &amp;amp;&amp;amp; lines.length === 0;
                let currentLine = &#039;&#039;;
                
                for (let i = 0; i &amp;lt; paragraph.length; i++) {
                    const char = paragraph[i];
                    const testLine = currentLine + char;
                    const currentMaxWidth = isFirstParaFirstLine ? firstLineMaxWidth : contentWidth;
                    const testWidth = this.measureTextWidth(testLine);
                    
                    // 严格截断逻辑：只要超出宽度就立即换行
                    if (testWidth &amp;gt; currentMaxWidth) {
                        if (currentLine) {
                            lines.push(currentLine);
                            currentLine = char;
                        } else {
                            // 即使是单个字符也强制截断（避免极端情况）
                            lines.push(char);
                            currentLine = &#039;&#039;;
                        }
                        // 只有第一段第一行需要首行缩进
                        isFirstParaFirstLine = false;
                    } else {
                        currentLine = testLine;
                    }
                }
                
                if (currentLine) {
                    lines.push(currentLine);
                }
            });
        }
        
        // 限制最大行数
        let actualLines = lines;
        if (maxLines &amp;gt; 0 &amp;amp;&amp;amp; lines.length &amp;gt; maxLines) {
            actualLines = lines.slice(0, maxLines);
            // 最后一行添加省略号（如果需要）
            if (config.overflow === &#039;ellipsis&#039;) {
                const lastLine = actualLines[actualLines.length - 1];
                let truncatedLine = lastLine;
                const currentMaxWidth = actualLines.length === 1 &amp;amp;&amp;amp; textIndent &amp;gt; 0 ? firstLineMaxWidth : contentWidth;
                
                while (truncatedLine.length &amp;gt; 0 &amp;amp;&amp;amp; 
                       this.measureTextWidth(truncatedLine + &#039;...&#039;) &amp;gt; currentMaxWidth) {
                    truncatedLine = truncatedLine.slice(0, -1);
                }
                actualLines[actualLines.length - 1] = truncatedLine + &#039;...&#039;;
            }
        }

        // 确定最终显示的行数
        let finalLineCount = actualLines.length;
        if (whiteSpace === &#039;nowrap&#039; || isEllipsisOrClip) {
            finalLineCount = 1; // 强制单行高度
        }
        
        // 计算总高度（像素）
        const lineHeightPx = config.fontSize * lineHeight;
        const totalContentHeightPx = finalLineCount * lineHeightPx;
        const totalHeightPx = totalContentHeightPx + (padding || 0) * 2;
        
        // 恢复原始字体
        this.ctx.font = originalFont;
        
        // 转换为百分比（相对于画布高度）
        const heightPercent = (totalHeightPx / this.config.height) * 100;
        console.log(`计算高度 - 实际行数: ${actualLines.length}, 显示行数: ${finalLineCount}, 像素高度: ${totalHeightPx}, 百分比高度: ${heightPercent}%`);
        
        return heightPercent;
    }
    
    /**
     * 获取字体度量信息（ ascent, descent, 行高 等）
     * @param {string} font 字体字符串
     * @param {number} fontSize 字体大小
     * @returns {Object} 字体度量信息
     */
    getFontMetrics(font, fontSize) {
        const cacheKey = font;
        
        // 检查缓存
        if (this._fontMetricsCache.has(cacheKey)) {
            return this._fontMetricsCache.get(cacheKey);
        }
        
        // 保存当前状态
        const originalFont = this.ctx.font;
        const originalTextBaseline = this.ctx.textBaseline;
        
        // 设置测量环境
        this.ctx.font = font;
        this.ctx.textBaseline = &#039;top&#039;;
        
        // 创建一个参考文本（使用大写和小写字母以及descender）
        const referenceText = &#039;Hg&#039;;
        const textMetrics = this.ctx.measureText(referenceText);
        
        // 计算 ascent (基线到顶部的距离) 和 descent (基线到底部的距离)
        const ascent = textMetrics.actualBoundingBoxAscent;
        const descent = textMetrics.actualBoundingBoxDescent;
        const lineGap = 0; // 简化计算
        
        // 恢复原始状态
        this.ctx.font = originalFont;
        this.ctx.textBaseline = originalTextBaseline;
        
        // 计算实际行高
        const actualLineHeight = ascent + descent + lineGap;
        
        // 缓存结果
        const metrics = {
            ascent,
            descent,
            lineGap,
            actualLineHeight,
            fontSize
        };
        this._fontMetricsCache.set(cacheKey, metrics);
        
        return metrics;
    }
    
    /**
     * 添加元素（合并默认配置和自定义配置）
     * @param {string} elementName 元素名称
     * @param {Object} customConfig 自定义配置
     */
    addElement(elementName, customConfig) {
        if (!customConfig || !customConfig.text) {
            return;
        }
        
        const mergedConfig = this.mergeWithTemplate(elementName, customConfig);
        this.elements[elementName] = mergedConfig;
    }
    
    /**
     * 合并默认配置和自定义配置
     * @param {string} elementName 元素名称
     * @param {Object} customConfig 自定义配置
     * @returns {Object} 合并后的配置
     */
    mergeWithTemplate(elementName, customConfig) {
        const template = this.elementTemplates[elementName];
        if (!template) {
            return Object.assign({}, customConfig);
        }
        
        const merged = Object.assign({}, template, customConfig);
        merged.enabled = customConfig.enabled !== undefined ? customConfig.enabled : template.enabled;
        merged.autoPosition = customConfig.autoPosition !== undefined ? customConfig.autoPosition : template.autoPosition;
        return merged;
    }
    
    /**
     * 将值转换为像素值（支持百分比）
     * @param {string|number} value 值
     * @param {string} dimension 维度（&#039;width&#039; 或 &#039;height&#039;）
     * @returns {number} 像素值
     */
    parseValueToPixel(value, dimension) {
        dimension = dimension || &#039;width&#039;;
        if (typeof value === &#039;string&#039; &amp;amp;&amp;amp; value.includes(&#039;%&#039;)) {
            const percent = parseFloat(value) / 100;
            if (dimension === &#039;width&#039;) {
                return this.config.width * percent;
            } else {
                return this.config.height * percent;
            }
        }
        return parseFloat(value) || 0;
    }
    
    /**
     * 获取元素的实际像素坐标和尺寸
     * @param {Object} element 元素配置
     * @returns {Object} 包含位置和尺寸的对象
     */
    getElementLayout(element) {
        const x = this.parseValueToPixel(element.x, &#039;width&#039;);
        const y = this.parseValueToPixel(element.y, &#039;height&#039;);
        const width = this.parseValueToPixel(element.width, &#039;width&#039;);
        const padding = element.padding || 0;
        
        return {
            x,
            y,
            width,
            padding,
            contentWidth: width - padding * 2,
            startX: this.getTextStartX(x, width, element.textAlign, padding),
            // 计算首行缩进后的起始X
            firstLineStartX: element.textIndent ? this.getTextStartX(x, width, element.textAlign, padding) + element.textIndent : this.getTextStartX(x, width, element.textAlign, padding)
        };
    }
    
    /**
     * 根据对齐方式获取文本起始X坐标
     * @param {number} x 元素X坐标
     * @param {number} width 元素宽度
     * @param {string} textAlign 文本对齐方式
     * @param {number} padding 内边距
     * @returns {number} 文本起始X坐标
     */
    getTextStartX(x, width, textAlign, padding) {
        padding = padding || 0;
        switch (textAlign) {
            case &#039;left&#039;:
                return x + padding;
            case &#039;right&#039;:
                return x + width - padding;
            case &#039;center&#039;:
            default:
                return x + width / 2;
        }
    }
    
    /**
     * 绘制背景
     * @param {string|HTMLImageElement} background 背景图片
     */
    async drawBackground(background) {
        this.ctx.clearRect(0, 0, this.config.width, this.config.height);
        
        if (background) {
            try {
                const image = await this.loadImage(background);
                const padding = this.config.backgroundPadding || 0;
                const availableWidth = this.config.width - padding * 2;
                const availableHeight = this.config.height - padding * 2;
                
                const scale = Math.min(
                    availableWidth / image.width, 
                    availableHeight / image.height
                );
                
                const scaledWidth = image.width * scale;
                const scaledHeight = image.height * scale;
                const x = padding + (availableWidth - scaledWidth) / 2;
                const y = padding + (availableHeight - scaledHeight) / 2;
                
                this.ctx.drawImage(image, x, y, scaledWidth, scaledHeight);
            } catch (error) {
                console.warn(&#039;背景图片加载失败，使用背景颜色:&#039;, error);
                this.drawColorBackground();
            }
        } else {
            this.drawColorBackground();
        }
    }
    
    /**
     * 绘制颜色背景
     */
    drawColorBackground() {
        this.ctx.fillStyle = this.config.backgroundColor;
        this.ctx.fillRect(0, 0, this.config.width, this.config.height);
    }
    
    /**
     * 加载图片
     * @param {string|HTMLImageElement} source 图片源
     * @returns {Promise&amp;lt;HTMLImageElement&amp;gt;}
     */
    loadImage(source) {
        return new Promise((resolve, reject) =&amp;gt; {
            if (typeof source === &#039;string&#039;) {
                const img = new Image();
                img.crossOrigin = &#039;anonymous&#039;;
                img.onload = () =&amp;gt; resolve(img);
                img.onerror = reject;
                img.src = source;
            } else if (source instanceof HTMLImageElement) {
                if (source.complete) {
                    resolve(source);
                } else {
                    source.onload = () =&amp;gt; resolve(source);
                    source.onerror = reject;
                }
            } else {
                reject(new Error(&#039;不支持的图片源类型&#039;));
            }
        });
    }
    
    /**
     * 绘制所有元素
     */
    drawAllElements() {
        Object.keys(this.elements).forEach(elementName =&amp;gt; {
            const element = this.elements[elementName];
            if (element.enabled !== false &amp;amp;&amp;amp; element.text) {
                this.drawElement(element);
            }
        });
    }
    
    /**
     * 绘制单个元素
     * @param {Object} element 元素配置
     */
    drawElement(element) {
        if (!element.text) return;
        
        // 获取布局信息
        const layout = this.getElementLayout(element);
        
        // 构建字体字符串
        let fontStyle = &#039;&#039;;
        if (element.bold) fontStyle += &#039;bold &#039;;
        if (element.italic) fontStyle += &#039;italic &#039;;
        
        this.ctx.font = `${fontStyle}${element.fontSize}px ${element.fontFamily}`;
        this.ctx.fillStyle = element.color;
        this.ctx.textBaseline = element.textBaseline;
        
        // 设置阴影
        if (element.shadow) {
            this.ctx.shadowColor = &#039;rgba(0, 0, 0, 0.5)&#039;;
            this.ctx.shadowBlur = 5;
            this.ctx.shadowOffsetX = 2;
            this.ctx.shadowOffsetY = 2;
        } else {
            this.ctx.shadowColor = &#039;transparent&#039;;
            this.ctx.shadowBlur = 0;
            this.ctx.shadowOffsetX = 0;
            this.ctx.shadowOffsetY = 0;
        }
        
        // 根据overflow策略绘制文本
        switch (element.overflow) {
            case &#039;ellipsis&#039;:
                this.drawTextWithEllipsis(element, layout);
                break;
            case &#039;clip&#039;:
                this.drawTextWithClip(element, layout);
                break;
            case &#039;wrap&#039;:
            default:
                this.drawTextWithWrap(element, layout);
                break;
        }
        
        // 重置阴影
        this.ctx.shadowColor = &#039;transparent&#039;;
        this.ctx.shadowBlur = 0;
        this.ctx.shadowOffsetX = 0;
        this.ctx.shadowOffsetY = 0;
    }
    
    /**
     * 测量文本宽度（缓存优化）
     * @param {string} text 文本
     * @returns {number} 文本宽度
     */
    measureTextWidth(text) {
        const cacheKey = `${this.ctx.font}|${text}`;
        if (this._textWidthCache.has(cacheKey)) {
            return this._textWidthCache.get(cacheKey);
        }
        
        const width = this.ctx.measureText(text).width;
        this._textWidthCache.set(cacheKey, width);
        return width;
    }
    
    /**
     * 绘制自动换行文本
     * @param {Object} element 元素配置
     * @param {Object} layout 布局信息
     */
    drawTextWithWrap(element, layout) {
        const { 
            text, 
            fontSize, 
            lineHeight, 
            maxLines, 
            textBaseline, 
            textAlign, 
            textIndent,
            textAlignLast,
            whiteSpace
        } = element;
        
        const { contentWidth, y, padding, x } = layout;
        
        let lines = [];
        
        if (whiteSpace === &#039;nowrap&#039;) {
            lines = text.split(&#039;\n&#039;);
        } else {
            lines = this.splitTextToLines(text, contentWidth, element);
        }
        
        // 限制最大行数
        if (maxLines &amp;gt; 0 &amp;amp;&amp;amp; lines.length &amp;gt; maxLines) {
            lines = lines.slice(0, maxLines);
            if (lines.length &amp;gt; 0) {
                const lastLine = lines[lines.length - 1];
                let truncatedLine = lastLine;
                const currentMaxWidth = lines.length === 1 &amp;amp;&amp;amp; textIndent &amp;gt; 0 ? contentWidth - textIndent : contentWidth;
                
                while (truncatedLine.length &amp;gt; 0 &amp;amp;&amp;amp; 
                       this.measureTextWidth(truncatedLine + &#039;...&#039;) &amp;gt; currentMaxWidth) {
                    truncatedLine = truncatedLine.slice(0, -1);
                }
                lines[lines.length - 1] = truncatedLine + &#039;...&#039;;
            }
        }
        
        const lineHeightPx = fontSize * lineHeight;
        let startY = y + padding;
        
        // 根据文本基线调整起始位置
        switch (textBaseline) {
            case &#039;middle&#039;:
                startY -= (lines.length * lineHeightPx) / 2;
                break;
            case &#039;bottom&#039;:
                startY -= lines.length * lineHeightPx;
                break;
            case &#039;top&#039;:
            default:
                break;
        }
        
        // 绘制每一行
        lines.forEach((line, index) =&amp;gt; {
            const isLastLine = index === lines.length - 1;
            
            // 计算每行的起始X坐标
            let lineStartX = x + padding;
            let lineContentWidth = contentWidth;
            
            // 首行缩进处理
            if (index === 0 &amp;amp;&amp;amp; textIndent &amp;gt; 0) {
                if (textAlign === &#039;left&#039; || textAlign === &#039;justify&#039;) {
                    lineStartX += textIndent;
                    lineContentWidth -= textIndent;
                }
            }
            
            // 根据对齐方式绘制文本
            if (textAlign === &#039;justify&#039; &amp;amp;&amp;amp; !isLastLine &amp;amp;&amp;amp; line.trim()) {
                this.drawJustifiedText(line, lineStartX, startY + index * lineHeightPx, lineContentWidth);
            } else {
                const currentAlign = (textAlign === &#039;justify&#039; &amp;amp;&amp;amp; isLastLine) ? textAlignLast : textAlign;
                this.drawAlignedText(line, lineStartX, startY + index * lineHeightPx, lineContentWidth, currentAlign);
            }
        });
    }
    
    /**
     * 绘制对齐文本
     * @param {string} text 文本
     * @param {number} x 起始X坐标
     * @param {number} y Y坐标
     * @param {number} maxWidth 最大宽度
     * @param {string} align 对齐方式
     */
    drawAlignedText(text, x, y, maxWidth, align) {
        const originalAlign = this.ctx.textAlign;
        
        switch (align) {
            case &#039;left&#039;:
            case &#039;start&#039;:
                this.ctx.textAlign = &#039;left&#039;;
                this.ctx.fillText(text, x, y);
                break;
            case &#039;right&#039;:
            case &#039;end&#039;:
                this.ctx.textAlign = &#039;right&#039;;
                this.ctx.fillText(text, x + maxWidth, y);
                break;
            case &#039;center&#039;:
                this.ctx.textAlign = &#039;center&#039;;
                this.ctx.fillText(text, x + maxWidth / 2, y);
                break;
            default:
                this.ctx.textAlign = &#039;left&#039;;
                this.ctx.fillText(text, x, y);
        }
        
        this.ctx.textAlign = originalAlign;
    }
    
    /**
     * 绘制两端对齐的文本
     * @param {string} text 文本
     * @param {number} x 起始X坐标
     * @param {number} y Y坐标
     * @param {number} maxWidth 最大宽度
     */
    drawJustifiedText(text, x, y, maxWidth) {
        const words = text.split(/(\s+)/).filter(word =&amp;gt; word.trim() !== &#039;&#039;);
        if (words.length &amp;lt;= 1) {
            this.ctx.textAlign = &#039;left&#039;;
            this.ctx.fillText(text, x, y);
            return;
        }
        
        // 计算非空格字符总宽度
        let contentWidth = 0;
        let spaceCount = 0;
        for (const word of words) {
            if (word.trim() === &#039;&#039;) {
                spaceCount++;
            } else {
                contentWidth += this.measureTextWidth(word);
            }
        }
        
        // 计算需要分配的空格总宽度
        const totalSpaceWidth = maxWidth - contentWidth;
        const spaceWidth = spaceCount &amp;gt; 0 ? totalSpaceWidth / spaceCount : 0;
        
        let currentX = x;
        
        // 绘制每个部分
        this.ctx.textAlign = &#039;left&#039;;
        for (let i = 0; i &amp;lt; words.length; i++) {
            const word = words[i];
            if (word.trim() === &#039;&#039;) {
                currentX += spaceWidth;
            } else {
                this.ctx.fillText(word, currentX, y);
                currentX += this.measureTextWidth(word);
            }
        }
    }
    
    /**
     * 绘制省略号文本（修复首行缩进问题）
     * @param {Object} element 元素配置
     * @param {Object} layout 布局信息
     */
    drawTextWithEllipsis(element, layout) {
        const { text, textIndent, textAlign } = element;
        const { contentWidth, y, firstLineStartX } = layout;
        
        // 计算实际可用宽度（考虑首行缩进）
        const availableWidth = textIndent &amp;gt; 0 ? contentWidth - textIndent : contentWidth;
        
        let displayText = text;
        const ellipsis = &#039;...&#039;;
        const ellipsisWidth = this.measureTextWidth(ellipsis);
        
        if (this.measureTextWidth(text) &amp;gt; availableWidth) {
            let truncatedText = text;
            while (truncatedText.length &amp;gt; 0 &amp;amp;&amp;amp; 
                   this.measureTextWidth(truncatedText + ellipsis) &amp;gt; availableWidth) {
                truncatedText = truncatedText.slice(0, -1);
            }
            displayText = truncatedText + ellipsis;
        }
        
        // 使用考虑首行缩进的起始X坐标
        this.ctx.textAlign = textAlign === &#039;left&#039; ? &#039;left&#039; : this.ctx.textAlign;
        this.ctx.fillText(displayText, firstLineStartX, y);
    }
    
    /**
     * 绘制裁剪文本（修复首行缩进问题）
     * @param {Object} element 元素配置
     * @param {Object} layout 布局信息
     */
    drawTextWithClip(element, layout) {
        const { text, textIndent, fontSize } = element;
        const { x, y, width, padding, firstLineStartX } = layout;
        
        // 计算裁剪区域（考虑首行缩进）
        const clipWidth = textIndent &amp;gt; 0 ? width - padding * 2 - textIndent : width - padding * 2;
        const clipX = textIndent &amp;gt; 0 ? x + padding + textIndent : x + padding;
        
        this.ctx.save();
        this.ctx.beginPath();
        this.ctx.rect(clipX, y - padding, clipWidth, fontSize * 2);
        this.ctx.clip();
        this.ctx.textAlign = &#039;left&#039;;
        this.ctx.fillText(text, firstLineStartX, y);
        this.ctx.restore();
    }
    
    /**
     * 分割文本为适合宽度的行（严格按宽度截断，不考虑字符类型）
     * @param {string} text 文本
     * @param {number} maxWidth 最大宽度
     * @param {Object} element 元素配置
     * @returns {string[]} 分割后的行数组
     */
    splitTextToLines(text, maxWidth, element) {
        const paragraphs = text.split(&#039;\n&#039;);
        const lines = [];
        const textIndent = element.textIndent || 0;
        const firstLineMaxWidth = maxWidth - textIndent;
        const otherLinesMaxWidth = maxWidth;
        
        // 处理每个段落
        paragraphs.forEach((paragraph, paraIndex) =&amp;gt; {
            if (paragraph.trim() === &#039;&#039;) {
                lines.push(&#039;&#039;);
                return;
            }
            
            // 第一个段落的第一行需要考虑首行缩进
            // 修复：使用let声明变量，允许重新赋值
            let isFirstParaFirstLine = paraIndex === 0 &amp;amp;&amp;amp; lines.length === 0;
            let currentLine = &#039;&#039;;
            
            for (let i = 0; i &amp;lt; paragraph.length; i++) {
                const char = paragraph[i];
                const testLine = currentLine + char;
                const currentMaxWidth = isFirstParaFirstLine ? firstLineMaxWidth : otherLinesMaxWidth;
                const testWidth = this.measureTextWidth(testLine);
                
                // 严格判断：只要超出宽度就立即换行
                if (testWidth &amp;gt; currentMaxWidth) {
                    // 如果当前行不为空，添加到结果并开始新行
                    if (currentLine) {
                        lines.push(currentLine);
                        currentLine = char;
                    } else {
                        // 即使是单个字符也强制截断（避免极端情况）
                        lines.push(char);
                        currentLine = &#039;&#039;;
                    }
                    // 只有第一段第一行需要首行缩进
                    isFirstParaFirstLine = false;
                } else {
                    currentLine = testLine;
                }
            }
            
            // 添加剩余内容
            if (currentLine) {
                lines.push(currentLine);
            }
        });
        
        return lines;
    }
    
    // 其他辅助方法
    getElementLayoutInfo(elementName) {
        if (this.elements[elementName]) {
            return this.getElementLayout(this.elements[elementName]);
        }
        return null;
    }
    
    updateElementConfig(elementName, config) {
        if (this.elements[elementName]) {
            this.elements[elementName] = Object.assign({}, this.elements[elementName], config);
        }
    }
    
    setElementTemplate(elementName, templateConfig) {
        if (this.elementTemplates[elementName]) {
            this.elementTemplates[elementName] = Object.assign({}, this.elementTemplates[elementName], templateConfig);
        }
    }
    
    setElementStyle(elementName, style) {
        if (this.elements[elementName]) {
            this.elements[elementName] = Object.assign({}, this.elements[elementName], style);
        }
    }
    
    setElementLayout(elementName, x, y, width) {
        if (this.elements[elementName]) {
            this.elements[elementName].x = x;
            this.elements[elementName].y = y;
            this.elements[elementName].width = width;
        }
    }
    
    setBackgroundPadding(padding) {
        this.config.backgroundPadding = padding;
    }
    
    getCanvas() {
        return this.canvas;
    }
    
    getBlob() {
        return new Promise((resolve) =&amp;gt; {
            this.canvas.toBlob(resolve, &#039;image/png&#039;);
        });
    }
    
    async download(filename) {
        if (!filename) {
            filename = &#039;结业证书_&#039; + new Date().toLocaleString() + &#039;.png&#039;;
        }
        const dataUrl = this.canvas.toDataURL(&#039;image/png&#039;);
        const link = document.createElement(&#039;a&#039;);
        link.download = filename;
        link.href = dataUrl;
        link.click();
    }
    
    setSize(width, height) {
        this.config.width = width;
        this.config.height = height;
        this.canvas.width = width;
        this.canvas.height = height;
    }
    
    previewTextLayout(elementName) {
        if (!this.elements[elementName]) return;
        
        const element = this.elements[elementName];
        const layout = this.getElementLayout(element);
        const testLines = this.splitTextToLines(element.text, layout.contentWidth, element);
        
        console.log(`元素 &quot;${elementName}&quot; 布局信息:`, {
            配置: {
                文本: element.text,
                位置: `${element.x}, ${element.y}`,
                宽度: element.width,
                对齐: element.textAlign,
                最后一行对齐: element.textAlignLast,
                首行缩进: element.textIndent,
                启用状态: element.enabled
            },
            实际像素: {
                x: layout.x,
                y: layout.y,
                宽度: layout.width,
                内容宽度: layout.contentWidth
            },
            文本测量: {
                单行宽度: this.measureTextWidth(element.text),
                分割行数: testLines.length,
                各行内容: testLines
            }
        });
    }
    
    destroy() {
        this.canvas.width = 0;
        this.canvas.height = 0;
        this.ctx = null;
        this.canvas = null;
        this._textWidthCache.clear();
        this._fontMetricsCache.clear();
    }
}

export default CanvasImageGenerator;
&lt;/code&gt;&lt;/pre&gt;
&lt;h3 id=&quot;h3-u4F7Fu7528u65B9u6CD5-1083&quot;&gt;&lt;a class=&quot;reference-link&quot; name=&quot;使用方法&quot;&gt;&lt;/a&gt;&lt;span class=&quot;header-link octicon octicon-link&quot;&gt;&lt;/span&gt;使用方法&lt;/h3&gt;&lt;blockquote&gt;&lt;p&gt;基本使用&lt;/p&gt;
&lt;/blockquote&gt;&lt;pre&gt;&lt;code class=&quot;language-js&quot;&gt;const generator = new CanvasImageGenerator();

// 生成图片
const imageDataUrl = await generator.generate({
    background: &#039;path/to/background.jpg&#039;,
    title: {
        text: &#039;多内容模块示例&#039;
    },
    contents: [
        {
            text: &#039;这是第一个内容模块，包含较短的文本。&#039;,
            fontSize: 20
        },
        {
            text: &#039;这是第二个内容模块，包含较长的文本内容。这个模块会自动计算高度，并基于上一个模块的底部位置进行精确定位，避免内容重叠问题。&#039;,
            fontSize: 18,
            lineHeight: 1.6
        },
        {
            text: &#039;这是第三个内容模块，可以禁用自动定位，使用自定义位置。&#039;,
            autoPosition: false,
            x: &#039;50%&#039;,
            y: &#039;70%&#039;
        }
    ],
    date: {
        text: &#039;2023年10月15日&#039;
    },
    unit: {
        text: &#039;报告单位：技术部&#039;
    }
});

// 在页面上显示
const img = document.createElement(&#039;img&#039;);
img.src = imageDataUrl;
document.body.appendChild(img);
高级使用
javascript
// 创建带初始配置的实例
const generator = new CanvasImageGenerator({
    width: 1000,
    height: 600,
    backgroundColor: &#039;#2c3e50&#039;
});

// 生成图片
const imageDataUrl = await generator.generate({
    background: &#039;https://example.com/background.jpg&#039;,
    title: {
        text: &#039;多内容模块示例&#039;
    },
    contents: [
        {
            text: &#039;这是第一个内容模块，包含较短的文本。&#039;,
            fontSize: 20
        },
        {
            text: &#039;这是第二个内容模块，包含较长的文本内容。这个模块会自动计算高度，并基于上一个模块的底部位置进行精确定位，避免内容重叠问题。&#039;,
            fontSize: 18,
            lineHeight: 1.6
        },
        {
            text: &#039;这是第三个内容模块，可以禁用自动定位，使用自定义位置。&#039;,
            autoPosition: false,
            x: &#039;50%&#039;,
            y: &#039;70%&#039;
        }
    ],
    date: {
        text: &#039;2023年12月31日&#039;,
        fontSize: 24,
        color: &#039;#f1c40f&#039;,
        x: 800,
        y: 500
    },
    unit: {
        text: &#039;编制：市场部&#039;,
        fontSize: 20,
        color: &#039;#f1c40f&#039;,
        x: 800,
        y: 540
    }
});

// 直接下载
await generator.download(&#039;年度报告.png&#039;);
&lt;/code&gt;&lt;/pre&gt;
&lt;blockquote&gt;&lt;p&gt;链式调用模式&lt;/p&gt;
&lt;/blockquote&gt;&lt;pre&gt;&lt;code class=&quot;language-js&quot;&gt;// 可以创建链式调用的包装函数
async function createCustomImage() {
    const generator = new CanvasImageGenerator();
    
    // 设置尺寸
    generator.setSize(1200, 800);
    
    // 生成并下载
    await generator.generate({
        background: &#039;background.jpg&#039;,
        title: { text: &#039;自定义标题&#039;, fontSize: 72 },
        content: { text: &#039;详细内容描述&#039; },
        date: { text: &#039;2024-01-01&#039; },
        unit: { text: &#039;单位：自定义&#039; }
    });
    
    await generator.download(&#039;custom-image.png&#039;);
    
    // 清理资源
    generator.destroy();
}
&lt;/code&gt;&lt;/pre&gt;
&lt;blockquote&gt;&lt;p&gt;在React/Vue中使用&lt;/p&gt;
&lt;/blockquote&gt;&lt;pre&gt;&lt;code class=&quot;language-js&quot;&gt;// React组件中使用


function ImageGeneratorComponent() {
    const generateImage = async () =&amp;gt; {
        const generator = new CanvasImageGenerator();
        
        try {
            const imageUrl = await generator.generate({
                background: &#039;/assets/bg.jpg&#039;,
                title: { text: &#039;React生成的图片&#039; },
                content: { text: &#039;这是在React中生成的图片&#039; },
                date: { text: new Date().toLocaleDateString() },
                unit: { text: &#039;来源：React应用&#039; }
            });
            
            // 更新state或直接使用
            setGeneratedImage(imageUrl);
        } catch (error) {
            console.error(&#039;生成失败:&#039;, error);
        }
    };
    
    return (
        &amp;lt;div&amp;gt;
            &amp;lt;button onClick={generateImage}&amp;gt;生成图片&amp;lt;/button&amp;gt;
            {/* 显示生成的图片 */}
        &amp;lt;/div&amp;gt;
    );
}
&lt;/code&gt;&lt;/pre&gt;
&lt;/body&gt;</description><pubDate>Fri, 14 Nov 2025 08:35:48 +0800</pubDate></item></channel></rss>