refactor: use useFileSelector hook for all file selection (#1905)

This commit is contained in:
Huang Xin
2025-08-26 16:04:10 +08:00
committed by GitHub
parent 66fceb2313
commit 977c61b914
3 changed files with 37 additions and 79 deletions
@@ -71,7 +71,7 @@ const processTauriFiles = (files: string[]): SelectedFile[] => {
export const useFileSelector = (appService: AppService | null, _: (key: string) => string) => {
const selectFiles = async (options: FileSelectorOptions = {}) => {
if (!appService) {
return { files: [], error: 'App service is not available' };
return { files: [] as SelectedFile[], error: 'App service is not available' };
}
try {
if (isTauriAppPlatform()) {
@@ -121,4 +121,9 @@ export const FILE_SELECTION_PRESETS = {
extensions: ['ttf', 'otf', 'woff', 'woff2'],
dialogTitle: _('Select Fonts'),
},
covers: {
accept: '.png, .jpg, .jpeg, .gif',
extensions: ['png', 'jpg', 'jpeg', 'gif'],
dialogTitle: _('Select Image'),
},
};