@lark-apaas/fullstack-rspack-preset 1.0.1-alpha.echarts.3 → 1.0.1-alpha.echarts.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -31,6 +31,7 @@ function resgisterEchartsTheme() {
31
31
  return;
32
32
  }
33
33
  isRegistered = true;
34
+ // 打包后main.js defer 执行,css会加载完成
34
35
  (0, echarts_2.registerTheme)('ud', (0, registry_echarts_theme_1.getShadcnEChartsTheme)());
35
36
  }
36
37
  resgisterEchartsTheme();
@@ -391,61 +391,3 @@ function getShadcnEChartsTheme() {
391
391
  // body
392
392
  return generateEChartsTheme(document.body);
393
393
  }
394
- // 监听主题变化并更新图表
395
- // eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/no-unused-vars
396
- function watchThemeChange(chart) {
397
- const observer = new MutationObserver((mutations) => {
398
- mutations.forEach((mutation) => {
399
- console.log(mutation);
400
- if (mutation.type === 'attributes' &&
401
- mutation.attributeName === 'data-theme-host') {
402
- const newTheme = generateEChartsTheme(document.documentElement);
403
- // 更新图表的颜色配置
404
- const currentOption = chart.getOption();
405
- console.log({
406
- ...newTheme,
407
- ...currentOption,
408
- });
409
- chart.setOption({
410
- ...newTheme,
411
- ...currentOption,
412
- });
413
- }
414
- });
415
- });
416
- observer.observe(document.documentElement, {
417
- attributes: true,
418
- attributeFilter: ['data-theme-host'],
419
- });
420
- return observer;
421
- }
422
- // 使用示例
423
- /*
424
- import * as echarts from 'echarts';
425
-
426
- // 方法1: 获取主题并初始化图表
427
- const theme = getShadcnEChartsTheme();
428
- const chart = echarts.init(document.getElementById('main'));
429
- chart.setOption({
430
- ...theme,
431
- xAxis: { type: 'category', data: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri'] },
432
- yAxis: { type: 'value' },
433
- series: [{ data: [120, 200, 150, 80, 70], type: 'line' }]
434
- });
435
-
436
- // 方法2: 监听主题变化自动更新
437
- const observer = watchThemeChange(chart);
438
-
439
- // 清理时取消监听
440
- // observer.disconnect();
441
-
442
- // 方法3: 只获取颜色数组
443
- const element = document.documentElement;
444
- const chartColors = [
445
- getCssVariable('--chart-1', element),
446
- getCssVariable('--chart-2', element),
447
- getCssVariable('--chart-3', element),
448
- getCssVariable('--chart-4', element),
449
- getCssVariable('--chart-5', element),
450
- ];
451
- */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lark-apaas/fullstack-rspack-preset",
3
- "version": "1.0.1-alpha.echarts.3",
3
+ "version": "1.0.1-alpha.echarts.4",
4
4
  "files": [
5
5
  "lib",
6
6
  "preset.config.js"