Skip to content

armgit / cindy

Public Imported from GitHub
0

Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。

feat(remote-desktop): 分辨率设置拆为画面比例与按本机推荐的分辨率 (#5525)

Dash510f66b20e66
diff --git a/apps/desktop/src/renderer/features/remote-desktop/RemoteDesktopViewerWindow.tsx b/apps/desktop/src/renderer/features/remote-desktop/RemoteDesktopViewerWindow.tsx
index 1902611936..2af82460c7 100644
--- a/apps/desktop/src/renderer/features/remote-desktop/RemoteDesktopViewerWindow.tsx
+++ b/apps/desktop/src/renderer/features/remote-desktop/RemoteDesktopViewerWindow.tsx
@@ -27,6 +27,16 @@ import { ConfirmDialog } from '@/components/ui/confirm-dialog';
import { Switch } from '@/components/ui/switch';
import { Popover, PopoverContent, PopoverTrigger } from '@/components/ui/popover';
import { Tip } from '@/components/ui/tooltip';
+import {
+ fittedChoices,
+ ratioLabel,
+ recommendedFit,
+ sameRatio,
+ tagRecommendedModes,
+ type ResolutionChoice,
+ type ResolutionTier,
+ type Size,
+} from './displayChoices';
// Fullscreen keeps an 8px toolbar strip visible. Electron drag regions swallow
// hover and macOS slides its own menu bar over the top edge, so reveal is
@@ -40,6 +50,20 @@ const QUALITY_LABELS = {
hd: 'remoteDesktop.viewer.hd',
} as const satisfies Record<RemoteDesktopVideoQuality, string>;
+const ASPECT_LABELS = {
+ original: 'remoteDesktop.viewer.aspectOriginal',
+ screen: 'remoteDesktop.viewer.aspectScreen',
+ window: 'remoteDesktop.viewer.aspectWindow',
+ current: 'remoteDesktop.viewer.aspectCurrent',
+} as const;
+
+const TIER_LABELS = {
+ same: 'remoteDesktop.viewer.resolutionSame',
+ larger: 'remoteDesktop.viewer.resolutionLarger',
+ more: 'remoteDesktop.viewer.resolutionMore',
+ max: 'remoteDesktop.viewer.resolutionMax',
+} as const satisfies Record<ResolutionTier, string>;
+
/** A clean, standalone remote desktop surface. No App, router, agent or task providers. */
export function RemoteDesktopViewerWindow() {
const { t } = useTranslation();
@@ -175,6 +199,73 @@ export function RemoteDesktopViewerWindow() {
setSelectOpen(open);
if (open) controller.current?.releaseInput();
};
+ // The choices below read this window and screen; refresh them while the
+ // panel is open and the window is resized or moved to a differently scaled screen.
+ const [viewport, setViewport] = useState(0);
+ useEffect(() => {
+ if (settings !== 'display') return;
+ const update = () => setViewport((value) => value + 1);
+ const scale = window.matchMedia?.(`(resolution: ${window.devicePixelRatio}dppx)`);
+ window.addEventListener('resize', update);
+ scale?.addEventListener('change', update);
+ return () => {
+ window.removeEventListener('resize', update);
+ scale?.removeEventListener('change', update);
+ };
+ }, [settings, viewport]);
+ // Sizes are in this screen's points: one remote pixel per local point looks the same size.
+ const screenSize = { width: window.screen.width, height: window.screen.height };
+ const windowSize =
+ root.current && root.current.clientWidth > 0 && root.current.clientHeight > 0
+ ? { width: root.current.clientWidth, height: root.current.clientHeight }
+ : null;
+ const ownDisplay = state?.caps?.displays.find((display) => display.id === state.displayId);
+ const fitted = state?.fittedDisplay ?? null;
+ const showWindow = !!windowSize && !sameRatio(windowSize, screenSize);
+ const aspectValue = !fitted
+ ? 'original'
+ : sameRatio(fitted, screenSize)
+ ? 'screen'
+ : showWindow && sameRatio(fitted, windowSize)
+ ? 'window'
+ : 'current';
+ // A computer already at this screen's ratio needs no temporary display.
+ const showScreen = aspectValue === 'screen' || !sameRatio(ownDisplay, screenSize);
+ const aspectOption = (
+ value: 'original' | 'screen' | 'window' | 'current',
+ size: Size | null | undefined,
+ recommended = false,
+ ) => {
+ const label = [t(ASPECT_LABELS[value]), size && ratioLabel(size)].filter(Boolean).join(' · ');
+ return {
+ value,
+ label: recommended ? t('remoteDesktop.viewer.recommended', { label }) : label,
+ disabled: value === 'original' && !!fitted && !state?.caps?.viewerDisplayRestore,
+ };
+ };
+ const aspect = {
+ value: aspectValue,
+ options: [
+ aspectOption('original', ownDisplay, !showScreen),
+ ...(showScreen ? [aspectOption('screen', screenSize, true)] : []),
+ ...(showWindow ? [aspectOption('window', windowSize)] : []),
+ ...(aspectValue === 'current' ? [aspectOption('current', fitted)] : []),
+ ],
+ };
+ // The window choice matches this window's size; the others match this screen.
+ const areaFor = (value: string) => (value === 'window' && windowSize ? windowSize : screenSize);
+ const applyRatio = (value: 'screen' | 'window') => {
+ const ratio = areaFor(value);
+ const size = recommendedFit(ratio, ratio);
+ if (!size) return Promise.resolve();
+ return controller.current?.fitDisplay(size.width, size.height, true, undefined, { ratio });
+ };
+ const ratioArea = areaFor(aspectValue);
+ const currentMode = modes.find((mode) => mode.current);
+ const resolutionChoices: ResolutionChoice[] =
+ fitted && currentMode
+ ? fittedChoices(fitted, ratioArea, currentMode, window.devicePixelRatio)
+ : tagRecommendedModes(modes, ratioArea, window.devicePixelRatio);
const workspaceAction = (action: 'workspaceLeft' | 'workspaceRight' | 'omarchyMenu') => {
const owner = generation.current;
void controller.current?.workspaceAction(action).catch(() => {
@@ -450,30 +541,37 @@ export function RemoteDesktopViewerWindow() {
</>
)}
{state?.caps?.viewerDisplay && (
- <div className="flex flex-col gap-2">
- <Button
- variant="secondary"
- disabled={!state.controlling || state.controlPending}
- onClick={() => {
- if (!root.current) return;
- void controller.current
- ?.fitDisplay(root.current.clientWidth, root.current.clientHeight)
- .then(loadModes)
- .catch(() => setNotice(t('remoteDesktop.viewer.settingsFailed')));
- }}
- >
- {t(
- root.current &&
- controller.current?.viewerDisplayMatched(
- root.current.clientWidth,
- root.current.clientHeight,
+ <FormField
+ label={t('remoteDesktop.viewer.aspect')}
+ hint={t('remoteDesktop.viewer.aspectHint')}
+ className="remote-viewer-field remote-viewer-field-wide"
+ >
+ {(control) => (
+ <Select
+ {...control}
+ className="w-full"
+ label={t('remoteDesktop.viewer.aspect')}
+ disabled={!state.controlling || state.controlPending}
+ value={aspect.value}
+ options={aspect.options}
+ onValueChange={(value) => {
+ if (value === 'current') return;
+ const owner = generation.current;
+ void (
+ value === 'original'
+ ? controller.current?.restoreDisplay()
+ : applyRatio(value === 'window' ? 'window' : 'screen')
)
- ? 'remoteDesktop.viewer.restoreViewerDisplay'
- : 'remoteDesktop.viewer.fitViewerDisplay',
- )}
- </Button>
- <p>{t('remoteDesktop.viewer.fitViewerDisplayHint')}</p>
- </div>
+ ?.then(loadModes)
+ .catch(() => {
+ if (owner === generation.current)
+ setNotice(t('remoteDesktop.viewer.settingsFailed'));
+ });
+ }}
+ onOpenChange={onSelectOpenChange}
+ />
+ )}
+ </FormField>
)}
{modesStatus === 'loading' && (
<p role="status">{t('remoteDesktop.loadingDisplayModes')}</p>
@@ -486,24 +584,35 @@ export function RemoteDesktopViewerWindow() {
</Button>
</div>
)}
- {modes.length > 0 && (
+ {resolutionChoices.length > 0 && (
<FormField
label={t('remoteDesktop.viewer.resolution')}
- className="remote-viewer-field"
+ hint={
+ resolutionChoices.some((mode) => mode.tier)
+ ? t('remoteDesktop.viewer.resolutionTierHint')
+ : undefined
+ }
+ className="remote-viewer-field remote-viewer-field-wide"
>
- {({ id }) => (
+ {(control) => (
<Select
- id={id}
+ {...control}
className="w-full"
label={t('remoteDesktop.viewer.resolution')}
disabled={!state?.controlling || state.controlPending}
- value={modes.find((mode) => mode.current)?.id ?? ''}
- options={modes.map((mode) => ({
+ value={resolutionChoices.find((mode) => mode.current)?.id ?? ''}
+ options={resolutionChoices.map((mode) => ({
value: mode.id,
- label: `${mode.width} × ${mode.height}${mode.native ? ` · ${t('remoteDesktop.nativeResolution')}` : ''}`,
+ label: [
+ `${mode.width} × ${mode.height}`,
+ mode.tier && t(TIER_LABELS[mode.tier]),
+ mode.native && t('remoteDesktop.nativeResolution'),
+ ]
+ .filter(Boolean)
+ .join(' · '),
}))}
onValueChange={(value) => {
- const mode = modes.find((item) => item.id === value);
+ const mode = resolutionChoices.find((item) => item.id === value);
if (!mode) return;
void controller.current
?.resolution(mode)
diff --git a/apps/desktop/src/renderer/features/remote-desktop/__tests__/displayChoices.test.ts b/apps/desktop/src/renderer/features/remote-desktop/__tests__/displayChoices.test.ts
new file mode 100644
index 0000000000..68206f66ad
--- /dev/null
+++ b/apps/desktop/src/renderer/features/remote-desktop/__tests__/displayChoices.test.ts
@@ -0,0 +1,98 @@
+import { describe, expect, it } from 'vitest';
+import {
+ fittedChoices,
+ ratioLabel,
+ recommendedFit,
+ sameRatio,
+ tagRecommendedModes,
+} from '../displayChoices';
+
+const listed = (choices: { width: number; height: number; tier?: string; current: boolean }[]) =>
+ choices.map((choice) => [`${choice.width}x${choice.height}`, choice.tier, choice.current]);
+
+describe('ratioLabel', () => {
+ it('names familiar ratios and falls back to long edge per short edge', () => {
+ expect(ratioLabel({ width: 2560, height: 1440 })).toBe('16:9');
+ expect(ratioLabel({ width: 1440, height: 900 })).toBe('16:10');
+ expect(ratioLabel({ width: 900, height: 1440 })).toBe('10:16');
+ expect(ratioLabel({ width: 1512, height: 982 })).toBe('1.54:1');
+ });
+});
+
+describe('sameRatio', () => {
+ it('tolerates even-pixel rounding but not a different shape', () => {
+ expect(sameRatio({ width: 1512, height: 982 }, { width: 1210, height: 786 })).toBe(true);
+ expect(sameRatio({ width: 1600, height: 900 }, { width: 1600, height: 1000 })).toBe(false);
+ expect(sameRatio(null, { width: 1, height: 1 })).toBe(false);
+ });
+});
+
+describe('fitted sizes', () => {
+ const macbook = { width: 1512, height: 982 };
+
+ it('applies this screen’s own size first, or the host’s largest', () => {
+ expect(recommendedFit(macbook, macbook)).toEqual(macbook);
+ expect(recommendedFit({ width: 3440, height: 1440 }, { width: 3440, height: 1440 })).toEqual({
+ width: 2560,
+ height: 1072,
+ });
+ });
+
+ it('offers more space only where a HiDPI screen keeps it sharp', () => {
+ expect(listed(fittedChoices(macbook, macbook, macbook, 2))).toEqual([
+ ['1210x786', 'larger', false],
+ ['1512x982', 'same', true],
+ ['1890x1228', 'more', false],
+ ]);
+ expect(listed(fittedChoices(macbook, macbook, macbook, 1))).toEqual([
+ ['1210x786', 'larger', false],
+ ['1512x982', 'same', true],
+ ]);
+ });
+
+ it('merges sizes the host limit collapses and keeps a larger-text one', () => {
+ const qhd = { width: 2560, height: 1440 };
+ // More space would exceed the host's 2560 limit and lands on the same size.
+ expect(listed(fittedChoices(qhd, qhd, qhd, 1.5))).toEqual([
+ ['2048x1152', 'larger', false],
+ ['2560x1440', 'same', true],
+ ]);
+ const wide = { width: 3440, height: 1440 };
+ expect(listed(fittedChoices(wide, wide, { width: 2560, height: 1072 }, 1))).toEqual([
+ ['2048x858', 'larger', false],
+ ['2560x1072', 'max', true],
+ ]);
+ });
+
+ it('calls a size the host limit shrank the largest, however slightly', () => {
+ const screen = { width: 2600, height: 1625 };
+ expect(listed(fittedChoices(screen, screen, { width: 2560, height: 1600 }, 1))).toEqual([
+ ['2080x1300', 'larger', false],
+ ['2560x1600', 'max', true],
+ ]);
+ });
+
+ it('keeps a current size that is not recommended', () => {
+ expect(listed(fittedChoices(macbook, macbook, { width: 1920, height: 1246 }, 1))).toEqual([
+ ['1210x786', 'larger', false],
+ ['1512x982', 'same', false],
+ ['1920x1246', undefined, true],
+ ]);
+ });
+});
+
+describe('tagRecommendedModes', () => {
+ it('marks the computer’s own modes close to a recommended size', () => {
+ const modes = [
+ { id: 'a', width: 1280, height: 720, current: false },
+ { id: 'b', width: 1920, height: 1080, current: false },
+ { id: 'c', width: 2560, height: 1440, current: true, native: true },
+ ];
+ expect(tagRecommendedModes(modes, { width: 2560, height: 1600 }, 1).map((m) => m.tier)).toEqual(
+ [undefined, undefined, 'same'],
+ );
+ expect(tagRecommendedModes(modes, { width: 1600, height: 1000 }, 2).map((m) => m.tier)).toEqual(
+ ['larger', 'more', undefined],
+ );
+ });
+});
diff --git a/apps/desktop/src/renderer/features/remote-desktop/__tests__/viewerControl.test.ts b/apps/desktop/src/renderer/features/remote-desktop/__tests__/viewerControl.test.ts
index 85551f8c13..851b16eaf1 100644
--- a/apps/desktop/src/renderer/features/remote-desktop/__tests__/viewerControl.test.ts
+++ b/apps/desktop/src/renderer/features/remote-desktop/__tests__/viewerControl.test.ts
@@ -57,11 +57,7 @@ async function fixture(
}));
let remembered = options.remembered ?? null;
const memory = vi.fn(
- async (
- _generation: number,
- _displayId: string,
- value?: RememberedViewerResolution | null,
- ) => {
+ async (_generation: number, _displayId: string, value?: RememberedViewerResolution | null) => {
if (value !== undefined) remembered = value;
return remembered;
},
@@ -137,13 +133,9 @@ async function fixture(
resolution: memory,
...options.api,
} satisfies RemoteDesktopViewerApi;
- controller = new DesktopViewerController(
- api,
- (options.root ?? {}) as HTMLElement,
- (state) => {
- snapshot = state;
- },
- );
+ controller = new DesktopViewerController(api, (options.root ?? {}) as HTMLElement, (state) => {
+ snapshot = state;
+ });
await vi.advanceTimersByTimeAsync(0);
return { control, heartbeat, clipboard, resolution, memory, api };
}
@@ -509,6 +501,9 @@ it('passes actual logical geometry to rendering and reacquires control after fit
});
expect(snapshot.controlling).toBe(true);
expect(f.control).toHaveBeenLastCalledWith(true);
+ // The list keeps the size the user asked for as current, not the host's logical size.
+ const current = (await controller.resolutionModes()).filter((mode) => mode.current);
+ expect(current).toMatchObject([{ width: 1920, height: 1420 }]);
});
const sent = (type: string) =>
@@ -558,11 +553,8 @@ it('offers same-ratio choices after fitting and restores the original display',
present();
// Host modes keep the monitor's ratio: the portrait mode is not offered.
expect((await controller.resolutionModes()).map((mode) => mode.id)).toEqual(['4k']);
- expect(controller.viewerDisplayMatched(500, 1000)).toBe(false);
await controller.fitDisplay(500, 1000);
expect(snapshot.fittedDisplay).toEqual({ width: 960, height: 1920 });
- expect(controller.viewerDisplayMatched(500, 1000)).toBe(true);
- expect(controller.viewerDisplayMatched(1000, 500)).toBe(false);
const fitted = await controller.resolutionModes();
expect(fitted.every((mode) => Math.abs(mode.width / mode.height - 0.5) < 0.003)).toBe(true);
expect(fitted.find((mode) => mode.current)).toMatchObject({ width: 960, height: 1920 });
@@ -573,7 +565,10 @@ it('offers same-ratio choices after fitting and restores the original display',
undefined,
);
expect(snapshot.fittedDisplay).toEqual({ width: 960, height: 1920 });
+ // Fitting the same ratio again is a fit, not a restore; restoring is explicit.
await controller.fitDisplay(500, 1000);
+ expect(request.mock.calls.some(([, r]) => r.op === 'restoreViewerDisplay')).toBe(false);
+ await controller.restoreDisplay();
expect(request.mock.calls.some(([, r]) => r.op === 'restoreViewerDisplay')).toBe(true);
expect(snapshot.fittedDisplay).toBeNull();
expect(f.memory).toHaveBeenLastCalledWith(1, 'one', null);
@@ -584,7 +579,10 @@ it('remembers system modes per monitor and forgets the computer’s own mode', a
const original = f.api.request;
vi.spyOn(f.api, 'request').mockImplementation(async (generation, r) =>
r.op === 'displayModes'
- ? [{ ...mode4k, current: true }, { id: 'hd', width: 1920, height: 1080, current: false }]
+ ? [
+ { ...mode4k, current: true },
+ { id: 'hd', width: 1920, height: 1080, current: false },
+ ]
: original(generation, r),
);
present();
@@ -614,7 +612,7 @@ it('reapplies a remembered system mode once control and the first frame are read
expect(f.resolution).toHaveBeenCalledOnce();
});
-it('refits a remembered fit to the current window at the remembered size', async () => {
+it('reapplies a remembered fit at its own size and ratio', async () => {
const f = await fixture(undefined, false, {
remembered: { kind: 'fit', width: 1280, height: 960 },
root: { clientWidth: 1000, clientHeight: 500 },
@@ -624,10 +622,28 @@ it('refits a remembered fit to the current window at the remembered size', async
await vi.advanceTimersByTimeAsync(0);
expect(request).toHaveBeenCalledWith(
1,
- expect.objectContaining({ op: 'viewerDisplay', width: 1280, height: 640 }),
+ expect.objectContaining({ op: 'viewerDisplay', width: 1280, height: 960 }),
+ undefined,
+ );
+ expect(snapshot.fittedDisplay).toEqual({ width: 1280, height: 960 });
+});
+
+it('switches the fitted ratio and keeps it across same-ratio sizes', async () => {
+ const f = await fixture();
+ const request = vi.spyOn(f.api, 'request');
+ present();
+ await controller.fitDisplay(500, 1000);
+ const screenRatio = { width: 1512, height: 982 };
+ await controller.fitDisplay(1512, 982, true, undefined, { ratio: screenRatio });
+ expect(request).toHaveBeenCalledWith(
+ 1,
+ expect.objectContaining({ op: 'viewerDisplay', width: 1512, height: 982 }),
undefined,
);
- expect(snapshot.fittedDisplay).toEqual({ width: 1920, height: 960 });
+ expect(snapshot.fittedDisplay).toEqual(screenRatio);
+ await controller.resolution({ id: 'fitted:1210x786', width: 1210, height: 786, current: false });
+ expect(snapshot.fittedDisplay).toEqual(screenRatio);
+ expect(f.memory).toHaveBeenLastCalledWith(1, 'one', { kind: 'fit', width: 1210, height: 786 });
});
it('does not retry a remembered choice that failed in this window', async () => {
@@ -690,17 +706,38 @@ it('maps channel refusals to the relay and real failures to errors', async () =>
const f = await channelFixture();
present();
f.ask(control, 'busy');
- runtime.post?.({ type: 'channelReply', epoch: 'lease', id: 'busy', ok: false, error: 'DESKTOP_CHANNEL_BUSY' });
+ runtime.post?.({
+ type: 'channelReply',
+ epoch: 'lease',
+ id: 'busy',
+ ok: false,
+ error: 'DESKTOP_CHANNEL_BUSY',
+ });
f.ask({ op: 'displayModes', lease: 'lease' }, 'large');
- runtime.post?.({ type: 'channelReply', epoch: 'lease', id: 'large', ok: false, error: 'DESKTOP_REPLY_TOO_LARGE' });
+ runtime.post?.({
+ type: 'channelReply',
+ epoch: 'lease',
+ id: 'large',
+ ok: false,
+ error: 'DESKTOP_REPLY_TOO_LARGE',
+ });
f.ask(control, 'failed');
- runtime.post?.({ type: 'channelReply', epoch: 'lease', id: 'failed', ok: false, error: 'DESKTOP_VIEW_ONLY' });
+ runtime.post?.({
+ type: 'channelReply',
+ epoch: 'lease',
+ id: 'failed',
+ ok: false,
+ error: 'DESKTOP_VIEW_ONLY',
+ });
f.ask(control, 'unsent');
runtime.post?.({ type: 'channelRequestState', epoch: 'lease', id: 'unsent', sent: false });
await vi.advanceTimersByTimeAsync(0);
expect(f.channelReply).toHaveBeenCalledWith(1, 'busy', { kind: 'relay' });
expect(f.channelReply).toHaveBeenCalledWith(1, 'large', { kind: 'relay' });
- expect(f.channelReply).toHaveBeenCalledWith(1, 'failed', { kind: 'error', code: 'DESKTOP_VIEW_ONLY' });
+ expect(f.channelReply).toHaveBeenCalledWith(1, 'failed', {
+ kind: 'error',
+ code: 'DESKTOP_VIEW_ONLY',
+ });
expect(f.channelReply).toHaveBeenCalledWith(1, 'unsent', { kind: 'relay' });
});
diff --git a/apps/desktop/src/renderer/features/remote-desktop/__tests__/viewerWindow.test.tsx b/apps/desktop/src/renderer/features/remote-desktop/__tests__/viewerWindow.test.tsx
index 1eb59e91e0..490bb22caf 100644
--- a/apps/desktop/src/renderer/features/remote-desktop/__tests__/viewerWindow.test.tsx
+++ b/apps/desktop/src/renderer/features/remote-desktop/__tests__/viewerWindow.test.tsx
@@ -1,6 +1,6 @@
// @vitest-environment jsdom
import { act, cleanup, fireEvent, render, screen, within, waitFor } from '@testing-library/react';
-import { afterEach, expect, it, vi } from 'vitest';
+import { afterEach, expect, it, onTestFinished, vi } from 'vitest';
import i18n from '@/i18n';
import { RemoteDesktopViewerWindow } from '../RemoteDesktopViewerWindow';
import type { ViewerSnapshot } from '../viewerController';
@@ -15,6 +15,10 @@ const lifecycle = vi.hoisted(() => ({
actualSize: vi.fn(),
keys: vi.fn(),
workspaceAction: vi.fn(async () => {}),
+ resolutionModes: vi.fn(async (): Promise<unknown[]> => []),
+ fitDisplay: vi.fn(async () => {}),
+ restoreDisplay: vi.fn(async () => {}),
+ resolution: vi.fn(async () => {}),
update: null as ((state: ViewerSnapshot) => void) | null,
}));
vi.mock('../viewerController', () => ({
@@ -35,6 +39,10 @@ vi.mock('../viewerController', () => ({
actualSize = lifecycle.actualSize;
keys = lifecycle.keys;
workspaceAction = lifecycle.workspaceAction;
+ resolutionModes = lifecycle.resolutionModes;
+ fitDisplay = lifecycle.fitDisplay;
+ restoreDisplay = lifecycle.restoreDisplay;
+ resolution = lifecycle.resolution;
close = () => this._api.close(1);
},
}));
@@ -511,3 +519,133 @@ it('releases shortcut capture when the picture input loses focus programmaticall
act(() => input.blur());
expect(inputFocus).toHaveBeenLastCalledWith(1, false);
});
+
+it('splits display size into a ratio choice and recommended resolutions for this screen', async () => {
+ await i18n.changeLanguage('zh-CN');
+ // jsdom has no scrollIntoView; Radix Select calls it when its list opens.
+ const scrollIntoView = HTMLElement.prototype.scrollIntoView;
+ HTMLElement.prototype.scrollIntoView = vi.fn();
+ onTestFinished(() => {
+ HTMLElement.prototype.scrollIntoView = scrollIntoView;
+ });
+ Object.defineProperties(window.screen, {
+ width: { configurable: true, value: 1512 },
+ height: { configurable: true, value: 982 },
+ });
+ Object.assign(window, {
+ electronAPI: {
+ remoteDesktopViewer: {
+ onActive: () => () => {},
+ onLocale: () => () => {},
+ onCloseRequested: () => () => {},
+ state: async () => ({ generation: 1 }),
+ rendererReady: async () => {},
+ presentationReady: async () => {},
+ inputFocus: async () => {},
+ },
+ },
+ });
+ lifecycle.resolutionModes.mockResolvedValue([
+ { id: 'hd', width: 1920, height: 1080, current: false },
+ { id: 'qhd', width: 2560, height: 1440, current: true, native: true },
+ ]);
+ render(<RemoteDesktopViewerWindow />);
+ const state: ViewerSnapshot = {
+ target: { deviceId: 'host', name: 'Mac' },
+ status: 'live',
+ error: null,
+ controlling: true,
+ controlPending: false,
+ caps: {
+ version: 1,
+ enabled: true,
+ canControl: true,
+ platform: 'darwin',
+ displays: [{ id: 'one', name: 'Display', width: 2560, height: 1440 }],
+ displayModes: true,
+ viewerDisplay: true,
+ viewerDisplayRestore: true,
+ },
+ displayId: 'one',
+ transport: 'direct',
+ latency: null,
+ settings: { fps: 30, quality: 'auto', audio: false },
+ ready: true,
+ preferences: {
+ audio: false,
+ privacyScreen: false,
+ hostMute: false,
+ clipboardSync: false,
+ lockOnExit: false,
+ },
+ safety: { privacyActive: false, notice: null, clipboardProgress: null },
+ receiveRate: null,
+ closing: false,
+ credential: null,
+ credentialBusy: false,
+ credentialNotice: null,
+ fittedDisplay: null,
+ };
+ await act(async () => lifecycle.update?.(state));
+ fireEvent.click(screen.getByRole('button', { name: '影音' }));
+ const panel = within(screen.getByRole('dialog', { name: '影音' }));
+ const aspect = panel.getByRole('combobox', { name: '画面比例' });
+ const resolution = await panel.findByRole('combobox', { name: '电脑分辨率' });
+ expect(aspect.textContent).toBe('电脑原始 · 16:9');
+ expect(resolution.textContent).toBe('2560 × 1440 · 原生');
+ // Each field's hint is announced with its control.
+ expect(document.getElementById(aspect.getAttribute('aria-describedby')!)?.textContent).toBe(
+ i18n.t('remoteDesktop.viewer.aspectHint'),
+ );
+ // Choices follow this screen: one already at the computer's ratio needs no other ratio.
+ Object.defineProperties(window.screen, {
+ width: { configurable: true, value: 1600 },
+ height: { configurable: true, value: 900 },
+ });
+ act(() => {
+ window.dispatchEvent(new Event('resize'));
+ });
+ expect(aspect.textContent).toBe('电脑原始 · 16:9(推荐)');
+ Object.defineProperties(window.screen, {
+ width: { configurable: true, value: 1512 },
+ height: { configurable: true, value: 982 },
+ });
+ act(() => {
+ window.dispatchEvent(new Event('resize'));
+ });
+ expect(aspect.textContent).toBe('电脑原始 · 16:9');
+ fireEvent.keyDown(aspect, { key: 'ArrowDown' });
+ const choice = await screen.findByRole('option', { name: '本机屏幕 · 1.54:1(推荐)' });
+ expect(screen.queryByRole('option', { name: /当前窗口/ })).toBeNull();
+ lifecycle.resolutionModes.mockResolvedValue([
+ { id: 'fitted:1512x982', width: 1512, height: 982, current: true },
+ ]);
+ fireEvent.keyDown(choice, { key: 'Enter' });
+ await waitFor(() =>
+ expect(lifecycle.fitDisplay).toHaveBeenCalledWith(1512, 982, true, undefined, {
+ ratio: { width: 1512, height: 982 },
+ }),
+ );
+ await act(async () =>
+ lifecycle.update?.({ ...state, fittedDisplay: { width: 1512, height: 982 } }),
+ );
+ await waitFor(() => expect(resolution.textContent).toBe('1512 × 982 · 与本机一致'));
+ expect(aspect.textContent).toBe('本机屏幕 · 1.54:1(推荐)');
+ expect(document.getElementById(resolution.getAttribute('aria-describedby')!)?.textContent).toBe(
+ i18n.t('remoteDesktop.viewer.resolutionTierHint'),
+ );
+ fireEvent.keyDown(resolution, { key: 'ArrowDown' });
+ fireEvent.keyDown(await screen.findByRole('option', { name: '1210 × 786 · 字更大' }), {
+ key: 'Enter',
+ });
+ await waitFor(() =>
+ expect(lifecycle.resolution).toHaveBeenCalledWith(
+ expect.objectContaining({ width: 1210, height: 786 }),
+ ),
+ );
+ fireEvent.keyDown(aspect, { key: 'ArrowDown' });
+ fireEvent.keyDown(await screen.findByRole('option', { name: '电脑原始 · 16:9' }), {
+ key: 'Enter',
+ });
+ await waitFor(() => expect(lifecycle.restoreDisplay).toHaveBeenCalledOnce());
+});
diff --git a/apps/desktop/src/renderer/features/remote-desktop/displayChoices.ts b/apps/desktop/src/renderer/features/remote-desktop/displayChoices.ts
new file mode 100644
index 0000000000..914a0450bc
--- /dev/null
+++ b/apps/desktop/src/renderer/features/remote-desktop/displayChoices.ts
@@ -0,0 +1,125 @@
+import type { RemoteDesktopDisplayMode } from '@cindy/device-link';
+
+export type Size = { width: number; height: number };
+
+/** What a recommended size does on this computer's screen. */
+export type ResolutionTier = 'same' | 'larger' | 'more' | 'max';
+
+/** A resolution entry; `tier` marks a size recommended for this computer's screen. */
+export interface ResolutionChoice extends RemoteDesktopDisplayMode {
+ tier?: ResolutionTier;
+}
+
+// Scales of this screen's own size, in priority order: when two land on the
+// same size, the earlier one stays. Above 1 only stays sharp on a HiDPI screen.
+const TIERS: readonly { tier: ResolutionTier; scale: number; hidpi?: boolean }[] = [
+ { tier: 'same', scale: 1 },
+ { tier: 'larger', scale: 0.8 },
+ { tier: 'more', scale: 1.25, hidpi: true },
+];
+const FITTED_MIN = 320;
+const FITTED_MAX = 2560;
+const COMMON_RATIOS = [
+ [16, 9],
+ [16, 10],
+ [3, 2],
+ [4, 3],
+ [5, 4],
+ [1, 1],
+ [21, 9],
+ [32, 9],
+];
+
+const valid = (size: Size | null | undefined): size is Size =>
+ !!size && size.width > 0 && size.height > 0;
+const near = (a: number, b: number) => Math.abs(a / b - 1) < 0.05;
+const tiersFor = (pixelRatio: number) => TIERS.filter((tier) => !tier.hidpi || pixelRatio >= 1.5);
+
+/** Same picture shape, tolerant of the even-pixel rounding of fitted sizes. */
+export function sameRatio(a: Size | null | undefined, b: Size | null | undefined): boolean {
+ return valid(a) && valid(b) && Math.abs((a.width * b.height) / (a.height * b.width) - 1) < 0.01;
+}
+
+/** A familiar name such as 16:10, otherwise the long edge per short edge. */
+export function ratioLabel(size: Size): string {
+ const landscape = size.width >= size.height;
+ const ratio = landscape ? size.width / size.height : size.height / size.width;
+ const [long, short] = COMMON_RATIOS.find(([a, b]) => Math.abs(ratio / (a / b) - 1) < 0.01) ?? [
+ Number(ratio.toFixed(2)),
+ 1,
+ ];
+ return landscape ? `${long}:${short}` : `${short}:${long}`;
+}
+
+/** The size that matches this screen: the ratio shown point-for-point as large as `area` allows. */
+function sameSize(ratio: Size, area: Size): Size {
+ const scale = Math.min(area.width / ratio.width, area.height / ratio.height);
+ return { width: ratio.width * scale, height: ratio.height * scale };
+}
+
+/** Even pixel sizes the host can create; larger requests shrink to its limit. */
+function fittedSize(base: Size, scale: number): Size | null {
+ const shrink = Math.min(1, FITTED_MAX / (Math.max(base.width, base.height) * scale));
+ const width = Math.round((base.width * scale * shrink) / 2) * 2;
+ const height = Math.round((base.height * scale * shrink) / 2) * 2;
+ return Math.min(width, height) >= FITTED_MIN ? { width, height } : null;
+}
+
+/** The size a ratio choice applies first: this screen's size, or the host's largest. */
+export function recommendedFit(ratio: Size, area: Size): Size | null {
+ return valid(ratio) && valid(area) ? fittedSize(sameSize(ratio, area), 1) : null;
+}
+
+/** A picture fitted to `ratio` offers only the recommended sizes, plus the current one. */
+export function fittedChoices(
+ ratio: Size,
+ area: Size,
+ current: Size,
+ pixelRatio: number,
+): ResolutionChoice[] {
+ const isCurrent = (size: Size) => size.width === current.width && size.height === current.height;
+ const choices: ResolutionChoice[] = [];
+ if (valid(ratio) && valid(area)) {
+ const base = sameSize(ratio, area);
+ const add = (size: Size | null, tier: ResolutionTier) => {
+ if (!size || choices.some((choice) => near(choice.width, size.width))) return;
+ choices.push({ id: `fitted:${size.width}x${size.height}`, ...size, current: false, tier });
+ };
+ for (const { tier, scale } of tiersFor(pixelRatio)) {
+ // A size the host's limit shrank is simply the largest available.
+ const capped = Math.max(base.width, base.height) * scale > FITTED_MAX;
+ add(fittedSize(base, scale), capped ? 'max' : tier);
+ }
+ // A screen past the host's limit collapses the sizes; keep a larger-text one.
+ if (choices.length === 1) add(fittedSize(choices[0], 0.8), 'larger');
+ }
+ if (!choices.some(isCurrent))
+ choices.push({
+ id: `fitted:${current.width}x${current.height}`,
+ width: current.width,
+ height: current.height,
+ current: true,
+ });
+ for (const choice of choices) choice.current = isCurrent(choice);
+ return choices.sort((a, b) => a.width - b.width);
+}
+
+/** The computer's own modes are fixed; mark those close to a recommended size. */
+export function tagRecommendedModes(
+ modes: RemoteDesktopDisplayMode[],
+ area: Size,
+ pixelRatio: number,
+): ResolutionChoice[] {
+ const choices: ResolutionChoice[] = modes.map((mode) => ({ ...mode }));
+ const reference = modes.find((mode) => mode.current) ?? modes[0];
+ if (!valid(reference) || !valid(area)) return choices;
+ const base = sameSize(reference, area);
+ for (const { tier, scale } of tiersFor(pixelRatio)) {
+ const target = base.width * scale;
+ const nearest = choices
+ .filter((choice) => choice.tier === undefined)
+ .sort((a, b) => Math.abs(a.width - target) - Math.abs(b.width - target))[0];
+ if (nearest && near(nearest.width, target)) nearest.tier = tier;
+ }
+ return choices;
+}
diff --git a/apps/desktop/src/renderer/features/remote-desktop/viewerController.ts b/apps/desktop/src/renderer/features/remote-desktop/viewerController.ts
index c272a68c3e..735774f59c 100644
--- a/apps/desktop/src/renderer/features/remote-desktop/viewerController.ts
+++ b/apps/desktop/src/renderer/features/remote-desktop/viewerController.ts
@@ -137,6 +137,9 @@ export class DesktopViewerController {
>();
/** The computer's own mode at the start of a lease; choosing it again forgets the memory. */
private hostMode: { lease: string; modeId?: string } | null = null;
+ /** The size last asked of a fitted display. A HiDPI host may report a smaller
+ * logical size; the list still shows the entry the user chose as current. */
+ private fittedRequest: { lease: string; size: Size } | null = null;
/** The remembered display choice is reapplied once per lease. */
private rememberedLease: string | null = null;
/** A remembered choice that failed is not retried in this window, so it cannot loop reconnects. */
@@ -729,7 +732,11 @@ export class DesktopViewerController {
async resolutionModes(): Promise<RemoteDesktopDisplayMode[]> {
const lease = this.session.lease;
if (!lease) return [];
- if (this.state.fittedDisplay) return fittedDisplayModes(this.state.fittedDisplay, lease.display);
+ if (this.state.fittedDisplay)
+ return fittedDisplayModes(
+ this.state.fittedDisplay,
+ this.fittedRequest?.lease === lease.lease ? this.fittedRequest.size : lease.display,
+ );
const modes = await this.displayModes();
// CoreGraphics modes keep their own orientation when Electron's display
// geometry is rotated. Compare modes in the enumeration's coordinate space.
@@ -755,22 +762,19 @@ export class DesktopViewerController {
}
throw new Error('DESKTOP_DISPLAY_MODES_UNAVAILABLE');
}
- /** Whether the fit button restores the computer's own display for this viewer size. */
- viewerDisplayMatched(width: number, height: number): boolean {
+ /** Returns from a fitted picture to the computer's own display and ratio. */
+ async restoreDisplay(): Promise<void> {
const fitted = this.state.fittedDisplay;
- return Boolean(
- fitted &&
- this.state.caps?.viewerDisplayRestore &&
- this.session.lease &&
- sameAspect(fitted, width, height),
- );
+ if (!fitted || !this.state.caps?.viewerDisplayRestore) return;
+ await this.fitDisplay(fitted.width, fitted.height, false, undefined, { restore: true });
}
+ /** `ratio` names the picture shape chosen for the same-ratio size list. */
async fitDisplay(
width: number,
height: number,
exactResolution = false,
modeId?: string,
- options: { viewport?: Size; remembered?: boolean } = {},
+ options: { ratio?: Size; remembered?: boolean; restore?: boolean } = {},
): Promise<void> {
if (
exactResolution &&
@@ -789,10 +793,7 @@ export class DesktopViewerController {
)
return;
const fitted = this.state.fittedDisplay;
- // Fitting again at the ratio already fitted restores the computer's display.
- const restore = Boolean(
- !exactResolution && fitted && caps?.viewerDisplayRestore && sameAspect(fitted, width, height),
- );
+ const restore = Boolean(options.restore && fitted && caps?.viewerDisplayRestore);
this.publish({ controlPending: true });
this.syncControl();
// A host that can follow display changes keeps the running stream; only a
@@ -822,9 +823,7 @@ export class DesktopViewerController {
? { kind: 'mode', modeId, width, height }
: { kind: 'fit', width: size.width, height: size.height },
);
- const fittedBase = options.viewport
- ? viewerDisplaySize(options.viewport.width, options.viewport.height)
- : null;
+ this.fittedRequest = modeId || restore ? null : { lease: lease.lease, size: { ...size } };
this.publish({
// Keep the physical source as the reconnect target; the temporary
// display is only the current capture/input surface.
@@ -832,13 +831,15 @@ export class DesktopViewerController {
// The temporary capture surface is lease state, never a reconnectable
// display choice in the selector.
caps,
- // Same-ratio sizes stay around the plain fit of the viewer.
+ // Keep the chosen ratio rather than a rounded size, so same-ratio
+ // choices do not drift from one resolution change to the next.
fittedDisplay:
modeId || restore
? null
- : exactResolution && (fitted ?? fittedBase)
- ? (fitted ?? fittedBase)
- : { width: next.display.width, height: next.display.height },
+ : (options.ratio ??
+ (exactResolution && fitted
+ ? fitted
+ : { width: next.display.width, height: next.display.height })),
});
const geometry = {
width: next.display.width,
@@ -915,23 +916,12 @@ export class DesktopViewerController {
if (!unchanged()) return;
if (remembered.kind === 'fit') {
if (!caps.viewerDisplay) return;
- // Same path as the button: measure this window now, then fit at the
- // remembered size if it is one of the same-ratio choices.
- const viewport = { width: this.root.clientWidth, height: this.root.clientHeight };
- const base = viewerDisplaySize(viewport.width, viewport.height);
- const edge = Math.max(remembered.width, remembered.height);
- const exact = base
- ? fittedDisplayModes(base, base).find((mode) => Math.max(mode.width, mode.height) === edge)
- : undefined;
- if (exact)
- await this.fitDisplay(exact.width, exact.height, true, undefined, {
- viewport,
- remembered: true,
- });
- else
- await this.fitDisplay(viewport.width, viewport.height, false, undefined, {
- remembered: true,
- });
+ // The ratio is a choice of its own now, not this window's shape.
+ const size = { width: remembered.width, height: remembered.height };
+ await this.fitDisplay(size.width, size.height, true, undefined, {
+ ratio: size,
+ remembered: true,
+ });
return;
}
if (!caps.resolutionRestore) return;
diff --git a/apps/desktop/src/renderer/features/remote-desktop/viewerWindow.css b/apps/desktop/src/renderer/features/remote-desktop/viewerWindow.css
index ed7859ec64..4cd0d9249b 100644
--- a/apps/desktop/src/renderer/features/remote-desktop/viewerWindow.css
+++ b/apps/desktop/src/renderer/features/remote-desktop/viewerWindow.css
@@ -261,6 +261,14 @@
grid-template-columns: minmax(0, 1fr) minmax(0, var(--space-40));
align-items: center;
}
+/* Ratio and size labels carry more than one word; give them the row's width. */
+.remote-viewer-field-wide {
+ grid-template-columns: auto minmax(0, 1fr);
+ column-gap: var(--space-3);
+}
+.remote-viewer-field-wide > :nth-child(n + 3) {
+ grid-column: 1 / -1;
+}
.remote-viewer-display-select {
flex: none;
width: 100%;
diff --git a/apps/desktop/src/renderer/i18n/locales/en/common.json b/apps/desktop/src/renderer/i18n/locales/en/common.json
index 5d472cc2d0..8238c7edcf 100644
--- a/apps/desktop/src/renderer/i18n/locales/en/common.json
+++ b/apps/desktop/src/renderer/i18n/locales/en/common.json
@@ -327,9 +327,18 @@
"confirmDisconnectHint": "The remote desktop connection will end. Apps on the computer will keep running.",
"disconnectFailed": "Could not disconnect. Try again.",
"clipboardShortcutHint": "Use {{modifier}}+C / {{modifier}}+V in the picture to copy and paste. Supported content depends on the remote computer; files are not transferred.",
- "fitViewerDisplay": "Match Current View",
- "restoreViewerDisplay": "Restore Original Aspect Ratio",
- "fitViewerDisplayHint": "Temporarily adjusts the computer desktop to this view’s aspect ratio, keeping its contents. Disconnect to restore the original resolution.",
+ "aspect": "Aspect ratio",
+ "aspectOriginal": "Original",
+ "aspectScreen": "This screen",
+ "aspectWindow": "This window",
+ "aspectCurrent": "Current",
+ "recommended": "{{label}} (Recommended)",
+ "aspectHint": "Match this screen to reduce empty space. The computer’s desktop ratio changes temporarily and keeps its contents; the original resolution returns when you disconnect.",
+ "resolutionSame": "Same as this screen",
+ "resolutionLarger": "Larger text",
+ "resolutionMore": "More space",
+ "resolutionMax": "Largest",
+ "resolutionTierHint": "Lower resolutions show larger text and use less data; higher ones fit more windows.",
"resolutionHint": "Resolution changes affect the actual remote monitor."
},
"settingUnsupported": "This computer does not support this setting yet",
diff --git a/apps/desktop/src/renderer/i18n/locales/ja/common.json b/apps/desktop/src/renderer/i18n/locales/ja/common.json
index be52012aa8..29f0c8fd70 100644
--- a/apps/desktop/src/renderer/i18n/locales/ja/common.json
+++ b/apps/desktop/src/renderer/i18n/locales/ja/common.json
@@ -327,9 +327,18 @@
"confirmDisconnectHint": "リモートデスクトップ接続を終了します。コンピュータ上のアプリは動作を続けます。",
"disconnectFailed": "切断できませんでした。もう一度お試しください。",
"clipboardShortcutHint": "画面内で {{modifier}}+C / {{modifier}}+V を使ってコピー・貼り付けできます。対応する内容は接続先のパソコンによって異なります。ファイルは転送されません。",
- "fitViewerDisplay": "現在の画面比率に合わせる",
- "restoreViewerDisplay": "元の縦横比に戻す",
- "fitViewerDisplayHint": "デスクトップの内容を保ったまま、パソコンの画面比率を一時的に変更します。切断すると元の解像度に戻ります。",
+ "aspect": "画面比率",
+ "aspectOriginal": "パソコン本来",
+ "aspectScreen": "この画面",
+ "aspectWindow": "このウィンドウ",
+ "aspectCurrent": "現在",
+ "recommended": "{{label}}(おすすめ)",
+ "aspectHint": "この画面に合わせると余白が減ります。デスクトップの内容を保ったままパソコンの画面比率を一時的に変更し、切断すると元の解像度に戻ります。",
+ "resolutionSame": "この画面と同じ",
+ "resolutionLarger": "文字を大きく",
+ "resolutionMore": "作業領域を広く",
+ "resolutionMax": "最大",
+ "resolutionTierHint": "解像度が低いほど文字が大きく通信量も少なくなり、高いほど多くのウィンドウを表示できます。",
"resolutionHint": "解像度の変更はリモートの実際のモニターに反映されます。"
},
"settingUnsupported": "このパソコンはまだこの設定に対応していません",
diff --git a/apps/desktop/src/renderer/i18n/locales/ko/common.json b/apps/desktop/src/renderer/i18n/locales/ko/common.json
index 72ed6d8bc4..6cfc435d2e 100644
--- a/apps/desktop/src/renderer/i18n/locales/ko/common.json
+++ b/apps/desktop/src/renderer/i18n/locales/ko/common.json
@@ -327,9 +327,18 @@
"confirmDisconnectHint": "원격 데스크톱 연결이 종료됩니다. 컴퓨터의 앱은 계속 실행됩니다.",
"disconnectFailed": "연결을 끊지 못했습니다. 다시 시도하세요.",
"clipboardShortcutHint": "화면 안에서 {{modifier}}+C / {{modifier}}+V로 복사하고 붙여넣으세요. 지원되는 내용은 원격 컴퓨터에 따라 다르며 파일은 전송되지 않습니다.",
- "fitViewerDisplay": "현재 화면 비율에 맞추기",
- "restoreViewerDisplay": "원래 화면 비율로 복원",
- "fitViewerDisplayHint": "데스크톱 내용을 유지하면서 컴퓨터 화면 비율을 일시적으로 변경합니다. 연결을 종료하면 원래 해상도로 돌아갑니다.",
+ "aspect": "화면 비율",
+ "aspectOriginal": "컴퓨터 원래",
+ "aspectScreen": "이 화면",
+ "aspectWindow": "이 창",
+ "aspectCurrent": "현재",
+ "recommended": "{{label}} (추천)",
+ "aspectHint": "이 화면에 맞추면 여백이 줄어듭니다. 데스크톱 내용을 유지한 채 컴퓨터 화면 비율을 일시적으로 변경하며, 연결을 종료하면 원래 해상도로 돌아갑니다.",
+ "resolutionSame": "이 화면과 같게",
+ "resolutionLarger": "글자 크게",
+ "resolutionMore": "공간 넓게",
+ "resolutionMax": "최대",
+ "resolutionTierHint": "해상도가 낮을수록 글자가 크고 데이터를 덜 쓰며, 높을수록 더 많은 창을 띄울 수 있습니다.",
"resolutionHint": "해상도를 변경하면 원격 컴퓨터의 실제 모니터에 적용됩니다."
},
"settingUnsupported": "이 컴퓨터는 아직 이 설정을 지원하지 않습니다",
diff --git a/apps/desktop/src/renderer/i18n/locales/zh-CN/common.json b/apps/desktop/src/renderer/i18n/locales/zh-CN/common.json
index 17dc793c03..c0f6f2cd9d 100644
--- a/apps/desktop/src/renderer/i18n/locales/zh-CN/common.json
+++ b/apps/desktop/src/renderer/i18n/locales/zh-CN/common.json
@@ -327,9 +327,18 @@
"confirmDisconnectHint": "将结束远程桌面连接,电脑上的应用仍会继续运行。",
"disconnectFailed": "未能断开连接,请重试。",
"clipboardShortcutHint": "在画面内使用 {{modifier}}+C / {{modifier}}+V 复制粘贴。支持的内容取决于远程电脑,暂不传输文件。",
- "fitViewerDisplay": "按当前画面比例调整",
- "restoreViewerDisplay": "恢复原始比例",
- "fitViewerDisplayHint": "临时调整电脑桌面比例,保留当前桌面内容。退出连接后恢复原分辨率。",
+ "aspect": "画面比例",
+ "aspectOriginal": "电脑原始",
+ "aspectScreen": "本机屏幕",
+ "aspectWindow": "当前窗口",
+ "aspectCurrent": "当前",
+ "recommended": "{{label}}(推荐)",
+ "aspectHint": "选择本机比例可减少留白。会临时调整电脑桌面比例并保留桌面内容,退出连接后恢复原分辨率。",
+ "resolutionSame": "与本机一致",
+ "resolutionLarger": "字更大",
+ "resolutionMore": "更多空间",
+ "resolutionMax": "最大",
+ "resolutionTierHint": "分辨率越低字越大、越省流量;越高能放下越多窗口。",
"resolutionHint": "分辨率修改会影响远端的实际显示器。"
},
"settingUnsupported": "当前电脑端暂不支持此设置",
diff --git a/apps/desktop/src/renderer/i18n/locales/zh-TW/common.json b/apps/desktop/src/renderer/i18n/locales/zh-TW/common.json
index 5b0b4da0f4..fac16391dd 100644
--- a/apps/desktop/src/renderer/i18n/locales/zh-TW/common.json
+++ b/apps/desktop/src/renderer/i18n/locales/zh-TW/common.json
@@ -327,9 +327,18 @@
"confirmDisconnectHint": "將結束遠端桌面連線,電腦上的應用程式仍會繼續執行。",
"disconnectFailed": "無法中斷連線,請重試。",
"clipboardShortcutHint": "在畫面內使用 {{modifier}}+C / {{modifier}}+V 複製貼上。支援的內容取決於遠端電腦,暫不傳輸檔案。",
- "fitViewerDisplay": "依目前畫面比例調整",
- "restoreViewerDisplay": "恢復原始比例",
- "fitViewerDisplayHint": "暫時調整電腦桌面比例,保留目前桌面內容。離開連線後恢復原解析度。",
+ "aspect": "畫面比例",
+ "aspectOriginal": "電腦原始",
+ "aspectScreen": "本機螢幕",
+ "aspectWindow": "目前視窗",
+ "aspectCurrent": "目前",
+ "recommended": "{{label}}(推薦)",
+ "aspectHint": "選擇本機比例可減少留白。會暫時調整電腦桌面比例並保留桌面內容,離開連線後恢復原解析度。",
+ "resolutionSame": "與本機一致",
+ "resolutionLarger": "字更大",
+ "resolutionMore": "更多空間",
+ "resolutionMax": "最大",
+ "resolutionTierHint": "解析度越低字越大、越省流量;越高能放下越多視窗。",
"resolutionHint": "解析度修改會影響遠端的實際顯示器。"
},
"settingUnsupported": "目前電腦端尚不支援此設定",