Files
douyi_guaji_main/webui/js/constants.js
T

260 lines
9.6 KiB
JavaScript

const UI_LIMITS = Object.freeze({
runLogMaxLines: 50000,
runLogMaxChars: 200000,
actionsLogMaxLines: 5000,
scrollBottomThresholdPx: 5,
screenshotPollMs: 1500,
logPollMs: 800,
statsPollMs: 1200,
});
const UI_CLASS = Object.freeze({
busy: "isBusy",
clickable: "isClickable",
collapsed: "isCollapsed",
listCollapsed: "isListCollapsed",
reservationHeader: "reservationHeader",
reservationBody: "reservationBody",
reservationsList: "reservationsList",
shotEmpty: "isShotEmpty",
statusRunning: "statusRunning",
statusIdle: "statusIdle",
statusError: "statusError",
});
const RUN_TONE = Object.freeze({
running: "running",
idle: "idle",
error: "error",
});
const UI_COPY = Object.freeze({
empty: "-",
device: {
autoOption: "(auto)",
autoLabel: "(auto)",
noOnline: "无在线设备",
adbReady: "ADB 已就绪",
adbMissing: "ADB 未找到",
autoOnline: (count) => `${count} 台在线 / 自动选择`,
},
runOverview: {
starting: "启动中",
startingMeta: "正在向后端发送启动请求",
failed: "启动失败",
stopping: "停止中",
stoppingMeta: "已请求后端停止运行",
meta: (pid, uptimeSeconds) => `PID ${pid ?? "-"} / 运行时长 ${fmtDuration(uptimeSeconds)}`,
},
overview: {
logLines: (count) => `${count ?? 0} 行`,
lastLog: (ts) => `最后日志 ${fmtTime(ts)}`,
fudaiState: (opened, attended) => `${opened} / ${attended}`,
fudaiMeta: (seen, wins) => `识别 ${seen} / 中奖 ${wins}`,
},
});
const TIMELINE_SERIES_KEYS = Object.freeze([
"fudai_open_detail",
"fudai_attend_ok",
"fudai_attend_fail",
"fudai_result_win",
"fudai_result_no_win",
"fudai_skip",
"switch_room",
]);
const TIMELINE_LAYOUT = Object.freeze({
width: 900,
height: 220,
paddingLeft: 36,
paddingRight: 14,
paddingTop: 10,
paddingBottom: 26,
});
const TIMELINE_STROKES = Object.freeze({
fudai_open_detail: { stroke: "var(--primary)", opacity: 1.0, dash: "" },
fudai_attend_ok: { stroke: "var(--primary)", opacity: 0.7, dash: "" },
fudai_attend_fail: { stroke: "var(--primary)", opacity: 0.4, dash: "4 3" },
fudai_result_win: { stroke: "var(--primary)", opacity: 1.0, dash: "2 3" },
fudai_result_no_win:{ stroke: "var(--primary)", opacity: 0.4, dash: "" },
fudai_skip: { stroke: "var(--muted)", opacity: 0.7, dash: "4 3" },
switch_room: { stroke: "var(--muted)", opacity: 1.0, dash: "2 3" },
});
const DEFAULTS = {
// 筛选
min_prize_value_yuan: 0,
min_participants: 0,
max_participants: 0,
skip_if_countdown_lt_seconds: 15,
reset_after_swipes_enabled: false,
reset_after_swipes: 10,
auto_join_fansclub: false,
fansclub_fail_action: "stay",
// 养号
yanghao_enabled: true,
yanghao_enable_actions: true,
yanghao_step_screenshot: false,
yanghao_recommend_duration_seconds: 60,
yanghao_recommend_interval_seconds: 0,
yanghao_like_prob: 0.15,
yanghao_fav_prob: 0.05,
yanghao_comment_prob: 0,
yanghao_icon_roi_size: 180,
yanghao_icon_match_threshold: 0.72,
yanghao_like_template_path: "assets/like.png",
yanghao_fav_template_path: "assets/fav.png",
yanghao_like_icon_x: 0,
yanghao_like_icon_y: 0,
yanghao_fav_icon_x: 0,
yanghao_fav_icon_y: 0,
yanghao_comment_btn_x: 0,
yanghao_comment_btn_y: 0,
yanghao_after_dwell_swipe_direction: "up",
yanghao_after_dwell_swipe_distance_px: 900,
// 高价值福袋预约
high_value_fudai_enabled: false,
high_value_fudai_threshold_yuan: 1000,
high_value_fudai_join_ahead_seconds: 300,
high_value_fudai_max_swipe_back: 60,
high_value_fudai_max_reservations: 5,
high_value_fudai_after_action: "continue",
high_value_room_revisit_enabled: true,
high_value_room_revisit_only_current_run: false,
reservation_back_verify_enabled: true,
// 找福袋图标相关
fudai_find_max_attempts: 5,
fudai_icon_retry_delay_seconds: 0.6,
fudai_icon_max_wait_seconds: 5.0,
// 是否禁用福袋内容OCR识别(仅前端默认,实际值以 config.json 为准)
fudai_disable_content_recognition: false,
fudai_detail_ui_mode: "auto",
fudai_detail_save_debug_images: false,
region_coords_edit_enabled: false,
fudai_detail_ocr_content_enabled: true,
fudai_detail_ocr_value_enabled: true,
fudai_detail_ocr_countdown_enabled: true,
fudai_detail_ocr_task_enabled: true,
fudai_detail_ocr_task_count_enabled: true,
fudai_detail_ocr_button_enabled: true,
fudai_detail_ocr_participants_enabled: false,
fudai_detail_ocr_live_title_enabled: false,
"fudai_detail_regions.legacy.content": [389, 1273, 1000, 1534],
"fudai_detail_regions.legacy.value": [643, 1466, 769, 1656],
"fudai_detail_regions.legacy.countdown_full": [390, 1110, 690, 1230],
"fudai_detail_regions.legacy.task_list": [50, 1621, 1032, 1960],
"fudai_detail_regions.legacy.task_count": [0, 0, 0, 0],
"fudai_detail_regions.legacy.participants": [389, 1273, 1000, 1534],
"fudai_detail_regions.legacy.button": [306, 2030, 780, 2180],
"fudai_detail_regions.legacy.live_title": [130, 120, 560, 225],
"fudai_detail_regions.v2_0_two_task.content": [360, 1410, 1035, 1495],
"fudai_detail_regions.v2_0_two_task.value": [300, 1585, 650, 1685],
"fudai_detail_regions.v2_0_two_task.countdown_full": [760, 1328, 1038, 1398],
"fudai_detail_regions.v2_0_two_task.task_list": [60, 1840, 1030, 2005],
"fudai_detail_regions.v2_0_two_task.task_count": [860, 1770, 1035, 1875],
"fudai_detail_regions.v2_0_two_task.participants": [520, 1325, 760, 1415],
"fudai_detail_regions.v2_0_two_task.button": [70, 2020, 1010, 2165],
"fudai_detail_regions.v2_0_two_task.live_title": [130, 120, 560, 225],
"fudai_detail_regions.v2_0_one_task.content": [360, 1460, 1035, 1545],
"fudai_detail_regions.v2_0_one_task.value": [350, 1640, 760, 1735],
"fudai_detail_regions.v2_0_one_task.countdown_full": [730, 1338, 1038, 1418],
"fudai_detail_regions.v2_0_one_task.info_line": [430, 1315, 1055, 1435],
"fudai_detail_regions.v2_0_one_task.task_list": [60, 1845, 885, 2005],
"fudai_detail_regions.v2_0_one_task.task_count": [890, 1855, 1040, 1960],
"fudai_detail_regions.v2_0_one_task.participants": [516, 1396, 743, 1443],
"fudai_detail_regions.v2_0_one_task.button": [70, 2050, 1010, 2195],
"fudai_detail_regions.v2_0_one_task.live_title": [130, 120, 560, 225],
"pixel_regions.lottery_result.button": [250, 1275, 825, 1435],
"pixel_regions.lottery_result.pixel": [290, 1300, 790, 1415],
"pixel_regions.lottery_result.click": [540, 1360, 0, 0],
"pixel_regions.attend_button": [200, 2000, 880, 2120],
"pixel_regions.fansclub_join": [200, 1940, 880, 2140],
"pixel_regions.coupon_popup": [9, 1173, 1079, 2255],
"pixel_regions.shopping_redpacket": [200, 300, 880, 1400],
"pixel_regions.fudai_detail_body": [0, 1160, 1080, 2250],
"pixel_regions.fudai_task_status": [820, 1815, 1050, 2035],
"pixel_regions.live_room_icon_bbox": [999, 172, 1028, 202],
pixel_detect_fudai_icon_enabled: true,
pixel_detect_coupon_popup_enabled: true,
pixel_detect_shopping_redpacket_enabled: false,
pixel_detect_lottery_result_enabled: true,
pixel_detect_attend_button_enabled: true,
pixel_detect_fansclub_join_enabled: true,
pixel_detect_fudai_detail_enabled: true,
pixel_detect_live_room_enabled: true,
ocr_lottery_result_enabled: true,
ocr_coupon_popup_enabled: true,
ocr_shopping_redpacket_enabled: false,
ocr_stage_page_enabled: true,
live_room_match_threshold: 0.8,
fudai_detail_body_bluepurple_threshold: 0.45,
fudai_detail_body_dark_threshold: 0.35,
fudai_task_status_template_threshold: 0.26,
reservation_back_swipe_delay: 0.6,
// 定时禁抢福袋(默认 2-7 点)
fudai_quiet_hours_enabled: true,
fudai_quiet_start_hour: 2,
fudai_quiet_end_hour: 7,
// 桌面 GUI 对齐补充
infinite_loop_enabled: false,
skip_if_countdown_gt_seconds: 900,
reset_after_swipes_action: "swipe",
reenter_live_entry_mode: "follow_list",
enable_back_on_misses: true,
enable_streaming_screenshot: true,
swipe_duration_ms: 600,
swipe_up_start_y: 1200,
swipe_up_end_y: 600,
switch_room_wait_after_stage_diag_seconds: 7.0,
fansclub_click_delay: 0.6,
fansclub_auto_join_wait_seconds: 5.0,
fansclub_manual_wait_seconds: 3.0,
high_value_fudai_poll_before_seconds: 10.0,
high_value_room_revisit_min_interval_seconds: 300,
high_value_room_revisit_max_per_run: 5,
high_value_room_revisit_min_prize_value: 0,
high_value_room_revisit_max_age_days: 30,
reservation_back_verify_wait_seconds: 5.0,
fudai_disable_task_recognition: false,
fudai_exit_after_misses: 30,
fudai_click_wait_seconds: 2.0,
fudai_detail_template_threshold: 0.7,
coupon_template_match_threshold: 0.75,
attend_button_red_ratio_threshold: 0.25,
fansclub_join_red_ratio_threshold: 0.25,
shopping_redpacket_red_ratio_threshold: 0.15,
yanghao_only: false,
yanghao_icon_match_threshold: 0.72,
"debug_captures.async_save": true,
"debug_captures.log_on_complete": false,
"logging.beautify_output": true,
"logging.color_output": true,
"logging.show_timestamps": true,
"logging.use_dated_logs": true,
"logging.enable_monitor": true,
"logging.compress_logs": true,
"logging.keep_days": 30,
"logging.max_total_size_gb": 10.0,
"logging.compress_after_days": 7,
"logging.debug_detail_level": "normal",
"logging.error_detail_level": "full",
"logging.action_log_format": "concise",
"logging.log_format_mode": "simple",
"logging.monitor_warning_mb": 500,
"logging.monitor_critical_mb": 2000,
"logging.stage_diag_verbose": false,
"logging.performance_tracking.enabled": true,
"logging.performance_tracking.track_function_calls": true,
"gui.theme": "litera",
"gui.realtime_status.refresh_interval_ms": 1000,
"gui.realtime_status.tail_items": 50,
log_unified_enabled: true,
log_unified_path: "logs/unified.log",
};