|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import { invoke } from '@tauri-apps/api/core'; |
|
|
import { MdxProfile } from '../types'; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
export const createDictGroup = async (groupName: string): Promise<number> => { |
|
|
return await invoke('library_create_dict_group', { groupName }); |
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
export const deleteDictGroup = async (groupId: number): Promise<void> => { |
|
|
await invoke('library_delete_dict_group', { groupId }); |
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
export const renameDictGroup = async (groupId: number, newName: string): Promise<void> => { |
|
|
await invoke('library_rename_dict_group', { groupId, newName }); |
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
export const refreshLibrary = async (): Promise<void> => { |
|
|
await invoke('library_refresh_library'); |
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
export const getGroup = async (groupId: number): Promise<MdxProfile> => { |
|
|
return await invoke('library_get_group', { groupId }); |
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
export const getProfile = async (groupId: number, profileId: number): Promise<MdxProfile> => { |
|
|
return await invoke('library_get_profile', { groupId, profileId }); |
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
export const listGroups = async (): Promise<MdxProfile[]> => { |
|
|
return await invoke('library_list_groups'); |
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
export const updateProfileDisabledStatus = async ( |
|
|
parentGroupId: number, |
|
|
profileId: number, |
|
|
disabled: boolean |
|
|
): Promise<void> => { |
|
|
await invoke('library_update_profile_disabled_status', { |
|
|
parentGroupId, |
|
|
profileId, |
|
|
disabled, |
|
|
}); |
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
export const adjustProfileOrder = async ( |
|
|
parentGroupId: number, |
|
|
profileId: number, |
|
|
newIndex: number |
|
|
): Promise<void> => { |
|
|
await invoke('library_adjust_profile_order', { |
|
|
parentGroupId, |
|
|
profileId, |
|
|
newIndex, |
|
|
}); |
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
export const adjustGroupOrder = async (groupId: number, newIndex: number): Promise<void> => { |
|
|
await invoke('library_adjust_group_order', { groupId, newIndex }); |
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
export const openMainDatabase = async (profileId: number): Promise<void> => { |
|
|
await invoke('library_open_main_database', { profileId }); |
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
export const getCurrentMainProfileId = async (): Promise<number> => { |
|
|
return await invoke('library_get_current_main_profile_id'); |
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
export const getMainDbProfile = async (): Promise<MdxProfile | null> => { |
|
|
return await invoke('library_get_main_db_profile'); |
|
|
}; |
|
|
|
|
|
|
|
|
export type { CollationOptions, ConvertOptions } from '../components/ConvertDBDialog'; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
export interface ConversionResult { |
|
|
newMdxPath: string; |
|
|
newMddPath?: string; |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
export const convertFile = async ( |
|
|
profileId: number, |
|
|
collationLocale: string, |
|
|
removeOldFiles: boolean = true |
|
|
): Promise<ConversionResult> => { |
|
|
return await invoke('library_convert_db', { profileId, collationLocale, removeOldFiles }); |
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
export const createFtsIndex = async (mdxFilePath: string): Promise<void> => { |
|
|
await invoke('library_create_fts_index', { mdxFilePath }); |
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
export const cancelConversion = async (): Promise<void> => { |
|
|
await invoke('library_cancel_conversion'); |
|
|
}; |
|
|
|
|
|
|