opt: handle error when failed to fetch applist.json

This commit is contained in:
KOWX712
2025-07-02 15:20:48 +08:00
parent 8d2cb81ae6
commit 9c8cb9b6c2

View File

@@ -32,12 +32,19 @@ export async function fetchAppList() {
});
// Fetch cached applist
const response = await fetch('applist.json');
const appList = await response.json();
const appNameMap = appList.reduce((map, app) => {
map[app.package_name] = app.app_name;
return map;
}, {});
let appList = [], appNameMap = {};
try {
const response = await fetch('applist.json');
appList = await response.json();
appNameMap = appList.reduce((map, app) => {
map[app.package_name] = app.app_name;
return map;
}, {});
} catch (error) {
console.warn("Failed to fetch applist.json:", error);
appList = [];
appNameMap = {};
}
// Get installed packages
let appEntries = [], installedPackages = [];