This commit is contained in:
张成
2025-12-18 18:46:29 +08:00
parent 73a0999e20
commit f233f368ed
5 changed files with 77 additions and 30 deletions

View File

@@ -240,21 +240,31 @@ class DeviceWorkStatusNotifier {
if (workStatus.currentActivity) {
const activity = workStatus.currentActivity;
const typeText = activity.type === 'command' ? '指令' : '任务';
const statusText = activity.status === 'running' ? '执行中' :
activity.status === 'completed' ? '已完成' :
const statusText = activity.status === 'running' ? '执行中' :
activity.status === 'completed' ? '已完成' :
activity.status === 'failed' ? '失败' : '未知';
// 构建详细描述:包含指令/任务名称和描述
let activityDesc = activity.description || activity.name;
// 对于指令,显示指令类型和名称的详细信息
if (activity.type === 'command') {
const cmdType = activity.commandType || '';
if (cmdType && cmdType !== activity.name) {
activityDesc = `${activityDesc} [${cmdType}]`;
// 使用 description 或 name避免重复显示
// 如果 description 存在且不等于 name优先使用 description
// 否则,使用 name 并可能添加 commandType
let activityDesc = '';
if (activity.description && activity.description !== activity.name) {
// 有独立的 description直接使用不再添加 commandType
activityDesc = activity.description;
} else {
// 使用 name
activityDesc = activity.name;
// 对于指令,如果 commandType 存在且与 name 不同,添加详细信息
if (activity.type === 'command') {
const cmdType = activity.commandType || '';
if (cmdType && cmdType !== activity.name && !activity.name.includes(cmdType)) {
activityDesc = `${activityDesc} [${cmdType}]`;
}
}
}
parts.push(`${typeText}: ${activityDesc} (${statusText}${activity.progress > 0 ? `, 进度: ${activity.progress}%` : ''})`);
} else {
parts.push('当前活动: 无');

View File

@@ -26,8 +26,8 @@ function checkTimeRange(timeRange) {
const startTime = startHour * 60 + startMinute;
const endTime = endHour * 60 + endMinute;
// 检查是否仅工作日
if (timeRange.workdays_only === 1) {
// 检查是否仅工作日(使用宽松比较,兼容字符串和数字)
if (timeRange.workdays_only == 1) { // 使用 == 而不是 ===
const dayOfWeek = now.getDay(); // 0=周日, 1=周一, ..., 6=周六
if (dayOfWeek === 0 || dayOfWeek === 6) {
return { allowed: false, reason: '当前是周末,不在允许的时间范围内' };

View File

@@ -523,8 +523,8 @@ class TaskHandlers {
const startTime = startHour * 60 + startMinute;
const endTime = endHour * 60 + endMinute;
// 检查是否仅工作日
if (timeRange.workdays_only === 1) {
// 检查是否仅工作日(使用宽松比较,兼容字符串和数字)
if (timeRange.workdays_only == 1) { // 使用 == 而不是 ===
const dayOfWeek = now.getDay(); // 0=周日, 1=周一, ..., 6=周六
if (dayOfWeek === 0 || dayOfWeek === 6) {
return { allowed: false, reason: '当前是周末,不在允许的时间范围内' };