(state)
| 417 | |
| 418 | //第一次渲染是在状态机 init()中调用的 |
| 419 | function renderApp(state) { |
| 420 | const pauseBtnIcon = `#icon-${state.paused ? "play" : "pause"}`; |
| 421 | const soundBtnIcon = `#icon-sound-${soundEnabledSelector() ? "on" : "off"}`; |
| 422 | appNodes.pauseBtnSVG.setAttribute("href", pauseBtnIcon); |
| 423 | appNodes.pauseBtnSVG.setAttribute("xlink:href", pauseBtnIcon); |
| 424 | appNodes.soundBtnSVG.setAttribute("href", soundBtnIcon); |
| 425 | appNodes.soundBtnSVG.setAttribute("xlink:href", soundBtnIcon); |
| 426 | appNodes.controls.classList.toggle("hide", state.menuOpen || state.config.hideControls); |
| 427 | appNodes.canvasContainer.classList.toggle("blur", state.menuOpen); |
| 428 | appNodes.menu.classList.toggle("hide", !state.menuOpen); |
| 429 | appNodes.finaleModeFormOption.style.opacity = state.config.autoLaunch ? 1 : 0.32; |
| 430 | |
| 431 | appNodes.quality.value = state.config.quality; |
| 432 | appNodes.shellType.value = state.config.shell; |
| 433 | appNodes.shellSize.value = state.config.size; |
| 434 | appNodes.wordShell.checked = state.config.wordShell; |
| 435 | appNodes.autoLaunch.checked = state.config.autoLaunch; |
| 436 | appNodes.finaleMode.checked = state.config.finale; |
| 437 | appNodes.skyLighting.value = state.config.skyLighting; |
| 438 | appNodes.hideControls.checked = state.config.hideControls; |
| 439 | appNodes.fullscreen.checked = state.fullscreen; |
| 440 | appNodes.longExposure.checked = state.config.longExposure; |
| 441 | appNodes.scaleFactor.value = state.config.scaleFactor.toFixed(2); |
| 442 | |
| 443 | appNodes.menuInnerWrap.style.opacity = state.openHelpTopic ? 0.12 : 1; |
| 444 | appNodes.helpModal.classList.toggle("active", !!state.openHelpTopic); |
| 445 | if (state.openHelpTopic) { |
| 446 | const { header, body } = helpContent[state.openHelpTopic]; |
| 447 | appNodes.helpModalHeader.textContent = header; |
| 448 | appNodes.helpModalBody.textContent = body; |
| 449 | } |
| 450 | } |
| 451 | |
| 452 | store.subscribe(renderApp); |
| 453 |
no test coverage detected