mirror of
https://github.com/Gloridust/WechatOnCloud.git
synced 2026-06-16 19:53:53 +08:00
fix(desktop): 输入模式切换改为整页重载,修卡死 + 切换不生效
切换模式时原先 bump vncNonce 在页内重挂 iframe,会让新旧两条 VNC ws 短暂并存, 概率性把实例 Xvnc 卡死(需重启容器恢复、面板重启无效),且新连接常读不到新 enable_ime (仍是英文)。改为 window.location.reload():先卸载旧页彻底关旧 ws,再以新模式干净重连, 正是用户实测唯一可靠的方式。 Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -125,17 +125,17 @@ export default function InstanceView({ onOpenMenu }: { onOpenMenu: () => void })
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
const setMode = (m: 'forward' | 'seamless') => {
|
const setMode = (m: 'forward' | 'seamless') => {
|
||||||
setInputMode(m);
|
|
||||||
try {
|
try {
|
||||||
window.localStorage.setItem('woc_input_mode', m);
|
window.localStorage.setItem('woc_input_mode', m);
|
||||||
// 同步写好 enable_ime,供下面重挂的 iframe 里 noVNC 连接时读取
|
// 同步写好 enable_ime,重载后新页面的 noVNC 连接时即读到
|
||||||
window.localStorage.setItem('enable_ime', m === 'seamless' ? 'true' : 'false');
|
window.localStorage.setItem('enable_ime', m === 'seamless' ? 'true' : 'false');
|
||||||
} catch {
|
} catch {
|
||||||
/* 隐私模式禁用 localStorage:忽略 */
|
/* 隐私模式禁用 localStorage:忽略 */
|
||||||
}
|
}
|
||||||
// 关键:重挂 iframe 让 noVNC 重新读取 enable_ime。否则当前已连接的会话仍是旧模式,
|
// 整页重载切换:先卸载旧页面(彻底关闭旧 VNC ws),再以新 enable_ime 干净重连。
|
||||||
// 表现为"刚切到无感还是打出英文,要换页再回来才行"。
|
// 不能用页内 bump vncNonce 重挂 iframe——那会让新旧两条 ws 短暂并存,概率性把实例的 Xvnc 卡死
|
||||||
setVncNonce((n) => n + 1);
|
//(需重启容器才恢复、面板重启无效),且新连接常读不到新模式(仍是英文)。整页重载是实测唯一可靠的方式。
|
||||||
|
window.location.reload();
|
||||||
};
|
};
|
||||||
const [imeText, setImeText] = useState('');
|
const [imeText, setImeText] = useState('');
|
||||||
const [imeSending, setImeSending] = useState(false);
|
const [imeSending, setImeSending] = useState(false);
|
||||||
|
|||||||
Reference in New Issue
Block a user