musicControl.ts 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. import api from "./baseApi.ts"
  2. import {ResponseData} from "@/types/apiTypes.ts";
  3. import {Magnet} from "@/types/magnetType.ts";
  4. import {Music_Actions} from "@/apis/ApiAction.ts";
  5. import {MusicScanSetting} from "@/types/musicType.ts";
  6. export async function fetchPlayList(): Promise< ResponseData<Magnet[]> >
  7. {
  8. let [_callId, promise] = api.sendQuery(Music_Actions.play_list_fetch, {});
  9. let response = await promise;
  10. return response;
  11. }
  12. export async function selectScanDir(defaultPath: string): Promise< ResponseData<string> >
  13. {
  14. let [_callId, promise] = api.sendQuery(Music_Actions.scan_music_select, defaultPath, -1, true);
  15. return await promise;
  16. }
  17. export async function addScanDir(scanSetting: MusicScanSetting)
  18. {
  19. let [_callId, promise] = api.sendQuery(Music_Actions.scan_music_add, scanSetting);
  20. return await promise;
  21. }
  22. export async function updateScanConfig(scanConfig: MusicScanSetting)
  23. {
  24. let [_callId, promise] = api.sendQuery(Music_Actions.scan_music_update, scanConfig);
  25. return await promise;
  26. }
  27. export async function fetchScanConfig() : Promise<ResponseData<MusicScanSetting[]>>
  28. {
  29. let [_callId, promise] = api.sendQuery(Music_Actions.scan_settings, {});
  30. return await promise;
  31. }
  32. export async function deleteScanConfig(id: number) : Promise<ResponseData<boolean>>
  33. {
  34. let [_callId, promise] = api.sendQuery(Music_Actions.scan_music_delete, id);
  35. return await promise;
  36. }