推进 INI 面板 launcher link view-model helper

This commit is contained in:
2026-06-15 04:25:29 +08:00
parent ac463453da
commit b330f7b1bc
7 changed files with 200 additions and 16 deletions

View File

@@ -73,16 +73,16 @@
</section>
</main>
<script type="module">
import { getIniPanelEntryManifest } from "./ui-shell.js";
import { createIniPanelLauncherLinkViewModel } from "./ui-shell.js";
const manifest = getIniPanelEntryManifest();
for (const entry of manifest) {
const link = document.querySelector(`a[data-entry-id="${entry.id}"]`);
const links = createIniPanelLauncherLinkViewModel();
for (const linkModel of links) {
const link = document.querySelector(`a[data-entry-id="${linkModel.entryId}"]`);
if (!link) {
throw new Error(`Missing launcher entry ${entry.id}`);
throw new Error(`Missing launcher entry ${linkModel.entryId}`);
}
link.textContent = entry.title;
link.href = entry.href;
link.textContent = linkModel.label;
link.href = linkModel.href;
}
</script>
</body>

View File

@@ -1,3 +1,8 @@
import {
INI_PANEL_ENTRIES,
getIniPanelEntryByHref,
getIniPanelEntryManifest,
} from "./entry-manifest.js";
export {
INI_PANEL_ENTRIES,
getIniPanelEntryByHref,
@@ -9,3 +14,15 @@ export {
export {
renderMachineSessionControlView,
} from "./control-view-renderer.js";
export function getVisibleIniPanelEntries() {
return getIniPanelEntryManifest();
}
export function createIniPanelLauncherLinkViewModel(entries = getVisibleIniPanelEntries()) {
return entries.map(({ id, href, title }) => ({
entryId: id,
href,
label: title,
}));
}