feat(web): restore candidate notice on home for logged-in users
This commit is contained in:
1 parent
0518397492
commit
ff88e91640
5 files changed
+39
-12
No files matched your search
@@ -0,0 +1,26 @@
|
||||
// 登录态与预览态的进程内共享状态。
|
||||
// app.js 在 boot 时写入,各视图(如 home.js)读取,避免重复请求 /api/session。
|
||||
|
||||
let state = { authEnabled: false, authenticated: true, preview: false };
|
||||
|
||||
export function setSession(data) {
|
||||
state = {
|
||||
authEnabled: Boolean(data?.auth_enabled),
|
||||
authenticated: data?.authenticated !== false,
|
||||
preview: Boolean(data?.preview),
|
||||
};
|
||||
return state;
|
||||
}
|
||||
|
||||
export function getSession() {
|
||||
return state;
|
||||
}
|
||||
|
||||
// 可访问「候选 / 系统」等受保护页面:未启用鉴权,或已登录。
|
||||
export function canAccessProtected() {
|
||||
return !state.authEnabled || state.authenticated;
|
||||
}
|
||||
|
||||
export function isPreview() {
|
||||
return state.preview;
|
||||
}
|
||||
Reference in new issue
Block a user