🎉 Sync 2026-09-21 03:58:45

This commit is contained in:
github-actions[bot] committed 2026-09-21 03:58:45 +08:00
1 parent da26c8c705
commit b8539f4af6
8 files changed
+443 -74

No files matched your search

@@ -71,6 +71,7 @@ function getRadioBand(devName) {
return view.extend({
initialValues: {},
initialShortcuts: [],
originalLanIp: null, // 持久快照,防止被 handleSave 覆盖
hasWireless: false,
hasNginx: false,
map: null,
@@ -119,6 +120,7 @@ return view.extend({
}
}
// 剥离现有频段后缀,确保输入框展示纯净的基准名称
var rawSsid = (ap && ap.ssid) || (this.hasWireless ? 'Kwrt' : '');
var baseSsid = rawSsid.replace(/_(2\.4G|5G|6G)$/i, '').trim();
@@ -147,6 +149,7 @@ return view.extend({
var sys = this.getSystemConfig();
this.initialValues = Object.assign({}, sys);
this.originalLanIp = sys.lan_ipaddr; // 记录不可变初始 IP
// 缓存初始 shortcuts 配置快照,用于保存时比对差异
var shortcuts = uci.sections('wizard', 'shortcuts') || [];
@@ -502,32 +505,59 @@ return view.extend({
});
},
// 5. 重写 View 级别的 handleSaveApply:应用生效并实现 LAN IP 变更平滑迁移与自动跳转
// 5. 重写 View 级别的 handleSaveApply:前置检测 LAN IP 变动,强制非回滚提交并精准弹出倒计时
handleSaveApply: function(ev, mode) {
var self = this;
// 关键修复:在 handleSave 覆盖 initialValues 之前,立即计算并锁定是否修改了 LAN IP
var oldIp = (self.originalLanIp || self.initialValues.lan_ipaddr || '').split('/')[0].trim();
var newIp = (self.optMap['lan_ipaddr'] ? self.optMap['lan_ipaddr'].formvalue('default') : '') || '';
newIp = newIp.split('/')[0].trim();
var ipChanged = !!(newIp && oldIp && (newIp !== oldIp));
return this.handleSave(ev).then(function(hasChanges) {
if (!hasChanges) return false;
var oldIp = self.initialValues.lan_ipaddr;
var newIp = (self.optMap['lan_ipaddr'].formvalue('default') || '').split('/')[0].trim();
var ipChanged = newIp && (newIp !== oldIp);
if (ipChanged) {
var sec = 15;
var targetUrl = window.location.protocol + '//' + newIp + (window.location.pathname || '/cgi-bin/luci/');
var countSpan = E('strong', {}, String(sec));
return ui.changes.apply(mode == '0').then(function() {
if (ipChanged) {
var sec = 15;
ui.showModal(_('LAN IP Address Changed'), [
E('p', _('LAN IP changed to %s. Redirecting in %d seconds...').format(newIp, sec)),
E('div', { 'class': 'spinning', 'style': 'margin: 1em auto;' })
]);
var timer = window.setInterval(function() {
sec--;
if (sec <= 0) {
window.clearInterval(timer);
window.location.href = window.location.protocol + '//' + newIp + window.location.pathname;
}
}, 1000);
}
});
// 1. 核心操作:调用 apply_unchecked,进行强制永久提交,彻底绕过 90 秒回滚保护机制!
L.post(L.url('admin', 'uci', 'apply_unchecked')).catch(function() {});
// 2. 立即在前端呼出弹窗遮罩层
ui.showModal(_('LAN IP Address Changed'), [
E('p', {}, [_('LAN IP has been changed to '), E('strong', {}, newIp), '.']),
E('p', {}, [_('Applying changes without rollback. Redirecting to the new address in '), countSpan, _(' seconds...')]),
E('p', { 'class': 'alert-message notice', 'style': 'margin-top: 1em;' },
_('提示:更改网段后,若未能自动加载新页面,请尝试重新插拔网线或断开重连 Wi-Fi,以获取新网段的 IP 地址。')),
E('div', { 'class': 'spinning', 'style': 'margin: 1.5em auto;' }),
E('div', { 'class': 'right' }, [
E('button', {
'class': 'cbi-button cbi-button-action',
'click': function() {
window.location.href = targetUrl;
}
}, _('Redirect Now'))
])
]);
// 3. 启动倒计时并自动跳转
var timer = window.setInterval(function() {
sec--;
countSpan.textContent = String(sec);
if (sec <= 0) {
window.clearInterval(timer);
window.location.href = targetUrl;
}
}, 1000);
return true;
} else {
// 未改动 LAN IP 的常规操作,保留原生的回滚自愈保护
return ui.changes.apply(mode == '0');
}
});
},