优化历史包袱,修复发布页面默认0 恢哈伏笔

This commit is contained in:
yml2213
2026-05-23 09:41:45 +08:00
parent d1f46fd02e
commit 40f5252b2e
12 changed files with 101 additions and 335 deletions
+7 -18
View File
@@ -20,7 +20,6 @@ import {
type ListingPublishOptions,
} from "@/api/listingOptions";
import { fetchListings, type Listing } from "@/api/listings";
import { buildFallbackListings } from "@/views/mobile/mobileHomeFallback";
import {
formatHafCoinM,
getCoinM,
@@ -32,12 +31,9 @@ import {
getLoginMethod,
getServerRegion,
hasGiftResources,
normalizeLoginMethod,
normalizeServerRegion,
} from "@/views/mobile/listingDisplay";
const loading = ref(false);
const loadFailed = ref(false);
const listings = ref<Listing[]>([]);
const announcements = ref<string[]>(defaultHomeAnnouncements);
const banners = ref<HomeBannerSlide[]>(defaultHomeBanners);
@@ -52,29 +48,24 @@ const filters = reactive({
});
const sortBy = ref("recommended");
const fallbackListings = computed(() => buildFallbackListings(publishOptions.value));
const sourceListings = computed(() =>
loadFailed.value ? fallbackListings.value : listings.value
);
const serverOptions = computed(() =>
uniqueOptions(
publishOptions.value.server_options
.map((item) => normalizeServerRegion(item))
.map((item) => item.trim())
.filter(Boolean)
)
);
const loginMethodOptions = computed(() =>
uniqueOptions(
publishOptions.value.login_method_options
.map((item) => normalizeLoginMethod(item))
.map((item) => item.trim())
.filter(Boolean)
)
);
const visibleListings = computed(() => {
const keyword = filters.keyword.trim().toLowerCase();
const filtered = sourceListings.value.filter((item) => {
const filtered = listings.value.filter((item) => {
const text = [
item.title,
item.description,
@@ -114,12 +105,12 @@ const statCards = computed(() => [
{ label: "可租账号", value: `${visibleListings.value.length}`, hint: "当前筛选结果" },
{
label: "高哈夫币",
value: `${sourceListings.value.filter((item) => getCoinM(item) >= 100).length}`,
value: `${listings.value.filter((item) => getCoinM(item) >= 100).length}`,
hint: "100M 以上",
},
{
label: "账密登录",
value: `${sourceListings.value.filter((item) => getLoginMethod(item) === "账号密码").length}`,
value: `${listings.value.filter((item) => getLoginMethod(item) === "账号密码").length}`,
hint: "交接更快",
},
]);
@@ -128,7 +119,6 @@ onMounted(loadHome);
async function loadHome() {
loading.value = true;
loadFailed.value = false;
try {
const [nextListings, config] = await Promise.all([
fetchListings(),
@@ -139,7 +129,6 @@ async function loadHome() {
banners.value = config.banners;
publishOptions.value = config.publish_options;
} catch {
loadFailed.value = true;
announcements.value = defaultHomeAnnouncements;
banners.value = defaultHomeBanners;
publishOptions.value = defaultListingPublishOptions;
@@ -328,8 +317,8 @@ function uniqueOptions(values: string[]) {
>
<div class="desktop-cover">
<img
v-if="item.screenshot_urls?.[0]"
:src="item.screenshot_urls[0]"
v-if="item.cover_url"
:src="item.cover_url"
:alt="getListingTitle(item)"
/>
<span v-else>HFB</span>