mirror of
https://gitee.com/spark-store-project/spark-store
synced 2026-04-26 09:20:18 +08:00
fix:修复混合模式下计数器问题
This commit is contained in:
26
src/App.vue
26
src/App.vue
@@ -210,7 +210,7 @@ const isDarkTheme = computed(() => {
|
||||
return themeMode.value === "dark";
|
||||
});
|
||||
|
||||
const categories: Ref<Record<string, string>> = ref({});
|
||||
const categories: Ref<Record<string, any>> = ref({});
|
||||
const apps: Ref<App[]> = ref([]);
|
||||
const activeCategory = ref("home");
|
||||
const searchQuery = ref("");
|
||||
@@ -403,8 +403,9 @@ const openDetail = (app: App | Record<string, unknown>) => {
|
||||
tags: '',
|
||||
img_urls: [],
|
||||
icons: '',
|
||||
origin: (app as any).origin || 'apm',
|
||||
currentStatus: 'not-installed',
|
||||
};
|
||||
} as App;
|
||||
}
|
||||
|
||||
// 后续逻辑使用 fullApp
|
||||
@@ -884,7 +885,7 @@ const loadCategories = async () => {
|
||||
if (currentStoreMode.value === "hybrid") modes.push("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) {
|
||||
const finalArch =
|
||||
@@ -897,10 +898,16 @@ const loadCategories = async () => {
|
||||
const response = await axiosInstance.get(cacheBuster(path));
|
||||
const data = response.data;
|
||||
Object.keys(data).forEach((key) => {
|
||||
if (categoryData[key]) {
|
||||
if (!categoryData[key].origins.includes(mode)) {
|
||||
categoryData[key].origins.push(mode);
|
||||
}
|
||||
} else {
|
||||
categoryData[key] = {
|
||||
zh: data[key].zh || data[key],
|
||||
origin: mode,
|
||||
origins: [mode],
|
||||
};
|
||||
}
|
||||
});
|
||||
} catch (e) {
|
||||
logger.error(`读取 ${mode} categories.json 失败: ${e}`);
|
||||
@@ -923,9 +930,12 @@ const loadApps = async (onFirstBatch?: () => void) => {
|
||||
// 并发加载所有分类,每个分类自带重试机制
|
||||
await Promise.all(
|
||||
categoriesList.map(async (category) => {
|
||||
try {
|
||||
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 =
|
||||
mode === "spark"
|
||||
? arch.replace("-apm", "-store")
|
||||
@@ -973,8 +983,10 @@ const loadApps = async (onFirstBatch?: () => void) => {
|
||||
onFirstBatch();
|
||||
}
|
||||
} catch (error) {
|
||||
logger.warn(`加载分类 ${category} 最终失败: ${error}`);
|
||||
logger.warn(`加载分类 ${category} 来源 ${mode} 最终失败: ${error}`);
|
||||
}
|
||||
})
|
||||
);
|
||||
}),
|
||||
);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user