diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS new file mode 100644 index 0000000..a5b32b2 --- /dev/null +++ b/.github/CODEOWNERS @@ -0,0 +1,2 @@ +# 默认由仓库维护者审阅所有变更。 +* @Hughhhhcoder diff --git a/.github/ISSUE_TEMPLATE/bug_report.yml b/.github/ISSUE_TEMPLATE/bug_report.yml new file mode 100644 index 0000000..6afef41 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/bug_report.yml @@ -0,0 +1,58 @@ +name: Bug 报告 +description: 报告一个可以稳定复现的问题 +title: "[Bug]: " +labels: + - bug +body: + - type: markdown + attributes: + value: | + 感谢反馈!提交前请先确认问题能在最新线上版本或 `master` 分支复现。 + + - type: input + id: browser + attributes: + label: 浏览器与版本 + placeholder: 例如 Chrome 128 / Safari 18 + validations: + required: true + + - type: input + id: tool + attributes: + label: 受影响的工具或页面 + placeholder: 例如 Markdown 编辑器、二维码工具 + validations: + required: true + + - type: textarea + id: steps + attributes: + label: 复现步骤 + description: 请按顺序写出最小复现路径。 + placeholder: | + 1. 打开…… + 2. 输入…… + 3. 点击…… + validations: + required: true + + - type: textarea + id: expected + attributes: + label: 预期行为 + validations: + required: true + + - type: textarea + id: actual + attributes: + label: 实际行为 + validations: + required: true + + - type: textarea + id: context + attributes: + label: 补充信息 + description: 可以附截图、控制台错误、操作系统或其他上下文。请先移除敏感数据。 diff --git a/.github/ISSUE_TEMPLATE/config.yml b/.github/ISSUE_TEMPLATE/config.yml new file mode 100644 index 0000000..e61d373 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/config.yml @@ -0,0 +1,8 @@ +blank_issues_enabled: true +contact_links: + - name: 在线体验 + url: https://htool.vercel.app/ + about: 先在最新线上版本确认问题是否可以复现。 + - name: 使用文档 + url: https://github.com/Hughhhhcoder/HTooL#快速开始 + about: 查看安装、测试、部署和隐私说明。 diff --git a/.github/ISSUE_TEMPLATE/feature_request.yml b/.github/ISSUE_TEMPLATE/feature_request.yml new file mode 100644 index 0000000..21792b8 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/feature_request.yml @@ -0,0 +1,34 @@ +name: 功能建议 +description: 提议一个能让 HTooL 更有用的改进 +title: "[Feature]: " +labels: + - enhancement +body: + - type: textarea + id: problem + attributes: + label: 要解决的问题 + description: 请描述场景和当前遇到的限制,而不仅是解决方案。 + placeholder: 我在……场景下,需要…… + validations: + required: true + + - type: textarea + id: proposal + attributes: + label: 建议方案 + description: 你希望工具如何工作? + validations: + required: true + + - type: textarea + id: alternatives + attributes: + label: 备选方案 + description: 你尝试过哪些替代做法? + + - type: textarea + id: context + attributes: + label: 补充信息 + description: 可以附示例、草图、截图或相关链接。 diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md new file mode 100644 index 0000000..ab5ef39 --- /dev/null +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -0,0 +1,27 @@ +## 变更摘要 + + + +## 关联 Issue + + + +## 验证方式 + +- [ ] `npm run test:unit` +- [ ] `npm run test:no-gradient` +- [ ] `npm run build` +- [ ] `npm run test:perf-budget` +- [ ] `npm run test:e2e` + +## 检查清单 + +- [ ] 我已检查浅色和暗色模式。 +- [ ] 我已检查移动端布局。 +- [ ] 我已补充或更新了相关测试。 +- [ ] 我没有提交密钥、个人数据或真实用户文件。 +- [ ] 如果涉及 UI,我已附上截图或录屏。 + +## 兼容性与风险 + + diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 0000000..ef16883 --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,12 @@ +version: 2 +updates: + - package-ecosystem: npm + directory: / + schedule: + interval: weekly + open-pull-requests-limit: 5 + + - package-ecosystem: github-actions + directory: / + schedule: + interval: monthly diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..50a155a --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,47 @@ +name: CI + +on: + push: + branches: [master] + pull_request: + branches: [master] + +permissions: + contents: read + +jobs: + verify: + name: Verify + runs-on: ubuntu-latest + timeout-minutes: 15 + + steps: + - name: Checkout + uses: actions/checkout@v5 + + - name: Setup Node.js + uses: actions/setup-node@v5 + with: + node-version: 20 + cache: npm + + - name: Install dependencies + run: npm ci + + - name: Run unit and component tests + run: npm run test:unit + + - name: Check design constraints + run: npm run test:no-gradient + + - name: Build production bundle + run: npm run build + + - name: Check performance budget + run: npm run test:perf-budget + + - name: Install Playwright Chromium + run: npx playwright install --with-deps chromium + + - name: Run end-to-end tests + run: npm run test:e2e diff --git a/CODE_OF_CONDUCT.md b/CODE_OF_CONDUCT.md new file mode 100644 index 0000000..ab2cfa1 --- /dev/null +++ b/CODE_OF_CONDUCT.md @@ -0,0 +1,23 @@ +# 行为准则 + +## 我们的承诺 + +为了营造开放、友善且可持续的协作环境,参与 HTooL 的每个人都应以尊重、善意和专业的方式交流,无论其经验、背景或身份如何。 + +## 可接受的行为 + +- 使用清晰、建设性的语言提出意见; +- 讨论实现、体验和证据,而不是评价个人; +- 接受不同观点,并在有新信息时修正自己的判断; +- 尊重项目维护者和其他贡献者的时间。 + +## 不可接受的行为 + +- 骚扰、歧视、威胁、人身攻击或故意羞辱; +- 发布他人的私人信息; +- 破坏讨论、刷屏、冒充他人或以恶意方式提交内容; +- 任何不适合公开协作环境的行为。 + +## 执行 + +请通过 [维护者主页](https://github.com/Hughhhhcoder) 私下联系维护者,报告违反本准则的行为。维护者会根据事实采取适当措施,并尽可能保护报告者的隐私。 diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 0000000..d3237c7 --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,53 @@ +# 贡献指南 + +感谢你愿意改进 HTooL。小而明确的 Pull Request 更容易被审阅,也更容易保持这个工具箱的稳定和克制。 + +## 开始之前 + +1. 确认 Node.js 版本为 20 或更高版本。 +2. 安装依赖:`npm ci`。 +3. 启动开发环境:`npm run dev`。 +4. 对行为变更先搜索现有 Issue,避免重复工作。 + +## 开发约定 + +- 页面放在 `src/views/`,跨页面组件放在 `src/components/`,纯逻辑放在 `src/utils/`。 +- 新增功能时同步补充单元/组件测试;涉及用户流程时补充 E2E 测试。 +- 保持工具页面响应式,并同时检查浅色和暗色模式。 +- 项目当前有两个设计门禁:不要在 `src/` 中使用 CSS gradient,并确保构建产物不超过性能预算。 +- 不要把密钥、个人数据或真实用户文件提交到仓库。 + +## 分支与提交 + +从 `master` 创建分支,例如: + +```bash +git switch -c feat/your-change +``` + +提交信息建议使用简短的 Conventional Commits 风格前缀: + +```text +feat: add a new utility +fix: handle invalid input +docs: improve setup guide +refactor: simplify converter state +test: cover keyboard shortcut +``` + +## 提交 Pull Request + +提交前至少运行: + +```bash +npm run check +``` + +如果本地没有 Playwright 浏览器,先运行 `npx playwright install chromium`。PR 描述请说明: + +- 做了什么,以及为什么做; +- 如何验证; +- 是否有 UI 变化(有的话附截图或录屏); +- 是否存在兼容性、性能或破坏性变更。 + +PR 会经过 CI 检查。维护者可能会要求拆分范围、补测试或调整交互细节。 diff --git a/README.md b/README.md index c27e71c..ee88487 100644 --- a/README.md +++ b/README.md @@ -1,55 +1,159 @@ -# HTooL +
+ + + +## 项目定位 + +HTooL 面向写作、开发和日常信息处理场景,优先把数据留在浏览器中完成处理。它不是一个需要账号和后端服务的复杂平台,而是一组打开即用、按任务分组的轻量工具。 + +## 工具一览 + +| 分组 | 工具 | 能力 | +| --- | --- | --- | +| 文档创作 | Markdown 编辑器 | 编辑、工具栏、实时预览、本地文件夹读写与保存 | +| 文档创作 | Markdown ↔ HTML | 双向转换、预览、复制与下载 | +| 图像与编码 | 图片格式转换 | 单个/批量转换、PNG/JPG/WebP/GIF 选择、质量调节 | +| 图像与编码 | 二维码工具 | 文本/链接生成、尺寸与颜色设置、图片解析、下载 | +| 图像与编码 | 手绘板 | 画笔、橡皮擦、颜色/粗细调节与 PNG 导出 | +| 系统与数据 | 数据处理工具 | 正则测试、URL 编码/解码、Base64、MD5 与 SHA-256 | +| 系统与数据 | IP 地址定位 | 查询 IPv4 的地域、时区与运营商信息 | + +## 主要特点 + +- 浏览器优先:图片转换、二维码、绘图和文本处理默认在本地完成。 +- 按需加载:Markdown、二维码等较重依赖仅在进入对应工具后加载。 +- 克制的界面:响应式布局、浅色/暗色模式,以及明确的任务分组。 +- 可验证的质量门禁:单元测试、组件测试、E2E 流程、构建体积预算和设计约束检查。 +- 可直接部署:Vercel 配置已包含单页应用路由回退规则。 -一个基于 Vue 3 + Vite 的在线工具箱,采用极简编辑风重构,包含 Markdown、图片、二维码、IP 查询等工具页面。 +## 技术栈 -## 功能特点 +- [Vue 3](https://vuejs.org/) + [Vue Router](https://router.vuejs.org/) +- [Vite](https://vite.dev/) +- [Vitest](https://vitest.dev/) + [Vue Test Utils](https://test-utils.vuejs.org/) +- [Playwright](https://playwright.dev/) +- [Marked](https://marked.js.org/) + [Turndown](https://github.com/mixmark-io/turndown) +- [DOMPurify](https://github.com/cure53/DOMPurify) +- [QRCode](https://github.com/soldair/node-qrcode) + [jsQR](https://github.com/cozmo/jsQR) -- 首页工具导航 -- Markdown 编辑器(预览/实时预览、文件夹读写) -- 图片格式转换(单个与批量) -- 二维码生成与解析 -- Markdown ↔ HTML 互转 -- 数据处理(正则、URL、Base64、哈希) -- IP 地址定位、手绘板 +## 快速开始 -## 技术栈 +### 环境要求 -- Vue 3 -- Vue Router -- Marked -- Highlight.js +- Node.js 20 或更高版本 +- npm 10 或更高版本 +- 需要运行 E2E 测试时,额外安装 Playwright Chromium -## 开发 +### 本地开发 ```bash -# 安装依赖 -npm install - -# 启动开发服务器(默认 http://localhost:3000) +git clone https://github.com/Hughhhhcoder/HTooL.git +cd HTooL +npm ci npm run dev +``` -# 构建生产版本 -npm run build +开发服务器默认地址为