feat(离线): 界面离线可看 —— GET 响应本地缓存 + 同步凭证持久化 (离线不清库) + 左上角离线徽标 (与 Windows 外壳分支同源)

This commit is contained in:
jif2.zhang
2026-10-26 16:05:59 +08:00
parent 9f16db4286
commit f34c8c3bae
5 changed files with 199 additions and 17 deletions
+3 -1
View File
@@ -1,5 +1,5 @@
import { createContext, useContext, useEffect, useState } from 'react'
import { api, getToken, setToken, setRememberFlag, setCurrentUserId } from '../api/client.js'
import { api, getToken, setToken, setRememberFlag, setCurrentUserId, clearApiCache } from '../api/client.js'
import { disconnectAndClearPowersync } from '../lib/powersync/db.js'
const AuthContext = createContext(null)
@@ -51,6 +51,8 @@ export function AuthProvider({ children }) {
setRememberFlag(false)
setUser(null)
setCurrentUserId('')
try { clearApiCache() } catch { /* ignore */ }
try { localStorage.removeItem('iboard_ps_cred') } catch { /* ignore */ }
// 断开同步并清空本地 SQLite (0.2.1 离线编辑)
try { await disconnectAndClearPowersync() } catch { /* ignore */ }
}