feat(oss图片): oss图片链接改用cdn加速链接

This commit is contained in:
hzj 2026-05-09 19:30:42 +08:00
parent 53885656ff
commit 6da368fcac
6 changed files with 24 additions and 16 deletions

View File

@ -119,7 +119,7 @@ const bgVapUrl = mp4Url('bg')
生成的线上地址形如:
```text
https://tkm-likei.oss-ap-southeast-1.aliyuncs.com/h5/Azizi/Activities/ActiveGame/bg.mp4
https://cdn.azizichat.com/h5/Azizi/Activities/ActiveGame/bg.mp4
```
开发环境会走:
@ -199,7 +199,7 @@ await preloadVapConfig(resolveProtectedAssetUrl(bgVapUrl))
```js
const rewardVapUrl =
'https://tkm-likei.oss-ap-southeast-1.aliyuncs.com/svgasource/manager-d824e59b-1a88-4d4f-aed3-01768ba20542.mp4'
'https://cdn.azizichat.com/svgasource/manager-d824e59b-1a88-4d4f-aed3-01768ba20542.mp4'
```
## 预加载建议

View File

@ -102,7 +102,7 @@ const shouldShowImage = computed(() => {
// const isOSSImage = computed(() => {
// return (
// props.imgUrl.startsWith('/oss/h5/Azizi/') ||
// props.imgUrl.startsWith('https://tkm-likei.oss-ap-southeast-1.aliyuncs.com/h5/Azizi/')
// props.imgUrl.startsWith('https://cdn.azizichat.com/h5/Azizi/')
// )
// })

View File

@ -1,9 +1,7 @@
import { protectAssetUrl } from '@/utils/protectedAssets.js'
export const OSS_BASE_URL =
process.env.NODE_ENV === 'development'
? '/oss/h5/Azizi/'
: 'https://tkm-likei.oss-ap-southeast-1.aliyuncs.com/h5/Azizi/'
process.env.NODE_ENV === 'development' ? '/oss/h5/Azizi/' : 'https://cdn.azizichat.com/h5/Azizi/'
function buildAssetUrl(imagePath, filename, extension) {
return `${OSS_BASE_URL}${imagePath}${filename}.${extension}`

View File

@ -61,7 +61,7 @@ class ImageCacheManager {
let cacheName
if (
normalizedUrl.startsWith('https://tkm-likei.oss-ap-southeast-1.aliyuncs.com/h5/Azizi/') ||
normalizedUrl.startsWith('https://cdn.azizichat.com/h5/Azizi/') ||
normalizedUrl.includes('/oss/h5/Azizi/')
) {
cacheName = this.imageCacheName
@ -309,9 +309,7 @@ class ImageCacheManager {
const containsAssets = normalizedUrl.includes('/assets/')
const containsOssH5 = normalizedUrl.includes('/oss/h5/Azizi/')
const startsWithOss = normalizedUrl.startsWith(
'https://tkm-likei.oss-ap-southeast-1.aliyuncs.com/h5/Azizi/',
)
const startsWithOss = normalizedUrl.startsWith('https://cdn.azizichat.com/h5/Azizi/')
// 只缓存三种类型的资源
return containsAssets || containsOssH5 || startsWithOss

View File

@ -9,7 +9,11 @@ const isEmptySourceValue = (value) => {
return true
}
return ['', 'null', 'undefined'].includes(String(value || '').trim().toLowerCase())
return ['', 'null', 'undefined'].includes(
String(value || '')
.trim()
.toLowerCase(),
)
}
const getRewardRawSourceUrl = (reward = {}) => {
@ -52,7 +56,9 @@ export function useDailyRechargeRewardVap(options = {}) {
if (resolvedUrl.startsWith('//')) {
const protocol =
typeof window !== 'undefined' && window.location?.protocol ? window.location.protocol : 'https:'
typeof window !== 'undefined' && window.location?.protocol
? window.location.protocol
: 'https:'
return `${protocol}${resolvedUrl}`
}
@ -71,7 +77,7 @@ export function useDailyRechargeRewardVap(options = {}) {
if (resolvedUrl.startsWith('/')) {
return process.env.NODE_ENV === 'development'
? `/oss${resolvedUrl}`
: `https://tkm-likei.oss-ap-southeast-1.aliyuncs.com${resolvedUrl}`
: `https://cdn.azizichat.com${resolvedUrl}`
}
return `https://${resolvedUrl}`
@ -82,7 +88,10 @@ export function useDailyRechargeRewardVap(options = {}) {
return false
}
return /^https?:\/\/.+\.mp4(?:[?#].*)?$/i.test(sourceUrl) || /^\/oss\/.+\.mp4(?:[?#].*)?$/i.test(sourceUrl)
return (
/^https?:\/\/.+\.mp4(?:[?#].*)?$/i.test(sourceUrl) ||
/^\/oss\/.+\.mp4(?:[?#].*)?$/i.test(sourceUrl)
)
}
const getRewardVapSourceUrl = (reward = {}) => {
@ -227,7 +236,10 @@ export function useDailyRechargeRewardVap(options = {}) {
const retryDelay = Math.min(500 + retryCount * 500, 2000)
const retryTimer = window.setTimeout(() => {
rewardVapRetryTimers.delete(sourceUrl)
if (getCurrentMainRewardVapSourceUrl() !== sourceUrl || failedRewardVapUrls.value.has(sourceUrl)) {
if (
getCurrentMainRewardVapSourceUrl() !== sourceUrl ||
failedRewardVapUrls.value.has(sourceUrl)
) {
return
}

View File

@ -312,7 +312,7 @@ export default defineConfig(({ mode }) => {
cors: true,
proxy: {
'/oss': {
target: 'https://tkm-likei.oss-ap-southeast-1.aliyuncs.com',
target: 'https://cdn.azizichat.com',
changeOrigin: true,
secure: true,
rewrite: (path) => path.replace(/^\/oss/, ''),