推进 INI 面板 launcher link view-model helper
This commit is contained in:
@@ -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>
|
||||
|
||||
@@ -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,
|
||||
}));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user