lumencode 0.4.4 → 1.1.0

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.
@@ -1,52 +1,13 @@
1
1
  import { ID } from './config.js';
2
+ import { destroyChart } from './utils.js';
2
3
 
3
4
  export function showSkeleton() {
4
- document.querySelectorAll('.card-value').forEach(el => {
5
- if (!el.classList.contains('skeleton')) {
6
- el._origText = el.textContent;
7
- el.textContent = '';
8
- el.classList.add('skeleton');
9
- }
10
- });
11
-
12
- document.querySelectorAll('.chart-wrap').forEach(el => {
13
- if (!el.querySelector('.chart-skeleton')) {
14
- const overlay = document.createElement('div');
15
- overlay.className = 'chart-skeleton';
16
- overlay.innerHTML = '<div class="chart-skeleton-bar"></div><div class="chart-skeleton-bar"></div><div class="chart-skeleton-bar"></div><div class="chart-skeleton-bar"></div><div class="chart-skeleton-bar"></div>';
17
- el.appendChild(overlay);
18
- }
19
- });
20
-
21
- const gitSection = document.getElementById(ID.GIT_SECTION);
22
- if (gitSection && gitSection.style.display !== 'none') {
23
- const gitStatsEl = document.getElementById(ID.GIT_STATS);
24
- if (gitStatsEl) {
25
- gitStatsEl.innerHTML = `
26
- <div class="git-skeleton-grid">
27
- <div><div class="skeleton" style="height:28px;width:60px;margin:0 auto 6px;border-radius:6px;"></div><div class="skeleton" style="height:14px;width:48px;margin:0 auto;border-radius:4px;"></div></div>
28
- <div><div class="skeleton" style="height:28px;width:60px;margin:0 auto 6px;border-radius:6px;"></div><div class="skeleton" style="height:14px;width:48px;margin:0 auto;border-radius:4px;"></div></div>
29
- <div><div class="skeleton" style="height:28px;width:60px;margin:0 auto 6px;border-radius:6px;"></div><div class="skeleton" style="height:14px;width:48px;margin:0 auto;border-radius:4px;"></div></div>
30
- <div><div class="skeleton" style="height:28px;width:60px;margin:0 auto 6px;border-radius:6px;"></div><div class="skeleton" style="height:14px;width:48px;margin:0 auto;border-radius:4px;"></div></div>
31
- </div>`;
32
- }
33
- const gitAiStats = document.getElementById(ID.GIT_AI_STATS);
34
- if (gitAiStats) {
35
- gitAiStats.innerHTML = `
36
- <div class="git-skeleton-grid" style="grid-template-columns:repeat(3,1fr);padding-top:14px;margin-top:14px;border-top:1px dashed var(--hairline);">
37
- <div><div class="skeleton" style="height:28px;width:50px;margin:0 auto 6px;border-radius:6px;"></div><div class="skeleton" style="height:14px;width:80px;margin:0 auto;border-radius:4px;"></div></div>
38
- <div><div class="skeleton" style="height:28px;width:50px;margin:0 auto 6px;border-radius:6px;"></div><div class="skeleton" style="height:14px;width:80px;margin:0 auto;border-radius:4px;"></div></div>
39
- <div><div class="skeleton" style="height:28px;width:50px;margin:0 auto 6px;border-radius:6px;"></div><div class="skeleton" style="height:14px;width:80px;margin:0 auto;border-radius:4px;"></div></div>
40
- </div>`;
41
- }
42
- const gitInsightsRow = document.getElementById(ID.GIT_INSIGHTS_ROW);
43
- if (gitInsightsRow) gitInsightsRow.style.display = 'none';
44
- }
5
+ /* In the new design, Alpine.js reactive state handles loading indicators.
6
+ This function is kept for API compatibility. */
45
7
  }
46
8
 
47
9
  export function hideSkeleton() {
48
- document.querySelectorAll('.card-value.skeleton').forEach(el => el.classList.remove('skeleton'));
49
- document.querySelectorAll('.chart-skeleton').forEach(el => el.remove());
10
+ /*同上*/
50
11
  }
51
12
 
52
13
  export function showError(msg) {
@@ -67,37 +28,17 @@ export function hideError() {
67
28
  }
68
29
 
69
30
  export function showEmpty() {
70
- document.querySelectorAll('.card-value').forEach(el => el.textContent = '-');
71
- document.getElementById(ID.STATS_GRID).style.display = 'none';
72
- document.getElementById(ID.ANALYTICS_SECTION).style.display = 'none';
73
- document.getElementById(ID.TREND_SECTION).style.display = 'none';
74
- document.getElementById(ID.GIT_SECTION).style.display = 'none';
75
31
  const wp = document.getElementById(ID.WELCOME_PAGE);
76
32
  if (wp) wp.style.display = 'flex';
77
- [ID.EXPORT_CSV_BTN, ID.PRINT_BTN, ID.WORK_REPORT_BTN].forEach(id => {
78
- const el = document.getElementById(id);
79
- if (el) el.style.display = 'none';
80
- });
81
33
  }
82
34
 
83
35
  export function hideEmpty() {
84
36
  const wp = document.getElementById(ID.WELCOME_PAGE);
85
37
  if (wp) wp.style.display = 'none';
86
- document.getElementById(ID.STATS_GRID).style.display = 'grid';
87
- document.getElementById(ID.ANALYTICS_SECTION).style.display = 'block';
88
- [ID.EXPORT_CSV_BTN, ID.PRINT_BTN, ID.WORK_REPORT_BTN].forEach(id => {
89
- const el = document.getElementById(id);
90
- if (el) el.style.display = '';
91
- });
92
38
  }
93
39
 
94
- export function clearReportUI(destroyChart) {
95
- document.querySelectorAll('.card-value').forEach(el => el.textContent = '-');
96
- document.querySelectorAll('.card-trend').forEach(el => el.textContent = '');
97
- document.getElementById(ID.ANALYTICS_SECTION).style.display = 'block';
98
- document.getElementById(ID.NO_DATA_HINT).style.display = 'block';
99
- document.getElementById(ID.CHARTS_DASHBOARD).style.display = 'none';
100
- document.getElementById(ID.TREND_SECTION).style.display = 'none';
101
- document.getElementById(ID.GIT_SECTION).style.display = 'none';
102
- [ID.SCENARIO_CHART, ID.MODEL_CHART, ID.PROJECT_CHART, ID.TOOL_CHART].forEach(destroyChart);
40
+ export function clearReportUI(destroyChartFn) {
41
+ hideEmpty();
42
+ const keys = [ID.SCENARIO_CHART, ID.MODEL_CHART, ID.PROJECT_CHART, ID.TOOL_CHART, ID.TREND_CHART, ID.CACHE_CHART, ID.MODEL_COST_CHART];
43
+ keys.forEach(destroyChart);
103
44
  }
package/public/utils.js CHANGED
@@ -1,3 +1,13 @@
1
+ // 获取今天日期字符串 YYYY-MM-DD
2
+ export function todayISO() {
3
+ return new Date().toISOString().slice(0, 10);
4
+ }
5
+
6
+ // 日期格式化 YYYY.MM.DD
7
+ export function fmtDate(d) {
8
+ return `${d.getFullYear()}.${String(d.getMonth() + 1).padStart(2, '0')}.${String(d.getDate()).padStart(2, '0')}`;
9
+ }
10
+
1
11
  // HTML 实体转义
2
12
  export function esc(s) {
3
13
  if (s == null) return '';
@@ -56,7 +56,7 @@ export function setWorkReportState(state) {
56
56
  if (state.level !== undefined) currentLevel = state.level;
57
57
  }
58
58
 
59
- // ── 加载并渲染工作汇报 ──
59
+ // ── 加载并渲染工作汇报 (legacy, kept for compatibility) ──
60
60
  export async function loadWorkReport(fetchFn, tool, period, date, platform, level) {
61
61
  if (platform) currentPlatform = platform;
62
62
  if (level) currentLevel = level;
@@ -67,33 +67,13 @@ export async function loadWorkReport(fetchFn, tool, period, date, platform, leve
67
67
  if (!res.ok) return;
68
68
  const markdown = await res.text();
69
69
  currentWorkReportMarkdown = markdown;
70
-
71
- let html = renderMarkdown(markdown);
72
- const platformLabels = { default: '标准', feishu: '飞书', dingtalk: '钉钉' };
73
- const platformClass = currentPlatform === 'feishu' ? 'feishu' : currentPlatform === 'dingtalk' ? 'dingtalk' : 'default';
74
- const badgeHtml = `<span class="platform-badge ${platformClass}">${platformLabels[currentPlatform] || '标准'}</span>`;
75
- html = html.replace(/(<h1 class="md-h1">.*?<\/h1>)/, `$1\n${badgeHtml}`);
76
-
77
- const content = document.getElementById(ID.WORK_REPORT_CONTENT);
78
- if (content) {
79
- content.innerHTML = html;
80
- content.classList.toggle('is-brief', currentLevel === 'brief');
81
- }
82
-
83
- document.getElementById(ID.STATS_GRID).style.display = 'none';
84
- document.getElementById(ID.ANALYTICS_SECTION).style.display = 'none';
85
- document.getElementById(ID.GIT_SECTION).style.display = 'none';
86
- document.getElementById(ID.WORK_REPORT_SECTION).style.display = 'block';
87
- document.getElementById(ID.WORK_REPORT_BTN).style.display = 'none';
88
70
  }
89
71
 
90
72
  // ── 复制 ──
91
73
  export async function copyWorkReport() {
92
74
  const text = currentWorkReportMarkdown;
93
- const btn = document.getElementById(ID.COPY_WORK_REPORT);
94
75
  try {
95
76
  await navigator.clipboard.writeText(text);
96
- if (btn) { btn.textContent = TEXT.COPIED; setTimeout(() => { btn.textContent = TEXT.COPY; }, 1500); }
97
77
  } catch {
98
78
  const ta = document.createElement('textarea');
99
79
  ta.value = text;
@@ -101,7 +81,6 @@ export async function copyWorkReport() {
101
81
  ta.select();
102
82
  document.execCommand('copy');
103
83
  document.body.removeChild(ta);
104
- if (btn) { btn.textContent = TEXT.COPIED; setTimeout(() => { btn.textContent = TEXT.COPY; }, 1500); }
105
84
  }
106
85
  }
107
86