feat: 推广 V3.5 实时氢耗并完善导出

This commit is contained in:
lingniu
2026-09-04 15:42:02 +08:00
parent a26179c8fe
commit e402eb5e60
53 changed files with 2855 additions and 320 deletions
@@ -1,5 +1,15 @@
import { afterEach, expect, test, vi } from 'vitest';
import { canAdminister, canOperate, clearAccessToken, getAccessToken, notifyUnauthorizedSession, PLATFORM_UNAUTHORIZED_EVENT, setAccessToken } from './session';
import {
canAdminister,
canOperate,
clearAccessToken,
getAccessToken,
hasMenu,
notifyUnauthorizedSession,
PLATFORM_UNAUTHORIZED_EVENT,
setAccessToken,
type PlatformSession,
} from './session';
afterEach(() => {
window.sessionStorage.clear();
@@ -21,6 +31,17 @@ test('role helpers follow the server permission hierarchy', () => {
expect(canAdminister({ name: 'a', role: 'admin', authMode: 'enforce' })).toBe(true);
});
test('an administrator can have account management removed explicitly', () => {
const session = {
role: 'admin',
userType: 'admin',
menuKeys: ['monitor', 'operations'],
} as PlatformSession;
expect(hasMenu(session, 'operations')).toBe(true);
expect(hasMenu(session, 'users')).toBe(false);
});
test('invalidates only the currently active rejected token', () => {
const unauthorized = vi.fn();
window.addEventListener(PLATFORM_UNAUTHORIZED_EVENT, unauthorized);