feat: 仅保留混合模式并根据架构动态构建请求路径

- 删除 AppSidebar.vue 中的 StoreModeSwitcher 引入并删除该组件。
- 强制设置当前商店模式为 'hybrid'。
- 修复了因为 `window.apm_store.arch` 包含 `-store` 或 `-apm` 后缀导致路径替换异常的问题,现在会通过动态添加后缀来构建资源请求路径,以兼容 Spark Store 和 APM Store 服务器不同的资源组织结构。
This commit is contained in:
vmomenv
2026-03-12 01:39:00 +00:00
parent 16f7b62491
commit 70cab0182d
10 changed files with 48 additions and 169 deletions

View File

@@ -72,11 +72,9 @@ const loadedIcon = ref(
);
const iconPath = computed(() => {
const arch = window.apm_store.arch || "amd64-apm";
const arch = window.apm_store.arch || "amd64";
const finalArch =
props.app.origin === "spark"
? arch.replace("-apm", "-store")
: arch.replace("-store", "-apm");
props.app.origin === "spark" ? `${arch}-store` : `${arch}-apm`;
return `${APM_STORE_BASE_URL}/${finalArch}/${props.app.category}/${props.app.pkgname}/icon.png`;
});

View File

@@ -109,7 +109,13 @@
<button
type="button"
class="inline-flex items-center gap-2 rounded-2xl bg-gradient-to-r from-brand to-brand-dark px-4 py-2 text-sm font-semibold text-white shadow-lg transition hover:-translate-y-0.5"
@click="emit('open-app', displayApp?.pkgname || '', displayApp?.origin)"
@click="
emit(
'open-app',
displayApp?.pkgname || '',
displayApp?.origin,
)
"
>
<i class="fas fa-external-link-alt"></i>
<span>打开</span>
@@ -343,11 +349,9 @@ const installBtnText = computed(() => {
});
const iconPath = computed(() => {
if (!displayApp.value) return "";
const arch = window.apm_store.arch || "amd64-apm";
const arch = window.apm_store.arch || "amd64";
const finalArch =
displayApp.value.origin === "spark"
? arch.replace("-apm", "-store")
: arch.replace("-store", "-apm");
displayApp.value.origin === "spark" ? `${arch}-store` : `${arch}-apm`;
return `${APM_STORE_BASE_URL}/${finalArch}/${displayApp.value.category}/${displayApp.value.pkgname}/icon.png`;
});
@@ -360,11 +364,9 @@ watch(
if (newApp) {
downloadCount.value = "";
try {
const arch = window.apm_store.arch || "amd64-apm";
const arch = window.apm_store.arch || "amd64";
const finalArch =
newApp.origin === "spark"
? arch.replace("-apm", "-store")
: arch.replace("-store", "-apm");
newApp.origin === "spark" ? `${arch}-store` : `${arch}-apm`;
const url = `${APM_STORE_BASE_URL}/${finalArch}/${newApp.category}/${newApp.pkgname}/download-times.txt`;
const resp = await axios.get(url, { responseType: "text" });
if (resp.status === 200) {

View File

@@ -89,7 +89,6 @@
<script setup lang="ts">
import ThemeToggle from "./ThemeToggle.vue";
import StoreModeSwitcher from "./StoreModeSwitcher.vue";
import amberLogo from "../assets/imgs/spark-store.svg";
defineProps<{

View File

@@ -65,11 +65,8 @@ defineEmits<{
const computedImgUrl = (link: HomeLink) => {
if (!link.imgUrl) return "";
const arch = window.apm_store.arch || "amd64-apm";
const finalArch =
link.origin === "spark"
? arch.replace("-apm", "-store")
: arch.replace("-store", "-apm");
const arch = window.apm_store.arch || "amd64";
const finalArch = link.origin === "spark" ? `${arch}-store` : `${arch}-apm`;
return `${APM_STORE_BASE_URL}/${finalArch}${link.imgUrl}`;
};

View File

@@ -1,45 +0,0 @@
<template>
<div
class="flex flex-col gap-2 p-4 rounded-2xl bg-slate-50 dark:bg-slate-800/50 border border-slate-200/70 dark:border-slate-700/70"
>
<span
class="text-xs font-semibold uppercase tracking-wider text-slate-500 dark:text-slate-400 px-1"
>商店模式</span
>
<div
class="grid grid-cols-3 gap-1 p-1 bg-slate-200/50 dark:bg-slate-900/50 rounded-xl"
>
<button
v-for="mode in modes"
:key="mode.id"
type="button"
class="flex flex-col items-center justify-center py-2 px-1 rounded-lg text-[10px] font-medium transition-all duration-200"
:class="
currentStoreMode === mode.id
? 'bg-white dark:bg-slate-700 text-brand shadow-sm scale-105 z-10'
: 'text-slate-500 dark:text-slate-400 hover:text-slate-700 dark:hover:text-slate-200'
"
@click="setMode(mode.id as StoreMode)"
>
<i :class="mode.icon" class="mb-1 text-xs"></i>
{{ mode.label }}
</button>
</div>
</div>
</template>
<script setup lang="ts">
import { currentStoreMode } from "../global/storeConfig";
import type { StoreMode } from "../global/typedefinition";
const modes = [
{ id: "spark", label: "星火", icon: "fas fa-fire" },
{ id: "apm", label: "APM", icon: "fas fa-box-open" },
{ id: "hybrid", label: "混合", icon: "fas fa-layer-group" },
];
const setMode = (mode: StoreMode) => {
currentStoreMode.value = mode;
localStorage.setItem("store_mode", mode);
};
</script>