feat: 开发环境提示目前没有isDev判断()

This commit is contained in:
NanGua-QWQ
2026-02-12 17:57:22 +08:00
parent 5984b203c3
commit db292f479c
2 changed files with 48 additions and 19 deletions
+40 -15
View File
@@ -139,22 +139,32 @@ function MainContent(): React.JSX.Element {
/>
</div>
</Dialog>
{/* 开发中画面水印 */}
<p
style={{
<div style={{
position: 'fixed',
display: 'flex',
bottom: '2px',
left: '20px',
opacity: 0.6,
color: '#de2611',
fontWeight: 'bold',
fontSize: '13px',
pointerEvents: 'none', // 防止水印干扰页面交互
zIndex: 9999 // 确保水印在最顶层显示
}}
>
({getArchitecture()})
opacity: 0.6,
zIndex: 9999
}}>
<p style={{
color: '#de2611',
fontWeight: 'bold',
fontSize: '13px',
pointerEvents: 'none',
}}>
,
</p>
<p style={{
color: '#44474b',
fontWeight: 'bold',
fontSize: '13px',
paddingLeft: '5px',
}}>
SecScore Dev ({getPlatform()}-{getArchitecture()})
</p>
</div>
</Layout>
)
}
@@ -166,16 +176,31 @@ function getArchitecture(): string {
if (userAgent.includes('arm64') || userAgent.includes('aarch64')) {
return 'ARM64';
} else if (userAgent.includes('x86_64') || userAgent.includes('amd64')) {
return 'x86_64';
} else if (userAgent.includes('x64') || userAgent.includes('amd64')) {
return 'x64';
} else if (userAgent.includes('i386') || userAgent.includes('i686')) {
return 'x86';
}
// 默认返回未知架构
return 'Unknown';
return userAgent;
}
function getPlatform(): string {
// 尝试从 userAgent 中获取平台信息
const userAgent = navigator.userAgent.toLowerCase();
if (userAgent.includes('windows')) {
return 'Windows';
} else if (userAgent.includes('mac')) {
return 'Mac';
} else if (userAgent.includes('linux')) {
return 'Linux';
}
return 'Unknown';
}
function App(): React.JSX.Element {
return (
<ThemeProvider>
@@ -1,5 +1,6 @@
import React, { useState, useEffect } from 'react'
import { Dialog, Input, Button, Space, Tag, MessagePlugin } from 'tdesign-react'
import { useTheme } from '../contexts/ThemeContext' // 导入主题上下文
interface Tag {
id: number
@@ -25,6 +26,9 @@ export const TagEditorDialog: React.FC<TagEditorDialogProps> = ({
const [allTags, setAllTags] = useState<Tag[]>([])
const [selectedTagIds, setSelectedTagIds] = useState<Set<number>>(new Set(initialTagIds))
const [loading, setLoading] = useState(false)
const { currentTheme } = useTheme() // 获取当前主题
const themeMode = currentTheme?.mode || 'light'; // 默认为 light
useEffect(() => {
if (visible) {
@@ -54,8 +58,8 @@ export const TagEditorDialog: React.FC<TagEditorDialogProps> = ({
const trimmed = inputValue.trim()
if (!trimmed) return
if (trimmed.length > 50) {
MessagePlugin.error('标签名称不能超过 50 个字符')
if (trimmed.length > 30) {
MessagePlugin.error('标签名称不能超过 30 个字符')
return
}
@@ -175,7 +179,7 @@ export const TagEditorDialog: React.FC<TagEditorDialogProps> = ({
<Tag
key={tag.id}
theme="primary"
variant="light"
variant={themeMode === 'dark' ? 'outline' : 'light'} // 根据主题模式动态设置变体
closable
onClose={() => handleToggleTag(tag.id)}
style={{ cursor: 'pointer' }}
@@ -202,7 +206,7 @@ export const TagEditorDialog: React.FC<TagEditorDialogProps> = ({
<Tag
key={tag.id}
theme="default"
variant="outline"
variant={themeMode === 'dark' ? 'light' : 'outline'} // 根据主题模式动态设置变体
closable
onClose={() => handleDeleteTag(tag.id)}
style={{ cursor: 'pointer' }}