Skip to content
This repository was archived by the owner on Feb 10, 2025. It is now read-only.

Commit c797ff5

Browse files
authored
fix: 🐛 fix scroll bar style (#617)
1 parent 25692f8 commit c797ff5

File tree

3 files changed

+33
-2
lines changed

3 files changed

+33
-2
lines changed

src/main.ts

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,16 @@
11
import { createApp } from 'vue'
22
import App from './App.vue'
33
import { setupI18n } from './locales'
4-
import { setupAssets } from './plugins'
4+
import { setupAssets, setupScrollbarStyle } from './plugins'
55
import { setupStore } from './store'
66
import { setupRouter } from './router'
77

88
async function bootstrap() {
99
const app = createApp(App)
1010
setupAssets()
1111

12+
setupScrollbarStyle()
13+
1214
setupStore(app)
1315

1416
setupI18n(app)

src/plugins/index.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
import setupAssets from './assets'
2+
import setupScrollbarStyle from './scrollbarStyle'
23

3-
export { setupAssets }
4+
export { setupAssets, setupScrollbarStyle }

src/plugins/scrollbarStyle.ts

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import { darkTheme, lightTheme } from 'naive-ui'
2+
3+
const setupScrollbarStyle = () => {
4+
const style = document.createElement('style')
5+
const styleContent = `
6+
::-webkit-scrollbar {
7+
background-color: transparent;
8+
width: ${lightTheme.Scrollbar.common?.scrollbarWidth};
9+
}
10+
::-webkit-scrollbar-thumb {
11+
background-color: ${lightTheme.Scrollbar.common?.scrollbarColor};
12+
border-radius: ${lightTheme.Scrollbar.common?.scrollbarBorderRadius};
13+
}
14+
html.dark ::-webkit-scrollbar {
15+
background-color: transparent;
16+
width: ${darkTheme.Scrollbar.common?.scrollbarWidth};
17+
}
18+
html.dark ::-webkit-scrollbar-thumb {
19+
background-color: ${darkTheme.Scrollbar.common?.scrollbarColor};
20+
border-radius: ${darkTheme.Scrollbar.common?.scrollbarBorderRadius};
21+
}
22+
`
23+
24+
style.innerHTML = styleContent
25+
document.head.appendChild(style)
26+
}
27+
28+
export default setupScrollbarStyle

0 commit comments

Comments
 (0)