feat(转换能力): 完善PDF转换与链接保留,优化大型文档处理,新增转换提示
build.yaml / build (push) Successful in 40s

This commit is contained in:
xiaoqidun committed 2026-09-24 17:26:12 +08:00
1 parent 86330dddd7
commit f13d8b81e1
9 files changed
+330 -114

No files matched your search

+4
View File
@@ -590,6 +590,10 @@
<dd id="metaFonts">0</dd>
</div>
</dl>
<details id="conversionNotice" class="conversion-notice" hidden>
<summary>转换提示</summary>
<div id="conversionWarnings" class="attachment-detail"></div>
</details>
<section id="securityPanel" class="security-panel" aria-labelledby="securityPanelTitle" hidden>
<div class="panel-row"><div id="securityPanelTitle" class="panel-title compact">安全</div><div class="panel-actions"><button id="encryptSaveButton" class="small-button" type="button" title="加密另存" aria-label="加密另存" aria-haspopup="dialog" aria-controls="exportPanel" disabled>加密</button><button id="signButton" class="small-button" type="button" aria-haspopup="dialog" aria-controls="signPanel" disabled>签章</button><button id="verifyButton" class="small-button" type="button" aria-haspopup="dialog" aria-controls="verifyPanel" disabled>验签</button></div></div>
<dl class="meta-list"><div><dt>加密</dt><dd id="securityEncryption">未加密</dd></div><div id="securityMethodRow" hidden><dt>算法</dt><dd id="securityMethod"></dd></div></dl>
+13
View File
@@ -2161,6 +2161,19 @@ button.outline-link:hover {
text-decoration: underline;
}
.conversion-notice {
margin-block: 12px;
}
.conversion-notice > summary {
cursor: pointer;
}
.conversion-notice p {
margin-block: 8px;
overflow-wrap: anywhere;
}
.attachment-detail {
color: var(--text-muted);
font-size: 12px;
+15
View File
@@ -29,6 +29,7 @@ let credentialRequest = null;
let cancelPageTouch = null;
const state = {
conversionWarnings: [],
composite: null,
annotationEdit: null,
annotationCreate: null,
@@ -440,6 +441,8 @@ const el = {
refreshAppButton: document.querySelector("#refreshAppButton"),
metaFile: document.querySelector("#metaFile"),
metaTitle: document.querySelector("#metaTitle"),
conversionNotice: document.querySelector("#conversionNotice"),
conversionWarnings: document.querySelector("#conversionWarnings"),
metaSubject: document.querySelector("#metaSubject"),
metaAuthor: document.querySelector("#metaAuthor"),
metaCreationDate: document.querySelector("#metaCreationDate"),
@@ -1929,6 +1932,7 @@ async function toggleEditor() {
state.composite = null;
state.selectObjects = true;
state.ofdBytes = null;
state.conversionWarnings = [];
state.objectClipboard = null;
state.styleClipboard = null;
canvasEditor.clear();
@@ -3331,6 +3335,7 @@ async function openOFD(file) {
setBusy(true, "正在读取文档", 10, STATUS.opening);
try {
let bytes = new Uint8Array(await file.arrayBuffer());
let warnings = [];
if (openSeq !== state.openSeq) {
return;
}
@@ -3341,8 +3346,10 @@ async function openOFD(file) {
const converted = await callWASM("ofdgoConvertPDF", bytes);
if (openSeq !== state.openSeq) return;
bytes = converted.bytes;
warnings = JSON.parse(converted.warnings || "null") || [];
}
state.ofdBytes = bytes;
state.conversionWarnings = warnings;
state.fileName = (file.name || "ofdgo.ofd").replace(/\.pdf$/i, ".ofd");
state.editing = false;
state.composite = null;
@@ -6310,6 +6317,14 @@ function markThumbnailError(index) {
function renderMeta(keepDetails = false) {
renderSecurity();
el.conversionNotice.hidden = !state.conversionWarnings.length;
renderMetaContent(el.conversionWarnings, state.conversionWarnings, () => {
el.conversionWarnings.replaceChildren(...state.conversionWarnings.map(warning => {
const item = document.createElement("p");
item.textContent = `第${warning.Page}页 · 位置${warning.Offset}:${warning.Message}`;
return item;
}));
});
const doc = state.doc || {};
el.metaPanel.setAttribute("aria-busy", String(!!doc.detailsPending));
document.title = `OFDGo WebUI - ${state.fileName}`;