Skip to content

Commit 0068b38

Browse files
committed
refactor: 处理初始化数据
1 parent 4830192 commit 0068b38

1 file changed

Lines changed: 7 additions & 4 deletions

File tree

  • src/components/BootstrapBlazor.UniverSheet/wwwroot

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

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,10 @@ export async function createUniverSheetAsync(sheet) {
3232
const { UniverSheetsDataValidationPlugin } = UniverSheetsDataValidation
3333
const { UniverSheetsDataValidationUIPlugin } = UniverSheetsDataValidationUi
3434
const { defaultTheme } = UniverDesign;
35+
3536
const options = {
36-
theme: defaultTheme,
37-
locale: LocaleType.ZH_CN,
37+
theme: sheet.options.theme ?? defaultTheme,
38+
locale: sheet.options.lang ?? LocaleType.ZH_CN,
3839
locales: {
3940
[LocaleType.ZH_CN]: merge(
4041
{},
@@ -69,9 +70,11 @@ export async function createUniverSheetAsync(sheet) {
6970
...options
7071
});
7172

72-
const { data } = sheet.options;
73+
const { data: { data } = {} } = sheet.options;
7374
if (data) {
74-
univerAPI.createWorkbook(typeof data.data === 'object' ? data.data : JSON.parse(data.data));
75+
const template = typeof data.template === 'string' ? JSON.parse(data.template) : data.template;
76+
template && delete data.template;
77+
univerAPI.createWorkbook(merge({}, template, { customData: data }));
7578
delete sheet.options.data;
7679
}
7780
else {

0 commit comments

Comments
 (0)