feat(ui): drop onto a button, and read the panels again

Three changes to the main window, requested together.

A file drop is now aimed. The three buttons are the only drop targets and the
button you release on is the action it runs; a release anywhere else on the
panel runs nothing and says so, instead of opening an action ring nobody asked
for. This replaces the old fallback in both delivery paths - the DOM handler and
the native webview drop - because two routes to the same gesture must not have
two different rules. dropFiles therefore takes a required action rather than an
optional one, and the actions ring is still reachable from the Shift-drag
gesture and from a file type with no convertible formats.

Recent rows can be dragged back onto those buttons. A row leaves Shift as a real
file drag, so one gesture can be reported twice, once by the DOM and once by the
native events, and which arrives first depends on the engine; recentDrag.landed
lets only the first through. The hint under the buttons names the affordance,
which is otherwise invisible, and all three buttons light up as candidates for as
long as any drag is in flight - a native one via dragging, an internal one via
rowDragging, since a row drag inside the webview does not raise native events.

Type sizes are on one ladder now (--text-3xs to --text-hero) instead of being
invented per rule, which is how the settings drawer drifted down to 7-8px. 92
declarations under 12px became one. The drawer is wider, its tabs are pills, and
the runtime, share, setup and radial surfaces moved onto the same scale.

The capture-behaviour setting is removed: the CaptureAfter enum, its field, its
command and its UI. A finished capture always shows the result card, falling back
to the editor when a card window cannot be created. Stored settings that still
carry captureAfter load unchanged, because the struct does not deny unknown
fields.

Also dropped 23 i18n keys no surface used, one dead re-export in history.ts, and
a stale .home-drop p rule that was outranking the new hint and sizing it as body
copy. tsconfig now turns on noUnusedLocals, noUnusedParameters and
noFallthroughCasesInSwitch, which is what keeps the dead imports from coming
back; the tree already passes all three.
main
mula.liu 2026-11-01 12:02:24 +08:00
parent 23973cee8f
commit e6818e029e
13 changed files with 739 additions and 602 deletions

View File

@ -529,19 +529,13 @@ fn finish_capture(
Ok(output.to_string_lossy().to_string())
}
/// Route a finished capture per the Capture-after setting. The card is allowed to
/// fail silently: a screenshot that saved is more important than an overlay that
/// could not be built, and the file is already on disk and copied by then.
/// Show the result card for a finished capture. The card is allowed to fail
/// silently: a screenshot that saved is more important than an overlay that could
/// not be built, and the file is already on disk and copied by then. The editor is
/// the fallback so a capture is never left with no way to act on it.
fn hand_off(app: &AppHandle, output: &Path) {
match settings::load(app).capture_after {
settings::CaptureAfter::Editor => {
let _ = editor::show_editor(app, output);
}
settings::CaptureAfter::Card => {
if result_card::show(app, output).is_err() {
let _ = editor::show_editor(app, output);
}
}
if result_card::show(app, output).is_err() {
let _ = editor::show_editor(app, output);
}
}

View File

@ -422,7 +422,6 @@ pub fn run() {
settings::set_autostart,
settings::check_output_access,
settings::set_language,
settings::set_capture_after,
settings::set_update_check_enabled,
settings::set_setup_reviewed,
settings::get_wedge_orders,

View File

@ -402,15 +402,11 @@ pub fn stop(app: &AppHandle, state: &AppState) -> Result<Option<RecordingInfo>,
output: session.output.to_string_lossy().to_string(),
started_at: session.started_at,
};
match crate::settings::load(app).capture_after {
crate::settings::CaptureAfter::Editor => {
editor::show_recording_editor(app, &info)?;
}
crate::settings::CaptureAfter::Card => {
if crate::result_card::show(app, Path::new(&info.output)).is_err() {
editor::show_recording_editor(app, &info)?;
}
}
// The card carries the recording's own Copy / Pin / Edit / Send buttons; the
// editor is the fallback so a finished recording is never left with no way to
// act on it.
if crate::result_card::show(app, Path::new(&info.output)).is_err() {
editor::show_recording_editor(app, &info)?;
}
crate::history::publish_result(
app,

View File

@ -25,16 +25,6 @@ pub struct SwitchUpdate {
pub autostart: Option<bool>,
}
/// What happens the instant a capture is saved. The card keeps the shot out of the
/// way but one click from Copy / Pin / Edit / Send; the editor opens it directly.
#[derive(Debug, Clone, Copy, Default, Deserialize, PartialEq, Eq, Serialize)]
#[serde(rename_all = "lowercase")]
pub enum CaptureAfter {
#[default]
Card,
Editor,
}
#[derive(Debug, Clone, Copy, Default, Deserialize, PartialEq, Eq, Serialize)]
#[serde(rename_all = "lowercase")]
pub enum FileOutputMode {
@ -59,8 +49,6 @@ pub struct AppSettings {
pub autostart: bool,
/// UI language, "" until the user picks one. Unset follows the system.
pub language: String,
/// Card or editor, chosen right after a screenshot or recording is written.
pub capture_after: CaptureAfter,
/// Ask the git release branch for a newer build once a day.
pub update_check_enabled: bool,
/// Last startup probe as a unix day, so the daily check survives restarts.
@ -86,7 +74,6 @@ impl Default for AppSettings {
share_enabled: true,
autostart: false,
language: String::new(),
capture_after: CaptureAfter::default(),
update_check_enabled: true,
last_update_check_day: 0,
wedge_orders: HashMap::new(),
@ -107,7 +94,6 @@ pub struct SettingsSnapshot {
pub share_enabled: bool,
pub autostart: bool,
pub language: String,
pub capture_after: CaptureAfter,
pub update_check_enabled: bool,
pub update_feed_url: String,
pub wedge_orders: HashMap<String, Vec<String>>,
@ -299,7 +285,6 @@ pub fn snapshot(app: &AppHandle) -> Result<SettingsSnapshot, String> {
// Report what the OS actually has registered, not what we last wrote.
autostart: crate::autostart::is_enabled(),
language: settings.language.clone(),
capture_after: settings.capture_after,
update_check_enabled: settings.update_check_enabled,
update_feed_url: crate::update::manifest_url(),
wedge_orders: settings.wedge_orders.clone(),
@ -380,22 +365,6 @@ pub fn update_check_due(app: &AppHandle, interval: std::time::Duration) -> bool
elapsed_days >= (interval.as_secs() / 86_400).max(1) as i64
}
#[tauri::command]
pub async fn set_capture_after(
app: AppHandle,
after: CaptureAfter,
) -> Result<SettingsSnapshot, String> {
tauri::async_runtime::spawn_blocking(move || {
update_settings(&app, |settings| {
settings.capture_after = after;
Ok(())
})?;
snapshot(&app)
})
.await
.map_err(|error| error.to_string())?
}
/// Close the guided first-run flow. The checks themselves are re-runnable from
/// Settings, so dismissing the flow loses nothing.
#[tauri::command]

View File

@ -22,6 +22,7 @@ import {
FileOutput,
LoaderCircle,
Maximize,
MoveRight,
Pin,
Presentation,
RefreshCw,
@ -37,7 +38,14 @@ import {
Wrench,
X,
} from "lucide-react";
import { useEffect, useMemo, useRef, useState, type CSSProperties } from "react";
import {
useEffect,
useMemo,
useRef,
useState,
type CSSProperties,
type DragEvent,
} from "react";
import { getInitialLang, publishLang, useI18n } from "../i18n";
import { api } from "../lib/api";
import { hitTestDropTarget, toWindowPoint } from "../lib/dropTargets";
@ -75,7 +83,6 @@ const FALLBACK_SETTINGS: AppSettings = {
dragEnabled: true,
shareEnabled: true,
autostart: false,
captureAfter: "card",
defaultFileOutputDir: "~/Downloads/Shift",
defaultScreenshotDir: "~/Pictures/Shift",
defaultRecordingDir: "~/Movies/Shift",
@ -154,13 +161,13 @@ function RecentThumb({ item }: { item: RecentItem }) {
return (
<span className={`home-recent-icon ${item.kind}`}>
{item.kind === "image" ? (
<FileImage size={15} />
<FileImage size={17} />
) : item.kind === "video" ? (
<FileVideo size={15} />
<FileVideo size={17} />
) : item.kind === "text" ? (
<FileText size={15} />
<FileText size={17} />
) : (
<FileGeneric size={15} />
<FileGeneric size={17} />
)}
</span>
);
@ -198,12 +205,12 @@ function OutputLocation({
) : null}
</div>
<div className="settings-path" title={path}>
<FolderOpen size={14} />
<FolderOpen size={16} />
<span>{path}</span>
</div>
<div className="settings-output-actions">
<button className="settings-small-button" onClick={onChoose}>
<FolderSearch size={14} />
<FolderSearch size={16} />
{chooseLabel}
</button>
<button className="settings-small-button" onClick={onReveal}>
@ -243,11 +250,16 @@ export function MainWindow() {
const toastTimer = useRef<number | null>(null);
const [, setNowTick] = useState(0);
const [dropAction, setDropAction] = useState<DropAction | null>(null);
/** True while a Recent row is being dragged, which the native `dragging` never covers. */
const [rowDragging, setRowDragging] = useState(false);
const [hotkeys, setHotkeys] = useState<HotkeyStatus | null>(null);
const dropTargets = useRef<Partial<Record<DropAction, HTMLElement | null>>>({});
// Recent rows can still be handed to other apps, but dropping one back onto
// Shift's own action buttons is intentionally unsupported.
const recentDragActive = useRef(false);
/**
* The Recent row that is in flight, and whether it has already landed. A row leaves
* Shift as a real file drag, so one gesture can be reported twice: once by the DOM,
* once by the native drop events. Only the first of the two may run an action.
*/
const recentDrag = useRef<{ path: string; landed: boolean } | null>(null);
const runtimeCheckStarted = useRef(false);
async function finishSetup() {
@ -320,9 +332,8 @@ export function MainWindow() {
return toWindowPoint(position, IS_MAC ? "mac" : "other", window.devicePixelRatio || 1);
}
function actionAt(position: { x: number; y: number }): DropAction | null {
const point = localPoint(position);
if (!point) return null;
/** Hit-test a point that is already in CSS pixels inside this window. */
function actionAtPoint(point: { x: number; y: number }): DropAction | null {
const boxes: Array<[DropAction, DOMRect | null | undefined]> = [
["formats", dropTargets.current.formats?.getBoundingClientRect()],
["tools", dropTargets.current.tools?.getBoundingClientRect()],
@ -331,11 +342,57 @@ export function MainWindow() {
return hitTestDropTarget(boxes, point);
}
function dropFiles(paths: string[], action: DropAction | null) {
function actionAt(position: { x: number; y: number }): DropAction | null {
const point = localPoint(position);
return point ? actionAtPoint(point) : null;
}
/**
* Run the one action a drop was aimed at.
*
* The button *is* the choice: a drop that lands on the panel rather than on one of
* the three buttons runs nothing, so the gesture can never open a ring the user did
* not ask for. `dropOnButton` says why instead of leaving the drop silent.
*/
function dropFiles(paths: string[], action: DropAction) {
if (paths.length === 0) return Promise.resolve();
if (action === "ocr") return runOcrOn(paths);
// Outside a button the ring keeps asking which action to run.
return api.showFilesInRadial(paths, action ?? "actions").then(() => undefined);
return api.showFilesInRadial(paths, action).then(() => undefined);
}
/**
* Land a dragged Recent row, at most once per gesture. Off a button it runs nothing,
* the same rule a file from Finder follows, and says so rather than going silent.
*/
function landRecentRow(action: DropAction | null) {
const drag = recentDrag.current;
if (!drag || drag.landed) return;
drag.landed = true;
setDropAction(null);
if (!action) {
flash(t("dropOnButton"), 2600);
return;
}
void dropFiles([drag.path], action).catch((error) => flash(String(error), 3200));
}
/**
* DOM half of the same gesture, armed on the window root. Whether a file drag that
* started inside the webview is reported here, to the native handler, or to both
* differs by engine, so both are listening and `landRecentRow` decides who was first.
*/
function rowDragOver(event: DragEvent) {
if (!recentDrag.current) return;
event.preventDefault();
event.dataTransfer.dropEffect = "copy";
const next = actionAtPoint({ x: event.clientX, y: event.clientY });
if (dropAction !== next) setDropAction(next);
}
function rowDropped(event: DragEvent) {
if (!recentDrag.current) return;
event.preventDefault();
landRecentRow(actionAtPoint({ x: event.clientX, y: event.clientY }));
}
async function chooseFiles(mode: "formats" | "tools") {
@ -593,23 +650,39 @@ export function MainWindow() {
if (isTauri()) {
void getCurrentWebview()
.onDragDropEvent((event) => {
if (recentDragActive.current) return;
const drag = recentDrag.current;
if (event.payload.type === "enter") {
setDragging(true);
setDropAction(actionAt(event.payload.position));
return;
}
if (event.payload.type === "over") {
setDropAction(actionAt(event.payload.position));
return;
}
if (event.payload.type === "leave") {
setDragging(false);
setDropAction(null);
return;
}
if (event.payload.type === "drop") {
const action = actionAt(event.payload.position);
setDragging(false);
setDropAction(null);
// A Recent row is a real file drag, so it can reach here as well as the
// panel's own DOM handler; nothing else can be in flight at the same time.
if (drag) {
landRecentRow(action);
return;
}
// Off a button there is no action to run, so the drop says what it expects
// instead of opening a ring the user never aimed at.
if (!action) {
flash(t("dropOnButton"), 2600);
return;
}
void dropFiles(event.payload.paths, action).catch((error) => flash(String(error), 3200));
return;
}
})
.then((unlisten) => unlisteners.push(unlisten));
@ -680,7 +753,11 @@ export function MainWindow() {
: [];
return (
<div className={`home ${IS_MAC ? "is-mac" : ""}`}>
<div
className={`home ${IS_MAC ? "is-mac" : ""}`}
onDragOver={rowDragOver}
onDrop={rowDropped}
>
<header className="home-bar" data-tauri-drag-region>
<div className="home-brand" data-tauri-drag-region>
<img className="home-mark" src="/shift-icon.png" alt="" aria-hidden="true" />
@ -694,9 +771,9 @@ export function MainWindow() {
onClick={() => void spring("fullscreen", () => api.captureFullscreen().then(() => undefined))}
>
{busy === "fullscreen" ? (
<LoaderCircle size={15} className="spin" />
<LoaderCircle size={17} className="spin" />
) : (
<Maximize size={15} />
<Maximize size={17} />
)}
{t("fullScreen")}
<kbd>{IS_MAC ? "⌥⇧4" : "Alt+Shift+4"}</kbd>
@ -707,7 +784,7 @@ export function MainWindow() {
void spring("capture", () => api.startCapture("screenshot").then(() => undefined))
}
>
{busy === "capture" ? <LoaderCircle size={15} className="spin" /> : <ScanLine size={15} />}
{busy === "capture" ? <LoaderCircle size={17} className="spin" /> : <ScanLine size={17} />}
{t("capture")}
<kbd>{IS_MAC ? "⌥⇧2" : "Alt+Shift+2"}</kbd>
</button>
@ -717,7 +794,7 @@ export function MainWindow() {
void spring("record", () => api.startCapture("recording").then(() => undefined))
}
>
{busy === "record" ? <LoaderCircle size={15} className="spin" /> : <Circle size={14} />}
{busy === "record" ? <LoaderCircle size={17} className="spin" /> : <Circle size={16} />}
{t("record")}
<kbd>{IS_MAC ? "⌥⇧3" : "Alt+Shift+3"}</kbd>
</button>
@ -726,7 +803,7 @@ export function MainWindow() {
title={t("settings")}
onClick={() => setSettingsOpen((value) => !value)}
>
<Settings2 size={17} />
<Settings2 size={19} />
</button>
</div>
</header>
@ -779,7 +856,13 @@ export function MainWindow() {
})}
</div>
<h1>{dragging ? t("homeDropRelease") : t("homeDropTitle")}</h1>
<div className={`home-primary-actions ${dropAction ? "has-drop-target" : ""}`}>
{/* While any drag is in flight all three buttons show as candidates, so the
aim is visible before the pointer reaches one. */}
<div
className={`home-primary-actions ${
dragging || rowDragging || dropAction ? "has-drop-target" : ""
}`}
>
<button
className={`home-primary ${dropAction === "formats" ? "is-drop-target" : ""}`}
ref={(node) => {
@ -790,9 +873,9 @@ export function MainWindow() {
}
>
{busy === "convert" ? (
<LoaderCircle size={16} className="spin" />
<LoaderCircle size={18} className="spin" />
) : (
<FileOutput size={16} />
<FileOutput size={18} />
)}
{t("convertFiles")}
</button>
@ -804,9 +887,9 @@ export function MainWindow() {
onClick={() => void spring("tools", () => chooseFiles("tools"))}
>
{busy === "tools" ? (
<LoaderCircle size={16} className="spin" />
<LoaderCircle size={18} className="spin" />
) : (
<Wrench size={15} />
<Wrench size={18} />
)}
{t("fileTools")}
</button>
@ -817,16 +900,20 @@ export function MainWindow() {
}}
onClick={() => void spring("ocr", chooseOcr)}
>
{busy === "ocr" ? <LoaderCircle size={16} className="spin" /> : <ScanText size={16} />}
{busy === "ocr" ? <LoaderCircle size={18} className="spin" /> : <ScanText size={18} />}
{t("ocr")}
</button>
</div>
<p className="home-drop-hint">
<MoveRight size={14} />
{t("homeDropHint")}
</p>
</section>
<aside className="home-side">
<section className="home-card home-card-recent">
<header className="home-card-head">
<Clock3 size={16} />
<Clock3 size={18} />
<h1>{t("recent")}</h1>
<span className="home-card-count">
{recent.length > 0
@ -846,7 +933,7 @@ export function MainWindow() {
</header>
{recent.length > 3 ? (
<label className="home-recent-search">
<Search size={13} />
<Search size={15} />
<input
value={historyQuery}
placeholder={t("searchHistory")}
@ -858,7 +945,7 @@ export function MainWindow() {
title={t("clearHistory")}
aria-label={t("clearHistory")}
>
<X size={12} />
<X size={13} />
</button>
) : null}
</label>
@ -866,7 +953,7 @@ export function MainWindow() {
{recent.length === 0 ? (
<div className="home-empty">
<span className="home-empty-glyph" aria-hidden="true">
<ScanLine size={17} />
<ScanLine size={19} />
</span>
<p>{t("recentEmpty")}</p>
</div>
@ -885,15 +972,26 @@ export function MainWindow() {
onDragStart={(event) => {
// A row leaves Shift as the file itself: WebKit turns the file URL
// in text/uri-list into a real file drop for Finder and friends,
// while the plain path remains readable for editors.
// while the plain path remains readable for editors. The same path
// is what tells our own drop zones the row has come back.
event.dataTransfer.effectAllowed = "copy";
recentDragActive.current = true;
recentDrag.current = { path: item.path, landed: false };
setRowDragging(true);
for (const [type, value] of Object.entries(dragOutPayload(item.path))) {
event.dataTransfer.setData(type, value);
}
}}
onDragEnd={() => {
recentDragActive.current = false;
setDropAction(null);
setDragging(false);
setRowDragging(false);
// Some engines report the native drop only after the button is
// already up, so the gesture stays recognised for a moment.
const drag = recentDrag.current;
if (!drag) return;
window.setTimeout(() => {
if (recentDrag.current === drag) recentDrag.current = null;
}, 500);
}}
>
<button
@ -917,24 +1015,24 @@ export function MainWindow() {
void history.setPinned(item.path, !item.pinned).catch(() => undefined)
}
>
<Star size={13} fill={item.pinned ? "currentColor" : "none"} />
<Star size={15} fill={item.pinned ? "currentColor" : "none"} />
</button>
<button title={t("sendTo")} onClick={() => setSharePaths([item.path])}>
<Send size={13} />
<Send size={15} />
</button>
<button title={t("revealFile")} onClick={() => void api.revealFile(item.path)}>
<FolderSearch size={13} />
<FolderSearch size={15} />
</button>
{item.kind === "image" ? (
<button title={t("pin")} onClick={() => void api.pinImage(item.path)}>
<Pin size={13} />
<Pin size={15} />
</button>
) : null}
<button
title={t("forget")}
onClick={() => void history.remove(item.path).catch(() => undefined)}
>
<X size={13} />
<X size={15} />
</button>
</span>
</li>
@ -958,7 +1056,7 @@ export function MainWindow() {
aria-label={t("close")}
title={t("close")}
>
<X size={17} />
<X size={19} />
</button>
<div className="home-settings-heading">
<h2>
@ -980,7 +1078,7 @@ export function MainWindow() {
aria-controls="settings-panel-system"
onClick={() => setSettingsTab("system")}
>
<Settings2 size={14} />
<Settings2 size={16} />
{t("systemSettings")}
</button>
<button
@ -991,7 +1089,7 @@ export function MainWindow() {
aria-controls="settings-panel-runtime"
onClick={() => setSettingsTab("runtime")}
>
<Cpu size={14} />
<Cpu size={16} />
{t("runtimeComponents")}
</button>
<button
@ -1002,7 +1100,7 @@ export function MainWindow() {
aria-controls="settings-panel-updates"
onClick={() => setSettingsTab("updates")}
>
<Sparkle size={14} />
<Sparkle size={16} />
{t("updates")}
</button>
</div>
@ -1044,7 +1142,7 @@ export function MainWindow() {
>
<section className="home-settings-section">
<div className="home-section-title">
<FolderCog size={15} />
<FolderCog size={17} />
{t("fileResults")}
</div>
<div className="home-segment">
@ -1077,7 +1175,7 @@ export function MainWindow() {
<section className="home-settings-section">
<div className="home-section-title">
<ScanLine size={15} />
<ScanLine size={17} />
{t("screenshots")}
</div>
<OutputLocation
@ -1090,26 +1188,11 @@ export function MainWindow() {
onReveal={() => void api.revealOutputDirectory("screenshot")}
onReset={() => void resetFolder("screenshot")}
/>
<div className="home-segment home-segment-after">
<button
className={(settings?.captureAfter ?? "card") !== "editor" ? "is-active" : ""}
onClick={() => void applySettings(() => api.setCaptureAfter("card"))}
>
{t("captureAfterCard")}
</button>
<button
className={settings?.captureAfter === "editor" ? "is-active" : ""}
onClick={() => void applySettings(() => api.setCaptureAfter("editor"))}
>
{t("captureAfterEditor")}
</button>
</div>
<p className="runtime-summary">{t("captureAfterBody")}</p>
</section>
<section className="home-settings-section">
<div className="home-section-title">
<Circle size={14} />
<Circle size={16} />
{t("recordings")}
</div>
<OutputLocation
@ -1192,14 +1275,14 @@ export function MainWindow() {
<section className="home-settings-section">
<div className="home-section-title">
<ShieldCheck size={15} />
<ShieldCheck size={17} />
{t("accessCheck")}
</div>
<button className="settings-wide-button" onClick={() => void runAccessCheck()}>
{checking ? (
<LoaderCircle size={14} className="spin" />
<LoaderCircle size={16} className="spin" />
) : (
<RefreshCw size={14} />
<RefreshCw size={16} />
)}
{checking ? t("checking") : t("checkAccess")}
</button>
@ -1210,7 +1293,7 @@ export function MainWindow() {
key={check.kind}
className={`home-check ${check.ok ? "is-ok" : "is-bad"}`}
>
{check.ok ? <Check size={14} /> : <X size={14} />}
{check.ok ? <Check size={15} /> : <X size={15} />}
<span>
<strong>{outputLabel(check.kind)}</strong>
<small>{check.ok ? t("accessOk") : check.message}</small>
@ -1226,11 +1309,11 @@ export function MainWindow() {
<div className="home-section-title">{t("permissions")}</div>
<div className="home-permission-row">
<button onClick={() => void api.openScreenRecordingSettings()}>
<ScanLine size={14} />
<ScanLine size={16} />
{t("screenPermission")}
</button>
<button onClick={() => void api.openFilesPermissionSettings()}>
<FolderOpen size={14} />
<FolderOpen size={16} />
{t("filesPermission")}
</button>
</div>
@ -1270,7 +1353,7 @@ export function MainWindow() {
<section className="home-settings-section">
<div className="runtime-section-head">
<div className="home-section-title">
<Cpu size={15} />
<Cpu size={17} />
{t("runtimeComponents")}
</div>
<button
@ -1278,7 +1361,7 @@ export function MainWindow() {
onClick={() => void refreshRuntime()}
disabled={runtimeLoading || runtimeInstalling !== null}
>
<RefreshCw size={12} className={runtimeLoading ? "spin" : ""} />
<RefreshCw size={13} className={runtimeLoading ? "spin" : ""} />
{runtimeLoading ? t("runtimeChecking") : t("runtimeRefresh")}
</button>
</div>
@ -1308,7 +1391,7 @@ export function MainWindow() {
) : null}
{runtimeLoading && !runtimeInfo ? (
<div className="runtime-loading">
<LoaderCircle size={14} className="spin" />
<LoaderCircle size={16} className="spin" />
{t("runtimeChecking")}
</div>
) : null}
@ -1328,7 +1411,7 @@ export function MainWindow() {
</div>
<div className="runtime-component-meta">
<span className="runtime-status">
{component.available ? <Check size={11} /> : <X size={11} />}
{component.available ? <Check size={13} /> : <X size={13} />}
{component.available ? t("runtimeAvailable") : t("runtimeMissing")}
</span>
{component.version ? (
@ -1351,9 +1434,9 @@ export function MainWindow() {
disabled={runtimeInstalling !== null || runtimeLoading}
>
{runtimeInstalling === component.id ? (
<LoaderCircle size={12} className="spin" />
<LoaderCircle size={14} className="spin" />
) : (
<Download size={12} />
<Download size={14} />
)}
{runtimeInstalling === component.id
? t("runtimeInstalling")

View File

@ -170,7 +170,7 @@ export function SetupPanel({
return (
<li key={row.id} className={`setup-row is-${row.state}`}>
<span className="setup-row-icon">
<Icon size={15} />
<Icon size={17} />
</span>
<span className="setup-row-body">
<strong>{t(`setupRow_${row.id}`)}</strong>
@ -191,9 +191,9 @@ export function SetupPanel({
</span>
<span className={`setup-state is-${row.state}`}>
{row.state === "ok" ? (
<Check size={14} />
<Check size={16} />
) : row.state === "problem" ? (
<X size={14} />
<X size={16} />
) : null}
{t(
row.state === "ok"

View File

@ -79,7 +79,7 @@ export function UpdatePanel({ feedUrl, autoCheck, onAutoCheckChange, system }: P
says what was upgraded and from where. */}
<div className="update-meta">
<div className="update-meta-line">
<Monitor size={13} />
<Monitor size={15} />
<span className="update-meta-label">{t("updateSystem")}</span>
{system ? (
<span className="update-system-host">
@ -92,13 +92,13 @@ export function UpdatePanel({ feedUrl, autoCheck, onAutoCheckChange, system }: P
)}
</div>
<div className="update-meta-line">
<Rss size={13} />
<Rss size={15} />
<span className="update-meta-label">{t("updateFeed")}</span>
{/* Only a status backed by a manifest may claim anything about trust: an
errored check has no manifest to have verified. */}
{status && status.state !== "error" ? (
<span className={`update-trust is-${status.signed ? "signed" : "unsigned"}`}>
<ShieldCheck size={11} />
<ShieldCheck size={13} />
{t(status.signed ? "updateSigned" : "updateUnsigned")}
</span>
) : null}
@ -108,7 +108,7 @@ export function UpdatePanel({ feedUrl, autoCheck, onAutoCheckChange, system }: P
<div className="runtime-section-head">
<div className="home-section-title">
<Sparkle size={15} />
<Sparkle size={17} />
{t("updates")}
</div>
<button
@ -116,7 +116,7 @@ export function UpdatePanel({ feedUrl, autoCheck, onAutoCheckChange, system }: P
onClick={() => void check()}
disabled={checking || downloading}
>
<RefreshCw size={12} className={checking ? "spin" : ""} />
<RefreshCw size={13} className={checking ? "spin" : ""} />
{checking ? t("updateChecking") : t("updateCheckNow")}
</button>
</div>
@ -138,7 +138,7 @@ export function UpdatePanel({ feedUrl, autoCheck, onAutoCheckChange, system }: P
{available && status ? (
<span className="update-arrow">
<span className="update-new">
<Sparkle size={11} />
<Sparkle size={13} />
{status.availableVersion}
</span>
<small>{status.date}</small>
@ -150,7 +150,7 @@ export function UpdatePanel({ feedUrl, autoCheck, onAutoCheckChange, system }: P
{status?.fileName ? (
<div className="update-artifact">
<PackageOpen size={13} />
<PackageOpen size={15} />
<span className="update-artifact-name" title={status.fileName}>
{status.fileName}
</span>
@ -169,7 +169,7 @@ export function UpdatePanel({ feedUrl, autoCheck, onAutoCheckChange, system }: P
{status?.sha256 ? (
<code className="update-hash" title={status.sha256}>
<ShieldCheck size={11} />
<ShieldCheck size={13} />
SHA256 {verified ? status.sha256 : `${status.sha256.slice(0, 16)}…`}
</code>
) : null}
@ -195,7 +195,7 @@ export function UpdatePanel({ feedUrl, autoCheck, onAutoCheckChange, system }: P
onClick={() => void download()}
disabled={downloading}
>
{downloading ? <LoaderCircle size={13} className="spin" /> : <Download size={13} />}
{downloading ? <LoaderCircle size={15} className="spin" /> : <Download size={15} />}
{downloading ? t("updateDownloading") : t("updateDownload")}
</button>
) : null}
@ -205,7 +205,7 @@ export function UpdatePanel({ feedUrl, autoCheck, onAutoCheckChange, system }: P
onClick={() => void install()}
disabled={installing}
>
{installing ? <LoaderCircle size={13} className="spin" /> : <Check size={13} />}
{installing ? <LoaderCircle size={15} className="spin" /> : <Check size={15} />}
{installing ? t("updateInstalling") : t("updateInstall")}
</button>
) : null}
@ -213,7 +213,7 @@ export function UpdatePanel({ feedUrl, autoCheck, onAutoCheckChange, system }: P
choice that only resets what is already decided. */}
{verified && !installing ? (
<button className="update-action" onClick={() => void clear()}>
<X size={13} />
<X size={15} />
{t("updateDiscard")}
</button>
) : null}

View File

@ -6,25 +6,14 @@ export type Lang = "en" | "zh";
const messages: Record<Lang, Record<string, string>> = {
en: {
appName: "Shift",
tagline: "Everything you need, one gesture away.",
heroTitle: "Move at the speed of thought",
heroBody:
"A radial file workspace inspired by Tangerine, with CleanShot-style capture, recording and local OCR.",
capture: "Capture area",
captureFullscreen: "Full screen capture",
fullScreen: "Full screen",
record: "Record area",
ocr: "OCR",
dropTitle: "Drop files to begin",
dropBody: "Drop images, PDFs, documents or video here. Every action stays on this device.",
recent: "Recent",
noRecent: "Your captures and recordings will appear here.",
settings: "Settings",
language: "Language",
english: "English",
chinese: "简体中文",
privacy: "Local by design",
chooseAction: "Choose an action",
chooseFormat: "Release over a format",
releaseCancel: "Move back to the center to cancel",
@ -52,7 +41,6 @@ const messages: Record<Lang, Record<string, string>> = {
cutout: "Cutout",
crop: "Crop",
reveal: "Reveal",
resize: "Resize",
rotate: "Rotate",
flip: "Flip",
blackWhite: "B&W",
@ -63,7 +51,6 @@ const messages: Record<Lang, Record<string, string>> = {
frame: "Frame",
mono: "Mono",
plain: "Plain",
more: "More",
merge: "Merge",
split: "Split",
files: "files",
@ -75,7 +62,6 @@ const messages: Record<Lang, Record<string, string>> = {
saved: "Saved",
copy: "Copy",
pin: "Pin",
pinUnavailable: "The pinned image is unavailable.",
pinLoadFailed: "The pinned image could not be displayed.",
copyText: "Copy text",
saveAs: "Save As…",
@ -88,29 +74,22 @@ const messages: Record<Lang, Record<string, string>> = {
audio: "Audio",
frameRate: "Frame rate",
dragSelect: "Drag to select an area",
recordingSaved: "Recording saved",
ocrTitle: "Extract text",
ocrRunning: "Reading text…",
ocrEmpty: "No readable text found.",
extractText: "Extract text",
revealFile: "Show in folder",
captureFailed: "Capture failed",
recordingFailed: "Recording failed",
actionFailed: "That action could not be completed",
comingSoon: "Coming soon.",
windowTitle: "Shift",
allSet: "All set",
openScreenSettings: "Open screen recording settings",
source: "Source",
quickActions: "Quick actions",
tools: "Tools",
fileCount: "Selected",
unsupported: "No formats for this file type",
homeDropTitle: "Drop files to get started",
homeDropRelease: "Release to choose an action",
homeDropRelease: "Release over one of the buttons",
homeDropHint: "Drop a file on a button to run that action.",
dropOnButton: "Drop the file on one of the three buttons.",
convertFiles: "Convert files",
fileTools: "File tools",
items: "items",
nothingYet: "Nothing yet",
itemCount: "{count} items",
recentEmpty: "Captures and processed files will appear here.",
@ -124,7 +103,6 @@ const messages: Record<Lang, Record<string, string>> = {
shareFiles: "Files",
shareSelectAll: "Select all",
shareSelectionCount: "{selected} of {total} selected",
shareNoFiles: "Select at least one file.",
shareSent: "{name} sent to {peer}.",
shareSentMany: "{count} files sent to {peer}.",
shareFilesCount: "{count} files",
@ -250,36 +228,20 @@ const messages: Record<Lang, Record<string, string>> = {
pinToRecent: "Favorite",
unpinFromRecent: "Unfavorite",
forget: "Remove from the list",
captureAfter: "After capture",
captureAfterCard: "Result card",
captureAfterEditor: "Open editor",
captureAfterBody:
"The card floats where the capture landed with Copy, Pin, Send and Edit on it, then fades away.",
agoNow: "just now",
agoMinutes: "{count}m ago",
agoHours: "{count}h ago",
agoDays: "{count}d ago",
},
zh: {
appName: "Shift",
tagline: "所有操作,只差一个手势。",
heroTitle: "以思考的速度处理文件",
heroBody:
"受 Tangerine 启发的径向文件工作台,并加入 CleanShot 风格的截图、录屏与本地 OCR。",
capture: "区域截图",
captureFullscreen: "全屏截图",
fullScreen: "全屏截图",
record: "区域录屏",
ocr: "文字识别",
dropTitle: "拖入文件开始",
dropBody: "支持图片、PDF、文档和视频。所有处理都在本机完成。",
recent: "最近使用",
noRecent: "你的截图和录屏会出现在这里。",
settings: "设置",
language: "语言",
english: "English",
chinese: "简体中文",
privacy: "本地优先",
chooseAction: "选择操作",
chooseFormat: "松开鼠标即可转换",
releaseCancel: "移回中心可取消",
@ -307,7 +269,6 @@ const messages: Record<Lang, Record<string, string>> = {
cutout: "抠图",
crop: "裁剪",
reveal: "在文件夹中显示",
resize: "缩放",
rotate: "旋转",
flip: "翻转",
blackWhite: "黑白",
@ -318,7 +279,6 @@ const messages: Record<Lang, Record<string, string>> = {
frame: "截帧",
mono: "单声道",
plain: "纯文本",
more: "更多",
merge: "合并",
split: "拆分",
files: "个文件",
@ -330,7 +290,6 @@ const messages: Record<Lang, Record<string, string>> = {
saved: "已保存",
copy: "复制",
pin: "钉在屏幕上",
pinUnavailable: "无法读取要钉住的图片。",
pinLoadFailed: "无法显示钉住的图片。",
copyText: "复制文字",
saveAs: "另存为…",
@ -343,29 +302,22 @@ const messages: Record<Lang, Record<string, string>> = {
audio: "声音",
frameRate: "帧率",
dragSelect: "拖动框选区域",
recordingSaved: "录屏已保存",
ocrTitle: "提取文字",
ocrRunning: "正在识别文字…",
ocrEmpty: "没有识别到可读文字。",
extractText: "提取文字",
revealFile: "在文件夹中显示",
captureFailed: "截图失败",
recordingFailed: "录屏失败",
actionFailed: "操作未能完成",
comingSoon: "该功能即将推出。",
windowTitle: "Shift",
allSet: "准备就绪",
openScreenSettings: "打开屏幕录制设置",
source: "来源",
quickActions: "快捷操作",
tools: "工具",
fileCount: "已选择",
unsupported: "此文件类型暂时没有可用格式",
homeDropTitle: "拖入文件开始处理",
homeDropRelease: "松开即可选择操作",
homeDropRelease: "请松开在按钮上",
homeDropHint: "把文件拖到对应按钮上,执行该操作。",
dropOnButton: "请把文件拖到下方三个按钮之一。",
convertFiles: "文件转换",
fileTools: "文件工具",
items: "项",
nothingYet: "暂无内容",
itemCount: "{count} 项",
recentEmpty: "截图和处理后的文件会出现在这里。",
@ -379,7 +331,6 @@ const messages: Record<Lang, Record<string, string>> = {
shareFiles: "文件",
shareSelectAll: "全选",
shareSelectionCount: "已选 {selected}/{total}",
shareNoFiles: "请至少勾选一个文件。",
shareSent: "已将 {name} 发送到 {peer}。",
shareSentMany: "已发送 {count} 个文件到 {peer}。",
shareFilesCount: "{count} 个文件",
@ -501,11 +452,6 @@ const messages: Record<Lang, Record<string, string>> = {
pinToRecent: "收藏",
unpinFromRecent: "取消收藏",
forget: "从列表移除",
captureAfter: "截图后",
captureAfterCard: "结果卡片",
captureAfterEditor: "打开编辑器",
captureAfterBody:
"卡片悬停在屏幕角落,提供复制、钉住、发送与编辑,然后自动消失。",
agoNow: "刚刚",
agoMinutes: "{count} 分钟前",
agoHours: "{count} 小时前",

View File

@ -141,8 +141,6 @@ export const api = {
revealOutputDirectory: (kind: "screenshot" | "recording" | "files") =>
invoke<void>("reveal_output_directory", { kind }),
openFilesPermissionSettings: () => invoke<void>("open_files_permission_settings"),
setCaptureAfter: (after: "card" | "editor") =>
invoke<AppSettings>("set_capture_after", { after }),
setUpdateCheckEnabled: (enabled: boolean) =>
invoke<SwitchState>("set_update_check_enabled", { enabled }),
setSetupReviewed: (reviewed: boolean) => invoke<boolean>("set_setup_reviewed", { reviewed }),

View File

@ -2,7 +2,6 @@ import { isTauri } from "@tauri-apps/api/core";
import { listen } from "@tauri-apps/api/event";
import { invoke } from "@tauri-apps/api/core";
import {
announceRecentChange,
clearLegacyRecentItems,
getLocalRecentItems,
type RecentItem,
@ -110,6 +109,3 @@ export const history = {
};
},
};
/** Kept so a caller that only has a path can still announce a local change. */
export { announceRecentChange };

File diff suppressed because it is too large Load Diff

View File

@ -88,8 +88,6 @@ export interface AppSettings {
autostart: boolean;
/** "" until the user picks a language; the tray follows whatever is stored. */
language: string;
/** Show the floating result card, or open the editor, after a capture. */
captureAfter: "card" | "editor";
/** Ask the git release branch for a newer build once a day. */
updateCheckEnabled: boolean;
/** Raw URL of the release manifest this build reads; "" when unconfigured. */

View File

@ -8,6 +8,9 @@
"esModuleInterop": true,
"allowSyntheticDefaultImports": true,
"strict": true,
"noUnusedLocals": true,
"noUnusedParameters": true,
"noFallthroughCasesInSwitch": true,
"forceConsistentCasingInFileNames": true,
"module": "ESNext",
"moduleResolution": "Bundler",