Files
SmyWorkCollect/SproutWorkCollect-Frontend/src/config/background.js

60 lines
2.6 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
// 网站背景图配置(前端可配,不需要改代码)。
// - 手机端用 mobileImages电脑端用 desktopImages按视口宽度 768px 区分)
// - blur.enabled 控制是否启用高斯模糊遮罩
// - blur.amount 是模糊强度,建议 4px10px
// - blur.overlayOpacity 是白色蒙层透明度0~1建议 0.20.5
const mobileImages = [
'https://image.smyhub.com/file/手机壁纸/女生/1772108123232_VJ86r.jpg',
'https://image.smyhub.com/file/手机壁纸/女生/1772108022800_f945774e0a45f7a4afdc3da2b112025f.png',
'https://image.smyhub.com/file/手机壁纸/女生/1772108024006_3f9030ba77e355869115bc90fe019d53.png',
'https://image.smyhub.com/file/手机壁纸/女生/1772108030393_159bbf61f88b38475ee9144a2e8e4956.png',
'https://image.smyhub.com/file/手机壁纸/女生/1772108021977_8020902a0c8788538eee1cd06e784c6a.png',
'https://image.smyhub.com/file/手机壁纸/女生/1772108021881_44374ab6c1daa54e0204bca48ac382f2.png',
];
const desktopImages = [
'https://image.smyhub.com/file/电脑壁纸/女生/cuSpSkq4.webp',
'https://image.smyhub.com/file/电脑壁纸/女生/5CrdoShv.webp',
'https://image.smyhub.com/file/电脑壁纸/女生/xTsVkCli.webp',
'https://image.smyhub.com/file/电脑壁纸/女生/ItOJOHST.webp',
'https://image.smyhub.com/file/电脑壁纸/女生/cUDkKiOf.webp',
'https://image.smyhub.com/file/电脑壁纸/女生/c2HxMuGK.webp',
'https://image.smyhub.com/file/电脑壁纸/女生/L0nQHehz.webp',
'https://image.smyhub.com/file/电脑壁纸/女生/hj64Cqxn.webp',
];
// 内容区块搜索框、分类块、内容卡片、顶栏和底栏的半透明背景透明度0=全透明 1=不透明,可自行修改
window.SITE_GLASS_OPACITY = 0.3;
export const getGlassOpacity = () => {
if (typeof window !== 'undefined' && typeof window.SITE_GLASS_OPACITY === 'number') {
return window.SITE_GLASS_OPACITY;
}
return 0.3;
};
export const BACKGROUND_CONFIG = {
mobileImages,
desktopImages,
blur: {
enabled: true,
amount: '6px',
overlayOpacity: 0.35,
},
};
export const pickBackgroundImage = (isMobile) => {
const list = isMobile ? BACKGROUND_CONFIG.mobileImages : BACKGROUND_CONFIG.desktopImages;
if (!Array.isArray(list) || list.length === 0) return null;
const index = Math.floor(Math.random() * list.length);
return list[index];
};
// 同时挂到 window 上,方便在控制台调试或以后用纯 script 标签引入时访问。
if (typeof window !== 'undefined') {
window.SITE_MOBILE_BACKGROUND_IMAGES = mobileImages;
window.SITE_DESKTOP_BACKGROUND_IMAGES = desktopImages;
window.SITE_BACKGROUND_BLUR = BACKGROUND_CONFIG.blur;
}