这是indexloc提供的服务,不要输入任何密码
Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 6 additions & 10 deletions src/appState.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,12 @@ import {
DEFAULT_FONT_FAMILY,
DEFAULT_FONT_SIZE,
DEFAULT_TEXT_ALIGN,
EXPORT_SCALES,
DEFAULT_EXPORT_SCALE
} from "./constants";
import { t } from "./i18n";
import { AppState, NormalizedZoomValue } from "./types";
import { getDateTime } from "./utils";

const defaultExportScale = EXPORT_SCALES.includes(devicePixelRatio)
? devicePixelRatio
: 1;

export const getDefaultAppState = (): Omit<
AppState,
"offsetTop" | "offsetLeft" | "width" | "height"
Expand Down Expand Up @@ -44,7 +40,7 @@ export const getDefaultAppState = (): Omit<
elementType: "selection",
errorMessage: null,
exportBackground: true,
exportScale: defaultExportScale,
exportScale: DEFAULT_EXPORT_SCALE,
exportEmbedScene: false,
exportWithDarkMode: false,
fileHandle: null,
Expand Down Expand Up @@ -76,7 +72,7 @@ export const getDefaultAppState = (): Omit<
viewBackgroundColor: oc.white,
zenModeEnabled: false,
zoom: { value: 1 as NormalizedZoomValue, translation: { x: 0, y: 0 } },
viewModeEnabled: false,
viewModeEnabled: false
};
};

Expand All @@ -93,7 +89,7 @@ const APP_STATE_STORAGE_CONF = (<
},
T extends Record<keyof AppState, Values>
>(
config: { [K in keyof T]: K extends keyof AppState ? T[K] : never },
config: { [K in keyof T]: K extends keyof AppState ? T[K] : never }
) => config)({
theme: { browser: true, export: false },
collaborators: { browser: false, export: false },
Expand Down Expand Up @@ -157,12 +153,12 @@ const APP_STATE_STORAGE_CONF = (<
width: { browser: false, export: false },
zenModeEnabled: { browser: true, export: false },
zoom: { browser: true, export: false },
viewModeEnabled: { browser: false, export: false },
viewModeEnabled: { browser: false, export: false }
});

const _clearAppStateForStorage = <ExportType extends "export" | "browser">(
appState: Partial<AppState>,
exportType: ExportType,
exportType: ExportType
) => {
type ExportableKeys = {
[K in keyof typeof APP_STATE_STORAGE_CONF]: typeof APP_STATE_STORAGE_CONF[K][ExportType] extends true
Expand Down
1 change: 1 addition & 0 deletions src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -145,4 +145,5 @@ export const MQ_MAX_HEIGHT_LANDSCAPE = 500;
export const MAX_DECIMALS_FOR_SVG_EXPORT = 2;

export const EXPORT_SCALES = [1, 2, 3];
export const DEFAULT_EXPORT_SCALE = 1;
export const DEFAULT_EXPORT_PADDING = 10; // px