change qrcode

This commit is contained in:
fyears 2022-01-01 23:26:01 +08:00
parent 4639b93cfa
commit 5b703334d7
3 changed files with 14 additions and 5 deletions

View File

@ -1,4 +1,5 @@
import QRCode from "qrcode";
import cloneDeep from "lodash/cloneDeep";
import {
COMMAND_URI,
@ -11,7 +12,10 @@ export const exportQrCodeUri = async (
currentVaultName: string,
pluginVersion: string
) => {
const data = encodeURIComponent(JSON.stringify(settings));
const settings2 = cloneDeep(settings);
delete settings2.dropbox;
delete settings2.onedrive;
const data = encodeURIComponent(JSON.stringify(settings2));
const vault = encodeURIComponent(currentVaultName);
const version = encodeURIComponent(pluginVersion);
const rawUri = `obsidian://${COMMAND_URI}?func=settings&version=${version}&vault=${vault}&data=${data}`;

View File

@ -96,10 +96,10 @@ export default class RemotelySavePlugin extends Plugin {
} else {
const copied = cloneDeep(parsed.result);
// new Notice(JSON.stringify(copied))
this.settings = copied;
this.settings = Object.assign({}, this.settings, copied);
this.saveSettings();
new Notice(
`New settings for ${this.manifest.name} saved. Reopen the plugin Settings to the effect.`
`New not-oauth2 settings for ${this.manifest.name} saved. Reopen the plugin Settings to the effect.`
);
}
});

View File

@ -258,6 +258,9 @@ class ExportSettingsQrCodeModal extends Modal {
);
const div1 = contentEl.createDiv();
div1.createEl("p", {
text: "This exports not-oauth2 settings. (It means that Dropbox, OneDrive info are NOT exported.)",
});
div1.createEl("p", {
text: "You can use another device to scan this qrcode.",
});
@ -855,11 +858,13 @@ export class RemotelySaveSettingTab extends PluginSettingTab {
// import and export
const importExportDiv = containerEl.createEl("div");
importExportDiv.createEl("h2", { text: "Import and Export Settings" });
importExportDiv.createEl("h2", {
text: "Import and Export Partial Settings",
});
new Setting(importExportDiv)
.setName("export")
.setDesc("Export all settings by generating a qrcode.")
.setDesc("Export not-oauth2 settings by generating a qrcode.")
.addButton(async (button) => {
button.setButtonText("Get QR Code");
button.onClick(async () => {