Skip to content

Commit

Permalink
🎨 Support export and import settings #10617
Browse files Browse the repository at this point in the history
  • Loading branch information
88250 committed Sep 26, 2024
1 parent afe993a commit e2406f8
Show file tree
Hide file tree
Showing 8 changed files with 61 additions and 0 deletions.
4 changes: 4 additions & 0 deletions app/appearance/langs/en_US.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
{
"exportConf": "Export settings",
"exportConfTip": "Account, access authorization code, synchronization, API token and data repo key will not be exported",
"importConf": "Import settings",
"importConfTip": "After importing, the current settings will be overwritten and the application will be automatically closed, please restart manually",
"jumpToPage": "Jump to the specified page: 1 ~ ${x}",
"pageCountAndSnapshotCount": "Total ${x} pages, ${y} snapshots",
"pageCountAndHistoryCount": "Total ${x} pages, ${y} histories",
Expand Down
4 changes: 4 additions & 0 deletions app/appearance/langs/es_ES.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
{
"exportConf": "Configuración de exportación",
"exportConfTip": "Las cuentas, los códigos de acceso, la sincronización, los tokens API y las claves del almacén de datos no se exportarán",
"importConf": "Importar configuración",
"importConfTip": "Después de importar, la configuración actual se sobrescribirá y la aplicación se cerrará automáticamente. Reiníciela manualmente",
"jumpToPage": "Saltar a la página especificada: 1 ~ ${x}",
"pageCountAndSnapshotCount": "Total ${x} páginas, ${y} instantáneas",
"pageCountAndHistoryCount": "Total ${x} páginas, ${y} historias",
Expand Down
4 changes: 4 additions & 0 deletions app/appearance/langs/fr_FR.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
{
"exportConf": "Exporter les paramètres",
"exportConfTip": "Les comptes, codes d'accès, synchronisation, tokens API et clés d'entrepôt de données ne seront pas exportés",
"importConf": "Importer les paramètres",
"importConfTip": "Après l'importation, les paramètres actuels seront écrasés et l'application sera automatiquement fermée. Veuillez la redémarrer manuellement",
"jumpToPage": "Aller à la page spécifiée : 1 ~ ${x}",
"pageCountAndSnapshotCount": "Total de ${x} pages, ${y} instantanés",
"pageCountAndHistoryCount": "Total de ${x} pages, ${y} histoires",
Expand Down
4 changes: 4 additions & 0 deletions app/appearance/langs/it_IT.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
{
"exportConf": "Impostazioni di esportazione",
"exportConfTip": "Account, codici di accesso, sincronizzazione, token API e chiavi di data warehouse non verranno esportati",
"importConf": "Importa impostazioni",
"importConfTip": "Dopo l'importazione, le impostazioni attuali verranno sovrascritte e l'applicazione verrà chiusa automaticamente. Riavviala manualmente",
"jumpToPage": "Salta alla pagina specificata: 1 ~ ${x}",
"pageCountAndSnapshotCount": "Totale ${x} pagine, ${y} snapshot",
"pageCountAndHistoryCount": "Totale ${x} pagine, ${y} cronologie",
Expand Down
4 changes: 4 additions & 0 deletions app/appearance/langs/ja_JP.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
{
"exportConf": "設定のエクスポート",
"exportConfTip": "アカウント、アクセス コード、同期、API トークン、データ ウェアハウス キーはエクスポートされません",
"importConf": "設定のインポート",
"importConfTip": "インポート後、現在の設定は上書きされ、アプリケーションは自動的に終了します。手動で再起動してください。",
"jumpToPage": "指定されたページにジャンプ:1 ~ ${x}",
"pageCountAndSnapshotCount": "合計 ${x} ページ、${y} スナップショット",
"pageCountAndHistoryCount": "合計 ${x} ページ、${y} 履歴",
Expand Down
4 changes: 4 additions & 0 deletions app/appearance/langs/zh_CHT.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
{
"exportConf": "匯出設定",
"exportConfTip": "帳號、存取授權碼、同步、API token 和資料倉儲金鑰不會被匯出",
"importConf": "導入設定",
"importConfTip": "導入後會覆蓋當設定並自動關閉應用,請手動重新啟動",
"jumpToPage": "跳轉到指定頁:1 ~ ${x}",
"pageCountAndSnapshotCount": "共 ${x} 頁,${y} 個快照",
"pageCountAndHistoryCount": "共 ${x} 頁,${y} 個歷史紀錄",
Expand Down
4 changes: 4 additions & 0 deletions app/appearance/langs/zh_CN.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
{
"exportConf": "导出设置",
"exportConfTip": "账号、访问授权码、同步、API token 和数据仓库密钥不会被导出",
"importConf": "导入设置",
"importConfTip": "导入后会覆盖当设置并自动关闭应用,请手动重启",
"jumpToPage": "跳转到指定页:1 ~ ${x}",
"pageCountAndSnapshotCount": "共 ${x} 页,${y} 个快照",
"pageCountAndHistoryCount": "共 ${x} 页,${y} 个历史版本",
Expand Down
33 changes: 33 additions & 0 deletions app/src/config/exportConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import {isBrowser} from "../util/functions";
import {showMessage} from "../dialog/message";
import {showFileInFolder} from "../util/pathName";
import {Constants} from "../constants";
import {openByMobile} from "../protyle/util/compatibility";

export const exportConfig = {
element: undefined as Element,
Expand Down Expand Up @@ -158,6 +159,27 @@ export const exportConfig = {
<input id="importData" class="b3-form__upload" type="file">
<svg><use xlink:href="#iconDownload"></use></svg>${window.siyuan.languages.import}
</button>
</div>
<div class="fn__flex b3-label config__item">
<div class="fn__flex-1 fn__flex-center">
${window.siyuan.languages.exportConf}
<div class="b3-label__text">${window.siyuan.languages.exportConfTip}</div>
</div>
<span class="fn__space"></span>
<button class="b3-button b3-button--outline fn__flex-center fn__size200" id="exportConf">
<svg><use xlink:href="#iconUpload"></use></svg>${window.siyuan.languages.export}
</button>
</div>
<div class="fn__flex b3-label config__item">
<div class="fn__flex-1 fn__flex-center">
${window.siyuan.languages.importConf}
<div class="b3-label__text">${window.siyuan.languages.importConfTip}</div>
</div>
<span class="fn__space"></span>
<button class="b3-button b3-button--outline fn__flex-center fn__size200" style="position: relative">
<input id="importConf" class="b3-form__upload" type="file">
<svg><use xlink:href="#iconDownload"></use></svg>${window.siyuan.languages.import}
</button>
</div>`;
},
bindEvent: () => {
Expand Down Expand Up @@ -208,6 +230,12 @@ export const exportConfig = {
formData.append("file", event.target.files[0]);
fetchPost("/api/import/importData", formData);
});
} else if (item.id === "importConf") {
item.addEventListener("change", (event: InputEvent & { target: HTMLInputElement }) => {
const formData = new FormData();
formData.append("file", event.target.files[0]);
fetchPost("/api/system/importConf", formData);
});
} else {
item.addEventListener("change", () => {
setexprt();
Expand Down Expand Up @@ -236,6 +264,11 @@ export const exportConfig = {
});
/// #endif
});
exportConfig.element.querySelector("#exportConf").addEventListener("click", async () => {
fetchPost("/api/system/exportConf", {}, response => {
openByMobile(response.data.zip);
});
});
/// #if !BROWSER
pandocBinPathElement.addEventListener("click", () => {
if (window.siyuan.config.export.pandocBin) {
Expand Down

0 comments on commit e2406f8

Please sign in to comment.