瀏覽代碼

fix(1.15.0->1.15.1): 修复标记功能未选中viewport时无法添加问题 (bug 120)

- 修复预定义标记、自定义标记和时间戳在未选中viewport时无法添加到图像的问题
- 实现智能viewport选择:有选中时仅添加到选中的viewport,无选中时自动添加到所有可见viewport
- 确保标记功能与测量工具保持一致的交互逻辑
- 添加 selectedViewportIds.length 检查条件
- 未选中时使用 getVisibleViewportCount() 获取可见viewport数量
- 遍历所有可见viewport并调用 addCustomMark() 函数

改动文件:
- src/pages/view/components/ViewerContainer.tsx
- CHANGELOG.md
- package.json
dengdx 3 周之前
父節點
當前提交
d024a02f2a
共有 5 個文件被更改,包括 174 次插入132 次删除
  1. 28 0
      CHANGELOG.md
  2. 2 2
      config/dev.ts
  3. 93 118
      package-lock.json
  4. 1 1
      package.json
  5. 50 11
      src/pages/view/components/ViewerContainer.tsx

+ 28 - 0
CHANGELOG.md

@@ -2,6 +2,34 @@
 
 本项目的所有重要变更都将记录在此文件中。
 
+## [1.15.1] - 2025-12-20 11:22
+
+### 修复 (Fixed)
+- **标记功能未选中viewport时无法添加问题** ([src/pages/view/components/ViewerContainer.tsx](src/pages/view/components/ViewerContainer.tsx))
+  - 修复预定义标记、自定义标记和时间戳在未选中viewport时无法添加到图像的问题
+  - 实现智能viewport选择:有选中时仅添加到选中的viewport,无选中时自动添加到所有可见viewport
+  - 确保标记功能与测量工具保持一致的交互逻辑
+  - 提升用户体验,无需手动选中图像即可添加标记
+
+**核心改进:**
+- 预定义标记处理优化:支持未选中viewport时自动添加到所有可见图像
+- 自定义标记处理优化:从下拉列表选择的标记现在能正确添加到图像
+- 时间戳处理优化:时间戳标记支持自动添加到所有可见图像
+- 交互一致性:与其他功能(如测量工具)保持相同的交互模式
+
+**技术实现:**
+- 添加 selectedViewportIds.length 检查条件
+- 未选中时使用 getVisibleViewportCount() 获取可见viewport数量
+- 遍历所有可见viewport并调用 addCustomMark() 函数
+- 使用 getViewportIdByUrl() 正确转换imageUrl到viewportId
+
+**改动文件:**
+- src/pages/view/components/ViewerContainer.tsx
+- CHANGELOG.md
+- package.json (版本更新: 1.15.0 -> 1.15.1)
+
+---
+
 ## [1.15.0] - 2025-12-19 18:50
 
 ### 新增 (Added)

+ 2 - 2
config/dev.ts

@@ -21,14 +21,14 @@ export default {
     devServer: {
       proxy: {
         '/dr': {
-          target: 'http://192.168.110.13:6001', // 你的后端服务地址
+          target: 'http://192.168.110.245:6001', // 你的后端服务地址
           changeOrigin: true, // 允许跨域
           // pathRewrite: {
           //   '^/dr/api': '' // 可选,用于重写路径
           // }
         },
         '/mqtt': {
-          target: 'ws://192.168.110.13:8083', // MQTT WebSocket 服务地址
+          target: 'ws://192.168.110.245:8083', // MQTT WebSocket 服务地址
           changeOrigin: true,
           ws: true, // 启用 WebSocket 代理
           // pathRewrite: {

File diff suppressed because it is too large
+ 93 - 118
package-lock.json


+ 1 - 1
package.json

@@ -1,6 +1,6 @@
 {
   "name": "zsis",
-  "version": "1.15.0",
+  "version": "1.15.1",
   "private": true,
   "description": "医学成像系统",
   "main": "main.js",

+ 50 - 11
src/pages/view/components/ViewerContainer.tsx

@@ -343,9 +343,22 @@ const ViewerContainer: React.FC<ViewerContainerProps> = ({ imageUrls }) => {
       if (action.startsWith('AddPredefinedMark:')) {
         const markText = action.substring('AddPredefinedMark:'.length);
         console.log(`添加预定义标记到图像: ${markText}`);
-        selectedViewportIds.forEach((viewportId) => {
-          addCustomMark(viewportId, markText);
-        });
+        
+        if (selectedViewportIds.length > 0) {
+          // 有选中的viewport,只对选中的添加
+          selectedViewportIds.forEach((viewportId) => {
+            addCustomMark(viewportId, markText);
+          });
+        } else {
+          // 没有选中,为所有可见的viewport添加
+          const visibleViewportCount = getVisibleViewportCount();
+          for (let i = 0; i < visibleViewportCount; i++) {
+            const viewportId = getViewportIdByUrl(imageUrls[i]);
+            if (viewportId) {
+              addCustomMark(viewportId, markText);
+            }
+          }
+        }
         dispatch(clearAction());
         return;
       }
@@ -404,17 +417,30 @@ const ViewerContainer: React.FC<ViewerContainerProps> = ({ imageUrls }) => {
             addMark(viewportId);
           });
           break;
-        case 'AddCustomMark':
+        case 'AddCustomMark': {
           // 从markPanel状态获取选中的标记文本(用于自定义标记)
           const selectedMarkText = store.getState().markPanel.selectedMark;
           console.log(`添加自定义标记到图像: ${selectedMarkText}`);
           if (selectedMarkText) {
-            selectedViewportIds.forEach((viewportId) => {
-              addCustomMark(viewportId, selectedMarkText);
-            });
+            if (selectedViewportIds.length > 0) {
+              // 有选中的viewport,只对选中的添加
+              selectedViewportIds.forEach((viewportId) => {
+                addCustomMark(viewportId, selectedMarkText);
+              });
+            } else {
+              // 没有选中,为所有可见的viewport添加
+              const visibleViewportCount = getVisibleViewportCount();
+              for (let i = 0; i < visibleViewportCount; i++) {
+                const viewportId = getViewportIdByUrl(imageUrls[i]);
+                if (viewportId) {
+                  addCustomMark(viewportId, selectedMarkText);
+                }
+              }
+            }
           }
           break;
-        case 'AddTimestamp':
+        }
+        case 'AddTimestamp': {
           const now = new Date();
           const timestamp = now.getFullYear() + '-' +
             String(now.getMonth() + 1).padStart(2, '0') + '-' +
@@ -423,10 +449,23 @@ const ViewerContainer: React.FC<ViewerContainerProps> = ({ imageUrls }) => {
             String(now.getMinutes()).padStart(2, '0') + ':' +
             String(now.getSeconds()).padStart(2, '0');
 
-          selectedViewportIds.forEach((viewportId) => {
-            addCustomMark(viewportId, timestamp);
-          });
+          if (selectedViewportIds.length > 0) {
+            // 有选中的viewport,只对选中的添加
+            selectedViewportIds.forEach((viewportId) => {
+              addCustomMark(viewportId, timestamp);
+            });
+          } else {
+            // 没有选中,为所有可见的viewport添加
+            const visibleViewportCount = getVisibleViewportCount();
+            for (let i = 0; i < visibleViewportCount; i++) {
+              const viewportId = getViewportIdByUrl(imageUrls[i]);
+              if (viewportId) {
+                addCustomMark(viewportId, timestamp);
+              }
+            }
+          }
           break;
+        }
         case 'Delete Digital Mask':
           selectedViewportIds.forEach((viewportId) => {
             remoteMask(viewportId);

Some files were not shown because too many files changed in this diff