refactor: clean up unused code and simplify imports

- Remove unused imports and variables across 35 files
- Simplify component logic and remove dead code
- Clean up test files by removing unnecessary setup
- Streamline CI workflow configuration

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
雨霖铃
2026-05-28 20:57:08 +08:00
parent e140af7698
commit ca4bfc33fd
35 changed files with 26 additions and 146 deletions
-12
View File
@@ -4,27 +4,15 @@ import { decodeBase64Url, parseJwt } from '@/utils/jwt';
describe('jwt utils', () => {
describe('decodeBase64Url', () => {
it('should decode standard base64url', () => {
// "test" -> "dGVzdA"
expect(decodeBase64Url('dGVzdA')).toBe('test');
});
it('should handle padding correctly', () => {
// "a" -> "YQ" (needs ==)
expect(decodeBase64Url('YQ')).toBe('a');
// "ab" -> "YWI" (needs =)
expect(decodeBase64Url('YWI')).toBe('ab');
});
it('should handle - and _ correctly', () => {
// Validating base64url specific chars
// standard base64 of binary 0xFF 0xEF is "/+8="
// base64url should be "_-8"
// Wait, let's use a simpler one.
// 0xFB 0xFF -> "+/8=" in base64, "-_8=" in base64url? No.
// + -> -
// / -> _
// let's try to encode something that results in + and /
// binary 0xFB 0xFF 0xBE -> "+/++" in base64 -> "-_--" in base64url
expect(decodeBase64Url('-_--')).toBeDefined();
});
+2 -3
View File
@@ -55,7 +55,7 @@ describe('useStorageState', () => {
await waitFor(() => {
// 异步加载后应覆盖为存储值
expect(result.current[0]).toBe(false);
expect(result.current[2]).toBe(true); // isInitialized
expect(result.current[2]).toBe(true);
});
});
@@ -67,7 +67,7 @@ describe('useStorageState', () => {
const { result } = renderHook(() => useStorageState('qrCode/urlExpanded', true));
await waitFor(() => {
expect(result.current[2]).toBe(true); // isInitialized
expect(result.current[2]).toBe(true);
});
await act(async () => {
@@ -77,7 +77,6 @@ describe('useStorageState', () => {
expect(result.current[0]).toBe(false);
expect(storageUtil.set).toHaveBeenCalledWith('qrCode/urlExpanded', false);
// 应同时写入 localStorage 快照
expect(localStorage.getItem('snapshot/qrCode/urlExpanded')).toBe(JSON.stringify(false));
});