Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
---
name: 缺陷报告
about: 报告可复现的问题
title: ''
---

## 问题与预期

描述实际行为与预期行为。

## 复现步骤

1.
2.
3.

## 环境

- XShot 版本 / commit:
- macOS 版本:
- Mac 芯片、显示器数量及缩放:
- 屏幕录制权限状态(如相关):

## 验证与附件

附相关检查命令、结果、日志或去除隐私信息的截图。请勿上传密钥或含个人信息的截图 / 演示项目。
21 changes: 21 additions & 0 deletions .github/ISSUE_TEMPLATE/feature_request.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
---
name: 功能建议
about: 说明使用场景与期望的改进
title: ''
---

## 使用场景

你在完成什么任务?当前遇到什么限制?

## 期望行为

描述你希望的操作流程与结果。

## 替代方案与范围

尝试过哪些替代方案?哪些功能是必需的?

## 补充材料

可附去除隐私信息的示例、截图或参考链接;请注明来源。
16 changes: 16 additions & 0 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
## 问题与改动

说明具体问题、修改后的行为及相关 Issue。

## 验证

- [ ] 已运行 `./scripts/build.sh`
- [ ] 已运行 `./scripts/check-interactive-demo.sh` 及与改动相关的检查
- [ ] 界面改动已附去除隐私信息的截图 / GIF(如适用)
- [ ] 已检查提交内容不包含密钥、个人配置或私密媒体

填写命令与结果;未运行或失败的检查请说明原因。真实设备验证请注明 macOS、芯片及显示器环境。

## 风险与待办

说明兼容性影响、权限变化、已知限制及需要维护者处理的事项。
37 changes: 37 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: Build and check

on:
push:
pull_request:

permissions:
contents: read

concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true

jobs:
build-and-check:
runs-on: macos-15
timeout-minutes: 20
env:
CLANG_MODULE_CACHE_PATH: ${{ github.workspace }}/.build/ModuleCache
SWIFT_MODULE_CACHE_PATH: ${{ github.workspace }}/.build/ModuleCache
steps:
- uses: actions/checkout@v4
with:
persist-credentials: false
- uses: actions/setup-node@v4
with:
node-version: '22'
- name: Verify ARM runner and toolchain
run: |
test "$(uname -m)" = arm64
swiftc --version
node --version
mkdir -p .build/ModuleCache
- name: Build app (ad hoc signing)
run: ./scripts/build.sh
- name: Check offline HTML export and navigation
run: ./scripts/check-interactive-demo.sh
29 changes: 29 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,32 @@
dist/
artifacts/
.DS_Store

# Xcode local build and user state
DerivedData/
*.xcuserstate
xcuserdata/

# Local environment files (keep sanitized examples)
.env*
!.env.example
!.env.sample

# Private keys, signing identities and local credentials
*.pem
*.key
*.p12
*.pfx
*.p8
*.mobileprovision
*.provisionprofile
*.keychain
*.keychain-db
id_rsa*
id_dsa*
id_ecdsa*
id_ed25519*
credentials.json
secrets.json
secrets.yml
secrets.yaml
42 changes: 42 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# 参与贡献

欢迎提交问题、文档改进与代码贡献。提交前请搜索已有 Issue / PR;较大的功能或交互调整请先用 Issue 说明使用场景与范围。

## 本地开发

需要 Apple Silicon Mac、macOS 14 或更新系统、Xcode Command Line Tools(`xcode-select --install`)及 zsh。离线 HTML 检查还需要 Node.js 22;应用构建本身没有第三方代码依赖。

从最新 `main` 创建独立开发分支,在仓库根目录运行:

```sh
./scripts/build.sh
./scripts/check-interactive-demo.sh
```

构建输出为 `dist/XShot.app`。构建采用本机临时签名,不包含 Developer ID 签名或公证。检查以合成图片和 Node.js 的 DOM 替身验证离线 HTML 导出、转义、导航与热点逻辑,不启动应用窗口或浏览器,也不采集屏幕。

根据改动补跑相关的 `scripts/check-*.sh`;各脚本的用途见 [README](README.md#验证)。部分 AppKit 检查依赖图形登录会话、隐藏窗口或系统服务,`check-demo-studio.sh` 还需要先运行 `check-demo-video.sh`。真实截图、录屏权限、多屏行为与视觉效果需要在本机手动验证,不能由离线检查代替。请参阅 [VERIFICATION.md](VERIFICATION.md)。

## CI 与复现

GitHub Actions 在 push 与 PR 时使用 `macos-15` ARM runner,运行上述构建与离线检查,并显式安装 Node.js 22。参见 [GitHub runner 说明](https://docs.github.com/en/actions/reference/runners/github-hosted-runners)。私有库需要启用 Actions 并有可用计算额度。若托管 runner 不可用,在上述本机环境运行相同命令并附上结果;不要将不可信 PR 自动转给个人 self-hosted runner。

受限环境中若编译器无法写入用户级缓存,可将缓存设到仓库的忽略目录后重试:

```sh
mkdir -p .build/ModuleCache
export CLANG_MODULE_CACHE_PATH="$PWD/.build/ModuleCache"
export SWIFT_MODULE_CACHE_PATH="$PWD/.build/ModuleCache"
./scripts/build.sh
./scripts/check-interactive-demo.sh
```

## 提交与 PR

- 保持改动聚焦,沿用现有 Swift 风格;行为修复应说明复现步骤及验证方式。
- PR 目标为 `main`,说明问题、修改后的行为、运行过的命令和结果。未运行或失败的检查请附原因。
- 界面改动请附去除隐私信息的截图或短 GIF,并注明设备与 macOS 版本。
- 不要提交密钥、证书、个人配置、真实用户截图或录屏。`.gitignore` 只是辅助,提交前仍应检查暂存内容。
- 使用第三方代码、素材或依赖前确认其许可证,并保留必要的来源与声明。

提交贡献即表示你有权按本项目的 [MIT 许可证](LICENSE) 提供这些内容。
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2026 korbinjoe

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
37 changes: 31 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# XShot

![XShot 标志(产品截图占位)](Resources/Logo/XShotMark.png)

*上图为现有项目标志,暂作展示占位;需要用户提供产品截图/GIF。*

独立实现的原生 macOS 截图与产品演示工具。0.2.0 包含窗口、区域与整屏截图、标注、复制与 PNG 保存、桌面贴图,以及自动缩放录屏和可点击步骤演示。

## 运行
Expand All @@ -10,6 +14,26 @@

全局快捷键为 **⌥X(Option + X)** 截图、**⌥R(Option + R)** 打开产品演示或完成录制、**⌥P(Option + P)** 暂停/继续录制;菜单栏也提供入口。首次截图或录制需允许 XShot 访问屏幕,刚授权后若无法采集,请重新打开应用。未授权时仍可打开本地图片进行标注。

## 安装 / 故障排除(非 App Store)

XShot **不在 App Store**。直接下载或自行构建的 `XShot.app` 首次打开时,macOS 可能提示「已损坏,无法打开」或「无法打开,因为来自身份不明的开发者」。这通常是 Gatekeeper / 隔离属性导致,可按下面步骤处理:

1. **右键打开**:在 Finder 中对 `XShot.app` 按住 Control 点击(或右键)→ 选择「打开」→ 在对话框中再点「打开」。第一次需要这样绕过 Gatekeeper。
2. **系统设置放行**:打开「系统设置」→「隐私与安全性」,在被拦下的提示附近点「仍要打开」/允许该 App。截图与录制还需在「屏幕与系统音频录制」中授权。
3. **清除隔离属性**(仍打不开时,在终端执行,路径按实际位置改):

```bash
xattr -cr /Applications/XShot.app
```

4. **可选:核对签名**(自行构建或附带签名的包):

```bash
codesign --verify --deep --strict /Applications/XShot.app
```

本地 `./scripts/build.sh` 生成的 `dist/XShot.app` 同样适用上述步骤。

## 截图与标注

按 **⌥X**,鼠标移到窗口上会自动高亮边界,单击即可选中;直接拖动仍为手动框选。选好后浮动工具栏直接提供矩形、箭头、画笔、文字与马赛克,以及颜色、线宽、撤销、重做和清空。无需先打开编辑器,按 **Enter / ⌘C** 或点击“复制”即可复制并结束截图,回到原应用用 **⌘V** 粘贴;**⌘S** 或“保存”直接保存 PNG,取消保存会返回原选区与标注。
Expand Down Expand Up @@ -100,14 +124,15 @@

`python3 scripts/make-icons.py` 可重建图标资源;常规构建直接使用 `Resources/` 内的 PNG 与 ICNS,不需要图像生成服务。

## 贡献与许可证

欢迎提交 Issue 和 PR,开发环境与检查流程见 [CONTRIBUTING.md](CONTRIBUTING.md)。本项目采用 [MIT 许可证](LICENSE)。

## 实现来源

- 项目源代码由本项目独立编写,以公开可见的产品行为作为需求参考。
- 未导入 iShot 源码、反编译代码、二进制、图标、图片、界面文件或文案。
- 本次实现使用苹果公开系统框架:AppKit、ScreenCaptureKit、AVFoundation、Core Image、Core Graphics、WebKit、Carbon(全局快捷键);没有外部代码依赖。
- 截图功能参考:[iShot](https://www.better365.cn/ishot.html);产品演示功能与交互参考:[Screen Studio](https://screen.studio/)、[Cap](https://cap.so/)、[Arcade](https://www.arcade.software/product/interactive-demo)、[Supademo](https://supademo.com/features/guided-demos)。未复用这些项目的代码或资产。
- 项目源代码由本项目独立编写,使用苹果公开系统框架:AppKit、ScreenCaptureKit、AVFoundation、Core Image、Core Graphics、WebKit、Carbon(全局快捷键);没有外部代码依赖。
- 需求与交互研究参考了公开可见的截图和演示工具体验,感谢 [iShot](https://www.better365.cn/ishot.html)、[Screen Studio](https://screen.studio/)、[Cap](https://cap.so/)、[Arcade](https://www.arcade.software/product/interactive-demo) 与 [Supademo](https://supademo.com/features/guided-demos) 提供的产品参考。相关名称与商标归各自权利人所有;列出参考不表示关联或背书。
- 本项目未复用上述产品的源码、反编译代码、二进制或资产。早期调研包含对本机已安装参考应用的版本、依赖及类名的只读检查;未采用反汇编或反编译实现,不将开发过程描述为严格的隔离式 clean-room。
- API 文档:[SCScreenshotManager](https://developer.apple.com/documentation/screencapturekit/scscreenshotmanager)。

前期曾只读检查已安装 iShot 的版本、依赖和类名以判断技术可分析性;项目没有采用其反汇编或反编译实现。这里记录实际开发过程,不宣称严格的隔离式 clean-room 开发。

长截图与 OCR 不在当前版本范围内。
8 changes: 7 additions & 1 deletion Tests/SettingsChecks.swift
Original file line number Diff line number Diff line change
Expand Up @@ -244,12 +244,18 @@ import AppKit
}
action(control(NSButton.self, "恢复默认设置", in: content))
precondition(settings.values == AppSettings.Values() && presets.selectedSegment == 1 && copy.state == .on)
// An inherited dark appearance is not a light baseline. Exercise both
// appearances explicitly so this check also works when macOS uses Dark Mode.
let inheritedAppearance = window.appearance
window.appearance = NSAppearance(named: .aqua)
try saveSnapshot("settings-default.png")
let lightStage = stagePixels()
window.appearance = NSAppearance(named: .darkAqua)
precondition(stagePixels() != lightStage, "The transparency stage must follow the window appearance")
try saveSnapshot("settings-dark.png")
window.appearance = nil
window.appearance = NSAppearance(named: .aqua)
precondition(stagePixels() == lightStage, "Returning to light appearance must restore the transparency stage")
window.appearance = inheritedAppearance
var invalid = settings.values
invalid.style.padding = .infinity
invalid.style.cornerRadius = -100
Expand Down
6 changes: 4 additions & 2 deletions scripts/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@ mkdir -p "$APP_DIR/Contents/Resources/Logo"
cp "$PROJECT_DIR"/Resources/Logo/*.png "$APP_DIR/Contents/Resources/Logo/"
codesign --force --sign - "$APP_DIR"
LSREGISTER="/System/Library/Frameworks/CoreServices.framework/Frameworks/LaunchServices.framework/Support/lsregister"
if [[ -x "$LSREGISTER" ]]; then
"$LSREGISTER" -f "$APP_DIR"
if [[ "${CI:-}" != "true" && -x "$LSREGISTER" ]]; then
if ! "$LSREGISTER" -f "$APP_DIR"; then
echo "Warning: app built, but Launch Services registration failed; open $APP_DIR manually." >&2
fi
fi
echo "$APP_DIR"
Loading