fix(banner): add nginx uploads proxy and resolve absolute image url for banners

这个提交包含在:
xcbyy
2026-10-10 11:09:36 +08:00
父节点 9417fe24b3
当前提交 df92166162
共有 2 个文件被更改,包括 26 次插入 和 6 次删除

查看文件

@@ -17,7 +17,7 @@
<swiper class="banner-swiper" circular autoplay interval="4000" indicator-dots indicator-color="rgba(255,255,255,0.3)" indicator-active-color="#6366F1">
<swiper-item v-for="banner in banners" :key="banner.id" class="banner-item" @click="goToActivity(banner)">
<view class="banner-card" :style="{ background: banner.bg || 'linear-gradient(135deg, #F43F5E 0%, #FB7185 100%)' }">
<image v-if="banner.image" class="banner-bg-img" :src="banner.image" mode="aspectFill" />
<image v-if="banner.image" class="banner-bg-img" :src="resolveBannerImage(banner.image)" mode="aspectFill" />
<view v-if="banner.image" class="banner-overlay"></view>
<view class="banner-content">
<view class="banner-tag">{{ banner.tag || banner.badge || '热门陪伴' }}</view>
@@ -199,6 +199,14 @@ const fetchLiveNavCategories = async () => {
}
};
const resolveBannerImage = (img) => {
if (!img) return '';
if (img.startsWith('/uploads/')) {
return `https://peiww.gynhc.com${img}`;
}
return img;
};
const resolveIcon = (icon) => {
if (!icon) return ICONS.gridAll;
if (ICONS[icon]) return ICONS[icon];

查看文件

@@ -696,6 +696,18 @@ export class MysqlRepository {
};
}
private formatBanner(banner: any): any {
if (!banner) return null;
let image = banner.image || '';
if (image && image.startsWith('/uploads/')) {
image = `https://peiww.gynhc.com${image}`;
}
return {
...banner,
image,
};
}
async getBanners(): Promise<any[]> {
const [rows]: any = await pool.query(`
SELECT
@@ -706,7 +718,7 @@ export class MysqlRepository {
WHERE status = 1
ORDER BY sort_order ASC, id DESC
`);
return rows;
return (rows || []).map((b: any) => this.formatBanner(b));
}
async getAdminBanners(): Promise<any[]> {
@@ -718,7 +730,7 @@ export class MysqlRepository {
FROM banners
ORDER BY sort_order ASC, id DESC
`);
return rows;
return (rows || []).map((b: any) => this.formatBanner(b));
}
async createBanner(data: {
@@ -758,7 +770,7 @@ export class MysqlRepository {
FROM banners
WHERE id = ?
`, [newId]);
return rows[0];
return this.formatBanner(rows[0]);
}
async updateBanner(id: number | string, data: Partial<{
@@ -830,7 +842,7 @@ export class MysqlRepository {
FROM banners
WHERE id = ?
`, [id]);
return rows[0] || null;
return this.formatBanner(rows[0]) || null;
}
async updateBannerStatus(id: number | string, status: number): Promise<any> {
@@ -843,7 +855,7 @@ export class MysqlRepository {
FROM banners
WHERE id = ?
`, [id]);
return rows[0] || null;
return this.formatBanner(rows[0]) || null;
}
async deleteBanner(id: number | string): Promise<boolean> {