|
|
@@ -9,7 +9,26 @@ interface ProductMenuProps {
|
|
|
|
|
|
export default function CoreProducts({products}: ProductMenuProps) {
|
|
|
|
|
|
- const BASE_URL = process.env.NEXT_PUBLIC_BASE_URL as string
|
|
|
+ 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 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"
|
|
|
+ }
|
|
|
|
|
|
const filteredProducts = useMemo(() => {
|
|
|
return (products ?? []).filter((item) => item.productCategoryName !== "软件产品")
|
|
|
@@ -99,7 +118,7 @@ export default function CoreProducts({products}: ProductMenuProps) {
|
|
|
</p>
|
|
|
<div className="mt-3 sm:mt-5 w-full overflow-hidden rounded-lg bg-gray-50">
|
|
|
<Image
|
|
|
- src={product.productUrl ? BASE_URL + product.productUrl : "/assets/productions/2.png"}
|
|
|
+ src={getProductImageUrl(product.productUrl)}
|
|
|
alt={product.productName}
|
|
|
width={1000}
|
|
|
height={1000}
|