mirror of
https://github.com/usememos/memos.git
synced 2025-06-05 22:09:59 +02:00
chore: add toast to system settings (#486)
This commit is contained in:
@ -2,6 +2,7 @@ import { useEffect, useState } from "react";
|
|||||||
import { useTranslation } from "react-i18next";
|
import { useTranslation } from "react-i18next";
|
||||||
import { Button, Switch, Textarea } from "@mui/joy";
|
import { Button, Switch, Textarea } from "@mui/joy";
|
||||||
import * as api from "../../helpers/api";
|
import * as api from "../../helpers/api";
|
||||||
|
import toastHelper from "../Toast";
|
||||||
import "../../less/settings/preferences-section.less";
|
import "../../less/settings/preferences-section.less";
|
||||||
|
|
||||||
interface State {
|
interface State {
|
||||||
@ -48,10 +49,16 @@ const SystemSection = () => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const handleSaveAdditionalStyle = async () => {
|
const handleSaveAdditionalStyle = async () => {
|
||||||
await api.upsertSystemSetting({
|
try {
|
||||||
name: "additionalStyle",
|
await api.upsertSystemSetting({
|
||||||
value: JSON.stringify(state.additionalStyle),
|
name: "additionalStyle",
|
||||||
});
|
value: JSON.stringify(state.additionalStyle),
|
||||||
|
});
|
||||||
|
} catch (error) {
|
||||||
|
console.error(error);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
toastHelper.success("Succeed to update additional style");
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleAdditionalScriptChanged = (value: string) => {
|
const handleAdditionalScriptChanged = (value: string) => {
|
||||||
@ -62,10 +69,16 @@ const SystemSection = () => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const handleSaveAdditionalScript = async () => {
|
const handleSaveAdditionalScript = async () => {
|
||||||
await api.upsertSystemSetting({
|
try {
|
||||||
name: "additionalScript",
|
await api.upsertSystemSetting({
|
||||||
value: JSON.stringify(state.additionalScript),
|
name: "additionalScript",
|
||||||
});
|
value: JSON.stringify(state.additionalScript),
|
||||||
|
});
|
||||||
|
} catch (error) {
|
||||||
|
console.error(error);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
toastHelper.success("Succeed to update additional script");
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
@ -89,7 +102,7 @@ const SystemSection = () => {
|
|||||||
}}
|
}}
|
||||||
minRows={5}
|
minRows={5}
|
||||||
maxRows={10}
|
maxRows={10}
|
||||||
defaultValue={state.additionalStyle}
|
value={state.additionalStyle}
|
||||||
onChange={(event) => handleAdditionalStyleChanged(event.target.value)}
|
onChange={(event) => handleAdditionalStyleChanged(event.target.value)}
|
||||||
/>
|
/>
|
||||||
<div className="form-label selector mt-2">
|
<div className="form-label selector mt-2">
|
||||||
@ -106,7 +119,7 @@ const SystemSection = () => {
|
|||||||
}}
|
}}
|
||||||
minRows={5}
|
minRows={5}
|
||||||
maxRows={10}
|
maxRows={10}
|
||||||
defaultValue={state.additionalScript}
|
value={state.additionalScript}
|
||||||
onChange={(event) => handleAdditionalScriptChanged(event.target.value)}
|
onChange={(event) => handleAdditionalScriptChanged(event.target.value)}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
Reference in New Issue
Block a user