feat:移除 banner 图片,使用 cdn 加载

This commit is contained in:
YunaiV
2025-12-22 19:08:37 +08:00
parent f27e78467c
commit 555806f3da
6 changed files with 19 additions and 5 deletions

4
env/.env vendored
View File

@@ -24,8 +24,8 @@ VITE_APP_PROXY_PREFIX = '/admin-api'
# 文件上传类型server - 后端上传, client - 前端直连上传,仅支持 S3 服务
VITE_UPLOAD_TYPE=server
# 第二个请求地址 (目前alova中可以使用)
VITE_SERVER_BASEURL_SECONDARY = 'https://ukw0y1.laf.run'
# 静态资源地址
VITE_STATIC_BASEURL = 'http://test.yudao.iocoder.cn'
# 认证模式,'single' | 'double' ==> 单token | 双token
VITE_AUTH_MODE = 'double'

View File

@@ -14,15 +14,17 @@
</template>
<script lang="ts" setup>
import { staticUrl } from '@/utils/download'
defineOptions({
name: 'HomeBanner',
})
/** Banner 轮播图数据 */
const banners: string[] = [
'/static/images/banner/banner01.jpg',
'/static/images/banner/banner02.jpg',
'/static/images/banner/banner03.jpg',
staticUrl('/static/banner/banner01.png'),
staticUrl('/static/banner/banner02.png'),
staticUrl('/static/banner/banner03.png'),
]
/** 处理点击 */

Binary file not shown.

Before

Width:  |  Height:  |  Size: 232 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 212 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 206 KiB

View File

@@ -123,3 +123,15 @@ export function formatFileSize(size?: number): string {
}
return `${(size / 1024 / 1024 / 1024).toFixed(2)} GB`
}
/**
* 获取静态资源完整 URL 地址
* @param path 资源路径
* @returns 完整的静态资源 URL 地址
*/
export function staticUrl(path: string): string {
const baseUrl = import.meta.env.VITE_STATIC_BASEURL || ''
// 确保 path 以 / 开头
const normalizedPath = path.startsWith('/') ? path : `/${path}`
return `${baseUrl}${normalizedPath}`
}