Skip to content

Commit c8c12b6

Browse files
committed
refactor: 增加 switchTheme 方法
1 parent 0696acb commit c8c12b6

1 file changed

Lines changed: 10 additions & 1 deletion

File tree

src/components/BootstrapBlazor.DockView/wwwroot/js/dockview-utils.js

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,13 @@ import { getConfig, reloadFromConfig, loadPanelsFromLocalstorage, saveConfig } f
66
import './dockview-extensions.js'
77

88
const cerateDockview = (el, options) => {
9+
const theme = options.theme || "dockview-theme-light";
910
const template = el.querySelector('template');
1011
const dockview = new DockviewComponent(el, {
1112
parentElement: el,
1213
theme: {
1314
name: "bb-dockview",
14-
className: options.theme || "dockview-theme-light",
15+
className: theme,
1516
dndOverlayMounting: 'absolute',
1617
dndPanelOverlay: 'group'
1718
},
@@ -35,6 +36,14 @@ const initDockview = (dockview, options, template) => {
3536
window.dockview = dockview;
3637
}
3738

39+
dockview.switchTheme = theme => {
40+
const themeName = `dockview-theme-${theme}`;
41+
if (dockview.options.theme.className !== themeName) {
42+
dockview.options.theme.className = themeName;
43+
dockview.updateTheme();
44+
}
45+
}
46+
3847
dockview.update = options => {
3948
if (options.layoutConfig) {
4049
reloadFromConfig(dockview, options);

0 commit comments

Comments
 (0)