diff --git a/web/package.json b/web/package.json index 7d00d8c4a..4d8c7e7f5 100644 --- a/web/package.json +++ b/web/package.json @@ -7,11 +7,10 @@ "@douyinfe/semi-icons": "^2.63.1", "@douyinfe/semi-ui": "^2.69.1", "@lobehub/icons": "^2.0.0", - "@monaco-editor/react": "^4.7.0", "@visactor/react-vchart": "~1.8.8", "@visactor/vchart": "~1.8.8", "@visactor/vchart-semi-theme": "~1.8.8", - "axios": "1.13.5", + "axios": "1.12.0", "clsx": "^2.1.1", "dayjs": "^1.11.11", "history": "^5.3.0", @@ -21,7 +20,6 @@ "lucide-react": "^0.511.0", "marked": "^4.1.1", "mermaid": "^11.6.0", - "monaco-editor": "^0.55.1", "qrcode.react": "^4.2.0", "react": "^18.2.0", "react-dom": "^18.2.0", diff --git a/web/src/components/table/channels/modals/ParamOverrideEditorModal.jsx b/web/src/components/table/channels/modals/ParamOverrideEditorModal.jsx index 42051d5bf..50dc4949a 100644 --- a/web/src/components/table/channels/modals/ParamOverrideEditorModal.jsx +++ b/web/src/components/table/channels/modals/ParamOverrideEditorModal.jsx @@ -17,8 +17,7 @@ along with this program. If not, see . For commercial licensing, please contact support@quantumnous.com */ -import React, { useCallback, useEffect, useMemo, useRef, useState } from 'react'; -import MonacoEditor from '@monaco-editor/react'; +import React, { useCallback, useEffect, useMemo, useState } from 'react'; import { useTranslation } from 'react-i18next'; import { Banner, @@ -36,7 +35,6 @@ import { } from '@douyinfe/semi-ui'; import { IconDelete, IconPlus } from '@douyinfe/semi-icons'; import { showError, verifyJSON } from '../../../../helpers'; -import JSONEditor from '../../../common/ui/JSONEditor'; const { Text } = Typography; @@ -206,214 +204,6 @@ const OPERATION_TEMPLATE = { ], }; -const MONACO_SCHEMA_URI = 'https://new-api.local/schemas/param-override.schema.json'; -const MONACO_MODEL_URI = 'inmemory://new-api/param-override.json'; - -const JSON_SCALAR_SCHEMA = { - oneOf: [ - { type: 'string' }, - { type: 'number' }, - { type: 'boolean' }, - { type: 'null' }, - { type: 'array' }, - { type: 'object' }, - ], -}; - -const PARAM_OVERRIDE_JSON_SCHEMA = { - $schema: 'http://json-schema.org/draft-07/schema#', - type: 'object', - properties: { - operations: { - type: 'array', - description: 'Operation pipeline for new param override format.', - items: { - type: 'object', - properties: { - mode: { - type: 'string', - enum: OPERATION_MODE_OPTIONS.map((item) => item.value), - }, - path: { type: 'string' }, - from: { type: 'string' }, - to: { type: 'string' }, - keep_origin: { type: 'boolean' }, - value: JSON_SCALAR_SCHEMA, - logic: { type: 'string', enum: ['AND', 'OR'] }, - conditions: { - oneOf: [ - { - type: 'array', - items: { - type: 'object', - properties: { - path: { type: 'string' }, - mode: { - type: 'string', - enum: CONDITION_MODE_OPTIONS.map((item) => item.value), - }, - value: JSON_SCALAR_SCHEMA, - invert: { type: 'boolean' }, - pass_missing_key: { type: 'boolean' }, - }, - required: ['path', 'mode'], - additionalProperties: false, - }, - }, - { - type: 'object', - additionalProperties: JSON_SCALAR_SCHEMA, - }, - ], - }, - }, - required: ['mode'], - additionalProperties: false, - allOf: [ - { - if: { properties: { mode: { const: 'set' } }, required: ['mode'] }, - then: { required: ['path'] }, - }, - { - if: { properties: { mode: { const: 'delete' } }, required: ['mode'] }, - then: { required: ['path'] }, - }, - { - if: { properties: { mode: { const: 'append' } }, required: ['mode'] }, - then: { required: ['path'] }, - }, - { - if: { properties: { mode: { const: 'prepend' } }, required: ['mode'] }, - then: { required: ['path'] }, - }, - { - if: { properties: { mode: { const: 'copy' } }, required: ['mode'] }, - then: { required: ['from', 'to'] }, - }, - { - if: { properties: { mode: { const: 'move' } }, required: ['mode'] }, - then: { required: ['from', 'to'] }, - }, - { - if: { properties: { mode: { const: 'replace' } }, required: ['mode'] }, - then: { required: ['path', 'from'] }, - }, - { - if: { - properties: { mode: { const: 'regex_replace' } }, - required: ['mode'], - }, - then: { required: ['path', 'from'] }, - }, - { - if: { - properties: { mode: { const: 'trim_prefix' } }, - required: ['mode'], - }, - then: { required: ['path', 'value'] }, - }, - { - if: { - properties: { mode: { const: 'trim_suffix' } }, - required: ['mode'], - }, - then: { required: ['path', 'value'] }, - }, - { - if: { - properties: { mode: { const: 'ensure_prefix' } }, - required: ['mode'], - }, - then: { required: ['path', 'value'] }, - }, - { - if: { - properties: { mode: { const: 'ensure_suffix' } }, - required: ['mode'], - }, - then: { required: ['path', 'value'] }, - }, - { - if: { - properties: { mode: { const: 'trim_space' } }, - required: ['mode'], - }, - then: { required: ['path'] }, - }, - { - if: { - properties: { mode: { const: 'to_lower' } }, - required: ['mode'], - }, - then: { required: ['path'] }, - }, - { - if: { - properties: { mode: { const: 'to_upper' } }, - required: ['mode'], - }, - then: { required: ['path'] }, - }, - { - if: { - properties: { mode: { const: 'return_error' } }, - required: ['mode'], - }, - then: { required: ['value'] }, - }, - { - if: { - properties: { mode: { const: 'prune_objects' } }, - required: ['mode'], - }, - then: { required: ['value'] }, - }, - { - if: { - properties: { mode: { const: 'sync_fields' } }, - required: ['mode'], - }, - then: { required: ['from', 'to'] }, - }, - { - if: { - properties: { mode: { const: 'set_header' } }, - required: ['mode'], - }, - then: { required: ['path', 'value'] }, - }, - { - if: { - properties: { mode: { const: 'delete_header' } }, - required: ['mode'], - }, - then: { required: ['path'] }, - }, - { - if: { - properties: { mode: { const: 'copy_header' } }, - required: ['mode'], - }, - then: { - anyOf: [{ required: ['path'] }, { required: ['from', 'to'] }], - }, - }, - { - if: { - properties: { mode: { const: 'move_header' } }, - required: ['mode'], - }, - then: { - anyOf: [{ required: ['path'] }, { required: ['from', 'to'] }], - }, - }, - ], - }, - }, - }, - additionalProperties: true, -}; - let localIdSeed = 0; const nextLocalId = () => `param_override_${Date.now()}_${localIdSeed++}`; @@ -649,24 +439,6 @@ const ParamOverrideEditorModal = ({ visible, value, onSave, onCancel }) => { const [operations, setOperations] = useState([createDefaultOperation()]); const [jsonText, setJsonText] = useState(''); const [jsonError, setJsonError] = useState(''); - const monacoConfiguredRef = useRef(false); - - const configureMonaco = useCallback((monaco) => { - if (monacoConfiguredRef.current) return; - monaco.languages.json.jsonDefaults.setDiagnosticsOptions({ - validate: true, - allowComments: false, - enableSchemaRequest: false, - schemas: [ - { - uri: MONACO_SCHEMA_URI, - fileMatch: [MONACO_MODEL_URI, '*param-override*.json'], - schema: PARAM_OVERRIDE_JSON_SCHEMA, - }, - ], - }); - monacoConfiguredRef.current = true; - }, []); useEffect(() => { if (!visible) return; @@ -1040,17 +812,19 @@ const ParamOverrideEditorModal = ({ visible, value, onSave, onCancel }) => { {visualMode === 'legacy' ? ( - +
+ {t('旧格式(直接覆盖):')} + setLegacyValue(nextValue)} + showClear + /> + + {t('这里直接编辑 JSON 对象,无需额外点开编辑器。')} + +
) : (
@@ -1519,32 +1293,17 @@ const ParamOverrideEditorModal = ({ visible, value, onSave, onCancel }) => {
- {t('JSON 智能提示')} + {t('普通编辑')} -
- handleJsonChange(nextValue ?? '')} - height='460px' - options={{ - minimap: { enabled: false }, - fontSize: 13, - lineNumbers: 'on', - automaticLayout: true, - scrollBeyondLastLine: false, - tabSize: 2, - insertSpaces: true, - wordWrap: 'on', - formatOnPaste: true, - formatOnType: true, - }} - /> -
+ handleJsonChange(nextValue ?? '')} + placeholder={JSON.stringify(OPERATION_TEMPLATE, null, 2)} + showClear + /> - {t('支持 mode/conditions 字段补全与 JSON Schema 校验')} + {t('直接编辑 JSON 文本,保存时会校验格式。')} {jsonError ? ( {jsonError}