fix:修复混合模式下计数器问题

This commit is contained in:
2026-03-11 08:51:10 +08:00
parent 257065018b
commit 66bf0124bd

View File

@@ -210,7 +210,7 @@ const isDarkTheme = computed(() => {
return themeMode.value === "dark"; return themeMode.value === "dark";
}); });
const categories: Ref<Record<string, string>> = ref({}); const categories: Ref<Record<string, any>> = ref({});
const apps: Ref<App[]> = ref([]); const apps: Ref<App[]> = ref([]);
const activeCategory = ref("home"); const activeCategory = ref("home");
const searchQuery = ref(""); const searchQuery = ref("");
@@ -403,8 +403,9 @@ const openDetail = (app: App | Record<string, unknown>) => {
tags: '', tags: '',
img_urls: [], img_urls: [],
icons: '', icons: '',
origin: (app as any).origin || 'apm',
currentStatus: 'not-installed', currentStatus: 'not-installed',
}; } as App;
} }
// 后续逻辑使用 fullApp // 后续逻辑使用 fullApp
@@ -884,7 +885,7 @@ const loadCategories = async () => {
if (currentStoreMode.value === "hybrid") modes.push("spark", "apm"); if (currentStoreMode.value === "hybrid") modes.push("spark", "apm");
else modes.push(currentStoreMode.value as "spark" | "apm"); else modes.push(currentStoreMode.value as "spark" | "apm");
const categoryData: Record<string, { zh: string; origin: string }> = {}; const categoryData: Record<string, { zh: string; origins: string[] }> = {};
for (const mode of modes) { for (const mode of modes) {
const finalArch = const finalArch =
@@ -897,10 +898,16 @@ const loadCategories = async () => {
const response = await axiosInstance.get(cacheBuster(path)); const response = await axiosInstance.get(cacheBuster(path));
const data = response.data; const data = response.data;
Object.keys(data).forEach((key) => { Object.keys(data).forEach((key) => {
if (categoryData[key]) {
if (!categoryData[key].origins.includes(mode)) {
categoryData[key].origins.push(mode);
}
} else {
categoryData[key] = { categoryData[key] = {
zh: data[key].zh || data[key], zh: data[key].zh || data[key],
origin: mode, origins: [mode],
}; };
}
}); });
} catch (e) { } catch (e) {
logger.error(`读取 ${mode} categories.json 失败: ${e}`); logger.error(`读取 ${mode} categories.json 失败: ${e}`);
@@ -923,9 +930,12 @@ const loadApps = async (onFirstBatch?: () => void) => {
// 并发加载所有分类,每个分类自带重试机制 // 并发加载所有分类,每个分类自带重试机制
await Promise.all( await Promise.all(
categoriesList.map(async (category) => { categoriesList.map(async (category) => {
try {
const catInfo = categories.value[category]; const catInfo = categories.value[category];
const mode = catInfo.origin; const origins: string[] = catInfo.origins || (catInfo.origin ? [catInfo.origin] : []);
await Promise.all(
origins.map(async (mode) => {
try {
const finalArch = const finalArch =
mode === "spark" mode === "spark"
? arch.replace("-apm", "-store") ? arch.replace("-apm", "-store")
@@ -973,8 +983,10 @@ const loadApps = async (onFirstBatch?: () => void) => {
onFirstBatch(); onFirstBatch();
} }
} catch (error) { } catch (error) {
logger.warn(`加载分类 ${category} 最终失败: ${error}`); logger.warn(`加载分类 ${category} 来源 ${mode} 最终失败: ${error}`);
} }
})
);
}), }),
); );