Browse Source

feat (1.70.2 -> 1.70.3): 重构系统模式选项为领域模型并修复国际化标签

- 新增 systemModel.ts 领域模型,定义系统模式选项接口和常量
- 将 SYSTEM_MODE_OPTIONS 从 SystemMode.tsx 移动到 domain/systemModel.ts
- 修复国际化文件中系统模式 R 和 S 的标签和描述互换问题
- 在 DeviceArea.tsx 中使用系统模式对象替代硬编码的模拟器判断逻辑
- 在 SystemMode.tsx 中导入 SYSTEM_MODE_OPTIONS 并添加调试日志

改动文件:
- src/domain/systemModel.ts
- src/assets/i18n/messages/en.js
- src/assets/i18n/messages/zh.js
- src/pages/exam/DeviceArea.tsx
- src/pages/system/SettingsModal/sections/SystemHome/SystemMode.tsx
szy 23 hours ago
parent
commit
b22b2847f3

+ 19 - 0
CHANGELOG.md

@@ -2,6 +2,24 @@
 
 
 本项目的所有重要变更都将记录在此文件中.
 本项目的所有重要变更都将记录在此文件中.
 
 
+## [1.70.3] - 2026-01-20 13:45
+
+feat (1.70.2 -> 1.70.3): 重构系统模式选项为领域模型并修复国际化标签
+
+- 新增 systemModel.ts 领域模型,定义系统模式选项接口和常量
+- 将 SYSTEM_MODE_OPTIONS 从 SystemMode.tsx 移动到 domain/systemModel.ts
+- 修复国际化文件中系统模式 R 和 S 的标签和描述互换问题
+- 在 DeviceArea.tsx 中使用系统模式对象替代硬编码的模拟器判断逻辑
+- 在 SystemMode.tsx 中导入 SYSTEM_MODE_OPTIONS 并添加调试日志
+
+改动文件:
+
+- src/domain/systemModel.ts
+- src/assets/i18n/messages/en.js
+- src/assets/i18n/messages/zh.js
+- src/pages/exam/DeviceArea.tsx
+- src/pages/system/SettingsModal/sections/SystemHome/SystemMode.tsx
+
 ## [1.70.2] - 2026-01-20 10:36
 ## [1.70.2] - 2026-01-20 10:36
 
 
 fix (bug-211): 修复历史清单编辑后列表不更新的问题
 fix (bug-211): 修复历史清单编辑后列表不更新的问题
@@ -13,6 +31,7 @@ fix (bug-211): 修复历史清单编辑后列表不更新的问题
 - 修复 payload 访问路径(使用 result.code 和 result.data)
 - 修复 payload 访问路径(使用 result.code 和 result.data)
 
 
 改动文件:
 改动文件:
+
 - src/states/patient/worklist/slices/history.ts
 - src/states/patient/worklist/slices/history.ts
 
 
 ## [1.70.1] - 2026-01-20 09:49
 ## [1.70.1] - 2026-01-20 09:49

+ 1 - 1
package.json

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

+ 4 - 4
src/assets/i18n/messages/en.js

@@ -395,8 +395,8 @@ export default {
   "exam.exitFeedback.complete": "Complete",
   "exam.exitFeedback.complete": "Complete",
   "exam.exitFeedback.cancel": "Cancel",
   "exam.exitFeedback.cancel": "Cancel",
   'systemMode.title': 'System Mode',
   'systemMode.title': 'System Mode',
-  'systemMode.R': 'Demo Mode',
-  'systemMode.S': 'Live Mode (Generator Controlled)',
+  'systemMode.S': 'Demo Mode',
+  'systemMode.R': 'Live Mode (Generator Controlled)',
   'systemMode.R-S': 'Live Mode (Generator Uncontrolled)',
   'systemMode.R-S': 'Live Mode (Generator Uncontrolled)',
   'systemMode.hint': 'Changing system mode requires saving configuration and restarting the software to take effect',
   'systemMode.hint': 'Changing system mode requires saving configuration and restarting the software to take effect',
   'systemMode.save': 'Save',
   'systemMode.save': 'Save',
@@ -404,8 +404,8 @@ export default {
   'systemMode.selectRequired': 'Please select a system mode',
   'systemMode.selectRequired': 'Please select a system mode',
   'systemMode.saveSuccess': 'System mode saved successfully, restart software to take effect',
   'systemMode.saveSuccess': 'System mode saved successfully, restart software to take effect',
   'systemMode.saveFailed': 'Failed to save system mode',
   'systemMode.saveFailed': 'Failed to save system mode',
-  'systemMode.R.desc': 'Both generator and FPD are virtual',
-  'systemMode.S.desc': 'Both generator and FPD are real hardware',
+  'systemMode.S.desc': 'Both generator and FPD are virtual',
+  'systemMode.R.desc': 'Both generator and FPD are real hardware',
   'systemMode.R-S.desc': 'FPD is real hardware, generator is virtual',
   'systemMode.R-S.desc': 'FPD is real hardware, generator is virtual',
   'scanner.indicator.tooltip.ready': 'Scanner is ready, you can scan QR code',
   'scanner.indicator.tooltip.ready': 'Scanner is ready, you can scan QR code',
   'scanner.indicator.tooltip.notReady': 'Scanner unavailable, click to activate',
   'scanner.indicator.tooltip.notReady': 'Scanner unavailable, click to activate',

+ 4 - 4
src/assets/i18n/messages/zh.js

@@ -395,8 +395,8 @@ export default {
   "exam.exitFeedback.complete": "完成",
   "exam.exitFeedback.complete": "完成",
   "exam.exitFeedback.cancel": "取消",
   "exam.exitFeedback.cancel": "取消",
   "systemMode.title": "系统模式",
   "systemMode.title": "系统模式",
-  "systemMode.R": "演示模式",
-  "systemMode.S": "真机模式(发生器受控)",
+  "systemMode.S": "演示模式",
+  "systemMode.R": "真机模式(发生器受控)",
   "systemMode.R-S": "真机模式(发生器不受控)",
   "systemMode.R-S": "真机模式(发生器不受控)",
   "systemMode.hint": "切换系统模式,需保存配置并重启软件才能生效",
   "systemMode.hint": "切换系统模式,需保存配置并重启软件才能生效",
   "systemMode.save": "保存",
   "systemMode.save": "保存",
@@ -404,8 +404,8 @@ export default {
   "systemMode.selectRequired": "请选择系统模式",
   "systemMode.selectRequired": "请选择系统模式",
   "systemMode.saveSuccess": "系统模式保存成功,重启软件后生效",
   "systemMode.saveSuccess": "系统模式保存成功,重启软件后生效",
   "systemMode.saveFailed": "保存系统模式失败",
   "systemMode.saveFailed": "保存系统模式失败",
-  "systemMode.R.desc": "发生器、FPD均为虚拟",
-  "systemMode.S.desc": "发生器、FPD均为真实硬件",
+  "systemMode.S.desc": "发生器、FPD均为虚拟",
+  "systemMode.R.desc": "发生器、FPD均为真实硬件",
   "systemMode.R-S.desc": "FPD真实、发生器虚拟",
   "systemMode.R-S.desc": "FPD真实、发生器虚拟",
   "scanner.indicator.tooltip.ready": "扫码枪已就绪,可以扫描二维码",
   "scanner.indicator.tooltip.ready": "扫码枪已就绪,可以扫描二维码",
   "scanner.indicator.tooltip.notReady": "扫码枪不可用,点击此处激活",
   "scanner.indicator.tooltip.notReady": "扫码枪不可用,点击此处激活",

+ 39 - 0
src/domain/systemModel.ts

@@ -0,0 +1,39 @@
+export interface SystemModeOption {
+  label: string;
+  value: string;
+  SimulatorGEN: number;
+  SimulatorFPD: number;
+  desc: string;
+  fpd: string;
+  gen: string;
+}
+
+export const SYSTEM_MODE_OPTIONS: SystemModeOption[] = [
+  {
+    label: '演示模式',
+    value: 'S',
+    SimulatorGEN: 1,
+    SimulatorFPD: 1,
+    desc: '发生器、FPD均为虚拟',
+    fpd: 'Simulator',
+    gen: 'Simulator',
+  },
+  {
+    label: '真机模式(发生器受控)',
+    value: 'R',
+    SimulatorGEN: 0,
+    SimulatorFPD: 0,
+    desc: '发生器、FPD均为真实硬件',
+    fpd: 'Physics',
+    gen: 'Physics',
+  },
+  {
+    label: '真机模式(发生器不受控)',
+    value: 'R-S',
+    SimulatorGEN: 1,
+    SimulatorFPD: 0,
+    desc: '发生器真实、FPD虚拟',
+    fpd: 'Physics',
+    gen: 'Simulator',
+  },
+];

+ 15 - 12
src/pages/exam/DeviceArea.tsx

@@ -11,7 +11,7 @@ import {
   GeneratorStatus,
   GeneratorStatus,
 } from '@/states/exam/deviceAreaSlice';
 } from '@/states/exam/deviceAreaSlice';
 import triggerInspection from '../../API/exam/triggerInspection';
 import triggerInspection from '../../API/exam/triggerInspection';
-
+import { SYSTEM_MODE_OPTIONS } from '@/domain/systemModel';
 const DeviceArea = ({ className }: { className?: string }) => {
 const DeviceArea = ({ className }: { className?: string }) => {
   const generatorStatus = useSelector(
   const generatorStatus = useSelector(
     (state: RootState) => state.deviceArea.generatorStatus
     (state: RootState) => state.deviceArea.generatorStatus
@@ -32,7 +32,10 @@ const DeviceArea = ({ className }: { className?: string }) => {
 
 
   // 读取 FPD 状态,判断是否为模拟器模式
   // 读取 FPD 状态,判断是否为模拟器模式
   const fpd = useSelector((state: RootState) => state.product.fpd);
   const fpd = useSelector((state: RootState) => state.product.fpd);
-  const isSimulator = fpd === 'Simulator';
+  const gen = useSelector((state: RootState) => state.product.gen);
+  const systemMode = SYSTEM_MODE_OPTIONS.find(
+    (option) => option.gen === gen && option.fpd === fpd
+  );
 
 
   const btnStyle = { width: '1.5rem', height: '1.5rem' };
   const btnStyle = { width: '1.5rem', height: '1.5rem' };
   const classValue = 'mr-1';
   const classValue = 'mr-1';
@@ -44,23 +47,22 @@ const DeviceArea = ({ className }: { className?: string }) => {
         className={classValue}
         className={classValue}
         icon={
         icon={
           <ToolOutlined
           <ToolOutlined
-            className={
-              generatorReady ? 'text-green-500' : 'text-yellow-500'
-            }
+            className={generatorReady ? 'text-green-500' : 'text-yellow-500'}
           />
           />
         }
         }
         title={`手闸状态指示器: ${generatorStatus}`}
         title={`手闸状态指示器: ${generatorStatus}`}
       />
       />
-      <Badge count={isSimulator ? 'S' : 'R'} offset={[-15, 10]} color="orange">
+      <Badge count={systemMode?.value} offset={[-15, 10]} color="orange">
         <Button
         <Button
           style={btnStyle}
           style={btnStyle}
           data-testid="device-all-ready"
           data-testid="device-all-ready"
-          className={`${classValue} ${exposureStatus === 'ready'
+          className={`${classValue} ${
+            exposureStatus === 'ready'
               ? 'text-green-500'
               ? 'text-green-500'
               : exposureStatus === 'not_ready'
               : exposureStatus === 'not_ready'
                 ? ''
                 ? ''
                 : ''
                 : ''
-            }`}
+          }`}
           icon={
           icon={
             <CameraOutlined
             <CameraOutlined
             // className={
             // className={
@@ -73,7 +75,7 @@ const DeviceArea = ({ className }: { className?: string }) => {
             />
             />
           }
           }
           onClick={() => {
           onClick={() => {
-            if (!isSimulator) {
+            if (systemMode?.value === 'R') {
               // 真实环境下禁止点击
               // 真实环境下禁止点击
               console.warn('真实环境下,曝光操作需要通过硬件触发');
               console.warn('真实环境下,曝光操作需要通过硬件触发');
               return;
               return;
@@ -81,19 +83,20 @@ const DeviceArea = ({ className }: { className?: string }) => {
             // 模拟环境下允许点击
             // 模拟环境下允许点击
             triggerInspection();
             triggerInspection();
           }}
           }}
-          title={`曝光指示器: ${exposureStatus}${isSimulator ? ' (模拟模式)' : ' (真实模式)'}`}
+          title={`曝光指示器: ${exposureStatus}${systemMode?.desc}`}
         />
         />
       </Badge>
       </Badge>
       <Button
       <Button
         style={btnStyle}
         style={btnStyle}
-        className={`${classValue} ${tabletStatus === 'exposing'
+        className={`${classValue} ${
+          tabletStatus === 'exposing'
             ? 'text-yellow-500'
             ? 'text-yellow-500'
             : tabletStatus === 'ready'
             : tabletStatus === 'ready'
               ? 'text-green-500'
               ? 'text-green-500'
               : tabletStatus === 'error'
               : tabletStatus === 'error'
                 ? 'text-red-500'
                 ? 'text-red-500'
                 : ''
                 : ''
-          }`}
+        }`}
         icon={
         icon={
           <TabletOutlined
           <TabletOutlined
           // className={
           // className={

+ 4 - 34
src/pages/system/SettingsModal/sections/SystemHome/SystemMode.tsx

@@ -8,38 +8,7 @@ import { Button, message, Spin } from 'antd';
 import { useIntl } from 'react-intl';
 import { useIntl } from 'react-intl';
 import { getConfig, modifyConfig } from '@/API/system/options';
 import { getConfig, modifyConfig } from '@/API/system/options';
 import { theme } from 'antd';
 import { theme } from 'antd';
-
-interface SystemModeOption {
-  label: string;
-  value: string;
-  SimulatorGEN: number;
-  SimulatorFPD: number;
-  desc: string;
-}
-
-const SYSTEM_MODE_OPTIONS: SystemModeOption[] = [
-  {
-    label: '演示模式',
-    value: 'S',
-    SimulatorGEN: 1,
-    SimulatorFPD: 1,
-    desc: '发生器、FPD均为虚拟',
-  },
-  {
-    label: '真机模式(发生器受控)',
-    value: 'R',
-    SimulatorGEN: 0,
-    SimulatorFPD: 0,
-    desc: '发生器、FPD均为真实硬件',
-  },
-  {
-    label: '真机模式(发生器不受控)',
-    value: 'R-S',
-    SimulatorGEN: 1,
-    SimulatorFPD: 0,
-    desc: 'FPD真实、发生器虚拟',
-  },
-];
+import { SYSTEM_MODE_OPTIONS } from '@/domain/systemModel';
 
 
 export const SystemMode: React.FC = () => {
 export const SystemMode: React.FC = () => {
   const { Text } = Typography;
   const { Text } = Typography;
@@ -116,11 +85,12 @@ export const SystemMode: React.FC = () => {
 
 
   const radioOptions = SYSTEM_MODE_OPTIONS.map((option) => ({
   const radioOptions = SYSTEM_MODE_OPTIONS.map((option) => ({
     ...option,
     ...option,
-    label: intl.formatMessage({ id: `systemMode.${option.value}` }),
-    desc: intl.formatMessage({ id: `systemMode.${option.value}.desc` }),
+    // label: intl.formatMessage({ id: `systemMode.${option.value}` }),
+    // desc: intl.formatMessage({ id: `systemMode.${option.value}.desc` }),
   }));
   }));
 
 
   const handleModeSelect = (modeValue: string) => {
   const handleModeSelect = (modeValue: string) => {
+    console.log('modeValue', modeValue);
     setSelectedMode(modeValue);
     setSelectedMode(modeValue);
   };
   };