mirror of
https://github.com/BewlyBewly/BewlyBewly.git
synced 2025-04-14 13:15:29 +00:00
perf: improve BewlyBewly inject speed
This commit is contained in:
@@ -4,6 +4,7 @@ import '~/styles'
|
||||
import { createApp } from 'vue'
|
||||
|
||||
import { useDark } from '~/composables/useDark'
|
||||
import { BEWLY_MOUNTED } from '~/constants/globalEvents'
|
||||
import { settings } from '~/logic'
|
||||
import { setupApp } from '~/logic/common-setup'
|
||||
import { runWhenIdle } from '~/utils/lazyLoad'
|
||||
@@ -113,6 +114,11 @@ if (settings.value.adaptToOtherPageStyles && isHomePage()) {
|
||||
`)
|
||||
}
|
||||
|
||||
window.addEventListener(BEWLY_MOUNTED, () => {
|
||||
if (beforeLoadedStyleEl)
|
||||
document.documentElement.removeChild(beforeLoadedStyleEl)
|
||||
})
|
||||
|
||||
// Set the original Bilibili top bar to `display: none` to prevent it from showing before the load
|
||||
// see: https://github.com/BewlyBewly/BewlyBewly/issues/967
|
||||
let removeOriginalTopBar: HTMLStyleElement | null = null
|
||||
@@ -139,8 +145,6 @@ async function onDOMLoaded() {
|
||||
if (originalTopBar)
|
||||
document.body.appendChild(originalTopBar)
|
||||
}
|
||||
if (beforeLoadedStyleEl)
|
||||
document.documentElement.removeChild(beforeLoadedStyleEl)
|
||||
|
||||
if (isSupportedPages()) {
|
||||
// Then inject the app
|
||||
|
||||
@@ -6,7 +6,7 @@ import browser from 'webextension-polyfill'
|
||||
|
||||
import type { BewlyAppProvider } from '~/composables/useAppProvider'
|
||||
import { useDark } from '~/composables/useDark'
|
||||
import { OVERLAY_SCROLL_BAR_SCROLL } from '~/constants/globalEvents'
|
||||
import { BEWLY_MOUNTED, OVERLAY_SCROLL_BAR_SCROLL } from '~/constants/globalEvents'
|
||||
import { AppPage, LanguageType } from '~/enums/appEnums'
|
||||
import { accessKey, settings } from '~/logic'
|
||||
import { getUserID, isHomePage, scrollToTop } from '~/utils/main'
|
||||
@@ -109,6 +109,7 @@ onBeforeMount(() => {
|
||||
})
|
||||
|
||||
onMounted(() => {
|
||||
window.dispatchEvent(new CustomEvent(BEWLY_MOUNTED))
|
||||
// openVideoPageIfBvidExists()
|
||||
|
||||
if (isHomePage()) {
|
||||
|
||||
Reference in New Issue
Block a user