dialog-export-config.html 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. <div class="easyui-layout" data-options="fit:true" style="width:100%;height:100%;">
  2. <div data-options="region:'center'" style="padding:3px;border:0px;overflow: hidden;">
  3. <div id="" class="dialog" style="width:100%;padding:0px;height:100%;border-bottom: 1px dotted #ccc;">
  4. <div>
  5. <input id="chk-export-system" type="checkbox" checked="checked" />
  6. <label for="chk-export-system" system-lang="dialog['export-config']['option-system']"></label>
  7. </div>
  8. <div>
  9. <input id="chk-export-dictionary" type="checkbox" checked="checked"/>
  10. <label for="chk-export-dictionary" system-lang="dialog['export-config']['option-dictionary']"></label>
  11. </div>
  12. <div>
  13. <input id="chk-export-server" type="checkbox" checked="checked"/>
  14. <label for="chk-export-server" system-lang="dialog['export-config']['option-server']"></label>
  15. </div>
  16. </div>
  17. </div>
  18. <div data-options="region:'south',border:false" style="text-align:right;padding:6px;">
  19. <span id="text-nochange" style="display:none;"></span>
  20. <span id="text-count"></span>
  21. <a id="button-ok" class="easyui-linkbutton" data-options="iconCls:'icon-ok',plain:true" href="javascript:void(0);"
  22. system-lang="dialog['public']['button-ok']">Ok</a>
  23. <a id="button-cancel" class="easyui-linkbutton" data-options="iconCls:'icon-cancel',plain:true" href="javascript:void(0);"
  24. system-lang="dialog['public']['button-cancel']">Cancel</a>
  25. </div>
  26. </div>
  27. <script type="text/javascript">
  28. (function (thisDialog) {
  29. var page = {
  30. init: function () {
  31. system.resetLangText(thisDialog);
  32. this.initEvents();
  33. },
  34. // 初始化事件
  35. initEvents: function () {
  36. // Cancel
  37. $("#button-cancel", thisDialog).click(function () {
  38. page.close();
  39. });
  40. $("#button-ok", thisDialog).click(function () {
  41. if (page.done()) {
  42. page.close();
  43. }
  44. });
  45. },
  46. done: function () {
  47. var data = {};
  48. // 系统
  49. if ($("#chk-export-system", thisDialog).prop("checked")) {
  50. data["system"] = system.config;
  51. data["user"] = system.userConfig;
  52. }
  53. // 目录字典
  54. if ($("#chk-export-dictionary", thisDialog).prop("checked")) {
  55. data["dictionary-folders"] = system.dictionary.folders.split("\n");
  56. }
  57. // 服务器
  58. if ($("#chk-export-server", thisDialog).prop("checked")) {
  59. data["server"] = $.extend({}, system.serverConfig);
  60. // 排除一些不需要的参数
  61. var except = ["blocklist-size", "config-dir", "rpc-version",
  62. "rpc-version-minimum", "version", "session-id", "units",
  63. "download-dir-free-space"];
  64. for (const key in except) {
  65. if (except.hasOwnProperty(key)) {
  66. const item = except[key];
  67. data.server.hasOwnProperty(item) && delete data.server[item];
  68. }
  69. }
  70. }
  71. if ($.isEmptyObject(data)) {
  72. thisDialog.find("#text-nochange").html(system.lang.dialog["export-config"].title).fadeInAndOut();
  73. return false;
  74. }
  75. data["configVersion"] = 1;
  76. var exportData = JSON.parse(JSON.stringify(data));
  77. saveFileAs("tr-web-control-config.json", JSON.stringify(exportData));
  78. return true;
  79. },
  80. close: function () {
  81. var source = thisDialog.data("popoverSource");
  82. if (source) {
  83. $(source).webuiPopover("hide");
  84. } else {
  85. thisDialog.dialog("close");
  86. }
  87. }
  88. };
  89. page.init();
  90. })($("#dialog-export-config"));
  91. </script>