dtable-ui-component 6.0.115-acc.4 → 6.0.115-acc.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -62,6 +62,8 @@ function ImagePreviewerLightbox(props) {
62
62
  const imageItem = imageSrcList[currentImageIndex];
63
63
  const URL = imageItem ? imageItem.thumbnail : '';
64
64
  const imageName = imageItem ? imageItem.name : '';
65
+
66
+ // Effect 1:只当 imageIndex 改变时同步
65
67
  _react.default.useEffect(() => {
66
68
  if (!imagesLength) {
67
69
  setCurrentImageIndex(0);
@@ -70,6 +72,13 @@ function ImagePreviewerLightbox(props) {
70
72
  const nextIndex = Number.isInteger(imageIndex) ? imageIndex : 0;
71
73
  setCurrentImageIndex(Math.min(Math.max(nextIndex, 0), imagesLength - 1));
72
74
  }, [imageIndex, imagesLength]);
75
+
76
+ // Effect 2:当列表改变时,确保索引不超界
77
+ _react.default.useEffect(() => {
78
+ if (currentImageIndex >= imagesLength && imagesLength > 0) {
79
+ setCurrentImageIndex(imagesLength - 1);
80
+ }
81
+ }, [imagesLength, imageSrcList]);
73
82
  const canRotateImage = onRotateImage && !readOnly && !['gif', 'heic', 'heif'].includes((0, _url.getFileSuffix)(URL)) && (0, _url.isInternalImg)(URL, server);
74
83
  let mainSrc = URL;
75
84
  if ((0, _url.needUseThumbnailImage)(URL)) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dtable-ui-component",
3
- "version": "6.0.115-acc.4",
3
+ "version": "6.0.115-acc.5",
4
4
  "main": "./lib/index.js",
5
5
  "dependencies": {
6
6
  "@seafile/react-image-lightbox": "^5.0.7",