feat(前端界面): OFDGo WebUI支持通过PWA关联并打开OFD文件
build.yaml / build (push) Successful in 37s

This commit is contained in:
xiaoqidun committed 2026-09-08 23:47:12 +08:00
1 parent 96a2bd7b85
commit efd72e9e61
2 files changed
+22 -3

No files matched your search

+13 -3
View File
@@ -146,7 +146,7 @@ el.toggleMetaButton.addEventListener("click", () => toggleSidebar("meta"));
el.fontAddButton.addEventListener("click", () => openFontFile(el.fontInput)); el.fontAddButton.addEventListener("click", () => openFontFile(el.fontInput));
el.fontDirectoryButton.addEventListener("click", () => openFontFile(el.fontDirectoryInput)); el.fontDirectoryButton.addEventListener("click", () => openFontFile(el.fontDirectoryInput));
el.localFontButton.addEventListener("click", loadLocalFonts); el.localFontButton.addEventListener("click", loadLocalFonts);
el.ofdInput.addEventListener("change", openSelectedOFD); el.ofdInput.addEventListener("change", () => openOFD(el.ofdInput.files[0]));
el.fontInput.addEventListener("change", openSelectedFonts); el.fontInput.addEventListener("change", openSelectedFonts);
el.fontDirectoryInput.addEventListener("change", openSelectedFonts); el.fontDirectoryInput.addEventListener("change", openSelectedFonts);
el.prevButton.addEventListener("click", () => renderPage(state.pageIndex - 1)); el.prevButton.addEventListener("click", () => renderPage(state.pageIndex - 1));
@@ -274,6 +274,17 @@ async function boot() {
await refreshLocalFontPermission(); await refreshLocalFontPermission();
setStatus(fontsRestored ? STATUS.ready : "字体读取失败"); setStatus(fontsRestored ? STATUS.ready : "字体读取失败");
setBusy(false); setBusy(false);
if ("launchQueue" in window) {
let opening = Promise.resolve();
window.launchQueue.setConsumer(({ files }) => {
if (!files.length) {
return;
}
opening = opening.then(async () => {
await openOFD(await files[0].getFile());
}).catch((err) => showError(err, !state.doc));
});
}
} catch (err) { } catch (err) {
setStatus("渲染引擎加载失败"); setStatus("渲染引擎加载失败");
setEmpty(String(err.message || err)); setEmpty(String(err.message || err));
@@ -533,8 +544,7 @@ function waitFor(predicate) {
}); });
} }
async function openSelectedOFD() { async function openOFD(file) {
const file = el.ofdInput.files[0];
if (!file) { if (!file) {
return; return;
} }
+9
View File
@@ -7,6 +7,15 @@
"display": "standalone", "display": "standalone",
"background_color": "#eef1f4", "background_color": "#eef1f4",
"theme_color": "#fbfcfd", "theme_color": "#fbfcfd",
"file_handlers": [
{
"action": "./",
"accept": {
"application/ofd": [".ofd"]
},
"launch_type": "multiple-clients"
}
],
"icons": [ "icons": [
{ {
"src": "./ofdgo.svg", "src": "./ofdgo.svg",