镜像自地址
https://github.com/lhly/cloud-drive-renamer.git
已同步 2026-10-20 21:57:47 +08:00
- 在平台适配器中统一暴露 getCurrentDirectoryKey() 方法,用于确定当前目录范围 - 新增 LastRenameOperation 数据模型和核心操作函数,支持单条撤销记录的创建、合并和范围校验 - 在 file-selector-panel 中集成撤销逻辑,支持执行后保存记录、retry 成功后合并记录以及撤销操作 - 在 config-panel 底部操作区新增撤销按钮,根据当前目录范围动态显示/隐藏 - 添加多语言支持,包含撤销相关文案 - 添加单元测试和集成测试,确保撤销功能的正确性和稳定性
55 行
1.5 KiB
TypeScript
55 行
1.5 KiB
TypeScript
import { beforeEach, describe, expect, it, vi } from 'vitest';
|
|
import { QuarkAdapter } from '../../src/adapters/quark/quark';
|
|
import { AliyunAdapter } from '../../src/adapters/aliyun/aliyun-adapter';
|
|
import { BaiduAdapter } from '../../src/adapters/baidu/baidu-adapter';
|
|
|
|
describe('current directory scope', () => {
|
|
beforeEach(() => {
|
|
vi.restoreAllMocks();
|
|
});
|
|
|
|
it('QuarkAdapter should expose current directory key from query string', () => {
|
|
Object.defineProperty(window, 'location', {
|
|
value: {
|
|
search: '?dir_id=test-dir-123',
|
|
hash: '',
|
|
},
|
|
writable: true,
|
|
configurable: true,
|
|
});
|
|
|
|
const adapter = new QuarkAdapter();
|
|
|
|
expect(adapter.getCurrentDirectoryKey()).toBe('test-dir-123');
|
|
});
|
|
|
|
it('AliyunAdapter should expose current directory key from pathname', () => {
|
|
Object.defineProperty(window, 'location', {
|
|
value: {
|
|
pathname: '/drive/file/all/66f55e9a8b9c4d0eaa11223344556677',
|
|
},
|
|
writable: true,
|
|
configurable: true,
|
|
});
|
|
|
|
const adapter = new AliyunAdapter();
|
|
|
|
expect(adapter.getCurrentDirectoryKey()).toBe('66f55e9a8b9c4d0eaa11223344556677');
|
|
});
|
|
|
|
it('BaiduAdapter should expose current directory key from decoded path query', () => {
|
|
Object.defineProperty(window, 'location', {
|
|
value: {
|
|
search: '?path=%2Fvideo%2Fseason1',
|
|
hash: '',
|
|
},
|
|
writable: true,
|
|
configurable: true,
|
|
});
|
|
|
|
const adapter = new BaiduAdapter();
|
|
|
|
expect(adapter.getCurrentDirectoryKey()).toBe('/video/season1');
|
|
});
|
|
});
|