Skip to content

Commit 621cdef

Browse files
committed
refactor: 精简 options 提高可读性
1 parent f450d83 commit 621cdef

2 files changed

Lines changed: 10 additions & 7 deletions

File tree

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,14 @@ export async function init(id, invoke, options) {
88
return;
99
}
1010

11+
const { theme, lang, plugins, data } = options;
1112
const univerSheet = {
1213
el,
1314
invoke,
14-
options
15+
data,
16+
theme, lang, plugins
1517
};
18+
1619
await createUniverSheetAsync(univerSheet);
1720
Data.set(id, univerSheet);
1821

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

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@ export async function createUniverSheetAsync(sheet) {
3333
const { defaultTheme } = UniverDesign;
3434

3535
const options = {
36-
theme: sheet.options.theme ?? defaultTheme,
37-
locale: sheet.options.lang ?? LocaleType.ZH_CN,
36+
theme: sheet.theme ?? defaultTheme,
37+
locale: sheet.lang ?? LocaleType.ZH_CN,
3838
locales: {
3939
[LocaleType.ZH_CN]: merge(
4040
{},
@@ -50,7 +50,7 @@ export async function createUniverSheetAsync(sheet) {
5050
UniverSheetsDataValidationUIPlugin,
5151
]
5252
};
53-
const plugins = sheet.options.plugins ?? {
53+
const plugins = sheet.plugins ?? {
5454
DefaultPlugin: '_content/BootstrapBlazor.UniverSheet/plugin.js'
5555
};
5656
for (const name in plugins) {
@@ -69,9 +69,9 @@ export async function createUniverSheetAsync(sheet) {
6969
...options
7070
});
7171

72-
const { data } = sheet.options || {};
73-
if (data) {
74-
const option = typeof data === 'string' ? JSON.parse(data) : data;
72+
const { workbookData } = sheet.data || {};
73+
if (workbookData) {
74+
const option = typeof workbookData === 'string' ? JSON.parse(workbookData) : workbookData;
7575
univerAPI.createWorkbook(option);
7676
}
7777
else {

0 commit comments

Comments
 (0)