refactor: move upload fetch timeout helper

This commit is contained in:
lix-2026
2026-05-25 00:59:49 +08:00
parent e54f255690
commit e1484f4cc0
4 changed files with 39 additions and 2 deletions
@@ -3879,6 +3879,10 @@ const SIDEBAR_TREE_JS: &str = r##"
}
async function fetchWithTimeout(input, init, timeoutMs, label) {
var runtimeFn = localUploadRuntimeFunction('fetchWithTimeout');
if (runtimeFn) {
return await runtimeFn(input, init || {}, timeoutMs, label);
}
var controller = typeof AbortController === 'function' ? new AbortController() : null;
var timer = 0;
try {
@@ -10930,6 +10934,7 @@ mod tests {
assert!(LOCAL_UPLOAD_RUNTIME_JS.contains("function resolveEditorUploadContext"));
assert!(LOCAL_UPLOAD_RUNTIME_JS.contains("function editorRootFromUploadOptions"));
assert!(LOCAL_UPLOAD_RUNTIME_JS.contains("function openEditorUploadFilePicker"));
assert!(LOCAL_UPLOAD_RUNTIME_JS.contains("function fetchWithTimeout"));
assert!(LOCAL_UPLOAD_RUNTIME_JS.contains("uploadFilesWithResolvedTarget"));
assert!(LOCAL_UPLOAD_RUNTIME_JS.contains("__mnoteLastEditorUploadRoot"));
}