|
@@ -7,8 +7,27 @@ import {Carousel} from "antd";
|
|
|
|
|
|
|
|
function ProductionSoft({products}: {products: ProductCategory[]}) {
|
|
function ProductionSoft({products}: {products: ProductCategory[]}) {
|
|
|
const BASE_URL = process.env.NEXT_PUBLIC_BASE_URL || ''
|
|
const BASE_URL = process.env.NEXT_PUBLIC_BASE_URL || ''
|
|
|
|
|
+ const REMOTE_BASE_URL = process.env.NEXT_PUBLIC_REMOTE_BASE_URL || 'http://47.107.107.47:8040'
|
|
|
const [isMobile, setIsMobile] = useState(false);
|
|
const [isMobile, setIsMobile] = useState(false);
|
|
|
|
|
|
|
|
|
|
+ const getProductImageUrl = (url?: string) => {
|
|
|
|
|
+ let coverImageUrl = url || '';
|
|
|
|
|
+ if (coverImageUrl) {
|
|
|
|
|
+ if (coverImageUrl.startsWith('http')) {
|
|
|
|
|
+ if (coverImageUrl.includes('localhost')) {
|
|
|
|
|
+ try {
|
|
|
|
|
+ const urlObj = new URL(coverImageUrl);
|
|
|
|
|
+ coverImageUrl = `${REMOTE_BASE_URL}${urlObj.pathname}${urlObj.search}`;
|
|
|
|
|
+ } catch (e) {}
|
|
|
|
|
+ }
|
|
|
|
|
+ } else {
|
|
|
|
|
+ coverImageUrl = `${REMOTE_BASE_URL.replace(/\/$/, '')}/${coverImageUrl.replace(/^\//, '')}`;
|
|
|
|
|
+ }
|
|
|
|
|
+ return coverImageUrl;
|
|
|
|
|
+ }
|
|
|
|
|
+ return "/assets/productions/2.png"
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
useEffect(() => {
|
|
useEffect(() => {
|
|
|
const checkMobile = () => setIsMobile(window.innerWidth < 640);
|
|
const checkMobile = () => setIsMobile(window.innerWidth < 640);
|
|
|
checkMobile();
|
|
checkMobile();
|
|
@@ -52,7 +71,7 @@ function ProductionSoft({products}: {products: ProductCategory[]}) {
|
|
|
>
|
|
>
|
|
|
<div className="w-full bg-gray-50 overflow-hidden">
|
|
<div className="w-full bg-gray-50 overflow-hidden">
|
|
|
<Image
|
|
<Image
|
|
|
- src={product.productUrl ? BASE_URL + product.productUrl : "/assets/productions/2.png"}
|
|
|
|
|
|
|
+ src={getProductImageUrl(product.productUrl)}
|
|
|
alt={product.productName}
|
|
alt={product.productName}
|
|
|
width={1000}
|
|
width={1000}
|
|
|
height={1000}
|
|
height={1000}
|