Skip to content

Commit 8cb39d9

Browse files
read text debug for template
1 parent 40aa72f commit 8cb39d9

3 files changed

Lines changed: 26 additions & 1 deletion

File tree

packages/webgal/src/Core/Modules/readHistory.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,15 @@ import { setReadHistory } from "@/store/userDataReducer";
88
import { setStorage } from "../controller/storage/storageController";
99
import { stageStateManager } from '@/Core/Modules/stage/stageStateManager';
1010

11+
let debugTextReadMode: boolean | null = null;
12+
13+
export function setDebugTextReadMode(isRead: boolean | null) {
14+
debugTextReadMode = isRead;
15+
if (isRead !== null) {
16+
stageStateManager.setStageAndCommit('isRead', isRead);
17+
}
18+
}
19+
1120
export class ReadHistoryManager {
1221
private history: Map<string, Uint8Array> = new Map();
1322

@@ -107,7 +116,7 @@ export class ReadHistoryManager {
107116
const bitset = this.history.get(scenarioName)!;
108117
isRead = (bitset[index >> 3] & (1 << (index & 7))) !== 0;
109118
}
110-
stageStateManager.setStage('isRead', isRead);
119+
stageStateManager.setStage('isRead', debugTextReadMode ?? isRead);
111120
if (!isRead) {
112121
this.addReadHistory();
113122
}

packages/webgal/src/Core/util/syncWithEditor/webSocketFunc.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import {
22
DebugCommand,
33
IComponentVisibilityCommand,
44
IDebugMessage,
5+
ITextReadModeCommand,
56
type IFastPreviewTimeoutPayload,
67
} from '@/types/debugProtocol';
78
import { webgalStore } from '@/store/store';
@@ -16,6 +17,7 @@ import { logger } from '@/Core/util/logger';
1617
import { syncWithOrigine } from './syncWithOrigine';
1718
import { baseTransform, IEffect } from '@/Core/Modules/stage/stageInterface';
1819
import { stageStateManager } from '@/Core/Modules/stage/stageStateManager';
20+
import { setDebugTextReadMode } from '@/Core/Modules/readHistory';
1921

2022
let editorSocket: WebSocket | null = null;
2123

@@ -158,6 +160,14 @@ export const webSocketFunc = () => {
158160
return;
159161
}
160162
}
163+
if (message.command === DebugCommand.SET_TEXT_READ_MODE) {
164+
try {
165+
const command = JSON.parse(message.message) as ITextReadModeCommand;
166+
setDebugTextReadMode(command.isRead);
167+
} catch (e) {
168+
logger.error(`无法设置文本已读显示模式 ${message.message}, ${e}`);
169+
}
170+
}
161171
};
162172
socket.onerror = () => {
163173
editorSocket = null;

packages/webgal/src/types/debugProtocol.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ export enum DebugCommand {
2121
SET_EFFECT,
2222
// 实时预览快进超时
2323
FAST_PREVIEW_TIMEOUT,
24+
// 设置文本已读显示模式
25+
SET_TEXT_READ_MODE,
2426
}
2527

2628
export interface IFastPreviewTimeoutPayload {
@@ -64,3 +66,7 @@ export interface IComponentVisibilityCommand {
6466
component: keyof IComponentsVisibility;
6567
visibility: boolean;
6668
}
69+
70+
export interface ITextReadModeCommand {
71+
isRead: boolean;
72+
}

0 commit comments

Comments
 (0)