Commit ffd248a3 authored by 张烨's avatar 张烨

fix: 保存配置和添加ace编辑器

parent 5ebb8e4d
...@@ -7,6 +7,8 @@ stats.json ...@@ -7,6 +7,8 @@ stats.json
# Cruft # Cruft
.DS_Store .DS_Store
npm-debug.log npm-debug.log
yarn.lock
package-lock.json
.idea .idea
src/umi src/umi
src/.umi src/.umi
......
...@@ -87,6 +87,7 @@ ...@@ -87,6 +87,7 @@
"@babel/polyfill": "7.4.3", "@babel/polyfill": "7.4.3",
"@babel/preset-typescript": "^7.12.1", "@babel/preset-typescript": "^7.12.1",
"@babel/runtime": "^7.10.5", "@babel/runtime": "^7.10.5",
"ace-builds": "^1.4.12",
"antd-img-crop": "^3.13.2", "antd-img-crop": "^3.13.2",
"bizcharts": "^4.0.15", "bizcharts": "^4.0.15",
"chalk": "2.4.2", "chalk": "2.4.2",
...@@ -107,6 +108,7 @@ ...@@ -107,6 +108,7 @@
"minimist": "1.2.0", "minimist": "1.2.0",
"prop-types": "15.7.2", "prop-types": "15.7.2",
"react": "16.8.6", "react": "16.8.6",
"react-ace": "^9.2.0",
"react-dom": "16.8.6", "react-dom": "16.8.6",
"react-helmet": "6.0.0-beta", "react-helmet": "6.0.0-beta",
"react-intl": "2.8.0", "react-intl": "2.8.0",
......
import { getConfigContent, saveConfigContent } from '@/services/webConfig/api'; import { getConfigContent, saveConfigContent } from '@/services/webConfig/api';
import { Button, Input, Modal, notification } from 'antd'; import { Button, Modal, notification } from 'antd';
import React, { Children, useState } from 'react'; import React, { Children, useState } from 'react';
import AceEditor from 'react-ace';
import styles from './webMenu.less';
import 'ace-builds/src-noconflict/mode-json';
import 'ace-builds/src-noconflict/theme-solarized_light';
const ConfigWrapper = props => { const ConfigWrapper = props => {
const { value, children, onChange, ...rest } = props; const { value, children, onChange, ...rest } = props;
...@@ -40,13 +44,14 @@ const ConfigWrapper = props => { ...@@ -40,13 +44,14 @@ const ConfigWrapper = props => {
err = true; err = true;
} }
if (!err) { if (!err) {
saveConfigContent(JSON.stringify(JSON.parse(text), null, 4)) saveConfigContent(value, JSON.stringify(JSON.parse(text), null, 4))
.then(res => { .then(res => {
if (res.success) { if (res.success) {
notification.success({ notification.success({
message: '保存成功', message: '保存成功',
duration: 3, duration: 3,
}); });
setVisible(false);
} }
}) })
.catch(error => { .catch(error => {
...@@ -74,13 +79,31 @@ const ConfigWrapper = props => { ...@@ -74,13 +79,31 @@ const ConfigWrapper = props => {
title="编辑配置" title="编辑配置"
visible={visible} visible={visible}
onOk={handleOk} onOk={handleOk}
width={650}
className={styles.modal}
maskClosable={false} maskClosable={false}
onCancel={() => setVisible(false)} onCancel={() => setVisible(false)}
> >
<Input.TextArea <AceEditor
mode="json"
theme="solarized_light"
value={text} value={text}
onChange={e => { name="UNIQUE_ID_OF_DIV"
setText(e.target.value); fontSize={14}
showPrintMargin
showGutter
width="100%"
wrapEnabled
highlightActiveLine
setOptions={{
enableBasicAutocompletion: false,
enableLiveAutocompletion: false,
enableSnippets: false,
showLineNumbers: true,
tabSize: 2,
}}
onChange={v => {
setText(v);
}} }}
rows={10} rows={10}
/> />
......
...@@ -301,11 +301,7 @@ const MiniMenu = props => { ...@@ -301,11 +301,7 @@ const MiniMenu = props => {
})} })}
> >
菜单列表 菜单列表
<div <div className={classnames(styles.tRight)}>
className={classnames({
[styles.tRight]: true,
})}
>
<Tooltip title="新增菜单组"> <Tooltip title="新增菜单组">
<FolderAddTwoTone <FolderAddTwoTone
className={`${styles.icon1} ${styles.icon}`} className={`${styles.icon1} ${styles.icon}`}
......
...@@ -76,4 +76,9 @@ ...@@ -76,4 +76,9 @@
min-height: 100%; min-height: 100%;
border: 1px solid #eee; border: 1px solid #eee;
padding: 10px; padding: 10px;
}
.modal{
.ant-modal-body{
padding: 0 !important;
}
} }
\ No newline at end of file
...@@ -92,9 +92,9 @@ export const deleteWebMenu = param => ...@@ -92,9 +92,9 @@ export const deleteWebMenu = param =>
export const getWebMenuInfo = param => export const getWebMenuInfo = param =>
get(`${CITY_SERVICE}/OMS.svc/P_GetMenuInfo?_version=9999`, param); get(`${CITY_SERVICE}/OMS.svc/P_GetMenuInfo?_version=9999`, param);
export const saveConfigContent = content => export const saveConfigContent = (fileName, content) =>
post( post(
`${CITY_SERVICE}/OMS.svc/W4_SaveConfigContent?_version=9999`, `${CITY_SERVICE}/OMS.svc/W4_SaveConfigContent?_version=9999&fileName=${fileName}`,
qs.stringify({ web4ConfigContent: content }), qs.stringify({ web4ConfigContent: content }),
{ {
headers: { headers: {
......
...@@ -24,6 +24,7 @@ const bizRedirectHandler = response => { ...@@ -24,6 +24,7 @@ const bizRedirectHandler = response => {
); );
notification.warning({ notification.warning({
key, key,
title: '提示',
message: '授权失败,即将跳转到登录页', message: '授权失败,即将跳转到登录页',
duration: 4, duration: 4,
btn, btn,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment