From aa0b0a5a596ad27f8418a19fee52275e3498711b Mon Sep 17 00:00:00 2001 From: Argo Zhang Date: Mon, 22 Dec 2025 14:07:36 +0800 Subject: [PATCH 1/2] feat(UniverSheet): add auto switch darkmode function --- .../Components/UniverSheet.razor.js | 33 +++++++++++++++++-- 1 file changed, 31 insertions(+), 2 deletions(-) diff --git a/src/components/BootstrapBlazor.UniverSheet/Components/UniverSheet.razor.js b/src/components/BootstrapBlazor.UniverSheet/Components/UniverSheet.razor.js index 1465e1f1..98592fb4 100644 --- a/src/components/BootstrapBlazor.UniverSheet/Components/UniverSheet.razor.js +++ b/src/components/BootstrapBlazor.UniverSheet/Components/UniverSheet.razor.js @@ -1,6 +1,7 @@ -import Data from '../../BootstrapBlazor/modules/data.js' -import { isFunction } from '../../BootstrapBlazor/modules/utility.js' +import { isFunction, registerBootstrapBlazorModule } from '../../BootstrapBlazor/modules/utility.js' import { createUniverSheetAsync } from '../univer.js' +import Data from '../../BootstrapBlazor/modules/data.js' +import EventHandler from "../../BootstrapBlazor/modules/event-handler.js" export async function init(id, invoke, options) { const el = document.getElementById(id); @@ -24,6 +25,10 @@ export async function init(id, invoke, options) { Data.set(id, univerSheet); invoke.invokeMethodAsync('TriggerReadyAsync'); + + registerBootstrapBlazorModule('UniverSheet', id, () => { + EventHandler.on(document, 'changed.bb.theme', updateTheme); + }); } export function execute(id, data) { @@ -39,4 +44,28 @@ export function dispose(id) { if (isFunction(univerSheet.dispose)) { univerSheet.dispose(); } + + const { UniverSheet } = window.BootstrapBlazor; + if (UniverSheet) { + UniverSheet.dispose(id, () => { + EventHandler.off(document, 'changed.bb.theme', updateTheme); + }); + } +} + +const updateTheme = e => { + const theme = e.theme; + + [...document.querySelectorAll('.bb-univer-sheet')].forEach(s => { + const id = s.getAttribute('id'); + if (id) { + const univerSheet = Data.get(id); + if (univerSheet && univerSheet.darkMode === null) { + const { univerAPI } = univerSheet; + if (univerAPI) { + univerAPI.toggleDarkMode(theme === 'dark'); + } + } + } + }); } From a63b6d2d1ed319d923f01fd91f943817853ff770 Mon Sep 17 00:00:00 2001 From: Argo Zhang Date: Mon, 22 Dec 2025 14:08:38 +0800 Subject: [PATCH 2/2] chore: bump version 10.0.5 --- .../BootstrapBlazor.UniverSheet.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/BootstrapBlazor.UniverSheet/BootstrapBlazor.UniverSheet.csproj b/src/components/BootstrapBlazor.UniverSheet/BootstrapBlazor.UniverSheet.csproj index 420129d1..5d2ac188 100644 --- a/src/components/BootstrapBlazor.UniverSheet/BootstrapBlazor.UniverSheet.csproj +++ b/src/components/BootstrapBlazor.UniverSheet/BootstrapBlazor.UniverSheet.csproj @@ -1,7 +1,7 @@  - 10.0.4 + 10.0.5