fix: stabilize local OCR and prod startup
This commit is contained in:
@@ -961,8 +961,28 @@ export function createSidebarPageSettingsRuntime(context) {
|
||||
}
|
||||
}
|
||||
|
||||
function emitLocalIndexBackgroundTask(status, label, error) {
|
||||
var now = Date.now();
|
||||
window.dispatchEvent(new CustomEvent('mnote:local-background-task-updated', {
|
||||
detail: {
|
||||
task: {
|
||||
taskKind: 'local_index',
|
||||
taskId: 'local-index',
|
||||
sourceRootRelativePath: '本地索引',
|
||||
rootUri: currentRootUri(),
|
||||
status: status,
|
||||
stageLabel: label,
|
||||
updatedAtMs: now,
|
||||
finishedAtMs: status === 'running' ? null : now,
|
||||
error: error || null
|
||||
}
|
||||
}
|
||||
}));
|
||||
}
|
||||
|
||||
async function refreshLocalIndex() {
|
||||
if (!pageSettingsLocalIndexIsAvailable()) return;
|
||||
emitLocalIndexBackgroundTask('running', '本地索引重建中', null);
|
||||
pageUiState.localIndexSummary = Object.assign({}, pageUiState.localIndexSummary || {}, {
|
||||
scopeKey: pageSettingsLocalIndexScopeKey(),
|
||||
loading: true,
|
||||
@@ -982,8 +1002,10 @@ export function createSidebarPageSettingsRuntime(context) {
|
||||
if (!response.ok || !payload || payload.ok !== true) {
|
||||
throw new Error(payload && payload.error && payload.error.message ? payload.error.message : 'local_index_refresh_' + response.status);
|
||||
}
|
||||
emitLocalIndexBackgroundTask('done', '本地索引已完成', null);
|
||||
await loadPageSettingsLocalIndex(true);
|
||||
} catch (error) {
|
||||
emitLocalIndexBackgroundTask('failed', '本地索引失败', error instanceof Error ? error.message : String(error));
|
||||
pageUiState.localIndexSummary = Object.assign({}, pageUiState.localIndexSummary || {}, {
|
||||
scopeKey: pageSettingsLocalIndexScopeKey(),
|
||||
loading: false,
|
||||
|
||||
Reference in New Issue
Block a user