♻️ refactor: centralize app settings

This commit is contained in:
2026-06-30 21:16:05 +07:00
parent 5fe93b26df
commit 9b90140cfd
20 changed files with 284 additions and 134 deletions
+2 -1
View File
@@ -29,7 +29,7 @@ import type { AccountSettings, ContentFilterKey, Pending2Fa, RecoveryCode } from
import type { Group, GroupSnapshot } from "./types/group";
import type { EnhancementId, EnhancementsSnapshot } from "./types/enhancements";
import type { GallerySnapshot, Photo, ThumbCacheStats } from "./types/gallery";
import type { AppConfig, PreferredRegion, RegionPing } from "./types/appConfig";
import type { AppConfig, AppPreferences, PreferredRegion, RegionPing } from "./types/appConfig";
import type { GameStatus } from "./types/game";
import type { IpcResult } from "./types/result";
import type { CacheEntryInfo, CacheStats, DebugSnapshot, LogEntry, WsEvent } from "./types/debug";
@@ -150,6 +150,7 @@ export interface IpcRequests {
"config:setGamePath": (p: { gamePath: string | null }) => IpcResult<AppConfig>;
"config:pickGamePath": () => IpcResult<AppConfig>;
"config:setPreferredRegion": (p: { region: PreferredRegion }) => IpcResult<AppConfig>;
"config:setPreferences": (p: Partial<AppPreferences>) => IpcResult<AppConfig>;
"region:detect": () => IpcResult<InstanceRegion>;
"region:ping": () => IpcResult<RegionPing[]>;
+13
View File
@@ -0,0 +1,13 @@
export const DEFAULT_LOCALE = "en" as const;
export const LOCALES = [
{ code: "en", nativeName: "English", englishName: "English" },
{ code: "ja", nativeName: "日本語", englishName: "Japanese" },
{ code: "th", nativeName: "ไทย", englishName: "Thai" },
] as const;
export type AppLocale = (typeof LOCALES)[number]["code"];
export function isAppLocale(value: unknown): value is AppLocale {
return typeof value === "string" && LOCALES.some((locale) => locale.code === value);
}
+10
View File
@@ -1,12 +1,22 @@
import type { InstanceRegion } from "./instance";
import type { AppLocale } from "../locales";
export type PreferredRegion = InstanceRegion | "auto";
export type AppSchemeMode = "light" | "dark" | "auto";
export interface AppPreferences {
schemeMode: AppSchemeMode;
accent: string | null;
locale: AppLocale;
showDebugNav: boolean;
}
export interface AppConfig {
version: string;
gamePath: string | null;
detectedGamePath: string | null;
preferredRegion: PreferredRegion;
preferences: AppPreferences;
}
export interface RegionPing {