feat(rag): replace LiteParse flows with LightRAG provider
This commit is contained in:
@@ -258,6 +258,26 @@ import {
|
||||
if (window.CSS && typeof window.CSS.escape === 'function') return window.CSS.escape(text);
|
||||
return text.replace(/["\\]/g, '\\$&');
|
||||
};
|
||||
const localFileOpenUrl = (rootUri, path) => {
|
||||
const normalizedRootUri = String(rootUri || '').trim();
|
||||
const normalizedPath = String(path || '').trim();
|
||||
if (!normalizedRootUri || !normalizedPath) return '';
|
||||
const url = new URL('/api/local-folder/files/open', window.location.origin);
|
||||
url.searchParams.set('rootUri', normalizedRootUri);
|
||||
url.searchParams.set('path', normalizedPath);
|
||||
return url.toString();
|
||||
};
|
||||
const resourceHrefFromUrlState = (rootUri, path, title) => {
|
||||
const fileUrl = localFileOpenUrl(rootUri, path);
|
||||
if (!fileUrl) return '';
|
||||
if (/\.pdf$/i.test(String(title || path || ''))) {
|
||||
const url = new URL('/pdf-preview', window.location.origin);
|
||||
url.searchParams.set('fileUrl', fileUrl);
|
||||
url.searchParams.set('fileName', title || path);
|
||||
return url.toString();
|
||||
}
|
||||
return fileUrl;
|
||||
};
|
||||
const applyDocumentEvidenceLocatorFromUrl = (root) => {
|
||||
if (!(root instanceof HTMLElement)) return;
|
||||
const url = currentUrl();
|
||||
@@ -289,7 +309,7 @@ import {
|
||||
const url = currentUrl();
|
||||
const raw = String(url.searchParams.get('resourceTab') || '').trim();
|
||||
if (!raw) return null;
|
||||
const objectIdentity = raw.includes('::') ? raw.slice(raw.indexOf('::') + 2) : raw;
|
||||
const objectIdentity = raw.startsWith('resource:') ? raw : (raw.includes('::') ? raw.slice(raw.indexOf('::') + 2) : raw);
|
||||
if (!objectIdentity.startsWith('resource:file:')) return null;
|
||||
const rootUri = currentWebShellRootUri();
|
||||
if (!rootUri) return null;
|
||||
@@ -299,6 +319,7 @@ import {
|
||||
const path = rest.slice(prefix.length).replace(/^\/+/, '');
|
||||
if (!path) return null;
|
||||
const title = path.split('/').filter(Boolean).pop() || path;
|
||||
const href = resourceHrefFromUrlState(rootUri, path, title);
|
||||
return {
|
||||
objectIdentity,
|
||||
documentId: currentWebShellDocumentId(),
|
||||
@@ -309,6 +330,8 @@ import {
|
||||
assetId: `local:asset:${path}`,
|
||||
title,
|
||||
fileName: title,
|
||||
href,
|
||||
officeUrl: href,
|
||||
openTarget: 'active-tab',
|
||||
page: url.searchParams.get('page') || undefined,
|
||||
bbox: url.searchParams.get('bbox') || undefined,
|
||||
@@ -1021,18 +1044,22 @@ import {
|
||||
});
|
||||
}, { once: true });
|
||||
|
||||
const restoreResourceTabFromUrl = () => {
|
||||
const restoreInput = restoreResourceTabInputFromUrl();
|
||||
if (!restoreInput) return Promise.resolve(false);
|
||||
return openResourceInActiveTab(restoreInput).catch((error) => {
|
||||
console.warn('mnote resource tab URL 恢复失败', error);
|
||||
return false;
|
||||
});
|
||||
};
|
||||
|
||||
if (paneRuntimes.length) {
|
||||
Promise.all(paneRuntimes.map((paneRuntime) => mountPane(paneRuntime))).then(() => {
|
||||
const restoreInput = restoreResourceTabInputFromUrl();
|
||||
if (restoreInput) {
|
||||
return openResourceInActiveTab(restoreInput).catch((error) => {
|
||||
console.warn('mnote resource tab URL 恢复失败', error);
|
||||
return false;
|
||||
});
|
||||
}
|
||||
return false;
|
||||
return restoreResourceTabFromUrl();
|
||||
}).catch((error) => {
|
||||
console.error('mnote multi-pane editor mount failed', error);
|
||||
});
|
||||
} else {
|
||||
void restoreResourceTabFromUrl();
|
||||
}
|
||||
})();
|
||||
|
||||
Reference in New Issue
Block a user