refactor: increase css editor height, fix EditMcpJsonPopup (#7535)

* refactor: increase css editor height

* fix: lint warnings

* refactor: use vh for height

* fix: editmcpjsonpopup editor unavailable after deleting all the code
This commit is contained in:
one 2025-06-27 21:53:43 +08:00 committed by GitHub
parent 98b12fb800
commit c7c1cf2552
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 26 additions and 22 deletions

View File

@ -546,7 +546,7 @@ const DataSettings: FC = () => {
}
handleDataMigration()
}, [])
}, [t])
const onSkipBackupFilesChange = (value: boolean) => {
setSkipBackupFile(value)

View File

@ -315,9 +315,9 @@ const DisplaySettings: FC = () => {
language="css"
placeholder={t('settings.display.custom.css.placeholder')}
onChange={(value) => dispatch(setCustomCss(value))}
height="350px"
height="60vh"
options={{
collapsible: true,
collapsible: false,
wrappable: true,
autocompletion: true,
lineNumbers: true,

View File

@ -3,7 +3,7 @@ import { TopView } from '@renderer/components/TopView'
import { useAppDispatch, useAppSelector } from '@renderer/store'
import { setMCPServers } from '@renderer/store/mcp'
import { MCPServer } from '@renderer/types'
import { Modal, Typography } from 'antd'
import { Modal, Spin, Typography } from 'antd'
import { useEffect, useState } from 'react'
import { useTranslation } from 'react-i18next'
@ -16,12 +16,14 @@ const PopupContainer: React.FC<Props> = ({ resolve }) => {
const [jsonConfig, setJsonConfig] = useState('')
const [jsonSaving, setJsonSaving] = useState(false)
const [jsonError, setJsonError] = useState('')
const [isLoading, setIsLoading] = useState(true)
const mcpServers = useAppSelector((state) => state.mcp.servers)
const dispatch = useAppDispatch()
const { t } = useTranslation()
useEffect(() => {
setIsLoading(true)
try {
const mcpServersObj: Record<string, any> = {}
@ -40,6 +42,8 @@ const PopupContainer: React.FC<Props> = ({ resolve }) => {
} catch (error) {
console.error('Failed to format JSON:', error)
setJsonError(t('settings.mcp.jsonFormatError'))
} finally {
setIsLoading(false)
}
}, [mcpServers, t])
@ -118,24 +122,24 @@ const PopupContainer: React.FC<Props> = ({ resolve }) => {
{jsonError ? <span style={{ color: 'red' }}>{jsonError}</span> : ''}
</Typography.Text>
</div>
{jsonConfig && (
<div style={{ marginBottom: '16px' }}>
<CodeEditor
value={jsonConfig}
language="json"
onChange={(value) => setJsonConfig(value)}
maxHeight="60vh"
options={{
lint: true,
collapsible: true,
wrappable: true,
lineNumbers: true,
foldGutter: true,
highlightActiveLine: true,
keymap: true
}}
/>
</div>
{isLoading ? (
<Spin size="large" />
) : (
<CodeEditor
value={jsonConfig}
language="json"
onChange={(value) => setJsonConfig(value)}
height="60vh"
options={{
lint: true,
collapsible: false,
wrappable: true,
lineNumbers: true,
foldGutter: true,
highlightActiveLine: true,
keymap: true
}}
/>
)}
<Typography.Text type="secondary">{t('settings.mcp.jsonModeHint')}</Typography.Text>
</Modal>