11import { addScript , addLink } from '../BootstrapBlazor/modules/utility.js'
22import DataService from './data-service.js'
33
4- const loadAssets = async ( ) => {
5- await addScript ( './_content/BootstrapBlazor.UniverSheet/univer/js/react.production.min.js' ) ;
6- await addScript ( './_content/BootstrapBlazor.UniverSheet/univer/js/react-dom.production.min.js' ) ;
7- await addScript ( './_content/BootstrapBlazor.UniverSheet/univer/js/rxjs.umd.min.js' ) ;
8- await addScript ( './_content/BootstrapBlazor.UniverSheet/univer/js/univerjs.presets.umd.min.js' ) ;
9- await addScript ( './_content/BootstrapBlazor.UniverSheet/univer/js/univerjs.preset-sheets-core.umd.min.js' ) ;
10- await addScript ( './_content/BootstrapBlazor.UniverSheet/univer/js/univerjs.preset-sheets-drawing.umd.min.js' ) ;
11- await addScript ( './_content/BootstrapBlazor.UniverSheet/univer/js/univerjs.sheets-zen-editor.umd.min.js' ) ;
12- await addScript ( './_content/BootstrapBlazor.UniverSheet/univer/js/univerjs.preset-sheets-data-validation.umd.min.js' ) ;
4+ const loadAssets = async lang => {
5+ console . log ( lang , 'lang' ) ;
6+ await addScript ( './_content/BootstrapBlazor.UniverSheet/univer/react.production.min.js' ) ;
7+ await addScript ( './_content/BootstrapBlazor.UniverSheet/univer/react-dom.production.min.js' ) ;
8+ await addScript ( './_content/BootstrapBlazor.UniverSheet/univer/rxjs.umd.min.js' ) ;
9+ await addScript ( './_content/BootstrapBlazor.UniverSheet/univer/univerjs.presets.umd.min.js' ) ;
10+ await addScript ( './_content/BootstrapBlazor.UniverSheet/univer/univerjs.preset-sheets-core/index.umd.min.js' ) ;
11+ await addScript ( './_content/BootstrapBlazor.UniverSheet/univer/univerjs.preset-sheets-drawing/index.umd.min.js' ) ;
12+ await addScript ( './_content/BootstrapBlazor.UniverSheet/univer/univerjs.sheets-zen-editor/index.umd.min.js' ) ;
13+ await addScript ( './_content/BootstrapBlazor.UniverSheet/univer/univerjs.preset-sheets-data-validation/index.umd.min.js' ) ;
1314
14- await addScript ( ' ./_content/BootstrapBlazor.UniverSheet/univer/js/ univerjs.preset-sheets-core. locales.zh-CN.js' ) ;
15- await addScript ( ' ./_content/BootstrapBlazor.UniverSheet/univer/js/ univerjs.preset-sheets-drawing. locales.zhCN.js' ) ;
16- await addScript ( ' ./_content/BootstrapBlazor.UniverSheet/univer/js/ univerjs.sheets-zen-editor. locales.zh-CN.js' ) ;
17- await addScript ( ' ./_content/BootstrapBlazor.UniverSheet/univer/js/ univerjs.preset-sheets-data-validation. locales.zh-CN.js' ) ;
15+ await addScript ( ` ./_content/BootstrapBlazor.UniverSheet/univer/univerjs.preset-sheets-core/ locales/ ${ lang } .js` ) ;
16+ await addScript ( ` ./_content/BootstrapBlazor.UniverSheet/univer/univerjs.preset-sheets-drawing/ locales/ ${ lang } .js` ) ;
17+ await addScript ( ` ./_content/BootstrapBlazor.UniverSheet/univer/univerjs.sheets-zen-editor/ locales/ ${ lang } .js` ) ;
18+ await addScript ( ` ./_content/BootstrapBlazor.UniverSheet/univer/univerjs.preset-sheets-data-validation/ locales/ ${ lang } .js` ) ;
1819
19- await addLink ( './_content/BootstrapBlazor.UniverSheet/univer/css/ univer-sheet.bundle.css' ) ;
20+ await addLink ( './_content/BootstrapBlazor.UniverSheet/univer/univer-sheet.bundle.css' ) ;
2021}
2122
22-
2323export async function createUniverSheetAsync ( sheet ) {
24- await loadAssets ( ) ;
25-
24+ await loadAssets ( sheet . lang ) ;
25+
2626 const { el } = sheet ;
2727 const { LocaleType, merge } = UniverCore ;
2828 const { createUniver } = UniverPresets ;
@@ -31,18 +31,18 @@ export async function createUniverSheetAsync(sheet) {
3131 const { UniverSheetsZenEditorPlugin } = UniverSheetsZenEditor
3232 const { UniverSheetsDataValidationPlugin } = UniverSheetsDataValidation
3333 const { UniverSheetsDataValidationUIPlugin } = UniverSheetsDataValidationUi
34- const { defaultTheme } = UniverDesign ;
35-
34+ const lang = sheet . lang . replace ( '-' , '' )
35+ const langStr = lang . charAt ( 0 ) . toUpperCase ( ) + lang . slice ( 1 )
3636 const options = {
37- theme : sheet . options . theme ?? defaultTheme ,
38- locale : sheet . options . lang ?? LocaleType . ZH_CN ,
37+ theme : UniverDesign [ sheet . theme ] ?? UniverDesign . defaultTheme , //'defaultTheme' | greenTheme
38+ locale : lang ,
3939 locales : {
40- [ LocaleType . ZH_CN ] : merge (
40+ [ lang ] : merge (
4141 { } ,
42- UniverPresetSheetsCoreZhCN ,
43- UniverPresetSheetsDrawingZhCN ,
44- UniverSheetsZenEditorZhCN ,
45- UniverSheetsDataValidationUiZhCN ,
42+ window [ `UniverPresetSheetsCore ${ langStr } ` ] ,
43+ window [ `UniverPresetSheetsDrawing ${ langStr } ` ] ,
44+ window [ `UniverSheetsZenEditor ${ langStr } ` ] ,
45+ window [ `UniverSheetsDataValidationUi ${ langStr } ` ] ,
4646 ) ,
4747 } ,
4848 plugins : [
@@ -51,7 +51,7 @@ export async function createUniverSheetAsync(sheet) {
5151 UniverSheetsDataValidationUIPlugin ,
5252 ]
5353 } ;
54- const plugins = sheet . options . plugins ?? {
54+ const plugins = sheet . plugins ?? {
5555 DefaultPlugin : '_content/BootstrapBlazor.UniverSheet/plugin.js'
5656 } ;
5757 for ( const name in plugins ) {
@@ -70,9 +70,9 @@ export async function createUniverSheetAsync(sheet) {
7070 ...options
7171 } ) ;
7272
73- const { data } = sheet . options . data || { } ;
74- if ( data ) {
75- const option = typeof data === 'string' ? JSON . parse ( data ) : data ;
73+ const { workbookData } = sheet . data || { } ;
74+ if ( workbookData ) {
75+ const option = typeof workbookData === 'string' ? JSON . parse ( workbookData ) : workbookData ;
7676 univerAPI . createWorkbook ( option ) ;
7777 }
7878 else {
0 commit comments