dsh-schedule-calendar 0.3.7 → 0.4.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/lib/client.js CHANGED
@@ -16,7 +16,7 @@ window.__ModuleLoader__.load({
16
16
  const { useState, useEffect, useRef, useMemo, useCallback } = React;
17
17
 
18
18
  const NAME = "dsh-schedule-calendar";
19
- const VERSION = "0.3.7";
19
+ const VERSION = "0.4.0";
20
20
  const REPO_URL = "https://github.com/loyalchiiina/dsh-schedule-calendar";
21
21
  const ROUTE = "/schedule-calendar";
22
22
 
@@ -126,6 +126,12 @@ const REPO_URL = "https://github.com/loyalchiiina/dsh-schedule-calendar";
126
126
  function lunarCn(m, d) { return (LM_CN[m] || (m + "月")) + (LD_CN[d] || (d + "日")); }
127
127
  function solarMd(dateStr) { if (!dateStr) return ""; return Number(dateStr.slice(5, 7)) + "月" + Number(dateStr.slice(8, 10)) + "日"; }
128
128
  const CAL_COLORS = { weekend: "#fff3d6", rest: "#e3f5ec", holiday: "#ffe0e1", makeup: "#e5edff" };
129
+ const DEFAULT_REMINDERS = [
130
+ { id: "r-sit", type: "sit", emoji: "🧘", name: "久坐提醒", enabled: true, intervalMin: 45, start: "09:00", end: "18:00", msg: "久坐 45 分钟啦,起身活动一下、伸个懒腰吧~" },
131
+ { id: "r-drink", type: "drink", emoji: "💧", name: "喝水提醒", enabled: true, intervalMin: 90, start: "08:00", end: "20:00", msg: "该喝水啦,小口慢饮,别等口渴才喝~" },
132
+ { id: "r-eye", type: "fun", emoji: "🐟", name: "摸鱼/护眼", enabled: true, intervalMin: 60, start: "09:30", end: "18:00", msg: "摸鱼时间到~看看远处放松眼睛,别一直盯屏幕" },
133
+ { id: "r-music", type: "music", emoji: "🎵", name: "听音乐提醒", enabled: true, intervalMin: 90, start: "10:00", end: "18:00", msg: "放首歌听吧,调节心情,效率更高~" }
134
+ ];
129
135
  const BUFFS = ["鸿运当头", "日进斗金", "暴富", "诸事顺遂", "心想事成", "财源广进", "贵人相助", "步步高升", "平安喜乐", "锦鲤附体", "否极泰来", "福星高照", "时来运转", "喜从天降", "万事如意"];
130
136
  const HEALTH_TIPS = ["记得多喝水 💧", "久坐记得起身活动一下 🧘", "按时吃饭,别饿着 🍚", "早点休息,别熬夜 🌙", "用眼一小时,远眺 30 秒 👀", "保持好心情,笑一笑 😄", "活动一下颈椎和肩膀 🤸"];
131
137
  function solarSign(m, d) {
@@ -154,6 +160,10 @@ const REPO_URL = "https://github.com/loyalchiiina/dsh-schedule-calendar";
154
160
  s.settings.colors = Object.assign({ weekend: CAL_COLORS.weekend, rest: CAL_COLORS.rest, holiday: CAL_COLORS.holiday, makeup: CAL_COLORS.makeup }, s.settings.colors || {});
155
161
  s.settings.buff = Object.assign({ date: "", text: "", streak: 0 }, s.settings.buff || {});
156
162
  s.settings.showAlmanac = s.settings.showAlmanac !== false;
163
+ if (!Array.isArray(s.settings.reminders) || !s.settings.reminders.length) s.settings.reminders = JSON.parse(JSON.stringify(DEFAULT_REMINDERS));
164
+ s.settings.drink = Object.assign({ weightKg: 60, totalMl: 2100, cups: 9, cupMl: 233, start: "08:00", end: "20:00" }, s.settings.drink || {});
165
+ s.settings.diy = Object.assign({ enabled: false, dir: "", intervalSec: 30, veil: 0.35 }, s.settings.diy || {});
166
+ s.settings.update = Object.assign({ autoCheck: false, lastCheck: 0, lastLatest: "" }, s.settings.update || {});
157
167
  s.settings.showHoroscope = s.settings.showHoroscope !== false;
158
168
  s.weatherCities = Array.isArray(s.weatherCities) ? s.weatherCities : [];
159
169
  if (!Array.isArray(s.persons) || !s.persons.length) {
@@ -257,6 +267,20 @@ const REPO_URL = "https://github.com/loyalchiiina/dsh-schedule-calendar";
257
267
  }, [year]);
258
268
  return { days, err };
259
269
  }
270
+ const FREE_HOLIDAYS = { "春节": 1, "清明节": 1, "劳动节": 1, "国庆节": 1, "国庆": 1 };
271
+
272
+ function buildHolidayRanges(map) {
273
+ const dates = Object.keys(map || {}).filter((k) => map[k] && map[k].holiday === true).sort();
274
+ const ranges = [];
275
+ let cur = null;
276
+ for (const k of dates) {
277
+ const nm = (map[k] && map[k].name) || "假期";
278
+ if (cur && dateKey(addDays(parseKey(cur.end), 1)) === k) { cur.end = k; }
279
+ else { cur = { start: k, end: k, name: nm, free: !!FREE_HOLIDAYS[nm] }; ranges.push(cur); }
280
+ }
281
+ return ranges;
282
+ }
283
+
260
284
  function useHolidays(year) {
261
285
  const [map, setMap] = useState({});
262
286
  useEffect(() => {
@@ -326,17 +350,18 @@ const REPO_URL = "https://github.com/loyalchiiina/dsh-schedule-calendar";
326
350
 
327
351
  /* ============================ 样式 ============================ */
328
352
  const CSS = `
329
- .dsc-root{--bg:var(--dsc-bg,#f7f8fa);--card:#ffffff;--line:#e7e9ef;--txt:#1f2430;--sub:#8a90a0;--accent:#4f7cff;--accent2:#eaf1ff;--red:#e5484d;--green:#2fa36b;--warn:#f5a623;font-size:13px;color:var(--txt);display:flex;flex-direction:column;height:100%;min-height:0;background:var(--bg);border-radius:10px;overflow:hidden}
330
- @media (prefers-color-scheme:dark){.dsc-root{--bg:#1b1e26;--card:#242833;--line:#333a49;--txt:#e6e9f0;--sub:#9aa2b4;--accent:#5b86ff;--accent2:#26314d;--red:#ff6b6f;--green:#3fbf82}}
353
+ .dsc-root{--bg:var(--dsc-bg,#eef2fb);--card:#ffffff;--line:#e3e8f2;--txt:#1b2233;--sub:#7d879b;--accent:#4f7cff;--accent2:#e9f0ff;--red:#e5484d;--green:#22a06b;--warn:#e8901a;font-size:13px;color:var(--txt);display:flex;flex-direction:column;height:100%;min-height:0;background:linear-gradient(180deg,rgba(79,124,255,.06),rgba(255,255,255,0) 120px),var(--bg);border-radius:12px;overflow:hidden}
354
+ @media (prefers-color-scheme:dark){.dsc-root{--bg:#161a22;--card:#20242e;--line:#2f3644;--txt:#e8ebf2;--sub:#98a1b3;--accent:#5b86ff;--accent2:#243050;--red:#ff6b6f;--green:#3fbf82;--warn:#f0a83a}}
355
+ body[data-ds-dark-theme] .dsc-root{--bg:#161a22;--card:#20242e;--line:#2f3644;--txt:#e8ebf2;--sub:#98a1b3;--accent:#5b86ff;--accent2:#243050;--red:#ff6b6f;--green:#3fbf82;--warn:#f0a83a;background:linear-gradient(180deg,rgba(91,134,255,.08),rgba(0,0,0,0) 120px),var(--bg)}
331
356
  .dsc-root *{box-sizing:border-box}
332
357
  .dsc-launch{display:inline-flex;align-items:center;justify-content:center;gap:6px;height:30px;padding:0 10px;border-radius:8px;border:1px solid var(--dsc-line,#e7e9ef);background:transparent;color:inherit;cursor:pointer;font-size:13px;line-height:1;vertical-align:middle}
333
358
  .dsc-launch svg{display:block;flex:0 0 auto}
334
359
  .dsc-launch span{display:inline-flex;align-items:center;line-height:1;white-space:nowrap}
335
360
  .dsc-launch:hover{background:rgba(127,127,127,.12)}
336
- .dsc-head{padding:10px 12px 8px;border-bottom:1px solid var(--line);display:flex;align-items:center;gap:10px;flex-wrap:wrap;background:linear-gradient(180deg,rgba(79,124,255,.06),transparent)}
337
- .dsc-hdate{font-size:15px;font-weight:700;letter-spacing:.3px}
361
+ .dsc-head{padding:9px 12px 7px;border-bottom:1px solid var(--line);display:flex;align-items:center;gap:8px;flex-wrap:nowrap;background:linear-gradient(180deg,rgba(79,124,255,.07),transparent)}
362
+ .dsc-hdate{font-size:15.5px;font-weight:700;letter-spacing:.3px;flex:1 1 auto;min-width:0;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
338
363
  .dsc-hsub{font-size:12px;color:var(--sub)}
339
- .dsc-pill{margin-left:auto;display:inline-flex;align-items:center;gap:6px;padding:5px 10px;border-radius:999px;background:var(--accent2);color:var(--accent);font-weight:600;font-size:12px}
364
+ .dsc-pill{display:inline-flex;align-items:center;gap:6px;padding:5px 10px;border-radius:999px;background:var(--accent2);color:var(--accent);font-weight:600;font-size:12px;flex:0 0 auto;white-space:nowrap;font-variant-numeric:tabular-nums}
340
365
  .dsc-pill.rest{background:rgba(47,163,107,.14);color:var(--green)}
341
366
  .dsc-pill small{font-weight:500;opacity:.8}
342
367
  .dsc-buffbar{display:flex;align-items:center;gap:8px;padding:6px 12px;background:linear-gradient(90deg,rgba(245,166,35,.14),rgba(229,72,77,.08));border-bottom:1px solid var(--line);font-size:12px}
@@ -383,28 +408,44 @@ const REPO_URL = "https://github.com/loyalchiiina/dsh-schedule-calendar";
383
408
  .dsc-wi{font-size:17px;display:block}
384
409
  .dsc-wt{font-weight:600}
385
410
  .dsc-wp{color:var(--sub);font-size:11px}
386
- .dsc-cal-wrap{display:flex;gap:10px;align-items:flex-start;flex-wrap:wrap}
387
- .dsc-cal-left{flex:1 1 300px;min-width:270px}
388
- .dsc-cal-right{flex:1 1 210px;min-width:200px}
411
+ .dsc-cal-wrap{display:flex;flex-direction:column;gap:12px;align-items:stretch}
412
+ .dsc-cal-left{width:100%}
413
+ .dsc-cal-right{width:100%}
389
414
  .dsc-cal-h{display:flex;align-items:center;gap:6px;margin-bottom:6px}
390
415
  .dsc-cal-title{font-weight:700;font-size:14px}
391
- .dsc-cal-grid{display:grid;grid-template-columns:repeat(7,1fr);gap:3px}
392
- .dsc-wd{text-align:center;color:var(--sub);font-size:11px;padding:2px 0}
393
- .dsc-cell{position:relative;border:1px solid transparent;border-radius:8px;min-height:46px;padding:3px 4px;cursor:pointer;background:transparent;display:flex;flex-direction:column;align-items:flex-start}
416
+ .dsc-cal-grid{display:grid;grid-template-columns:repeat(7,1fr);gap:5px}
417
+ .dsc-wd{text-align:center;color:var(--sub);font-size:12px;font-weight:600;padding:3px 0}
418
+ .dsc-cell{position:relative;border:1px solid transparent;border-radius:10px;min-height:74px;padding:5px 6px;cursor:pointer;background:transparent;display:flex;flex-direction:column;align-items:flex-start;gap:1px}
394
419
  .dsc-cell:hover{background:rgba(127,127,127,.08)}
395
420
  .dsc-cell.out{opacity:.32}
396
- .dsc-cell.weekend{background:rgba(245,166,35,.16)}
397
- .dsc-cell.rest{background:rgba(47,163,107,.16)}
398
- .dsc-cell.holiday{background:rgba(229,72,77,.18)}
399
- .dsc-cell.makeup{background:rgba(79,124,255,.12)}
421
+ .dsc-cell.weekend{background:rgba(245,166,35,.13)}
422
+ .dsc-cell.rest{background:rgba(34,160,107,.14)}
423
+ .dsc-cell.holiday{background:rgba(229,72,77,.15)}
424
+ .dsc-cell.makeup{background:rgba(79,124,255,.11)}
400
425
  .dsc-cell.weekend .dsc-dnum,.dsc-cell.rest .dsc-dnum{color:var(--green)}
401
426
  .dsc-cell.holiday .dsc-dnum{color:var(--red)}
402
427
  .dsc-cell.sel{background:var(--accent2);border-color:var(--accent)}
403
428
  .dsc-cell.today .dsc-dnum{background:var(--accent);color:#fff;border-radius:6px}
404
- .dsc-dnum{font-size:12.5px;font-weight:700;line-height:18px;min-width:18px;text-align:center}
405
- .dsc-lunar{font-size:10px;color:var(--sub);line-height:1.2;white-space:nowrap;overflow:hidden;max-width:100%}
429
+ .dsc-dnum{font-size:15px;font-weight:700;line-height:20px;min-width:20px;text-align:left}
430
+ .dsc-lunar{font-size:11px;color:var(--sub);line-height:1.25;white-space:nowrap;overflow:hidden;max-width:100%}
406
431
  .dsc-lunar.fest{color:var(--red);font-weight:600}
407
432
  .dsc-lunar.term{color:var(--accent)}
433
+ .dsc-flag{position:absolute;top:3px;right:3px;font-size:10px;font-weight:700;line-height:1;padding:2px 5px;border-radius:6px;z-index:2}
434
+ .dsc-flag.off{background:rgba(34,160,107,.20);color:var(--green)}
435
+ .dsc-flag.on{background:rgba(79,124,255,.18);color:var(--accent)}
436
+ .dsc-holsum{display:flex;flex-wrap:wrap;gap:8px;margin:0 0 6px;font-size:11.5px;color:var(--sub)}
437
+ .dsc-holsum-item{background:rgba(229,72,77,.10);border-radius:6px;padding:2px 6px}
438
+ .dsc-holsum-item.free{background:rgba(34,160,107,.14);color:var(--green)}
439
+ .dsc-hol-free{position:absolute;right:26px;top:3px;font-size:9.5px;font-weight:700;line-height:1;padding:2px 4px;border-radius:5px;background:rgba(34,160,107,.22);color:var(--green);z-index:2}
440
+ .dsc-bglayer{position:absolute;inset:0;background-size:cover;background-position:center;background-repeat:no-repeat;transition:opacity .9s ease;pointer-events:none}
441
+ .dsc-bgscrim{position:absolute;inset:0;pointer-events:none;z-index:3}
442
+ .dsc-root.has-bg .dsc-dnum,.dsc-root.has-bg .dsc-lunar,.dsc-root.has-bg .dsc-muted,.dsc-root.has-bg .dsc-dayt,.dsc-root.has-bg .dsc-cal-title,.dsc-root.has-bg .dsc-wd,.dsc-root.has-bg .dsc-holsum,.dsc-root.has-bg .dsc-tab,.dsc-root.has-bg .dsc-hdate,.dsc-root.has-bg .dsc-title{text-shadow:0 1px 2px rgba(255,255,255,.85),0 0 6px rgba(255,255,255,.55)}
443
+ body[data-ds-dark-theme] .dsc-root.has-bg .dsc-dnum,body[data-ds-dark-theme] .dsc-root.has-bg .dsc-lunar,body[data-ds-dark-theme] .dsc-root.has-bg .dsc-muted,body[data-ds-dark-theme] .dsc-root.has-bg .dsc-dayt,body[data-ds-dark-theme] .dsc-root.has-bg .dsc-cal-title,body[data-ds-dark-theme] .dsc-root.has-bg .dsc-wd,body[data-ds-dark-theme] .dsc-root.has-bg .dsc-holsum,body[data-ds-dark-theme] .dsc-root.has-bg .dsc-tab,body[data-ds-dark-theme] .dsc-root.has-bg .dsc-hdate,body[data-ds-dark-theme] .dsc-root.has-bg .dsc-title{text-shadow:0 1px 2px rgba(0,0,0,.85),0 0 6px rgba(0,0,0,.6)}
444
+ .dsc-holiday-tag{position:absolute;left:3px;bottom:3px;font-size:9.5px;font-weight:700;line-height:1;padding:2px 4px;border-radius:5px;background:rgba(229,72,77,.20);color:var(--red);z-index:2}
445
+ .dsc-root{position:relative}
446
+ .dsc-bg{position:absolute;inset:0;z-index:0;background-size:cover;background-position:center;background-repeat:no-repeat;transition:background-image .5s ease}
447
+ .dsc-bg::after{content:"";position:absolute;inset:0;background:var(--bg);opacity:var(--dsc-bg-veil,.72)}
448
+ .dsc-head,.dsc-buffbar,.dsc-alert,.dsc-nav,.dsc-body{position:relative;z-index:4}
408
449
  .dsc-item.dim{opacity:.42;filter:grayscale(.4)}
409
450
  .dsc-item.dim .t{color:var(--sub)}
410
451
  .dsc-item.soon{border-left:4px solid var(--accent);background:rgba(79,124,255,.14);box-shadow:inset 0 0 0 1px rgba(79,124,255,.30)}
@@ -417,6 +458,52 @@ const REPO_URL = "https://github.com/loyalchiiina/dsh-schedule-calendar";
417
458
  .dsc-item .t{font-weight:600}
418
459
  .dsc-item .m{color:var(--sub);font-size:11.5px;margin-top:1px}
419
460
  .dsc-item.star{border-color:rgba(245,166,35,.5);background:rgba(245,166,35,.06)}
461
+ .dsc-desk{position:relative;width:100%;border:1px dashed var(--line);border-radius:12px;background:rgba(127,127,127,.03)}
462
+ .dsc-desk-icon{position:absolute;box-sizing:border-box;width:76px;height:96px;display:flex;flex-direction:column;align-items:center;gap:3px;padding:8px 4px;border:1px solid transparent;border-radius:12px;cursor:grab;user-select:none;-webkit-user-select:none;text-align:center;transition:background .15s,border-color .15s}
463
+ .dsc-desk-icon:hover{border-color:var(--line);background:rgba(127,127,127,.08)}
464
+ .dsc-desk-icon:active{cursor:grabbing}
465
+ .dsc-desk-icon.star{border-color:rgba(245,166,35,.5);background:rgba(245,166,35,.06)}
466
+ .dsc-desk-icon.dim{opacity:.5}
467
+ .dsc-desk-ico{font-size:30px;line-height:1}
468
+ .dsc-desk-t{font-size:11.5px;font-weight:600;max-width:100%;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
469
+ .dsc-desk-n{font-size:10px;color:var(--sub);max-width:100%;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
470
+ .dsc-ev-del{position:absolute;top:1px;right:2px;border:none;background:transparent;color:var(--sub);cursor:pointer;font-size:13px;line-height:1;padding:2px;opacity:0}
471
+ .dsc-ev-del:hover{color:var(--red);opacity:.9}
472
+ .dsc-desk-icon:hover .dsc-ev-del{opacity:.7}
473
+ .dsc-ev-lock{position:absolute;top:1px;left:2px;border:none;background:transparent;cursor:pointer;font-size:11px;line-height:1;padding:2px;opacity:0}
474
+ .dsc-desk-icon:hover .dsc-ev-lock{opacity:.7}
475
+ .dsc-desk-icon.locked .dsc-ev-lock{opacity:.95}
476
+ .dsc-desk-icon.locked{border-color:rgba(245,166,35,.5)}
477
+ .dsc-desk-grid{display:grid;grid-template-columns:repeat(auto-fill,minmax(78px,1fr));gap:10px;padding:10px;border:1px dashed var(--line);border-radius:12px;background:rgba(127,127,127,.03)}
478
+ .dsc-desk-cell{position:relative;display:flex;flex-direction:column;align-items:center;gap:4px;padding:12px 6px 10px;border:1px solid transparent;border-radius:12px;cursor:grab;user-select:none;-webkit-user-select:none;text-align:center;min-height:92px;transition:background .15s,border-color .15s}
479
+ .dsc-desk-cell:hover{border-color:var(--line);background:rgba(127,127,127,.08)}
480
+ .dsc-desk-cell.star{border-color:rgba(245,166,35,.5);background:rgba(245,166,35,.06)}
481
+ .dsc-desk-cell.dim{opacity:.5}
482
+ .dsc-desk-cell.locked{border-color:rgba(245,166,35,.5)}
483
+ .dsc-desk-cell.dragover{border-color:var(--accent);background:rgba(79,124,255,.12)}
484
+ .dsc-desk-cell .dsc-ev-lock{position:absolute;top:1px;left:2px;border:none;background:transparent;cursor:pointer;font-size:11px;line-height:1;padding:2px;opacity:0}
485
+ .dsc-desk-cell:hover .dsc-ev-lock{opacity:.7}
486
+ .dsc-desk-cell.locked .dsc-ev-lock{opacity:.95}
487
+ .dsc-desk-cell .dsc-ev-del{position:absolute;top:1px;right:2px;border:none;background:transparent;color:var(--sub);cursor:pointer;font-size:13px;line-height:1;padding:2px;opacity:0}
488
+ .dsc-desk-cell:hover .dsc-ev-del{opacity:.7}
489
+ .dsc-ctxmenu{position:fixed;z-index:9999;background:var(--card);border:1px solid var(--line);border-radius:12px;box-shadow:0 12px 34px rgba(0,0,0,.32);padding:6px;display:flex;flex-direction:column;gap:2px;min-width:150px}
490
+ .dsc-ctxmenu-t{font-size:11px;color:var(--sub);padding:4px 10px 6px;font-weight:600;letter-spacing:.3px}
491
+ .dsc-ctxmenu button{display:flex;align-items:center;gap:8px;width:100%;border:none;background:transparent;cursor:pointer;font-size:13px;padding:8px 10px;border-radius:8px;color:var(--txt);text-align:left}
492
+ .dsc-ctxmenu button:hover{background:var(--accent2);color:var(--accent)}
493
+ .dsc-ctxmenu button.cancel{margin-top:4px;color:var(--sub);border-top:1px solid var(--line);border-radius:0 0 8px 8px;justify-content:center}
494
+ .dsc-ctxmenu button.cancel:hover{background:rgba(127,127,127,.12);color:var(--red)}
495
+ .dsc-root.has-bg{--card:rgba(255,255,255,.72)}
496
+ body[data-ds-dark-theme] .dsc-root.has-bg{--card:rgba(30,34,44,.66)}
497
+ .dsc-root.has-bg .dsc-card,.dsc-root.has-bg .dsc-input,.dsc-root.has-bg .dsc-select,.dsc-root.has-bg .dsc-textarea{backdrop-filter:blur(3px)}
498
+ .dsc-root.has-bg .dsc-card,.dsc-root.has-bg .dsc-cal-left,.dsc-root.has-bg .dsc-input,.dsc-root.has-bg .dsc-select,.dsc-root.has-bg .dsc-textarea{background:rgba(255,255,255,.55)!important;backdrop-filter:blur(6px)}
499
+ body[data-ds-dark-theme] .dsc-root.has-bg .dsc-card,body[data-ds-dark-theme] .dsc-root.has-bg .dsc-cal-left,body[data-ds-dark-theme] .dsc-root.has-bg .dsc-input,body[data-ds-dark-theme] .dsc-root.has-bg .dsc-select,body[data-ds-dark-theme] .dsc-root.has-bg .dsc-textarea{background:rgba(18,22,30,.55)!important;backdrop-filter:blur(6px)}
500
+ .dsc-root.has-bg .dsc-buffbar{background:rgba(255,255,255,.45)!important}
501
+ body[data-ds-dark-theme] .dsc-root.has-bg .dsc-buffbar{background:rgba(18,22,30,.45)!important}
502
+ .dsc-root{--dsc-scrim-rgb:247,249,252}
503
+ body[data-ds-dark-theme] .dsc-root{--dsc-scrim-rgb:18,22,30}
504
+ .dsc-root.has-bg.no-frost .dsc-card,.dsc-root.has-bg.no-frost .dsc-cal-left,.dsc-root.has-bg.no-frost .dsc-input,.dsc-root.has-bg.no-frost .dsc-select,.dsc-root.has-bg.no-frost .dsc-textarea{backdrop-filter:none!important}
505
+ .dsc-root.has-bg.no-frost .dsc-card,.dsc-root.has-bg.no-frost .dsc-cal-left{background:rgba(255,255,255,.22)!important}
506
+ body[data-ds-dark-theme] .dsc-root.has-bg.no-frost .dsc-card,body[data-ds-dark-theme] .dsc-root.has-bg.no-frost .dsc-cal-left{background:rgba(14,16,22,.22)!important}
420
507
  .dsc-time{font-variant-numeric:tabular-nums;font-weight:700;color:var(--accent);min-width:42px;font-size:12px}
421
508
  .dsc-badge{font-size:10px;padding:1px 6px;border-radius:999px;background:var(--accent2);color:var(--accent);font-weight:600}
422
509
  .dsc-badge.warn{background:rgba(245,166,35,.16);color:#b8860b}
@@ -570,7 +657,57 @@ const REPO_URL = "https://github.com/loyalchiiina/dsh-schedule-calendar";
570
657
  h("div", { className: "m" },
571
658
  [isLunar ? "农历" + lunarCn(ev.lunar.month, ev.lunar.day) : (ev.date ? "阳历" + solarMd(ev.date) : ""), ev.repeat && ev.repeat !== "none" && ev.repeat !== "lunar-yearly" ? (EV_LABEL[ev.repeat] || "") : "", ev.note || "", ev.remindMinutes ? "提前" + ev.remindMinutes + "分" : "", ev.createdAt ? "创建于" + ev.createdAt.slice(5, 16).replace("T", " ") : ""].filter(Boolean).join(" · ")),
572
659
  ev.star && lunar && !isLunar && lunar.fest ? h("span", { className: "dsc-badge warn" }, lunar.fest) : null),
573
- onDelete ? h(Btn, { kind: "mini ghost", onClick: () => onDelete(ev.id), title: "删除" }, "×") : null);
660
+ onDelete ? h(Btn, { kind: "mini ghost", onClick: () => { if (ev.locked) return; onDelete(ev.id); }, title: ev.locked ? "已上锁" : "删除" }, "×") : null);
661
+ }
662
+
663
+ const CATEGORIES = [
664
+ { key: "birthday", emoji: "🎂", name: "生日" },
665
+ { key: "anniversary", emoji: "🎁", name: "纪念日" },
666
+ { key: "festival", emoji: "🎉", name: "节日" },
667
+ { key: "memorial", emoji: "🕯", name: "祭奠/忌日" },
668
+ { key: "meeting", emoji: "📅", name: "日程/会议" },
669
+ { key: "reminder", emoji: "⏰", name: "提醒" },
670
+ { key: "star", emoji: "⭐", name: "星标/其他" }
671
+ ];
672
+ const CAT_EMOJI = {};
673
+ for (const cc of CATEGORIES) CAT_EMOJI[cc.key] = cc.emoji;
674
+
675
+ function eventIcon(ev) {
676
+ if (ev && ev.icon && CAT_EMOJI[ev.icon]) return CAT_EMOJI[ev.icon];
677
+ const t = String((ev && ev.title) || "");
678
+ if (/生日/.test(t)) return "🎂";
679
+ if (/纪念|结婚|周年/.test(t)) return "🎁";
680
+ if (/忌日|祭|清明|中元/.test(t)) return "🕯";
681
+ if (/节/.test(t)) return "🎉";
682
+ if (repeatOf(ev) === "lunar-yearly") return "🎂";
683
+ if (ev && ev.time) return "⏰";
684
+ if (ev && ev.star) return "⭐";
685
+ return "📅";
686
+ }
687
+
688
+ function isBday(ev) {
689
+ const ic = eventIcon(ev);
690
+ return ic === "🎂" || ic === "🎁";
691
+ }
692
+
693
+ function DeskIcon(props) {
694
+ const { ev, status, index, onReorder, onDelete, onToggleLock, onContext } = props;
695
+ const [over, setOver] = useState(false);
696
+ return h("div", {
697
+ className: "dsc-desk-cell" + (ev.star ? " star" : "") + (status ? " " + status : "") + (ev.locked ? " locked" : "") + (over ? " dragover" : ""),
698
+ draggable: true,
699
+ title: ev.title + (ev.note ? " · " + ev.note : ""),
700
+ onDragStart: (e) => { try { e.dataTransfer.setData("text/plain", String(index)); e.dataTransfer.effectAllowed = "move"; } catch (err) { /* ignore */ } },
701
+ onDragOver: (e) => { e.preventDefault(); try { e.dataTransfer.dropEffect = "move"; } catch (err) { /* ignore */ } if (!over) setOver(true); },
702
+ onDragLeave: () => setOver(false),
703
+ onDrop: (e) => { e.preventDefault(); setOver(false); let from = NaN; try { from = parseInt(e.dataTransfer.getData("text/plain"), 10); } catch (err) { /* ignore */ } if (!isNaN(from) && from !== index && onReorder) onReorder(from, index); },
704
+ onContextMenu: (e) => { if (onContext) onContext(e, ev); }
705
+ },
706
+ h("button", { className: "dsc-ev-lock", onClick: (e) => { e.stopPropagation(); onToggleLock && onToggleLock(ev.id); }, title: ev.locked ? "已上锁 · 点此解锁" : "点此上锁(上锁后需解锁才能删除)" }, ev.locked ? "🔒" : "🔓"),
707
+ h("button", { className: "dsc-ev-del", onClick: (e) => { e.stopPropagation(); onDelete && onDelete(ev); }, title: ev.locked ? "已上锁" : "删除" }, ev.locked ? "🔒" : "×"),
708
+ h("div", { className: "dsc-desk-ico" }, eventIcon(ev)),
709
+ h("div", { className: "dsc-desk-t" }, ev.title),
710
+ ev.note ? h("div", { className: "dsc-desk-n" }, ev.note) : null);
574
711
  }
575
712
 
576
713
  function TodoRow(props) {
@@ -595,6 +732,31 @@ const REPO_URL = "https://github.com/loyalchiiina/dsh-schedule-calendar";
595
732
  const [menu, setMenu] = useState(null);
596
733
  const { days: lunarDays } = useLunar(vy);
597
734
  const holidays = useHolidays(vy);
735
+ const holRanges = useMemo(() => buildHolidayRanges(holidays), [holidays]);
736
+ const freeDates = {};
737
+ holRanges.forEach((r) => { if (r.free) { let d = parseKey(r.start); const e = parseKey(r.end); let g = 0; while (d.getTime() <= e.getTime() && g < 400) { freeDates[dateKey(d)] = 1; d = addDays(d, 1); g++; } } });
738
+ const monthRanges = holRanges.filter((r) => { const ss = parseKey(r.start), ee = parseKey(r.end); const ms = new Date(vy, vm - 1, 1).getTime(); const me = new Date(vy, vm, 0).getTime(); return ee.getTime() >= ms && ss.getTime() <= me; });
739
+ const FEST_FREE = { "春节": 1, "清明节": 1, "劳动节": 1, "国庆节": 1 };
740
+ const FEST_NORM = { "春节": "春节", "元宵": "元宵节", "元宵节": "元宵节", "端午": "端午节", "端午节": "端午节", "中秋": "中秋节", "中秋节": "中秋节", "清明": "清明节", "清明节": "清明节" };
741
+ const festDays = {};
742
+ for (let ddd = 1; ddd <= new Date(vy, vm, 0).getDate(); ddd++) {
743
+ const kk = vy + "-" + pad(vm) + "-" + pad(ddd);
744
+ const ll = lunarDays && lunarDays[kk];
745
+ let nm = null;
746
+ if (ll && ll.term === "清明") nm = "清明节";
747
+ else if (ll && ll.fest && FEST_NORM[ll.fest]) nm = FEST_NORM[ll.fest];
748
+ else if (vm === 1 && ddd === 1) nm = "元旦";
749
+ else if (vm === 5 && ddd === 1) nm = "劳动节";
750
+ else if (vm === 10 && ddd === 1) nm = "国庆节";
751
+ if (nm) festDays[kk] = { name: nm, free: !!FEST_FREE[nm] };
752
+ }
753
+ Object.keys(festDays).forEach((kk) => { if (festDays[kk].free) freeDates[kk] = 1; });
754
+ const monthItems = monthRanges.slice();
755
+ Object.keys(festDays).sort().forEach((kk) => {
756
+ let covered = false;
757
+ for (const r of monthRanges) { if (kk >= r.start && kk <= r.end) { covered = true; break; } }
758
+ if (!covered) monthItems.push({ start: kk, end: kk, name: festDays[kk].name, free: !!freeDates[kk] });
759
+ });
598
760
  const occMap = useMemo(() => buildOccMap(store.events, lunarDays || {}, vy), [store.events, lunarDays, vy]);
599
761
  const person = store.persons.find((p) => p.id === store.settings.activePersonId) || store.persons[0];
600
762
 
@@ -634,6 +796,8 @@ const REPO_URL = "https://github.com/loyalchiiina/dsh-schedule-calendar";
634
796
  h("span", { className: "dsc-cal-title" }, vy + " 年 " + vm + " 月"),
635
797
  h(Btn, { kind: "mini ghost", onClick: () => shiftMonth(1) }, "›"),
636
798
  h("span", { style: { marginLeft: "auto" } }, h(Btn, { kind: "mini", onClick: () => { setVy(now.getFullYear()); setVm(now.getMonth() + 1); setSel(todayKey()); } }, "今天"))),
799
+ h("div", { className: "dsc-holsum" },
800
+ monthItems.length ? monthItems.map((r) => h("span", { key: r.start + r.name, className: "dsc-holsum-item" + (r.free ? " free" : "") }, r.name + " " + mmdd(r.start) + (r.start !== r.end ? "–" + mmdd(r.end) : "") + (r.free ? " · 高速免费" : ""))) : null),
637
801
  h("div", { className: "dsc-cal-grid" },
638
802
  ["一", "二", "三", "四", "五", "六", "日"].map((w) => h("div", { key: w, className: "dsc-wd" }, w)),
639
803
  cells.map((dt, i) => {
@@ -670,6 +834,9 @@ const REPO_URL = "https://github.com/loyalchiiina/dsh-schedule-calendar";
670
834
  onContextMenu: (e) => { e.preventDefault(); setSel(k); setMenu({ x: e.clientX, y: e.clientY, date: k }); },
671
835
  title: hol ? hol.name : (l ? l.monthCn + l.dayCn : "")
672
836
  },
837
+ (function () { let f = ""; if (holOff) f = "休"; else if (holMakeup) f = "班"; else if (isWeekend) f = (worked ? "班" : "休"); else if (!worked) f = "休"; return f ? h("span", { className: "dsc-flag " + (f === "休" ? "off" : "on") }, f) : null; })(),
838
+ freeDates[k] ? h("span", { className: "dsc-hol-free", title: "高速免费" }, "免") : null,
839
+ (holOff || holMakeup) ? h("span", { className: "dsc-holiday-tag", title: hol ? hol.name : "" }, holMakeup ? "调休" : "假") : null,
673
840
  h("div", { className: "dsc-dnum" }, dt.getDate()),
674
841
  h("div", { className: lunarCls }, lunarTxt || (hol ? hol.name : "")),
675
842
  h("div", { className: "dsc-dots" }, occ.slice(0, 4).map((ev, j) => h("span", { key: j, className: "dsc-dot" + (ev.star ? " star" : "") }))));
@@ -696,6 +863,28 @@ const REPO_URL = "https://github.com/loyalchiiina/dsh-schedule-calendar";
696
863
  const y0 = new Date().getFullYear();
697
864
  const l1 = useLunar(y0), l2 = useLunar(y0 + 1);
698
865
  const lunarAll = Object.assign({}, l1.days || {}, l2.days || {});
866
+ const deskRef = useRef(null);
867
+ const [deskW, setDeskW] = useState(320);
868
+ const [confirmDel, setConfirmDel] = useState(null);
869
+ const [notice, setNotice] = useState("");
870
+ const [catMenu, setCatMenu] = useState(null);
871
+ useEffect(() => {
872
+ const el = deskRef.current;
873
+ if (!el) return undefined;
874
+ const measure = () => { if (deskRef.current) setDeskW(deskRef.current.clientWidth || 320); };
875
+ measure();
876
+ let ro = null;
877
+ if (typeof ResizeObserver !== "undefined") { ro = new ResizeObserver(measure); ro.observe(el); }
878
+ window.addEventListener("resize", measure);
879
+ return () => { if (ro) ro.disconnect(); window.removeEventListener("resize", measure); };
880
+ }, [store && store.events ? store.events.length : 0]);
881
+ useEffect(() => {
882
+ if (!catMenu) return undefined;
883
+ const close = () => setCatMenu(null);
884
+ document.addEventListener("mousedown", close);
885
+ document.addEventListener("scroll", close, true);
886
+ return () => { document.removeEventListener("mousedown", close); document.removeEventListener("scroll", close, true); };
887
+ }, [catMenu]);
699
888
  const cyc = (ev) => {
700
889
  const r = repeatOf(ev);
701
890
  if (r === "none") return ev.date || "";
@@ -714,10 +903,53 @@ const REPO_URL = "https://github.com/loyalchiiina/dsh-schedule-calendar";
714
903
  const days = nxt ? Math.round((parseKey(nxt) - parseKey(today)) / 86400000) : 999;
715
904
  const soon = !dim && !!cd;
716
905
  return { ev: ev, sort: nxt || ev.date || "9999", status: dim ? "dim" : (soon ? "soon" : "") };
717
- }).sort((a, b) => String(a.sort).localeCompare(String(b.sort)));
906
+ }).sort((a, b) => {
907
+ const ao = typeof a.ev.ord === "number", bo = typeof b.ev.ord === "number";
908
+ if (ao && bo) return a.ev.ord - b.ev.ord;
909
+ if (ao) return -1;
910
+ if (bo) return 1;
911
+ return String(a.sort).localeCompare(String(b.sort));
912
+ });
913
+ const IW = 76, IH = 96, GX = 10, GY = 10, PAD = 6;
914
+ const perRow = Math.max(1, Math.floor((deskW - 2 * PAD + GX) / (IW + GX)));
915
+ const nEv = rows.length;
916
+ const rowsN = Math.max(1, Math.ceil(nEv / perRow));
917
+ const autoPos = (i) => { const r = Math.floor(i / perRow), c = i % perRow; return { x: PAD + c * (IW + GX), y: PAD + (rowsN - 1 - r) * (IH + GY) }; };
918
+ const colOf = (px) => Math.max(0, Math.round((px - PAD) / (IW + GX)));
919
+ const rowOf = (py) => Math.max(0, Math.round((py - PAD) / (IH + GY)));
920
+ const effPos = (r, i) => r.ev.pos || autoPos(i);
921
+ const maxRowUsed = rows.reduce((m, r, i) => Math.max(m, rowOf(effPos(r, i).y)), rowsN - 1);
922
+ const deskH = 2 * PAD + (maxRowUsed + 1) * IH + maxRowUsed * GY;
923
+ const bdays = rows.filter((r) => isBday(r.ev));
924
+ const allBdayLocked = bdays.length > 0 && bdays.every((r) => r.ev.locked);
718
925
  return h("div", null,
719
- h("div", { className: "dsc-sec-h" }, "全部日程", h("span", { className: "sp" }, h(Btn, { kind: "pri mini", onClick: () => goAdd(today) }, "+ 新建"))),
720
- rows.length ? rows.map((r) => h(EventRow, { key: r.ev.id, ev: r.ev, status: r.status, onDelete: (id) => update((s) => ({ ...s, events: s.events.filter((x) => x.id !== id) })) })) : h("div", { className: "dsc-card dsc-empty" }, "还没有日程"));
926
+ h("div", { className: "dsc-sec-h" }, "全部日程", h("span", { className: "sp" },
927
+ h(Btn, { kind: "mini", onClick: () => update((s) => ({ ...s, events: s.events.map((e) => (isBday(e) ? { ...e, locked: !allBdayLocked } : e)) })) }, allBdayLocked ? "🔓 解锁生日" : "🔒 一键上锁"),
928
+ h(Btn, { kind: "mini", onClick: () => update((s) => ({ ...s, events: s.events.map((e) => { const c = { ...e }; delete c.pos; delete c.ord; return c; }) })) }, "自动排列"),
929
+ h(Btn, { kind: "pri mini", onClick: () => goAdd(today) }, "+ 新建"))),
930
+ notice ? h("div", { className: "dsc-tagline" }, notice) : null,
931
+ confirmDel ? h("div", { className: "dsc-card", style: { borderColor: "var(--red)", marginBottom: 8 } },
932
+ h("div", { style: { fontSize: 12.5, marginBottom: 8 } }, "确定删除「" + (confirmDel.title || "该日程") + "」?此操作不可撤销。"),
933
+ h("div", { className: "dsc-row", style: { gap: 8 } },
934
+ h(Btn, { kind: "mini pri", onClick: () => { const id = confirmDel.id; setConfirmDel(null); update((s) => ({ ...s, events: s.events.filter((x) => x.id !== id) })); } }, "确定删除"),
935
+ h(Btn, { kind: "mini", onClick: () => setConfirmDel(null) }, "取消"))) : null,
936
+ rows.length
937
+ ? h("div", { className: "dsc-desk-grid" },
938
+ rows.map((r, i) => h(DeskIcon, {
939
+ key: r.ev.id,
940
+ ev: r.ev,
941
+ status: r.status,
942
+ index: i,
943
+ onReorder: (from, to) => { update((s) => { const order = rows.map((x) => x.ev.id); const mv = order.splice(from, 1)[0]; order.splice(to, 0, mv); const om = {}; order.forEach((id, idx) => { om[id] = idx; }); return { ...s, events: s.events.map((e) => ({ ...e, ord: (om[e.id] != null ? om[e.id] : e.ord) })) }; }); },
944
+ onToggleLock: (id) => update((s) => ({ ...s, events: s.events.map((e) => (e.id === id ? { ...e, locked: !e.locked } : e)) })),
945
+ onContext: (e, ev) => { e.preventDefault(); const w = (typeof window !== "undefined" ? window.innerWidth : 1200); const hh = (typeof window !== "undefined" ? window.innerHeight : 800); setCatMenu({ x: Math.max(6, Math.min(e.clientX, w - 170)), y: Math.max(6, Math.min(e.clientY, hh - 330)), id: ev.id }); },
946
+ onDelete: (ev) => { if (ev.locked) { setNotice("「" + (ev.title || "") + "」已上锁,请先点左上角🔒解锁再删除"); return; } setNotice(""); setConfirmDel(ev); }
947
+ })))
948
+ : h("div", { className: "dsc-card dsc-empty" }, "还没有日程"),
949
+ catMenu ? h("div", { className: "dsc-ctxmenu", style: { left: catMenu.x + "px", top: catMenu.y + "px" }, onMouseDown: (e) => e.stopPropagation() },
950
+ h("div", { className: "dsc-ctxmenu-t" }, "切换分类图标"),
951
+ CATEGORIES.map((c) => h("button", { key: c.key, onClick: () => { const id = catMenu.id; setCatMenu(null); update((s) => ({ ...s, events: s.events.map((e) => (e.id === id ? { ...e, icon: c.key } : e)) })); } }, h("span", { style: { fontSize: 16, lineHeight: 1 } }, c.emoji), h("span", null, c.name))),
952
+ h("button", { className: "cancel", onClick: () => setCatMenu(null) }, "取消")) : null);
721
953
  }
722
954
 
723
955
  /* ---------- 待办 ---------- */
@@ -981,6 +1213,24 @@ const REPO_URL = "https://github.com/loyalchiiina/dsh-schedule-calendar";
981
1213
  const [results, setResults] = useState([]);
982
1214
  const [busy, setBusy] = useState(false);
983
1215
  const [msg, setMsg] = useState("");
1216
+ const updRem = (fn) => update((s) => ({ ...s, settings: { ...s.settings, reminders: fn(s.settings.reminders || []) } }));
1217
+ const toggleReminder = (id) => updRem((arr) => arr.map((x) => x.id === id ? { ...x, enabled: !x.enabled } : x));
1218
+ const setReminderIv = (id, iv) => updRem((arr) => arr.map((x) => x.id === id ? { ...x, intervalMin: iv } : x));
1219
+ const delReminder = (id) => updRem((arr) => arr.filter((x) => x.id !== id));
1220
+ const addReminder = () => updRem((arr) => arr.concat([{ id: uid(), type: "custom", emoji: "⏰", name: "自定义提醒", enabled: true, intervalMin: 60, start: "09:00", end: "18:00", msg: "休息一下~" }]));
1221
+ const resetReminders = () => update((s) => ({ ...s, settings: { ...s.settings, reminders: JSON.parse(JSON.stringify(DEFAULT_REMINDERS)) } }));
1222
+ const drinkTotalMl = () => (store.settings.drink && store.settings.drink.totalMl) || 2100;
1223
+ const drinkCups = () => (store.settings.drink && store.settings.drink.cups) || 9;
1224
+ const setDrinkWeight = (w) => update((s) => { const totalMl2 = Math.round(w * 35); const cups = Math.max(1, Math.round(totalMl2 / 233)); return { ...s, settings: { ...s.settings, drink: { ...(s.settings.drink || {}), weightKg: w, totalMl: totalMl2, cups: cups } } }; });
1225
+ const diy = store.settings.diy || {};
1226
+ const setDiy = (patch) => update((s) => ({ ...s, settings: { ...s.settings, diy: { ...(s.settings.diy || {}), ...patch } } }));
1227
+ const browseFolder = async () => { try { const r = await postJson(apiUrl("/pick-folder"), {}); if (r && r.ok && r.path) setDiy({ dir: r.path }); else if (r && r.error) setMsg("选择文件夹失败:" + r.error); } catch (e) { setMsg(String((e && e.message) || e)); } };
1228
+ const updCfg = store.settings.update || {};
1229
+ const [upd, setUpd] = useState(null);
1230
+ const [updBusy, setUpdBusy] = useState(false);
1231
+ const setUpdateCfg = (patch) => update((s) => ({ ...s, settings: { ...s.settings, update: { ...(s.settings.update || {}), ...patch } } }));
1232
+ const checkUpdate = async () => { setUpdBusy(true); try { const r = await getJson(apiUrl("/update/check")); setUpd(r); setUpdateCfg({ lastCheck: Date.now(), lastLatest: (r && r.latest) || "" }); } catch (e) { setUpd({ ok: false, available: false, error: String((e && e.message) || e) }); } finally { setUpdBusy(false); } };
1233
+ useEffect(() => { const c = (store.settings && store.settings.update) || {}; if (c.autoCheck && Date.now() - (c.lastCheck || 0) > 86400000) checkUpdate(); }, []);
984
1234
  const search = async () => {
985
1235
  const s = q.trim(); if (!s) return;
986
1236
  setBusy(true); setMsg("");
@@ -1027,6 +1277,40 @@ const REPO_URL = "https://github.com/loyalchiiina/dsh-schedule-calendar";
1027
1277
  h("label", { className: "dsc-row" }, h("input", { type: "checkbox", checked: !!store.settings.workReminder, onChange: (e) => update((s) => ({ ...s, settings: { ...s.settings, workReminder: e.target.checked } })) }), "上下班提醒"),
1028
1278
  h("label", { className: "dsc-row", style: { marginTop: 4 } }, h("input", { type: "checkbox", checked: store.settings.showAlmanac !== false, onChange: (e) => update((s) => ({ ...s, settings: { ...s.settings, showAlmanac: e.target.checked } })) }), "今日头部显示黄历(宜/忌)"),
1029
1279
  h("label", { className: "dsc-row", style: { marginTop: 4 } }, h("input", { type: "checkbox", checked: store.settings.showHoroscope !== false, onChange: (e) => update((s) => ({ ...s, settings: { ...s.settings, showHoroscope: e.target.checked } })) }), "今日底部显示星座运势")),
1280
+ h("div", { className: "dsc-sec dsc-card" },
1281
+ h("div", { className: "dsc-sec-h" }, "健康/趣味提醒",
1282
+ h("span", { className: "sp" },
1283
+ h(Btn, { kind: "mini", onClick: resetReminders }, "恢复默认"),
1284
+ h(Btn, { kind: "mini pri", onClick: addReminder }, "+ 新增"))),
1285
+ (store.settings.reminders || []).map((rm) => h("div", { key: rm.id, className: "dsc-row", style: { marginBottom: 5 } },
1286
+ h("input", { type: "checkbox", checked: !!rm.enabled, onChange: () => toggleReminder(rm.id) }),
1287
+ h("span", { style: { flex: 1, minWidth: 60 } }, (rm.emoji || "⏰") + " " + (rm.name || "提醒")),
1288
+ h("span", { className: "dsc-muted", style: { fontSize: 11, whiteSpace: "nowrap" } }, "每 " + (rm.intervalMin || 60) + " 分"),
1289
+ h("input", { className: "dsc-input", type: "number", style: { width: 52 }, value: rm.intervalMin || 60, onChange: (e) => setReminderIv(rm.id, Math.max(5, Number(e.target.value) || 5)) }),
1290
+ h("button", { className: "dsc-btn mini ghost", onClick: () => delReminder(rm.id) }, "✕"))),
1291
+ h("div", { className: "dsc-sec-h", style: { marginTop: 10 } }, "喝水计划(科学饮水)"),
1292
+ h("div", { className: "dsc-row" },
1293
+ h("span", { className: "dsc-muted", style: { fontSize: 12 } }, "体重"),
1294
+ h("input", { className: "dsc-input", type: "number", style: { width: 64 }, value: (store.settings.drink && store.settings.drink.weightKg) || 60, onChange: (e) => setDrinkWeight(Number(e.target.value) || 60) }),
1295
+ h("span", { className: "dsc-muted", style: { fontSize: 12 } }, "kg → 每日约 " + drinkTotalMl() + " ml · " + drinkCups() + " 次 · 每次约 " + Math.round(drinkTotalMl() / drinkCups()) + " ml")),
1296
+ h("div", { className: "dsc-muted", style: { fontSize: 11, marginTop: 3 } }, "每日饮水量 ≈ 体重×35ml,分 8~10 次、每次 200~250ml,间隔约 1~1.5 小时;运动或天气热时适当增加。" )),
1297
+ h("div", { className: "dsc-sec dsc-card" },
1298
+ h("div", { className: "dsc-sec-h" }, "DIY 背景(壁纸文件夹轮播)"),
1299
+ h("label", { className: "dsc-row", style: { marginBottom: 6 } },
1300
+ h("input", { type: "checkbox", checked: !!diy.enabled, onChange: (e) => setDiy({ enabled: e.target.checked }) }),
1301
+ "启用背景图轮播(深浅色自动适配)"),
1302
+ h("label", { className: "dsc-row", style: { marginBottom: 6 } },
1303
+ h("input", { type: "checkbox", checked: diy.frost !== false, onChange: (e) => setDiy({ frost: e.target.checked }) }),
1304
+ "磨砂玻璃效果(关闭后更透明、能清楚看壁纸)"),
1305
+ h("div", { className: "dsc-row", style: { marginBottom: 6 } },
1306
+ h("input", { className: "dsc-input", style: { flex: 1, minWidth: 120 }, placeholder: "壁纸文件夹绝对路径,如 D:/壁纸,可手输或点浏览", value: diy.dir || "", onChange: (e) => setDiy({ dir: e.target.value }) }),
1307
+ h(Btn, { kind: "mini", onClick: browseFolder }, "浏览…")),
1308
+ h("div", { className: "dsc-row", style: { marginBottom: 6 } },
1309
+ h("span", { className: "dsc-muted", style: { fontSize: 12 } }, "切换间隔(秒)"),
1310
+ h("input", { className: "dsc-input", type: "number", style: { width: 64 }, min: 1, value: diy.intervalSec || 30, onChange: (e) => setDiy({ intervalSec: Math.max(1, Number(e.target.value) || 30) }) }),
1311
+ h("span", { className: "dsc-muted", style: { fontSize: 12 } }, "壁纸透明度(%)"),
1312
+ h("input", { className: "dsc-input", type: "number", style: { width: 64 }, min: 0, max: 100, value: Math.round((1 - (diy.veil == null ? 0.3 : diy.veil)) * 100), onChange: (e) => setDiy({ veil: Math.min(1, Math.max(0, 1 - (Number(e.target.value) || 0) / 100)) }) })),
1313
+ h("div", { className: "dsc-muted", style: { fontSize: 11, marginTop: 2 } }, "只需填壁纸文件夹路径;插件读取文件夹内图片(jpg/png/webp/gif)自动轮播为面板背景。「壁纸透明度」0~100(0=不显示壁纸,100=壁纸完全显示),建议 60~85;启用后卡片会半透明透出壁纸,深色/浅色模式自动适配。")),
1030
1314
  h("div", { className: "dsc-sec dsc-card" },
1031
1315
  h("div", { className: "dsc-sec-h" }, "日历配色(点色块改颜色)"),
1032
1316
  [["weekend", "周末"], ["rest", "休息日"], ["holiday", "法定假期"], ["makeup", "补班上班"]].map((pair) =>
@@ -1044,6 +1328,20 @@ const REPO_URL = "https://github.com/loyalchiiina/dsh-schedule-calendar";
1044
1328
  h("div", { className: "dsc-row" },
1045
1329
  h("span", { style: { flex: 1, fontSize: 12 } }, "日程助手 · 开源插件,喜欢请点个 Star ⭐"),
1046
1330
  h(Btn, { kind: "mini pri", onClick: () => { try { window.open(REPO_URL, "_blank"); } catch (e) { /* ignore */ } } }, "GitHub Star"))),
1331
+ h("div", { className: "dsc-sec dsc-card" },
1332
+ h("div", { className: "dsc-sec-h" }, "关于与更新"),
1333
+ h("div", { className: "dsc-row", style: { marginBottom: 6 } },
1334
+ h("span", { style: { flex: 1, fontSize: 12 } }, "当前版本 v" + VERSION),
1335
+ h(Btn, { kind: "mini pri", onClick: checkUpdate }, updBusy ? "检查中…" : "检查更新")),
1336
+ upd && upd.installType === "local" ? h("div", { className: "dsc-muted", style: { fontSize: 11.5, lineHeight: 1.6, marginTop: 2 } }, "当前为本地开发版(link 安装),如需更新请 git pull 或重新发布;不支持从 npm 一键安装。") : null,
1337
+ upd && upd.error ? h("div", { className: "dsc-muted", style: { fontSize: 11.5, color: "#e05a5a", marginTop: 2 } }, "检查失败:" + upd.error + "(可稍后重试)") : null,
1338
+ upd && !upd.error && upd.ok ? h("div", { style: { fontSize: 12, lineHeight: 1.7, marginTop: 4 } },
1339
+ h("div", null, "最新版本:" + (upd.latest || "未知") + (upd.hasUpdate ? " 🆕 有新版本" : " ✓ 已是最新")),
1340
+ upd.source ? h("div", { className: "dsc-muted", style: { fontSize: 11 } }, "来源:" + upd.source) : null,
1341
+ upd.hasUpdate && upd.installType !== "local" ? h("div", { style: { marginTop: 6 } }, h(Btn, { kind: "mini", onClick: () => { try { window.open(upd.latestUrl || REPO_URL, "_blank"); } catch (e) { /* ignore */ } } }, "查看新版"), h("span", { className: "dsc-muted", style: { fontSize: 11, marginLeft: 6 } }, "升级需手动批准并重启")) : null) : null,
1342
+ h("label", { className: "dsc-row", style: { marginTop: 8 } },
1343
+ h("span", { style: { flex: 1, fontSize: 12 } }, "自动检查更新(仅检查并提示,不自动安装)"),
1344
+ h("input", { type: "checkbox", checked: !!updCfg.autoCheck, onChange: (e) => { setUpdateCfg({ autoCheck: e.target.checked }); if (e.target.checked) checkUpdate(); } }))),
1047
1345
  h("div", { className: "dsc-tagline", style: { textAlign: "center", marginTop: 12 } }, "日程助手 v" + VERSION));
1048
1346
  }
1049
1347
 
@@ -1096,6 +1394,63 @@ const REPO_URL = "https://github.com/loyalchiiina/dsh-schedule-calendar";
1096
1394
  }
1097
1395
 
1098
1396
  /* ============================ 主 Tab ============================ */
1397
+ function MailView(props) {
1398
+ const [st, setSt] = useState(null);
1399
+ const [items, setItems] = useState([]);
1400
+ const [sel, setSel] = useState(null);
1401
+ const [busy, setBusy] = useState(false);
1402
+ const [msg, setMsg] = useState("");
1403
+ const [email, setEmail] = useState("");
1404
+ const [authCode, setAuthCode] = useState("");
1405
+ const [label, setLabel] = useState("");
1406
+ const load = useCallback(async () => {
1407
+ try {
1408
+ const a = await getJson(apiUrl("/mail/state"));
1409
+ setSt(a);
1410
+ const l = await getJson(apiUrl("/mail/list", "since=0"));
1411
+ setItems(((l && l.items) || []).slice().reverse());
1412
+ } catch (e) { setMsg("加载失败:" + String((e && e.message) || e)); }
1413
+ }, []);
1414
+ useEffect(() => { load(); const t = setInterval(load, 8000); return () => clearInterval(t); }, [load]);
1415
+ const post = async (path, body) => { setBusy(true); try { const r = await postJson(apiUrl(path), body || {}); if (r && r.ok === false && r.error) setMsg(r.error); await load(); return r; } catch (e) { setMsg(String((e && e.message) || e)); } finally { setBusy(false); } };
1416
+ const accounts = (st && st.accounts) || [];
1417
+ const enabled = !!(st && st.enabled);
1418
+ return h("div", null,
1419
+ h("div", { className: "dsc-sec-h" }, "邮件监控", h("span", { className: "sp" },
1420
+ h(Btn, { kind: "mini", onClick: () => post("/mail/mock-inject", {}) }, "模拟一封"),
1421
+ h(Btn, { kind: "mini pri", onClick: () => post("/mail/config", { enabled: !enabled }) }, enabled ? "关闭监控" : "开启监控"))),
1422
+ msg ? h("div", { className: "dsc-tagline" }, msg) : null,
1423
+ h("div", { className: "dsc-card", style: { marginBottom: 10 } },
1424
+ h("div", { className: "dsc-muted", style: { fontSize: 11.5, marginBottom: 6 } }, "状态:" + (enabled ? "监控中" : "未开启") + " · 账号 " + accounts.length + " · 邮件 " + ((st && st.total) || 0)),
1425
+ accounts.length ? accounts.map((a) => h("div", { key: a.id, className: "dsc-row", style: { marginBottom: 5 } },
1426
+ h("span", { style: { flex: 1, minWidth: 0, overflow: "hidden", textOverflow: "ellipsis", whiteSpace: "nowrap" } }, (a.label || a.email) + (a.hasAuthCode ? "" : "(缺授权码)") + (a.lastError ? " ⚠" + a.lastError : "")),
1427
+ h(Btn, { kind: "mini", onClick: () => post("/mail/account/test", { id: a.id }) }, "测试"),
1428
+ h(Btn, { kind: "mini ghost", onClick: () => post("/mail/account/delete", { id: a.id }) }, "删除"))) : h("div", { className: "dsc-muted", style: { fontSize: 12 } }, "还没有账号,添加一个 QQ 邮箱账号:"),
1429
+ h("div", { className: "dsc-row", style: { marginTop: 6, gap: 6 } },
1430
+ h("input", { className: "dsc-input", style: { flex: 1, minWidth: 90 }, placeholder: "备注(可选)", value: label, onChange: (e) => setLabel(e.target.value) }),
1431
+ h("input", { className: "dsc-input", style: { flex: 1.3, minWidth: 110 }, placeholder: "QQ邮箱地址", value: email, onChange: (e) => setEmail(e.target.value) })),
1432
+ h("div", { className: "dsc-row", style: { marginTop: 6, gap: 6 } },
1433
+ h("input", { className: "dsc-input", style: { flex: 1, minWidth: 110 }, type: "password", placeholder: "IMAP 授权码", value: authCode, onChange: (e) => setAuthCode(e.target.value) }),
1434
+ h(Btn, { kind: "mini pri", onClick: async () => { if (!email.trim()) { setMsg("请填邮箱地址"); return; } const r = await post("/mail/account/save", { label: label.trim() || email.trim(), email: email.trim(), authCode: authCode.trim() }); if (r && r.ok) { setEmail(""); setAuthCode(""); setLabel(""); setMsg("已保存账号"); } } }, "保存账号"))),
1435
+ h("div", { className: "dsc-muted", style: { fontSize: 11.5, lineHeight: 1.7, margin: "2px 0 10px" } },
1436
+ "IMAP 授权码不是 QQ 密码。获取:电脑登录 QQ邮箱网页版 → 设置 → 账号 → 账号与安全 → 安全设置 → POP3/IMAP/SMTP 服务 → 生成授权码(首次需手机短信验证),填上方授权码框。",
1437
+ h("span", { style: { marginLeft: 6 } }, h(Btn, { kind: "mini ghost", onClick: () => { try { window.open("https://wx.mail.qq.com/account/index#/verify/gac", "_blank"); } catch (e) { /* ignore */ } } }, "如何获取授权码?"))),
1438
+ h("div", { className: "dsc-sec-h" }, "收件箱(最近 " + items.length + " 封)"),
1439
+ items.length ? items.map((m, i) => {
1440
+ const from = (m.from && (m.from.name || m.from.address)) || m.fromAddress || "未知发件人";
1441
+ let when = "";
1442
+ try { when = m.date ? new Date(m.date).toLocaleString("zh-CN") : ""; } catch (e) { when = String(m.date || ""); }
1443
+ return h("div", { key: m.id || m.seq || i, className: "dsc-item", style: { cursor: "pointer" }, onClick: () => setSel(m) },
1444
+ h("div", { style: { flex: 1, minWidth: 0 } },
1445
+ h("div", { className: "t" }, (m.hasAttach ? "📎 " : "") + (m.subject || "(无主题)")),
1446
+ h("div", { className: "m" }, from + (when ? " · " + when : ""))));
1447
+ }) : h("div", { className: "dsc-card dsc-empty" }, "暂无邮件"),
1448
+ sel ? h("div", { className: "dsc-card", style: { marginTop: 10 } },
1449
+ h("div", { className: "dsc-sec-h" }, (sel.subject || "(无主题)"), h("span", { className: "sp" }, h(Btn, { kind: "mini ghost", onClick: () => setSel(null) }, "关闭"))),
1450
+ h("div", { className: "dsc-muted", style: { fontSize: 11.5, marginBottom: 6 } }, ((sel.from && (sel.from.name || sel.from.address)) || "") + " · " + (sel.date || "")),
1451
+ h("div", { style: { fontSize: 12.5, lineHeight: 1.7, whiteSpace: "pre-wrap", maxHeight: 260, overflow: "auto" } }, sel.preview || sel.snippet || "")) : null);
1452
+ }
1453
+
1099
1454
  function ScheduleTab(props) {
1100
1455
  const { ctx } = props;
1101
1456
  const { store, status, err, update, reload } = useStore();
@@ -1107,6 +1462,47 @@ const REPO_URL = "https://github.com/loyalchiiina/dsh-schedule-calendar";
1107
1462
  const alertTimer = useRef(null);
1108
1463
 
1109
1464
  useEffect(() => { const t = setInterval(() => setNow(new Date()), 1000); return () => clearInterval(t); }, []);
1465
+ const diyCfg = (store && store.settings && store.settings.diy) || {};
1466
+ const [wallList, setWallList] = useState([]);
1467
+ const [wallIdx, setWallIdx] = useState(0);
1468
+ const [bgUrls, setBgUrls] = useState(["", ""]);
1469
+ const [bgFront, setBgFront] = useState(0);
1470
+ useEffect(() => {
1471
+ if (!diyCfg.enabled || !diyCfg.dir) { setWallList([]); setWallIdx(0); return; }
1472
+ let cancelled = false;
1473
+ getJson(apiUrl("/wallpapers", "dir=" + encodeURIComponent(diyCfg.dir)))
1474
+ .then((j) => { if (!cancelled) { setWallList((j && j.files) || []); setWallIdx(0); } })
1475
+ .catch(() => { if (!cancelled) setWallList([]); });
1476
+ return () => { cancelled = true; };
1477
+ }, [diyCfg.enabled, diyCfg.dir]);
1478
+ useEffect(() => {
1479
+ if (!wallList.length) { setBgUrls(["", ""]); setBgFront(0); return; }
1480
+ const urlOf = (i) => apiUrl("/wallpaper", "dir=" + encodeURIComponent(diyCfg.dir) + "&name=" + encodeURIComponent(wallList[i % wallList.length]));
1481
+ let cancelled = false;
1482
+ const first = urlOf(wallIdx);
1483
+ const img = new Image();
1484
+ img.onload = () => { if (!cancelled) setBgUrls((prev) => { const nx = prev.slice(); nx[bgFront] = first; return nx; }); };
1485
+ img.onerror = () => { if (!cancelled) setBgUrls((prev) => { const nx = prev.slice(); nx[bgFront] = first; return nx; }); };
1486
+ img.src = first;
1487
+ return () => { cancelled = true; };
1488
+ }, [wallList, wallIdx, diyCfg.dir]);
1489
+ useEffect(() => {
1490
+ if (wallList.length < 2) return;
1491
+ const sec = Math.max(1, Number(diyCfg.intervalSec) || 30);
1492
+ const t = setInterval(() => {
1493
+ setWallIdx((i) => {
1494
+ const next = (i + 1) % wallList.length;
1495
+ const url = apiUrl("/wallpaper", "dir=" + encodeURIComponent(diyCfg.dir) + "&name=" + encodeURIComponent(wallList[next]));
1496
+ setBgFront((f) => {
1497
+ const back = 1 - f;
1498
+ setBgUrls((prev) => { const nx = prev.slice(); nx[back] = url; return nx; });
1499
+ return back;
1500
+ });
1501
+ return next;
1502
+ });
1503
+ }, sec * 1000);
1504
+ return () => clearInterval(t);
1505
+ }, [wallList, diyCfg.intervalSec, diyCfg.dir]);
1110
1506
 
1111
1507
  const yearNow = now.getFullYear();
1112
1508
  const lunarNow = useLunar(yearNow);
@@ -1149,6 +1545,31 @@ const REPO_URL = "https://github.com/loyalchiiina/dsh-schedule-calendar";
1149
1545
  if (now.getHours() === eh && now.getMinutes() === em) due.push({ key: "we-" + tk, msg: "该下班啦(" + person.name + " " + sc.workEnd + ")" });
1150
1546
  }
1151
1547
  const occ = occurrencesForDate(tk, store.events, lunarTodayDays);
1548
+ // 健康/趣味提醒:久坐 · 喝水(科学) · 摸鱼/护眼 · 听音乐 · 自定义
1549
+ {
1550
+ const rems = store.settings.reminders || [];
1551
+ const nowMin = now.getHours() * 60 + now.getMinutes();
1552
+ for (const rm of rems) {
1553
+ if (!rm || !rm.enabled) continue;
1554
+ const parseHM = (t) => { const a = String(t || "00:00").split(":").map(Number); return (a[0] || 0) * 60 + (a[1] || 0); };
1555
+ const sMin = parseHM(rm.start || "00:00"), eMin = parseHM(rm.end || "23:59");
1556
+ const iv = Math.max(5, Number(rm.intervalMin) || 60);
1557
+ if (nowMin < sMin || nowMin >= eMin) continue;
1558
+ const slot = Math.floor((nowMin - sMin) / iv);
1559
+ if (slot < 0 || nowMin !== sMin + slot * iv) continue;
1560
+ const key = "rm-" + rm.id + "-" + tk + "-" + slot;
1561
+ if (fired.current[key]) continue;
1562
+ fired.current[key] = true;
1563
+ let extra = "";
1564
+ if (rm.type === "drink") {
1565
+ const dk = store.settings.drink || {};
1566
+ const totalMl = dk.totalMl || 2100;
1567
+ const cups = dk.cups || 9;
1568
+ extra = "(每次约 " + Math.round(totalMl / cups) + "ml,今天共 " + cups + " 次,合计约 " + totalMl + "ml)";
1569
+ }
1570
+ due.push({ key: key, msg: (rm.emoji ? rm.emoji + " " : "") + (rm.name || "提醒") + ":" + (rm.msg || "休息一下~") + extra });
1571
+ }
1572
+ }
1152
1573
  for (const ev of occ) {
1153
1574
  if (ev.time) {
1154
1575
  const [hh, mm] = ev.time.split(":").map(Number);
@@ -1177,9 +1598,22 @@ const REPO_URL = "https://github.com/loyalchiiina/dsh-schedule-calendar";
1177
1598
  const lToday = lunarNow.days && lunarNow.days[tk];
1178
1599
  const holToday = holidaysNow[tk];
1179
1600
  const ws = workStatus(person, now);
1180
- const navItems = [["today", "今日"], ["calendar", "日历"], ["events", "日程"], ["todos", "待办"], ["reports", "报告"], ["settings", "设置"]];
1601
+ const navItems = [["today", "今日"], ["calendar", "日历"], ["events", "日程"], ["mail", "邮件"], ["todos", "待办"], ["reports", "报告"], ["settings", "设置"]];
1181
1602
 
1182
- return h("div", { className: "dsc-root" },
1603
+ const _vRaw = (diyCfg.veil == null ? 0.3 : Number(diyCfg.veil));
1604
+ const _vSafe = Math.min(0.92, Math.max(0.45, isFinite(_vRaw) ? _vRaw : 0.3));
1605
+ const veilA = String(_vSafe);
1606
+ return h("div", { className: "dsc-root" + (wallList.length ? " has-bg" : "") + (wallList.length && diyCfg.frost === false ? " no-frost" : "") },
1607
+ (wallList.length ? [0, 1].map((li) => h("div", {
1608
+ key: "bg" + li,
1609
+ className: "dsc-bglayer",
1610
+ style: {
1611
+ backgroundImage: bgUrls[li] ? ("url(" + bgUrls[li] + ")") : "none",
1612
+ opacity: bgUrls[li] ? 1 : 0,
1613
+ zIndex: (li === bgFront ? 2 : 1),
1614
+ },
1615
+ })) : null),
1616
+ (wallList.length ? h("div", { className: "dsc-bgscrim", style: { background: "rgba(var(--dsc-scrim-rgb), " + veilA + ")" } }) : null),
1183
1617
  h("div", { className: "dsc-head" },
1184
1618
  h("div", null,
1185
1619
  h("div", { className: "dsc-hdate" }, now.getMonth() + 1 + "月" + now.getDate() + "日 " + WD[now.getDay()] + (function () { const p = [lToday ? "农历" + lToday.monthCn + lToday.dayCn : "", lToday && lToday.term ? lToday.term : "", holToday ? holToday.name : ""].filter(Boolean); if (store.settings.showAlmanac !== false && almanacToday) { p.push("宜:" + (almanacToday.yi || []).join("/") + " 忌:" + (almanacToday.ji || []).join("/")); } return p.length ? " · " + p.join(" · ") : ""; })())),
@@ -1201,6 +1635,7 @@ const REPO_URL = "https://github.com/loyalchiiina/dsh-schedule-calendar";
1201
1635
  nav === "events" ? h(EventsView, { store, update, goAdd }) : null,
1202
1636
  nav === "todos" ? h(TodosView, { store, update }) : null,
1203
1637
  nav === "reports" ? h(ReportsView, { store, update, now }) : null,
1638
+ nav === "mail" ? h(MailView, { now: now }) : null,
1204
1639
  nav === "settings" ? h(SettingsView, { store, update, reload, now }) : null));
1205
1640
  }
1206
1641
 
@@ -1220,7 +1655,7 @@ const REPO_URL = "https://github.com/loyalchiiina/dsh-schedule-calendar";
1220
1655
  if (ms < 0) ms = 0;
1221
1656
  const s = Math.floor(ms / 1000);
1222
1657
  const hh = Math.floor(s / 3600), mm = Math.floor((s % 3600) / 60), ss = s % 60;
1223
- return (hh > 0 ? hh + ":" : "") + pad(mm) + ":" + pad(ss);
1658
+ return pad(hh) + ":" + pad(mm) + ":" + pad(ss);
1224
1659
  }
1225
1660
 
1226
1661
  /* ============================ apply ============================ */