diff --git a/src/views/personal-settings-view.jsx b/src/views/personal-settings-view.jsx index f0784315..929a62e4 100644 --- a/src/views/personal-settings-view.jsx +++ b/src/views/personal-settings-view.jsx @@ -297,7 +297,7 @@ function SettingsList({onToast, onLogout, tinode, chatList, onDeleteAccount}) { // 但因为底下真的没有任何东西在渲染,视觉上跟直接跳转到一个空白新页面没有区别。改成本组件自己的 // 本地 state,弹层作为兄弟节点叠在列表上方,列表本身不卸载——group-management-view.jsx 的 // OwnerSelect(选择新群主)已经是这个正确模式,这里照抄,不是发明新写法。 - const [sheet, setSheet] = React.useState(null); // null | 'cache' | 'history' | 'delete' + const [sheet, setSheet] = React.useState(null); // null | 'cache' | 'history' | 'delete' | 'logout' React.useEffect(() => { getYouthMode().then(d => { writeCachedData('youth-mode', d); setYouthSettings(d); }).catch(() => {}); getRealnameStatus().then(d => { writeCachedData('me-realname', d); setRealname(d); }).catch(() => {}); @@ -305,11 +305,6 @@ function SettingsList({onToast, onLogout, tinode, chatList, onDeleteAccount}) { const youthEnabled = youthSettings ? youthSettings.enabled : null; const realnameStatus = realname ? realname.status : null; const realnameLabel = {verified: '已认证', pending: '审核中', rejected: '未通过'}[realnameStatus] || '未认证'; - const logout = () => { - if (window.confirm('确定要退出当前登录吗?')) { - onLogout ? onLogout() : onToast('当前环境不支持退出登录'); - } - }; return
setSheet('cache')} /> @@ -329,11 +324,12 @@ function SettingsList({onToast, onLogout, tinode, chatList, onDeleteAccount}) {
setSheet('delete')} danger />
- +
{sheet === 'cache' ? setSheet(null)} /> : null} {sheet === 'history' ? setSheet(null)} /> : null} {sheet === 'delete' ? setSheet(null)} /> : null} + {sheet === 'logout' ? setSheet(null)} /> : null}
; } @@ -346,6 +342,20 @@ function ConfirmSheet({icon, title, body, confirmLabel = '确认', confirmDanger ; } +// Was a bare `window.confirm()` -- the only one of these four confirmation flows not using this +// same ConfirmSheet pattern, an inconsistency with cache/history/delete-account below (their own +// comments describe deliberately moving away from route-per-confirmation dialogs to this in-place +// sheet). A native confirm() is also environment-dependent: some embedded WebViews/kiosk contexts +// disable synchronous dialogs outright (confirm() then returns false unconditionally, silently +// preventing logout with no error shown), which this sheet-based approach doesn't depend on. +function LogoutConfirm({onLogout, onToast, onClose}) { + const confirm = () => { + onClose(); + onLogout ? onLogout() : onToast('当前环境不支持退出登录'); + }; + return ; +} + // No backend endpoint clears cache/history -- both are pure client-side operations (confirmed: // server/main.go's ~74 routes have nothing for either). Cache clearing empties Cache Storage/IDB; // clearing all history calls the native Tinode delMessagesAll(false) per open conversation, same