diff --git a/src/app-hooks/useSafeNavigate/index.js b/src/app-hooks/useSafeNavigate/index.js index c221f1be4..08fffda07 100644 --- a/src/app-hooks/useSafeNavigate/index.js +++ b/src/app-hooks/useSafeNavigate/index.js @@ -15,7 +15,7 @@ const safeShowDenied = () => { }) } -export default function useSafeNavigate() { +export default function useSafeNavigate () { const navigate = useNavigate() const lastDeniedRef = useRef(null) diff --git a/src/components/KeepAlive/index.jsx b/src/components/KeepAlive/index.jsx index 780de1c2f..8f59b9426 100644 --- a/src/components/KeepAlive/index.jsx +++ b/src/components/KeepAlive/index.jsx @@ -88,8 +88,9 @@ const createKeepAliveManager = () => { // set global options: { deactivateDelay, keepInactiveCount, limit } setOptions: (opts = {}) => { if (typeof opts.deactivateDelay === 'number') deactivateDelay = opts.deactivateDelay - if (typeof opts.keepInactiveCount === 'number') + if (typeof opts.keepInactiveCount === 'number') { keepInactiveCount = Math.max(0, Math.floor(opts.keepInactiveCount)) + } if (typeof opts.limit === 'number') limit = Math.max(0, Math.floor(opts.limit)) }, register: (id, opts) => { @@ -193,7 +194,7 @@ const createKeepAliveManager = () => { instances.delete(id) activeMap.delete(id) keys = keys.filter((k) => k !== id) - }, + } } } @@ -302,7 +303,7 @@ const KeepAlive = ({ id, active = false, children, persistOnUnmount = false, cac if (!active) return scrollPos.current.set(e.target, { left: e.target.scrollLeft, - top: e.target.scrollTop, + top: e.target.scrollTop }) } @@ -350,7 +351,7 @@ const KeepAlive = ({ id, active = false, children, persistOnUnmount = false, cac if (container.parentNode !== placeholder) { // 在移动DOM之前,发送自定义事件通知子组件 const event = new CustomEvent('keepalive-dom-move', { - detail: { from: container.parentNode, to: placeholder }, + detail: { from: container.parentNode, to: placeholder } }) container.dispatchEvent(event) @@ -420,7 +421,7 @@ KeepAlive.propTypes = { active: PropTypes.bool, children: PropTypes.node, persistOnUnmount: PropTypes.bool, - cacheLimit: PropTypes.number, + cacheLimit: PropTypes.number } export default KeepAlive diff --git a/src/components/stateless/NotificationDrawer/index.jsx b/src/components/stateless/NotificationDrawer/index.jsx index bbb58b16b..f4d9ccc04 100644 --- a/src/components/stateless/NotificationDrawer/index.jsx +++ b/src/components/stateless/NotificationDrawer/index.jsx @@ -11,17 +11,17 @@ const initialNotifications = [ title: '新功能上线', description: '全站菜单查询功能全新上线,支持快速定位与跳转!', read: false, - time: '5分钟前', + time: '5分钟前' }, { id: 3, title: '新功能上线', description: 'ResponsiveTable高复用表格上线,欢迎试用!', read: false, - time: '10分钟前', + time: '10分钟前' }, { id: 4, title: '新功能上线', description: '权限系统与主题切换已支持。', read: false, time: '15分钟前' }, - { id: 5, title: '文档更新', description: 'README.md 已优化,欢迎查阅。', read: true, time: '1天前' }, + { id: 5, title: '文档更新', description: 'README.md 已优化,欢迎查阅。', read: true, time: '1天前' } ] const NotificationDropdown = ({ iconColor, variant = 'inline', buttonStyle, ghost = false }) => { @@ -58,7 +58,7 @@ const NotificationDropdown = ({ iconColor, variant = 'inline', buttonStyle, ghos } const { - token: { colorBgContainer, colorBorder, colorText, colorTextSecondary, colorTextTertiary }, + token: { colorBgContainer, colorBorder, colorText, colorTextSecondary, colorTextTertiary } } = theme.useToken() // content structure: header (optional) / list (scrollable) / footer (fixed) @@ -69,45 +69,47 @@ const NotificationDropdown = ({ iconColor, variant = 'inline', buttonStyle, ghos backgroundColor: colorBgContainer, color: colorText, display: 'flex', - flexDirection: 'column', + flexDirection: 'column' }} >
- {notifications.length === 0 ? ( -
暂无通知
- ) : ( - notifications.slice(0, MAX_ITEMS).map((item) => ( - - )) - )} + {notifications.length === 0 + ? ( +
暂无通知
+ ) + : ( + notifications.slice(0, MAX_ITEMS).map((item) => ( + + )) + )}
- - - @@ -136,56 +138,58 @@ const NotificationDropdown = ({ iconColor, variant = 'inline', buttonStyle, ghos const openDrawer = () => setPopVisible(true) const iconNode = ( - + ) const triggerNode = - variant === 'button' ? ( - - ) : ( - - ) + variant === 'button' + ? ( + + ) + : ( + + ) return ( <> {triggerNode} setPopVisible(false)} open={popVisible} size={360} @@ -201,7 +205,7 @@ NotificationDropdown.propTypes = { iconColor: PropTypes.string, variant: PropTypes.oneOf(['inline', 'button']), buttonStyle: PropTypes.object, - ghost: PropTypes.bool, + ghost: PropTypes.bool } export default NotificationDropdown diff --git a/src/components/stateless/PointerMove/index.jsx b/src/components/stateless/PointerMove/index.jsx index 3f4651d57..5c8b72f61 100644 --- a/src/components/stateless/PointerMove/index.jsx +++ b/src/components/stateless/PointerMove/index.jsx @@ -46,7 +46,7 @@ const PointerMove = () => { className={styles.star} animate={{ x: coordinates?.x ?? 0, y: coordinates?.y ?? 0, opacity: 1 }} transition={{ - type: 'spring', + type: 'spring' }} /> ) diff --git a/src/pages/chatgpt/index.jsx b/src/pages/chatgpt/index.jsx index 282ac8c2a..beab214e6 100644 --- a/src/pages/chatgpt/index.jsx +++ b/src/pages/chatgpt/index.jsx @@ -19,7 +19,7 @@ import { Switch, Tag, Spin, - theme, + theme } from 'antd' import { DownloadOutlined, @@ -35,7 +35,7 @@ import { CodeOutlined, TableOutlined, PartitionOutlined, - NodeIndexOutlined, + NodeIndexOutlined } from '@ant-design/icons' import { copyTextToClipboard } from '@utils/aidFn' import initSSE from './fixSse' @@ -120,14 +120,14 @@ const runMermaidBlocks = async ({ blocks, setCharts, setProgress, signal }) => { let idx = 0 let finished = 0 - function onSettled() { + function onSettled () { active -= 1 finished += 1 if (!signal.aborted) setProgress({ total, finished }) pump() } - function pump() { + function pump () { if (signal.aborted) return while (!signal.aborted && active < concurrency && idx < total) { const i = idx @@ -155,7 +155,7 @@ const hexToRgb = (hex) => { return { r: clamp(Number(rgbMatch[1]), 0, 255), g: clamp(Number(rgbMatch[2]), 0, 255), - b: clamp(Number(rgbMatch[3]), 0, 255), + b: clamp(Number(rgbMatch[3]), 0, 255) } } @@ -165,9 +165,9 @@ const hexToRgb = (hex) => { const full = h.length === 3 ? h - .split('') - .map((c) => c + c) - .join('') + .split('') + .map((c) => c + c) + .join('') : h const n = Number.parseInt(full, 16) if (Number.isNaN(n)) return null @@ -218,7 +218,7 @@ const CustomComponents = { borderCollapse: 'collapse', border: '1px solid #d9d9d9', borderRadius: '6px', - overflow: 'hidden', + overflow: 'hidden' }} > {children} @@ -231,7 +231,7 @@ const CustomComponents = { {...props} style={{ backgroundColor: '#fafafa', - borderBottom: '2px solid #d9d9d9', + borderBottom: '2px solid #d9d9d9' }} > {children} @@ -247,7 +247,7 @@ const CustomComponents = { fontWeight: 600, color: '#262626', borderRight: '1px solid #d9d9d9', - whiteSpace: 'normal', + whiteSpace: 'normal' }} > {children} @@ -263,12 +263,12 @@ const CustomComponents = { borderRight: '1px solid #f0f0f0', verticalAlign: 'top', whiteSpace: 'normal', - wordBreak: 'break-word', + wordBreak: 'break-word' }} > {children} - ), + ) } const syncMermaidThemeFromToken = async (token, mode) => { @@ -287,14 +287,14 @@ const syncMermaidThemeFromToken = async (token, mode) => { lineColor: token.colorPrimary, secondaryColor: isDark ? '#141414' : token.colorBgLayout, tertiaryColor: isDark ? '#0f0f0f' : token.colorFillQuaternary || token.colorBgLayout, - fontFamily: token.fontFamily, + fontFamily: token.fontFamily }, flowchart: { useMaxWidth: true, htmlLabels: true, - curve: 'basis', + curve: 'basis' }, - securityLevel: 'loose', + securityLevel: 'loose' }) } catch (e) { console.warn('Mermaid 初始化失败:', e) @@ -460,7 +460,7 @@ const PROJECT_TEMPLATES = { 3. 包含至少 6 个代码块示例 4. 包含至少 5 个数学公式 5. 内容详实,符合大型企业级项目标准 -6. 所有图表都要有实际意义,不是占位符`, +6. 所有图表都要有实际意义,不是占位符` }, fintech: { title: '金融风控平台', @@ -569,7 +569,7 @@ const PROJECT_TEMPLATES = { 3. 包含至少 8 个代码块示例 4. 包含至少 6 个数学公式 5. 符合金融行业标准和监管要求 -6. 所有图表都要有实际业务意义`, +6. 所有图表都要有实际业务意义` }, smartCity: { title: '智慧城市运营中心', @@ -691,8 +691,8 @@ const PROJECT_TEMPLATES = { 3. 包含至少 10 个代码块示例 4. 包含至少 6 个数学公式 5. 符合智慧城市建设标准和规范 -6. 所有图表都要有实际应用场景`, - }, +6. 所有图表都要有实际应用场景` + } } // 修复后的 MermaidRenderer - 只在文档完成时渲染一次 @@ -775,7 +775,7 @@ const MermaidChartViewer = ({ svg, title, themeMode }) => { startX: e.clientX, startY: e.clientY, baseX: translate.x, - baseY: translate.y, + baseY: translate.y } try { e.currentTarget.setPointerCapture(e.pointerId) @@ -815,7 +815,7 @@ const MermaidChartViewer = ({ svg, title, themeMode }) => { const dataUrl = await toPng(wrapRef.current, { cacheBust: true, backgroundColor: isDarkMode ? '#1e1e1e' : token.colorBgContainer, - pixelRatio: Math.min(3, Math.max(2, window.devicePixelRatio || 2)), + pixelRatio: Math.min(3, Math.max(2, window.devicePixelRatio || 2)) }) const link = document.createElement('a') link.download = `${title || 'mermaid'}.png` @@ -837,34 +837,34 @@ const MermaidChartViewer = ({ svg, title, themeMode }) => { '--mm-text': isDarkMode ? 'rgba(255, 255, 255, 0.88)' : token.colorText, '--mm-text2': isDarkMode ? 'rgba(255, 255, 255, 0.65)' : token.colorTextSecondary, '--mm-shadow': isDarkMode ? 'none' : token.boxShadowSecondary, - '--mm-primary': token.colorPrimary, + '--mm-primary': token.colorPrimary }} >
{title}
- - - - - - - - - -
@@ -880,7 +880,7 @@ const MermaidChartViewer = ({ svg, title, themeMode }) => {
@@ -893,7 +893,7 @@ const MermaidChartViewer = ({ svg, title, themeMode }) => { MermaidChartViewer.propTypes = { svg: PropTypes.string, title: PropTypes.string, - themeMode: PropTypes.string, + themeMode: PropTypes.string } // NOSONAR @@ -944,48 +944,52 @@ const MermaidRenderer = ({ content, readyState, themeMode }) => { '--mm-bg': isDarkMode ? '#141414' : token.colorBgContainer, '--mm-bg2': isDarkMode ? '#0f0f0f' : token.colorBgLayout, '--mm-shadow': isDarkMode ? 'none' : token.boxShadowSecondary, - '--mm-primary': token.colorPrimary, + '--mm-primary': token.colorPrimary }} > - {total > 0 ? ( -
- - 正在渲染 {total} 个图表,已完成 {finished}/{total} - - {finished < total && } -
- ) : ( -
- - 未检测到 Mermaid 代码块 - -
- )} + {total > 0 + ? ( +
+ + 正在渲染 {total} 个图表,已完成 {finished}/{total} + + {finished < total && } +
+ ) + : ( +
+ + 未检测到 Mermaid 代码块 + +
+ )} {charts.map((c) => { if (c?.pending) return null return (
- {c.svg ? ( - - ) : ( -
- - 查看错误与原始代码 -
- {c.error} -
-
{c.code}
- + {c.svg + ? ( + + ) + : ( +
+ + 查看错误与原始代码 +
+ {c.error} +
+
{c.code}
+ } - /> -
- )} + /> +
+ )}
) })} @@ -996,7 +1000,7 @@ const MermaidRenderer = ({ content, readyState, themeMode }) => { MermaidRenderer.propTypes = { content: PropTypes.string, readyState: PropTypes.number, - themeMode: PropTypes.string, + themeMode: PropTypes.string } const ChatGpt = () => { @@ -1148,7 +1152,7 @@ const ChatGpt = () => { const handleTemplateChange = (templateKey) => { setSelectedTemplate(templateKey) form.setFieldsValue({ - text: PROJECT_TEMPLATES[templateKey].prompt, + text: PROJECT_TEMPLATES[templateKey].prompt }) } @@ -1167,7 +1171,7 @@ const ChatGpt = () => { if (e.data !== '[DONE]') { const payload = JSON.parse(e.data) const { - delta: { content }, + delta: { content } } = payload?.choices[0] || { delta: { content: '' } } if (content) { apiResultRef.current += content @@ -1291,7 +1295,7 @@ PRD文档内容: if (e.data !== '[DONE]') { const payload = JSON.parse(e.data) const { - delta: { content }, + delta: { content } } = payload?.choices[0] || { delta: { content: '' } } if (content) { structureResultRef.current += content @@ -1376,25 +1380,25 @@ PRD文档内容: >
-