跳到主要内容
ArcBlock Community

Custom Components not loading

Twelve
支持
pages-kitbug

The custom components page is not loading on my crazyvisionscomics.com site.

When trying to load all the components come up empty and the add button is blank. My page ends up freezing and becoming unresponsive

4 条回复

Twelve16个月前

I’ve restarted and updated all my blocklets. Still having the issue.

xiaoliang16个月前
  1. 添加按钮默认是不可点击,需要选中一个组件后,才可以点击,将该组件添加到页面模板中

image.png

  1. 关于组件渲染都是空白的问题,我注意到您站点的中自定义组件很多?滚动条看上去已经滚动到了中间的位置,想和您确认几个问题:
  2. 最顶部的组件是否也全部渲染的是空白?
  3. Basic 中组件能正常预览吗?
  4. 需要检查是否存在特别复杂的组件,或者组件中存在死循环导致阻塞了其他组件的渲染
Twelve16个月前

I found the component. This component has been running for months with no issue. Why now?

javascriptCopy
import React from '@blocklet/pages-kit/builtin/react';
import { Box, Typography } from '@blocklet/pages-kit/builtin/mui/material';

export default function ScrollingBanner({
  title = '',
  bgColor = 'black',
  titleColor = 'white',
  speed = 60, // Speed multiplier
  image1,
  image2,
  image3,
  image4,
  image5,
  image6,
  image7,
  image8,
  image9,
  image10,
}) {
  // Collect valid image URLs
  const images = [
    image1?.url || '',
    image2?.url || '',
    image3?.url || '',
    image4?.url || '',
    image5?.url || '',
    image6?.url || '',
    image7?.url || '',
    image8?.url || '',
    image9?.url || '',
    image10?.url || '',
  ].filter((url) => url !== ''); // Filter out empty or undefined values

  // Double the images for seamless scrolling
  const doubledImages = [...images, ...images];

  // Constants for image size and gaps
  const imageWidth = 200; // Width of each image in pixels
  const gapWidth = 20; // Gap between images in pixels

  // Dynamically calculate scroll distance based on user-provided images
  const scrollDistance = images.length * (imageWidth + gapWidth); // Scroll full width of original images
  const totalContentWidth = doubledImages.length * (imageWidth + gapWidth); // Total content width

  // Ensure speed has a valid value (minimum 1)
  const adjustedSpeed = Math.max(speed, 1);
  const animationDuration = (scrollDistance / adjustedSpeed).toFixed(2); // Animation duration in seconds

  // Debugging logs
  console.log('Images Array:', images);
  console.log('Doubled Images Array:', doubledImages);
  console.log('Scroll Distance (User Images):', scrollDistance);
  console.log('Total Content Width:', totalContentWidth);
  console.log('Animation Duration (s):', animationDuration);

  return (
    <Box sx={{ backgroundColor: bgColor, padding: '20px', textAlign: 'center' }}>
      {title && (
        <Typography variant="h5" sx={{ color: titleColor, marginBottom: '10px' }}>
          {title}
        </Typography>
      )}
      <Box
        className="scroll-container"
        sx={{
          overflow: 'hidden',
          whiteSpace: 'nowrap',
          position: 'relative',
          display: 'flex',
          alignItems: 'center',
          width: '100%',
        }}
      >
        <Box
          className="scrolling-content"
          sx={{
            display: 'flex',
            gap: `${gapWidth}px`,
            animation: `scroll ${animationDuration}s linear infinite`,
          }}
        >
          {doubledImages.map((imageUrl, index) => (
            <Box
              key={`image-${index}`}
              component="img"
              src={imageUrl}
              alt={`Artist logo ${index + 1}`}
              sx={{
                width: `${imageWidth}px`,
                height: `${imageWidth}px`,
                display: 'inline-block',
              }}
            />
          ))}
        </Box>
      </Box>
    </Box>
  );
}

// Add keyframes for scrolling dynamically
const styles = document.createElement('style');
styles.innerHTML = `
@keyframes scroll {
  0% { transform: translateX(0); }
  100% { transform: translateX(calc(-100%)); } /* Scrolls full width of user-provided images */
}
`;
document.head.appendChild(styles);
Twelve16个月前

Is there a way to put up some bumpers or warning that a component is going to cause an issue? Finding and unlocking this component took me about an hour or so to do. And now one of my favorite components doesnt work? However it is working on another page that I run it on.

回复