diff --git a/build-module.js b/build-module.js index 3716a6a..186fa96 100644 --- a/build-module.js +++ b/build-module.js @@ -1,5 +1,6 @@ import fs from 'fs'; import archiver from 'archiver'; +import { spawn } from 'child_process'; // 读取版本信息用以命名 const propContent = fs.readFileSync('module.prop', 'utf-8'); @@ -37,15 +38,12 @@ const excludes = [ 'package-lock.json', 'package.json', 'pnpm-lock.yaml', - 'vite.config.js', - 'src', - 'public', '.vscode', '.git', '.gitignore', 'build.ps1', 'build-module.js', - 'index.html', // 根目录的 html 已构建至 webroot + 'webui', // webui 目录已经构建到 webroot zipName ]; diff --git a/customize.sh b/customize.sh index 1eb16a6..f415acc 100755 --- a/customize.sh +++ b/customize.sh @@ -239,11 +239,10 @@ IMPORT_OLD_CONFIG() { echo "- 已沿用旧配置" cp -f "$old_config/ui_max_bri.txt" "$mod_config/" cp -f "$old_config/max_bri.txt" "$mod_config/" - [ -s "$old_config/sleep_time.txt" ] && cp -f "$old_config/sleep_time.txt" "$mod_config/" + [ -e "$old_config/sleep_time.txt" ] && cp -f "$old_config/sleep_time.txt" "$mod_config/" || echo "1900-0600" >"$mod_config/sleep_time.txt" [ -s "$old_config/auto_bri_sleep.txt" ] && cp -f "$old_config/auto_bri_sleep.txt" "$mod_config/" [ -s "$old_config/steps_num.txt" ] && cp -f "$old_config/steps_num.txt" "$mod_config/" [ -s "$old_config/log_max_size.txt" ] && cp -f "$old_config/log_max_size.txt" "$mod_config/" - [ -s "$old_config/sleep_time.txt" ] && cp -f "$old_config/sleep_time.txt" "$mod_config/" # 迁移旧的路径配置(如果存在) mkdir -p "$mod_path_config" @@ -281,8 +280,14 @@ IMPORT_OLD_CONFIG() { INIT_CONFIG() { mkdir -p "$mod_config" mkdir -p "$mod_path_config" - touch "$mod_config/ui_max_bri.txt" - touch "$mod_config/max_bri.txt" + + # 仅在文件不存在时才创建,保留任何已存在的配置 + [ ! -f "$mod_config/ui_max_bri.txt" ] && touch "$mod_config/ui_max_bri.txt" + [ ! -f "$mod_config/max_bri.txt" ] && touch "$mod_config/max_bri.txt" + [ ! -f "$mod_config/sleep_time.txt" ] && touch "$mod_config/sleep_time.txt" + [ ! -f "$mod_config/auto_bri_sleep.txt" ] && touch "$mod_config/auto_bri_sleep.txt" + [ ! -f "$mod_config/steps_num.txt" ] && touch "$mod_config/steps_num.txt" + [ ! -f "$mod_config/log_max_size.txt" ] && touch "$mod_config/log_max_size.txt" # 初始化设备路径配置 (仅在文件不存在时使用默认值,保留用户自定义配置) [ ! -f "$mod_path_config/now_bri_file.txt" ] && echo -n "$DEFAULT_NOW_BRI_FILE" >"$mod_path_config/now_bri_file.txt" diff --git a/package.json b/package.json index dcd5527..8333db3 100644 --- a/package.json +++ b/package.json @@ -4,9 +4,9 @@ "version": "2.1.0", "type": "module", "scripts": { - "dev": "vite", - "build": "vite build && node build-module.js", - "preview": "vite preview" + "dev": "cd webui && vite", + "build": "cd webui && vite build && cd .. && node build-module.js", + "preview": "cd webui && vite preview" }, "devDependencies": { "archiver": "^7.0.1", diff --git a/script/daemon.sh b/script/daemon.sh index 4e96256..eca42c4 100644 --- a/script/daemon.sh +++ b/script/daemon.sh @@ -37,18 +37,22 @@ get_config_hash() { # 日志函数 _log() { - printf '[%s] [daemon] %s\n' "$(date '+%d %H:%M:%S.%3N')" "$1" >>"$log_file" + local level="${2:-INFO}" + printf '[%s] [%-8s] [%-8s] %s\n' "$(date '+%m-%d %H:%M:%S')" "daemon" "$level" "$1" >>"$log_file" } # 确保环境就绪 mkdir -p "$PID_DIR" +_log "守护进程启动,开始监控配置文件..." "INFO" + while true; do # 检查是否需要手动停止或暂时挂起 if [ -f "$stop_file" ]; then # 全局停止,杀掉现有并等待 [ -f "$pid_file" ] && kill -9 "$(cat "$pid_file")" 2>/dev/null rm -f "$pid_file" + _log "检测到停止信号,已暂停" "WARN" sleep 5 continue fi @@ -68,7 +72,7 @@ while true; do if [ -f "$config_cache_file" ]; then cached_config="$(cat "$config_cache_file")" if [ "$current_config" != "$cached_config" ]; then - _log "检测到配置文件改变,将重启 inotifyd..." + _log "✓ 配置文件已更新,重启监听进程..." "WARN" [ -f "$pid_file" ] && kill -9 "$(cat "$pid_file")" 2>/dev/null rm -f "$pid_file" echo "$current_config" >"$config_cache_file" @@ -81,7 +85,7 @@ while true; do fi # 正常启动并监听 - _log "启动 inotifyd 监听任务..." + _log "→ 启动 inotifyd 监听..." "INFO" now_bri_file="$current_config" # 更新缓存,让 up.sh 知道当前监听的是哪个文件 @@ -92,11 +96,12 @@ while true; do inotify_pid=$! echo "$inotify_pid" >"$pid_file" - _log "inotifyd 启动,PID: $inotify_pid,监听文件: $now_bri_file" + _log "✓ inotifyd 已启动 (PID: $inotify_pid)" "SUCCESS" + _log " 监听文件: $now_bri_file" "INFO" # 3. 通过 wait 阻塞,实时感知进程死亡 (兼容所有 BusyBox 环境) wait "$inotify_pid" - _log "监听进程 ($inotify_pid) 已退出 (Code: $?)" + _log "⚠ 监听进程 ($inotify_pid) 已退出,将在 1 秒后重启..." "WARN" sleep 0.5 done diff --git a/script/up.sh b/script/up.sh index 1b973e1..6f5aef7 100644 --- a/script/up.sh +++ b/script/up.sh @@ -32,6 +32,8 @@ max_bri_file="$(get_config "$PATH_CONFIG_DIR/max_bri_file.txt" "$DEFAULT_MAX_BRI # 日志函数 _log() { + local level="${2:-INFO}" + case "$1" in "日志过大"*) ;; *) if [ -f "$stop_file" ]; then return; fi ;; @@ -46,22 +48,28 @@ _log() { local cur_size cur_size=$(du -k "$log_file" | cut -f1) if [ "$cur_size" -ge "$max_size" ]; then - echo "[$(date '+%d %H:%M:%S.%3N')] [up] 日志过大 ($cur_size KB), 自动重置" >"$log_file" + printf '[%s] [%-8s] [%-8s] %s\n' "$(date '+%m-%d %H:%M:%S')" "up" "WARN" "日志过大 ($cur_size KB), 自动重置" >"$log_file" fi fi - printf '[%s] [up] %s\n' "$(date '+%d %H:%M:%S.%3N')" "$1" >>"$log_file" + printf '[%s] [%-8s] [%-8s] %s\n' "$(date '+%m-%d %H:%M:%S')" "up" "$level" "$1" >>"$log_file" } -_log "[$$] 收到 inotifyd 通知..." +_log "→ 收到 inotifyd 通知 (PID: $$)" "INFO" +_log "⚠ 正在抢占:清理其他 inotifyd 进程..." "WAIT" +touch "$pause_file" +killall -9 inotifyd 2>/dev/null +for p in $(pgrep -f "up.sh"); do + [ "$p" != "$$" ] && kill -9 "$p" 2>/dev/null +done if [ -f "$stop_file" ]; then - _log "[$$] [拦截] 检测到 stop.flag, 服务已处于手动暂停状态" + _log "✗ 服务已处于手动暂停状态,本次操作被取消" "WARN" exit 0 fi if [ -f "$flag_file" ]; then - _log "[$$] [拦截] 已经有一个 up.sh (${flag_file}) 在运行, 本进程退出" + _log "✗ 另一个 up.sh 进程正在运行,本进程退出" "WARN" exit 1 fi touch "$flag_file" @@ -111,11 +119,11 @@ update_all() { # 如果步长为 0 (差值太小), 直接设置目标亮度 if [ "$step_value" -eq 0 ]; then - _log "[$$] 步长为 0, 直接设置目标亮度: $target_bri" + _log "✓ 直接设定亮度为: $target_bri" "INFO" echo -n "$target_bri" >"$now_bri_file" && return 0 || return 1 fi - _log "[$$] 开始调整亮度: $start_bri -> $target_bri, 共 $steps_num 步, 每步 $step_value" + _log "→ 开始调整亮度: $start_bri → $target_bri (共 $steps_num 步)" "INFO" for step in $(seq 1 "$steps_num"); do echo -n $((start_bri + step * step_value)) >"$now_bri_file" sleep 0.02 @@ -130,44 +138,34 @@ CHECK_BRI() { local cycle_num local now_bri - # 循环 10 次 (检查 5s) + # 循环 10 次 (检查 3s) # shellcheck disable=SC2034 for cycle_num in $(seq 1 10); do now_bri="$(cat "$now_bri_file")" if [ "$now_bri" -ge "$ui_max_bri" ] && [ "$now_bri" -lt "$target_bri" ]; then - _log "[$$] [满足提升条件] 当前亮度: $now_bri (>= $ui_max_bri), 目标提升至: $target_bri" - _log "[$$] [抢占] 正在清理 inotifyd 和其它上报进程..." - touch "$pause_file" - killall -9 inotifyd 2>/dev/null - for p in $(pgrep -f "up.sh"); do - [ "$p" != "$$" ] && kill -9 "$p" 2>/dev/null - done - rm -f "$flag_file" + _log "⚡ 满足提升条件: $now_bri ≥ $ui_max_bri,目标 ↑ $target_bri" "SUCCESS" if update_all; then - _log "[$$] [成功] 亮度提升任务已完成 (已设为: $target_bri)" - _log "--------------------" + _log "✓ 亮度提升已完成 (当前: $target_bri)" "SUCCESS" + _log "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━" "INFO" return 0 else - _log "[$$] [失败] 亮度提升过程中遇到异常" - _log "--------------------" + _log "✗ 亮度提升失败:无法写入节点文件" "ERROR" + _log "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━" "ERROR" return 1 fi fi - sleep 0.5 + sleep 0.3 done - _log "[$$] [取消] 循环检测结束, 未持续触发有效提升阈值" + _log "─ 检测超时:未持续触发有效提升阈值" "WARN" return 1 } MAIN() { - # 0.5 秒等待以避免 inotifyd 刚启动时的误触 - sleep 0.5 - # 解析并判断休眠 if IS_SLEEP_TIME; then - _log "[$$] 当前处于休眠时段 ($sleep_start-$sleep_end), 跳过本次调整" - _log "--------------------" + _log "⏸ 休眠时段 ($sleep_start-$sleep_end),本次调整已跳过" "INFO" + _log "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━" "INFO" rm -f "$flag_file" return fi @@ -175,15 +173,15 @@ MAIN() { if [ "$auto_bri_sleep" = "1" ]; then mode="$(settings get system screen_brightness_mode 2>/dev/null)" if [ "$mode" = "1" ]; then - _log "[$$] 当前为自动亮度模式, 根据设置跳过本次调整" - _log "--------------------" + _log "🔄 自动亮度模式已启用,本次调整已跳过" "INFO" + _log "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━" "INFO" rm -f "$flag_file" return fi fi - _log "[$$] 亮度被调整, 将在 0.5s 后检测是否符合条件" - sleep 0.5 + _log "📊 检测亮度变化..." "INFO" + # sleep 0.5 CHECK_BRI rm -f "$flag_file" # 删除成果锁 rm -f "$pause_file" # 解锁守护进程,让它自动拉起 inotifyd @@ -193,7 +191,7 @@ MAIN() { local cached_now_bri="$(cat "$PATH_CONFIG_DIR/.cached_path" 2>/dev/null || echo "$DEFAULT_NOW_BRI_FILE")" if [ "$current_now_bri" != "$cached_now_bri" ]; then - _log "[$$] 检测到设备路径配置已改变,重启 inotifyd..." + _log "⚙ 配置已更新,重启 inotifyd..." "WARN" killall -9 inotifyd 2>/dev/null fi } diff --git a/service.sh b/service.sh index 9391aaa..feb4c6b 100755 --- a/service.sh +++ b/service.sh @@ -22,29 +22,32 @@ get_config() { } _log() { - printf '[%s] [service] %s\n' "$(date '+%d %H:%M:%S.%3N')" "$1" >>"$log_file" + local level="${2:-INFO}" + printf '[%s] [%s] [%-8s] %s\n' "$(date '+%m-%d %H:%M:%S')" "service" "$level" "$1" >>"$log_file" } # 等待系统就绪 sleep 30 -_log "LuminPro 已启动" -_log "- 前台最大亮度: $(cat "$CONFIG_DIR/ui_max_bri.txt")" -_log "- 峰值最大亮度: $(cat "$CONFIG_DIR/max_bri.txt")" -_log "- 休眠时间: $(cat "$CONFIG_DIR/sleep_time.txt")" +_log "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━" "START" +_log "LuminPro 模块已启动" "SUCCESS" +_log "前台最大亮度: $(cat "$CONFIG_DIR/ui_max_bri.txt")" "INFO" +_log "峰值最大亮度: $(cat "$CONFIG_DIR/max_bri.txt")" "INFO" +_log "休眠时间: $(cat "$CONFIG_DIR/sleep_time.txt")" "INFO" # 读取设备路径配置 now_bri_file="$(get_config "$PATH_CONFIG_DIR/now_bri_file.txt" "$DEFAULT_NOW_BRI_FILE")" max_bri_file="$(get_config "$PATH_CONFIG_DIR/max_bri_file.txt" "$DEFAULT_MAX_BRI_FILE")" -_log "- 当前亮度节点: $now_bri_file" -_log "- 最大亮度节点: $max_bri_file" +_log "当前亮度节点: $now_bri_file" "INFO" +_log "最大亮度节点: $max_bri_file" "INFO" -_log "LuminPro 启动守护监控..." +_log "启动守护监控进程..." "WAIT" chmod 755 "$MODDIR/script/up.sh" chmod 755 "$MODDIR/script/daemon.sh" # 启动守护进程 sh "$MODDIR/script/daemon.sh" & -_log "- 守护进程 PID: $!" +_log "守护进程已启动 (PID: $!)" "SUCCESS" +_log "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━" "DONE" exit 0 diff --git a/webroot/assets/index-Berty6Q2.css b/webroot/assets/index-Berty6Q2.css new file mode 100644 index 0000000..23ced29 --- /dev/null +++ b/webroot/assets/index-Berty6Q2.css @@ -0,0 +1 @@ +:root{--md-sys-color-background:#111318;--md-sys-color-on-background:#e2e2e9;--md-sys-color-surface:#1e1f25;--md-sys-color-surface-container:#212429;--md-sys-color-surface-container-high:#2b2930;--md-sys-color-on-surface:#e2e2e9;--md-sys-color-on-surface-variant:#c4c6d0;--md-sys-color-primary:#a8c7fa;--md-sys-color-on-primary:#062e6f;--md-sys-color-primary-container:#1b4b9b;--md-sys-color-on-primary-container:#d3e3fd;--md-sys-color-outline:#8e9099;--md-sys-color-outline-variant:#44474f;--md-sys-color-error:#ffb4ab;--md-sys-color-on-error:#690005;--border-radius-m:16px;--border-radius-s:8px;--spacing-s:8px;--spacing-m:16px;--spacing-l:24px}@font-face{font-family:Geist;src:url(/Geist-VariableFont_wght.ttf)format("truetype");font-weight:100 900;font-style:normal}@font-face{font-family:Google Sans Code;src:url(/GoogleSansCode-VariableFont_wght.ttf)format("truetype");font-weight:100 900;font-style:normal}*{box-sizing:border-box;-webkit-tap-highlight-color:transparent}html{scrollbar-width:none;-ms-overflow-style:none}html::-webkit-scrollbar{display:none}body{padding:0;padding-top:var(--safe-area-inset-top,0);padding-bottom:var(--safe-area-inset-bottom,0);background-color:var(--md-sys-color-background);color:var(--md-sys-color-on-background);scrollbar-width:none;-ms-overflow-style:none;margin:0;font-family:Geist,system-ui,-apple-system,sans-serif;line-height:1.5}body::-webkit-scrollbar{display:none}#app{padding:var(--spacing-m);padding-bottom:calc(var(--spacing-m) + 80px);gap:var(--spacing-m);flex-direction:column;max-width:600px;margin:0 auto;display:flex}.app-header{padding:var(--spacing-m) 0;justify-content:space-between;align-items:center;display:flex}.header-content{align-items:center;gap:var(--spacing-m);display:flex}.header-icon{background:var(--md-sys-color-surface-container-high);border-radius:50%;justify-content:center;align-items:center;width:48px;height:48px;font-size:2rem;display:flex}.header-text h1{color:var(--md-sys-color-on-background);margin:0;font-size:1.25rem;font-weight:500}.header-subtitle{color:var(--md-sys-color-on-surface-variant);margin:0;font-size:.875rem}.header-status{background:var(--md-sys-color-surface-container);border-radius:100px;align-items:center;gap:6px;padding:4px 12px;font-size:.875rem;display:flex}.status-dot{background-color:var(--md-sys-color-error);border-radius:50%;width:8px;height:8px}.card{background-color:var(--md-sys-color-surface);border-radius:var(--border-radius-m);padding:var(--spacing-l);flex-direction:column;display:flex;box-shadow:0 1px 3px #0000004d,0 4px 8px 3px #00000026}#log-section{flex:1;min-height:calc(100vh - 220px)}.card-header{align-items:center;gap:var(--spacing-s);margin-bottom:var(--spacing-l);display:flex}.card-header h2{color:var(--md-sys-color-on-surface);flex-grow:1;margin:0;font-size:1.125rem;font-weight:500}.config-group{margin-bottom:var(--spacing-l);padding:var(--spacing-m);background-color:var(--md-sys-color-surface-container);border-radius:var(--border-radius-s)}.group-title{margin:0 0 var(--spacing-m) 0;color:var(--md-sys-color-primary);text-transform:uppercase;letter-spacing:.5px;font-size:.875rem;font-weight:600}.config-item{justify-content:space-between;align-items:center;display:flex}.config-item+.config-item{margin-top:var(--spacing-m)}.config-label{flex-direction:column;display:flex}.config-name{color:var(--md-sys-color-on-surface);font-size:1rem}.config-desc{color:var(--md-sys-color-on-surface-variant);font-size:.875rem}.config-input{background-color:var(--md-sys-color-surface-container-high);color:var(--md-sys-color-on-surface);border:1px solid var(--md-sys-color-outline);border-radius:var(--border-radius-s);text-align:right;outline:none;width:100px;padding:8px 12px;font-family:inherit;font-size:1rem;transition:border-color .2s,box-shadow .2s}.config-input:focus{border-color:var(--md-sys-color-primary);box-shadow:0 0 0 2px #a8c7fa4d}.config-input-wide{width:140px}.config-item-expand{margin-top:var(--spacing-s);opacity:0;justify-content:flex-end;max-height:0;transition:all .3s;display:flex;overflow:hidden}.config-item-expand.show{opacity:1;max-height:100px;margin-bottom:var(--spacing-m)}.custom-time-picker{align-items:center;gap:8px;display:flex}.time-unit{background-color:var(--md-sys-color-surface-container-high);border-radius:var(--border-radius-s);border:1px solid var(--md-sys-color-outline);align-items:center;gap:2px;padding:2px 6px;display:flex}.time-input{width:32px;color:var(--md-sys-color-on-surface);text-align:center;-moz-appearance:textfield;background-color:#0000;border:none;outline:none;font-family:Google Sans Code,monospace;font-size:.875rem}.time-input::-webkit-outer-spin-button{-webkit-appearance:none;margin:0}.time-input::-webkit-inner-spin-button{-webkit-appearance:none;margin:0}.time-sep{color:var(--md-sys-color-on-surface-variant);font-size:.875rem}.switch{width:52px;height:32px;display:inline-block;position:relative}.switch input{opacity:0;width:0;height:0}.slider{cursor:pointer;background-color:var(--md-sys-color-surface-container-high);border:2px solid var(--md-sys-color-outline);border-radius:34px;transition:all .4s;position:absolute;inset:0}.slider:before{content:"";background-color:var(--md-sys-color-outline);border-radius:50%;width:24px;height:24px;transition:all .4s;position:absolute;bottom:2px;left:2px}input:checked+.slider{background-color:var(--md-sys-color-primary-container);border-color:var(--md-sys-color-primary)}input:checked+.slider:before{background-color:var(--md-sys-color-primary);transform:translate(20px)}.status-grid{gap:var(--spacing-m);grid-template-columns:1fr 1fr;display:grid}.status-item{background-color:var(--md-sys-color-surface-container);padding:var(--spacing-m);border-radius:var(--border-radius-s);flex-direction:column;display:flex}.status-label{color:var(--md-sys-color-on-surface-variant);margin-bottom:4px;font-size:.75rem}.status-value{color:var(--md-sys-color-primary);word-break:break-all;font-size:1.125rem;font-weight:500}.brightness-section{margin-top:var(--spacing-l);padding:var(--spacing-m);background:linear-gradient(135deg, var(--md-sys-color-surface-container-high) 0%, var(--md-sys-color-surface-container) 100%);border-radius:var(--border-radius-m);border:1px solid var(--md-sys-color-outline-variant)}.brightness-header{margin-bottom:var(--spacing-m);justify-content:space-between;align-items:center;display:flex}.brightness-title{color:var(--md-sys-color-on-surface);letter-spacing:.5px;font-size:1rem;font-weight:600}.brightness-percent{color:var(--md-sys-color-primary);text-align:right;min-width:50px;font-size:1.25rem;font-weight:700}.brightness-container{margin-bottom:var(--spacing-m);padding:var(--spacing-s) 0;align-items:center;gap:8px;display:flex;position:relative}.brightness-label{color:var(--md-sys-color-on-surface-variant);text-align:center;min-width:24px;font-size:.75rem;font-weight:500}.brightness-slider{background:var(--md-sys-color-surface-container);appearance:none;cursor:grab;border-radius:4px;outline:none;flex:1;height:8px;transition:all .2s}.brightness-slider:hover{height:10px;box-shadow:0 0 8px #a8c7fa4d}.brightness-slider::-webkit-slider-thumb{appearance:none;background:var(--md-sys-color-primary);cursor:grab;border:2px solid var(--md-sys-color-surface);border-radius:50%;width:28px;height:28px;transition:all .2s;box-shadow:0 2px 8px #0006,inset 0 1px 2px #ffffff4d}.brightness-slider::-webkit-slider-thumb:hover{transform:scale(1.1);box-shadow:0 4px 12px #00000080,inset 0 1px 2px #ffffff4d}.brightness-slider::-webkit-slider-thumb:active{cursor:grabbing;box-shadow:0 0 0 10px #a8c7fa33}.brightness-slider::-moz-range-thumb{background:var(--md-sys-color-primary);cursor:grab;border:2px solid var(--md-sys-color-surface);border-radius:50%;width:28px;height:28px;transition:all .2s;box-shadow:0 2px 8px #0006,inset 0 1px 2px #ffffff4d}.brightness-slider::-moz-range-thumb:hover{transform:scale(1.1);box-shadow:0 4px 12px #00000080,inset 0 1px 2px #ffffff4d}.brightness-slider::-moz-range-thumb:active{cursor:grabbing;box-shadow:0 0 0 10px #a8c7fa33}.brightness-slider::-moz-range-track{background:0 0;border:none}.auto-brightness-row{padding:var(--spacing-s) var(--spacing-m);border-radius:var(--border-radius-s);background-color:#a8c7fa14;justify-content:space-between;align-items:center;display:flex}.auto-brightness-label{color:var(--md-sys-color-on-surface);font-size:.875rem;font-weight:500}.card-actions{margin-top:var(--spacing-l);padding-top:var(--spacing-m);border-top:1px solid var(--md-sys-color-outline-variant);justify-content:flex-end;gap:12px;display:flex}.btn{cursor:pointer;border:none;border-radius:100px;justify-content:center;align-items:center;gap:8px;padding:10px 24px;font-family:inherit;font-size:.875rem;font-weight:500;transition:background-color .2s,opacity .2s;display:inline-flex}.btn:active{opacity:.8}.btn-primary{background-color:var(--md-sys-color-primary);color:var(--md-sys-color-on-primary)}.btn-outline{border:1px solid var(--md-sys-color-outline);color:var(--md-sys-color-primary);background-color:#0000}.btn-outline-s,.btn-text-s{border:1px solid var(--md-sys-color-outline-variant);color:var(--md-sys-color-primary);border-radius:var(--border-radius-s);cursor:pointer;white-space:nowrap;background-color:#0000;justify-content:center;align-items:center;min-width:50px;height:28px;padding:4px 10px;font-size:.75rem;transition:all .2s;display:inline-flex}.btn-text-s:active{background-color:var(--md-sys-color-surface-container-high)}.btn-danger{background-color:var(--md-sys-color-error)!important;color:var(--md-sys-color-on-error)!important;border:none!important}.header-actions{align-items:center;gap:8px;display:flex}.btn-icon-only{color:var(--md-sys-color-on-surface-variant);cursor:pointer;background:0 0;border:none;border-radius:50%;justify-content:center;align-items:center;padding:4px;font-size:1.25rem;display:flex}.btn-icon-only:active{background-color:var(--md-sys-color-surface-container-high)}.animate-spin{animation:1s linear infinite spin}@keyframes spin{0%{transform:rotate(0)}to{transform:rotate(360deg)}}.log-output{padding:var(--spacing-s);border-radius:var(--border-radius-s);white-space:pre-wrap;word-wrap:break-word;scrollbar-width:none;-ms-overflow-style:none;flex:1;min-height:300px;margin:0;font-family:Google Sans Code,Consolas,Courier New,monospace;font-size:.75rem;overflow-y:auto}.log-filter-select{border:1px solid var(--md-sys-color-outline);border-radius:var(--border-radius-s);background-color:var(--md-sys-color-surface);color:var(--md-sys-color-on-surface);cursor:pointer;padding:6px 12px;font-family:inherit;font-size:.875rem;transition:border-color .2s}.log-filter-select:hover{border-color:var(--md-sys-color-on-surface)}.log-filter-select:focus{border-color:var(--md-sys-color-primary);outline:none;box-shadow:0 0 0 2px #4caf5033}.log-output::-webkit-scrollbar{display:none}.toast{background-color:var(--md-sys-color-on-surface);color:var(--md-sys-color-surface);border-radius:var(--border-radius-s);z-index:1000;text-align:center;width:max-content;max-width:90vw;padding:12px 24px;font-size:.875rem;transition:transform .3s cubic-bezier(.18,.89,.32,1.28);position:fixed;bottom:24px;left:50%;transform:translate(-50%)translateY(100px);box-shadow:0 2px 5px #0006}.toast.show{transform:translate(-50%)translateY(0)}.floating-navbar{background-color:var(--md-sys-color-surface-container-high);-webkit-backdrop-filter:blur(10px);backdrop-filter:blur(10px);z-index:999;border-radius:28px;justify-content:center;align-items:center;gap:8px;width:fit-content;max-width:calc(100% - 32px);padding:12px 16px;display:flex;position:fixed;bottom:16px;left:50%;transform:translate(-50%);box-shadow:0 4px 12px #00000026,0 8px 24px #0003}.navbar-slider{background-color:var(--md-sys-color-primary-container);opacity:.5;pointer-events:none;z-index:-1;border-radius:8px;height:32px;transition:left .3s cubic-bezier(.4,0,.2,1),width .3s cubic-bezier(.4,0,.2,1);position:absolute}.navbar-btn{color:var(--md-sys-color-on-surface-variant);cursor:pointer;background-color:#0000;border:none;border-radius:8px;flex-direction:column;flex:1;justify-content:center;align-items:center;gap:4px;max-width:80px;padding:8px 16px;font-size:.75rem;transition:all .2s;display:flex}.navbar-btn i{justify-content:center;align-items:center;font-size:1.25rem;display:flex}.navbar-btn:active{background-color:var(--md-sys-color-surface-container)}.navbar-btn.active{background-color:var(--md-sys-color-primary-container);color:var(--md-sys-color-on-primary-container)} diff --git a/webroot/assets/index-BjK9R0FR.js b/webroot/assets/index-BjK9R0FR.js deleted file mode 100644 index 8897db4..0000000 --- a/webroot/assets/index-BjK9R0FR.js +++ /dev/null @@ -1,4 +0,0 @@ -(function(){let e=document.createElement(`link`).relList;if(e&&e.supports&&e.supports(`modulepreload`))return;for(let e of document.querySelectorAll(`link[rel="modulepreload"]`))n(e);new MutationObserver(e=>{for(let t of e)if(t.type===`childList`)for(let e of t.addedNodes)e.tagName===`LINK`&&e.rel===`modulepreload`&&n(e)}).observe(document,{childList:!0,subtree:!0});function t(e){let t={};return e.integrity&&(t.integrity=e.integrity),e.referrerPolicy&&(t.referrerPolicy=e.referrerPolicy),e.crossOrigin===`use-credentials`?t.credentials=`include`:e.crossOrigin===`anonymous`?t.credentials=`omit`:t.credentials=`same-origin`,t}function n(e){if(e.ep)return;e.ep=!0;let n=t(e);fetch(e.href,n)}})();var e=0;function t(t){return`${t}_callback_${Date.now()}_${e++}`}function n(e,n){return n===void 0&&(n={}),new Promise((r,i)=>{let a=t(`exec`);window[a]=(e,t,n)=>{r({errno:e,stdout:t,stderr:n}),o(a)};function o(e){delete window[e]}try{ksu.exec(e,JSON.stringify(n),a)}catch(e){i(e),o(a)}})}function r(){this.listeners={}}r.prototype.on=function(e,t){this.listeners[e]||(this.listeners[e]=[]),this.listeners[e].push(t)},r.prototype.emit=function(e,...t){this.listeners[e]&&this.listeners[e].forEach(e=>e(...t))};function i(){this.listeners={},this.stdin=new r,this.stdout=new r,this.stderr=new r}i.prototype.on=function(e,t){this.listeners[e]||(this.listeners[e]=[]),this.listeners[e].push(t)},i.prototype.emit=function(e,...t){this.listeners[e]&&this.listeners[e].forEach(e=>e(...t))};var a={xmlns:`http://www.w3.org/2000/svg`,width:24,height:24,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,"stroke-width":2,"stroke-linecap":`round`,"stroke-linejoin":`round`},o=([e,t,n])=>{let r=document.createElementNS(`http://www.w3.org/2000/svg`,e);return Object.keys(t).forEach(e=>{r.setAttribute(e,String(t[e]))}),n?.length&&n.forEach(e=>{let t=o(e);r.appendChild(t)}),r},s=(e,t={})=>o([`svg`,{...a,...t},e]),c=e=>{for(let t in e)if(t.startsWith(`aria-`)||t===`role`||t===`title`)return!0;return!1},l=(...e)=>e.filter((e,t,n)=>!!e&&e.trim()!==``&&n.indexOf(e)===t).join(` `).trim(),u=e=>e.replace(/^([A-Z])|[\s-_]+(\w)/g,(e,t,n)=>n?n.toUpperCase():t.toLowerCase()),d=e=>{let t=u(e);return t.charAt(0).toUpperCase()+t.slice(1)},f=e=>Array.from(e.attributes).reduce((e,t)=>(e[t.name]=t.value,e),{}),p=e=>typeof e==`string`?e:!e||!e.class?``:e.class&&typeof e.class==`string`?e.class.split(` `):e.class&&Array.isArray(e.class)?e.class:``,m=(e,{nameAttr:t,icons:n,attrs:r})=>{let i=e.getAttribute(t);if(i==null)return;let o=n[d(i)];if(!o)return console.warn(`${e.outerHTML} icon name was not found in the provided icons object.`);let u=f(e),m=c(u)?{}:{"aria-hidden":`true`},h={...a,"data-lucide":i,...m,...r,...u},g=p(u),_=p(r),v=l(`lucide`,`lucide-${i}`,...g,..._);v&&Object.assign(h,{class:v});let y=s(o,h);return e.parentNode?.replaceChild(y,e)},h=[[`path`,{d:`M22 12h-2.48a2 2 0 0 0-1.93 1.46l-2.35 8.36a.25.25 0 0 1-.48 0L9.24 2.18a.25.25 0 0 0-.48 0l-2.35 8.36A2 2 0 0 1 4.49 12H2`}]],g=[[`path`,{d:`M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`}],[`path`,{d:`M10 9H8`}],[`path`,{d:`M16 13H8`}],[`path`,{d:`M16 17H8`}]],_=[[`path`,{d:`M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8`}],[`path`,{d:`M21 3v5h-5`}],[`path`,{d:`M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16`}],[`path`,{d:`M8 16H3v5`}]],v=[[`path`,{d:`M15.2 3a2 2 0 0 1 1.4.6l3.8 3.8a2 2 0 0 1 .6 1.4V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2z`}],[`path`,{d:`M17 21v-7a1 1 0 0 0-1-1H8a1 1 0 0 0-1 1v7`}],[`path`,{d:`M7 3v4a1 1 0 0 0 1 1h7`}]],y=[[`path`,{d:`M9.671 4.136a2.34 2.34 0 0 1 4.659 0 2.34 2.34 0 0 0 3.319 1.915 2.34 2.34 0 0 1 2.33 4.033 2.34 2.34 0 0 0 0 3.831 2.34 2.34 0 0 1-2.33 4.033 2.34 2.34 0 0 0-3.319 1.915 2.34 2.34 0 0 1-4.659 0 2.34 2.34 0 0 0-3.32-1.915 2.34 2.34 0 0 1-2.33-4.033 2.34 2.34 0 0 0 0-3.831A2.34 2.34 0 0 1 6.35 6.051a2.34 2.34 0 0 0 3.319-1.915`}],[`circle`,{cx:`12`,cy:`12`,r:`3`}]],b=[[`circle`,{cx:`12`,cy:`12`,r:`4`}],[`path`,{d:`M12 2v2`}],[`path`,{d:`M12 20v2`}],[`path`,{d:`m4.93 4.93 1.41 1.41`}],[`path`,{d:`m17.66 17.66 1.41 1.41`}],[`path`,{d:`M2 12h2`}],[`path`,{d:`M20 12h2`}],[`path`,{d:`m6.34 17.66-1.41 1.41`}],[`path`,{d:`m19.07 4.93-1.41 1.41`}]],x=({icons:e={},nameAttr:t=`data-lucide`,attrs:n={},root:r=document,inTemplates:i}={})=>{if(!Object.values(e).length)throw Error(`Please provide an icons object. -If you want to use all the icons you can import it like: - \`import { createIcons, icons } from 'lucide'; -lucide.createIcons({icons});\``);if(r===void 0)throw Error("`createIcons()` only works in a browser environment.");if(Array.from(r.querySelectorAll(`[${t}]`)).forEach(r=>m(r,{nameAttr:t,icons:e,attrs:n})),i&&Array.from(r.querySelectorAll(`template`)).forEach(r=>x({icons:e,nameAttr:t,attrs:n,root:r.content,inTemplates:i})),t===`data-lucide`){let t=r.querySelectorAll(`[icon-name]`);t.length>0&&(console.warn(`[Lucide] Some icons were found with the now deprecated icon-name attribute. These will still be replaced for backwards compatibility, but will no longer be supported in v1.0 and you should switch to data-lucide`),Array.from(t).forEach(t=>m(t,{nameAttr:`icon-name`,icons:e,attrs:n})))}},S=`/data/adb/modules/LuminPro/config`,C=`/data/adb/modules/LuminPro/config/path`,w=`/data/adb/modules/LuminPro/config/.backup`,T=`/data/adb/modules/LuminPro/pid/inotifyd.pid`,E=`/data/adb/modules/LuminPro/pid/up.flag`,D=`/data/adb/modules/LuminPro/pid/stop.flag`,O=`/data/adb/modules/LuminPro/service.log`,k=`/sys/class/backlight/panel0-backlight/brightness`,A=`/sys/class/backlight/panel0-backlight/max_brightness`,j=k,M=A;function N(e){let t=document.getElementById(`toast`);t.textContent=e,t.classList.add(`show`),setTimeout(()=>t.classList.remove(`show`),3e3)}async function P(e){try{return await n(e)}catch(e){return console.error(e),{errno:-1,stdout:``,stderr:String(e)}}}async function F(e,t){return P(`echo -n '${String(t).replace(/'/g,`'\\''`)}' > "${e}"`)}async function I(){let[e,t]=await Promise.all([P(`cat "${C}/now_bri_file.txt"`),P(`cat "${C}/max_bri_file.txt"`)]);e.errno===0&&(j=e.stdout.trim()),t.errno===0&&(M=t.stdout.trim());let[n,r,i,a,o,s]=await Promise.all([P(`cat "${S}/ui_max_bri.txt"`),P(`cat "${S}/max_bri.txt"`),P(`cat "${S}/sleep_time.txt"`),P(`cat "${S}/auto_bri_sleep.txt"`),P(`cat "${S}/steps_num.txt"`),P(`cat "${S}/log_max_size.txt"`)]);if(n.errno===0&&(document.getElementById(`input-ui-max-bri`).value=n.stdout.trim()),r.errno===0&&(document.getElementById(`input-max-bri`).value=r.stdout.trim()),document.getElementById(`input-now-bri-file`).value=j,document.getElementById(`input-sys-max-bri-file`).value=M,i.errno===0){let e=i.stdout.trim(),t=document.getElementById(`input-sleep-mode`),n=document.getElementById(`sleep-time-expand`);if(e&&e.includes(`-`)){t.checked=!0,n.classList.add(`show`);let[r,i]=e.split(`-`);r.length===4&&(document.getElementById(`input-sleep-start-h`).value=r.slice(0,2),document.getElementById(`input-sleep-start-m`).value=r.slice(2)),i.length===4&&(document.getElementById(`input-sleep-end-h`).value=i.slice(0,2),document.getElementById(`input-sleep-end-m`).value=i.slice(2))}else t.checked=!1,n.classList.remove(`show`),document.getElementById(`input-sleep-start-h`).value=`19`,document.getElementById(`input-sleep-start-m`).value=`00`,document.getElementById(`input-sleep-end-h`).value=`06`,document.getElementById(`input-sleep-end-m`).value=`00`}if(a.errno===0&&(document.getElementById(`input-auto-bri-sleep`).checked=a.stdout.trim()===`1`),o.errno===0){let e=o.stdout.trim();document.getElementById(`input-steps-num`).value=e||`50`}else document.getElementById(`input-steps-num`).value=`50`;if(s.errno===0){let e=s.stdout.trim();document.getElementById(`input-log-max-size`).value=e||`500`}else document.getElementById(`input-log-max-size`).value=`500`}async function L(){let e=document.getElementById(`input-ui-max-bri`).value,t=document.getElementById(`input-max-bri`).value,n=e=>String(e).padStart(2,`0`),r=document.getElementById(`input-sleep-mode`).checked,i=``;r&&(i=`${n(document.getElementById(`input-sleep-start-h`).value)}${n(document.getElementById(`input-sleep-start-m`).value)}-${n(document.getElementById(`input-sleep-end-h`).value)}${n(document.getElementById(`input-sleep-end-m`).value)}`);let a=document.getElementById(`input-auto-bri-sleep`).checked?`1`:`0`,o=document.getElementById(`input-steps-num`).value||`50`,s=document.getElementById(`input-log-max-size`).value||`500`;if(!e||!t){N(`亮度值不能为空`);return}N(`保存中...`),await F(`${S}/ui_max_bri.txt`,e),await F(`${S}/max_bri.txt`,t),await F(`${S}/sleep_time.txt`,i),await F(`${S}/auto_bri_sleep.txt`,a),await F(`${S}/steps_num.txt`,o),await F(`${S}/log_max_size.txt`,s),await P(`rm -f "${E}"`);let c=await P(`cat "${T}"`);c.errno===0&&c.stdout.trim()?N(`配置已保存 (可能需要在下次调整时生效)`):N(`配置已保存 (服务未运行)`)}async function R(){let e=document.getElementById(`input-now-bri-file`).value||k,t=document.getElementById(`input-sys-max-bri-file`).value||A;N(`保存中...`);let n=j!==e||M!==t;await F(`${C}/now_bri_file.txt`,e),await F(`${C}/max_bri_file.txt`,t),N(n?`设备路径已修改,需要重启服务生效`:`设置已保存`)}var z=!1,B=null;function V(){let e=document.getElementById(`btn-reset`);e.textContent=`恢复默认`,e.classList.remove(`btn-danger`),z=!1,B&&clearTimeout(B)}async function H(){let e=document.getElementById(`btn-reset`);if(!z){z=!0,e.textContent=`确认`,e.classList.add(`btn-danger`),B=setTimeout(V,5e3);return}N(`正在恢复默认配置...`),V();let[t,n,r,i,a,o]=await Promise.all([P(`cat "${w}/ui_max_bri.txt"`),P(`cat "${w}/max_bri.txt"`),P(`cat "${w}/sleep_time.txt"`),P(`cat "${w}/auto_bri_sleep.txt"`),P(`cat "${w}/steps_num.txt"`),P(`cat "${w}/log_max_size.txt"`)]);if(t.errno===0&&(document.getElementById(`input-ui-max-bri`).value=t.stdout.trim()),n.errno===0&&(document.getElementById(`input-max-bri`).value=n.stdout.trim()),r.errno===0){let e=r.stdout.trim(),t=document.getElementById(`input-sleep-mode`),n=document.getElementById(`sleep-time-expand`);if(e.includes(`-`)){t.checked=!0,n.classList.add(`show`);let[r,i]=e.split(`-`);r.length===4&&(document.getElementById(`input-sleep-start-h`).value=r.slice(0,2),document.getElementById(`input-sleep-start-m`).value=r.slice(2)),i.length===4&&(document.getElementById(`input-sleep-end-h`).value=i.slice(0,2),document.getElementById(`input-sleep-end-m`).value=i.slice(2))}}else document.getElementById(`input-sleep-mode`).checked=!0,document.getElementById(`sleep-time-expand`).classList.add(`show`),document.getElementById(`input-sleep-start-h`).value=`19`,document.getElementById(`input-sleep-start-m`).value=`00`,document.getElementById(`input-sleep-end-h`).value=`06`,document.getElementById(`input-sleep-end-m`).value=`00`;document.getElementById(`input-auto-bri-sleep`).checked=i.errno===0?i.stdout.trim()===`1`:!0,document.getElementById(`input-steps-num`).value=a.errno===0?a.stdout.trim():`50`,document.getElementById(`input-log-max-size`).value=o.errno===0?o.stdout.trim():`500`,await L()}async function U(){let[e,t,n,r]=await Promise.all([P(`cat "${j}"`),P(`cat "${M}"`),P(`cat "${T}"`),P(`[ -f "${D}" ] && echo "1" || echo "0"`)]),i=r.stdout.trim()===`1`,a=n.errno===0&&n.stdout.trim(),o=document.querySelector(`.header-status .status-dot`),s=document.querySelector(`.header-status .status-text`),c=document.getElementById(`btn-toggle-service`);i?(o.style.backgroundColor=`var(--md-sys-color-error)`,s.textContent=`已暂停`,c.textContent=`启用`):a?(o.style.backgroundColor=`#4caf50`,s.textContent=`运行中`,c.textContent=`暂停`):(o.style.backgroundColor=`var(--md-sys-color-error)`,s.textContent=`未运行`,c.textContent=`暂停`),document.getElementById(`status-current-bri`).textContent=e.errno===0?e.stdout.trim():`—`,document.getElementById(`status-sys-max-bri`).textContent=t.errno===0?t.stdout.trim():`—`,document.getElementById(`status-inotifyd-pid`).textContent=a?n.stdout.trim():`离线`;let l=document.getElementById(`input-sleep-mode`).checked,u=document.getElementById(`input-sleep-start-h`).value,d=document.getElementById(`input-sleep-start-m`).value,f=document.getElementById(`input-sleep-end-h`).value,p=document.getElementById(`input-sleep-end-m`).value,m=!1;if(l&&u&&d&&f&&p){let e=new Date,t=e.getHours()*100+e.getMinutes(),n=parseInt(u,10)*100+parseInt(d,10),r=parseInt(f,10)*100+parseInt(p,10);n>r?(t>=n||t=n&&t{await U(),e.disabled=!1},1e3)}async function K(){let e=document.getElementById(`log-output`),t=await P(`tail -n 50 "${O}"`);if(t.errno===0){let n=t.stdout.trim()||`暂无日志`;e.textContent!==n&&(e.textContent=n,e.scrollTop=e.scrollHeight)}}async function q(){await Promise.all([U(),K()]),setTimeout(q,500)}async function J(){x({icons:{Sun:b,Settings:y,Save:v,Activity:h,RefreshCw:_,FileText:g}}),document.getElementById(`btn-save`).addEventListener(`click`,L),document.getElementById(`btn-save-advanced`).addEventListener(`click`,R),document.getElementById(`btn-reset`).addEventListener(`click`,H),document.getElementById(`btn-toggle-service`).addEventListener(`click`,W),document.getElementById(`btn-restart-service`).addEventListener(`click`,G),document.getElementById(`input-sleep-mode`).addEventListener(`change`,e=>{let t=document.getElementById(`sleep-time-expand`);e.target.checked?t.classList.add(`show`):t.classList.remove(`show`)}),await I(),q()}document.addEventListener(`DOMContentLoaded`,J); \ No newline at end of file diff --git a/webroot/assets/index-CUDfuwAt.js b/webroot/assets/index-CUDfuwAt.js new file mode 100644 index 0000000..dc8686d --- /dev/null +++ b/webroot/assets/index-CUDfuwAt.js @@ -0,0 +1,6 @@ +(function(){let e=document.createElement(`link`).relList;if(e&&e.supports&&e.supports(`modulepreload`))return;for(let e of document.querySelectorAll(`link[rel="modulepreload"]`))n(e);new MutationObserver(e=>{for(let t of e)if(t.type===`childList`)for(let e of t.addedNodes)e.tagName===`LINK`&&e.rel===`modulepreload`&&n(e)}).observe(document,{childList:!0,subtree:!0});function t(e){let t={};return e.integrity&&(t.integrity=e.integrity),e.referrerPolicy&&(t.referrerPolicy=e.referrerPolicy),e.crossOrigin===`use-credentials`?t.credentials=`include`:e.crossOrigin===`anonymous`?t.credentials=`omit`:t.credentials=`same-origin`,t}function n(e){if(e.ep)return;e.ep=!0;let n=t(e);fetch(e.href,n)}})();var e=0;function t(t){return`${t}_callback_${Date.now()}_${e++}`}function n(e,n){return n===void 0&&(n={}),new Promise((r,i)=>{let a=t(`exec`);window[a]=(e,t,n)=>{r({errno:e,stdout:t,stderr:n}),o(a)};function o(e){delete window[e]}try{ksu.exec(e,JSON.stringify(n),a)}catch(e){i(e),o(a)}})}function r(){this.listeners={}}r.prototype.on=function(e,t){this.listeners[e]||(this.listeners[e]=[]),this.listeners[e].push(t)},r.prototype.emit=function(e,...t){this.listeners[e]&&this.listeners[e].forEach(e=>e(...t))};function i(){this.listeners={},this.stdin=new r,this.stdout=new r,this.stderr=new r}i.prototype.on=function(e,t){this.listeners[e]||(this.listeners[e]=[]),this.listeners[e].push(t)},i.prototype.emit=function(e,...t){this.listeners[e]&&this.listeners[e].forEach(e=>e(...t))};var a={xmlns:`http://www.w3.org/2000/svg`,width:24,height:24,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,"stroke-width":2,"stroke-linecap":`round`,"stroke-linejoin":`round`},o=([e,t,n])=>{let r=document.createElementNS(`http://www.w3.org/2000/svg`,e);return Object.keys(t).forEach(e=>{r.setAttribute(e,String(t[e]))}),n?.length&&n.forEach(e=>{let t=o(e);r.appendChild(t)}),r},s=(e,t={})=>o([`svg`,{...a,...t},e]),c=e=>{for(let t in e)if(t.startsWith(`aria-`)||t===`role`||t===`title`)return!0;return!1},l=(...e)=>e.filter((e,t,n)=>!!e&&e.trim()!==``&&n.indexOf(e)===t).join(` `).trim(),u=e=>e.replace(/^([A-Z])|[\s-_]+(\w)/g,(e,t,n)=>n?n.toUpperCase():t.toLowerCase()),d=e=>{let t=u(e);return t.charAt(0).toUpperCase()+t.slice(1)},f=e=>Array.from(e.attributes).reduce((e,t)=>(e[t.name]=t.value,e),{}),p=e=>typeof e==`string`?e:!e||!e.class?``:e.class&&typeof e.class==`string`?e.class.split(` `):e.class&&Array.isArray(e.class)?e.class:``,m=(e,{nameAttr:t,icons:n,attrs:r})=>{let i=e.getAttribute(t);if(i==null)return;let o=n[d(i)];if(!o)return console.warn(`${e.outerHTML} icon name was not found in the provided icons object.`);let u=f(e),m=c(u)?{}:{"aria-hidden":`true`},h={...a,"data-lucide":i,...m,...r,...u},g=p(u),_=p(r),v=l(`lucide`,`lucide-${i}`,...g,..._);v&&Object.assign(h,{class:v});let y=s(o,h);return e.parentNode?.replaceChild(y,e)},h=[[`path`,{d:`M22 12h-2.48a2 2 0 0 0-1.93 1.46l-2.35 8.36a.25.25 0 0 1-.48 0L9.24 2.18a.25.25 0 0 0-.48 0l-2.35 8.36A2 2 0 0 1 4.49 12H2`}]],g=[[`path`,{d:`M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`}],[`path`,{d:`M10 9H8`}],[`path`,{d:`M16 13H8`}],[`path`,{d:`M16 17H8`}]],_=[[`path`,{d:`M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8`}],[`path`,{d:`M21 3v5h-5`}],[`path`,{d:`M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16`}],[`path`,{d:`M8 16H3v5`}]],v=[[`path`,{d:`M15.2 3a2 2 0 0 1 1.4.6l3.8 3.8a2 2 0 0 1 .6 1.4V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2z`}],[`path`,{d:`M17 21v-7a1 1 0 0 0-1-1H8a1 1 0 0 0-1 1v7`}],[`path`,{d:`M7 3v4a1 1 0 0 0 1 1h7`}]],y=[[`path`,{d:`M9.671 4.136a2.34 2.34 0 0 1 4.659 0 2.34 2.34 0 0 0 3.319 1.915 2.34 2.34 0 0 1 2.33 4.033 2.34 2.34 0 0 0 0 3.831 2.34 2.34 0 0 1-2.33 4.033 2.34 2.34 0 0 0-3.319 1.915 2.34 2.34 0 0 1-4.659 0 2.34 2.34 0 0 0-3.32-1.915 2.34 2.34 0 0 1-2.33-4.033 2.34 2.34 0 0 0 0-3.831A2.34 2.34 0 0 1 6.35 6.051a2.34 2.34 0 0 0 3.319-1.915`}],[`circle`,{cx:`12`,cy:`12`,r:`3`}]],b=[[`circle`,{cx:`12`,cy:`12`,r:`4`}],[`path`,{d:`M12 2v2`}],[`path`,{d:`M12 20v2`}],[`path`,{d:`m4.93 4.93 1.41 1.41`}],[`path`,{d:`m17.66 17.66 1.41 1.41`}],[`path`,{d:`M2 12h2`}],[`path`,{d:`M20 12h2`}],[`path`,{d:`m6.34 17.66-1.41 1.41`}],[`path`,{d:`m19.07 4.93-1.41 1.41`}]],x=({icons:e={},nameAttr:t=`data-lucide`,attrs:n={},root:r=document,inTemplates:i}={})=>{if(!Object.values(e).length)throw Error(`Please provide an icons object. +If you want to use all the icons you can import it like: + \`import { createIcons, icons } from 'lucide'; +lucide.createIcons({icons});\``);if(r===void 0)throw Error("`createIcons()` only works in a browser environment.");if(Array.from(r.querySelectorAll(`[${t}]`)).forEach(r=>m(r,{nameAttr:t,icons:e,attrs:n})),i&&Array.from(r.querySelectorAll(`template`)).forEach(r=>x({icons:e,nameAttr:t,attrs:n,root:r.content,inTemplates:i})),t===`data-lucide`){let t=r.querySelectorAll(`[icon-name]`);t.length>0&&(console.warn(`[Lucide] Some icons were found with the now deprecated icon-name attribute. These will still be replaced for backwards compatibility, but will no longer be supported in v1.0 and you should switch to data-lucide`),Array.from(t).forEach(t=>m(t,{nameAttr:`icon-name`,icons:e,attrs:n})))}},S=`/data/adb/modules/LuminPro/config`,C=`/data/adb/modules/LuminPro/config/path`,w=`/data/adb/modules/LuminPro/config/.backup`,T=`/data/adb/modules/LuminPro/pid/inotifyd.pid`,ee=`/data/adb/modules/LuminPro/pid/up.flag`,te=`/data/adb/modules/LuminPro/pid/stop.flag`,E=`/data/adb/modules/LuminPro/service.log`,D=`/sys/class/backlight/panel0-backlight/brightness`,O=`/sys/class/backlight/panel0-backlight/max_brightness`,k=D,A=O,j=1e3,M=5e3,N=null,P=null;function F(e){let t=document.getElementById(`toast`);t.textContent=e,t.classList.add(`show`),setTimeout(()=>t.classList.remove(`show`),3e3)}async function I(e){try{return await n(e)}catch(e){return console.error(e),{errno:-1,stdout:``,stderr:String(e)}}}async function L(e,t){return I(`echo -n '${String(t).replace(/'/g,`'\\''`)}' > "${e}"`)}async function ne(){let[e,t]=await Promise.all([I(`cat "${C}/now_bri_file.txt"`),I(`cat "${C}/max_bri_file.txt"`)]);e.errno===0&&(k=e.stdout.trim()),t.errno===0&&(A=t.stdout.trim());let[n,r,i,a,o,s]=await Promise.all([I(`cat "${S}/ui_max_bri.txt"`),I(`cat "${S}/max_bri.txt"`),I(`cat "${S}/sleep_time.txt"`),I(`cat "${S}/auto_bri_sleep.txt"`),I(`cat "${S}/steps_num.txt"`),I(`cat "${S}/log_max_size.txt"`)]);if(n.errno===0&&(document.getElementById(`input-ui-max-bri`).value=n.stdout.trim()),r.errno===0&&(document.getElementById(`input-max-bri`).value=r.stdout.trim()),document.getElementById(`input-now-bri-file`).value=k,document.getElementById(`input-sys-max-bri-file`).value=A,i.errno===0){let e=i.stdout.trim(),t=document.getElementById(`input-sleep-mode`),n=document.getElementById(`sleep-time-expand`);if(e&&e.includes(`-`)){t.checked=!0,n.classList.add(`show`);let[r,i]=e.split(`-`);r.length===4&&(document.getElementById(`input-sleep-start-h`).value=r.slice(0,2),document.getElementById(`input-sleep-start-m`).value=r.slice(2)),i.length===4&&(document.getElementById(`input-sleep-end-h`).value=i.slice(0,2),document.getElementById(`input-sleep-end-m`).value=i.slice(2))}else t.checked=!1,n.classList.remove(`show`),document.getElementById(`input-sleep-start-h`).value=`19`,document.getElementById(`input-sleep-start-m`).value=`00`,document.getElementById(`input-sleep-end-h`).value=`06`,document.getElementById(`input-sleep-end-m`).value=`00`}if(a.errno===0&&(document.getElementById(`input-auto-bri-sleep`).checked=a.stdout.trim()===`1`),o.errno===0){let e=o.stdout.trim();document.getElementById(`input-steps-num`).value=e||`50`}else document.getElementById(`input-steps-num`).value=`50`;if(s.errno===0){let e=s.stdout.trim();document.getElementById(`input-log-max-size`).value=e||`500`}else document.getElementById(`input-log-max-size`).value=`500`;let c=localStorage.getItem(`statusLogRefreshInterval`),l=localStorage.getItem(`configRefreshInterval`);c&&!isNaN(parseInt(c,10))&&(j=Math.max(100,parseInt(c,10))),l&&!isNaN(parseInt(l,10))&&(M=Math.max(1e3,parseInt(l,10))),document.getElementById(`input-status-refresh-interval`).value=j,document.getElementById(`input-config-refresh-interval`).value=M}async function R(){let e=document.getElementById(`input-ui-max-bri`).value,t=document.getElementById(`input-max-bri`).value,n=e=>String(e).padStart(2,`0`),r=document.getElementById(`input-sleep-mode`).checked,i=``;r&&(i=`${n(document.getElementById(`input-sleep-start-h`).value)}${n(document.getElementById(`input-sleep-start-m`).value)}-${n(document.getElementById(`input-sleep-end-h`).value)}${n(document.getElementById(`input-sleep-end-m`).value)}`);let a=document.getElementById(`input-auto-bri-sleep`).checked?`1`:`0`,o=document.getElementById(`input-steps-num`).value||`50`,s=document.getElementById(`input-log-max-size`).value||`500`;if(!e||!t){F(`亮度值不能为空`);return}F(`保存中...`),await L(`${S}/ui_max_bri.txt`,e),await L(`${S}/max_bri.txt`,t),await L(`${S}/sleep_time.txt`,i),await L(`${S}/auto_bri_sleep.txt`,a),await L(`${S}/steps_num.txt`,o),await L(`${S}/log_max_size.txt`,s),await I(`rm -f "${ee}"`);let c=await I(`cat "${T}"`);c.errno===0&&c.stdout.trim()?F(`配置已保存 (可能需要在下次调整时生效)`):F(`配置已保存 (服务未运行)`)}async function z(){let e=document.getElementById(`input-now-bri-file`).value||D,t=document.getElementById(`input-sys-max-bri-file`).value||O;F(`保存中...`);let n=k!==e||A!==t;await L(`${C}/now_bri_file.txt`,e),await L(`${C}/max_bri_file.txt`,t),F(n?`设备路径已修改,需要重启服务生效`:`设置已保存`)}function B(){let e=parseInt(document.getElementById(`input-status-refresh-interval`).value,10)||1e3,t=parseInt(document.getElementById(`input-config-refresh-interval`).value,10)||5e3;if(e<100){F(`状态/日志刷新间隔最小为100ms`),document.getElementById(`input-status-refresh-interval`).value=100;return}if(t<1e3){F(`配置刷新间隔最小为1000ms`),document.getElementById(`input-config-refresh-interval`).value=1e3;return}localStorage.setItem(`statusLogRefreshInterval`,e),localStorage.setItem(`configRefreshInterval`,t),j=e,M=t,le(),$(),F(`Web UI 配置已保存,刷新间隔已更新`)}var V=!1,H=null;function U(){let e=document.getElementById(`btn-reset`);e.textContent=`恢复默认`,e.classList.remove(`btn-danger`),V=!1,H&&clearTimeout(H)}async function re(){let e=document.getElementById(`btn-reset`);if(!V){V=!0,e.textContent=`确认`,e.classList.add(`btn-danger`),H=setTimeout(U,5e3);return}F(`正在恢复默认配置...`),U();let[t,n,r,i,a,o]=await Promise.all([I(`cat "${w}/ui_max_bri.txt"`),I(`cat "${w}/max_bri.txt"`),I(`cat "${w}/sleep_time.txt"`),I(`cat "${w}/auto_bri_sleep.txt"`),I(`cat "${w}/steps_num.txt"`),I(`cat "${w}/log_max_size.txt"`)]);if(t.errno===0&&(document.getElementById(`input-ui-max-bri`).value=t.stdout.trim()),n.errno===0&&(document.getElementById(`input-max-bri`).value=n.stdout.trim()),r.errno===0){let e=r.stdout.trim(),t=document.getElementById(`input-sleep-mode`),n=document.getElementById(`sleep-time-expand`);if(e.includes(`-`)){t.checked=!0,n.classList.add(`show`);let[r,i]=e.split(`-`);r.length===4&&(document.getElementById(`input-sleep-start-h`).value=r.slice(0,2),document.getElementById(`input-sleep-start-m`).value=r.slice(2)),i.length===4&&(document.getElementById(`input-sleep-end-h`).value=i.slice(0,2),document.getElementById(`input-sleep-end-m`).value=i.slice(2))}}else document.getElementById(`input-sleep-mode`).checked=!0,document.getElementById(`sleep-time-expand`).classList.add(`show`),document.getElementById(`input-sleep-start-h`).value=`19`,document.getElementById(`input-sleep-start-m`).value=`00`,document.getElementById(`input-sleep-end-h`).value=`06`,document.getElementById(`input-sleep-end-m`).value=`00`;document.getElementById(`input-auto-bri-sleep`).checked=i.errno===0?i.stdout.trim()===`1`:!0,document.getElementById(`input-steps-num`).value=a.errno===0?a.stdout.trim():`50`,document.getElementById(`input-log-max-size`).value=o.errno===0?o.stdout.trim():`500`,await R()}async function W(){let[e,t,n,r,i]=await Promise.all([I(`cat "${k}"`),I(`cat "${A}"`),I(`cat "${T}"`),I(`[ -f "${te}" ] && echo "1" || echo "0"`),I(`settings get system screen_brightness_mode`)]),a=r.stdout.trim()===`1`,o=n.errno===0&&n.stdout.trim(),s=document.querySelector(`.header-status .status-dot`),c=document.querySelector(`.header-status .status-text`),l=document.getElementById(`btn-toggle-service`);a?(s.style.backgroundColor=`var(--md-sys-color-error)`,c.textContent=`已暂停`,l.textContent=`启用`):o?(s.style.backgroundColor=`#4caf50`,c.textContent=`运行中`,l.textContent=`暂停`):(s.style.backgroundColor=`var(--md-sys-color-error)`,c.textContent=`未运行`,l.textContent=`暂停`);let u=e.errno===0?e.stdout.trim():`0`;document.getElementById(`status-current-bri`).textContent=u,document.getElementById(`status-sys-max-bri`).textContent=t.errno===0?t.stdout.trim():`—`,document.getElementById(`status-inotifyd-pid`).textContent=o?n.stdout.trim():`离线`;let d=document.getElementById(`brightness-slider`),f=t.errno===0?parseInt(t.stdout.trim(),10):255;d.max=f;let p=parseInt(u,10)||0;d.value=p;let m=Math.round(p/f*100);document.getElementById(`brightness-display`).textContent=m+`%`;let h=i.errno===0?parseInt(i.stdout.trim(),10):0,g=document.getElementById(`auto-brightness-toggle`);g.checked=h===1;let _=document.getElementById(`input-sleep-mode`).checked,v=document.getElementById(`input-sleep-start-h`).value,y=document.getElementById(`input-sleep-start-m`).value,b=document.getElementById(`input-sleep-end-h`).value,x=document.getElementById(`input-sleep-end-m`).value,S=!1;if(_&&v&&y&&b&&x){let e=new Date,t=e.getHours()*100+e.getMinutes(),n=parseInt(v,10)*100+parseInt(y,10),r=parseInt(b,10)*100+parseInt(x,10);n>r?(t>=n||t=n&&t{await W(),e.disabled=!1},1e3)}var G=null;async function oe(e){try{let t=parseInt(e.target.value,10),n=Math.round(t/255*100);document.getElementById(`brightness-display`).textContent=n+`%`,G&&clearTimeout(G),G=setTimeout(async()=>{let e=await I(`echo -n '${t}' > '${k}' 2>/dev/null && echo 'OK'`);e.errno===0&&e.stdout.includes(`OK`)||(F(`亮度设置失败,已恢复`),await W())},300)}catch(e){F(`设置亮度出错: `+e.message),await W()}}async function se(e){try{let t=e.target.checked?1:0,n=await I(`settings put system screen_brightness_mode ${t}`);n.errno===0?F(t===1?`自动亮度已启用`:`手动亮度已启用`):(F(`设置失败: `+(n.stderr||`未知错误`)),e.target.checked=!e.target.checked)}catch(t){F(`设置自动亮度出错: `+t.message),e.target.checked=!e.target.checked}}var K=``;async function q(){let e=document.getElementById(`log-output`),t=document.getElementById(`log-level-filter`).value;if(!K){e.textContent=`暂无日志`;return}let n=K;if(t){let e=K.split(` +`).filter(e=>e.includes(`[${t}]`));n=e.length>0?e.join(` +`):`暂无 [${t}] 等级的日志`}e.textContent!==n&&(e.textContent=n,e.scrollTop=e.scrollHeight)}async function J(){document.getElementById(`log-output`),document.getElementById(`log-level-filter`).value;let e=await I(`tail -n 50 "${E}"`);e.errno===0&&(K=e.stdout.trim()||`暂无日志`,await q())}var Y=!1,X=null;async function ce(){let e=document.getElementById(`btn-clear-logs`);if(!Y){Y=!0,e.textContent=`确认清空`,e.classList.add(`btn-danger`),X=setTimeout(()=>{Y=!1,e.textContent=`清空日志`,e.classList.remove(`btn-danger`)},5e3);return}Y=!1,e.textContent=`清空日志`,e.classList.remove(`btn-danger`),clearTimeout(X),F(`正在清空日志...`);let t=await I(`> "${E}"`);t.errno===0?(K=``,F(`日志已清空`),await J()):F(`清空失败: `+(t.stderr||`未知错误`))}function le(){N&&=(clearTimeout(N),null),P&&=(clearTimeout(P),null)}async function Z(){try{await Promise.all([W(),J()])}catch(e){console.error(`Error refreshing status/logs:`,e)}N=setTimeout(Z,j)}async function Q(){P=setTimeout(Q,M)}async function $(){await Promise.all([W(),J()]),N=setTimeout(Z,j),P=setTimeout(Q,M)}function ue(){let e=document.querySelectorAll(`.navbar-btn`),t=document.querySelectorAll(`.card`),n=document.querySelector(`.navbar-slider`);function r(e){if(!n||!e)return;let t=e.closest(`.floating-navbar`).getBoundingClientRect(),r=e.getBoundingClientRect(),i=r.left-t.left,a=r.width;n.style.left=i+`px`,n.style.width=a+`px`}function i(e){t.forEach(t=>{let n=t.getAttribute(`data-nav-group`);t.style.display=n===e?`block`:`none`})}function a(t){e.forEach(e=>e.classList.remove(`active`)),t.classList.add(`active`),r(t)}e.forEach(e=>{e.addEventListener(`click`,()=>{i(e.getAttribute(`data-section`)),a(e)})}),e.length>0&&(i(e[0].getAttribute(`data-section`)),r(e[0])),window.addEventListener(`resize`,()=>{let e=document.querySelector(`.navbar-btn.active`);e&&r(e)})}async function de(){x({icons:{Sun:b,Settings:y,Save:v,Activity:h,RefreshCw:_,FileText:g}}),ue(),document.getElementById(`btn-save`).addEventListener(`click`,R),document.getElementById(`btn-save-advanced`).addEventListener(`click`,z),document.getElementById(`btn-save-webui-config`).addEventListener(`click`,B),document.getElementById(`btn-reset`).addEventListener(`click`,re),document.getElementById(`btn-toggle-service`).addEventListener(`click`,ie),document.getElementById(`btn-restart-service`).addEventListener(`click`,ae);let e=document.getElementById(`brightness-slider`),t=document.getElementById(`auto-brightness-toggle`);e&&e.addEventListener(`input`,oe),t&&t.addEventListener(`change`,se);let n=document.getElementById(`log-level-filter`),r=document.getElementById(`btn-clear-logs`);n&&n.addEventListener(`change`,async()=>{await q()}),r&&r.addEventListener(`click`,ce),document.getElementById(`input-sleep-mode`).addEventListener(`change`,e=>{let t=document.getElementById(`sleep-time-expand`);e.target.checked?t.classList.add(`show`):t.classList.remove(`show`)}),await ne(),$()}document.addEventListener(`DOMContentLoaded`,de); \ No newline at end of file diff --git a/webroot/assets/index-DpSbbGTK.css b/webroot/assets/index-DpSbbGTK.css deleted file mode 100644 index e5cd6d2..0000000 --- a/webroot/assets/index-DpSbbGTK.css +++ /dev/null @@ -1 +0,0 @@ -:root{--md-sys-color-background:#111318;--md-sys-color-on-background:#e2e2e9;--md-sys-color-surface:#1e1f25;--md-sys-color-surface-container:#212429;--md-sys-color-surface-container-high:#2b2930;--md-sys-color-on-surface:#e2e2e9;--md-sys-color-on-surface-variant:#c4c6d0;--md-sys-color-primary:#a8c7fa;--md-sys-color-on-primary:#062e6f;--md-sys-color-primary-container:#1b4b9b;--md-sys-color-on-primary-container:#d3e3fd;--md-sys-color-outline:#8e9099;--md-sys-color-outline-variant:#44474f;--md-sys-color-error:#ffb4ab;--md-sys-color-on-error:#690005;--border-radius-m:16px;--border-radius-s:8px;--spacing-s:8px;--spacing-m:16px;--spacing-l:24px}@font-face{font-family:Geist;src:url(/Geist-VariableFont_wght.ttf)format("truetype");font-weight:100 900;font-style:normal}@font-face{font-family:Google Sans Code;src:url(/GoogleSansCode-VariableFont_wght.ttf)format("truetype");font-weight:100 900;font-style:normal}*{box-sizing:border-box;-webkit-tap-highlight-color:transparent}body{padding:0;padding-top:var(--safe-area-inset-top,0);padding-bottom:var(--safe-area-inset-bottom,0);background-color:var(--md-sys-color-background);color:var(--md-sys-color-on-background);margin:0;font-family:Geist,system-ui,-apple-system,sans-serif;line-height:1.5}#app{padding:var(--spacing-m);gap:var(--spacing-m);flex-direction:column;max-width:600px;margin:0 auto;display:flex}.app-header{padding:var(--spacing-m) 0;justify-content:space-between;align-items:center;display:flex}.header-content{align-items:center;gap:var(--spacing-m);display:flex}.header-icon{background:var(--md-sys-color-surface-container-high);border-radius:50%;justify-content:center;align-items:center;width:48px;height:48px;font-size:2rem;display:flex}.header-text h1{color:var(--md-sys-color-on-background);margin:0;font-size:1.25rem;font-weight:500}.header-subtitle{color:var(--md-sys-color-on-surface-variant);margin:0;font-size:.875rem}.header-status{background:var(--md-sys-color-surface-container);border-radius:100px;align-items:center;gap:6px;padding:4px 12px;font-size:.875rem;display:flex}.status-dot{background-color:var(--md-sys-color-error);border-radius:50%;width:8px;height:8px}.card{background-color:var(--md-sys-color-surface);border-radius:var(--border-radius-m);padding:var(--spacing-l);box-shadow:0 1px 3px #0000004d,0 4px 8px 3px #00000026}.card-header{align-items:center;gap:var(--spacing-s);margin-bottom:var(--spacing-l);display:flex}.card-header h2{color:var(--md-sys-color-on-surface);flex-grow:1;margin:0;font-size:1.125rem;font-weight:500}.config-group{margin-bottom:var(--spacing-l);padding:var(--spacing-m);background-color:var(--md-sys-color-surface-container);border-radius:var(--border-radius-s)}.group-title{margin:0 0 var(--spacing-m) 0;color:var(--md-sys-color-primary);text-transform:uppercase;letter-spacing:.5px;font-size:.875rem;font-weight:600}.config-item{justify-content:space-between;align-items:center;display:flex}.config-item+.config-item{margin-top:var(--spacing-m)}.config-label{flex-direction:column;display:flex}.config-name{color:var(--md-sys-color-on-surface);font-size:1rem}.config-desc{color:var(--md-sys-color-on-surface-variant);font-size:.875rem}.config-input{background-color:var(--md-sys-color-surface-container-high);color:var(--md-sys-color-on-surface);border:1px solid var(--md-sys-color-outline);border-radius:var(--border-radius-s);text-align:right;outline:none;width:100px;padding:8px 12px;font-family:inherit;font-size:1rem;transition:border-color .2s,box-shadow .2s}.config-input:focus{border-color:var(--md-sys-color-primary);box-shadow:0 0 0 2px #a8c7fa4d}.config-input-wide{width:140px}.config-item-expand{margin-top:var(--spacing-s);opacity:0;justify-content:flex-end;max-height:0;transition:all .3s;display:flex;overflow:hidden}.config-item-expand.show{opacity:1;max-height:100px;margin-bottom:var(--spacing-m)}.custom-time-picker{align-items:center;gap:8px;display:flex}.time-unit{background-color:var(--md-sys-color-surface-container-high);border-radius:var(--border-radius-s);border:1px solid var(--md-sys-color-outline);align-items:center;gap:2px;padding:2px 6px;display:flex}.time-input{width:32px;color:var(--md-sys-color-on-surface);text-align:center;-moz-appearance:textfield;background-color:#0000;border:none;outline:none;font-family:Google Sans Code,monospace;font-size:.875rem}.time-input::-webkit-outer-spin-button{-webkit-appearance:none;margin:0}.time-input::-webkit-inner-spin-button{-webkit-appearance:none;margin:0}.time-sep{color:var(--md-sys-color-on-surface-variant);font-size:.875rem}.switch{width:52px;height:32px;display:inline-block;position:relative}.switch input{opacity:0;width:0;height:0}.slider{cursor:pointer;background-color:var(--md-sys-color-surface-container-high);border:2px solid var(--md-sys-color-outline);border-radius:34px;transition:all .4s;position:absolute;inset:0}.slider:before{content:"";background-color:var(--md-sys-color-outline);border-radius:50%;width:24px;height:24px;transition:all .4s;position:absolute;bottom:2px;left:2px}input:checked+.slider{background-color:var(--md-sys-color-primary-container);border-color:var(--md-sys-color-primary)}input:checked+.slider:before{background-color:var(--md-sys-color-primary);transform:translate(20px)}.status-grid{gap:var(--spacing-m);grid-template-columns:1fr 1fr;display:grid}.status-item{background-color:var(--md-sys-color-surface-container);padding:var(--spacing-m);border-radius:var(--border-radius-s);flex-direction:column;display:flex}.status-label{color:var(--md-sys-color-on-surface-variant);margin-bottom:4px;font-size:.75rem}.status-value{color:var(--md-sys-color-primary);word-break:break-all;font-size:1.125rem;font-weight:500}.card-actions{margin-top:var(--spacing-l);padding-top:var(--spacing-m);border-top:1px solid var(--md-sys-color-outline-variant);justify-content:flex-end;gap:12px;display:flex}.btn{cursor:pointer;border:none;border-radius:100px;justify-content:center;align-items:center;gap:8px;padding:10px 24px;font-family:inherit;font-size:.875rem;font-weight:500;transition:background-color .2s,opacity .2s;display:inline-flex}.btn:active{opacity:.8}.btn-primary{background-color:var(--md-sys-color-primary);color:var(--md-sys-color-on-primary)}.btn-outline{border:1px solid var(--md-sys-color-outline);color:var(--md-sys-color-primary);background-color:#0000}.btn-outline-s,.btn-text-s{border:1px solid var(--md-sys-color-outline-variant);color:var(--md-sys-color-primary);border-radius:var(--border-radius-s);cursor:pointer;white-space:nowrap;background-color:#0000;justify-content:center;align-items:center;min-width:50px;height:28px;padding:4px 10px;font-size:.75rem;transition:all .2s;display:inline-flex}.btn-text-s:active{background-color:var(--md-sys-color-surface-container-high)}.btn-danger{background-color:var(--md-sys-color-error)!important;color:var(--md-sys-color-on-error)!important;border:none!important}.header-actions{align-items:center;gap:8px;display:flex}.btn-icon-only{color:var(--md-sys-color-on-surface-variant);cursor:pointer;background:0 0;border:none;border-radius:50%;justify-content:center;align-items:center;padding:4px;font-size:1.25rem;display:flex}.btn-icon-only:active{background-color:var(--md-sys-color-surface-container-high)}.animate-spin{animation:1s linear infinite spin}@keyframes spin{0%{transform:rotate(0)}to{transform:rotate(360deg)}}.log-output{padding:var(--spacing-s);border-radius:var(--border-radius-s);white-space:pre-wrap;word-wrap:break-word;height:200px;margin:0;font-family:Google Sans Code,Consolas,Courier New,monospace;font-size:.75rem;overflow-y:auto}.toast{background-color:var(--md-sys-color-on-surface);color:var(--md-sys-color-surface);border-radius:var(--border-radius-s);z-index:1000;text-align:center;width:max-content;max-width:90vw;padding:12px 24px;font-size:.875rem;transition:transform .3s cubic-bezier(.18,.89,.32,1.28);position:fixed;bottom:24px;left:50%;transform:translate(-50%)translateY(100px);box-shadow:0 2px 5px #0006}.toast.show{transform:translate(-50%)translateY(0)} diff --git a/webroot/index.html b/webroot/index.html index 664765b..6fbd0f0 100644 --- a/webroot/index.html +++ b/webroot/index.html @@ -6,8 +6,8 @@ LuminPro - - + + @@ -15,7 +15,6 @@
-

LuminPro

日用屏幕亮度强化

@@ -28,9 +27,8 @@
-
+
-

实时状态

@@ -56,12 +54,31 @@ —
+ + +
+
+ 亮度 + —% +
+
+ 0% + + 100% +
+
+ 自动亮度调节 + +
+
-
+
-

亮度配置

@@ -166,9 +183,8 @@
-
+
-

高级设置

@@ -200,17 +216,77 @@
+ +
+
+

Web UI 配置

+
+ +
+
+
+ 状态/日志刷新间隔 + 单位: 毫秒 (最小100ms) +
+
+ +
+
+
+
+ 配置卡片刷新间隔 + 单位: 毫秒 (最小1000ms) +
+
+ +
+
+
+ +
+ +
+
+ -
+
-

运行日志

+
+ + +
加载中...
+ + +
+ + + + +
diff --git a/index.html b/webui/index.html similarity index 68% rename from index.html rename to webui/index.html index 8a3747d..1aa18c7 100644 --- a/index.html +++ b/webui/index.html @@ -14,7 +14,6 @@
-

LuminPro

日用屏幕亮度强化

@@ -27,9 +26,8 @@
-
+
-

实时状态

@@ -55,12 +53,31 @@ —
+ + +
+
+ 亮度 + —% +
+
+ 0% + + 100% +
+
+ 自动亮度调节 + +
+
-
+
-

亮度配置

@@ -165,9 +182,8 @@
-
+
-

高级设置

@@ -199,17 +215,77 @@
+ +
+
+

Web UI 配置

+
+ +
+
+
+ 状态/日志刷新间隔 + 单位: 毫秒 (最小100ms) +
+
+ +
+
+
+
+ 配置卡片刷新间隔 + 单位: 毫秒 (最小1000ms) +
+
+ +
+
+
+ +
+ +
+
+ -
+
-

运行日志

+
+ + +
加载中...
+ + +
+ + + + +
diff --git a/public/Geist-VariableFont_wght.ttf b/webui/public/Geist-VariableFont_wght.ttf similarity index 100% rename from public/Geist-VariableFont_wght.ttf rename to webui/public/Geist-VariableFont_wght.ttf diff --git a/public/GoogleSansCode-VariableFont_wght.ttf b/webui/public/GoogleSansCode-VariableFont_wght.ttf similarity index 100% rename from public/GoogleSansCode-VariableFont_wght.ttf rename to webui/public/GoogleSansCode-VariableFont_wght.ttf diff --git a/src/main.js b/webui/src/main.js similarity index 58% rename from src/main.js rename to webui/src/main.js index b3ec2e8..c4d3f54 100644 --- a/src/main.js +++ b/webui/src/main.js @@ -14,6 +14,12 @@ const DEFAULT_SYS_MAX_BRI_FILE = '/sys/class/backlight/panel0-backlight/max_brig let NOW_BRI_FILE = DEFAULT_NOW_BRI_FILE; let SYS_MAX_BRI_FILE = DEFAULT_SYS_MAX_BRI_FILE; +// Web UI 配置 +let statusLogRefreshInterval = 1000; // 状态/日志刷新间隔(默认1秒) +let configRefreshInterval = 5000; // 配置卡片刷新间隔(默认5秒) +let autoRefreshStatusLogTimer = null; // 状态/日志刷新定时器 +let autoRefreshConfigTimer = null; // 配置刷新定时器 + // ========================== // 工具函数 // ========================== @@ -114,6 +120,20 @@ async function loadConfig() { } else { document.getElementById('input-log-max-size').value = '500'; } + + // 加载 Web UI 配置(从 localStorage) + const savedStatusRefresh = localStorage.getItem('statusLogRefreshInterval'); + const savedConfigRefresh = localStorage.getItem('configRefreshInterval'); + + if (savedStatusRefresh && !isNaN(parseInt(savedStatusRefresh, 10))) { + statusLogRefreshInterval = Math.max(100, parseInt(savedStatusRefresh, 10)); + } + if (savedConfigRefresh && !isNaN(parseInt(savedConfigRefresh, 10))) { + configRefreshInterval = Math.max(1000, parseInt(savedConfigRefresh, 10)); + } + + document.getElementById('input-status-refresh-interval').value = statusLogRefreshInterval; + document.getElementById('input-config-refresh-interval').value = configRefreshInterval; } // 2. 保存配置并重启服务 @@ -186,6 +206,38 @@ async function saveAdvancedConfig() { } } +// 2.3 保存 Web UI 配置 +function saveWebUIConfig() { + const statusRefresh = parseInt(document.getElementById('input-status-refresh-interval').value, 10) || 1000; + const configRefresh = parseInt(document.getElementById('input-config-refresh-interval').value, 10) || 5000; + + // 验证最小值 + if (statusRefresh < 100) { + showToast('状态/日志刷新间隔最小为100ms'); + document.getElementById('input-status-refresh-interval').value = 100; + return; + } + if (configRefresh < 1000) { + showToast('配置刷新间隔最小为1000ms'); + document.getElementById('input-config-refresh-interval').value = 1000; + return; + } + + // 保存到 localStorage + localStorage.setItem('statusLogRefreshInterval', statusRefresh); + localStorage.setItem('configRefreshInterval', configRefresh); + + // 更新全局变量 + statusLogRefreshInterval = statusRefresh; + configRefreshInterval = configRefresh; + + // 重启刷新循环 + stopAutoRefresh(); + startAutoRefresh(); + + showToast('Web UI 配置已保存,刷新间隔已更新'); +} + // 2.5 恢复默认 let isResetConfirming = false; let resetTimer = null; @@ -267,11 +319,12 @@ async function handleReset() { // 3. 刷新实时状态 async function loadStatus() { - const [curRes, sysRes, pidRes, stopRes] = await Promise.all([ + const [curRes, sysRes, pidRes, stopRes, autoBriRes] = await Promise.all([ runCmd(`cat "${NOW_BRI_FILE}"`), runCmd(`cat "${SYS_MAX_BRI_FILE}"`), runCmd(`cat "${PID_FILE}"`), - runCmd(`[ -f "${STOP_FLAG_FILE}" ] && echo "1" || echo "0"`) + runCmd(`[ -f "${STOP_FLAG_FILE}" ] && echo "1" || echo "0"`), + runCmd(`settings get system screen_brightness_mode`) ]); const isPaused = stopRes.stdout.trim() === '1'; @@ -296,10 +349,27 @@ async function loadStatus() { } // 填入数值 - document.getElementById('status-current-bri').textContent = curRes.errno === 0 ? curRes.stdout.trim() : '—'; + const currentBri = curRes.errno === 0 ? curRes.stdout.trim() : '0'; + document.getElementById('status-current-bri').textContent = currentBri; document.getElementById('status-sys-max-bri').textContent = sysRes.errno === 0 ? sysRes.stdout.trim() : '—'; document.getElementById('status-inotifyd-pid').textContent = running ? pidRes.stdout.trim() : '离线'; + // 更新亮度滑条 + const brightnessSlider = document.getElementById('brightness-slider'); + const sysMaxBri = sysRes.errno === 0 ? parseInt(sysRes.stdout.trim(), 10) : 255; + brightnessSlider.max = sysMaxBri; + const currentBriValue = parseInt(currentBri, 10) || 0; + brightnessSlider.value = currentBriValue; + + // 显示为百分比 + const percentage = Math.round((currentBriValue / sysMaxBri) * 100); + document.getElementById('brightness-display').textContent = percentage + '%'; + + // 更新自动亮度开关 + const autoBriMode = autoBriRes.errno === 0 ? parseInt(autoBriRes.stdout.trim(), 10) : 0; + const autoBriToggle = document.getElementById('auto-brightness-toggle'); + autoBriToggle.checked = autoBriMode === 1; + // 简易判断当前休眠状态 (只为了前端展示,不影响后端核心) const isEnabled = document.getElementById('input-sleep-mode').checked; const sH = document.getElementById('input-sleep-start-h').value; @@ -353,29 +423,239 @@ async function restartService() { btn.disabled = false; }, 1000); } + +let brightnessChangeTimer = null; + +async function handleBrightnessChange(e) { + try { + const newBri = parseInt(e.target.value, 10); + const percentage = Math.round((newBri / 255) * 100); + + // 立即更新 UI(不等待文件 IO) + document.getElementById('brightness-display').textContent = percentage + '%'; + + // 清除之前的定时器 + if (brightnessChangeTimer) { + clearTimeout(brightnessChangeTimer); + } + + // 防抖:300ms 后才真正写入文件 + brightnessChangeTimer = setTimeout(async () => { + const cmd = `echo -n '${newBri}' > '${NOW_BRI_FILE}' 2>/dev/null && echo 'OK'`; + const res = await runCmd(cmd); + + if (!(res.errno === 0 && res.stdout.includes('OK'))) { + showToast('亮度设置失败,已恢复'); + await loadStatus(); // 恢复旧值 + } + }, 300); + } catch (error) { + showToast('设置亮度出错: ' + error.message); + await loadStatus(); + } +} + +async function handleAutoBrightnessToggle(e) { + try { + const mode = e.target.checked ? 1 : 0; + const cmd = `settings put system screen_brightness_mode ${mode}`; + const res = await runCmd(cmd); + + if (res.errno === 0) { + const msg = mode === 1 ? '自动亮度已启用' : '手动亮度已启用'; + showToast(msg); + } else { + showToast('设置失败: ' + (res.stderr || '未知错误')); + e.target.checked = !e.target.checked; // 恢复旧值 + } + } catch (error) { + showToast('设置自动亮度出错: ' + error.message); + e.target.checked = !e.target.checked; + } +} + +// 保存所有原始日志内容 +let fullLogContent = ''; + +async function applyLogFilter() { + // 快速应用日志筛选,不重新读取文件 + const logEl = document.getElementById('log-output'); + const filterLevel = document.getElementById('log-level-filter').value; + + if (!fullLogContent) { + logEl.textContent = '暂无日志'; + return; + } + + let displayLog = fullLogContent; + if (filterLevel) { + const lines = fullLogContent.split('\n'); + const filteredLines = lines.filter(line => line.includes(`[${filterLevel}]`)); + displayLog = filteredLines.length > 0 ? filteredLines.join('\n') : `暂无 [${filterLevel}] 等级的日志`; + } + + if (logEl.textContent !== displayLog) { + logEl.textContent = displayLog; + logEl.scrollTop = logEl.scrollHeight; + } +} + async function loadLogs() { const logEl = document.getElementById('log-output'); + const filterLevel = document.getElementById('log-level-filter').value; + // 读取最后 50 行日志 const res = await runCmd(`tail -n 50 "${LOG_FILE}"`); if (res.errno === 0) { - const freshLog = res.stdout.trim() || '暂无日志'; - // 只有当日志内容变化时才更新 DOM, 减少闪烁 - if(logEl.textContent !== freshLog) { - logEl.textContent = freshLog; - logEl.scrollTop = logEl.scrollHeight; - } + const rawLog = res.stdout.trim() || '暂无日志'; + fullLogContent = rawLog; + + // 应用筛选 + await applyLogFilter(); + } +} + +let clearLogsConfirming = false; +let clearLogsTimer = null; + +async function handleClearLogs() { + const btn = document.getElementById('btn-clear-logs'); + + if (!clearLogsConfirming) { + // 进入确认状态 + clearLogsConfirming = true; + btn.textContent = '确认清空'; + btn.classList.add('btn-danger'); + + // 5秒后自动重置回原来状态 + clearLogsTimer = setTimeout(() => { + clearLogsConfirming = false; + btn.textContent = '清空日志'; + btn.classList.remove('btn-danger'); + }, 5000); + return; + } + + // 执行清空动作 + clearLogsConfirming = false; + btn.textContent = '清空日志'; + btn.classList.remove('btn-danger'); + clearTimeout(clearLogsTimer); + + showToast('正在清空日志...'); + const res = await runCmd(`> "${LOG_FILE}"`); + + if (res.errno === 0) { + fullLogContent = ''; + showToast('日志已清空'); + await loadLogs(); // 刷新显示 + } else { + showToast('清空失败: ' + (res.stderr || '未知错误')); } } // 自动刷新循环 +function stopAutoRefresh() { + if (autoRefreshStatusLogTimer) { + clearTimeout(autoRefreshStatusLogTimer); + autoRefreshStatusLogTimer = null; + } + if (autoRefreshConfigTimer) { + clearTimeout(autoRefreshConfigTimer); + autoRefreshConfigTimer = null; + } +} + +async function startAutoRefreshStatusLog() { + try { + await Promise.all([loadStatus(), loadLogs()]); + } catch (error) { + console.error('Error refreshing status/logs:', error); + } + autoRefreshStatusLogTimer = setTimeout(startAutoRefreshStatusLog, statusLogRefreshInterval); +} + +async function startAutoRefreshConfig() { + try { + // 刷新配置相关卡片 (这里可以添加配置相关的刷新逻辑) + // 目前配置不需要定时读取,但保留这个函数以便后续扩展 + } catch (error) { + console.error('Error refreshing config:', error); + } + autoRefreshConfigTimer = setTimeout(startAutoRefreshConfig, configRefreshInterval); +} + async function startAutoRefresh() { + // 立即执行一次状态/日志刷新 await Promise.all([loadStatus(), loadLogs()]); - setTimeout(startAutoRefresh, 500); // 0.5s 周期 + + // 启动定时刷新 + autoRefreshStatusLogTimer = setTimeout(startAutoRefreshStatusLog, statusLogRefreshInterval); + autoRefreshConfigTimer = setTimeout(startAutoRefreshConfig, configRefreshInterval); } // ========================== // 初始化 // ========================== + +// 底栏导航逻辑 +function setupNavbar() { + const navbarBtns = document.querySelectorAll('.navbar-btn'); + const sections = document.querySelectorAll('.card'); + const navbarSlider = document.querySelector('.navbar-slider'); + + // 更新滑块位置 + function updateSliderPosition(activeBtn) { + if (!navbarSlider || !activeBtn) return; + + const navbarRect = activeBtn.closest('.floating-navbar').getBoundingClientRect(); + const btnRect = activeBtn.getBoundingClientRect(); + + const sliderLeft = btnRect.left - navbarRect.left; + const sliderWidth = btnRect.width; + + navbarSlider.style.left = sliderLeft + 'px'; + navbarSlider.style.width = sliderWidth + 'px'; + } + + // 根据分组显示卡片 + function showGroup(groupName) { + sections.forEach(section => { + const sectionGroup = section.getAttribute('data-nav-group'); + section.style.display = sectionGroup === groupName ? 'block' : 'none'; + }); + } + + // 设置按钮状态 + function setActiveBtn(btn) { + navbarBtns.forEach(b => b.classList.remove('active')); + btn.classList.add('active'); + updateSliderPosition(btn); + } + + // 为每个按钮添加点击监听 + navbarBtns.forEach(btn => { + btn.addEventListener('click', () => { + const groupName = btn.getAttribute('data-section'); + showGroup(groupName); + setActiveBtn(btn); + }); + }); + + // 初始化:显示第一个分组 + if (navbarBtns.length > 0) { + const firstGroup = navbarBtns[0].getAttribute('data-section'); + showGroup(firstGroup); + updateSliderPosition(navbarBtns[0]); + } + + // 监听窗口大小变化以更新滑块位置 + window.addEventListener('resize', () => { + const activeBtn = document.querySelector('.navbar-btn.active'); + if (activeBtn) updateSliderPosition(activeBtn); + }); +} + async function init() { // 初始化 Lucide 图标 @@ -390,13 +670,43 @@ async function init() { } }); + // 初始化底栏导航 + setupNavbar(); + // 绑定事件 document.getElementById('btn-save').addEventListener('click', saveConfig); document.getElementById('btn-save-advanced').addEventListener('click', saveAdvancedConfig); + document.getElementById('btn-save-webui-config').addEventListener('click', saveWebUIConfig); document.getElementById('btn-reset').addEventListener('click', handleReset); document.getElementById('btn-toggle-service').addEventListener('click', toggleService); document.getElementById('btn-restart-service').addEventListener('click', restartService); + // 绑定亮度和自动亮度控件事件 + const brightnessSlider = document.getElementById('brightness-slider'); + const autoBrightnessToggle = document.getElementById('auto-brightness-toggle'); + + if (brightnessSlider) { + brightnessSlider.addEventListener('input', handleBrightnessChange); + } + + if (autoBrightnessToggle) { + autoBrightnessToggle.addEventListener('change', handleAutoBrightnessToggle); + } + + // 绑定日志控件事件 + const logLevelFilter = document.getElementById('log-level-filter'); + const btnClearLogs = document.getElementById('btn-clear-logs'); + + if (logLevelFilter) { + logLevelFilter.addEventListener('change', async () => { + await applyLogFilter(); // 改变筛选等级时应用筛选 + }); + } + + if (btnClearLogs) { + btnClearLogs.addEventListener('click', handleClearLogs); + } + // 定时休眠折叠逻辑 document.getElementById('input-sleep-mode').addEventListener('change', (e) => { const expandArea = document.getElementById('sleep-time-expand'); diff --git a/src/style.css b/webui/src/style.css similarity index 63% rename from src/style.css rename to webui/src/style.css index b04577e..b406386 100644 --- a/src/style.css +++ b/webui/src/style.css @@ -41,6 +41,16 @@ -webkit-tap-highlight-color: transparent; } +/* 隐藏所有滚动条 */ +html { + scrollbar-width: none; /* Firefox */ + -ms-overflow-style: none; /* IE/Edge */ +} + +html::-webkit-scrollbar { + display: none; /* Chrome, Safari */ +} + body { margin: 0; padding: 0; @@ -51,10 +61,17 @@ body { color: var(--md-sys-color-on-background); font-family: 'Geist', system-ui, -apple-system, sans-serif; line-height: 1.5; + scrollbar-width: none; /* Firefox */ + -ms-overflow-style: none; /* IE/Edge */ +} + +body::-webkit-scrollbar { + display: none; /* Chrome, Safari */ } #app { padding: var(--spacing-m); + padding-bottom: calc(var(--spacing-m) + 80px); max-width: 600px; margin: 0 auto; display: flex; @@ -123,6 +140,13 @@ body { border-radius: var(--border-radius-m); padding: var(--spacing-l); box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.3), 0 4px 8px 3px rgba(0, 0, 0, 0.15); + display: flex; + flex-direction: column; +} + +#log-section { + flex: 1; + min-height: calc(100vh - 220px); } .card-header { @@ -338,6 +362,138 @@ input:checked + .slider:before { word-break: break-all; } +/* Brightness Section */ +.brightness-section { + margin-top: var(--spacing-l); + padding: var(--spacing-m); + background: linear-gradient(135deg, var(--md-sys-color-surface-container-high) 0%, var(--md-sys-color-surface-container) 100%); + border-radius: var(--border-radius-m); + border: 1px solid var(--md-sys-color-outline-variant); +} + +.brightness-header { + display: flex; + justify-content: space-between; + align-items: center; + margin-bottom: var(--spacing-m); +} + +.brightness-title { + font-size: 1rem; + font-weight: 600; + color: var(--md-sys-color-on-surface); + letter-spacing: 0.5px; +} + +.brightness-percent { + font-size: 1.25rem; + font-weight: 700; + color: var(--md-sys-color-primary); + min-width: 50px; + text-align: right; +} + +/* Brightness Slider Container */ +.brightness-container { + position: relative; + display: flex; + align-items: center; + gap: 8px; + margin-bottom: var(--spacing-m); + padding: var(--spacing-s) 0; +} + +.brightness-label { + font-size: 0.75rem; + color: var(--md-sys-color-on-surface-variant); + min-width: 24px; + text-align: center; + font-weight: 500; +} + +/* Brightness Slider */ +.brightness-slider { + flex: 1; + height: 8px; + border-radius: 4px; + background: var(--md-sys-color-surface-container); + outline: none; + -webkit-appearance: none; + appearance: none; + cursor: grab; + transition: all 0.2s; +} + +.brightness-slider:hover { + height: 10px; + box-shadow: 0 0 8px rgba(168, 199, 250, 0.3); +} + +.brightness-slider::-webkit-slider-thumb { + -webkit-appearance: none; + appearance: none; + width: 28px; + height: 28px; + border-radius: 50%; + background: var(--md-sys-color-primary); + cursor: grab; + box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4), inset 0 1px 2px rgba(255, 255, 255, 0.3); + transition: all 0.2s; + border: 2px solid var(--md-sys-color-surface); +} + +.brightness-slider::-webkit-slider-thumb:hover { + box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5), inset 0 1px 2px rgba(255, 255, 255, 0.3); + transform: scale(1.1); +} + +.brightness-slider::-webkit-slider-thumb:active { + cursor: grabbing; + box-shadow: 0 0 0 10px rgba(168, 199, 250, 0.2); +} + +.brightness-slider::-moz-range-thumb { + width: 28px; + height: 28px; + border-radius: 50%; + background: var(--md-sys-color-primary); + cursor: grab; + border: 2px solid var(--md-sys-color-surface); + box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4), inset 0 1px 2px rgba(255, 255, 255, 0.3); + transition: all 0.2s; +} + +.brightness-slider::-moz-range-thumb:hover { + box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5), inset 0 1px 2px rgba(255, 255, 255, 0.3); + transform: scale(1.1); +} + +.brightness-slider::-moz-range-thumb:active { + cursor: grabbing; + box-shadow: 0 0 0 10px rgba(168, 199, 250, 0.2); +} + +.brightness-slider::-moz-range-track { + background: transparent; + border: none; +} + +/* Auto Brightness Row */ +.auto-brightness-row { + display: flex; + justify-content: space-between; + align-items: center; + padding: var(--spacing-s) var(--spacing-m); + background-color: rgba(168, 199, 250, 0.08); + border-radius: var(--border-radius-s); +} + +.auto-brightness-label { + font-size: 0.875rem; + color: var(--md-sys-color-on-surface); + font-weight: 500; +} + /* Actions */ .card-actions { display: flex; @@ -445,11 +601,40 @@ input:checked + .slider:before { font-size: 0.75rem; padding: var(--spacing-s); border-radius: var(--border-radius-s); - height: 200px; + flex: 1; + min-height: 300px; overflow-y: auto; margin: 0; white-space: pre-wrap; word-wrap: break-word; + scrollbar-width: none; /* Firefox */ + -ms-overflow-style: none; /* IE/Edge */ +} + +.log-filter-select { + padding: 6px 12px; + border: 1px solid var(--md-sys-color-outline); + border-radius: var(--border-radius-s); + background-color: var(--md-sys-color-surface); + color: var(--md-sys-color-on-surface); + font-family: inherit; + font-size: 0.875rem; + cursor: pointer; + transition: border-color 0.2s; +} + +.log-filter-select:hover { + border-color: var(--md-sys-color-on-surface); +} + +.log-filter-select:focus { + outline: none; + border-color: var(--md-sys-color-primary); + box-shadow: 0 0 0 2px rgba(76, 175, 80, 0.2); +} + +.log-output::-webkit-scrollbar { + display: none; /* Chrome, Safari */ } /* Simple Toast */ @@ -474,3 +659,68 @@ input:checked + .slider:before { .toast.show { transform: translateX(-50%) translateY(0); } + +/* Floating Navigation Bar */ +.floating-navbar { + position: fixed; + bottom: 16px; + left: 50%; + transform: translateX(-50%); + display: flex; + justify-content: center; + align-items: center; + gap: 8px; + background-color: var(--md-sys-color-surface-container-high); + backdrop-filter: blur(10px); + padding: 12px 16px; + border-radius: 28px; + box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15), 0 8px 24px rgba(0, 0, 0, 0.2); + z-index: 999; + width: fit-content; + max-width: calc(100% - 32px); +} + +.navbar-slider { + position: absolute; + height: 32px; + border-radius: 8px; + background-color: var(--md-sys-color-primary-container); + opacity: 0.5; + transition: left 0.3s cubic-bezier(0.4, 0, 0.2, 1), width 0.3s cubic-bezier(0.4, 0, 0.2, 1); + pointer-events: none; + z-index: -1; +} + +.navbar-btn { + display: flex; + flex-direction: column; + align-items: center; + justify-content: center; + gap: 4px; + padding: 8px 16px; + background-color: transparent; + border: none; + color: var(--md-sys-color-on-surface-variant); + font-size: 0.75rem; + cursor: pointer; + border-radius: 8px; + transition: all 0.2s ease; + flex: 1; + max-width: 80px; +} + +.navbar-btn i { + font-size: 1.25rem; + display: flex; + align-items: center; + justify-content: center; +} + +.navbar-btn:active { + background-color: var(--md-sys-color-surface-container); +} + +.navbar-btn.active { + background-color: var(--md-sys-color-primary-container); + color: var(--md-sys-color-on-primary-container); +} diff --git a/vite.config.js b/webui/vite.config.js similarity index 81% rename from vite.config.js rename to webui/vite.config.js index 98a7236..279e475 100644 --- a/vite.config.js +++ b/webui/vite.config.js @@ -2,7 +2,7 @@ import { defineConfig } from 'vite'; export default defineConfig({ build: { - outDir: 'webroot', + outDir: '../webroot', emptyOutDir: true, }, });