mirror of
https://github.com/YuleBest/LuminPro.git
synced 2026-12-04 00:54:42 +08:00
fix: 刷入脚本优化
This commit is contained in:
1 parent
e66b26a2e5
commit
8431079246
17 files changed
+335
-180
No files matched your search
+5
-1
@@ -2,4 +2,8 @@ node_modules/
|
||||
dist/
|
||||
.vite/
|
||||
*.log
|
||||
*.zip
|
||||
*.zip
|
||||
|
||||
# 屏蔽 webroot 下的所有文件,但保留目录本身
|
||||
webroot/*
|
||||
!webroot/.gitkeep
|
||||
@@ -0,0 +1 @@
|
||||
1
|
||||
@@ -0,0 +1 @@
|
||||
512
|
||||
Whitespace-only changes.
Whitespace-only changes.
@@ -0,0 +1 @@
|
||||
50
|
||||
Whitespace-only changes.
+135
-96
@@ -14,71 +14,71 @@ 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"
|
||||
# ==========================
|
||||
# 配置读取函数
|
||||
# ==========================
|
||||
# 优先读取旧配置,其次读取默认配置
|
||||
get_config_value() {
|
||||
local config_name="$1"
|
||||
local old_file="$old_config/$config_name"
|
||||
local new_file="$mod_config/$config_name"
|
||||
local default_value="$2"
|
||||
|
||||
if [ -f "$path_config" ]; then
|
||||
cat "$path_config"
|
||||
else
|
||||
echo "$default_path"
|
||||
# 1. 检查旧配置是否存在且非空
|
||||
if [ -f "$old_file" ]; then
|
||||
local old_val="$(cat "$old_file" 2>/dev/null | tr -d ' \n')"
|
||||
if [ -n "$old_val" ]; then
|
||||
echo "$old_val"
|
||||
return
|
||||
fi
|
||||
fi
|
||||
|
||||
# 2. 检查默认配置是否存在且非空
|
||||
if [ -f "$new_file" ]; then
|
||||
local new_val="$(cat "$new_file" 2>/dev/null | tr -d ' \n')"
|
||||
if [ -n "$new_val" ]; then
|
||||
echo "$new_val"
|
||||
return
|
||||
fi
|
||||
fi
|
||||
|
||||
# 3. 返回默认值
|
||||
echo "$default_value"
|
||||
}
|
||||
|
||||
# 初始化全局变量(尝试读取配置,失败则使用默认值)
|
||||
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")"
|
||||
# 获取设备路径函数(与 get_config_value 相同逻辑)
|
||||
get_device_path() {
|
||||
local config_name="$1"
|
||||
local default_path="$2"
|
||||
get_config_value "$config_name" "$default_path"
|
||||
}
|
||||
|
||||
# 初始化全局变量(优先读取旧配置,其次读取默认值)
|
||||
now_bri_file="$(get_device_path "path/now_bri_file.txt" "$DEFAULT_NOW_BRI_FILE")"
|
||||
max_bri_file="$(get_device_path "path/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 ""
|
||||
|
||||
# 验证路径是否存在
|
||||
echo ""
|
||||
echo "- 尝试验证路径..."
|
||||
echo " - 当前亮度节点: $now_bri_file"
|
||||
echo " - 最大亮度节点: $max_bri_file"
|
||||
echo "- 当前亮度节点: $now_bri_file"
|
||||
echo "- 最大亮度节点: $max_bri_file"
|
||||
echo ""
|
||||
|
||||
if [ -f "$now_bri_file" ] && [ -f "$max_bri_file" ]; then
|
||||
echo "✓ 找到亮度节点文件"
|
||||
echo "[OK] 找到亮度节点文件"
|
||||
else
|
||||
echo "x 未找到亮度节点文件"
|
||||
echo "[X] 未找到亮度节点文件"
|
||||
if [ ! -f "$now_bri_file" ]; then
|
||||
echo " ✗ 当前亮度节点不存在: $now_bri_file"
|
||||
echo " - 当前亮度节点不存在: $now_bri_file"
|
||||
fi
|
||||
if [ ! -f "$max_bri_file" ]; then
|
||||
echo " ✗ 最大亮度节点不存在: $max_bri_file"
|
||||
echo " - 最大亮度节点不存在: $max_bri_file"
|
||||
fi
|
||||
echo ""
|
||||
echo "设备不支持默认路径,需要修改配置"
|
||||
@@ -90,14 +90,14 @@ CHECK_FILES() {
|
||||
echo ""
|
||||
echo "查找路径的方法:"
|
||||
echo " find /sys -name '*brightness*' 2>/dev/null | grep -E '(brightness|lcd)'"
|
||||
abort "x 安装中止:无法找到设备亮度节点"
|
||||
abort "[X] 安装中止:无法找到设备亮度节点"
|
||||
fi
|
||||
|
||||
now_bri="$(cat "$now_bri_file")"
|
||||
max_bri="$(cat "$max_bri_file")"
|
||||
max_bri_sys="$(cat "$max_bri_file")"
|
||||
|
||||
echo "✓ 当前亮度: $now_bri"
|
||||
echo "✓ 最大亮度: $max_bri"
|
||||
echo "[OK] 当前亮度: $now_bri"
|
||||
echo "[OK] 系统最大亮度: $max_bri_sys"
|
||||
}
|
||||
|
||||
# 监听音量键函数
|
||||
@@ -120,42 +120,42 @@ button_listener() {
|
||||
SHOW_CHANGELOG() {
|
||||
local changelog_file="$MODPATH/changelog.md"
|
||||
if [ -f "$changelog_file" ]; then
|
||||
echo "--------------------------------------"
|
||||
echo "- 本次更新日志:"
|
||||
echo "========================================"
|
||||
echo "[*] 本次更新日志:"
|
||||
# 提取第一个二级标题及其内容,直到遇到下一个二级标题或文件结束
|
||||
# 使用更具兼容性的 awk 逻辑
|
||||
awk '/^## / { if (p) exit; p=1; print; next } p { print }' "$changelog_file"
|
||||
echo "--------------------------------------"
|
||||
echo "========================================"
|
||||
fi
|
||||
}
|
||||
|
||||
NOTE() {
|
||||
cat "$MODPATH/NOTE.txt"
|
||||
echo ""
|
||||
echo "* 按音量 + 进入下一步, 按音量 - 退出"
|
||||
echo "* 继续则表明你已理解并接受所有风险"
|
||||
echo "[i] 按音量 + 进入下一步, 按音量 - 退出"
|
||||
echo "[i] 继续则表明你已理解并接受所有风险"
|
||||
|
||||
if [ "$(button_listener)" = "0" ]; then
|
||||
echo "- 已确认进入下一步"
|
||||
echo "[OK] 已确认进入下一步"
|
||||
else
|
||||
abort "- 已退出"
|
||||
abort "[X] 已退出"
|
||||
fi
|
||||
}
|
||||
|
||||
# 测试前台最大亮度
|
||||
TEST_UI_MAX_BRI() {
|
||||
echo ""
|
||||
echo "- 开始测试前台最大亮度"
|
||||
echo "[*] 开始测试前台最大亮度"
|
||||
echo ""
|
||||
|
||||
sleep 1
|
||||
echo "******** 请关闭自动亮度 ********"
|
||||
echo "* 按音量 + 进入下一步, 按音量 - 退出"
|
||||
echo "======== 请关闭自动亮度 ========"
|
||||
echo "[i] 按音量 + 进入下一步, 按音量 - 退出"
|
||||
|
||||
if [ "$(button_listener)" = "0" ]; then
|
||||
echo "- 已确认进入下一步"
|
||||
echo "[OK] 已确认进入下一步"
|
||||
else
|
||||
abort "- 已退出"
|
||||
abort "[X] 已退出"
|
||||
fi
|
||||
|
||||
# 调整亮度前, 记录当前亮度用于之后恢复
|
||||
@@ -163,27 +163,33 @@ TEST_UI_MAX_BRI() {
|
||||
echo ""
|
||||
|
||||
sleep 1
|
||||
echo "******** 请将屏幕亮度调至最大 ********"
|
||||
echo "* 按音量 + 进入下一步, 按音量 - 退出"
|
||||
echo "======== 请将屏幕亮度调至最大 ========"
|
||||
echo "[i] 按音量 + 进入下一步, 按音量 - 退出"
|
||||
|
||||
if [ "$(button_listener)" = "0" ]; then
|
||||
echo "- 已确认进入下一步"
|
||||
echo "[OK] 已确认进入下一步"
|
||||
else
|
||||
abort "- 已退出"
|
||||
abort "[X] 已退出"
|
||||
fi
|
||||
|
||||
ui_max_bri="$(cat "$now_bri_file")"
|
||||
echo "- 前台最大亮度: [ $ui_max_bri ]"
|
||||
echo "[OK] 前台最大亮度: [ $ui_max_bri ]"
|
||||
|
||||
# 保存到旧配置和新配置
|
||||
echo -n "$ui_max_bri" >"$old_config/ui_max_bri.txt"
|
||||
echo -n "$ui_max_bri" >"$mod_config/ui_max_bri.txt"
|
||||
|
||||
echo ""
|
||||
echo "- 峰值最大亮度由节点文件获得: [ $max_bri ]"
|
||||
echo "- 若不符合预期, 请稍后到配置文件或 Web UI 更改"
|
||||
echo -n "$max_bri" >"$mod_config/max_bri.txt"
|
||||
echo "[i] 峰值最大亮度由节点文件获得: [ $max_bri_sys ]"
|
||||
echo "[i] 若不符合预期, 请稍后到配置文件或 Web UI 更改"
|
||||
|
||||
# 保存到旧配置和新配置
|
||||
echo -n "$max_bri_sys" >"$old_config/max_bri.txt"
|
||||
echo -n "$max_bri_sys" >"$mod_config/max_bri.txt"
|
||||
|
||||
echo ""
|
||||
echo "- 测试完成"
|
||||
echo "- 正在为你恢复亮度..."
|
||||
echo "[OK] 测试完成"
|
||||
echo "[*] 正在为你恢复亮度..."
|
||||
echo -n "$restore_bri" >"$now_bri_file"
|
||||
}
|
||||
|
||||
@@ -191,15 +197,51 @@ TEST_UI_MAX_BRI() {
|
||||
END() {
|
||||
echo ""
|
||||
sleep 1
|
||||
echo "******** 模块策略:"
|
||||
echo "- 当亮度达到 [ $(cat "$mod_config/ui_max_bri.txt") ] 时, 自动提升至 [ $(cat "$mod_config/max_bri.txt") ]"
|
||||
echo "- 配置目录: /data/adb/modules/LuminPro/config"
|
||||
echo "- 也可以使用 Web UI 进行配置"
|
||||
|
||||
# 读取最终配置
|
||||
local final_max_bri="$(get_config_value "max_bri.txt" "")"
|
||||
local final_ui_max_bri="$(get_config_value "ui_max_bri.txt" "")"
|
||||
|
||||
# 检查是否需要重新测试
|
||||
if [ -z "$final_max_bri" ] || [ -z "$final_ui_max_bri" ]; then
|
||||
echo ""
|
||||
echo "[!] ======== 配置不完整 ========"
|
||||
if [ -z "$final_max_bri" ]; then
|
||||
echo "[X] 峰值最大亮度: 未配置"
|
||||
else
|
||||
echo "[OK] 峰值最大亮度: $final_max_bri"
|
||||
fi
|
||||
if [ -z "$final_ui_max_bri" ]; then
|
||||
echo "[X] 前台最大亮度: 未配置"
|
||||
else
|
||||
echo "[OK] 前台最大亮度: $final_ui_max_bri"
|
||||
fi
|
||||
echo ""
|
||||
echo "[!] 检测到配置缺失,需要重新进行亮度测试。"
|
||||
echo "[i] 请在模块安装后的重启后,通过以下方式补全配置:"
|
||||
echo " 1. 使用 Web UI 手工输入"
|
||||
echo " 2. 编辑配置文件: /data/adb/modules/LuminPro/config/"
|
||||
echo " 3. 重新刷入新的压缩包(会重新运行此脚本)"
|
||||
echo ""
|
||||
echo "[i] 或按音量 + 现在进行测试, 按音量 - 跳过"
|
||||
if [ "$(button_listener)" = "0" ]; then
|
||||
echo "[*] 正在进行测试..."
|
||||
TEST_UI_MAX_BRI
|
||||
final_max_bri="$(get_config_value "max_bri.txt" "")"
|
||||
final_ui_max_bri="$(get_config_value "ui_max_bri.txt" "")"
|
||||
fi
|
||||
fi
|
||||
|
||||
echo ""
|
||||
echo "* 模块已刷入, 请重启手机"
|
||||
echo "- 感谢您的使用"
|
||||
echo "- 作者: 酷安 @于乐yule"
|
||||
echo "======== 模块策略 ========"
|
||||
echo "[*] 当亮度达到 [ $final_ui_max_bri ] 时,自动提升至 [ $final_max_bri ]"
|
||||
echo "[i] 配置目录: /data/adb/modules/LuminPro/config"
|
||||
echo "[i] 也可以使用 Web UI 进行配置"
|
||||
|
||||
echo ""
|
||||
echo "[OK] 模块已刷入,请重启手机"
|
||||
echo "[i] 感谢您的使用"
|
||||
echo "[i] 作者: 酷安 @于乐yule"
|
||||
echo ""
|
||||
|
||||
sleep 1
|
||||
@@ -214,32 +256,29 @@ IMPORT_OLD_CONFIG() {
|
||||
|
||||
echo ""
|
||||
sleep 1
|
||||
echo "- 检测到已有配置:"
|
||||
echo " - 前台最大亮度: $(cat "$old_config/ui_max_bri.txt")"
|
||||
echo " - 峰值最大亮度: $(cat "$old_config/max_bri.txt")"
|
||||
echo "[i] 检测到已有配置:"
|
||||
echo " - 前台最大亮度: $(cat "$old_config/ui_max_bri.txt")"
|
||||
echo " - 峰值最大亮度: $(cat "$old_config/max_bri.txt")"
|
||||
if [ -s "$old_config/sleep_time.txt" ]; then
|
||||
echo " - 休眠时间: $(cat "$old_config/sleep_time.txt")"
|
||||
echo " - 休眠时间: $(cat "$old_config/sleep_time.txt")"
|
||||
fi
|
||||
if [ -s "$old_config/auto_bri_sleep.txt" ]; then
|
||||
echo " - 自动亮度时休眠: $(cat "$old_config/auto_bri_sleep.txt" | sed 's/1/开启/;s/0/关闭/')"
|
||||
echo " - 自动亮度时休眠: $(cat "$old_config/auto_bri_sleep.txt" | sed 's/1/开启/;s/0/关闭/')"
|
||||
fi
|
||||
if [ -s "$old_config/steps_num.txt" ]; then
|
||||
echo " - 亮度提升步数: $(cat "$old_config/steps_num.txt")"
|
||||
echo " - 亮度提升步数: $(cat "$old_config/steps_num.txt")"
|
||||
fi
|
||||
if [ -s "$old_config/log_max_size.txt" ]; then
|
||||
echo " - 日志大小限制: $(cat "$old_config/log_max_size.txt") KB"
|
||||
fi
|
||||
if [ -s "$old_config/sleep_time.txt" ]; then
|
||||
echo " - 休眠时间: $(cat "$old_config/sleep_time.txt")"
|
||||
echo " - 日志大小限制: $(cat "$old_config/log_max_size.txt") KB"
|
||||
fi
|
||||
echo ""
|
||||
echo "* 按音量 + 沿用旧配置, 按音量 - 重新测试"
|
||||
echo "[?] 按音量 + 沿用旧配置, 按音量 - 重新测试"
|
||||
|
||||
if [ "$(button_listener)" = "0" ]; then
|
||||
echo "- 已沿用旧配置"
|
||||
echo "[OK] 已沿用旧配置"
|
||||
cp -f "$old_config/ui_max_bri.txt" "$mod_config/"
|
||||
cp -f "$old_config/max_bri.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"
|
||||
[ -e "$old_config/sleep_time.txt" ] && cp -f "$old_config/sleep_time.txt" "$mod_config/" || touch "$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/"
|
||||
@@ -259,7 +298,7 @@ IMPORT_OLD_CONFIG() {
|
||||
local old_version_code
|
||||
old_version_code="$(grep_get_prop versionCode "/data/adb/modules/LuminPro/module.prop")"
|
||||
if [ "$old_version_code" = "2101" ] && [ ! -d "$old_config/.backup" ]; then
|
||||
echo "- 检测到从 2101 版本升级, 正在补全备份目录..."
|
||||
echo "[i] 检测到从 2101 版本升级,正在补全备份目录..."
|
||||
mkdir -p "$mod_config/.backup"
|
||||
cp -f "$mod_config/"*.txt "$mod_config/.backup/" 2>/dev/null
|
||||
else
|
||||
@@ -269,7 +308,7 @@ IMPORT_OLD_CONFIG() {
|
||||
fi
|
||||
return 0
|
||||
else
|
||||
echo "- 将重新测试"
|
||||
echo "[*] 将重新测试"
|
||||
return 1
|
||||
fi
|
||||
fi
|
||||
@@ -296,7 +335,7 @@ INIT_CONFIG() {
|
||||
|
||||
# 补全缺失设置并设定默认值
|
||||
ENSURE_DEFAULTS() {
|
||||
[ ! -s "$mod_config/sleep_time.txt" ] && echo "1900-0600" >"$mod_config/sleep_time.txt"
|
||||
[ ! -f "$mod_config/sleep_time.txt" ] && touch "$mod_config/sleep_time.txt"
|
||||
[ ! -s "$mod_config/auto_bri_sleep.txt" ] && echo "1" >"$mod_config/auto_bri_sleep.txt"
|
||||
[ ! -s "$mod_config/steps_num.txt" ] && echo "50" >"$mod_config/steps_num.txt"
|
||||
[ ! -s "$mod_config/log_max_size.txt" ] && echo "500" >"$mod_config/log_max_size.txt"
|
||||
|
||||
+1
-1
@@ -101,7 +101,7 @@ while true; do
|
||||
|
||||
# 3. 通过 wait 阻塞,实时感知进程死亡 (兼容所有 BusyBox 环境)
|
||||
wait "$inotify_pid"
|
||||
_log "⚠ 监听进程 ($inotify_pid) 已退出,将在 1 秒后重启..." "WARN"
|
||||
_log "[-] 监听进程 ($inotify_pid) 已退出,将在 1 秒后重启..." "WARN"
|
||||
|
||||
sleep 0.5
|
||||
done
|
||||
+18
-18
@@ -55,8 +55,8 @@ _log() {
|
||||
printf '[%s] [%-8s] [%-8s] %s\n' "$(date '+%m-%d %H:%M:%S')" "up" "$level" "$1" >>"$log_file"
|
||||
}
|
||||
|
||||
_log "→ 收到 inotifyd 通知 (PID: $$)" "INFO"
|
||||
_log "⚠ 正在抢占:清理其他 inotifyd 进程..." "WAIT"
|
||||
_log "[*] 收到 inotifyd 通知 (PID: $$)" "INFO"
|
||||
_log "[!] 正在抢占:清理其他 inotifyd 进程..." "WAIT"
|
||||
touch "$pause_file"
|
||||
killall -9 inotifyd 2>/dev/null
|
||||
for p in $(pgrep -f "up.sh"); do
|
||||
@@ -64,12 +64,12 @@ for p in $(pgrep -f "up.sh"); do
|
||||
done
|
||||
|
||||
if [ -f "$stop_file" ]; then
|
||||
_log "✗ 服务已处于手动暂停状态,本次操作被取消" "WARN"
|
||||
_log "[X] 服务已处于手动暂停状态,本次操作被取消" "WARN"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
if [ -f "$flag_file" ]; then
|
||||
_log "✗ 另一个 up.sh 进程正在运行,本进程退出" "WARN"
|
||||
_log "[X] 另一个 up.sh 进程正在运行,本进程退出" "WARN"
|
||||
exit 1
|
||||
fi
|
||||
touch "$flag_file"
|
||||
@@ -119,11 +119,11 @@ update_all() {
|
||||
|
||||
# 如果步长为 0 (差值太小), 直接设置目标亮度
|
||||
if [ "$step_value" -eq 0 ]; then
|
||||
_log "✓ 直接设定亮度为: $target_bri" "INFO"
|
||||
_log "[OK] 直接设定亮度为: $target_bri" "INFO"
|
||||
echo -n "$target_bri" >"$now_bri_file" && return 0 || return 1
|
||||
fi
|
||||
|
||||
_log "→ 开始调整亮度: $start_bri → $target_bri (共 $steps_num 步)" "INFO"
|
||||
_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
|
||||
@@ -143,29 +143,29 @@ CHECK_BRI() {
|
||||
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" "SUCCESS"
|
||||
_log "[+] 满足提升条件: $now_bri >= $ui_max_bri,目标 ^ $target_bri" "SUCCESS"
|
||||
|
||||
if update_all; then
|
||||
_log "✓ 亮度提升已完成 (当前: $target_bri)" "SUCCESS"
|
||||
_log "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━" "INFO"
|
||||
_log "[OK] 亮度提升已完成 (当前: $target_bri)" "SUCCESS"
|
||||
_log "================================================" "INFO"
|
||||
return 0
|
||||
else
|
||||
_log "✗ 亮度提升失败:无法写入节点文件" "ERROR"
|
||||
_log "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━" "ERROR"
|
||||
_log "[X] 亮度提升失败:无法写入节点文件" "ERROR"
|
||||
_log "================================================" "ERROR"
|
||||
return 1
|
||||
fi
|
||||
fi
|
||||
sleep 0.3
|
||||
done
|
||||
_log "─ 检测超时:未持续触发有效提升阈值" "WARN"
|
||||
_log "[-] 检测超时:未持续触发有效提升阈值" "WARN"
|
||||
return 1
|
||||
}
|
||||
|
||||
MAIN() {
|
||||
# 解析并判断休眠
|
||||
if IS_SLEEP_TIME; then
|
||||
_log "⏸ 休眠时段 ($sleep_start-$sleep_end),本次调整已跳过" "INFO"
|
||||
_log "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━" "INFO"
|
||||
_log "[||] 休眠时段 ($sleep_start-$sleep_end),本次调整已跳过" "INFO"
|
||||
_log "================================================" "INFO"
|
||||
rm -f "$flag_file"
|
||||
return
|
||||
fi
|
||||
@@ -173,14 +173,14 @@ MAIN() {
|
||||
if [ "$auto_bri_sleep" = "1" ]; then
|
||||
mode="$(settings get system screen_brightness_mode 2>/dev/null)"
|
||||
if [ "$mode" = "1" ]; then
|
||||
_log "🔄 自动亮度模式已启用,本次调整已跳过" "INFO"
|
||||
_log "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━" "INFO"
|
||||
_log "[<>] 自动亮度模式已启用,本次调整已跳过" "INFO"
|
||||
_log "================================================" "INFO"
|
||||
rm -f "$flag_file"
|
||||
return
|
||||
fi
|
||||
fi
|
||||
|
||||
_log "📊 检测亮度变化..." "INFO"
|
||||
_log "[*] 检测亮度变化..." "INFO"
|
||||
# sleep 0.5
|
||||
CHECK_BRI
|
||||
rm -f "$flag_file" # 删除成果锁
|
||||
@@ -191,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..." "WARN"
|
||||
_log "[*] 配置已更新,重启 inotifyd..." "WARN"
|
||||
killall -9 inotifyd 2>/dev/null
|
||||
fi
|
||||
}
|
||||
|
||||
Whitespace-only changes.
@@ -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}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-syLine truncated
|
||||
@@ -1,6 +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`,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`Line truncated
|
||||
`).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);
|
||||
+6
-5
@@ -6,8 +6,8 @@
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no" />
|
||||
<title>LuminPro</title>
|
||||
<link rel="stylesheet" type="text/css" href="/internal/insets.css" />
|
||||
<script type="module" crossorigin src="/assets/index-CUDfuwAt.js"></script>
|
||||
<link rel="stylesheet" crossorigin href="/assets/index-Berty6Q2.css">
|
||||
<script type="module" crossorigin src="/assets/index-BGcJ5yJ_.js"></script>
|
||||
<link rel="stylesheet" crossorigin href="/assets/index-BsOofCBH.css">
|
||||
</head>
|
||||
|
||||
<body>
|
||||
@@ -17,7 +17,8 @@
|
||||
<div class="header-content">
|
||||
<div class="header-text">
|
||||
<h1>LuminPro</h1>
|
||||
<p class="header-subtitle" id="module-version">日用屏幕亮度强化</p>
|
||||
<p class="header-subtitle">日用屏幕亮度强化</p>
|
||||
<p class="header-version" id="module-version">V2.2-2203</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="header-status" id="module-status">
|
||||
@@ -195,7 +196,7 @@
|
||||
<span class="config-desc">修改需重启服务</span>
|
||||
</div>
|
||||
<div class="config-value">
|
||||
<input type="text" id="input-now-bri-file" class="config-input config-input-wide" />
|
||||
<textarea id="input-now-bri-file" class="config-textarea"></textarea>
|
||||
</div>
|
||||
</div>
|
||||
<div class="config-item">
|
||||
@@ -204,7 +205,7 @@
|
||||
<span class="config-desc">修改需重启服务</span>
|
||||
</div>
|
||||
<div class="config-value">
|
||||
<input type="text" id="input-sys-max-bri-file" class="config-input config-input-wide" />
|
||||
<textarea id="input-sys-max-bri-file" class="config-textarea"></textarea>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
+4
-3
@@ -16,7 +16,8 @@
|
||||
<div class="header-content">
|
||||
<div class="header-text">
|
||||
<h1>LuminPro</h1>
|
||||
<p class="header-subtitle" id="module-version">日用屏幕亮度强化</p>
|
||||
<p class="header-subtitle">日用屏幕亮度强化</p>
|
||||
<p class="header-version" id="module-version">V2.2-2203</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="header-status" id="module-status">
|
||||
@@ -194,7 +195,7 @@
|
||||
<span class="config-desc">修改需重启服务</span>
|
||||
</div>
|
||||
<div class="config-value">
|
||||
<input type="text" id="input-now-bri-file" class="config-input config-input-wide" />
|
||||
<textarea id="input-now-bri-file" class="config-textarea"></textarea>
|
||||
</div>
|
||||
</div>
|
||||
<div class="config-item">
|
||||
@@ -203,7 +204,7 @@
|
||||
<span class="config-desc">修改需重启服务</span>
|
||||
</div>
|
||||
<div class="config-value">
|
||||
<input type="text" id="input-sys-max-bri-file" class="config-input config-input-wide" />
|
||||
<textarea id="input-sys-max-bri-file" class="config-textarea"></textarea>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
+39
-19
@@ -332,20 +332,30 @@ async function loadStatus() {
|
||||
|
||||
const statusDot = document.querySelector('.header-status .status-dot');
|
||||
const statusText = document.querySelector('.header-status .status-text');
|
||||
const statusContainer = document.getElementById('module-status');
|
||||
const toggleBtn = document.getElementById('btn-toggle-service');
|
||||
|
||||
if (isPaused) {
|
||||
statusDot.style.backgroundColor = 'var(--md-sys-color-error)';
|
||||
statusDot.style.boxShadow = '0 0 8px rgba(244, 67, 54, 0.5)';
|
||||
statusText.textContent = '已暂停';
|
||||
toggleBtn.textContent = '启用';
|
||||
statusContainer.classList.remove('status-running', 'status-loading');
|
||||
statusContainer.classList.add('status-paused');
|
||||
} else if (running) {
|
||||
statusDot.style.backgroundColor = '#4caf50';
|
||||
statusDot.style.boxShadow = '0 0 8px rgba(76, 175, 80, 0.6)';
|
||||
statusText.textContent = '运行中';
|
||||
toggleBtn.textContent = '暂停';
|
||||
statusContainer.classList.remove('status-paused', 'status-loading');
|
||||
statusContainer.classList.add('status-running');
|
||||
} else {
|
||||
statusDot.style.backgroundColor = 'var(--md-sys-color-error)';
|
||||
statusDot.style.boxShadow = '0 0 8px rgba(244, 67, 54, 0.5)';
|
||||
statusText.textContent = '未运行';
|
||||
toggleBtn.textContent = '暂停';
|
||||
statusContainer.classList.remove('status-running', 'status-paused');
|
||||
statusContainer.classList.add('status-loading');
|
||||
}
|
||||
|
||||
// 填入数值
|
||||
@@ -424,31 +434,24 @@ async function restartService() {
|
||||
}, 1000);
|
||||
}
|
||||
|
||||
let brightnessChangeTimer = null;
|
||||
|
||||
async function handleBrightnessChange(e) {
|
||||
try {
|
||||
const newBri = parseInt(e.target.value, 10);
|
||||
const percentage = Math.round((newBri / 255) * 100);
|
||||
const brightnessSlider = document.getElementById('brightness-slider');
|
||||
const sysMaxBri = parseInt(brightnessSlider.max, 10);
|
||||
const percentage = Math.round((newBri / sysMaxBri) * 100);
|
||||
|
||||
// 立即更新 UI(不等待文件 IO)
|
||||
document.getElementById('brightness-display').textContent = percentage + '%';
|
||||
|
||||
// 清除之前的定时器
|
||||
if (brightnessChangeTimer) {
|
||||
clearTimeout(brightnessChangeTimer);
|
||||
}
|
||||
// 直接写入文件,无防抖
|
||||
const cmd = `echo -n '${newBri}' > '${NOW_BRI_FILE}' 2>/dev/null && echo 'OK'`;
|
||||
const res = await runCmd(cmd);
|
||||
|
||||
// 防抖: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);
|
||||
if (!(res.errno === 0 && res.stdout.includes('OK'))) {
|
||||
showToast('亮度设置失败,已恢复');
|
||||
await loadStatus(); // 恢复旧值
|
||||
}
|
||||
} catch (error) {
|
||||
showToast('设置亮度出错: ' + error.message);
|
||||
await loadStatus();
|
||||
@@ -603,6 +606,7 @@ function setupNavbar() {
|
||||
const navbarBtns = document.querySelectorAll('.navbar-btn');
|
||||
const sections = document.querySelectorAll('.card');
|
||||
const navbarSlider = document.querySelector('.navbar-slider');
|
||||
let sliderFixedWidth = 0; // 固定滑块宽度
|
||||
|
||||
// 更新滑块位置
|
||||
function updateSliderPosition(activeBtn) {
|
||||
@@ -612,10 +616,14 @@ function setupNavbar() {
|
||||
const btnRect = activeBtn.getBoundingClientRect();
|
||||
|
||||
const sliderLeft = btnRect.left - navbarRect.left;
|
||||
const sliderWidth = btnRect.width;
|
||||
|
||||
// 首次设置固定宽度
|
||||
if (sliderFixedWidth === 0) {
|
||||
sliderFixedWidth = btnRect.width;
|
||||
navbarSlider.style.width = sliderFixedWidth + 'px';
|
||||
}
|
||||
|
||||
navbarSlider.style.left = sliderLeft + 'px';
|
||||
navbarSlider.style.width = sliderWidth + 'px';
|
||||
}
|
||||
|
||||
// 根据分组显示卡片
|
||||
@@ -717,6 +725,18 @@ async function init() {
|
||||
}
|
||||
});
|
||||
|
||||
// Textarea 自适应高度
|
||||
document.querySelectorAll('.config-textarea').forEach(textarea => {
|
||||
const autoResize = () => {
|
||||
textarea.style.height = 'auto';
|
||||
textarea.style.height = Math.min(textarea.scrollHeight, 300) + 'px';
|
||||
};
|
||||
textarea.addEventListener('input', autoResize);
|
||||
textarea.addEventListener('change', autoResize);
|
||||
// 初始加载时调整高度
|
||||
setTimeout(autoResize, 0);
|
||||
});
|
||||
|
||||
// 初次加载配置
|
||||
await loadConfig();
|
||||
// 开启自动刷新状态和日志 (内置了已包含 loadStatus 和 loadLogs)
|
||||
|
||||
+124
-30
@@ -70,8 +70,8 @@ body::-webkit-scrollbar {
|
||||
}
|
||||
|
||||
#app {
|
||||
padding: var(--spacing-m);
|
||||
padding-bottom: calc(var(--spacing-m) + 80px);
|
||||
padding: 20px;
|
||||
padding-bottom: calc(20px + 80px);
|
||||
max-width: 600px;
|
||||
margin: 0 auto;
|
||||
display: flex;
|
||||
@@ -84,54 +84,107 @@ body::-webkit-scrollbar {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
padding: var(--spacing-m) 0;
|
||||
padding: 20px 20px;
|
||||
}
|
||||
|
||||
.header-content {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: var(--spacing-m);
|
||||
gap: 16px;
|
||||
flex: 1;
|
||||
}
|
||||
|
||||
.header-icon {
|
||||
font-size: 2rem;
|
||||
background: var(--md-sys-color-surface-container-high);
|
||||
width: 48px;
|
||||
height: 48px;
|
||||
border-radius: 50%;
|
||||
font-size: 2.5rem;
|
||||
background: linear-gradient(135deg, var(--md-sys-color-primary-container), var(--md-sys-color-secondary-container));
|
||||
width: 56px;
|
||||
height: 56px;
|
||||
border-radius: 12px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.12);
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.header-text {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 2px;
|
||||
}
|
||||
|
||||
.header-text h1 {
|
||||
margin: 0;
|
||||
font-size: 1.25rem;
|
||||
font-weight: 500;
|
||||
font-size: 1.5rem;
|
||||
font-weight: 700;
|
||||
color: var(--md-sys-color-on-background);
|
||||
letter-spacing: -0.3px;
|
||||
}
|
||||
|
||||
.header-subtitle {
|
||||
margin: 0;
|
||||
font-size: 0.875rem;
|
||||
font-size: 0.9rem;
|
||||
color: var(--md-sys-color-on-surface-variant);
|
||||
font-weight: 400;
|
||||
}
|
||||
|
||||
.header-version {
|
||||
margin: 0;
|
||||
font-size: 0.75rem;
|
||||
color: var(--md-sys-color-primary);
|
||||
font-weight: 600;
|
||||
letter-spacing: 0.5px;
|
||||
text-transform: uppercase;
|
||||
}
|
||||
|
||||
.header-status {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 6px;
|
||||
background: var(--md-sys-color-surface-container);
|
||||
padding: 4px 12px;
|
||||
border-radius: 100px;
|
||||
gap: 8px;
|
||||
background: var(--md-sys-color-surface-container-high);
|
||||
padding: 8px 16px;
|
||||
border-radius: 12px;
|
||||
font-size: 0.875rem;
|
||||
color: var(--md-sys-color-on-surface);
|
||||
font-weight: 500;
|
||||
box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08);
|
||||
border: 1px solid rgba(var(--md-sys-color-on-surface-rgb, 0, 0, 0), 0.08);
|
||||
}
|
||||
|
||||
.status-dot {
|
||||
width: 8px;
|
||||
height: 8px;
|
||||
width: 10px;
|
||||
height: 10px;
|
||||
border-radius: 50%;
|
||||
background-color: var(--md-sys-color-error); /* 默认离线红色,在线动态改为绿色 #4caf50 */
|
||||
background-color: var(--md-sys-color-error);
|
||||
box-shadow: 0 0 8px rgba(244, 67, 54, 0.5);
|
||||
animation: status-pulse 2s infinite;
|
||||
}
|
||||
|
||||
@keyframes status-pulse {
|
||||
0%, 100% {
|
||||
box-shadow: 0 0 8px rgba(244, 67, 54, 0.5);
|
||||
}
|
||||
50% {
|
||||
box-shadow: 0 0 12px rgba(244, 67, 54, 0.8);
|
||||
}
|
||||
}
|
||||
|
||||
@keyframes status-pulse-green {
|
||||
0%, 100% {
|
||||
box-shadow: 0 0 8px rgba(76, 175, 80, 0.6);
|
||||
}
|
||||
50% {
|
||||
box-shadow: 0 0 12px rgba(76, 175, 80, 0.8);
|
||||
}
|
||||
}
|
||||
|
||||
.header-status.status-running .status-dot {
|
||||
animation: status-pulse-green 2s infinite;
|
||||
}
|
||||
|
||||
.header-status.status-paused .status-dot,
|
||||
.header-status.status-loading .status-dot {
|
||||
animation: status-pulse 2s infinite;
|
||||
}
|
||||
|
||||
/* Cards */
|
||||
@@ -187,6 +240,17 @@ body::-webkit-scrollbar {
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
#advanced-section .config-item {
|
||||
flex-direction: column;
|
||||
align-items: flex-start;
|
||||
gap: 12px;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
#advanced-section .config-value {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.config-item + .config-item {
|
||||
margin-top: var(--spacing-m);
|
||||
}
|
||||
@@ -220,6 +284,33 @@ body::-webkit-scrollbar {
|
||||
transition: border-color 0.2s, box-shadow 0.2s;
|
||||
}
|
||||
|
||||
#advanced-section .config-input {
|
||||
width: 100%;
|
||||
text-align: left;
|
||||
}
|
||||
|
||||
.config-textarea {
|
||||
width: 100%;
|
||||
min-height: 60px;
|
||||
max-height: 300px;
|
||||
padding: 8px 12px;
|
||||
font-family: 'Geist', system-ui, monospace;
|
||||
font-size: 0.875rem;
|
||||
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);
|
||||
resize: vertical;
|
||||
line-height: 1.4;
|
||||
transition: border-color 0.2s, box-shadow 0.2s;
|
||||
}
|
||||
|
||||
.config-textarea:focus {
|
||||
outline: none;
|
||||
border-color: var(--md-sys-color-primary);
|
||||
box-shadow: 0 0 0 2px rgba(168, 199, 250, 0.3);
|
||||
}
|
||||
|
||||
.config-input:focus {
|
||||
border-color: var(--md-sys-color-primary);
|
||||
box-shadow: 0 0 0 2px rgba(168, 199, 250, 0.3);
|
||||
@@ -612,13 +703,14 @@ input:checked + .slider:before {
|
||||
}
|
||||
|
||||
.log-filter-select {
|
||||
padding: 6px 12px;
|
||||
border: 1px solid var(--md-sys-color-outline);
|
||||
padding: 4px 10px;
|
||||
border: 1px solid var(--md-sys-color-outline-variant);
|
||||
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;
|
||||
font-size: 0.75rem;
|
||||
height: 28px;
|
||||
cursor: pointer;
|
||||
transition: border-color 0.2s;
|
||||
}
|
||||
@@ -669,10 +761,10 @@ input:checked + .slider:before {
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
gap: 12px;
|
||||
background-color: var(--md-sys-color-surface-container-high);
|
||||
backdrop-filter: blur(10px);
|
||||
padding: 12px 16px;
|
||||
padding: 12px 20px;
|
||||
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;
|
||||
@@ -683,12 +775,13 @@ input:checked + .slider:before {
|
||||
.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);
|
||||
border-radius: 12px;
|
||||
background-color: rgba(var(--md-sys-color-primary-rgb, 103, 58, 183), 0.2);
|
||||
border: 1px solid rgba(var(--md-sys-color-primary-rgb, 103, 58, 183), 0.3);
|
||||
transition: left 0.35s ease-out, width 0.35s ease-out, background-color 0.35s ease-out, box-shadow 0.35s ease-out;
|
||||
pointer-events: none;
|
||||
z-index: -1;
|
||||
box-shadow: inset 0 2px 4px rgba(var(--md-sys-color-primary-rgb, 103, 58, 183), 0.15), 0 1px 3px rgba(var(--md-sys-color-primary-rgb, 103, 58, 183), 0.1);
|
||||
}
|
||||
|
||||
.navbar-btn {
|
||||
@@ -697,7 +790,7 @@ input:checked + .slider:before {
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
gap: 4px;
|
||||
padding: 8px 16px;
|
||||
padding: 10px 20px;
|
||||
background-color: transparent;
|
||||
border: none;
|
||||
color: var(--md-sys-color-on-surface-variant);
|
||||
@@ -706,7 +799,8 @@ input:checked + .slider:before {
|
||||
border-radius: 8px;
|
||||
transition: all 0.2s ease;
|
||||
flex: 1;
|
||||
max-width: 80px;
|
||||
max-width: 90px;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.navbar-btn i {
|
||||
|
||||
Reference in new issue
Block a user