Редактор: превью с поворотом, проекты, безопасное сохранение zip, dev-меню
RotatedImage: размер контейнера через clientWidth/Height (не getBoundingClientRect), чтобы cover при 90°/270° работал под zoom React Flow; убраны отладочные логи. Главное меню в dev: пункт «Вид» с DevTools (Ctrl+Shift+I без пустого application menu). Список проектов: project.list без лицензии; список подгружается при неактивной лицензии; ProjectPicker с подсказками; listProjects пропускает битые zip. Сохранение проектов: atomicReplace — замена zip без rm до commit; восстановление *.dnd.zip.tmp при старте; тесты. EditorApp: блокировка UI при открытых окнах презентации и пульта; стили оверлея. Made-with: Cursor
This commit is contained in:
@@ -9,7 +9,7 @@ const here = path.dirname(fileURLToPath(import.meta.url));
|
||||
void test('projectState: list/get after delete invalidates in-flight initial load (epoch guard)', () => {
|
||||
const src = fs.readFileSync(path.join(here, 'projectState.ts'), 'utf8');
|
||||
assert.match(src, /projectDataEpochRef/);
|
||||
assert.match(src, /const epoch = projectDataEpochRef\.current/);
|
||||
assert.match(src, /const epoch = \+\+projectDataEpochRef\.current/);
|
||||
assert.match(src, /if \(projectDataEpochRef\.current !== epoch\) return/);
|
||||
assert.match(
|
||||
src,
|
||||
@@ -21,3 +21,8 @@ void test('projectState: list/get after delete invalidates in-flight initial loa
|
||||
);
|
||||
assert.match(src, /const refreshProjects = async \(\) => \{[\s\S]+?projectDataEpochRef\.current \+= 1/);
|
||||
});
|
||||
|
||||
void test('ipc router: project.list does not require license', () => {
|
||||
const routerSrc = fs.readFileSync(path.join(here, '..', '..', '..', 'main', 'ipc', 'router.ts'), 'utf8');
|
||||
assert.match(routerSrc, /if \(channel === ipcChannels\.project\.list\) return false/);
|
||||
});
|
||||
|
||||
@@ -131,7 +131,7 @@ export function useProjectState(licenseActive: boolean): readonly [State, Action
|
||||
|
||||
const closeProject = async () => {
|
||||
setState((s) => ({ ...s, project: null, selectedSceneId: null }));
|
||||
if (licenseActive) await refreshProjects();
|
||||
await refreshProjects();
|
||||
};
|
||||
|
||||
const createScene = async () => {
|
||||
@@ -385,24 +385,37 @@ export function useProjectState(licenseActive: boolean): readonly [State, Action
|
||||
exportProject,
|
||||
deleteProject,
|
||||
};
|
||||
}, [api, licenseActive]);
|
||||
}, [api]);
|
||||
|
||||
useEffect(() => {
|
||||
if (!licenseActive) {
|
||||
queueMicrotask(() => {
|
||||
projectDataEpochRef.current += 1;
|
||||
setState({ projects: [], project: null, selectedSceneId: null, zipProgress: null });
|
||||
});
|
||||
return;
|
||||
}
|
||||
const epoch = ++projectDataEpochRef.current;
|
||||
void (async () => {
|
||||
const epoch = projectDataEpochRef.current;
|
||||
const listRes = await api.invoke(ipcChannels.project.list, {});
|
||||
if (projectDataEpochRef.current !== epoch) return;
|
||||
setState((s) => ({ ...s, projects: listRes.projects }));
|
||||
const res = await api.invoke(ipcChannels.project.get, {});
|
||||
if (projectDataEpochRef.current !== epoch) return;
|
||||
setState((s) => ({ ...s, project: res.project, selectedSceneId: res.project?.currentSceneId ?? null }));
|
||||
try {
|
||||
const listRes = await api.invoke(ipcChannels.project.list, {});
|
||||
if (projectDataEpochRef.current !== epoch) return;
|
||||
if (!licenseActive) {
|
||||
setState((s) => ({
|
||||
...s,
|
||||
projects: listRes.projects,
|
||||
project: null,
|
||||
selectedSceneId: null,
|
||||
}));
|
||||
return;
|
||||
}
|
||||
setState((s) => ({ ...s, projects: listRes.projects }));
|
||||
const res = await api.invoke(ipcChannels.project.get, {});
|
||||
if (projectDataEpochRef.current !== epoch) return;
|
||||
setState((s) => ({
|
||||
...s,
|
||||
project: res.project,
|
||||
selectedSceneId: res.project?.currentSceneId ?? null,
|
||||
}));
|
||||
} catch {
|
||||
if (projectDataEpochRef.current !== epoch) return;
|
||||
if (!licenseActive) {
|
||||
setState((s) => ({ ...s, project: null, selectedSceneId: null }));
|
||||
}
|
||||
}
|
||||
})();
|
||||
}, [licenseActive, api]);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user