Skip to content

Commit c63809f

Browse files
committed
refactor: 更新脚本
1 parent a44dcc3 commit c63809f

2 files changed

Lines changed: 17 additions & 5 deletions

File tree

src/components/BootstrapBlazor.UniverSheet/Components/UniverSheet.razor.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,16 @@ export async function init(id, invoke, options) {
88
return;
99
}
1010

11-
const { theme, lang, plugins, data, ribbonType } = options;
11+
const { theme, lang, plugins, data, ribbonType, darkMode } = options;
1212
const univerSheet = {
1313
el,
1414
invoke,
1515
data,
1616
plugins,
1717
theme,
1818
lang,
19-
ribbonType
19+
ribbonType,
20+
darkMode
2021
};
2122

2223
await createUniverSheetAsync(univerSheet);

src/components/BootstrapBlazor.UniverSheet/wwwroot/univer.js

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { addScript, addLink } from '../BootstrapBlazor/modules/utility.js'
1+
import { addScript, addLink, getTheme } from '../BootstrapBlazor/modules/utility.js'
22
import DataService from './data-service.js'
33

44
const loadAssets = async lang => {
@@ -42,8 +42,8 @@ export async function createUniverSheetAsync(sheet) {
4242
const lang = sheet.lang.replace('-', '')
4343
const langStr = lang.charAt(0).toUpperCase() + lang.slice(1)
4444
const options = {
45-
theme: UniverDesign[sheet.theme] ?? UniverDesign.defaultTheme, //'defaultTheme' | greenTheme
46-
darkMode: sheet.darkMode ?? false, // false | true
45+
theme: sheet.theme,
46+
darkMode: sheet.darkMode,
4747
locale: lang,
4848
locales: {
4949
[lang]: merge(
@@ -87,6 +87,17 @@ export async function createUniverSheetAsync(sheet) {
8787
options.plugins.push(plugin);
8888
}
8989

90+
if (options.theme === 'greenTheme') {
91+
options.theme = UniverDesign.greenTheme;
92+
}
93+
else {
94+
options.theme = UniverDesign.defaultTheme;
95+
}
96+
97+
if (options.darkMode === null) {
98+
options.darkMode = getTheme() === 'dark';
99+
}
100+
90101
const { univer, univerAPI } = createUniver(options);
91102

92103
const { workbookData } = sheet.data || {};

0 commit comments

Comments
 (0)