dsh-weekly-report-lau 1.1.3 → 1.2.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.
package/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # 周报工作台 · dsh-weekly-report-lau v1.1.3
1
+ # 周报工作台 · dsh-weekly-report v1.2.0
2
2
 
3
3
  **装上即用的 DSH 完整插件**:双击即装,自动注册 bundle、自动常驻面板服务、自动打开面板,全程不用敲命令。API Key、输出目录、绩效表与模板由使用者按需提供,插件负责识别并据此生成、输出。
4
4
 
@@ -12,7 +12,7 @@
12
12
  | 功能级 / 行为变化 | 第二位 | `1.0.x` → `1.1.0` |
13
13
  | 不兼容的大改版 | 第一位 | `1.x` → `2.0.0` |
14
14
 
15
- 当前 **1.1.3**:面板服务与面板页显示的版本号都直接读 `package.json`,不会再出现「包是新的、界面还是旧号」。1.1.3 概览「周报格式」预览改为通用脱敏示例值(不含真实学校、链接或工单号),并移除「看真实数据」入口。1.1.2 面板样式全面改用 flex 布局(兼容不支持 CSS Grid 的旧内核 WebView)、开关改为「滑块 / 文案 / 已开启已关闭徽标」单行 flex 结构、按钮与说明文字分层更清晰。1.1.1 修复开关滑块与文字重叠、开关增加「已开启/已关闭」状态徽标、结构检测结果不再贴顶。
15
+ 当前 **1.2.0**:新增「定时生成」模块(设置页配置每周生成时间,插件内置调度器到点自动生成并同步绩效表,默认周六 12:00、默认关闭;左下角实时展示定时安排)。1.1.3 面板服务与面板页显示的版本号都直接读 `package.json`,不会再出现「包是新的、界面还是旧号」。1.1.3 概览「周报格式」预览改为通用脱敏示例值(不含真实学校、链接或工单号),并移除「看真实数据」入口。1.1.2 面板样式全面改用 flex 布局(兼容不支持 CSS Grid 的旧内核 WebView)、开关改为「滑块 / 文案 / 已开启已关闭徽标」单行 flex 结构、按钮与说明文字分层更清晰。1.1.1 修复开关滑块与文字重叠、开关增加「已开启/已关闭」状态徽标、结构检测结果不再贴顶。
16
16
 
17
17
  ## 双击即装(零命令)
18
18
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-weekly-report-lau",
3
- "version": "1.1.3",
3
+ "version": "1.2.0",
4
4
  "type": "module",
5
5
  "description": "周报工作台 · 装上即用的 DSH 完整插件:一键安装、自动常驻、面板零手工启动,按使用者提供的 API Key 与路径模板生成周报与绩效表。",
6
6
  "main": "./lib/index.js",
@@ -14,6 +14,9 @@
14
14
  "files": [
15
15
  "lib",
16
16
  "service",
17
+ "!service/engine/.cache",
18
+ "!service/engine/.cache/**",
19
+ "!service/**/.cache/**",
17
20
  "locale",
18
21
  "icon.svg",
19
22
  "cordis.patch.yml",
@@ -25,10 +28,7 @@
25
28
  "一键安装.vbs",
26
29
  "一键安装.cmd",
27
30
  "一键安装.command",
28
- "install.sh",
29
- "!service/engine/.cache",
30
- "!service/engine/.cache/**",
31
- "!service/**/.cache/**"
31
+ "install.sh"
32
32
  ],
33
33
  "comment:distribution": "完整分发包请保留 node_modules/(内含 exceljs,绩效表功能零网络可用);精简包可由 install.mjs 或设置页自动补装。",
34
34
  "dsh": {
package/plugin.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-weekly-report-lau",
3
- "version": "1.1.3",
3
+ "version": "1.2.0",
4
4
  "displayName": {
5
5
  "zh": "周报工作台",
6
6
  "en": "Weekly Report Studio"
@@ -43,7 +43,7 @@
43
43
  "verified": {
44
44
  "installChecks": "9/9",
45
45
  "smoke": "68/68",
46
- "hostRevive": "12s 内拉起 v1.1.3",
46
+ "hostRevive": "12s 内拉起 v1.2.0",
47
47
  "installDeps": "ok / mode=bundled",
48
48
  "reportRepair": "1 处补全,其余 5 份历史文件未重写",
49
49
  "perfWrite": "就地写入 2 个单元格,结构指纹前后一致"
@@ -53,7 +53,7 @@
53
53
  "repairTool": "service/engine/repair-report.mjs(npm run repair / 历史页「检查格式」)",
54
54
  "openDir": "WINDIR 绝对路径 explorer.exe,/select 选中文件,错误不再被吞,前端 toast 反馈"
55
55
  },
56
- "version": "1.1.3",
56
+ "version": "1.2.0",
57
57
  "versionRule": {
58
58
  "minor": "最后一位",
59
59
  "feature": "第二位",
@@ -106,8 +106,15 @@
106
106
  "progress"
107
107
  ],
108
108
  "scheduleHint": "每周六 12:00",
109
+ "scheduledRun": {
110
+ "enabled": "默认关闭,设置页开启",
111
+ "default": "周六 12:00 + 同步绩效表",
112
+ "engine": "服务内置调度器(setInterval 20s tick + 分钟槽持久化去重),无需外部计划任务",
113
+ "ui": "设置页「定时生成」卡片配置;面板左下角实时展示定时安排与下次运行时间"
114
+ },
109
115
  "timeRule": "已完成=开始~完成;未完成=开始~本周周日;任何一条结束时间不越过本周周日"
110
116
  },
117
+ "schedule": "每周(周几 + 时:分)自动生成本周周报,默认周六 12:00、默认关闭;由服务内置调度器触发(每 20s 检查、分钟槽持久化去重),不依赖系统计划任务;到点触发复用手动生成的全部校验与日志",
111
118
  "performanceRules": {
112
119
  "content": "本月全部周报内容填入绩效表,时间一致",
113
120
  "keepFormat": true,
package/service/paths.cjs CHANGED
@@ -28,7 +28,7 @@ function pickDataDir() {
28
28
  process.env.WEEKLY_DATA_DIR,
29
29
  path.join(home, '.dsh', 'weekly-report'),
30
30
  path.join(os.homedir(), '.dsh', 'weekly-report'),
31
- path.join(os.tmpdir(), 'dsh-weekly-report-lau'),
31
+ path.join(os.tmpdir(), 'dsh-weekly-report'),
32
32
  ].filter(Boolean);
33
33
  for (const dir of candidates) {
34
34
  try {
@@ -37,7 +37,7 @@ function pickDataDir() {
37
37
  return path.resolve(dir);
38
38
  } catch { /* 换下一个 */ }
39
39
  }
40
- return path.join(os.tmpdir(), 'dsh-weekly-report-lau');
40
+ return path.join(os.tmpdir(), 'dsh-weekly-report');
41
41
  }
42
42
 
43
43
  const DATA_DIR = pickDataDir();
@@ -88,6 +88,13 @@ function defaultConfig() {
88
88
  handler: '',
89
89
  threshold: 0.85,
90
90
  mcp_url: 'https://yanfa.scedu.tech/api/mcp',
91
+ schedule: {
92
+ enabled: false, // 定时生成默认关闭,由使用者在「设置」页开启
93
+ weekday: 6, // 0=周日 … 6=周六(Date#getDay 口径),默认每周六
94
+ hour: 12,
95
+ minute: 0,
96
+ perfAuto: true, // 定时生成时同步写入绩效表(提供目录才写)
97
+ },
91
98
  confirm: { send_mail: false, imap_host: '', imap_port: 993, lookback_days: 14, subject_keyword: '周报' },
92
99
  notify: {
93
100
  enabled: false,
@@ -68,6 +68,14 @@
68
68
  document.addEventListener('change', (e) => {
69
69
  const input = e.target;
70
70
  if (input && input.matches && input.matches('.ws-switch input[type="checkbox"]')) syncSwitchStates();
71
+ // 定时开关切换后立即让「生成日 / 时间 / 同步绩效表」跟着可用或禁用,不用等保存
72
+ if (input && input.id === 'f-schedule-enabled') {
73
+ const on = input.checked;
74
+ $('#schedule-box').querySelectorAll('select, input').forEach((el) => { el.disabled = !on; });
75
+ $('#f-schedule-perf').disabled = !on;
76
+ $('#schedule-perf-row').classList.toggle('is-disabled', !on);
77
+ $('#schedule-next-hint').textContent = on ? '保存后生效' : '未开启';
78
+ }
71
79
  });
72
80
  syncSwitchStates();
73
81
 
@@ -157,6 +165,12 @@
157
165
  $('#f-perf-template').value = c.perf_template || '';
158
166
  $('#f-perf-insert').checked = Boolean(c.perf_allow_insert);
159
167
  $('#f-threshold').value = c.threshold ?? 0.85;
168
+ const sc = c.schedule || {};
169
+ $('#f-schedule-enabled').checked = Boolean(sc.enabled);
170
+ $('#f-schedule-day').value = String(sc.weekday ?? 6);
171
+ $('#f-schedule-time').value = `${String(sc.hour ?? 12).padStart(2, '0')}:${String(sc.minute ?? 0).padStart(2, '0')}`;
172
+ $('#f-schedule-perf').checked = sc.perfAuto !== false;
173
+ renderSchedule(st);
160
174
  $('#f-notify').checked = Boolean(c.notify && c.notify.enabled);
161
175
  $('#smtp-box').hidden = !$('#f-notify').checked;
162
176
  $('#notify-badge').textContent = $('#f-notify').checked ? '已开启' : '默认关闭';
@@ -188,6 +202,42 @@
188
202
  $('#btn-run').disabled = !(st.key && st.key.present);
189
203
  }
190
204
 
205
+ // ---------------------------------------------------------------- 定时生成
206
+ const WEEKDAYS = ['周日', '周一', '周二', '周三', '周四', '周五', '周六'];
207
+
208
+ function fmtDateTime(iso) {
209
+ try {
210
+ const d = new Date(iso);
211
+ return `${d.getMonth() + 1}月${d.getDate()}日 ${String(d.getHours()).padStart(2, '0')}:${String(d.getMinutes()).padStart(2, '0')}`;
212
+ } catch { return ''; }
213
+ }
214
+
215
+ /** 左下角与设置卡片:展示跟随定时配置(开启显示安排与下次运行,关闭显示未开启)。 */
216
+ function renderSchedule(st) {
217
+ const sc = (st.config && st.config.schedule) || {};
218
+ const sch = st.schedule || {};
219
+ const on = Boolean(sc.enabled);
220
+ const day = WEEKDAYS[Number(sc.weekday ?? 6)] || '周六';
221
+ const hm = `${String(sc.hour ?? 12).padStart(2, '0')}:${String(sc.minute ?? 0).padStart(2, '0')}`;
222
+ // 左下角脚注
223
+ const nav = $('#nav-schedule-hint');
224
+ if (on) {
225
+ const next = sch.nextRunAt ? fmtDateTime(sch.nextRunAt) : '待计算';
226
+ nav.innerHTML = `定时:每周${day} ${hm}<br>下次 ${esc(next)}`;
227
+ nav.classList.add('is-on');
228
+ } else {
229
+ nav.textContent = '定时生成未开启';
230
+ nav.classList.remove('is-on');
231
+ }
232
+ // 设置卡片:下次运行 + 控件可用性
233
+ $('#schedule-next-hint').textContent = on
234
+ ? (sch.nextRunAt ? `下次:${fmtDateTime(sch.nextRunAt)}` : '已开启(时间待确认)')
235
+ : '未开启';
236
+ $('#schedule-box').querySelectorAll('select, input').forEach((el) => { el.disabled = !on; });
237
+ $('#f-schedule-perf').disabled = !on;
238
+ $('#schedule-perf-row').classList.toggle('is-disabled', !on);
239
+ }
240
+
191
241
  // ---------------------------------------------------------------- 模板
192
242
  /** 概览预览用的通用示例数据:全部为脱敏占位值,不含任何真实学校、链接或工单编号;
193
243
  * 实际生成时这些字段全部由本周工单/任务数据替换。 */
@@ -226,6 +276,13 @@
226
276
  perf_template: $('#f-perf-template').value.trim(),
227
277
  perf_allow_insert: $('#f-perf-insert').checked,
228
278
  threshold: Number($('#f-threshold').value) || 0.85,
279
+ schedule: {
280
+ enabled: $('#f-schedule-enabled').checked,
281
+ weekday: Number($('#f-schedule-day').value),
282
+ hour: Number(($('#f-schedule-time').value || '12:00').split(':')[0]),
283
+ minute: Number(($('#f-schedule-time').value || '12:00').split(':')[1]),
284
+ perfAuto: $('#f-schedule-perf').checked,
285
+ },
229
286
  notify: {
230
287
  enabled: $('#f-notify').checked,
231
288
  smtp: {
@@ -5,7 +5,7 @@
5
5
  <meta name="viewport" content="width=device-width, initial-scale=1">
6
6
  <title>周报工作台</title>
7
7
  <link rel="icon" type="image/svg+xml" href="/icon.svg">
8
- <link rel="stylesheet" href="/style.css?v=1.1.3">
8
+ <link rel="stylesheet" href="/style.css?v=1.2.0">
9
9
  </head>
10
10
  <body>
11
11
  <div class="ws-app">
@@ -33,7 +33,7 @@
33
33
  <button class="ws-nav__item" data-view="settings" type="button"><span class="ws-nav__ico">⚙</span>设置</button>
34
34
  <button class="ws-nav__item" data-view="history" type="button"><span class="ws-nav__ico">≡</span>历史</button>
35
35
  <div class="ws-nav__foot">
36
- <div class="ws-nav__hint">每周六 12:00 生成<br>周报与绩效表同步</div>
36
+ <div class="ws-nav__hint" id="nav-schedule-hint">定时生成未开启<br>可到「设置」里配置</div>
37
37
  </div>
38
38
  </nav>
39
39
 
@@ -211,6 +211,26 @@
211
211
  <div class="ws-chips" id="tpl-chips"></div>
212
212
  </div>
213
213
 
214
+ <div class="ws-card">
215
+ <div class="ws-card__head"><h2>定时生成</h2><span class="ws-card__hint" id="schedule-next-hint">未开启</span></div>
216
+ <label class="ws-switch"><input type="checkbox" id="f-schedule-enabled"><span class="ws-switch__track"></span><span class="ws-switch__label"><b>定时自动生成</b><small>插件内置定时器到点自动生成本周周报,不依赖系统计划任务;面板后台常驻即生效</small></span><em class="ws-switch__state"></em></label>
217
+ <div class="ws-field ws-field--2" id="schedule-box">
218
+ <div><label for="f-schedule-day">生成日(每周)</label>
219
+ <select id="f-schedule-day">
220
+ <option value="0">周日</option>
221
+ <option value="1">周一</option>
222
+ <option value="2">周二</option>
223
+ <option value="3">周三</option>
224
+ <option value="4">周四</option>
225
+ <option value="5">周五</option>
226
+ <option value="6" selected>周六</option>
227
+ </select></div>
228
+ <div><label for="f-schedule-time">生成时间</label><input type="time" id="f-schedule-time" value="12:00"></div>
229
+ </div>
230
+ <label class="ws-switch" id="schedule-perf-row"><input type="checkbox" id="f-schedule-perf"><span class="ws-switch__track"></span><span class="ws-switch__label"><b>定时生成时同步绩效表</b><small>与手动生成一致:本月全部周报内容逐格写入,表格格式保持不变(需提供绩效表目录)</small></span><em class="ws-switch__state"></em></label>
231
+ <p class="ws-card__desc">开启后,左下角会显示定时安排与下次运行时间;到点自动生成,结果可在「生成」页日志与「历史」页查看。服务重启后同一分钟不会重复生成。</p>
232
+ </div>
233
+
214
234
  <div class="ws-card">
215
235
  <div class="ws-card__head"><h2>邮件通知</h2><span class="ws-badge" id="notify-badge">默认关闭</span></div>
216
236
  <label class="ws-switch"><input type="checkbox" id="f-notify"><span class="ws-switch__track"></span><span class="ws-switch__label"><b>生成后发送邮件</b><small>默认关闭;需要时再填写 SMTP,插件不预置任何凭据</small></span><em class="ws-switch__state"></em></label>
@@ -310,6 +330,6 @@
310
330
  </div>
311
331
 
312
332
  <div class="ws-toast" id="toast" hidden></div>
313
- <script src="/app.js?v=1.1.3"></script>
333
+ <script src="/app.js?v=1.2.0"></script>
314
334
  </body>
315
335
  </html>
@@ -94,6 +94,8 @@ button { cursor: pointer; }
94
94
  .ws-nav__ico { width: 18px; text-align: center; font-size: 15px; opacity: .85; }
95
95
  .ws-nav__foot { margin-top: auto; padding: 16px 14px 0; border-top: 1px solid var(--line); flex: 0 0 auto; }
96
96
  .ws-nav__hint { font-size: 11px; line-height: 1.8; color: var(--text-3); }
97
+ .ws-nav__hint.is-on { color: var(--accent-strong); font-weight: 600; }
98
+ .ws-switch.is-disabled { opacity: .55; pointer-events: none; }
97
99
 
98
100
  .ws-main { flex: 1; min-width: 0; min-height: 0; max-width: 1040px; padding: 26px 32px 32px; overflow-y: auto; }
99
101
  .ws-view { display: none; animation: ws-in .25s ease both; }
@@ -205,13 +207,16 @@ button { cursor: pointer; }
205
207
  .ws-field--2 > div { flex: 1 1 200px; min-width: 0; }
206
208
  .ws-field__note { font-size: 11.5px; color: var(--text-3); margin-top: 7px; line-height: 1.6; }
207
209
  .ws-optional { font-weight: 400; color: var(--text-3); font-size: 11px; margin-left: 4px; }
208
- input[type=text], input[type=password], input[type=date], input[type=month], input[type=number], input:not([type]), textarea {
210
+ input[type=text], input[type=password], input[type=date], input[type=month], input[type=number], input[type=time], input:not([type]), textarea, select {
209
211
  width: 100%; padding: 9px 12px;
210
212
  background: var(--surface); color: var(--text);
211
213
  border: 1px solid var(--line-strong); border-radius: 9px;
212
214
  outline: none; transition: border-color .15s, box-shadow .15s;
215
+ font-size: 13px;
213
216
  }
214
- input:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
217
+ select { cursor: pointer; appearance: auto; }
218
+ input:focus, textarea:focus, select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
219
+ input:disabled, select:disabled, textarea:disabled { opacity: .55; cursor: not-allowed; background: var(--surface-soft); }
215
220
  input::placeholder, textarea::placeholder { color: #b3bac7; }
216
221
  .ws-textarea { font: 12.5px/1.8 var(--mono); resize: vertical; min-height: clamp(110px, 22dvh, 180px); }
217
222
  .ws-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
@@ -42,6 +42,79 @@ let run = {
42
42
  artifacts: { reports: [], perf: [], weeks: [] },
43
43
  };
44
44
 
45
+ // ---------------------------------------------------------------- 定时生成
46
+ /**
47
+ * 内置调度器:不依赖系统计划任务 / 外部 cron,面板服务常驻即生效。
48
+ * - 每 20 秒 tick 一次,命中「周几 + 时 + 分」且未触发过该分钟槽才触发;
49
+ * - 触发动作完全复用 startRun(API Key / 绩效表目录 / 组件等校验、运行日志全部一致);
50
+ * - 已触发的分钟槽持久化到数据目录,服务被心跳拉起重启后不会在同一分钟内重复生成。
51
+ */
52
+ const SCHEDULE_TICK_MS = 20000;
53
+ const SCHEDULE_STATE_FILE = () => path.join(P.DATA_DIR, 'schedule-state.json');
54
+ let sched = { lastSlot: '', lastRunAt: null, lastResult: null, timer: null };
55
+
56
+ function pad2(n) { return String(n).padStart(2, '0'); }
57
+
58
+ /** 计算下一次运行时刻;未开启或配置非法返回 null。 */
59
+ function computeNextRun(sc, now) {
60
+ if (!sc || !sc.enabled) return null;
61
+ const wd = Number(sc.weekday); const hh = Number(sc.hour); const mm = Number(sc.minute);
62
+ if (!Number.isInteger(wd) || wd < 0 || wd > 6) return null;
63
+ if (!Number.isInteger(hh) || hh < 0 || hh > 23) return null;
64
+ if (!Number.isInteger(mm) || mm < 0 || mm > 59) return null;
65
+ const base = now || new Date();
66
+ for (let i = 0; i < 8; i += 1) {
67
+ const d = new Date(base.getFullYear(), base.getMonth(), base.getDate() + i, hh, mm, 0, 0);
68
+ if (d.getDay() === wd && d.getTime() > base.getTime()) return d;
69
+ }
70
+ return null;
71
+ }
72
+
73
+ function readSchedState() {
74
+ try { return JSON.parse(fs.readFileSync(SCHEDULE_STATE_FILE(), 'utf8')) || {}; } catch { return {}; }
75
+ }
76
+
77
+ function writeSchedState(patch) {
78
+ try { P.atomicWrite(SCHEDULE_STATE_FILE(), JSON.stringify({ ...readSchedState(), ...patch }, null, 2) + '\n'); } catch { /* ignore */ }
79
+ }
80
+
81
+ /** 到点触发:复用 startRun 的全部校验与日志,并在运行日志里标注来源。 */
82
+ function scheduledFire(now) {
83
+ const slot = `${now.getFullYear()}${pad2(now.getMonth() + 1)}${pad2(now.getDate())}-${pad2(now.getHours())}${pad2(now.getMinutes())}`;
84
+ if (sched.lastSlot === slot || readSchedState().lastSlot === slot) return; // 本分钟已触发过
85
+ sched.lastSlot = slot;
86
+ writeSchedState({ lastSlot: slot });
87
+ const sc = P.loadConfig().config.schedule || {};
88
+ P.log(`schedule: fire ${slot} weekday=${sc.weekday} perfAuto=${sc.perfAuto ? 1 : 0}`);
89
+ const r = startRun({ period: 'current', perfAuto: Boolean(sc.perfAuto), scheduled: true });
90
+ sched.lastRunAt = new Date().toISOString();
91
+ sched.lastResult = r.ok ? 'started' : String(r.error || 'failed');
92
+ if (!r.ok) P.log(`schedule: trigger rejected: ${r.error || '未知原因'}`);
93
+ else pushLine(`[scheduled] 定时任务已触发(${slot})`);
94
+ }
95
+
96
+ function scheduleTick() {
97
+ try {
98
+ const sc = P.loadConfig().config.schedule;
99
+ if (!sc || !sc.enabled) return;
100
+ const now = new Date();
101
+ if (now.getDay() !== Number(sc.weekday)) return;
102
+ if (now.getHours() !== Number(sc.hour) || now.getMinutes() !== Number(sc.minute)) return;
103
+ if (run.running) return; // 有手动任务在跑就不抢,下个周期再触发
104
+ scheduledFire(now);
105
+ } catch (e) { P.log(`schedule tick error: ${(e && e.message) || e}`); }
106
+ }
107
+
108
+ function startScheduler() {
109
+ if (sched.timer) clearInterval(sched.timer);
110
+ const st = readSchedState();
111
+ sched.lastSlot = String(st.lastSlot || '');
112
+ if (typeof st.lastRunAt === 'string') sched.lastRunAt = st.lastRunAt;
113
+ if (typeof st.lastResult === 'string') sched.lastResult = st.lastResult;
114
+ sched.timer = setInterval(scheduleTick, SCHEDULE_TICK_MS);
115
+ if (sched.timer && typeof sched.timer.unref === 'function') sched.timer.unref();
116
+ }
117
+
45
118
  function json(res, code, body) {
46
119
  const text = JSON.stringify(body);
47
120
  res.writeHead(code, {
@@ -221,6 +294,12 @@ function collectState() {
221
294
  },
222
295
  config: P.maskConfig(cfg), configError: loaded.error,
223
296
  key: P.keyInfo(), excelAvailable: excelAvailable(),
297
+ schedule: {
298
+ config: cfg.schedule || null,
299
+ nextRunAt: (() => { const d = computeNextRun(cfg.schedule, new Date()); return d ? d.toISOString() : null; })(),
300
+ lastRunAt: sched.lastRunAt, lastResult: sched.lastResult,
301
+ running: run.running,
302
+ },
224
303
  checks: extra.checks, probe: extra.probe,
225
304
  reports: reports.slice(0, 12), reportCount: reports.length,
226
305
  run: publicRun(), serverTime: new Date().toISOString(),
@@ -587,6 +666,7 @@ server.on('error', (e) => {
587
666
  server.listen(PORT, HOST, () => {
588
667
  P.ensureDirs();
589
668
  P.loadConfig();
669
+ startScheduler();
590
670
  P.log(`weekly studio v${VERSION} on http://${HOST}:${PORT} · data=${P.DATA_DIR} · node=${process.version}`);
591
671
  console.log(`weekly studio v${VERSION} on http://${HOST}:${PORT} · data=${P.DATA_DIR}`);
592
672
  });
package/smoke.mjs CHANGED
@@ -230,6 +230,19 @@ try {
230
230
  ok('结构识别结果有可读表格样式', /\.ws-kv/.test(cssText), '');
231
231
  ok('版本号取自 package.json', /readFileSync\(path\.join\(__dirname, '\.\.', 'package\.json'\)/.test(fs.readFileSync(path.join(HERE, 'service', 'server.cjs'), 'utf8')), '');
232
232
 
233
+ // 定时生成模块:配置默认值、服务端调度器、UI 三层都要在
234
+ const pathsText = fs.readFileSync(path.join(HERE, 'service', 'paths.cjs'), 'utf8');
235
+ const srvText = fs.readFileSync(path.join(HERE, 'service', 'server.cjs'), 'utf8');
236
+ ok('定时生成有内置默认配置', /schedule:\s*\{[\s\S]*?enabled:\s*false[\s\S]*?weekday:\s*6[\s\S]*?hour:\s*12/.test(pathsText), '默认周六 12:00,关闭');
237
+ ok('服务端内置调度器', /function scheduleTick/.test(srvText) && /setInterval\(scheduleTick/.test(srvText) && /startScheduler\(\)/.test(srvText), '不依赖外部计划任务');
238
+ ok('定时触发的分钟槽会持久化去重', /SCHEDULE_STATE_FILE/.test(srvText) && /writeSchedState/.test(srvText), '');
239
+ ok('定时触发复用 startRun 校验', /startRun\(\{\s*period:\s*'current',\s*perfAuto:\s*Boolean\(sc\.perfAuto\),\s*scheduled:\s*true\s*\}\)/.test(srvText), '');
240
+ ok('state 接口返回下次运行时间', /nextRunAt/.test(srvText) && /computeNextRun/.test(srvText), '');
241
+ ok('设置页有定时生成卡片', ['f-schedule-enabled', 'f-schedule-day', 'f-schedule-time', 'f-schedule-perf', 'schedule-next-hint'].every((id) => htmlText.includes(`id="${id}"`)), '');
242
+ ok('左下角展示跟随定时配置', htmlText.includes('id="nav-schedule-hint"') && /renderSchedule/.test(jsText) && /定时:每周/.test(jsText), '');
243
+ ok('保存设置会写入 schedule 配置', /schedule:\s*\{[\s\S]*?weekday:\s*Number\(\$\('#f-schedule-day'\)\.value\)/.test(jsText), '');
244
+ ok('定时开关切换即时联动控件', /f-schedule-enabled'/.test(jsText) && /is-disabled/.test(cssText), '');
245
+
233
246
  const plugin = JSON.parse(fs.readFileSync(path.join(HERE, 'plugin.json'), 'utf8'));
234
247
  ok('plugin.json 声明装上即用', plugin.automatic.autoRegisterBundle === true && plugin.automatic.autoStartService === true, '');
235
248
  ok('声明会话数据仅作参考', plugin.dataSource.sessionData === 'design-reference-only', '');
@@ -72,7 +72,7 @@ footer{text-align:center;color:var(--text3);font-size:11.5px;padding:20px 0 40px
72
72
  <h1>装上,就能用</h1>
73
73
  <p>一条命令完成安装与启动,不用重启 DSH、不用手工拉服务。API Key、输出目录、绩效表与模板由你按需提供,插件负责识别并据此生成、输出。</p>
74
74
  <div class="stat">
75
- <div><b>v1.1.3</b><small>版本号取自 package.json</small></div>
75
+ <div><b>v1.2.0</b><small>版本号取自 package.json</small></div>
76
76
  <div><b>0 预置凭据</b><small>邮件默认关闭</small></div>
77
77
  <div><b>4 个页面</b><small>概览 / 生成 / 设置 / 历史</small></div>
78
78
  </div>
@@ -145,10 +145,10 @@ footer{text-align:center;color:var(--text3);font-size:11.5px;padding:20px 0 40px
145
145
  <section id="s6" data-t="周报格式 模板 占位符 category school time subject work note progress"><h2>6 · 周报格式与模板</h2>
146
146
  <p>沿用你在历史会话里约定的块格式,输出与之前的样例逐字一致:</p>
147
147
  <pre><button class="copy">复制</button>【项目运维】
148
- 四川传媒学院
148
+ ×× 学校(示例)
149
149
  时间: 2026年11月9日
150
- 事项: 帆软报表健康巡检异常提示
151
- 工作内容:https://yanfa.scedu.tech/?tab=ticket-detail&amp;ticketId=195
150
+ 事项: 某系统例行巡检(示例事项)
151
+ 工作内容:https://example.com/ticket/0000(示例链接)
152
152
  重要说明:无
153
153
  进度:100%</pre>
154
154
  <table><tr><th>占位符</th><th>含义</th></tr>