seewo-kit: 云端代理探活 + shell 直连回退,修复写操作永久挂起
云端 MCP(7916) 对单个 shell 的转发会永久阻塞且不报超时:实测 130s 无响应, 期间云端没有向 shell 端口发起 TCP,shell 日志也没有请求记录;而该 shell 自己的 MCP 端口(从 Log\<时间>,<pid>\last_info.txt 读取)读写/截图均 10-130ms 正常。 - 新增 callShellTool/routeFor:每个 shell 首次调用做 4s 探活,云端超时即自动 改走直连端口;单次调用中途超时也立刻降级,不再让调用方干等 - 路由按 shell 缓存,失败 15s 后重试;shell 重启导致端口变化时自动重新发现 - diagnose_courseware 输出 live.shells[].transport(cloud/direct/端口), 新增 proxy-dead 警告;写操作与 export_slides 结果附带 transport - 修正“渲染线程卡死”的误判文案 - README 增补坑 16
This commit is contained in:
+301
-28
@@ -47,19 +47,55 @@ const stamp = () => {
|
||||
const isSlidePath = p => SLIDE_RE.test(String(p || '').replace(/\//g, '\\'));
|
||||
|
||||
// ---------------------------------------------------------------- 希沃 MCP 客户端
|
||||
let sessionId = null;
|
||||
let rpcId = 100;
|
||||
let initialized = false;
|
||||
//
|
||||
// 希沃有两层 MCP:
|
||||
// · 云端(7916,Cloud MCP,宿主是主窗口进程)只有 11 个 en_* / 云课件工具,
|
||||
// 其余 52 个「shell 工具」是它转发给某个课件窗口进程(shell)去执行的;
|
||||
// · 每个 shell 进程自己也有一个完整的 MCP 服务,端口随机,启动时会写进日志。
|
||||
//
|
||||
// 云端那条转发链【没有超时】:某个 shell 的代理一旦失效,所有带 shellId 的调用都会永久挂住
|
||||
// (实测 130 秒无响应,且 shell 侧收不到任何请求,连 TCP 都没连)。这会让写操作既写不进去,
|
||||
// 又长时间不报错。所以这里对每个 shell 做一次探活:代理不通就自动改走该 shell 的直连端口。
|
||||
// 直连端口从 %APPDATA%\Seewo\EasiNote5\Log\<时间>,<pid>\last_info.txt 里读取。
|
||||
const LOG_ROOT = path.join(os.homedir(), 'AppData', 'Roaming', 'Seewo', 'EasiNote5', 'Log');
|
||||
const PORT_RE = /Shell MCP server started on port:\s*(\d+)/g;
|
||||
const LISTEN_RE = /Listening on http:\/\/(?:127\.0\.0\.1|\[::1\]):(\d+)\//;
|
||||
|
||||
async function post(body, timeoutMs = 30000) {
|
||||
/** 只有云端才有的工具;其余工具在 shell 直连端口上也有,可以走直连 */
|
||||
const CLOUD_ONLY = new Set([
|
||||
'en_find_shells', 'en_bind_shell', 'en_goto_app_ui',
|
||||
'new_cloud_courseware', 'new_cloud_courseware_from_pptx', 'open_cloud_courseware',
|
||||
'search_cloud_courseware', 'generate_video_from_pptx',
|
||||
'ensys_open_file', 'switch_to_display_board_mode', 'recognition_document_and_goto_page',
|
||||
]);
|
||||
|
||||
const PROBE_TIMEOUT_MS = 4000;
|
||||
const DEFAULT_TIMEOUT_MS = 30000;
|
||||
|
||||
let rpcId = 100;
|
||||
const sessions = new Map(); // port -> { sid, initialized, rpcId }
|
||||
const routes = new Map(); // shellId -> { kind: 'cloud'|'direct'|'dead', port, reason, at }
|
||||
const shellPorts = new Map(); // shellId -> { port, dir }
|
||||
|
||||
function sessionOf(port) {
|
||||
let st = sessions.get(port);
|
||||
if (!st) {
|
||||
st = { sid: null, initialized: false };
|
||||
sessions.set(port, st);
|
||||
}
|
||||
return st;
|
||||
}
|
||||
|
||||
async function postTo(port, body, timeoutMs = DEFAULT_TIMEOUT_MS) {
|
||||
const st = sessionOf(port);
|
||||
const headers = { 'Content-Type': 'application/json', Accept: 'application/json, text/event-stream' };
|
||||
if (sessionId) headers['Mcp-Session-Id'] = sessionId;
|
||||
const res = await fetch(`http://127.0.0.1:${MCP_PORT}/mcp`, {
|
||||
if (st.sid) headers['Mcp-Session-Id'] = st.sid;
|
||||
const res = await fetch(`http://127.0.0.1:${port}/mcp`, {
|
||||
method: 'POST', headers, body: JSON.stringify(body),
|
||||
signal: AbortSignal.timeout(timeoutMs),
|
||||
});
|
||||
const sid = res.headers.get('mcp-session-id');
|
||||
if (sid) sessionId = sid;
|
||||
if (sid) st.sid = sid;
|
||||
const text = await res.text();
|
||||
if (text.includes('data:')) {
|
||||
const data = text.split('\n').filter(l => l.startsWith('data:')).map(l => l.slice(5).trim()).join('');
|
||||
@@ -68,33 +104,214 @@ async function post(body, timeoutMs = 30000) {
|
||||
try { return JSON.parse(text); } catch { return { raw: text }; }
|
||||
}
|
||||
|
||||
async function rpc(name, args = {}, { timeoutMs } = {}) {
|
||||
const r = await post({ jsonrpc: '2.0', id: rpcId++, method: 'tools/call', params: { name, arguments: args } }, timeoutMs);
|
||||
async function ensureInitOn(port, timeoutMs = DEFAULT_TIMEOUT_MS) {
|
||||
const st = sessionOf(port);
|
||||
if (st.initialized) return;
|
||||
await postTo(port, {
|
||||
jsonrpc: '2.0', id: 1, method: 'initialize',
|
||||
params: { protocolVersion: '2025-06-18', capabilities: {}, clientInfo: { name: 'seewo-kit', version: '1.1' } },
|
||||
}, timeoutMs);
|
||||
await postTo(port, { jsonrpc: '2.0', method: 'notifications/initialized' }, timeoutMs);
|
||||
st.initialized = true;
|
||||
}
|
||||
|
||||
async function rpcOn(port, name, args = {}, timeoutMs = DEFAULT_TIMEOUT_MS) {
|
||||
await ensureInitOn(port, timeoutMs);
|
||||
const r = await postTo(port, {
|
||||
jsonrpc: '2.0', id: rpcId++, method: 'tools/call', params: { name, arguments: args },
|
||||
}, timeoutMs);
|
||||
if (r.error) throw new Error(`${name}: ${JSON.stringify(r.error)}`);
|
||||
const txt = (r.result?.content ?? []).filter(c => c.type === 'text').map(c => c.text).join('\n');
|
||||
if (r.result?.isError) throw new Error(`${name}: ${txt}`);
|
||||
return { text: txt, data: r.result?.structuredContent };
|
||||
}
|
||||
|
||||
async function ensureInit() {
|
||||
if (initialized) return;
|
||||
await post({
|
||||
jsonrpc: '2.0', id: 1, method: 'initialize',
|
||||
params: { protocolVersion: '2025-06-18', capabilities: {}, clientInfo: { name: 'seewo-kit', version: '1.0' } },
|
||||
});
|
||||
await post({ jsonrpc: '2.0', method: 'notifications/initialized' });
|
||||
initialized = true;
|
||||
const ensureInit = () => ensureInitOn(MCP_PORT);
|
||||
const rpc = (name, args, { timeoutMs } = {}) => rpcOn(MCP_PORT, name, args, timeoutMs);
|
||||
|
||||
/** 超时 / 连不上,才算「这条链路坏了」;业务报错说明对面是通的 */
|
||||
function isTransportError(e) {
|
||||
const n = String(e?.name || '');
|
||||
const m = String(e?.message || '');
|
||||
return n === 'TimeoutError' || n === 'AbortError'
|
||||
|| /aborted due to timeout|fetch failed|ECONNREFUSED|ECONNRESET|other side closed|socket/i.test(m);
|
||||
}
|
||||
|
||||
async function mcp(name, args = {}, { timeoutMs } = {}) {
|
||||
/** 找 shell 进程的日志目录(目录名形如 20261123_102339,7568) */
|
||||
function shellLogDirs(shellId) {
|
||||
if (!existsSync(LOG_ROOT)) return [];
|
||||
const want = String(shellId);
|
||||
const out = [];
|
||||
for (const name of readdirSync(LOG_ROOT)) {
|
||||
const m = name.match(/(?:,|_)(\d+)$/);
|
||||
if (!m || m[1] !== want) continue;
|
||||
const dir = path.join(LOG_ROOT, name);
|
||||
try { if (!statSync(dir).isDirectory()) continue; } catch { continue; }
|
||||
out.push({ name, dir });
|
||||
}
|
||||
// 目录名自带时间戳,倒序即最新在前
|
||||
out.sort((a, b) => b.name.localeCompare(a.name));
|
||||
return out;
|
||||
}
|
||||
|
||||
/** 从日志里取这个 shell 的直连 MCP 端口 */
|
||||
function discoverShellPort(shellId, { fresh = false } = {}) {
|
||||
const id = String(shellId);
|
||||
if (!fresh) {
|
||||
const cached = shellPorts.get(id);
|
||||
if (cached) return cached.port;
|
||||
}
|
||||
for (const { dir } of shellLogDirs(id)) {
|
||||
for (const file of ['last_info.txt', 'all_info.txt']) {
|
||||
const f = path.join(dir, file);
|
||||
if (!existsSync(f)) continue;
|
||||
const txt = readFileSync(f, 'utf8');
|
||||
const hits = [...txt.matchAll(PORT_RE)];
|
||||
const port = hits.length ? hits[hits.length - 1][1] : txt.match(LISTEN_RE)?.[1];
|
||||
if (port) {
|
||||
shellPorts.set(id, { port, dir });
|
||||
return port;
|
||||
}
|
||||
}
|
||||
}
|
||||
shellPorts.delete(id);
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 直连调用:shell 服务本来就是「当前课件」作用域,shellId 要脱掉
|
||||
* (带上反而可能被判成 shellId 与绑定窗口不一致)。
|
||||
*/
|
||||
async function directRpc(port, name, args = {}, timeoutMs = DEFAULT_TIMEOUT_MS) {
|
||||
const once = async (a) => {
|
||||
try {
|
||||
return await rpcOn(port, name, a, timeoutMs);
|
||||
} catch (e) {
|
||||
// 端口被复用时旧会话会失效,重握手一次
|
||||
if (/session|会话/i.test(String(e.message))) {
|
||||
const st = sessionOf(port);
|
||||
st.sid = null;
|
||||
st.initialized = false;
|
||||
return await rpcOn(port, name, a, timeoutMs);
|
||||
}
|
||||
throw e;
|
||||
}
|
||||
};
|
||||
const clean = { ...args };
|
||||
const hadShell = Object.prototype.hasOwnProperty.call(clean, 'shellId');
|
||||
delete clean.shellId;
|
||||
try {
|
||||
return await once(clean);
|
||||
} catch (e) {
|
||||
if (hadShell && /shellId|绑定|绑定的|Usage error|请先调用/i.test(String(e.message))) {
|
||||
return await once(args);
|
||||
}
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
/** 判断这个 shell 该走云端还是直连;结果按 shell 缓存,避免每次都等超时 */
|
||||
async function routeFor(shellId) {
|
||||
const id = String(shellId);
|
||||
const cached = routes.get(id);
|
||||
if (cached && cached.kind !== 'dead') return cached;
|
||||
// 已知彻底不通时不要每次调用都重等两轮探测,15 秒后再试
|
||||
if (cached && cached.kind === 'dead' && Date.now() - (cached.at ?? 0) < 15000) return cached;
|
||||
|
||||
let cloudError = null;
|
||||
try {
|
||||
await rpcOn(MCP_PORT, 'get_current_courseware_info', { shellId: id }, PROBE_TIMEOUT_MS);
|
||||
const r = { kind: 'cloud', port: discoverShellPort(id), at: Date.now() };
|
||||
routes.set(id, r);
|
||||
return r;
|
||||
} catch (e) {
|
||||
if (!isTransportError(e)) {
|
||||
// 有业务返回,说明云端代理是通的
|
||||
const r = { kind: 'cloud', port: discoverShellPort(id), at: Date.now() };
|
||||
routes.set(id, r);
|
||||
return r;
|
||||
}
|
||||
cloudError = e;
|
||||
}
|
||||
|
||||
const port = discoverShellPort(id, { fresh: true });
|
||||
if (port) {
|
||||
try {
|
||||
await rpcOn(port, 'get_current_courseware_info', {}, PROBE_TIMEOUT_MS);
|
||||
const r = { kind: 'direct', port, reason: `云端代理无响应(${cloudError.message}),改走直连 ${port}`, at: Date.now() };
|
||||
routes.set(id, r);
|
||||
return r;
|
||||
} catch (e) {
|
||||
cloudError = new Error(`${cloudError.message};直连 ${port} 也失败:${e.message}`);
|
||||
}
|
||||
}
|
||||
const r = { kind: 'dead', port, reason: String(cloudError?.message || '未知'), at: Date.now() };
|
||||
routes.set(id, r);
|
||||
return r;
|
||||
}
|
||||
|
||||
/** 带 shellId 的工具调用:云端代理坏了就自动改直连 */
|
||||
async function callShellTool(name, args = {}, { timeoutMs = DEFAULT_TIMEOUT_MS, shellId } = {}) {
|
||||
const id = String(shellId);
|
||||
const route = await routeFor(id);
|
||||
|
||||
if (route.kind === 'dead') {
|
||||
throw new Error(
|
||||
`云端 MCP 到 shell ${id} 的代理没有响应,也找不到可用的直连端口。`
|
||||
+ `原因:${route.reason}。请重启希沃白板后重试。`,
|
||||
);
|
||||
}
|
||||
|
||||
if (route.kind === 'cloud') {
|
||||
try {
|
||||
return await rpcOn(MCP_PORT, name, args, timeoutMs);
|
||||
} catch (e) {
|
||||
if (!isTransportError(e)) throw e;
|
||||
// 探活通过但这次仍超时:立即降级,别让调用方干等
|
||||
const port = discoverShellPort(id, { fresh: true });
|
||||
if (port) {
|
||||
try {
|
||||
const r = await directRpc(port, name, args, timeoutMs);
|
||||
routes.set(id, { kind: 'direct', port, reason: `云端代理超时(${e.message}),改走直连 ${port}`, at: Date.now() });
|
||||
return r;
|
||||
} catch (e2) {
|
||||
routes.set(id, { kind: 'dead', port, reason: `${e.message};直连失败:${e2.message}`, at: Date.now() });
|
||||
throw e2;
|
||||
}
|
||||
}
|
||||
routes.set(id, { kind: 'dead', port: null, reason: e.message, at: Date.now() });
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
return await directRpc(route.port, name, args, timeoutMs);
|
||||
} catch (e) {
|
||||
// shell 重启后端口会变,重新发现一次
|
||||
const port = discoverShellPort(id, { fresh: true });
|
||||
if (port && port !== route.port) {
|
||||
const r = await directRpc(port, name, args, timeoutMs);
|
||||
routes.set(id, { kind: 'direct', port, at: Date.now() });
|
||||
return r;
|
||||
}
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
async function mcp(name, args = {}, { timeoutMs, direct = false } = {}) {
|
||||
const shellId = args && args.shellId != null ? String(args.shellId) : null;
|
||||
if (!direct && shellId && !CLOUD_ONLY.has(name)) {
|
||||
return callShellTool(name, args, { timeoutMs: timeoutMs ?? DEFAULT_TIMEOUT_MS, shellId });
|
||||
}
|
||||
await ensureInit();
|
||||
try {
|
||||
return await rpc(name, args, { timeoutMs });
|
||||
} catch (e) {
|
||||
// 会话过期时重新握手一次
|
||||
if (/session|会话|ShellId/i.test(String(e.message))) {
|
||||
sessionId = null;
|
||||
initialized = false;
|
||||
if (/session|会话/i.test(String(e.message))) {
|
||||
const st = sessionOf(MCP_PORT);
|
||||
st.sid = null;
|
||||
st.initialized = false;
|
||||
await ensureInit();
|
||||
return await rpc(name, args, { timeoutMs });
|
||||
}
|
||||
@@ -102,6 +319,40 @@ async function mcp(name, args = {}, { timeoutMs } = {}) {
|
||||
}
|
||||
}
|
||||
|
||||
/** 给结果用:这个 shell 当前实际走的链路(cloud / direct) */
|
||||
export function shellRouteOf(shellId) {
|
||||
const r = routes.get(String(shellId));
|
||||
if (!r) return null;
|
||||
return { kind: r.kind, port: r.port ?? null, ...(r.reason ? { reason: r.reason } : {}) };
|
||||
}
|
||||
|
||||
/** 给 diagnose 用:这个 shell 的云端代理 / 直连端口各自是否可用 */
|
||||
export async function shellTransportOf(shellId) {
|
||||
const id = String(shellId);
|
||||
let cloud;
|
||||
try {
|
||||
const info = await rpcOn(MCP_PORT, 'get_current_courseware_info', { shellId: id }, PROBE_TIMEOUT_MS);
|
||||
cloud = { ok: true, info };
|
||||
} catch (e) {
|
||||
cloud = { ok: false, error: e.message };
|
||||
}
|
||||
const port = discoverShellPort(id, { fresh: true });
|
||||
let direct = { ok: false, port: port ?? null, ...(port ? {} : { error: '日志里没有找到该 shell 的 MCP 端口' }) };
|
||||
if (port) {
|
||||
try {
|
||||
const info = await rpcOn(port, 'get_current_courseware_info', {}, PROBE_TIMEOUT_MS);
|
||||
direct = { ok: true, port, info };
|
||||
} catch (e) {
|
||||
direct = { ok: false, port, error: e.message };
|
||||
}
|
||||
}
|
||||
// 顺便把探活结果写进路由缓存,diagnose 之后的调用不用再等一次超时
|
||||
if (cloud.ok) routes.set(id, { kind: 'cloud', port: direct.port ?? null, at: Date.now() });
|
||||
else if (direct.ok) routes.set(id, { kind: 'direct', port, reason: `云端代理无响应(${cloud.error}),改走直连 ${port}`, at: Date.now() });
|
||||
else routes.set(id, { kind: 'dead', port: direct.port ?? null, reason: String(cloud.error || direct.error || '未知'), at: Date.now() });
|
||||
return { cloud, direct, route: routes.get(id) ?? null };
|
||||
}
|
||||
|
||||
const shells = () => mcp('en_find_shells', { searchingMode: 'All' })
|
||||
.then(r => r.data?.shells ?? [])
|
||||
.catch(() => []);
|
||||
@@ -1102,6 +1353,10 @@ async function ensureEditMode(shellId, { timeoutMs = 20000 } = {}) {
|
||||
let mode = null;
|
||||
let tries = 0;
|
||||
while (Date.now() < deadline) {
|
||||
// 首选云端窗口列表里的 workingMode(直连端口的 get_current_courseware_info 不带 shellContext)
|
||||
const cur = (await shells()).find(s => String(s.id) === String(shellId));
|
||||
mode = cur?.workingMode ?? mode;
|
||||
if (mode === 'Edit') return true;
|
||||
const info = await mcp('get_current_courseware_info', { shellId }, { timeoutMs: 12000 }).catch(() => null);
|
||||
mode = infoOf(info)?.shellContext?.workingMode ?? mode;
|
||||
if (mode === 'Edit') return true;
|
||||
@@ -1197,6 +1452,7 @@ async function runEdit(cw, opts, action) {
|
||||
...(warnings.length ? { warnings } : {}),
|
||||
reopened: !!shellId,
|
||||
shellId,
|
||||
...(shellId ? { transport: shellRouteOf(shellId) } : {}),
|
||||
sync: syncText,
|
||||
};
|
||||
});
|
||||
@@ -2485,9 +2741,17 @@ export async function diagnoseCourseware({ courseware, checkRender = false, rend
|
||||
const list = (await shells()).filter(s => sameCourseware(s, cw));
|
||||
const details = [];
|
||||
for (const s of list) {
|
||||
const info = await mcp('get_current_courseware_info', { shellId: s.id }, { timeoutMs: 12000 }).catch(() => null);
|
||||
const tr = await shellTransportOf(s.id);
|
||||
const info = tr.cloud.ok ? tr.cloud.info : (tr.direct.ok ? tr.direct.info : null);
|
||||
const d = infoOf(info) ?? {};
|
||||
if (!info) {
|
||||
if (!tr.cloud.ok && tr.direct.ok) {
|
||||
push('warn', 'proxy-dead',
|
||||
`shell ${s.id} 的云端 MCP 代理无响应(${tr.cloud.error}),kit 已自动改走直连端口 ${tr.direct.port};`
|
||||
+ '写操作仍可用,但云端代理要重启希沃才会恢复');
|
||||
} else if (!tr.cloud.ok && !tr.direct.ok) {
|
||||
push('error', 'shell-unreachable',
|
||||
`shell ${s.id} 的云端代理和直连端口都不可用(云端:${tr.cloud.error};直连:${tr.direct.error ?? '无端口'});此时不要写课件`);
|
||||
} else if (!info) {
|
||||
push('warn', 'shell-unresponsive', `shell ${s.id} 12 秒内没有响应(可能正在渲染、切换界面或关闭),此时不要写课件`);
|
||||
}
|
||||
details.push({
|
||||
@@ -2496,6 +2760,13 @@ export async function diagnoseCourseware({ courseware, checkRender = false, rend
|
||||
pages: typeof d.slideCount === 'number' ? d.slideCount : null,
|
||||
size: typeof d.size === 'number' ? d.size : null,
|
||||
remoteId: d.remoteId ?? null,
|
||||
transport: {
|
||||
cloud: tr.cloud.ok ? 'ok' : 'dead',
|
||||
...(tr.cloud.ok ? {} : { cloudError: tr.cloud.error }),
|
||||
direct: tr.direct.ok ? 'ok' : 'dead',
|
||||
directPort: tr.direct.port ?? null,
|
||||
...(tr.direct.ok ? {} : (tr.direct.error ? { directError: tr.direct.error } : {})),
|
||||
},
|
||||
});
|
||||
}
|
||||
live = { open: details.length, shells: details };
|
||||
@@ -2538,7 +2809,7 @@ export async function diagnoseCourseware({ courseware, checkRender = false, rend
|
||||
if (!render.ok) push('warn', 'render', `截图只拿到 ${bytes} 字节,渲染可能没起来`);
|
||||
} catch (e) {
|
||||
render = { ok: false, page: renderPage, ms: Date.now() - startedAt, error: e.message };
|
||||
push('error', 'render', `截图接口 ${timeoutSec} 秒没返回,渲染线程很可能已卡死;重启希沃后再继续`);
|
||||
push('error', 'render', `截图 ${timeoutSec} 秒没返回(云端代理和 shell 直连都没成功);重启希沃后再继续`);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2566,6 +2837,7 @@ export async function diagnoseCourseware({ courseware, checkRender = false, rend
|
||||
issues,
|
||||
tips: issues.length ? [
|
||||
'multi-instance/display-mode 两种报错都不是让你忽略的:它们说明希沃里有多份内容,任何一方保存都会覆盖另一方。',
|
||||
'proxy-dead 表示云端 MCP 到该窗口的转发链路坏了:kit 会自动走直连端口,写入不受影响,但重启希沃才会修好云端代理。',
|
||||
'render 报错时不要反复重试截图,重启希沃最快。',
|
||||
] : [],
|
||||
};
|
||||
@@ -3063,7 +3335,7 @@ export async function exportSlides({
|
||||
page: n, path: file, bytes, attempts,
|
||||
...(ok ? {} : {
|
||||
error: timedOut
|
||||
? `截图超时(${timeoutSec} 秒)。请确认希沃窗口在前台、课件已完整加载;必要时重启希沃后重试,或调大 timeoutSec。`
|
||||
? `截图超时(${timeoutSec} 秒):云端代理和 shell 直连都没有返回。请确认希沃窗口已完整加载,必要时重启希沃,或调大 timeoutSec。`
|
||||
: (lastError ?? '没有生成截图文件'),
|
||||
timedOut, ...(stale ? { stale: true } : {}),
|
||||
}),
|
||||
@@ -3072,10 +3344,10 @@ export async function exportSlides({
|
||||
aborted = true;
|
||||
break;
|
||||
}
|
||||
// 连续两页超时基本可以断定渲染线程已死,继续只会更慢
|
||||
// 连续两页超时基本可以断定链路已死,继续只会更慢
|
||||
if (consecutiveTimeouts >= 2) {
|
||||
aborted = true;
|
||||
abortedReason = `连续 ${consecutiveTimeouts} 页截图超时,希沃渲染线程很可能已卡死,请重启希沃后再导出`;
|
||||
abortedReason = `连续 ${consecutiveTimeouts} 页截图超时(云端代理与直连都不可用),请重启希沃后再导出`;
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -3086,13 +3358,14 @@ export async function exportSlides({
|
||||
courseware: cw.name, localId: cw.localId,
|
||||
shellId: shell.id, opened, outDir: dir,
|
||||
workingMode: modeNow,
|
||||
...(shellRouteOf(shell.id) ? { transport: shellRouteOf(shell.id) } : {}),
|
||||
...(keptDisplayMode ? { note: '课件停在授课界面:为免丢内容没有切回备课,截图即当前授课画面。' } : {}),
|
||||
count: files.length, requested: nums.length,
|
||||
succeeded, failed, skipped: nums.length - files.length,
|
||||
aborted,
|
||||
...(aborted ? {
|
||||
hint: abortedReason
|
||||
?? '已中止剩余页面:希沃截图接口卡住了。重启希沃、让课件完整加载后再导出,比继续等更快。',
|
||||
?? '已中止剩余页面:截图一直超时(云端代理与直连都不可用)。重启希沃、让课件完整加载后再导出,比继续等更快。',
|
||||
} : {}),
|
||||
timeoutSec, files,
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user