|
@@ -2,7 +2,9 @@ import React, { useEffect, useRef } from 'react';
|
|
|
import * as cornerstone from '@cornerstonejs/core';
|
|
|
import * as cornerstoneTools from '@cornerstonejs/tools';
|
|
|
import * as cornerstoneDICOMImageLoader from '@cornerstonejs/dicom-image-loader';
|
|
|
-import createImageIdsAndCacheMetaData from '../../createImageIdsAndCacheMetaData';
|
|
|
+// import createImageIdsAndCacheMetaData from '../../createImageIdsAndCacheMetaData';
|
|
|
+import store from '@/states/store';
|
|
|
+import { SystemMode } from '@/states/systemModeSlice';
|
|
|
|
|
|
const StackViewer = ({ imageIndex }) => {
|
|
|
const elementRef = useRef<HTMLDivElement>(null);
|
|
@@ -13,15 +15,46 @@ const StackViewer = ({ imageIndex }) => {
|
|
|
cornerstone.init();
|
|
|
cornerstoneTools.init();
|
|
|
// 注册加载器
|
|
|
- cornerstoneDICOMImageLoader.init();
|
|
|
- // Get Cornerstone imageIds and fetch metadata into RAM
|
|
|
- const imageIds = await createImageIdsAndCacheMetaData({
|
|
|
- StudyInstanceUID:
|
|
|
- '1.3.6.1.4.1.14519.5.2.1.7009.2403.334240657131972136850343327463',
|
|
|
- SeriesInstanceUID:
|
|
|
- '1.3.6.1.4.1.14519.5.2.1.7009.2403.226151125820845824875394858561',
|
|
|
- wadoRsRoot: 'https://d14fa38qiwhyfd.cloudfront.net/dicomweb',
|
|
|
+ // cornerstoneDICOMImageLoader.init();
|
|
|
+ const state = store.getState();
|
|
|
+ console.log(`当前系统模式:${state.systemMode.mode}`);
|
|
|
+
|
|
|
+ const token =
|
|
|
+ state.systemMode.mode === SystemMode.Emergency
|
|
|
+ ? state.product.guest
|
|
|
+ : state.userInfo.token;
|
|
|
+ console.log(`token stack.image.viewer: ${token}`);
|
|
|
+ // const { productName, language, source } = state.product;
|
|
|
+
|
|
|
+ cornerstoneDICOMImageLoader.init({
|
|
|
+ maxWebWorkers: navigator.hardwareConcurrency || 1,
|
|
|
+ errorInterceptor: (error) => {
|
|
|
+ if (error.status === 401) {
|
|
|
+ console.error('Authentication failed. Please refresh the token.');
|
|
|
+ // Optionally, trigger token refresh
|
|
|
+ }
|
|
|
+ console.error(`请求dcm文件出错:${error}`);
|
|
|
+ },
|
|
|
+ //startWebWorkersOnDemand: true,
|
|
|
+
|
|
|
+ beforeSend: (xhr, imageId, defaultHeaders) => {
|
|
|
+ return {
|
|
|
+ ...defaultHeaders,
|
|
|
+ Authorization: `Bearer ${token}`,
|
|
|
+ Language: 'en',
|
|
|
+ Product: 'DROS',
|
|
|
+ Source: 'Electron',
|
|
|
+ };
|
|
|
+ },
|
|
|
});
|
|
|
+ // // Get Cornerstone imageIds and fetch metadata into RAM
|
|
|
+ // const imageIds = await createImageIdsAndCacheMetaData({
|
|
|
+ // StudyInstanceUID:
|
|
|
+ // '1.3.6.1.4.1.14519.5.2.1.7009.2403.334240657131972136850343327463',
|
|
|
+ // SeriesInstanceUID:
|
|
|
+ // '1.3.6.1.4.1.14519.5.2.1.7009.2403.226151125820845824875394858561',
|
|
|
+ // wadoRsRoot: 'https://d14fa38qiwhyfd.cloudfront.net/dicomweb',
|
|
|
+ // });
|
|
|
// Instantiate a rendering engine
|
|
|
const renderingEngineId = 'myRenderingEngine';
|
|
|
const renderingEngine = new cornerstone.RenderingEngine(
|
|
@@ -43,11 +76,26 @@ const StackViewer = ({ imageIndex }) => {
|
|
|
viewportId
|
|
|
) as cornerstone.Types.IStackViewport;
|
|
|
// 给定一个dcm文件路径,加载并显示出来
|
|
|
- // const imageId1='dicomweb:https://ohif-assets-new.s3.us-east-1.amazonaws.com/ACRIN-Regular/CT+CT+IMAGES/CT000000.dcm';
|
|
|
- // const imageId2='dicomweb:https://ohif-assets-new.s3.us-east-1.amazonaws.com/ACRIN-Regular/CT+CT+IMAGES/CT000005.dcm';
|
|
|
- // const imageId3='dicomweb:https://ohif-dicom-json-example.s3.amazonaws.com/LIDC-IDRI-0001/01-01-2000-30178/3000566.000000-03192/1-001.dcm';
|
|
|
- // viewport.setStack([imageId1,imageId2,imageId3], 2);
|
|
|
- viewport.setStack(imageIds, imageIndex);
|
|
|
+ const imageId1 =
|
|
|
+ 'dicomweb:https://ohif-assets-new.s3.us-east-1.amazonaws.com/ACRIN-Regular/CT+CT+IMAGES/CT000000.dcm';
|
|
|
+ const imageId2 =
|
|
|
+ 'dicomweb:https://ohif-assets-new.s3.us-east-1.amazonaws.com/ACRIN-Regular/CT+CT+IMAGES/CT000005.dcm';
|
|
|
+ const imageId3 =
|
|
|
+ 'dicomweb:https://ohif-dicom-json-example.s3.amazonaws.com/LIDC-IDRI-0001/01-01-2000-30178/3000566.000000-03192/1-001.dcm';
|
|
|
+ const imageId4 =
|
|
|
+ 'dicomweb:http://192.168.11.12:6001/dr/api/v1/auth/image/dcm/DemoImage.dcm';
|
|
|
+ const imageId5 =
|
|
|
+ 'dicomweb:http://localhost:10086/dr/api/v1/pub/dcm/DemoImage.dcm';
|
|
|
+ const imageId6 =
|
|
|
+ 'dicomweb:http://localhost:10086/dr/api/v1/auth/image/dcm/DemoImage.dcm';
|
|
|
+ const imageId7 =
|
|
|
+ 'dicomweb:http://localhost:10086/dr/api/v1/pub/dcm/DemoImage.dcm';
|
|
|
+ imageIndex = 5;
|
|
|
+ viewport.setStack(
|
|
|
+ [imageId1, imageId2, imageId3, imageId4, imageId5, imageId6, imageId7],
|
|
|
+ imageIndex
|
|
|
+ );
|
|
|
+ // viewport.setStack(imageIds, imageIndex);
|
|
|
|
|
|
viewport.render();
|
|
|
};
|