From b6d3e08eaf244559abde7f3d644b7a148dd9b254 Mon Sep 17 00:00:00 2001 From: Haoyu Xu Date: Wed, 8 Jan 2025 22:32:01 +0800 Subject: [PATCH] fix: misc fixes --- showcase/src/components/aklive2d.js | 21 +++++++------- showcase/src/components/background.js | 6 ++-- showcase/src/components/fallback.css | 8 +++++ showcase/src/components/fallback.js | 42 +++++++++++++++------------ showcase/src/components/player.js | 4 +++ showcase/src/components/voice.js | 11 ++++--- showcase/src/index.js | 5 +--- 7 files changed, 56 insertions(+), 41 deletions(-) diff --git a/showcase/src/components/aklive2d.js b/showcase/src/components/aklive2d.js index 20b4693..e1fd86c 100644 --- a/showcase/src/components/aklive2d.js +++ b/showcase/src/components/aklive2d.js @@ -16,7 +16,6 @@ import '@/components/aklive2d.css' export default class AKLive2D { #el = document.createElement("div") #appEl - #widgetEl #queries = new URLSearchParams(window.location.search) #voice = new Voice() #music = new Music() @@ -25,7 +24,7 @@ export default class AKLive2D { #logo = new Logo() #insight = new Insight() - constructor(appEl, widgetEl) { + constructor(appEl) { document.title = import.meta.env.VITE_TITLE console.log("All resources are extracted from Arknights. Github: https://gura.ch/aklive2d-gh") @@ -33,24 +32,23 @@ export default class AKLive2D { document.addEventListener("gesturestart", e => e.preventDefault()); this.#appEl = appEl - this.#widgetEl = widgetEl } init() { - if (isWebGLSupported) { - this.#logo.init(this.#appEl); - this.#background.init(this.#appEl, this.#widgetEl); - this.#voice.init(this.#appEl, this.#widgetEl); - this.#music.init(this.#appEl); - this.#player.init(this.#widgetEl, this); + this.#logo.init(this.#appEl); + this.#background.init(this.#appEl); + this.#voice.init(this.#appEl); + this.#music.init(this.#appEl); + if (isWebGLSupported()) { + this.#player.init(this.#appEl); } else { - (new Fallback()).init(this.#widgetEl) + (new Fallback()).init(this.#appEl) } this.#el.id = "settings-box" this.#el.hidden = true this.#el.innerHTML = `
- ${this.#logo.HTML} + ${this.#logo.HTML} ${this.#background.HTML} ${this.#player.HTML} ${this.#voice.HTML} @@ -103,6 +101,7 @@ export default class AKLive2D { success() { this.#music.link(this.#background) this.#background.link(this.#music) + this.#voice.link(this.#player) this.#voice.success() this.#music.success() this.#insight.success() diff --git a/showcase/src/components/background.js b/showcase/src/components/background.js index 45524ee..53b5dca 100644 --- a/showcase/src/components/background.js +++ b/showcase/src/components/background.js @@ -1,9 +1,9 @@ import { - insertHTMLNodeBefore, readFile, updateHTMLOptions, showRelatedHTML, syncHTMLValue, + insertHTMLChild, } from "@/components/helper"; import "@/components/background.css" @@ -20,14 +20,14 @@ export default class Background { } #musicObj - init(el, widgetEl) { + init(el) { this.#parentEl = el this.#el.id = "background-box" this.image = this.#default.location + this.#default.image this.#el.innerHTML = `