Skip to content

Commit

Permalink
支持自动格式化json
Browse files Browse the repository at this point in the history
  • Loading branch information
zhoudian committed Dec 11, 2021
1 parent e6611d3 commit 6446b17
Show file tree
Hide file tree
Showing 26 changed files with 165 additions and 25 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "QuickRedis",
"version": "2.6.0",
"version": "2.6.2",
"private": true,
"description": "QuickRedis",
"author": "https://quick123.net/",
Expand Down
1 change: 1 addition & 0 deletions public/locales/cs.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
"SystemConfig.start": "#### SystemConfig ####",
"SystemConfig.lang": "Vyberte jazyk",
"SystemConfig.tree.split": "Nastavit oddělovač",
"SystemConfig.auto.format.json": "Format json automatically",
"SystemConfig.title": "Konfigurace systému",
"SystemConfig.needRestart": "Abyste se projevili, musíte restartovat.",
"SystemConfig.end00": "#### SystemConfig ####",
Expand Down
1 change: 1 addition & 0 deletions public/locales/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
"SystemConfig.start": "#### SystemConfig ####",
"SystemConfig.lang": "Sprache auswählen",
"SystemConfig.tree.split": "Trennzeichen einstellen",
"SystemConfig.auto.format.json": "Format json automatically",
"SystemConfig.title": "Systemkonfiguration",
"SystemConfig.needRestart": "Sie müssen neu starten, um wirksam zu werden.",
"SystemConfig.end00": "#### SystemConfig ####",
Expand Down
1 change: 1 addition & 0 deletions public/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
"SystemConfig.start": "#### SystemConfig ####",
"SystemConfig.lang": "Select language",
"SystemConfig.tree.split": "Set separator",
"SystemConfig.auto.format.json": "Format json automatically",
"SystemConfig.title": "System configuration",
"SystemConfig.needRestart": "You need to restart to take effect.",
"SystemConfig.end00": "#### SystemConfig ####",
Expand Down
1 change: 1 addition & 0 deletions public/locales/es.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
"SystemConfig.start": "#### SystemConfig ####",
"SystemConfig.lang": "Seleccionar idioma",
"SystemConfig.tree.split": "Establecer separador",
"SystemConfig.auto.format.json": "Format json automatically",
"SystemConfig.title": "Configuración del sistema",
"SystemConfig.needRestart": "Necesita reiniciar para que surta efecto",
"SystemConfig.end00": "#### SystemConfig ####",
Expand Down
1 change: 1 addition & 0 deletions public/locales/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
"SystemConfig.start": "#### SystemConfig ####",
"SystemConfig.lang": "Sélectionnez la langue",
"SystemConfig.tree.split": "Définir le séparateur",
"SystemConfig.auto.format.json": "Format json automatically",
"SystemConfig.title": "Configuration système",
"SystemConfig.needRestart": "Vous devez redémarrer pour prendre effet.",
"SystemConfig.end00": "#### SystemConfig ####",
Expand Down
1 change: 1 addition & 0 deletions public/locales/id.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
"SystemConfig.start": "#### SystemConfig ####",
"SystemConfig.lang": "Pilih bahasa",
"SystemConfig.tree.split": "Atur pemisah",
"SystemConfig.auto.format.json": "Format json automatically",
"SystemConfig.title": "Konfigurasi sistem",
"SystemConfig.needRestart": "Anda perlu memulai ulang untuk menerapkannya.",
"SystemConfig.end00": "#### SystemConfig ####",
Expand Down
1 change: 1 addition & 0 deletions public/locales/it.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
"SystemConfig.start": "#### SystemConfig ####",
"SystemConfig.lang": "Seleziona lingua",
"SystemConfig.tree.split": "Imposta separatore",
"SystemConfig.auto.format.json": "Format json automatically",
"SystemConfig.title": "Configurazione del sistema",
"SystemConfig.needRestart": "È necessario riavviare per avere effetto.",
"SystemConfig.end00": "#### SystemConfig ####",
Expand Down
1 change: 1 addition & 0 deletions public/locales/ja.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
"SystemConfig.start": "#### SystemConfig ####",
"SystemConfig.lang": "言語を選択してください",
"SystemConfig.tree.split": "区切り文字を設定する",
"SystemConfig.auto.format.json": "Format json automatically",
"SystemConfig.title": "システム構成",
"SystemConfig.needRestart": "有効にするには再起動する必要があります。",
"SystemConfig.end00": "#### SystemConfig ####",
Expand Down
1 change: 1 addition & 0 deletions public/locales/ko.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
"SystemConfig.start": "#### SystemConfig ####",
"SystemConfig.lang": "언어 선택",
"SystemConfig.tree.split": "구분자 설정",
"SystemConfig.auto.format.json": "Format json automatically",
"SystemConfig.title": "시스템 구성",
"SystemConfig.needRestart": "적용하려면 다시 시작해야합니다.",
"SystemConfig.end00": "#### SystemConfig ####",
Expand Down
1 change: 1 addition & 0 deletions public/locales/nl.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
"SystemConfig.start": "#### SystemConfig ####",
"SystemConfig.lang": "Selecteer taal",
"SystemConfig.tree.split": "Scheidingsteken instellen",
"SystemConfig.auto.format.json": "Format json automatically",
"SystemConfig.title": "Systeemconfiguratie",
"SystemConfig.needRestart": "U moet opnieuw opstarten om van kracht te worden.",
"SystemConfig.end00": "#### SystemConfig ####",
Expand Down
1 change: 1 addition & 0 deletions public/locales/pl.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
"SystemConfig.start": "#### SystemConfig ####",
"SystemConfig.lang": "Wybierz język",
"SystemConfig.tree.split": "Ustaw separator",
"SystemConfig.auto.format.json": "Format json automatically",
"SystemConfig.title": "Konfiguracja systemu",
"SystemConfig.needRestart": "Musisz zrestartować, aby odniosły skutek.",
"SystemConfig.end00": "#### SystemConfig ####",
Expand Down
1 change: 1 addition & 0 deletions public/locales/pt.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
"SystemConfig.start": "#### SystemConfig ####",
"SystemConfig.lang": "Selecione o idioma",
"SystemConfig.tree.split": "Definir separador",
"SystemConfig.auto.format.json": "Format json automatically",
"SystemConfig.title": "Configuração do sistema",
"SystemConfig.needRestart": "Você precisa reiniciar para fazer efeito.",
"SystemConfig.end00": "#### SystemConfig ####",
Expand Down
1 change: 1 addition & 0 deletions public/locales/ru.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
"SystemConfig.start": "#### SystemConfig ####",
"SystemConfig.lang": "Выбрать язык",
"SystemConfig.tree.split": "Установить разделитель",
"SystemConfig.auto.format.json": "Format json automatically",
"SystemConfig.title": "Конфигурация системы",
"SystemConfig.needRestart": "Для вступления в силу необходимо перезапустить.",
"SystemConfig.end00": "#### SystemConfig ####",
Expand Down
1 change: 1 addition & 0 deletions public/locales/uk.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
"SystemConfig.start": "#### SystemConfig ####",
"SystemConfig.lang": "Вибрати мову",
"SystemConfig.tree.split": "Встановити роздільник",
"SystemConfig.auto.format.json": "Format json automatically",
"SystemConfig.title": "Конфігурація системи",
"SystemConfig.needRestart": "Вам потрібно перезапуститися, щоб набути чинності.",
"SystemConfig.end00": "#### SystemConfig ####",
Expand Down
1 change: 1 addition & 0 deletions public/locales/vi.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
"SystemConfig.start": "#### SystemConfig ####",
"SystemConfig.lang": "Chọn ngôn ngữ",
"SystemConfig.tree.split": "Đặt dấu phân cách",
"SystemConfig.auto.format.json": "Format json automatically",
"SystemConfig.title": "Cấu hình hệ thống",
"SystemConfig.needRestart": "Bạn cần khởi động lại để có hiệu lực.",
"SystemConfig.end00": "#### SystemConfig ####",
Expand Down
1 change: 1 addition & 0 deletions public/locales/zh-CN.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
"SystemConfig.start": "#### SystemConfig ####",
"SystemConfig.lang": "选择语言",
"SystemConfig.tree.split": "设置分隔符",
"SystemConfig.auto.format.json": "自动格式化json",
"SystemConfig.title": "系统配置",
"SystemConfig.needRestart": "您需要重新启动才能生效。",
"SystemConfig.end00": "#### SystemConfig ####",
Expand Down
1 change: 1 addition & 0 deletions public/locales/zh-TW.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
"SystemConfig.start": "#### SystemConfig ####",
"SystemConfig.lang": "選擇語言",
"SystemConfig.tree.split": "設置分隔符",
"SystemConfig.auto.format.json": "自動格式化json",
"SystemConfig.title": "系統配置",
"SystemConfig.needRestart": "您需要重新啟動才能生效。",
"SystemConfig.end00": "#### SystemConfig ####",
Expand Down
54 changes: 43 additions & 11 deletions src/components/SystemConfig/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React from "react";
import { Modal, Row, Col, Select, Input, Tooltip } from "antd";
import { Modal, Row, Col, Select, Input, Tooltip, Checkbox } from "antd";
import LocaleUtils from "@/utils/LocaleUtils";
import intl from "react-intl-universal";
import { ExclamationCircleOutlined } from "@ant-design/icons";
Expand All @@ -10,7 +10,11 @@ const { ipcRenderer, remote } = window.require("electron");
* 系统配置
*/
class SystemConfig extends React.Component {
state = { visible: false, config: { lang: "", splitSign: "" } };
needRestart = false;
state = {
visible: false,
config: { lang: "", splitSign: "", autoFormatJson: true },
};
componentDidMount() {
// 重置连接事件
ipcRenderer.on("system-config", (event, arg) => {
Expand All @@ -30,18 +34,22 @@ class SystemConfig extends React.Component {
visible: false,
});
LocaleUtils.saveSystemConfig(this.state.config);
confirm({
title: intl.get("common.notice"),
icon: <ExclamationCircleOutlined />,
content: intl.get("SystemConfig.needRestart"),
onOk() {
remote.app.quit();
},
onCancel() {},
});
if (this.needRestart) {
this.needRestart = false;
confirm({
title: intl.get("common.notice"),
icon: <ExclamationCircleOutlined />,
content: intl.get("SystemConfig.needRestart"),
onOk() {
remote.app.quit();
},
onCancel() {},
});
}
};

handleCancel = (e) => {
this.needRestart = false;
this.setState({
visible: false,
});
Expand All @@ -56,6 +64,7 @@ class SystemConfig extends React.Component {
this.setState({
config: { ...this.state.config, lang: val },
});
this.needRestart = true;
}
/**
*修改分隔符
Expand All @@ -66,6 +75,20 @@ class SystemConfig extends React.Component {
this.setState({
config: { ...this.state.config, splitSign: event.target.value },
});
this.needRestart = true;
};
/**
*修改自动格式化json
*
* @memberof SystemConfig
*/
handleAutoFormatJsonChange = (event) => {
this.setState({
config: {
...this.state.config,
autoFormatJson: event.target.checked,
},
});
};

render() {
Expand Down Expand Up @@ -108,6 +131,15 @@ class SystemConfig extends React.Component {
/>
</Tooltip>
</Col>
<Col span={6}>
{intl.get("SystemConfig.auto.format.json")}
</Col>
<Col span={18}>
<Checkbox
onChange={this.handleAutoFormatJsonChange}
checked={this.state.config.autoFormatJson}
></Checkbox>
</Col>
</Row>
</Modal>
</div>
Expand Down
2 changes: 1 addition & 1 deletion src/pages/HostContent/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class HostContent extends Component {
hostKeyShowType = HOST_KEY_SHOW_TYPE.TREE;
componentDidMount() {
this.updateDBCount();
let splitSign = LocaleUtils.readSystemConfig().splitSign;
let splitSign = LocaleUtils.readSystemConfig(false).splitSign;
if (splitSign === "" || splitSign === undefined || splitSign === null) {
this.hostKeyShowType = HOST_KEY_SHOW_TYPE.TABLE;
}
Expand Down
15 changes: 15 additions & 0 deletions src/pages/HostKeyHash/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import uuid from "node-uuid";
import Log from "@/services/LogService";
import QuickMonacoEditor from "@/components/QuickMonacoEditor";
import intl from "react-intl-universal";
import LocaleUtils from "@/utils/LocaleUtils";
const { Search } = Input;
/**
* HostKeyHash-管理
Expand Down Expand Up @@ -348,6 +349,20 @@ class HostKeyHash extends Component {
if (data[key]) {
obj[key] = data[key] || null;
}
let autoFormatJson =
LocaleUtils.readSystemConfig(false).autoFormatJson;
if (autoFormatJson) {
try {
let formatJson = JSON.stringify(
JSON.parse(obj.value),
null,
4
);
obj.value = formatJson;
} catch (error) {
// 非json格式,忽略
}
}
form.setFieldsValue(obj);
});
this.setState({ modal: { visible: true, type: 1 } });
Expand Down
15 changes: 15 additions & 0 deletions src/pages/HostKeyList/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import uuid from "node-uuid";
import Log from "@/services/LogService";
import QuickMonacoEditor from "@/components/QuickMonacoEditor";
import intl from "react-intl-universal";
import LocaleUtils from "@/utils/LocaleUtils";
const { Option } = Select;
/**
* HostKeyList-管理
Expand Down Expand Up @@ -261,6 +262,20 @@ class HostKeyList extends Component {
if (data[key]) {
obj[key] = data[key] || null;
}
let autoFormatJson =
LocaleUtils.readSystemConfig(false).autoFormatJson;
if (autoFormatJson) {
try {
let formatJson = JSON.stringify(
JSON.parse(obj.member),
null,
4
);
obj.member = formatJson;
} catch (error) {
// 非json格式,忽略
}
}
form.setFieldsValue(obj);
});
this.setState({ modal: { visible: true, type: 1 } });
Expand Down
15 changes: 15 additions & 0 deletions src/pages/HostKeySet/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import uuid from "node-uuid";
import Log from "@/services/LogService";
import QuickMonacoEditor from "@/components/QuickMonacoEditor";
import intl from "react-intl-universal";
import LocaleUtils from "@/utils/LocaleUtils";
const { Search } = Input;
/**
* HostKeySet-管理
Expand Down Expand Up @@ -306,6 +307,20 @@ class HostKeySet extends Component {
if (data[key]) {
obj[key] = data[key] || null;
}
let autoFormatJson =
LocaleUtils.readSystemConfig(false).autoFormatJson;
if (autoFormatJson) {
try {
let formatJson = JSON.stringify(
JSON.parse(obj.member),
null,
4
);
obj.member = formatJson;
} catch (error) {
// 非json格式,忽略
}
}
form.setFieldsValue(obj);
});
this.setState({ modal: { visible: true, type: 1 } });
Expand Down
15 changes: 15 additions & 0 deletions src/pages/HostKeySortSet/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import { REDIS_DATA_SHOW } from "@/utils/constant";
import uuid from "node-uuid";
import QuickMonacoEditor from "@/components/QuickMonacoEditor";
import intl from "react-intl-universal";
import LocaleUtils from "@/utils/LocaleUtils";
const { Search } = Input;
/**
* HostKeySortSet-管理
Expand Down Expand Up @@ -379,6 +380,20 @@ class HostKeySortSet extends Component {
if (data[key]) {
obj[key] = data[key] || null;
}
let autoFormatJson =
LocaleUtils.readSystemConfig(false).autoFormatJson;
if (autoFormatJson) {
try {
let formatJson = JSON.stringify(
JSON.parse(obj.member),
null,
4
);
obj.member = formatJson;
} catch (error) {
// 非json格式,忽略
}
}
form.setFieldsValue(obj);
});
this.setState({ modal: { visible: true, type: 1 } });
Expand Down
Loading

0 comments on commit 6446b17

Please sign in to comment.