feat: add SproutWorkCollect apps

This commit is contained in:
2026-03-13 17:14:37 +08:00
parent 189baa3d59
commit 46afd3149f
54 changed files with 28126 additions and 4 deletions

View File

@@ -0,0 +1,38 @@
const DEFAULT_PROD_API_ORIGIN = 'https://work.api.shumengya.top';
const stripTrailingSlashes = (value) => value.replace(/\/+$/, '');
const stripApiSuffix = (value) => value.replace(/\/api\/?$/, '');
const hasHttpProtocol = (value) => /^https?:\/\//i.test(value);
export const getApiBaseUrl = () => {
const envUrl = process.env.REACT_APP_API_URL;
if (envUrl) {
const normalized = stripTrailingSlashes(envUrl);
// 避免生产环境错误使用相对路径(例如 /api导致请求打到前端自身域名
if (normalized.startsWith('/')) {
if (process.env.NODE_ENV === 'production') {
// eslint-disable-next-line no-console
console.warn(
`[SproutWorkCollect] REACT_APP_API_URL=${normalized} 是相对路径,已忽略并回退到默认后端:${DEFAULT_PROD_API_ORIGIN}/api`,
);
return `${DEFAULT_PROD_API_ORIGIN}/api`;
}
return normalized.endsWith('/api') ? normalized : `${normalized}/api`;
}
const absolute = hasHttpProtocol(normalized) ? normalized : `https://${normalized}`;
return absolute.endsWith('/api') ? absolute : `${absolute}/api`;
}
if (process.env.NODE_ENV === 'production') {
return `${DEFAULT_PROD_API_ORIGIN}/api`;
}
return 'http://localhost:5000/api';
};
export const getApiOrigin = () => stripApiSuffix(getApiBaseUrl());

View File

@@ -0,0 +1,59 @@
// 网站背景图配置(前端可配,不需要改代码)。
// - 手机端用 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;
}