feat: export old setting
This commit is contained in:
@@ -45,7 +45,11 @@ import { loadOrFetchSubRules } from "../../libs/subRules";
|
||||
import { useAlert } from "../../hooks/Alert";
|
||||
import { syncShareRules } from "../../libs/sync";
|
||||
import { debounce } from "../../libs/utils";
|
||||
import { delSubRules, getSyncWithDefault } from "../../libs/storage";
|
||||
import {
|
||||
delSubRules,
|
||||
getSyncWithDefault,
|
||||
getRulesOld,
|
||||
} from "../../libs/storage";
|
||||
import OwSubRule from "./OwSubRule";
|
||||
import ClearAllIcon from "@mui/icons-material/ClearAll";
|
||||
import HelpButton from "./HelpButton";
|
||||
@@ -901,6 +905,11 @@ function UserRules({ subRules, rules }) {
|
||||
text={i18n("export")}
|
||||
fileName={`kiss-rules_${Date.now()}.json`}
|
||||
/>
|
||||
<DownloadButton
|
||||
handleData={async () => JSON.stringify(await getRulesOld(), null, 2)}
|
||||
text={i18n("export_old")}
|
||||
fileName={`kiss-rules_v1_${Date.now()}.json`}
|
||||
/>
|
||||
|
||||
<ShareButton
|
||||
rules={rules}
|
||||
@@ -979,6 +988,7 @@ function SubRulesItem({
|
||||
deleteDataCache,
|
||||
}) {
|
||||
const [loading, setLoading] = useState(false);
|
||||
const alert = useAlert();
|
||||
|
||||
const handleDel = async () => {
|
||||
try {
|
||||
@@ -1000,6 +1010,12 @@ function SubRulesItem({
|
||||
await updateDataCache(url);
|
||||
} catch (err) {
|
||||
kissLog("sync sub rules", err);
|
||||
alert.error(
|
||||
<>
|
||||
<p>Sync Error:</p>
|
||||
<pre>{err.message}</pre>
|
||||
</>
|
||||
);
|
||||
} finally {
|
||||
setLoading(false);
|
||||
}
|
||||
|
||||
@@ -32,6 +32,7 @@ import { sendBgMsg } from "../../libs/msg";
|
||||
import { kissLog } from "../../libs/log";
|
||||
import UploadButton from "./UploadButton";
|
||||
import DownloadButton from "./DownloadButton";
|
||||
import { getSettingOld } from "../../libs/storage";
|
||||
|
||||
function ShortcutItem({ action, label }) {
|
||||
const { shortcut, setShortcut } = useShortcut(action);
|
||||
@@ -137,6 +138,13 @@ export default function Settings() {
|
||||
text={i18n("export")}
|
||||
fileName={`kiss-setting_${Date.now()}.json`}
|
||||
/>
|
||||
<DownloadButton
|
||||
handleData={async () =>
|
||||
JSON.stringify(await getSettingOld(), null, 2)
|
||||
}
|
||||
text={i18n("export_old")}
|
||||
fileName={`kiss-setting_v1_${Date.now()}.json`}
|
||||
/>
|
||||
</Stack>
|
||||
|
||||
<Box>
|
||||
|
||||
@@ -189,7 +189,7 @@ export default function SyncSetting() {
|
||||
</LoadingButton>
|
||||
<Button
|
||||
size="small"
|
||||
variant="contained"
|
||||
variant="outlined"
|
||||
onClick={handleGenerateShareString}
|
||||
startIcon={<ContentCopyIcon />}
|
||||
>
|
||||
@@ -198,7 +198,7 @@ export default function SyncSetting() {
|
||||
<Button
|
||||
onClick={handleImportFromClipboard}
|
||||
size="small"
|
||||
variant="contained"
|
||||
variant="outlined"
|
||||
startIcon={<ContentPasteIcon />}
|
||||
>
|
||||
{i18n("import", "import")}
|
||||
|
||||
Reference in New Issue
Block a user