diff --git a/client/src/sections/wuyuanbiaoba/components/CameraView.jsx b/client/src/sections/wuyuanbiaoba/components/CameraView.jsx
index 5c90ad1..d76fef7 100644
--- a/client/src/sections/wuyuanbiaoba/components/CameraView.jsx
+++ b/client/src/sections/wuyuanbiaoba/components/CameraView.jsx
@@ -167,7 +167,7 @@ const CameraView = ({
setStartPos({ x: mouseX, y: mouseY });
setDrawing(true);
setCurrentDrawingRect(null);
- }else{
+ } else {
message.warning("已达到标靶数量上限(5个)!");
}
}
@@ -285,15 +285,14 @@ const CameraView = ({
const videoRect = screenToVideoCoordinates(x, y, w, h);
if (videoRect && rectangles.length < maxRectangles) {
- // 只取时间戳后4位作为id和key
- const ts = Date.now().toString();
- const shortId = ts.slice(-4);
+ const nextIndex = Number(rectangles[rectangles.length - 1]?.id) ? Number(rectangles[rectangles.length - 1]?.id)-100+1 : 1;
+ const fixedId = `10${nextIndex}`;
+
// 根据选中的模板预设参数
const templateParams = selectedTemplate
? {
// 从模板中获取参数
- name:
- `target${rectangles.length + 1}` || selectedTemplate.name,
+ name: `target${nextIndex}` || selectedTemplate.name,
radius: selectedTemplate.physicalRadius || 40.0,
isReferencePoint: selectedTemplate.isBaseline || false,
gradientThreshold:
@@ -305,7 +304,7 @@ const CameraView = ({
}
: {
// 默认参数
- name: `target${rectangles.length + 1}`,
+ name: `target${nextIndex}`,
radius: 40.0,
isReferencePoint: false,
gradientThreshold: 100,
@@ -316,8 +315,8 @@ const CameraView = ({
};
const newRect = {
- id: shortId,
- key: shortId,
+ id: fixedId,
+ key: fixedId,
...videoRect,
...templateParams,
// 保存矩形区域信息用于服务端
diff --git a/client/src/sections/wuyuanbiaoba/components/TargetDetailModal.jsx b/client/src/sections/wuyuanbiaoba/components/TargetDetailModal.jsx
index 64b791f..7648fd3 100644
--- a/client/src/sections/wuyuanbiaoba/components/TargetDetailModal.jsx
+++ b/client/src/sections/wuyuanbiaoba/components/TargetDetailModal.jsx
@@ -138,6 +138,7 @@ const TargetDetailModal = ({
rules={[
{ required: true, message: "请输入标靶描述" },
{ max: 50, message: "标靶描述不能超过50个字符" },
+ { pattern: /^[^\u4e00-\u9fa5]+$/, message: "仅支持英文、数字及符号" },
]}
>
diff --git a/client/src/sections/wuyuanbiaoba/components/TargetList.jsx b/client/src/sections/wuyuanbiaoba/components/TargetList.jsx
index 8e87ad0..29f62c8 100644
--- a/client/src/sections/wuyuanbiaoba/components/TargetList.jsx
+++ b/client/src/sections/wuyuanbiaoba/components/TargetList.jsx
@@ -9,6 +9,7 @@ const TargetList = ({
onSelectTarget,
onClickClearAll,
}) => {
+
const targetColumns = [
{
title: "标靶操作",
diff --git a/client/src/sections/wuyuanbiaoba/components/TemplateModal.jsx b/client/src/sections/wuyuanbiaoba/components/TemplateModal.jsx
index 3e01b48..e9e4b5d 100644
--- a/client/src/sections/wuyuanbiaoba/components/TemplateModal.jsx
+++ b/client/src/sections/wuyuanbiaoba/components/TemplateModal.jsx
@@ -49,9 +49,8 @@ const TemplateModal = ({
name: templateData.name,
gaussianBlur: templateData.gaussianBlur || 1,
physicalRadius: templateData.physicalRadius || 40.0,
- gradientThresholdValue:
- templateData.gradientThresholdValue || 100,
- anchorThresholdValue: templateData.anchorThresholdValue || 80,
+ gradientThresholdValue: templateData.gradientThresholdValue,
+ anchorThresholdValue: templateData.anchorThresholdValue,
});
setIsBaseline(templateData.isBaseline || false);
setIsPerspectiveCorrection(
@@ -60,10 +59,8 @@ const TemplateModal = ({
setBinaryThreshold(templateData.binaryThreshold || 100);
setGaussianBlur(templateData.gaussianBlur || 1);
setPhysicalRadius(templateData.physicalRadius || 40.0);
- setGradientThresholdValue(
- templateData.gradientThresholdValue || 100
- );
- setAnchorThresholdValue(templateData.anchorThresholdValue || 80);
+ setGradientThresholdValue(templateData.gradientThresholdValue);
+ setAnchorThresholdValue(templateData.anchorThresholdValue);
// 设置图片数据
if (templateData.imageUrl) {
@@ -161,6 +158,7 @@ const TemplateModal = ({
const handleOk = async () => {
try {
+ debugger;
const values = await form.validateFields();
// 检查是否上传了图片
@@ -201,7 +199,7 @@ const TemplateModal = ({
const handleDelete = () => {
if (templateData) {
// 检查是否为第一个模板(内置模板)
- if (templateData.key === 'builtin_1') {
+ if (templateData.key === "builtin_1") {
message.warning("该模板为内置模板,不允许删除!");
return;
}
@@ -220,7 +218,7 @@ const TemplateModal = ({
onCancel={onCancel}
width={500}
footer={[
- mode === "edit" && templateData?.key !== 'builtin_1' && (
+ mode === "edit" && templateData?.key !== "builtin_1" && (
+ 标靶图片
+ *
+ >
+ }
rules={[{ required: true, message: "请上传标靶图片" }]}
>
{
const threshold = info.threshold || {};
return {
- key: info.id !== undefined ? info.id.toString() : targetKey,
- id: info.id !== undefined ? info.id.toString() : targetKey,
+ key: info.id,
+ id: info.id,
name: info.desc || `目标${targetKey}`,
radius: info.radius || 40.0,
isReferencePoint: info.base || false,
@@ -97,7 +97,7 @@ export const useTargetStorage = () => {
perspective: targetInfo.perspective || null,
handlerInfo: targetInfo.handler_info || null,
};
- });
+ }).sort((a, b) => Number(a.id) - Number(b.id)); // 按id数字升序排序;
setTargets(formattedTargets);
setError(null);
diff --git a/client/src/sections/wuyuanbiaoba/hooks/useTemplateStorage.js b/client/src/sections/wuyuanbiaoba/hooks/useTemplateStorage.js
index ce91473..25d36dc 100644
--- a/client/src/sections/wuyuanbiaoba/hooks/useTemplateStorage.js
+++ b/client/src/sections/wuyuanbiaoba/hooks/useTemplateStorage.js
@@ -43,7 +43,7 @@ const createBuiltinTemplate = async () => {
return {
key: 'builtin_1',
- name: 'template1',
+ name: '标靶模板1',
isBaseline: false,
isPerspectiveCorrection: false,
binaryThreshold: 100,
@@ -59,7 +59,7 @@ const createBuiltinTemplate = async () => {
// 如果图片加载失败,返回不带图片的内置模板
return {
key: 'builtin_1',
- name: '模板1',
+ name: '标靶模板1',
isBaseline: false,
isPerspectiveCorrection: false,
binaryThreshold: 100,