我想添加一个+layout.server.ts
在每次导航操作中调用的 JWT 验证/刷新。
我有以下代码,并注意到该console.log()
语句仅当我使用 F5 重新加载页面时运行,而不是通过锚标记导航时运行。
import type { LayoutServerLoad } from './$types';
export const load: LayoutServerLoad = async ({ cookies }) => {
console.log("running layout on server");
};
如何才能使每次导航时都调用加载函数?
据我所知,
load
只有当函数所依赖的参数发生变化(或被invalidateAll
调用)时,函数才会重新运行。这种逻辑可能更适合
handle
钩子。