Browse Source

fix(schedule): 修正节假日逻辑为法定工作日

将 holiday 类型逻辑从判断节假日调整为判断法定工作日,并同步更新前端文案。
yangkaixiang 6 days ago
parent
commit
674d119b24
3 changed files with 4 additions and 4 deletions
  1. 1 1
      src/index.js
  2. 1 1
      src/scheduleService.js
  3. 2 2
      views/schedules.ejs

+ 1 - 1
src/index.js

@@ -12,7 +12,7 @@ const mqttService = new MqttService();
 const weekdayLabel = (value) => ['一', '二', '三', '四', '五', '六', '日'][Number(value) - 1] || '';
 const actionLabel = (action) => ({ open: '开灯', close: '关灯', query: '查询', state_change: '状态变化' }[action] || action);
 const targetLabel = (channel) => Number(channel) === 0 ? '全部灯' : `灯${channel}`;
-const repeatLabel = (type) => ({ daily: '每天', workday: '工作日', holiday: '法定节假日', custom: '自定义' }[type] || type);
+const repeatLabel = (type) => ({ daily: '每天', workday: '工作日', holiday: '法定工作日', custom: '自定义' }[type] || type);
 const holidayTypeLabel = (type) => ({ holiday: '节假日', adjusted_workday: '调休' }[type] || type);
 
 app.set('view engine', 'ejs');

+ 1 - 1
src/scheduleService.js

@@ -26,7 +26,7 @@ function isHoliday(dateText) {
 function scheduleMatchesDate(schedule, dateText) {
   if (schedule.repeat_type === 'daily') return true;
   if (schedule.repeat_type === 'workday') return isWorkday(dateText);
-  if (schedule.repeat_type === 'holiday') return isHoliday(dateText);
+  if (schedule.repeat_type === 'holiday') return isWorkday(dateText);
   if (schedule.repeat_type === 'custom') {
     const weekdays = String(schedule.weekdays || '')
       .split(',')

+ 2 - 2
views/schedules.ejs

@@ -17,7 +17,7 @@
     <section class="hero tile-light compact page-intro">
       <p class="eyebrow">Schedule</p>
       <h1>定时计划</h1>
-      <p class="lead">支持每天、工作日、法定节假日、自定义。</p>
+      <p class="lead">支持每天、工作日、法定工作日、自定义。</p>
       <div class="hero-actions compact-actions">
         <button class="button-primary" type="button" id="openScheduleDialog">添加计划</button>
       </div>
@@ -92,7 +92,7 @@
         <select name="repeat_type" id="repeatType">
           <option value="daily">每天</option>
           <option value="workday">工作日</option>
-          <option value="holiday">法定节假日</option>
+          <option value="holiday">法定工作日</option>
           <option value="custom">自定义</option>
         </select>
       </label>