feat(electron): add font list handlers

This commit is contained in:
Jimmfly
2024-08-19 22:25:15 +08:00
committed by EYHN
parent 3a220da1b6
commit 9a4cb5d69a
5 changed files with 27 additions and 0 deletions
@@ -0,0 +1,15 @@
import { getFonts } from 'font-list';
import type { NamespaceHandlers } from '../type';
export const fontListHandlers = {
getSystemFonts: async () => {
try {
const fonts = await getFonts();
return fonts;
} catch (error) {
console.error('Failed to get system fonts:', error);
return [];
}
},
} satisfies NamespaceHandlers;
@@ -0,0 +1 @@
export * from './handlers';
@@ -5,6 +5,7 @@ import { clipboardHandlers } from './clipboard';
import { configStorageHandlers } from './config-storage';
import { exportHandlers } from './export';
import { findInPageHandlers } from './find-in-page';
import { fontListHandlers } from './font-list';
import { getLogFilePath, logger, revealLogFile } from './logger';
import { sharedStorageHandlers } from './shared-storage';
import { uiHandlers } from './ui/handlers';
@@ -29,6 +30,7 @@ export const allHandlers = {
configStorage: configStorageHandlers,
findInPage: findInPageHandlers,
sharedStorage: sharedStorageHandlers,
fontList: fontListHandlers,
};
export const registerHandlers = () => {