项目文件夹

文件
wehub-resource-sync 2114b14ee0
Sync main into demo / sync (push) Has been cancelled
chore: import upstream snapshot with attribution
2026-07-13 12:35:26 +08:00

22 行
733 B
TypeScript

import { netJson } from '../../../os/NetworkService';
import type { ITunesResponse } from './jsonp';
type ITunesParams = Record<string, string | number | boolean | undefined | null>;
function toQuery(params: ITunesParams) {
const query = new URLSearchParams();
for (const [key, value] of Object.entries(params)) {
if (value === undefined || value === null) continue;
query.set(key, String(value));
}
return query.toString();
}
export function searchITunes(params: ITunesParams) {
return netJson<ITunesResponse>(`https://itunes.apple.com/search?${toQuery(params)}`);
}
export function lookupITunes(params: ITunesParams) {
return netJson<ITunesResponse>(`https://itunes.apple.com/lookup?${toQuery(params)}`);
}