From 839300b476d6a8f85cb74b6d25fa7e71730c16d0 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Mon, 19 Aug 2024 09:41:35 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=8E=81=20Sync=202024-08-19=2009:41?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- luci-app-mosdns/luci-app-mosdns/Makefile | 2 +- .../resources/view/mosdns/basic.js | 36 ++++++++++++------- 2 files changed, 24 insertions(+), 14 deletions(-) diff --git a/luci-app-mosdns/luci-app-mosdns/Makefile b/luci-app-mosdns/luci-app-mosdns/Makefile index a658bb9e..a6ecd857 100644 --- a/luci-app-mosdns/luci-app-mosdns/Makefile +++ b/luci-app-mosdns/luci-app-mosdns/Makefile @@ -1,7 +1,7 @@ include $(TOPDIR)/rules.mk PKG_NAME:=luci-app-mosdns -PKG_VERSION:=1.6.0 +PKG_VERSION:=1.6.1 PKG_RELEASE:=1 LUCI_TITLE:=LuCI Support for mosdns diff --git a/luci-app-mosdns/luci-app-mosdns/htdocs/luci-static/resources/view/mosdns/basic.js b/luci-app-mosdns/luci-app-mosdns/htdocs/luci-static/resources/view/mosdns/basic.js index da9965fc..719f4781 100644 --- a/luci-app-mosdns/luci-app-mosdns/htdocs/luci-static/resources/view/mosdns/basic.js +++ b/luci-app-mosdns/luci-app-mosdns/htdocs/luci-static/resources/view/mosdns/basic.js @@ -37,7 +37,7 @@ function renderStatus(isRunning) { } return view.extend({ - load: function() { + load: function () { return Promise.all([ L.resolveDefault(fs.exec('/usr/bin/mosdns', ['version']), null), ]); @@ -314,10 +314,15 @@ return view.extend({ return fs.trimmed('/etc/mosdns/rule/cloudflare-cidr.txt'); }; o.write = function (section_id, formvalue) { - return fs.write('/etc/mosdns/rule/cloudflare-cidr.txt', formvalue.trim().replace(/\r\n/g, '\n') + '\n') - .then(function (i) { - return fs.exec('/etc/init.d/mosdns', ['restart']); - }); + return this.cfgvalue(section_id).then(function (value) { + if (value == formvalue) { + return; + } + return fs.write('/etc/mosdns/rule/cloudflare-cidr.txt', formvalue.trim().replace(/\r\n/g, '\n') + '\n') + .then(function (i) { + return fs.exec('/etc/init.d/mosdns', ['restart']); + }); + }); }; /* api */ @@ -344,14 +349,19 @@ return view.extend({ return fs.trimmed('/etc/mosdns/config_custom.yaml'); }; o.write = function (section_id, formvalue) { - return fs.write('/etc/mosdns/config_custom.yaml', formvalue.trim().replace(/\r\n/g, '\n') + '\n') - .then(function (i) { - ui.addNotification(null, E('p', _('Configuration have been saved.')), 'info'); - return fs.exec('/etc/init.d/mosdns', ['restart']); - }) - .catch(function (e) { - ui.addNotification(null, E('p', _('Unable to save contents: %s').format(e.message))); - }); + return this.cfgvalue(section_id).then(function (value) { + if (value == formvalue) { + return; + } + return fs.write('/etc/mosdns/config_custom.yaml', formvalue.trim().replace(/\r\n/g, '\n') + '\n') + .then(function (i) { + ui.addNotification(null, E('p', _('Configuration have been saved.')), 'info'); + return fs.exec('/etc/init.d/mosdns', ['restart']); + }) + .catch(function (e) { + ui.addNotification(null, E('p', _('Unable to save contents: %s').format(e.message))); + }); + }); }; o = s.taboption('geodata', form.DynamicList, 'geosite_tags', _('GeoSite Tags'),