mirror of
https://github.com/BewlyBewly/BewlyBewly.git
synced 2025-04-14 13:15:29 +00:00
feat: add common method injectCSS
* refactor: address ts errors
This commit is contained in:
@@ -4,19 +4,12 @@ import App from './views/App.vue'
|
||||
import { setupApp } from '~/logic/common-setup'
|
||||
import { i18n } from '~/utils/i18n'
|
||||
import { SVG_ICONS } from '~/utils/svgIcons'
|
||||
import { injectCSS } from '~/utils/main'
|
||||
|
||||
let app: any
|
||||
|
||||
const isFirefox: boolean = /Firefox/i.test(navigator.userAgent)
|
||||
|
||||
function injectCSS(css: string): HTMLStyleElement {
|
||||
const el = document.createElement('style')
|
||||
el.setAttribute('rel', 'stylesheet')
|
||||
el.innerText = css
|
||||
document.documentElement.appendChild(el)
|
||||
return el
|
||||
}
|
||||
|
||||
const beforeLoadedStyleEl = injectCSS(`
|
||||
html.dark {
|
||||
background: hsl(230 12% 6%);
|
||||
@@ -70,6 +63,8 @@ function injectApp() {
|
||||
|| /https?:\/\/search.bilibili.com\.*/.test(currentUrl)
|
||||
// moments
|
||||
|| /https?:\/\/t.bilibili.com\.*/.test(currentUrl)
|
||||
// history page
|
||||
|| /https?:\/\/(www.)?bilibili.com\/account\/history.*/.test(currentUrl)
|
||||
) {
|
||||
if (
|
||||
/https?:\/\/bilibili.com\/?$/.test(currentUrl)
|
||||
|
||||
@@ -13,7 +13,7 @@ import Favorites from './Favorites/Favorites.vue'
|
||||
import { accessKey, settings } from '~/logic'
|
||||
import '~/styles/index.ts'
|
||||
import { AppPage, LanguageType } from '~/enums/appEnums'
|
||||
import { getUserID, hexToRGBA, smoothScrollToTop } from '~/utils/main'
|
||||
import { getUserID, hexToRGBA, injectCSS, smoothScrollToTop } from '~/utils/main'
|
||||
import emitter from '~/utils/mitt'
|
||||
|
||||
const activatedPage = ref<AppPage>(AppPage.Home)
|
||||
@@ -166,9 +166,15 @@ onMounted(() => {
|
||||
})
|
||||
|
||||
if (!isHomePage.value) {
|
||||
const originalTopBar: HTMLElement = document.querySelector('#biliMainHeader, #bili-header-container') as HTMLElement
|
||||
if (originalTopBar)
|
||||
originalTopBar.style.visibility = 'hidden'
|
||||
injectCSS(`
|
||||
.bili-header .bili-header__bar, #bili-header-container {
|
||||
visibility: hidden
|
||||
}
|
||||
`)
|
||||
|
||||
// const originalTopBar: HTMLElement = document.querySelector('.bili-header .bili-header__bar, #bili-header-container') as HTMLElement
|
||||
// if (originalTopBar)
|
||||
// originalTopBar.style.visibility = 'hidden'
|
||||
}
|
||||
|
||||
setAppAppearance()
|
||||
@@ -445,7 +451,7 @@ function handleBackToTop() {
|
||||
|
||||
<main
|
||||
v-if="isHomePage"
|
||||
p="t-80px" m-auto
|
||||
p="t-70px" m-auto
|
||||
relative
|
||||
:w="isVideoPage ? '[calc(100%-160px)]' : 'lg:85% md:[calc(90%-60px)] [calc(100%-140px)]'"
|
||||
>
|
||||
|
||||
Reference in New Issue
Block a user