From a6bfba9647962f3f28d52b8af0e43a2ee68f7a61 Mon Sep 17 00:00:00 2001 From: Yule Date: Sun, 5 Apr 2026 05:59:34 +0800 Subject: [PATCH] =?UTF-8?q?chore:=20=E6=94=AF=E6=8C=81=E8=87=AA=E5=AE=9A?= =?UTF-8?q?=E4=B9=89=E6=96=87=E4=BB=B6=E8=AE=BE=E5=A4=87=E8=B7=AF=E5=BE=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- config/path/max_bri_file.txt | 1 + config/path/now_bri_file.txt | 1 + customize.sh | 128 ++++++++++++++++++++++++++----- index.html | 83 ++++++++++++++------ module.prop | 2 +- script/daemon.sh | 48 +++++++++++- script/up.sh | 33 +++++++- service.sh | 22 ++++++ src/main.js | 42 +++++++++- update.json | 4 +- webroot/assets/index-BjK9R0FR.js | 4 + webroot/assets/index-GvCaVVmw.js | 4 - webroot/index.html | 85 ++++++++++++++------ 13 files changed, 375 insertions(+), 82 deletions(-) create mode 100644 config/path/max_bri_file.txt create mode 100644 config/path/now_bri_file.txt create mode 100644 webroot/assets/index-BjK9R0FR.js delete mode 100644 webroot/assets/index-GvCaVVmw.js diff --git a/config/path/max_bri_file.txt b/config/path/max_bri_file.txt new file mode 100644 index 0000000..beaf703 --- /dev/null +++ b/config/path/max_bri_file.txt @@ -0,0 +1 @@ +/sys/class/backlight/panel0-backlight/max_brightness \ No newline at end of file diff --git a/config/path/now_bri_file.txt b/config/path/now_bri_file.txt new file mode 100644 index 0000000..8f88ce9 --- /dev/null +++ b/config/path/now_bri_file.txt @@ -0,0 +1 @@ +/sys/class/backlight/panel0-backlight/brightness \ No newline at end of file diff --git a/customize.sh b/customize.sh index 93a27bd..1eb16a6 100755 --- a/customize.sh +++ b/customize.sh @@ -1,13 +1,104 @@ #!/system/bin/sh #shellcheck shell=ash -now_bri_file="/sys/class/backlight/panel0-backlight/brightness" -max_bri_file="/sys/class/backlight/panel0-backlight/max_brightness" +# 默认设备路径(如果路径配置不存在) +DEFAULT_NOW_BRI_FILE="/sys/class/backlight/panel0-backlight/brightness" +DEFAULT_MAX_BRI_FILE="/sys/class/backlight/panel0-backlight/max_brightness" + mod_config="$MODPATH/config" +mod_path_config="$mod_config/path" old_config="/data/adb/modules/LuminPro/config" +old_path_config="/data/adb/modules/LuminPro/config/path" # 创建配置目录 [ -d "$mod_config" ] || mkdir -p "$mod_config" +[ -d "$mod_path_config" ] || mkdir -p "$mod_path_config" + +# 获取设备路径函数 +get_device_path() { + local path_config="$1" + local default_path="$2" + + if [ -f "$path_config" ]; then + cat "$path_config" + else + echo "$default_path" + fi +} + +# 初始化全局变量(尝试读取配置,失败则使用默认值) +now_bri_file="$(get_device_path "$mod_path_config/now_bri_file.txt" "$DEFAULT_NOW_BRI_FILE")" +max_bri_file="$(get_device_path "$mod_path_config/max_bri_file.txt" "$DEFAULT_MAX_BRI_FILE")" + +# 检查亮度节点文件 +CHECK_FILES() { + sleep 1 + + # 策略:尝试从多个位置读取配置 + # 1. 首先从 $MODPATH(安装到设备上的目录)读取 + # 2. 然后从脚本所在目录读取(压缩包源) + # 3. 最后使用默认值 + + now_bri_file="$DEFAULT_NOW_BRI_FILE" + max_bri_file="$DEFAULT_MAX_BRI_FILE" + + # 尝试从多个来源读取配置文件 + local now_sources="$mod_path_config/now_bri_file.txt $old_path_config/now_bri_file.txt" + local max_sources="$mod_path_config/max_bri_file.txt $old_path_config/max_bri_file.txt" + + # 查找第一个存在的配置文件 + for source_file in $now_sources; do + if [ -f "$source_file" ]; then + now_bri_file="$(cat "$source_file")" + echo "- 从 $source_file 读取了亮度节点路径" + break + fi + done + + for source_file in $max_sources; do + if [ -f "$source_file" ]; then + max_bri_file="$(cat "$source_file")" + echo "- 从 $source_file 读取了最大亮度节点路径" + break + fi + done + + # 验证路径是否存在 + echo "" + echo "- 尝试验证路径..." + echo " - 当前亮度节点: $now_bri_file" + echo " - 最大亮度节点: $max_bri_file" + echo "" + + if [ -f "$now_bri_file" ] && [ -f "$max_bri_file" ]; then + echo "✓ 找到亮度节点文件" + else + echo "x 未找到亮度节点文件" + if [ ! -f "$now_bri_file" ]; then + echo " ✗ 当前亮度节点不存在: $now_bri_file" + fi + if [ ! -f "$max_bri_file" ]; then + echo " ✗ 最大亮度节点不存在: $max_bri_file" + fi + echo "" + echo "设备不支持默认路径,需要修改配置" + echo "修改方法:" + echo " 1. 编辑压缩包内的 config/path/now_bri_file.txt" + echo " 2. 编辑压缩包内的 config/path/max_bri_file.txt" + echo " 3. 添加你设备的正确亮度节点路径" + echo " 4. 重新打包并刷入模块" + echo "" + echo "查找路径的方法:" + echo " find /sys -name '*brightness*' 2>/dev/null | grep -E '(brightness|lcd)'" + abort "x 安装中止:无法找到设备亮度节点" + fi + + now_bri="$(cat "$now_bri_file")" + max_bri="$(cat "$max_bri_file")" + + echo "✓ 当前亮度: $now_bri" + echo "✓ 最大亮度: $max_bri" +} # 监听音量键函数 button_listener() { @@ -51,23 +142,6 @@ NOTE() { fi } -# 检查亮度节点文件 -CHECK_FILES() { - sleep 1 - if [ -f "$now_bri_file" ] && [ -f "$max_bri_file" ]; then - echo "- 找到亮度节点文件" - else - echo "x 未找到亮度节点文件" - abort "x 暂不支持您的设备" - fi - - now_bri="$(cat "$now_bri_file")" - max_bri="$(cat "$max_bri_file")" - - echo "- 当前亮度: $now_bri" - echo "- 最大亮度: $max_bri" -} - # 测试前台最大亮度 TEST_UI_MAX_BRI() { echo "" @@ -171,6 +245,17 @@ IMPORT_OLD_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" + if [ -d "$old_path_config" ]; then + [ -s "$old_path_config/now_bri_file.txt" ] && cp -f "$old_path_config/now_bri_file.txt" "$mod_path_config/" + [ -s "$old_path_config/max_bri_file.txt" ] && cp -f "$old_path_config/max_bri_file.txt" "$mod_path_config/" + else + # 创建默认路径配置 + echo -n "$DEFAULT_NOW_BRI_FILE" >"$mod_path_config/now_bri_file.txt" + echo -n "$DEFAULT_MAX_BRI_FILE" >"$mod_path_config/max_bri_file.txt" + fi + # 版本迁移逻辑 local old_version_code old_version_code="$(grep_get_prop versionCode "/data/adb/modules/LuminPro/module.prop")" @@ -195,8 +280,13 @@ 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_path_config/now_bri_file.txt" ] && echo -n "$DEFAULT_NOW_BRI_FILE" >"$mod_path_config/now_bri_file.txt" + [ ! -f "$mod_path_config/max_bri_file.txt" ] && echo -n "$DEFAULT_MAX_BRI_FILE" >"$mod_path_config/max_bri_file.txt" } # 补全缺失设置并设定默认值 diff --git a/index.html b/index.html index 3616c81..8a3747d 100644 --- a/index.html +++ b/index.html @@ -26,6 +26,37 @@ + +
+
+ +

实时状态

+
+ + +
+
+ +
+
+ 当前亮度 + — +
+
+ 系统最大亮度 + — +
+
+ inotifyd PID + — +
+
+ 休眠状态 + — +
+
+
+
@@ -133,34 +164,38 @@
- -
+ +
- -

实时状态

-
- - + +

高级设置

+
+ +
+
+
+ 当前亮度节点 + 修改需重启服务 +
+
+ +
+
+
+
+ 最大亮度节点 + 修改需重启服务 +
+
+ +
-
-
- 当前亮度 - — -
-
- 系统最大亮度 - — -
-
- inotifyd PID - — -
-
- 休眠状态 - — -
+
+
diff --git a/module.prop b/module.prop index 357455d..8828fda 100755 --- a/module.prop +++ b/module.prop @@ -1,7 +1,7 @@ id=LuminPro name=LuminPro丨日用屏幕亮度强化 version=V2.2 -versionCode=2202 +versionCode=2203 author=酷安@Yule description=本模块旨在让你的 Android 设备随时可以使用高亮度显示屏幕内容。无论设备当前亮度如何,只要满足设定的前台触发亮度条件,模块便会自动且平滑地提升屏幕亮度至硬件支持的峰值状态,确保你在强光室外也能获得清晰的显示效果 updateJson=https://share.yule.ink/magisk/mod/luminpro/update.json \ No newline at end of file diff --git a/script/daemon.sh b/script/daemon.sh index 6927fa5..4e96256 100644 --- a/script/daemon.sh +++ b/script/daemon.sh @@ -7,11 +7,33 @@ SCRIPT_DIR="$(dirname "$REAL_PATH")" MODDIR="$(dirname "$SCRIPT_DIR")" PID_DIR="$MODDIR/pid" +CONFIG_DIR="$MODDIR/config" +PATH_CONFIG_DIR="$CONFIG_DIR/path" pid_file="$PID_DIR/inotifyd.pid" stop_file="$PID_DIR/stop.flag" pause_file="$PID_DIR/daemon.pause" log_file="$MODDIR/service.log" -now_bri_file="/sys/class/backlight/panel0-backlight/brightness" +config_cache_file="$PID_DIR/.config_cache" + +# 默认设备路径 +DEFAULT_NOW_BRI_FILE="/sys/class/backlight/panel0-backlight/brightness" + +# 读取配置函数 +get_config() { + local config_file="$1" + local default_value="$2" + if [ -f "$config_file" ]; then + cat "$config_file" + else + echo "$default_value" + fi +} + +# 获取当前配置的哈希值(用于检测配置变化) +get_config_hash() { + local now_file="$(get_config "$PATH_CONFIG_DIR/now_bri_file.txt" "$DEFAULT_NOW_BRI_FILE")" + echo "$now_file" +} # 日志函数 _log() { @@ -39,14 +61,38 @@ while true; do continue fi + # 获取当前配置 + current_config="$(get_config_hash)" + + # 检查配置是否改变 + if [ -f "$config_cache_file" ]; then + cached_config="$(cat "$config_cache_file")" + if [ "$current_config" != "$cached_config" ]; then + _log "检测到配置文件改变,将重启 inotifyd..." + [ -f "$pid_file" ] && kill -9 "$(cat "$pid_file")" 2>/dev/null + rm -f "$pid_file" + echo "$current_config" >"$config_cache_file" + sleep 1 + continue + fi + else + # 第一次启动或缓存不存在,保存当前配置 + echo "$current_config" >"$config_cache_file" + fi + # 正常启动并监听 _log "启动 inotifyd 监听任务..." + now_bri_file="$current_config" + + # 更新缓存,让 up.sh 知道当前监听的是哪个文件 + echo -n "$now_bri_file" >"$PATH_CONFIG_DIR/.cached_path" # 启动并重定向 (不再使用子进程管道以保证 PID 抓取准确) inotifyd "$MODDIR/script/up.sh" "$now_bri_file:c" >>"$log_file" 2>&1 & inotify_pid=$! echo "$inotify_pid" >"$pid_file" + _log "inotifyd 启动,PID: $inotify_pid,监听文件: $now_bri_file" # 3. 通过 wait 阻塞,实时感知进程死亡 (兼容所有 BusyBox 环境) wait "$inotify_pid" diff --git a/script/up.sh b/script/up.sh index b98257e..1b973e1 100644 --- a/script/up.sh +++ b/script/up.sh @@ -4,12 +4,31 @@ MODDIR="${0%/*/*}" CONFIG_DIR="$MODDIR/config" +PATH_CONFIG_DIR="$CONFIG_DIR/path" PID_DIR="$MODDIR/pid" flag_file="$PID_DIR/up.flag" stop_file="$PID_DIR/stop.flag" log_file="$MODDIR/service.log" pause_file="$PID_DIR/daemon.pause" -now_bri_file="/sys/class/backlight/panel0-backlight/brightness" + +# 默认设备路径 +DEFAULT_NOW_BRI_FILE="/sys/class/backlight/panel0-backlight/brightness" +DEFAULT_MAX_BRI_FILE="/sys/class/backlight/panel0-backlight/max_brightness" + +# 读取配置函数 +get_config() { + local config_file="$1" + local default_value="$2" + if [ -f "$config_file" ]; then + cat "$config_file" + else + echo "$default_value" + fi +} + +# 获取亮度文件路径 +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() { @@ -47,9 +66,6 @@ if [ -f "$flag_file" ]; then fi touch "$flag_file" -# 节点文件 -now_bri_file="/sys/class/backlight/panel0-backlight/brightness" - # 读取配置 (均为数值) ui_max_bri="$(cat "$CONFIG_DIR/ui_max_bri.txt")" max_bri="$(cat "$CONFIG_DIR/max_bri.txt")" @@ -171,6 +187,15 @@ MAIN() { CHECK_BRI rm -f "$flag_file" # 删除成果锁 rm -f "$pause_file" # 解锁守护进程,让它自动拉起 inotifyd + + # 如果配置文件被修改了,杀掉 inotifyd 让 daemon 重启并重新读取配置 + local current_now_bri="$(cat "$PATH_CONFIG_DIR/now_bri_file.txt" 2>/dev/null || echo "$DEFAULT_NOW_BRI_FILE")" + 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..." + killall -9 inotifyd 2>/dev/null + fi } MAIN diff --git a/service.sh b/service.sh index 8ee4bc0..9391aaa 100755 --- a/service.sh +++ b/service.sh @@ -3,8 +3,24 @@ MODDIR="${0%/*}" CONFIG_DIR="$MODDIR/config" +PATH_CONFIG_DIR="$CONFIG_DIR/path" log_file="$MODDIR/service.log" +# 默认设备路径 +DEFAULT_NOW_BRI_FILE="/sys/class/backlight/panel0-backlight/brightness" +DEFAULT_MAX_BRI_FILE="/sys/class/backlight/panel0-backlight/max_brightness" + +# 读取配置函数 +get_config() { + local config_file="$1" + local default_value="$2" + if [ -f "$config_file" ]; then + cat "$config_file" + else + echo "$default_value" + fi +} + _log() { printf '[%s] [service] %s\n' "$(date '+%d %H:%M:%S.%3N')" "$1" >>"$log_file" } @@ -17,6 +33,12 @@ _log "- 前台最大亮度: $(cat "$CONFIG_DIR/ui_max_bri.txt")" _log "- 峰值最大亮度: $(cat "$CONFIG_DIR/max_bri.txt")" _log "- 休眠时间: $(cat "$CONFIG_DIR/sleep_time.txt")" +# 读取设备路径配置 +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 "LuminPro 启动守护监控..." chmod 755 "$MODDIR/script/up.sh" chmod 755 "$MODDIR/script/daemon.sh" diff --git a/src/main.js b/src/main.js index 5a0d658..b3ec2e8 100644 --- a/src/main.js +++ b/src/main.js @@ -2,13 +2,17 @@ import { exec } from 'kernelsu'; import { createIcons, Sun, Settings, Save, Activity, RefreshCw, FileText } from 'lucide'; const CONFIG_DIR = '/data/adb/modules/LuminPro/config'; +const PATH_CONFIG_DIR = '/data/adb/modules/LuminPro/config/path'; const BACKUP_DIR = '/data/adb/modules/LuminPro/config/.backup'; const PID_FILE = '/data/adb/modules/LuminPro/pid/inotifyd.pid'; const FLAG_FILE = '/data/adb/modules/LuminPro/pid/up.flag'; const STOP_FLAG_FILE = '/data/adb/modules/LuminPro/pid/stop.flag'; const LOG_FILE = '/data/adb/modules/LuminPro/service.log'; -const NOW_BRI_FILE = '/sys/class/backlight/panel0-backlight/brightness'; -const SYS_MAX_BRI_FILE = '/sys/class/backlight/panel0-backlight/max_brightness'; +const DEFAULT_NOW_BRI_FILE = '/sys/class/backlight/panel0-backlight/brightness'; +const DEFAULT_SYS_MAX_BRI_FILE = '/sys/class/backlight/panel0-backlight/max_brightness'; + +let NOW_BRI_FILE = DEFAULT_NOW_BRI_FILE; +let SYS_MAX_BRI_FILE = DEFAULT_SYS_MAX_BRI_FILE; // ========================== // 工具函数 @@ -43,6 +47,16 @@ async function writeFile(path, content) { // 1. 加载配置 async function loadConfig() { + // 首先加载设备路径配置 + const [pathNowRes, pathMaxRes] = await Promise.all([ + runCmd(`cat "${PATH_CONFIG_DIR}/now_bri_file.txt"`), + runCmd(`cat "${PATH_CONFIG_DIR}/max_bri_file.txt"`) + ]); + + if (pathNowRes.errno === 0) NOW_BRI_FILE = pathNowRes.stdout.trim(); + if (pathMaxRes.errno === 0) SYS_MAX_BRI_FILE = pathMaxRes.stdout.trim(); + + // 然后加载其他配置 const [uiRes, maxRes, sleepRes, autoRes, stepsRes, logSizeRes] = await Promise.all([ runCmd(`cat "${CONFIG_DIR}/ui_max_bri.txt"`), runCmd(`cat "${CONFIG_DIR}/max_bri.txt"`), @@ -55,6 +69,10 @@ async function loadConfig() { if (uiRes.errno === 0) document.getElementById('input-ui-max-bri').value = uiRes.stdout.trim(); if (maxRes.errno === 0) document.getElementById('input-max-bri').value = maxRes.stdout.trim(); + // 加载高级设置中的设备路径 + document.getElementById('input-now-bri-file').value = NOW_BRI_FILE; + document.getElementById('input-sys-max-bri-file').value = SYS_MAX_BRI_FILE; + if (sleepRes.errno === 0) { const timeVal = sleepRes.stdout.trim(); const modeSwitch = document.getElementById('input-sleep-mode'); @@ -149,6 +167,25 @@ async function saveConfig() { } } +// 2.2 保存高级设置(设备路径) +async function saveAdvancedConfig() { + const nowBriFile = document.getElementById('input-now-bri-file').value || DEFAULT_NOW_BRI_FILE; + const sysMaxBriFile = document.getElementById('input-sys-max-bri-file').value || DEFAULT_SYS_MAX_BRI_FILE; + + showToast('保存中...'); + + // 保存设备路径配置 + const pathChanged = (NOW_BRI_FILE !== nowBriFile) || (SYS_MAX_BRI_FILE !== sysMaxBriFile); + await writeFile(`${PATH_CONFIG_DIR}/now_bri_file.txt`, nowBriFile); + await writeFile(`${PATH_CONFIG_DIR}/max_bri_file.txt`, sysMaxBriFile); + + if (pathChanged) { + showToast('设备路径已修改,需要重启服务生效'); + } else { + showToast('设置已保存'); + } +} + // 2.5 恢复默认 let isResetConfirming = false; let resetTimer = null; @@ -355,6 +392,7 @@ async function init() { // 绑定事件 document.getElementById('btn-save').addEventListener('click', saveConfig); + document.getElementById('btn-save-advanced').addEventListener('click', saveAdvancedConfig); document.getElementById('btn-reset').addEventListener('click', handleReset); document.getElementById('btn-toggle-service').addEventListener('click', toggleService); document.getElementById('btn-restart-service').addEventListener('click', restartService); diff --git a/update.json b/update.json index c03d76f..766bc71 100644 --- a/update.json +++ b/update.json @@ -1,6 +1,6 @@ { - "versionCode": 2202, + "versionCode": 2203, "version": "V2.2", - "zipUrl": "https://share.yule.ink/magisk/mod/luminpro/module/LuminPro_V2.2-2202.zip", + "zipUrl": "https://share.yule.ink/magisk/mod/luminpro/module/LuminPro_V2.2-2203.zip", "changelog": "https://share.yule.ink/magisk/mod/luminpro/changelog.md" } \ No newline at end of file diff --git a/webroot/assets/index-BjK9R0FR.js b/webroot/assets/index-BjK9R0FR.js new file mode 100644 index 0000000..8897db4 --- /dev/null +++ b/webroot/assets/index-BjK9R0FR.js @@ -0,0 +1,4 @@ +(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-GvCaVVmw.js b/webroot/assets/index-GvCaVVmw.js deleted file mode 100644 index 9ff1435..0000000 --- a/webroot/assets/index-GvCaVVmw.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/.backup`,w=`/data/adb/modules/LuminPro/pid/inotifyd.pid`,T=`/data/adb/modules/LuminPro/pid/up.flag`,E=`/data/adb/modules/LuminPro/pid/stop.flag`,D=`/data/adb/modules/LuminPro/service.log`,O=`/sys/class/backlight/panel0-backlight/brightness`,k=`/sys/class/backlight/panel0-backlight/max_brightness`;function A(e){let t=document.getElementById(`toast`);t.textContent=e,t.classList.add(`show`),setTimeout(()=>t.classList.remove(`show`),3e3)}async function j(e){try{return await n(e)}catch(e){return console.error(e),{errno:-1,stdout:``,stderr:String(e)}}}async function M(e,t){return j(`echo -n '${String(t).replace(/'/g,`'\\''`)}' > "${e}"`)}async function N(){let[e,t,n,r,i,a]=await Promise.all([j(`cat "${S}/ui_max_bri.txt"`),j(`cat "${S}/max_bri.txt"`),j(`cat "${S}/sleep_time.txt"`),j(`cat "${S}/auto_bri_sleep.txt"`),j(`cat "${S}/steps_num.txt"`),j(`cat "${S}/log_max_size.txt"`)]);if(e.errno===0&&(document.getElementById(`input-ui-max-bri`).value=e.stdout.trim()),t.errno===0&&(document.getElementById(`input-max-bri`).value=t.stdout.trim()),n.errno===0){let e=n.stdout.trim(),t=document.getElementById(`input-sleep-mode`),r=document.getElementById(`sleep-time-expand`);if(e&&e.includes(`-`)){t.checked=!0,r.classList.add(`show`);let[n,i]=e.split(`-`);n.length===4&&(document.getElementById(`input-sleep-start-h`).value=n.slice(0,2),document.getElementById(`input-sleep-start-m`).value=n.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,r.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(r.errno===0&&(document.getElementById(`input-auto-bri-sleep`).checked=r.stdout.trim()===`1`),i.errno===0){let e=i.stdout.trim();document.getElementById(`input-steps-num`).value=e||`50`}else document.getElementById(`input-steps-num`).value=`50`;if(a.errno===0){let e=a.stdout.trim();document.getElementById(`input-log-max-size`).value=e||`500`}else document.getElementById(`input-log-max-size`).value=`500`}async function P(){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){A(`亮度值不能为空`);return}A(`保存中...`),await M(`${S}/ui_max_bri.txt`,e),await M(`${S}/max_bri.txt`,t),await M(`${S}/sleep_time.txt`,i),await M(`${S}/auto_bri_sleep.txt`,a),await M(`${S}/steps_num.txt`,o),await M(`${S}/log_max_size.txt`,s),await j(`rm -f "${T}"`);let c=await j(`cat "${w}"`);c.errno===0&&c.stdout.trim()?A(`配置已保存 (可能需要在下次调整时生效)`):A(`配置已保存 (服务未运行)`)}var F=!1,I=null;function L(){let e=document.getElementById(`btn-reset`);e.textContent=`恢复默认`,e.classList.remove(`btn-danger`),F=!1,I&&clearTimeout(I)}async function R(){let e=document.getElementById(`btn-reset`);if(!F){F=!0,e.textContent=`确认`,e.classList.add(`btn-danger`),I=setTimeout(L,5e3);return}A(`正在恢复默认配置...`),L();let[t,n,r,i,a,o]=await Promise.all([j(`cat "${C}/ui_max_bri.txt"`),j(`cat "${C}/max_bri.txt"`),j(`cat "${C}/sleep_time.txt"`),j(`cat "${C}/auto_bri_sleep.txt"`),j(`cat "${C}/steps_num.txt"`),j(`cat "${C}/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 P()}async function z(){let[e,t,n,r]=await Promise.all([j(`cat "${O}"`),j(`cat "${k}"`),j(`cat "${w}"`),j(`[ -f "${E}" ] && 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 z(),e.disabled=!1},1e3)}async function H(){let e=document.getElementById(`log-output`),t=await j(`tail -n 50 "${D}"`);if(t.errno===0){let n=t.stdout.trim()||`暂无日志`;e.textContent!==n&&(e.textContent=n,e.scrollTop=e.scrollHeight)}}async function U(){await Promise.all([z(),H()]),setTimeout(U,500)}async function W(){x({icons:{Sun:b,Settings:y,Save:v,Activity:h,RefreshCw:_,FileText:g}}),document.getElementById(`btn-save`).addEventListener(`click`,P),document.getElementById(`btn-reset`).addEventListener(`click`,R),document.getElementById(`btn-toggle-service`).addEventListener(`click`,B),document.getElementById(`btn-restart-service`).addEventListener(`click`,V),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 N(),U()}document.addEventListener(`DOMContentLoaded`,W); \ No newline at end of file diff --git a/webroot/index.html b/webroot/index.html index 650e0bb..664765b 100644 --- a/webroot/index.html +++ b/webroot/index.html @@ -6,7 +6,7 @@ LuminPro - + @@ -27,6 +27,37 @@ + +
+
+ +

实时状态

+
+ + +
+
+ +
+
+ 当前亮度 + — +
+
+ 系统最大亮度 + — +
+
+ inotifyd PID + — +
+
+ 休眠状态 + — +
+
+
+
@@ -134,34 +165,38 @@
- -
+ +
- -

实时状态

-
- - + +

高级设置

+
+ +
+
+
+ 当前亮度节点 + 修改需重启服务 +
+
+ +
+
+
+
+ 最大亮度节点 + 修改需重启服务 +
+
+ +
-
-
- 当前亮度 - — -
-
- 系统最大亮度 - — -
-
- inotifyd PID - — -
-
- 休眠状态 - — -
+
+