From 85433ac0711f34e8de7c74a6e80bbdcec4618e5f Mon Sep 17 00:00:00 2001 From: Jerry Yan <792602257@qq.com> Date: Mon, 2 Feb 2026 18:59:32 +0800 Subject: [PATCH] =?UTF-8?q?feat(template):=20=E7=A7=BB=E9=99=A4=E6=A8=A1?= =?UTF-8?q?=E6=9D=BF=E7=B1=BB=E5=9E=8B=E5=92=8C=E7=89=88=E6=9C=AC=E5=AD=97?= =?UTF-8?q?=E6=AE=B5=E5=B9=B6=E6=B7=BB=E5=8A=A0=E7=AE=A1=E7=90=86=E5=91=98?= =?UTF-8?q?=E6=9D=83=E9=99=90=E6=8E=A7=E5=88=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 移除了模板详情页面中的类型和版本显示字段 - 移除了模板列表页面中的类型和版本列 - 添加了管理员权限检查功能,通过 localStorage 键控制 - 将编辑和删除操作按钮限制为仅管理员可见 - 将创建模板按钮限制为仅管理员可见 --- .../Template/TemplateDetail.tsx | 8 -- .../DataAnnotation/Template/TemplateList.tsx | 81 +++++++++---------- 2 files changed, 39 insertions(+), 50 deletions(-) diff --git a/frontend/src/pages/DataAnnotation/Template/TemplateDetail.tsx b/frontend/src/pages/DataAnnotation/Template/TemplateDetail.tsx index 9e030f1..0955a1c 100644 --- a/frontend/src/pages/DataAnnotation/Template/TemplateDetail.tsx +++ b/frontend/src/pages/DataAnnotation/Template/TemplateDetail.tsx @@ -43,14 +43,6 @@ const TemplateDetail: React.FC = ({ {template.style} - - - {template.builtIn ? "系统内置" : "自定义"} - - - - {template.version} - {new Date(template.createdAt).toLocaleString()} diff --git a/frontend/src/pages/DataAnnotation/Template/TemplateList.tsx b/frontend/src/pages/DataAnnotation/Template/TemplateList.tsx index 8f128e1..202ad1b 100644 --- a/frontend/src/pages/DataAnnotation/Template/TemplateList.tsx +++ b/frontend/src/pages/DataAnnotation/Template/TemplateList.tsx @@ -1,4 +1,4 @@ -import React, { useState } from "react"; +import React, { useState, useEffect } from "react"; import { Button, Table, @@ -32,7 +32,16 @@ import { TemplateTypeMap } from "@/pages/DataAnnotation/annotation.const.tsx"; +const TEMPLATE_ADMIN_KEY = "datamate_template_admin"; + const TemplateList: React.FC = () => { + const [isAdmin, setIsAdmin] = useState(false); + + useEffect(() => { + // 检查 localStorage 中是否存在特殊键 + const hasAdminKey = localStorage.getItem(TEMPLATE_ADMIN_KEY) !== null; + setIsAdmin(hasAdminKey); + }, []); const filterOptions = [ { key: "category", @@ -225,23 +234,7 @@ const TemplateList: React.FC = () => { {ClassificationMap[category as keyof typeof ClassificationMap]?.label || category} ), }, - { - title: "类型", - dataIndex: "builtIn", - key: "builtIn", - width: 100, - render: (builtIn: boolean) => ( - - {builtIn ? "系统内置" : "自定义"} - - ), - }, - { - title: "版本", - dataIndex: "version", - key: "version", - width: 80, - }, + { title: "创建时间", dataIndex: "createdAt", @@ -263,29 +256,31 @@ const TemplateList: React.FC = () => { onClick={() => handleView(record)} /> - <> - - - + {isAdmin && ( +
+ +
+ )}