docs: annotate all shared frontend modules in Chinese
This commit is contained in:
1 parent
2be21c1c62
commit
408f8e5c98
55 files changed
+349
No files matched your search
@@ -1,3 +1,4 @@
|
||||
/** 同源多标签页会话同步:监听 jwt/clear 变更,退出时将当前受保护页面替换为登录页。 */
|
||||
import { defineNuxtPlugin } from "#app";
|
||||
import { useAuth, isValidJwt } from "~/lib/auth.js";
|
||||
import { r as safeRedirect } from "~/lib/auth-redirect.js";
|
||||
@@ -9,6 +10,7 @@ export default defineNuxtPlugin({
|
||||
setup(app) {
|
||||
const auth = useAuth();
|
||||
const router = app.$router;
|
||||
// 只处理 localStorage 会话事件;读取最新值而非 event.newValue,避免积压事件倒退状态。
|
||||
function reconcileSession(event) {
|
||||
if (
|
||||
event.storageArea !== localStorage ||
|
||||
@@ -30,6 +32,7 @@ export default defineNuxtPlugin({
|
||||
}
|
||||
}
|
||||
window.addEventListener("storage", reconcileSession);
|
||||
// 应用销毁时解绑,避免热重载或重新挂载后叠加处理同一 storage 事件。
|
||||
app.vueApp.onUnmount(() =>
|
||||
window.removeEventListener("storage", reconcileSession),
|
||||
);
|
||||
|
||||
Reference in new issue
Block a user