baseline: capture workspace state (bug fixes in progress)

main
Shift 2026-10-21 08:54:54 +08:00
commit 0eb75595c6
137 changed files with 23099 additions and 0 deletions

49
.github/workflows/ci.yml vendored 100644
View File

@ -0,0 +1,49 @@
name: CI
on:
push:
pull_request:
jobs:
macos:
runs-on: macos-latest
steps:
- uses: actions/checkout@v4
- uses: pnpm/action-setup@v4
with:
version: 9
- uses: actions/setup-node@v4
with:
node-version: 22
cache: pnpm
- uses: dtolnay/rust-toolchain@stable
with:
targets: aarch64-apple-darwin,x86_64-apple-darwin
- run: pnpm install --frozen-lockfile
- run: pnpm mac:drag-bridge
- run: pnpm check
- run: pnpm build
- run: cargo test --lib
working-directory: src-tauri
- run: pnpm tauri build --target universal-apple-darwin --debug --bundles app
env:
RUSTUP_TOOLCHAIN: stable
windows:
runs-on: windows-latest
steps:
- uses: actions/checkout@v4
- uses: pnpm/action-setup@v4
with:
version: 9
- uses: actions/setup-node@v4
with:
node-version: 22
cache: pnpm
- uses: dtolnay/rust-toolchain@stable
- run: pnpm install --frozen-lockfile
- run: pnpm check
- run: pnpm build
- run: cargo check
working-directory: src-tauri
- run: pnpm tauri build --debug --no-bundle

7
.gitignore vendored 100644
View File

@ -0,0 +1,7 @@
node_modules/
dist/
src-tauri/target/
src-tauri/gen/
artifacts/
FileFlipper/
.DS_Store

3
LICENSE 100644
View File

@ -0,0 +1,3 @@
MIT License
Copyright (c) 2026 Shift Contributors

406
README.md 100644
View File

@ -0,0 +1,406 @@
# Shift
**A radial file workspace for macOS and Windows. Drag a file, release over a wedge, and the conversion happens on your machine.**
**Language:** English · [简体中文](README.zh-CN.md)
Shift puts file conversion, screenshot, screen recording, annotation, and bilingual OCR behind one radial menu that appears wherever you drop a file. No uploads, no account, no cloud round-trip — every byte is processed locally.
Built on Tauri 2, Rust, React and TypeScript. Native capture and drag behaviour live behind per-platform adapters, so the radial menu, editor, and format catalogue are identical everywhere.
---
- [What it does](#what-it-does)
- [Quick start](#quick-start)
- [Supported files](#supported-files)
- [Conversions](#conversions)
- [Tools](#tools)
- [Compression, naming, cancellation](#compression-naming-cancellation)
- [Capture & annotation](#capture--annotation)
- [OCR](#ocr)
- [Shortcuts](#shortcuts)
- [Tray menu](#tray-menu)
- [Output locations](#output-locations)
- [External dependencies](#external-dependencies)
- [Platform status](#platform-status)
- [Build from source](#build-from-source)
- [Architecture](#architecture)
- [Repository layout](#repository-layout)
- [Privacy](#privacy)
- [Known limitations](#known-limitations)
- [FAQ](#faq)
- [Contributing](#contributing)
- [License](#license)
---
## What it does
**The radial menu is the whole interface.** Hold `Shift` and drag a file in Finder (or `Ctrl + Shift` on Windows) and a ring opens under the cursor. Release over a format to convert, or add `Option`/`Alt` to switch to the tool ring. The main window accepts drops too, and its `Convert files` / `File tools` buttons open the same rings for files you pick yourself.
**Everything is type-aware.** The ring only offers what the selected file can actually become — an image offers PNG/JPG/WEBP/HEIC/TIFF/BMP/GIF/PDF, a PPTX offers PDF and Markdown, and a `.key` or `.pages` file offers no conversion wedges at all instead of failing later. The centre shows a glass preview with the file's dimensions and size; a multi-file selection renders a stacked icon deck.
**Batch by default.** Select ten files, drag, and one gesture produces ten outputs. Results land next to each source with a descriptive suffix (`report (compressed).pdf`, `photo (rotated).png`) and never overwrite — a numeric suffix is appended on collision. Settings can collect every result into one folder instead.
**Capture is built in.** Frozen-screen area capture, full-screen capture, and area recording with a floating timer, all aimed at the monitor under the pointer rather than always the primary display. Screenshots open straight into the annotation canvas and can be pinned as always-on-top reference windows.
**OCR runs on-device.** English and Simplified Chinese, via a bundled Tesseract WASM engine with the traineddata shipped inside the app. No network access at any point in the OCR path.
## Quick start
Shift lives in the menu bar (macOS) and the notification area (Windows), and it also has a normal window. There is no required window to keep open — the rings work from anywhere.
**Convert a file (Shift).**
1. Find the file in Finder or File Explorer.
2. Press and hold on it and start dragging, keeping the mouse button down.
3. While dragging, hold `Shift`. The ring appears around the pointer.
4. Drag toward the format you want — the wedge fills in and grows, and its name shows in the centre — then release. You only have to head in its direction; precision is not required.
5. The status pill reports `Saved N files.` and the result sits next to the original.
> 💡 You can press `Shift` after the drag begins. Once the ring is up you may let go of `Shift`; it stays until you release the mouse.
> 💡 Changed your mind? Release back near the centre (inside the 92 px inner radius) and nothing happens.
> 💡 Near a screen edge the ring slides back on screen; the whole 760 px ring is clamped inside the monitor under the pointer.
**Use a tool (`Option + Shift`, or `Ctrl + Shift` on Windows).** Same gesture, and the wedges become tools for that file type instead of formats. While the ring is open, keep `Shift` held and press or release `Option`/`Ctrl` to flip between the format ring and the tool ring.
**Prefer not to drag?** In the main window, **Convert files** and **File tools** open a picker and then show the same ring for what you chose; **OCR** picks an image and reads it. Dropping files straight onto the main window opens the action ring directly.
**Several files at once.** Multi-select with `⌘`/`Ctrl`-click, then drag. Every file is processed. With 2+ images or 2+ PDFs selected, a **Merge** wedge appears that combines them into a single PDF.
**First run on macOS.** Grant Screen Recording for screenshots and recording, and Files & Folders access for the output locations you choose. Capture checks permission before showing the overlay, so a denial produces an actionable error rather than a black screenshot.
## Supported files
Recognition is by extension, against four tables in `src-tauri/src/files.rs`. The `kind` drives the centre icon and which wedges appear. Bold extensions are the ones that actually convert; the rest are recognised and get Open, Reveal, or an export-first message.
| Kind | Extensions |
| --- | --- |
| `image` | **`png` `jpg` `jpeg` `webp` `tiff` `tif` `bmp` `gif`** `heic` `heif` `avif` |
| `video` | **`mp4` `mov` `m4v` `avi` `mkv` `webm`** |
| `audio` | **`mp3` `wav` `m4a` `aiff` `aif` `caf` `flac` `ogg`** |
| `pdf` | **`pdf`** |
| `document` | **`docx` `rtf` `odt` `txt` `md` `html` `htm`** `doc` `pages` |
| `presentation` | **`pptx`** `ppt` `key` |
| `spreadsheet` | **`xlsx` `xls` `xlsb` `ods` `csv` `tsv`** `numbers` |
| `other` | anything unrecognised — Open and Reveal only |
Decoding and encoding are not symmetric, and the app does not pretend otherwise:
- **Image decode** is native (Rust `image`) for PNG, JPEG, WebP, TIFF, BMP, GIF, and every tool-ring operation uses that decoder. HEIC/HEIF/AVIF are not in it, so those formats convert through the system path — `sips` on macOS, ImageMagick elsewhere — but rotate, flip, B&W, 50% and compress will not read them until they are converted first.
- **Image encode** for PNG, JPG, WebP, TIFF, BMP, GIF is native. HEIC export goes through `sips` on macOS and requires ImageMagick on Windows/Linux. AVIF reads fine and can be written by the same system path, but the ring does not offer it yet.
- **Media** decode and encode are whatever your FFmpeg build supports; the menu offers MP4, MOV, GIF and M4A for video, and M4A, WAV and MP3 for audio.
- **Office** files are parsed in pure Rust (`calamine` for spreadsheets, `zip` + `quick-xml` for PPTX), so no Office installation is needed.
- **Recognised but not converted:** `.doc`, `.pages`, `.ppt`, `.key` and `.numbers` get their proper icon plus Edit, Open and Reveal, but no format wedges. Export them to DOCX, PPTX or XLSX first.
## Conversions
The format ring for a given file type. Every arrow below is wired in `src-tauri/src/files.rs`.
| Source | Ring offers | Engine | Notes |
| --- | --- | --- | --- |
| Image | `PNG` `JPG` `WEBP` `TIFF` `BMP` `GIF` | Rust `image` | Lossless path when the codec allows it |
| Image | `HEIC` | `sips` / ImageMagick | macOS native; other OS need `magick` |
| Image | `PDF` | `printpdf` | One page per image, sized at 300 dpi |
| Video | `MP4` `MOV` | FFmpeg | `libx264`, falling back to `h264_videotoolbox` then `mpeg4` |
| Video | `GIF` | FFmpeg | First 15 s only, 12 fps, 480 px wide — capped so a long recording cannot produce a 100 MB GIF |
| Video | `M4A` | FFmpeg | Audio track only, 192k AAC |
| Audio | `M4A` `WAV` `MP3` | FFmpeg | MP3 falls back to `lame` if FFmpeg lacks `libmp3lame` |
| PDF | `TXT` `MD` | `lopdf` | Text-layer extraction; errors clearly when a PDF is scanned |
| PDF | `DOCX` `RTF` | `lopdf` + Pandoc | Text layer becomes the document body; needs Pandoc |
| PDF | `HEIC` | PDFKit / Poppler + `sips` | Pages render as PNG then transcode; needs a system HEIC codec |
| PDF | `PNG` `JPG` `TIFF` | PDFKit / Poppler | One file per page into a `… pages` folder |
| Document `docx` `rtf` `odt` `txt` `md` `html` | `PDF` | AppKit renderer (macOS) · Pandoc elsewhere | macOS path needs no LaTeX or wkhtmltopdf |
| Document `docx` `rtf` `odt` `txt` `md` `html` | `DOCX` `RTF` `HTML` `TXT` `MD` `ODT` | Pandoc | Markdown writes as GFM |
| Presentation `.pptx` | `MD` `PDF` | Pure Rust + Pandoc | Per-slide headings, bullet text and **tables as real Markdown tables**; PDF is a text summary, not a layout render |
| Spreadsheet | `MD` `PDF` | `calamine` / Rust | One Markdown table per sheet; `csv`/`tsv` parsed directly |
Anything not in this table is not offered — the ring is built from this catalogue at runtime, so a wedge you can click is a wedge that works. If a dependency is missing, the wedge names it instead of failing silently.
> Note: unlike some radial converters, Shift does **not** hide the file's own format. Dragging a PNG still shows PNG, which makes it a quick way to re-encode a file in place.
> Scanned/image-only PDFs have no text layer, so `TXT`/`MD` return a clear error — use **OCR** on those, which renders each page first.
## Tools
The tool ring (`Option + Shift` while dragging). These are one-gesture operations, not conversions.
| Tool | Applies to | Output | What it does |
| --- | --- | --- | --- |
| Compress | image, video, audio, PDF | `.jpg`/`.png`, `.mp4`, `.m4a`, `.pdf` | Images re-encode at q68 (PNG kept when alpha); video at CRF 28; audio to 128k AAC; PDF images resampled to ≤1440 px at q60 JPEG, then objects pruned |
| Metadata | image, PDF | same type, ` (clean)` | Rewrites the image with no EXIF; strips the PDF `/Info` and `/Metadata` entries |
| Rotate | image, PDF | same type, ` (rotated)` | 90° clockwise, in place for the format |
| Flip | image | same type, ` (flipped)` | Horizontal mirror |
| B&W | image | same type, ` (bw)` | Grayscale conversion |
| 50% | image | same type, ` (50%)` | Half width and height, Lanczos3 |
| Crop | image | `.png`, ` (cropped)` | Radial crop opens the editor for an interactive selection |
| Cutout | image | — | Opens the editor, which keys out the sampled background colour |
| Merge | 2+ images | `.pdf`, ` (images)` | One page per image, in selection order |
| Merge | 2+ PDFs | `.pdf`, ` (merged)` | Concatenates in selection order |
| Split | PDF | `Page 001.pdf` … | One PDF per page in a `… pages` folder |
| Extract text | PDF | `.txt` | Text layer only; use OCR for scans |
| 720p | video | `.mp4`, ` (720p)` | Scales to 720p height, keeps aspect |
| Mute | video | same type, ` (muted)` | Drops the audio track, video stream copied without re-encode |
| Frame | video | `.png`, ` (frame)` | First frame as a still |
| Extract audio | video | `.m4a` | 192k AAC |
| Mono | audio | `.m4a`, ` (mono)` | Downmix to single-channel 128k AAC |
| Plain | document | `.txt` | Plain-text dump via Pandoc |
| OCR | image, PDF | `.txt`, ` (OCR)` | See [OCR](#ocr) |
| Edit / Annotate / Redact / Add BG | image | — | Opens the editor with the matching tool preselected |
| Open · Reveal | any file | — | Hands off to the system default app or file manager |
## Compression, naming, cancellation
**What Compress actually does.**
| Input | Behaviour |
| --- | --- |
| Image | Re-encoded at quality 68. Images with transparency are written as PNG, everything else as JPG |
| PDF | Embedded images above 1440 px are resampled to q60 JPEG, then objects are pruned, renumbered and saved compressed. If the result is not smaller, nothing is written |
| Video | Re-encoded at CRF 28 / 2M target, AAC 96k audio, into MP4 |
| Audio | To 128k AAC M4A |
**Output naming — nothing is ever overwritten.** Results land next to the source with a descriptive suffix, and a collision appends ` 2`, ` 3`, … rather than replacing anything.
```text
report (compressed).pdf photo (rotated).png slide (bw).png
report (clean).pdf photo (50%).png report (merged).pdf
```
PDF→image and PDF split write into a new `Name pages` folder containing `Page 001.png`, `Page 002.png`, … A second run makes `Name pages 2`, also never overwriting.
**Cancel a gesture.** Release near the centre of the ring, or outside the ring entirely, and no action runs.
## Capture & annotation
**Capture.** Area capture paints a frozen still so the pixels you select are the pixels you get; full-screen capture skips the overlay entirely. Recordings save as MOV on macOS via `screencapture -v` and MP4 elsewhere via FFmpeg, with a floating timer and stop control. Linux capture prefers `grim` and falls back to `gnome-screenshot`.
**Annotation.** The editor canvas works at native resolution and writes a new PNG, so the source file is never modified.
| Tool | Behaviour |
| --- | --- |
| Rectangle, Arrow, Highlight, Text | Freehand placement, colour and weight per annotation |
| Redact | Solid black bar, burnt into the output — not an overlay |
| Pixelate | Real mosaic sampling of the region underneath, not a translucent fill |
| Number | Auto-incrementing callout badges |
| Crop | Interactive crop with an explicit apply step |
| Add BG | Rounded-corner padding with a gradient mat, for social and deck shots |
| Cutout | Samples the four corners, averages the background, keys it out to transparency |
| Undo | Pops annotations first, then image-level operations |
| Save copy / Copy | New file with a suffix, or straight to the clipboard |
| Pin | Floats the image as an always-on-top window with copy and close |
**Editor.** Images open the annotator; video opens a player; `txt` `md` `csv` `tsv` `html` `htm` open as editable text. Every editor host has Copy, Save As, Open, Reveal in Folder, OCR and Copy Text.
## OCR
Tesseract.js with the LSTM core, running as WASM inside the app. `eng` and `chi_sim` traineddata are copied into `public/tesseract` at build time by `pnpm prepare:ocr`, so recognition works with no network and no download on first run.
- **Images** — one pass, live progress, text goes to the editor or the clipboard.
- **Scanned PDFs** — pages are rendered to images first, then OCR'd sequentially with per-page progress, and the results are written to a ` (OCR)` text file with `--- Page N ---` separators.
- **Text PDFs** — use Extract Text instead; it reads the embedded layer directly and is far faster.
## Shortcuts
| Action | macOS | Windows / Linux |
| --- | --- | --- |
| Capture area | `⌥⇧2` | `Alt+Shift+2` |
| Record area | `⌥⇧3` | `Alt+Shift+3` |
| Capture full screen | `⌥⇧4` | `Alt+Shift+4` |
| Format ring while dragging | hold `⇧` | hold `Shift` |
| Tool ring while dragging | `⌥⇧` | `Ctrl+Shift` |
The three capture shortcuts are registered globally. The drag rings are modifier-driven: begin dragging with the modifier already held and the ring appears under the cursor without Shift needing focus.
## Tray menu
The menu bar (macOS) and notification area (Windows) icon exposes the actions you would otherwise reach through the window:
| Item | Shortcut | Meaning |
| --- | --- | --- |
| Open Shift | — | Show the main window |
| Capture area | `Alt+Shift+2` | Start an area screenshot |
| Capture full screen | `Alt+Shift+4` | Grab the monitor under the pointer |
| Record area | `Alt+Shift+3` | Start, or stop, an area recording |
| OCR an image… | — | Pick an image and read its text locally |
| Quit Shift | `Cmd/Ctrl+Q` | Exit; an in-flight recording is finalised first |
Tray labels are English only for now; everything inside the windows follows the app language.
Settings → **Behaviour** holds two switches: **Drag rings** (master enable for the Shift-drag gesture) and **Launch at login**.
## Output locations
| Result | Default |
| --- | --- |
| Screenshots | `~/Pictures/Shift` |
| Recordings | `~/Movies/Shift` |
| File actions | beside the source file |
Each is overridable in Settings. File actions offer a *collect everything in one folder* mode in place of beside-the-source. The Settings panel lists every resolved path, checks that it is actually writable, reveals it in the file manager, and deep-links to the macOS Screen Recording and Files & Folders privacy panes when access is missing.
## External dependencies
Core conversion, radial menu, capture, and OCR work with nothing installed. These extend coverage:
| Tool | Needed for | macOS | Windows | Linux |
| --- | --- | --- | --- | --- |
| FFmpeg | media convert/compress, 720p, mute, frame, mono; recording off-macOS | optional | **required** for recording | **required** |
| Pandoc | document ↔ DOCX/RTF/ODT/HTML/TXT/MD | optional | needed | needed |
| Poppler `pdftoppm` | PDF → images, scanned-PDF OCR | not needed (PDFKit) | needed | needed |
| ImageMagick `magick` | HEIC/AVIF encode | not needed (`sips`) | needed | needed |
| LAME | MP3 encode when FFmpeg lacks `libmp3lame` | rare | rare | rare |
Tools are found on `PATH` at call time and results are cached, so a missing dependency degrades one wedge rather than the app.
## Platform status
| Capability | macOS | Windows | Linux |
| --- | --- | --- | --- |
| Radial menu, editor, tray, i18n | Yes | Yes | Yes |
| Drag-to-ring | AppKit global drag bridge | Win32 drag-state poll + native drop | none yet — main-window picker only |
| Area / full-screen capture | `screencapture` | PowerShell | `grim` / `gnome-screenshot` |
| Monitor under cursor | Yes | Yes | `grim` output selection |
| Area recording | `screencapture -v` | FFmpeg | planned |
| Image convert and edit | Yes | Yes | Yes |
| HEIC / AVIF encode | `sips` | ImageMagick | ImageMagick |
| PDF text, merge, split, rotate, compress | Yes | Yes | Yes |
| PDF → images | PDFKit sidecar (+ `sips` for HEIC) | Poppler (+ ImageMagick for HEIC) | Poppler (+ ImageMagick for HEIC) |
| Scanned-PDF OCR | Yes | Poppler required | Poppler required |
| Document → PDF | bundled AppKit renderer | Pandoc + a PDF engine | Pandoc + a PDF engine |
| PPTX / XLSX / ODS → Markdown | Yes (pure Rust) | Yes | Yes |
| Local EN + ZH OCR | Yes | Yes | Yes |
## Build from source
Requires Node.js 20+, pnpm 8+, Rust 1.90+, and macOS 13+ with Xcode Command Line Tools for the native macOS sidecars.
```bash
pnpm install
pnpm mac:drag-bridge # macOS only — AppKit drag, PDFKit and document renderers
pnpm tauri dev
```
`pnpm mac:drag-bridge` compiles `native/macos/*.swift` into per-architecture and universal sidecars under `src-tauri/binaries`. Windows and Linux skip it entirely.
```bash
pnpm check # TypeScript, no emit
pnpm build # tsc + vite
cargo test --lib # Rust unit tests, from src-tauri/
pnpm tauri build # release bundle
```
Universal macOS build:
```bash
rustup target add aarch64-apple-darwin x86_64-apple-darwin
pnpm mac:drag-bridge
RUSTUP_TOOLCHAIN=stable pnpm tauri build --target universal-apple-darwin --bundles app
```
The result is one universal Mach-O including universal drag, PDF-render and doc-render sidecars. Windows build steps are in `docs/BUILD_WINDOWS.md`.
**Permissions (macOS).** Screen Recording for capture, Files & Folders for the output folders you choose, Microphone when recording with audio. Shift checks Screen Recording before opening the overlay, so a denial surfaces an actionable error rather than a black screenshot. Dev builds signed with a local certificate keep those grants stable across rebuilds; distribution needs Developer ID plus notarization.
## Architecture
```text
React UI one webview, five views
├─ main drop target, shortcuts, recent outputs, language, settings
├─ radial transparent always-on-top ring, hit-tested by polar sector
├─ capture frozen still + area selection
├─ recorder floating timer and stop control
├─ editor annotation canvas, text, video, OCR
└─ pin always-on-top image reference
Tauri command layer src-tauri/src/
├─ files.rs inspect, convert, compress, metadata, rotate, crop, media
├─ pdf.rs merge, split, rotate, text, render, image→PDF, compress
├─ office.rs PPTX and spreadsheet → Markdown, pure Rust
├─ capture.rs full-screen capture, region crop, editor handoff
├─ recording.rs screencapture / FFmpeg, with interrupt-based finalization
├─ drag_bridge.rs global drag detection, ring mode, radial positioning
├─ settings.rs output directories, write checks, privacy deep links
└─ editor.rs editor and pin window state
Platform adapters
├─ macOS AppKit drag bridge · PDFKit renderer · AppKit doc renderer · screencapture
├─ Windows Win32 drag state · PowerShell capture · FFmpeg · Poppler
└─ Linux grim / gnome-screenshot · FFmpeg · Poppler
OCR: Tesseract.js WASM + bundled eng/chi_sim, in-process, offline
```
The radial hit-test is pure geometry — one polar calculation shared by native pointer events, webview hover, and the Windows drop payload — so ring behaviour does not drift between platforms.
## Repository layout
```text
src/ React UI, i18n (en/zh), Tauri API bindings
src-tauri/src/ Rust command layer and platform adapters
native/macos/ Swift sidecars: drag bridge, PDF renderer, doc renderer,
compiled into src-tauri/binaries/ by pnpm mac:drag-bridge
scripts/ OCR asset staging, macOS sidecar build
public/tesseract/ WASM core + traineddata, generated, not committed
assets/ app icon source
src-tauri/icons/ generated app icons per platform
docs/ Windows build guide, roadmap
.github/workflows/ macOS and Windows CI
FileFlipper/ separate companion project, its own repository
```
## Privacy
Shift makes no network requests. Files are read, converted, and written locally; OCR runs in-process against bundled models; recent outputs are a local list. Nothing is uploaded, and nothing is collected.
## Known limitations
- Document → PDF on Windows/Linux still needs Pandoc plus a working PDF engine; the bundled AppKit renderer is macOS-only.
- PPTX and spreadsheet → PDF is a text and table summary, not a layout-accurate render.
- `.doc`, `.pages`, `.ppt`, `.key` and `.numbers` are recognised but not parsed — export to DOCX/PPTX/XLSX first.
- HEIC/HEIF/AVIF convert through the system decoder, but the pixel tools need a PNG/JPEG/WebP/TIFF/BMP/GIF input; AVIF is not yet an export target.
- PDF compression resamples embedded images to at most 1440 px as q60 JPEG. It deliberately skips anything it cannot prove it can round-trip — masks, indexed or CMYK colour, JPX/JBIG2/CCITT — so exotic scans may still resist shrinking.
- Windows recording and media conversion require `ffmpeg` on `PATH`.
- Windows paths build and pass CI, but gesture-level QA needs real Windows hardware.
- Signing identity changes on macOS may require re-approving Screen Recording and Accessibility.
Roadmap: `docs/ROADMAP.md`.
## FAQ
**❓ I hold Shift while dragging and no ring appears.**
Start the drag first — mouse button held, file moving past the drag threshold — and hold `Shift` during it. Pressing `Shift` with a file merely selected does nothing. On Windows the ring needs `Shift` held at the moment the drag crosses the system threshold; add `Ctrl` at that moment for tools.
**❓ It says this file type has no formats.**
Unrecognised extensions get Open and Reveal only, and legacy Apple/Office formats (`.doc`, `.pages`, `.ppt`, `.key`, `.numbers`) intentionally offer no conversion. Export them to DOCX, PPTX or XLSX first.
**❓ Can I make it run at login, or toggle it off?**
Yes, both, in Settings → **Behaviour**. **Drag rings** is the master switch for the Shift-drag gesture: off means no ring ever appears, while the tray, window and shortcuts keep working. **Launch at login** registers a LaunchAgent on macOS, a `HKCU\...\Run` entry on Windows, or an autostart `.desktop` file on Linux, and is reversible from the same toggle.
The login item is registered for the current user only and points at the app bundle, so macOS keeps the same Screen Recording identity across launches. Move the app and re-toggle it once.
**❓ Are my files uploaded?**
No. There is no upload path in the code and no network call in the conversion or OCR paths; the Tesseract models ship inside the app. Nothing is collected, and there is no account.
**❓ Where did my output go?**
Next to the source file by default, with a suffix — check the recent list in the main window first, since clicking an entry opens the result. Settings lists every resolved output path and can reveal it.
**❓ Which languages are supported?**
English and Simplified Chinese, switchable in the main window's Settings. On first launch it follows the system language. The tray menu and native macOS permission prompts stay in English.
**❓ Can I edit a screenshot without saving it?**
Yes — annotation works on a canvas copy and only writes on **Save copy** or **Copy**. The source file is never modified. Use **Pin** to keep it floating on screen as a reference instead.
**❓ How do I uninstall?**
Quit from the tray and delete the app. Nothing is written outside your output folders and the app's own config/cache directories.
## Contributing
Adding a format is one entry in `formatSetFor` in `src/components/RadialMenu.tsx` plus its handling in `perform_action` in `src-tauri/src/files.rs`; adding a tool is one entry in `toolWedges` plus one match arm. CI runs `pnpm check`, `pnpm build`, `cargo test --lib`, and a debug bundle on macOS and Windows.
**Forks and derivative works are welcome.** You may use, modify, redistribute, and build on this code commercially, provided you keep the copyright notice and the LICENSE file.
## License
Released under the **MIT License** — see [LICENSE](LICENSE) and [THIRD_PARTY_NOTICES.md](THIRD_PARTY_NOTICES.md).
The app builds against Tauri (MIT / Apache-2.0), React (MIT), Lucide (ISC), and Tesseract.js with its English and Simplified Chinese models (Apache-2.0).

408
README.zh-CN.md 100644
View File

@ -0,0 +1,408 @@
# Shift
**面向 macOS 与 Windows 的环形文件工作台。拖住文件,松开在某个扇区上,转换就在你自己的机器上完成。**
**语言:** [English](README.md) · **简体中文**
Shift 把文件格式转换、截图、录屏、标注、中英双语 OCR 全部收进一个环形菜单,它出现在你放下文件的地方。不上传、不注册、不经云端中转——每一个字节都在本地处理。
基于 Tauri 2、Rust、React 与 TypeScript 构建。原生截屏与拖拽行为封装在各平台适配器之后,因此环形菜单、编辑器与格式目录在所有平台上完全一致。
---
- [能力概览](#能力概览)
- [快速上手](#快速上手)
- [支持的文件](#支持的文件)
- [格式转换](#格式转换)
- [工具](#工具)
- [压缩、命名与取消](#压缩命名与取消)
- [截图与标注](#截图与标注)
- [OCR](#ocr)
- [快捷键](#快捷键)
- [菜单栏菜单](#菜单栏菜单)
- [输出位置](#输出位置)
- [外部依赖](#外部依赖)
- [平台支持情况](#平台支持情况)
- [从源码构建](#从源码构建)
- [架构](#架构)
- [仓库结构](#仓库结构)
- [隐私](#隐私)
- [已知限制](#已知限制)
- [常见问题](#常见问题)
- [参与贡献](#参与贡献)
- [许可证](#许可证)
---
## 能力概览
**环形菜单就是全部交互。** 在访达中按住 `Shift` 拖动文件(Windows 为 `Ctrl + Shift`),圆环会出现在光标下方。松开在某个格式上即完成转换;再加上 `Option`/`Alt` 可切换到工具环。主窗口同样接受拖放,其「文件转换」与「文件工具」按钮会先让你挑选文件,再弹出同一个圆环。
**一切按类型驱动。** 圆环只列出所选文件真正能变成的格式——图片会给出 PNG/JPG/WEBP/HEIC/TIFF/BMP/GIF/PDF,PPTX 给出 PDF 与 Markdown,而 `.key`、`.pages` 文件不会给出任何转换扇区,而不是等你点击后才失败。中心是毛玻璃预览,显示尺寸与体积;多选文件会渲染成一叠层叠图标。
**默认批量处理。** 选中十个文件、一次拖拽,就产出十个结果。结果保存在源文件旁边并附带描述性后缀(`report (compressed).pdf`、`photo (rotated).png`),永不覆盖——重名时自动追加序号。也可在设置中改为统一收集到一个文件夹。
**截图能力内置。** 冻结画面的区域截图、全屏截图,以及带悬浮计时器的区域录屏;一律对准光标所在的显示器,而非固定主屏。截图完成后直接进入标注画布,并可钉成常驻置顶的参考窗口。
**OCR 在本机运行。** 英文与简体中文,使用随应用打包的 Tesseract WASM 引擎与语言模型。OCR 全流程不发生任何网络请求。
## 快速上手
Shift 常驻菜单栏(macOS)与通知区域(Windows),同时也有普通窗口。无需一直开着某个窗口——圆环在任何地方都能唤起。
**转换文件(Shift)**
1. 在访达或资源管理器中找到文件。
2. 按住鼠标左键把文件拖起来(不要松开)。
3. 拖动过程中按住 `Shift`,圆环会出现在光标周围。
4. 朝想要的格式方向拖动——该扇区会高亮放大,中心显示它的名称——然后松开鼠标。只需朝那个方向即可,不必精确对准。
5. 状态提示会显示「已保存 N 个文件」,结果就在原文件旁边。
> 💡 `Shift` 可以在开始拖动之后再按。圆环出现后就可以松开 `Shift`,它会一直保持到你松开鼠标。
> 💡 改变主意了?把鼠标移回中心(内圈 92 px 之内)再松开,什么都不会发生。
> 💡 靠近屏幕边缘时圆环会自动移回屏幕内;整个 760 px 的圆环会被约束在光标所在显示器范围内。
**使用工具(`Option + Shift`,Windows 为 `Ctrl + Shift`)** 操作相同,扇区会从格式换成该类型文件可用的工具。圆环打开时,保持按住 `Shift`,再按下或松开 `Option`/`Ctrl`,即可在格式环与工具环之间来回切换。
**不想拖动?** 主窗口中的「文件转换」与「文件工具」会先让你挑选文件,然后对选中的文件弹出同一个圆环;「文字识别」则选取图片并识别。直接把文件拖到主窗口上,会直接打开操作环。
**一次处理多个文件。** 用 `⌘`/`Ctrl` 点选多个文件后一起拖动,每个文件都会被处理。选中 2 张以上图片或 2 个以上 PDF 时,会出现「合并」扇区,把它们合成一个 PDF。
**macOS 首次运行。** 需要授予「屏幕录制」(截图与录屏),以及你所选输出目录的「文件与文件夹」访问权限。截图前会先检查权限,因此被拒绝时给出的是可操作的提示,而不是一张全黑截图。
## 支持的文件
按扩展名识别,对应 `src-tauri/src/files.rs` 中的四张表。`kind` 决定中心图标以及会出现哪些扇区。**加粗**的扩展名是可以真正转换的;其余的只是能被识别,仅提供打开、在文件夹中显示,或提示你先去导出。
| 类型 | 扩展名 |
| --- | --- |
| `image` | **`png` `jpg` `jpeg` `webp` `tiff` `tif` `bmp` `gif`** `heic` `heif` `avif` |
| `video` | **`mp4` `mov` `m4v` `avi` `mkv` `webm`** |
| `audio` | **`mp3` `wav` `m4a` `aiff` `aif` `caf` `flac` `ogg`** |
| `pdf` | **`pdf`** |
| `document` | **`docx` `rtf` `odt` `txt` `md` `html` `htm`** `doc` `pages` |
| `presentation` | **`pptx`** `ppt` `key` |
| `spreadsheet` | **`xlsx` `xls` `xlsb` `ods` `csv` `tsv`** `numbers` |
| `other` | 未识别的类型——仅提供打开与在文件夹中显示 |
解码与编码能力并不对称,应用也不会假装对称:
- **图片解码**由 Rust `image` 原生完成,支持 PNG、JPEG、WebP、TIFF、BMP、GIF,工具环的每个操作都走这个解码器。HEIC/HEIF/AVIF 不在其中,它们的转换走系统通道——macOS 用 `sips`,其他系统用 ImageMagick——因此旋转、翻转、黑白、50%、压缩在处理这些格式前需要先转一次。
- **图片编码**中的 PNG、JPG、WebP、TIFF、BMP、GIF 为原生实现。HEIC 导出在 macOS 走 `sips`,在 Windows/Linux 需要 ImageMagick。AVIF 可以正常读取,同一套系统通道也能写出,但圆环暂未提供该选项。
- **音视频**的解码与编码范围取决于你的 FFmpeg 构建;菜单为视频提供 MP4、MOV、GIF、M4A,为音频提供 M4A、WAV、MP3。
- **Office 文件**以纯 Rust 解析(表格用 `calamine`,PPTX 用 `zip` + `quick-xml`),因此无需安装 Office。
- **可识别但不转换:** `.doc`、`.pages`、`.ppt`、`.key`、`.numbers` 会显示各自类型的图标,并提供编辑、打开、在文件夹中显示,但没有格式扇区。请先导出为 DOCX、PPTX 或 XLSX。
## 格式转换
以下是各文件类型在格式环中的选项。每一条转换路径都实现在 `src-tauri/src/files.rs`。
| 源类型 | 圆环提供 | 引擎 | 说明 |
| --- | --- | --- | --- |
| 图片 | `PNG` `JPG` `WEBP` `TIFF` `BMP` `GIF` | Rust `image` | 编码器允许时走无损路径 |
| 图片 | `HEIC` | `sips` / ImageMagick | macOS 原生;其他系统需要 `magick` |
| 图片 | `PDF` | `printpdf` | 每张图一页,按 300 dpi 定尺寸 |
| 视频 | `MP4` `MOV` | FFmpeg | 优先 `libx264`,依次回退 `h264_videotoolbox`、`mpeg4` |
| 视频 | `GIF` | FFmpeg | 仅取前 15 秒、12 fps、宽 480 px——设有上限,避免长时间录屏产出上百 MB 的 GIF |
| 视频 | `M4A` | FFmpeg | 仅保留音频轨,192k AAC |
| 音频 | `M4A` `WAV` `MP3` | FFmpeg | 若 FFmpeg 缺少 `libmp3lame`,MP3 回退到 `lame` |
| PDF | `TXT` `MD` | `lopdf` | 抽取文字层;扫描件会明确报错并引导使用文字识别 |
| PDF | `DOCX` `RTF` | `lopdf` + Pandoc | 以文字层作为正文;需要 Pandoc |
| PDF | `HEIC` | PDFKit / Poppler + `sips` | 先渲染为 PNG 再转码;需要系统 HEIC 编码器 |
| PDF | `PNG` `JPG` `TIFF` | PDFKit / Poppler | 每页一个文件,输出到 `… pages` 文件夹 |
| 文档 `docx` `rtf` `odt` `txt` `md` `html` | `PDF` | AppKit 渲染器(macOS)· 其他系统 Pandoc | macOS 路径不需要 LaTeX 或 wkhtmltopdf |
| 文档 `docx` `rtf` `odt` `txt` `md` `html` | `DOCX` `RTF` `HTML` `TXT` `MD` `ODT` | Pandoc | Markdown 以 GFM 写出 |
| 演示文稿 `.pptx` | `MD` `PDF` | 纯 Rust + Pandoc | 按页生成标题、要点文字,**表格会输出为真正的 Markdown 表格**;PDF 仍是文字摘要版,非版面还原 |
| 电子表格 | `MD` `PDF` | `calamine` / 纯 Rust | 每个工作表一张 Markdown 表;`csv`/`tsv` 直接解析 |
表中没有的转换不会出现在界面上——圆环在运行时按这份目录生成,因此看得见的扇区就是能用的扇区。若缺少依赖,扇区会直接告诉你需要安装什么,而不是静默失败。
> 说明:与部分环形转换工具不同,Shift **不会**隐藏文件自身的格式。拖动 PNG 时仍会出现 PNG,这也是一键重编码、统一画质的好办法。
> 扫描件/纯图片 PDF 没有文字层,选 `TXT`/`MD` 会返回明确报错——请改用「文字识别」,它会先把每页渲染成图片。
## 工具
工具环(拖拽时按 `Option + Shift`)。这些是一次手势完成的操作,不属于格式转换。
| 工具 | 适用对象 | 输出 | 具体行为 |
| --- | --- | --- | --- |
| 压缩 | 图片、视频、音频、PDF | `.jpg`/`.png`、`.mp4`、`.m4a`、`.pdf` | 图片按 q68 重编码(含透明通道则保留 PNG);视频 CRF 28;音频转 128k AAC;PDF 先把内嵌图片降采样到 ≤1440 px 的 q60 JPEG,再清理对象 |
| 元数据 | 图片、PDF | 同类型,` (clean)` | 重写图片并去除 EXIF;移除 PDF 的 `/Info` 与 `/Metadata` |
| 旋转 | 图片、PDF | 同类型,` (rotated)` | 顺时针 90°,按各格式的原生方式处理 |
| 翻转 | 图片 | 同类型,` (flipped)` | 水平镜像 |
| 黑白 | 图片 | 同类型,` (bw)` | 转灰度 |
| 50% | 图片 | 同类型,` (50%)` | 宽高各减半,Lanczos3 |
| 裁剪 | 图片 | `.png`,` (cropped)` | 环形菜单中的裁剪会打开编辑器进行交互式框选 |
| 抠图 | 图片 | — | 打开编辑器,按采样到的背景色抠除背景 |
| 合并 | 2 张以上图片 | `.pdf`,` (images)` | 每图一页,按选中顺序排列 |
| 合并 | 2 个以上 PDF | `.pdf`,` (merged)` | 按选中顺序拼接 |
| 拆分 | PDF | `Page 001.pdf` … | 每页一个 PDF,输出到 `… pages` 文件夹 |
| 提取文字 | PDF | `.txt` | 仅文字层;扫描件请用「文字识别」 |
| 720p | 视频 | `.mp4`,` (720p)` | 缩放到 720p 高度,保持宽高比 |
| 静音 | 视频 | 同类型,` (muted)` | 去掉音轨,视频流直接复制、不重编码 |
| 截帧 | 视频 | `.png`,` (frame)` | 取首帧导出为静帧 |
| 提取音频 | 视频 | `.m4a` | 192k AAC |
| 单声道 | 音频 | `.m4a`,` (mono)` | 下混为单声道 128k AAC |
| 纯文本 | 文档 | `.txt` | 通过 Pandoc 导出纯文本 |
| 文字识别 | 图片、PDF | `.txt`,` (OCR)` | 见 [OCR](#ocr) |
| 编辑 / 标注 / 打码 / 加背景 | 图片 | — | 打开编辑器并预选对应工具 |
| 打开 · 在文件夹中显示 | 任意文件 | — | 交由系统默认应用或文件管理器 |
## 压缩、命名与取消
**「压缩」具体做了什么。**
| 输入 | 行为 |
| --- | --- |
| 图片 | 按画质 68 重新编码。含透明通道的图片写出 PNG,其余写出 JPG |
| PDF | 超过 1440 px 的内嵌图片先降采样为 q60 JPEG,再清理、重编号对象并压缩保存。若结果没有更小则不写出文件 |
| 视频 | 以 CRF 28 / 目标码率 2M 重编码,AAC 96k 音频,输出 MP4 |
| 音频 | 转为 128k AAC 的 M4A |
**输出命名——永不覆盖任何文件。** 结果保存在源文件旁边并附带描述性后缀;重名时追加 ` 2`、` 3`……而不是替换原文件。
```text
report (compressed).pdf photo (rotated).png slide (bw).png
report (clean).pdf photo (50%).png report (merged).pdf
```
PDF 转图片与 PDF 拆分会新建 `名称 pages` 文件夹,内含 `Page 001.png`、`Page 002.png`……再执行一次会生成 `名称 pages 2`,同样不会覆盖。
**取消手势。** 在圆环中心附近、或圆环范围之外松开鼠标,不会执行任何操作。
## 截图与标注
**截图。** 区域截图会先铺一层冻结画面,你框选的像素就是最终得到的像素;全屏截图则完全跳过遮罩层。录屏在 macOS 通过 `screencapture -v` 保存为 MOV,其他系统通过 FFmpeg 保存为 MP4,配有悬浮计时器与停止按钮。Linux 截图优先使用 `grim`,回退到 `gnome-screenshot`。
**标注。** 编辑器画布按原始分辨率工作,并写出新的 PNG,因此源文件永远不会被修改。
| 工具 | 行为 |
| --- | --- |
| 矩形、箭头、高亮、文字 | 自由绘制,每条标注可单独设置颜色与粗细 |
| 打码 | 实心黑色遮挡条,直接烧入输出图像——不是覆盖层 |
| 马赛克 | 对下方区域做真实采样降采样,不是半透明填充 |
| 序号 | 自动递增的序号标记 |
| 裁剪 | 交互式裁剪,带明确的「应用裁剪」步骤 |
| 加背景 | 圆角留白加渐变底,适合社交配图与幻灯片插图 |
| 抠图 | 采样四角、求平均背景色,并将其抠为透明 |
| 撤销 | 先回退标注,再回退图像级操作 |
| 保存副本 / 复制 | 另存为带后缀的新文件,或直接写入剪贴板 |
| 钉在屏幕上 | 将图片浮为置顶窗口,带复制与关闭按钮 |
**编辑器。** 图片打开标注画布;视频打开播放器;`txt` `md` `csv` `tsv` `html` `htm` 以可编辑文本打开。每个编辑器都提供复制、另存为、打开、在文件夹中显示、文字识别与复制文字。
## OCR
界面中对应「文字识别」(图片与扫描件)和「提取文字」(含文字层的 PDF)两处按钮。
使用 Tesseract.js 的 LSTM 内核,以 WASM 形式在应用内运行。`eng` 与 `chi_sim` 语言模型在构建时由 `pnpm prepare:ocr` 复制到 `public/tesseract`,因此识别无需联网,首次运行也不会下载任何东西。
- **图片**——单次识别,实时显示进度,结果可进入编辑器或剪贴板。
- **扫描版 PDF**——先把各页渲染成图片,再逐页识别并显示每页进度,结果写入 ` (OCR)` 文本文件,页与页之间用 `--- Page N ---` 分隔。
- **含文字层的 PDF**——请改用「提取文字」,它直接读取内嵌文字层,速度远快于 OCR。
## 快捷键
| 操作 | macOS | Windows / Linux |
| --- | --- | --- |
| 区域截图 | `⌥⇧2` | `Alt+Shift+2` |
| 区域录屏 | `⌥⇧3` | `Alt+Shift+3` |
| 全屏截图 | `⌥⇧4` | `Alt+Shift+4` |
| 拖拽时显示格式环 | 按住 `⇧` | 按住 `Shift` |
| 拖拽时显示工具环 | `⌥⇧` | `Ctrl+Shift` |
三个截图快捷键注册为全局快捷键。拖拽圆环由修饰键驱动:在开始拖动之前就按住修饰键,圆环会直接出现在光标处,无需先让 Shift 获得焦点。
## 菜单栏菜单
菜单栏(macOS)与通知区域(Windows)图标提供这些快捷入口:
| 菜单项 | 快捷键 | 作用 |
| --- | --- | --- |
| Open Shift | — | 显示主窗口 |
| Capture area | `Alt+Shift+2` | 开始区域截图 |
| Capture full screen | `Alt+Shift+4` | 截取光标所在显示器 |
| Record area | `Alt+Shift+3` | 开始或停止区域录屏 |
| OCR an image… | — | 选择图片并在本机识别文字 |
| Quit Shift | `Cmd/Ctrl+Q` | 退出;若有正在进行的录屏会先收尾保存 |
菜单项文案目前仅有英文;窗口内的界面会跟随应用语言。
设置面板的「行为」区有两个开关:**拖拽圆环**(Shift 拖拽手势的总开关)与**开机时启动**。
## 输出位置
| 结果 | 默认位置 |
| --- | --- |
| 截图 | `~/Pictures/Shift` |
| 录屏 | `~/Movies/Shift` |
| 文件操作 | 源文件所在文件夹 |
三者都可在设置中修改。文件操作另外提供「统一收集到一个文件夹」模式,替代默认的就近保存。设置面板会列出所有解析后的实际路径、检测该路径是否可写、在文件管理器中显示它,并在缺少权限时直接跳转到 macOS 的「屏幕录制」与「文件与文件夹」隐私面板。
## 外部依赖
核心转换、环形菜单、截图与 OCR 在零外部依赖的情况下即可工作。以下工具用于扩展能力边界:
| 工具 | 用于 | macOS | Windows | Linux |
| --- | --- | --- | --- | --- |
| FFmpeg | 音视频转换/压缩、720p、静音、截帧、单声道;非 macOS 的录屏 | 可选 | 录屏**必需** | **必需** |
| Pandoc | 文档 ↔ DOCX/RTF/ODT/HTML/TXT/MD | 可选 | 需要 | 需要 |
| Poppler `pdftoppm` | PDF 转图片、扫描件 OCR | 不需要(PDFKit) | 需要 | 需要 |
| ImageMagick `magick` | HEIC/AVIF 编码 | 不需要(`sips`) | 需要 | 需要 |
| LAME | 当 FFmpeg 缺少 `libmp3lame` 时的 MP3 编码 | 少见 | 少见 | 少见 |
这些工具在调用时从 `PATH` 查找并缓存结果,因此缺失某个依赖只会影响对应的扇区,不会影响整个应用。
## 平台支持情况
| 能力 | macOS | Windows | Linux |
| --- | --- | --- | --- |
| 环形菜单、编辑器、托盘、多语言 | 支持 | 支持 | 支持 |
| 拖拽唤起圆环 | AppKit 全局拖拽桥 | Win32 拖拽状态轮询 + 原生拖放 | 暂不支持——仅能用主窗口选择文件 |
| 区域 / 全屏截图 | `screencapture` | PowerShell | `grim` / `gnome-screenshot` |
| 跟随光标所在显示器 | 支持 | 支持 | `grim` 输出选择 |
| 区域录屏 | `screencapture -v` | FFmpeg | 计划中 |
| 图片转换与编辑 | 支持 | 支持 | 支持 |
| HEIC / AVIF 编码 | `sips` | ImageMagick | ImageMagick |
| PDF 文字、合并、拆分、旋转、压缩 | 支持 | 支持 | 支持 |
| PDF 转图片 | PDFKit 伴生进程(HEIC 需 `sips`) | Poppler(HEIC 需 ImageMagick) | Poppler(HEIC 需 ImageMagick) |
| 扫描件文字识别 | 支持 | 需 Poppler | 需 Poppler |
| 文档转 PDF | 内置 AppKit 渲染器 | Pandoc + PDF 引擎 | Pandoc + PDF 引擎 |
| PPTX / XLSX / ODS 转 Markdown | 支持(纯 Rust) | 支持 | 支持 |
| 本地中英文字识别 | 支持 | 支持 | 支持 |
## 从源码构建
需要 Node.js 20+、pnpm 8+、Rust 1.90+;构建 macOS 原生伴生进程还需 macOS 13+ 与 Xcode 命令行工具。
```bash
pnpm install
pnpm mac:drag-bridge # 仅 macOS —— AppKit 拖拽桥、PDFKit 与文档渲染器
pnpm tauri dev
```
`pnpm mac:drag-bridge` 会把 `native/macos/*.swift` 编译为 `src-tauri/binaries` 下的分架构与通用(universal)伴生进程。Windows 与 Linux 完全跳过这一步。
```bash
pnpm check # TypeScript 类型检查,不产出文件
pnpm build # tsc + vite
cargo test --lib # Rust 单元测试,在 src-tauri/ 目录下执行
pnpm tauri build # 发布构建
```
macOS 通用(Universal)构建:
```bash
rustup target add aarch64-apple-darwin x86_64-apple-darwin
pnpm mac:drag-bridge
RUSTUP_TOOLCHAIN=stable pnpm tauri build --target universal-apple-darwin --bundles app
```
产物是单个通用 Mach-O,内含通用版的拖拽、PDF 渲染与文档渲染伴生进程。Windows 构建步骤见 `docs/BUILD_WINDOWS.md`。
**权限(macOS)。** 截图与录屏需要「屏幕录制」,输出目录需要「文件与文件夹」授权,带声音录屏需要「麦克风」。Shift 会在打开截图遮罩前先检查屏幕录制权限,因此被拒绝时给出的是可操作的提示,而不是一张全黑的截图。使用本地证书签名的开发构建,可以在反复重编译后保持这些授权稳定;对外分发则需要 Developer ID 证书与公证。
## 架构
```text
React UI 单一 webview,五种视图
├─ main 拖放目标、快捷键、最近输出、语言、设置
├─ radial 透明置顶圆环,按极角扇区命中判定
├─ capture 冻结画面 + 区域框选
├─ recorder 悬浮计时器与停止按钮
├─ editor 标注画布、文本、视频、OCR
└─ pin 置顶图片参考窗
Tauri 命令层 src-tauri/src/
├─ files.rs 检视、转换、压缩、元数据、旋转、裁剪、音视频
├─ pdf.rs 合并、拆分、旋转、文字、渲染、图片转 PDF、压缩
├─ office.rs PPTX 与电子表格转 Markdown,纯 Rust
├─ capture.rs 全屏截图、区域裁剪、交给编辑器
├─ recording.rs screencapture / FFmpeg,以中断方式收尾
├─ drag_bridge.rs 全局拖拽检测、圆环模式、环形菜单定位
├─ settings.rs 输出目录、可写检测、隐私面板深链
└─ editor.rs 编辑器与钉图窗口状态
平台适配器
├─ macOS AppKit 拖拽桥 · PDFKit 渲染器 · AppKit 文档渲染器 · screencapture
├─ Windows Win32 拖拽状态 · PowerShell 截图 · FFmpeg · Poppler
└─ Linux grim / gnome-screenshot · FFmpeg · Poppler
OCR:Tesseract.js WASM + 内置 eng/chi_sim,进程内运行,完全离线
```
环形菜单的命中判定是纯几何计算——同一套极角运算同时服务于原生指针事件、webview 悬停与 Windows 的拖放数据,因此圆环行为不会在各平台之间产生偏差。
## 仓库结构
```text
src/ React 界面、多语言(en/zh)、Tauri API 绑定
src-tauri/src/ Rust 命令层与平台适配器
native/macos/ Swift 伴生进程:拖拽桥、PDF 渲染器、文档渲染器
由 pnpm mac:drag-bridge 编译进 src-tauri/binaries/
scripts/ OCR 资源准备、macOS 伴生进程构建
public/tesseract/ WASM 内核与语言模型,构建生成,不提交
assets/ 应用图标源文件
src-tauri/icons/ 各平台生成的应用图标
docs/ Windows 构建指南、路线图
.github/workflows/ macOS 与 Windows CI
FileFlipper/ 独立姊妹项目,拥有自己的仓库
```
## 隐私
Shift 不发起任何网络请求。文件在本地读取、转换、写回;OCR 在进程内基于内置模型运行;最近输出只是本地列表。既不上传,也不收集。
## 已知限制
- Windows/Linux 上的文档转 PDF 仍需 Pandoc 加上可用的 PDF 引擎;内置的 AppKit 渲染器仅限 macOS。
- PPTX 与电子表格转 PDF 是文字与表格摘要,不是版面精确还原。
- `.doc`、`.pages`、`.ppt`、`.key`、`.numbers` 可识别但不解析——请先导出为 DOCX/PPTX/XLSX。
- HEIC/HEIF/AVIF 通过系统解码器转换,但像素类工具需要 PNG/JPEG/WebP/TIFF/BMP/GIF 输入;AVIF 暂未提供为导出目标。
- PDF 压缩会把内嵌图片降采样到最长边 1440 px、q60 JPEG。凡是不能确认可安全往返的内容都会原样保留——蒙版、索引色/CMYK、JPX/JBIG2/CCITT——因此部分特殊扫描件仍难以压缩。
- Windows 的录屏与音视频转换要求 `PATH` 中存在 `ffmpeg`。
- Windows 代码路径可编译并通过 CI,但手势层面的验证仍需真实 Windows 设备。
- macOS 上签名身份变化后,可能需要重新授予「屏幕录制」与「辅助功能」权限。
路线图见 `docs/ROADMAP.md`。
## 常见问题
**❓ 按住 Shift 拖文件,圆环没出现。**
一定要先开始拖动——按住鼠标并把文件拖过拖动阈值——在拖动过程中按住 `Shift`。只选中文件再按 `Shift` 是没有反应的。Windows 需要在拖拽越过系统阈值的那一刻按住 `Shift`;同一时刻再按 `Ctrl` 则进入工具环。
**❓ 提示这类文件没有可用格式。**
未识别的扩展名仅提供打开与在文件夹中显示;旧版 Apple/Office 格式(`.doc`、`.pages`、`.ppt`、`.key`、`.numbers`)刻意不提供转换。请先导出为 DOCX、PPTX 或 XLSX。
**❓ 能开机自启吗?能一键停用吗?**
都可以,位置在设置面板的「行为」区。**拖拽圆环**是 Shift 拖拽手势的总开关:关闭后不会再出现任何圆环,而托盘、主窗口与快捷键照常可用。**开机时启动**会在 macOS 写入 LaunchAgent、Windows 写入 `HKCU\...\Run`、Linux 写入 autostart `.desktop`,同一开关即可撤销。
登录项只对当前用户生效,并指向 .app 包本身,因此 macOS 的屏幕录制授权身份在多次启动间保持一致。若移动了应用位置,请重新切换一次该开关。
**❓ 我的文件会被上传吗?**
不会。代码里不存在上传路径,转换与 OCR 流程也不发起任何网络请求;Tesseract 模型随应用一起打包。不收集数据,也没有账号体系。
**❓ 输出文件去哪儿了?**
默认在源文件旁边,带描述性后缀。可先看主窗口的最近列表,点击条目即可打开结果;设置面板会列出全部实际输出路径并可在文件管理器中显示。
**❓ 支持哪些语言?**
英文与简体中文,可在主窗口的设置中切换;首次启动时跟随系统语言。托盘菜单与 macOS 系统权限弹窗仍为英文。
**❓ 能先标注、不保存原图吗?**
可以。标注工作在画布副本上,只有「保存副本」或「复制」才会写盘,源文件永不被修改。也可以「钉在屏幕上」,把它作为浮动参考图。
**❓ 怎么卸载?**
从托盘退出,然后删除应用即可。除你指定的输出目录和应用自身的配置/缓存目录外,不会写入其他位置。
## 参与贡献
新增一种格式 = 在 `src/components/RadialMenu.tsx` 的 `formatSetFor` 中加一项,并在 `src-tauri/src/files.rs` 的 `perform_action` 中加对应处理;新增一个工具 = 在 `toolWedges` 加一项加一个 match 分支。CI 会执行 `pnpm check`、`pnpm build`、`cargo test --lib`,并在 macOS 与 Windows 上产出 debug 包。
**欢迎二次开发。** 你可以免费使用、修改、再发布本代码,也可用于商业项目,只需保留原版权声明与 LICENSE 文件。
## 许可证
以 **MIT 许可证**发布——见 [LICENSE](LICENSE) 与 [THIRD_PARTY_NOTICES.md](THIRD_PARTY_NOTICES.md)。
本应用构建使用了 Tauri(MIT / Apache-2.0)、React(MIT)、Lucide(ISC),以及 Tesseract.js 与其英文、简体中文模型(Apache-2.0)。

View File

@ -0,0 +1,12 @@
# Third-party notices
Shift includes or builds against the following open-source components:
- Tauri: MIT or Apache-2.0.
- React: MIT.
- Lucide icons: ISC.
- Tesseract.js: Apache-2.0.
- tesseract.js-core: Apache-2.0.
- tessdata_fast English and Simplified Chinese models: Apache-2.0.
See each package's license file under `node_modules` or its upstream repository for the complete text.

30
assets/icon.svg 100644
View File

@ -0,0 +1,30 @@
<svg width="1024" height="1024" viewBox="0 0 1024 1024" fill="none" xmlns="http://www.w3.org/2000/svg">
<defs>
<linearGradient id="bg" x1="120" y1="92" x2="884" y2="930" gradientUnits="userSpaceOnUse">
<stop stop-color="#FFB25C"/>
<stop offset="0.48" stop-color="#FF6B35"/>
<stop offset="1" stop-color="#C66BFF"/>
</linearGradient>
<radialGradient id="shine" cx="0" cy="0" r="1" gradientUnits="userSpaceOnUse" gradientTransform="translate(344 276) rotate(46) scale(760)">
<stop stop-color="white" stop-opacity="0.32"/>
<stop offset="1" stop-color="white" stop-opacity="0"/>
</radialGradient>
<filter id="shadow" x="86" y="110" width="852" height="852" filterUnits="userSpaceOnUse">
<feDropShadow dx="0" dy="24" stdDeviation="28" flood-color="#7A3018" flood-opacity="0.28"/>
</filter>
</defs>
<rect width="1024" height="1024" rx="228" fill="url(#bg)"/>
<rect width="1024" height="1024" rx="228" fill="url(#shine)"/>
<g filter="url(#shadow)">
<circle cx="512" cy="512" r="326" fill="#FFF4EA" fill-opacity="0.96"/>
<path d="M512 186A326 326 0 0 1 808.5 358L604.4 476A145 145 0 0 0 512 367V186Z" fill="#FFE9D5"/>
<path d="M808.5 358A326 326 0 0 1 808.5 666L604.4 548A145 145 0 0 0 604.4 476L808.5 358Z" fill="#FFDCC4"/>
<path d="M808.5 666A326 326 0 0 1 512 838V657A145 145 0 0 0 604.4 548L808.5 666Z" fill="#FFE3CE"/>
<path d="M512 838A326 326 0 0 1 215.5 666L419.6 548A145 145 0 0 0 512 657V838Z" fill="#FFD7C0"/>
<path d="M215.5 666A326 326 0 0 1 215.5 358L419.6 476A145 145 0 0 0 419.6 548L215.5 666Z" fill="#FFE9D5"/>
<path d="M215.5 358A326 326 0 0 1 512 186V367A145 145 0 0 0 419.6 476L215.5 358Z" fill="#FFF0E2"/>
<circle cx="512" cy="512" r="157" fill="#FFF9F4"/>
<circle cx="512" cy="512" r="120" fill="#FF6B35"/>
<path d="M512 420V604M420 512H604" stroke="#FFF9F4" stroke-width="46" stroke-linecap="round"/>
</g>
</svg>

After

Width:  |  Height:  |  Size: 1.9 KiB

View File

@ -0,0 +1,57 @@
# Windows build
## Requirements
- Windows 10/11 x64
- Visual Studio Build Tools with the Desktop development with C++ workload
- WebView2 Runtime (included with current Windows releases)
- Node.js 20+ and pnpm 8+
- Rust stable through rustup
- FFmpeg on `PATH` for screen recording and media conversion
- Pandoc on `PATH` for document conversion
- Poppler (`pdftoppm`) on `PATH` for PDF-to-image rendering
- ImageMagick (`magick`) if HEIC/AVIF export is required
## Build
```powershell
pnpm install
pnpm check
pnpm build
cd src-tauri
cargo check
cd ..
pnpm tauri build
```
The installer is written below `src-tauri\target\release\bundle`.
## Runtime behavior
- Hold `Shift` while starting a file drag, then move past the Windows drag threshold. Shift places a transparent radial window under the pointer and receives the native OLE drop.
- Hold `Ctrl + Shift` for the tool ring.
- Global shortcuts use `Alt + Shift + 2`, `Alt + Shift + 3`, and `Alt + Shift + 4`.
- The first screen capture uses the same local-only processing paths as macOS; no cloud service is involved.
## Cross-compile check from macOS
The Windows-specific Rust code can be type-checked from macOS:
```bash
rustup target add x86_64-pc-windows-msvc
PATH="/opt/homebrew/opt/llvm/bin:$PATH" \
cargo check --target x86_64-pc-windows-msvc
```
This proves `cfg(windows)` code compiles. Interactive drag/drop and FFmpeg recording still need a real Windows host for runtime QA.
## Cross-build a Windows EXE from macOS
```bash
cargo install cargo-xwin --locked
cd src-tauri
cargo +stable xwin build --target x86_64-pc-windows-msvc --release
```
The executable is written to `src-tauri/target/x86_64-pc-windows-msvc/release/shift.exe`.
It needs the Microsoft WebView2 Runtime on the target machine. FFmpeg, Poppler and Pandoc remain optional external tools for recording, PDF rendering and document conversion.

40
docs/ROADMAP.md 100644
View File

@ -0,0 +1,40 @@
# Shift Roadmap
## M1: Foundation
- Tangerine radial menu and transition between format/tool rings.
- Global Shift-drag bridge on macOS.
- Area screenshot, area recording, local EN/ZH OCR.
- Image conversion and basic file operations.
- Shared English/Chinese UI and tray app.
- Launch at login and a master enable switch for the drag rings, both in Settings.
## M2: Capture parity
- Multi-display capture for the monitor under the pointer is implemented; per-display recording QA is ongoing.
- Annotation canvas: crop, rectangle, arrow, text, highlight, black-bar redaction, pixelate/mosaic, numbering and gradient background are implemented; blur and stamps are next.
- Pinned screenshot windows with copy and close controls are implemented.
- Recording controls: resolution, frame rate, audio source, pause/resume.
- Capture history library with search, pinning and drag-out.
- Quick-access overlay after capture, matching CleanShot's floating result card.
## M3: File workspace
- PDF, image, media, DOCX and Markdown paths are implemented; DOC/DOCX/ODT/RTF/HTML/TXT to PDF is implemented on macOS through the bundled AppKit renderer; PowerPoint/Excel basic text/table PDF export is implemented, with layout-accurate export next.
- Batch operations and drag-to-submenu interaction.
- Custom radial item ordering and per-file-type presets.
- Undo history and conflict-safe output naming.
## M4: Cross-platform parity
- Windows global drag bridge using the Win32/OLE drag state is implemented.
- Windows native capture backend without PowerShell where practical.
- Linux Wayland and X11 capture backends.
- Universal macOS build is implemented; Windows ARM64 build is pending.
## M5: Distribution
- Signed and notarized macOS package.
- Signed Windows installer.
- Automatic updates with signed manifests.
- Permission onboarding and diagnostics screen.

13
index.html 100644
View File

@ -0,0 +1,13 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta name="theme-color" content="#f4a261" />
<title>Shift</title>
</head>
<body>
<div id="root"></div>
<script type="module" src="/src/main.tsx"></script>
</body>
</html>

View File

@ -0,0 +1,107 @@
import AppKit
import Foundation
func fail(_ message: String) -> Never {
FileHandle.standardError.write((message + "\n").data(using: .utf8)!)
exit(1)
}
guard CommandLine.arguments.count == 3 else {
fail("usage: doc-render <input> <output.pdf>")
}
let input = URL(fileURLWithPath: CommandLine.arguments[1])
let output = URL(fileURLWithPath: CommandLine.arguments[2])
let extensionName = input.pathExtension.lowercased()
var documentType: NSAttributedString.DocumentType?
switch extensionName {
case "docx":
documentType = .officeOpenXML
case "doc":
documentType = .docFormat
case "odt":
documentType = .openDocument
case "rtf":
documentType = .rtf
case "rtfd":
documentType = .rtfd
case "html", "htm":
documentType = .html
case "txt", "md", "markdown":
documentType = .plain
default:
documentType = nil
}
var options: [NSAttributedString.DocumentReadingOptionKey: Any] = [:]
if let documentType {
options[.documentType] = documentType
}
if documentType == .html {
options[.baseURL] = input.deletingLastPathComponent()
}
let data: Data
do {
data = try Data(contentsOf: input)
} catch {
fail("could not read input: \(error.localizedDescription)")
}
let attributed: NSAttributedString
do {
attributed = try NSAttributedString(data: data, options: options, documentAttributes: nil)
} catch {
fail("could not parse document: \(error.localizedDescription)")
}
let app = NSApplication.shared
app.setActivationPolicy(.prohibited)
let printInfo = NSPrintInfo.shared.copy() as! NSPrintInfo
printInfo.paperSize = NSSize(width: 595.2, height: 841.8)
printInfo.topMargin = 42
printInfo.bottomMargin = 42
printInfo.leftMargin = 48
printInfo.rightMargin = 48
printInfo.horizontalPagination = .fit
printInfo.verticalPagination = .automatic
printInfo.isHorizontallyCentered = false
printInfo.isVerticallyCentered = false
printInfo.jobDisposition = .save
printInfo.dictionary()[NSPrintInfo.AttributeKey.jobSavingURL] = output
let printable = printInfo.imageablePageBounds
let textView = NSTextView(frame: NSRect(x: 0, y: 0, width: printable.width, height: 1))
textView.isEditable = false
textView.isSelectable = false
textView.drawsBackground = false
textView.textContainerInset = .zero
textView.textContainer?.lineFragmentPadding = 0
textView.textContainer?.widthTracksTextView = true
textView.textContainer?.containerSize = NSSize(
width: printable.width,
height: .greatestFiniteMagnitude
)
textView.textStorage?.setAttributedString(attributed)
guard let layoutManager = textView.layoutManager,
let textContainer = textView.textContainer else {
fail("could not create text layout")
}
layoutManager.ensureLayout(for: textContainer)
let used = layoutManager.usedRect(for: textContainer)
let height = max(1, ceil(used.height))
textView.frame = NSRect(x: 0, y: 0, width: printable.width, height: height)
let operation = NSPrintOperation(view: textView, printInfo: printInfo)
operation.showsPrintPanel = false
operation.showsProgressPanel = false
if !operation.run() {
fail("could not render PDF")
}
guard FileManager.default.fileExists(atPath: output.path) else {
fail("PDF was not created")
}

View File

@ -0,0 +1,94 @@
import AppKit
import Foundation
struct Payload: Encodable {
let type: String
let x: Double?
let y: Double?
let files: [String]?
let tools: Bool?
}
func emit(_ payload: Payload) {
let encoder = JSONEncoder()
guard let data = try? encoder.encode(payload),
let line = String(data: data, encoding: .utf8) else { return }
print(line)
fflush(stdout)
}
func cursorLocation() -> NSPoint {
if let event = CGEvent(source: nil) {
return event.location
}
return NSEvent.mouseLocation
}
let dragPasteboard = NSPasteboard(name: .drag)
var mouseWasDown = false
var pickerShown = false
var toolsMode = false
var changeCountAtMouseDown = dragPasteboard.changeCount
var lastX = Double.nan
var lastY = Double.nan
func draggedFileURLs() -> [String] {
let objects = dragPasteboard.readObjects(
forClasses: [NSURL.self],
options: [.urlReadingFileURLsOnly: true]
)
return (objects as? [URL])?.map(\.path) ?? []
}
func tick() {
if getppid() == 1 {
exit(0)
}
let mouseDown = NSEvent.pressedMouseButtons & 1 != 0
let point = cursorLocation()
if !mouseDown {
changeCountAtMouseDown = dragPasteboard.changeCount
}
if !mouseDown && mouseWasDown && pickerShown {
pickerShown = false
emit(Payload(type: "end", x: point.x, y: point.y, files: nil, tools: nil))
}
mouseWasDown = mouseDown
guard mouseDown else { return }
let flags = NSEvent.modifierFlags.intersection(.deviceIndependentFlagsMask)
let shift = flags.contains(.shift)
let option = flags.contains(.option)
if !pickerShown {
guard shift, dragPasteboard.changeCount != changeCountAtMouseDown else { return }
let files = draggedFileURLs()
guard !files.isEmpty else { return }
pickerShown = true
toolsMode = option
lastX = point.x
lastY = point.y
emit(Payload(type: "show", x: point.x, y: point.y, files: files, tools: option))
return
}
if shift && option != toolsMode {
toolsMode = option
emit(Payload(type: "mode", x: point.x, y: point.y, files: nil, tools: option))
}
if abs(point.x - lastX) > 0.5 || abs(point.y - lastY) > 0.5 {
lastX = point.x
lastY = point.y
emit(Payload(type: "move", x: point.x, y: point.y, files: nil, tools: nil))
}
}
let timer = Timer(timeInterval: 1.0 / 30.0, repeats: true) { _ in
tick()
}
RunLoop.main.add(timer, forMode: .common)
RunLoop.main.run()

View File

@ -0,0 +1,55 @@
import AppKit
import Foundation
import PDFKit
func fail(_ message: String) -> Never {
FileHandle.standardError.write((message + "\n").data(using: .utf8)!)
exit(1)
}
guard CommandLine.arguments.count == 4 else {
fail("usage: pdf-render <input.pdf> <output-dir> <png|jpg|tiff>")
}
let input = URL(fileURLWithPath: CommandLine.arguments[1])
let outputDirectory = URL(fileURLWithPath: CommandLine.arguments[2], isDirectory: true)
let extensionName = CommandLine.arguments[3].lowercased()
let fileType: NSBitmapImageRep.FileType
switch extensionName {
case "png": fileType = .png
case "jpg", "jpeg": fileType = .jpeg
case "tif", "tiff": fileType = .tiff
default: fail("unsupported image format: \(extensionName)")
}
try FileManager.default.createDirectory(at: outputDirectory, withIntermediateDirectories: true)
guard let document = PDFDocument(url: input) else {
fail("could not open PDF: \(input.path)")
}
for index in 0..<document.pageCount {
guard let page = document.page(at: index) else { continue }
let bounds = page.bounds(for: .mediaBox)
let scale = min(2.0, 3000.0 / max(bounds.width, bounds.height, 1.0))
let size = NSSize(
width: max(1, bounds.width * scale),
height: max(1, bounds.height * scale)
)
let pageImage = page.thumbnail(of: size, for: .mediaBox)
let canvas = NSImage(size: size)
canvas.lockFocus()
NSColor.white.setFill()
NSRect(origin: .zero, size: size).fill()
pageImage.draw(in: NSRect(origin: .zero, size: size))
canvas.unlockFocus()
guard let tiff = canvas.tiffRepresentation,
let bitmap = NSBitmapImageRep(data: tiff),
let data = bitmap.representation(using: fileType, properties: [:]) else {
fail("could not render page \(index + 1)")
}
let output = outputDirectory.appendingPathComponent(
String(format: "Page %03d.%@", index + 1, extensionName == "jpeg" ? "jpg" : extensionName)
)
try data.write(to: output)
}

38
package.json 100644
View File

@ -0,0 +1,38 @@
{
"name": "shift",
"private": true,
"version": "0.1.0",
"type": "module",
"scripts": {
"prepare:ocr": "bash scripts/prepare-ocr-assets.sh",
"predev": "pnpm prepare:ocr",
"prebuild": "pnpm prepare:ocr",
"dev": "vite --port 1420 --strictPort",
"build": "tsc && vite build",
"preview": "vite preview",
"tauri": "tauri",
"check": "tsc --noEmit",
"mac:drag-bridge": "bash scripts/build-macos-drag-bridge.sh"
},
"dependencies": {
"@tauri-apps/api": "^2.12.4",
"@tauri-apps/plugin-clipboard-manager": "^2.5.0",
"@tauri-apps/plugin-dialog": "^2.8.3",
"@tauri-apps/plugin-global-shortcut": "^2.4.1",
"@tauri-apps/plugin-opener": "^2.7.2",
"@tesseract.js-data/chi_sim": "^1.0.0",
"@tesseract.js-data/eng": "^1.0.0",
"lucide-react": "^0.468.0",
"react": "^19.1.0",
"react-dom": "^19.1.0",
"tesseract.js": "^7.0.0"
},
"devDependencies": {
"@tauri-apps/cli": "^2.12.3",
"@types/react": "^19.1.0",
"@types/react-dom": "^19.1.0",
"@vitejs/plugin-react": "^4.4.0",
"typescript": "~5.8.3",
"vite": "^6.3.0"
}
}

1335
pnpm-lock.yaml 100644

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,35 @@
<svg width="512" height="512" viewBox="0 0 512 512" fill="none" xmlns="http://www.w3.org/2000/svg">
<defs>
<linearGradient id="sky" x1="64" y1="32" x2="462" y2="488" gradientUnits="userSpaceOnUse">
<stop stop-color="#FFCF8A"/>
<stop offset="0.52" stop-color="#FF8A4C"/>
<stop offset="1" stop-color="#D56FD7"/>
</linearGradient>
<radialGradient id="fruit" cx="0" cy="0" r="1" gradientUnits="userSpaceOnUse" gradientTransform="translate(194 202) rotate(52) scale(156)">
<stop stop-color="#FFA73D"/>
<stop offset="0.7" stop-color="#FF6B1A"/>
<stop offset="1" stop-color="#C93C0D"/>
</radialGradient>
<filter id="soft" x="-20%" y="-20%" width="140%" height="140%">
<feDropShadow dx="0" dy="18" stdDeviation="18" flood-color="#71250B" flood-opacity="0.24"/>
</filter>
</defs>
<rect width="512" height="512" rx="112" fill="url(#sky)"/>
<path d="M382 56C352 124 338 180 342 246C346 310 376 366 424 414" stroke="#7D4A25" stroke-width="20" stroke-linecap="round"/>
<path d="M376 146C322 118 292 150 280 188" stroke="#7D4A25" stroke-width="13" stroke-linecap="round"/>
<path d="M363 213C312 190 281 217 273 253" stroke="#7D4A25" stroke-width="12" stroke-linecap="round"/>
<path d="M403 280C356 257 326 282 318 318" stroke="#7D4A25" stroke-width="12" stroke-linecap="round"/>
<path d="M358 120C324 84 278 88 255 107C283 122 316 131 358 120Z" fill="#41743B"/>
<path d="M344 176C311 143 273 151 255 172C286 184 311 188 344 176Z" fill="#4E8444"/>
<path d="M384 243C349 214 315 222 299 242C326 252 351 254 384 243Z" fill="#3E7038"/>
<g filter="url(#soft)">
<circle cx="177" cy="190" r="75" fill="url(#fruit)"/>
<circle cx="307" cy="184" r="67" fill="url(#fruit)"/>
<circle cx="235" cy="314" r="78" fill="url(#fruit)"/>
<circle cx="354" cy="310" r="61" fill="url(#fruit)"/>
<circle cx="140" cy="315" r="57" fill="url(#fruit)"/>
</g>
<circle cx="150" cy="163" r="18" fill="#FFD28E" fill-opacity="0.65"/>
<circle cx="284" cy="158" r="15" fill="#FFD28E" fill-opacity="0.6"/>
<circle cx="210" cy="288" r="18" fill="#FFD28E" fill-opacity="0.58"/>
</svg>

After

Width:  |  Height:  |  Size: 2.1 KiB

View File

@ -0,0 +1,20 @@
<!doctype html>
<html lang="zh">
<head>
<meta charset="UTF-8" />
<link rel="stylesheet" href="/src/styles.css" />
<style>
body { background: #f5eee7; }
.wrap { display: flex; justify-content: center; align-items: center; height: 100vh; }
</style>
</head>
<body data-view="main">
<div class="wrap">
<div class="home-primary-actions has-drop-target">
<button class="home-primary is-drop-target">文件转换</button>
<button class="home-secondary">文件工具</button>
<button class="home-secondary">文字识别</button>
</div>
</div>
</body>
</html>

Binary file not shown.

After

Width:  |  Height:  |  Size: 77 KiB

Binary file not shown.

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

Binary file not shown.

File diff suppressed because one or more lines are too long

Binary file not shown.

File diff suppressed because one or more lines are too long

Binary file not shown.

Binary file not shown.

Binary file not shown.

File diff suppressed because one or more lines are too long

3
public/tesseract/worker.min.js vendored 100644

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,80 @@
#!/usr/bin/env bash
set -euo pipefail
root_dir="$(cd "$(dirname "$0")/.." && pwd)"
host_triple="$(rustc -vV | awk '/^host:/ { print $2 }')"
out_dir="$root_dir/src-tauri/binaries"
out_file="$out_dir/drag-bridge-$host_triple"
pdf_out_file="$out_dir/pdf-render-$host_triple"
doc_out_file="$out_dir/doc-render-$host_triple"
tmp_dir="$(mktemp -d)"
trap 'find "$tmp_dir" -type f -delete; rmdir "$tmp_dir"' EXIT
mkdir -p "$out_dir"
for arch in arm64 x86_64; do
swiftc \
-O \
-target "$arch-apple-macosx13.0" \
-framework AppKit \
"$root_dir/native/macos/drag-bridge.swift" \
-o "$tmp_dir/drag-bridge-$arch"
swiftc \
-O \
-target "$arch-apple-macosx13.0" \
-framework AppKit \
-framework PDFKit \
"$root_dir/native/macos/pdf-render.swift" \
-o "$tmp_dir/pdf-render-$arch"
swiftc \
-O \
-target "$arch-apple-macosx13.0" \
-framework AppKit \
"$root_dir/native/macos/doc-render.swift" \
-o "$tmp_dir/doc-render-$arch"
done
lipo -create \
"$tmp_dir/drag-bridge-arm64" \
"$tmp_dir/drag-bridge-x86_64" \
-output "$out_dir/drag-bridge-universal-apple-darwin"
lipo -create \
"$tmp_dir/pdf-render-arm64" \
"$tmp_dir/pdf-render-x86_64" \
-output "$out_dir/pdf-render-universal-apple-darwin"
lipo -create \
"$tmp_dir/doc-render-arm64" \
"$tmp_dir/doc-render-x86_64" \
-output "$out_dir/doc-render-universal-apple-darwin"
cp "$tmp_dir/drag-bridge-arm64" "$out_dir/drag-bridge-aarch64-apple-darwin"
cp "$tmp_dir/pdf-render-arm64" "$out_dir/pdf-render-aarch64-apple-darwin"
cp "$tmp_dir/doc-render-arm64" "$out_dir/doc-render-aarch64-apple-darwin"
cp "$tmp_dir/drag-bridge-x86_64" "$out_dir/drag-bridge-x86_64-apple-darwin"
cp "$tmp_dir/pdf-render-x86_64" "$out_dir/pdf-render-x86_64-apple-darwin"
cp "$tmp_dir/doc-render-x86_64" "$out_dir/doc-render-x86_64-apple-darwin"
if [[ "$host_triple" == "aarch64-apple-darwin" ]]; then
cp "$tmp_dir/drag-bridge-arm64" "$out_file"
cp "$tmp_dir/pdf-render-arm64" "$pdf_out_file"
cp "$tmp_dir/doc-render-arm64" "$doc_out_file"
else
cp "$tmp_dir/drag-bridge-x86_64" "$out_file"
cp "$tmp_dir/pdf-render-x86_64" "$pdf_out_file"
cp "$tmp_dir/doc-render-x86_64" "$doc_out_file"
fi
chmod +x "$out_file" "$pdf_out_file" \
"$doc_out_file" \
"$out_dir/drag-bridge-aarch64-apple-darwin" \
"$out_dir/pdf-render-aarch64-apple-darwin" \
"$out_dir/doc-render-aarch64-apple-darwin" \
"$out_dir/drag-bridge-x86_64-apple-darwin" \
"$out_dir/pdf-render-x86_64-apple-darwin" \
"$out_dir/doc-render-x86_64-apple-darwin" \
"$out_dir/drag-bridge-universal-apple-darwin" \
"$out_dir/pdf-render-universal-apple-darwin" \
"$out_dir/doc-render-universal-apple-darwin"
echo "Built $out_file"
echo "Built $pdf_out_file"
echo "Built $doc_out_file"
echo "Built universal macOS sidecars"

View File

@ -0,0 +1,13 @@
#!/usr/bin/env bash
set -euo pipefail
root_dir="$(cd "$(dirname "$0")/.." && pwd)"
target="$root_dir/public/tesseract"
core_source="$root_dir/node_modules/.pnpm/tesseract.js-core@7.0.0/node_modules/tesseract.js-core"
mkdir -p "$target/lang" "$target/core"
cp "$root_dir/node_modules/tesseract.js/dist/worker.min.js" "$target/worker.min.js"
cp "$core_source"/tesseract-core*.wasm.js "$target/core/"
cp "$core_source"/tesseract-core*.wasm "$target/core/"
cp -L "$root_dir/node_modules/@tesseract.js-data/eng/4.0.0_best_int/eng.traineddata.gz" "$target/lang/"
cp -L "$root_dir/node_modules/@tesseract.js-data/chi_sim/4.0.0_best_int/chi_sim.traineddata.gz" "$target/lang/"

6101
src-tauri/Cargo.lock generated 100644

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,50 @@
[package]
name = "shift"
version = "0.1.0"
description = "A radial file utility with screenshot, recording and OCR."
authors = ["Shift Contributors"]
edition = "2021"
[lib]
name = "shift_lib"
crate-type = ["staticlib", "cdylib", "rlib"]
[build-dependencies]
tauri-build = { version = "2", features = [] }
[dependencies]
tauri = { version = "2.11", features = ["tray-icon", "image-png", "macos-private-api", "protocol-asset", "unstable"] }
tauri-plugin-clipboard-manager = "2"
tauri-plugin-dialog = "2"
tauri-plugin-global-shortcut = "2"
tauri-plugin-opener = "2"
serde = { version = "1", features = ["derive"] }
serde_json = "1"
image = { version = "0.25.8", default-features = false, features = ["png", "jpeg", "webp", "tiff", "bmp", "gif"] }
lopdf = { version = "0.45", default-features = false }
printpdf = { version = "0.12.8", default-features = false, features = ["images", "png", "jpeg", "webp", "tiff", "bmp", "gif"] }
calamine = "0.36.1"
quick-xml = "0.42"
zip = { version = "8.6", default-features = false, features = ["deflate"] }
base64 = "0.22"
chrono = { version = "0.4", features = ["clock"] }
uuid = { version = "1", features = ["v4"] }
which = "7"
[target.'cfg(windows)'.dependencies]
windows-sys = { version = "0.59", features = [
"Win32_Foundation",
"Win32_System_Console",
"Win32_System_Threading",
"Win32_UI_Input_KeyboardAndMouse",
"Win32_UI_WindowsAndMessaging",
] }
[target.'cfg(unix)'.dependencies]
libc = "0.2"
[profile.dev]
debug = 1
[profile.dev.package."*"]
debug = false

View File

@ -0,0 +1,20 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>NSScreenCaptureUsageDescription</key>
<string>Shift captures the area you select for screenshots and screen recordings.</string>
<key>NSMicrophoneUsageDescription</key>
<string>Shift can include microphone audio in screen recordings when you enable it.</string>
<key>NSDesktopFolderUsageDescription</key>
<string>Shift saves processed files to the folder you choose, including folders on your Desktop.</string>
<key>NSDocumentsFolderUsageDescription</key>
<string>Shift saves processed files to the folder you choose, including folders in Documents.</string>
<key>NSDownloadsFolderUsageDescription</key>
<string>Shift saves processed files to the folder you choose, including Downloads.</string>
<key>NSRemovableVolumesUsageDescription</key>
<string>Shift can process and save files on removable volumes you select.</string>
<key>NSNetworkVolumesUsageDescription</key>
<string>Shift can process and save files on network volumes you select.</string>
</dict>
</plist>

View File

@ -0,0 +1 @@

View File

@ -0,0 +1,3 @@
fn main() {
tauri_build::build()
}

View File

@ -0,0 +1,24 @@
{
"$schema": "../gen/schemas/desktop-schema.json",
"identifier": "default",
"description": "Default permissions for Shift windows.",
"windows": ["main", "radial", "capture", "recorder", "editor", "pin-*"],
"permissions": [
"core:default",
"core:window:allow-show",
"core:window:allow-hide",
"core:window:allow-close",
"core:window:allow-set-position",
"core:window:allow-set-size",
"core:window:allow-set-focus",
"core:window:allow-start-dragging",
"core:window:allow-current-monitor",
"core:window:allow-outer-position",
"core:window:allow-scale-factor",
"global-shortcut:default",
"dialog:default",
"opener:default",
"clipboard-manager:allow-write-text",
"clipboard-manager:allow-write-image"
]
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 28 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 32 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 37 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.2 KiB

View File

@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
<foreground android:drawable="@mipmap/ic_launcher_foreground"/>
<background android:drawable="@color/ic_launcher_background"/>
</adaptive-icon>

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 23 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 39 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 17 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 59 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 19 KiB

View File

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="ic_launcher_background">#FFFFFF</color>
</resources>

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 41 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 77 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 941 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 199 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.5 KiB

Some files were not shown because too many files have changed in this diff Show More