perf: webui 刷新优化;增加一个 boost 脚本

This commit is contained in:
YuleBest committed 2026-04-06 06:12:42 +08:00
1 parent b1d2a444c8
commit aeda7236ce
8 files changed
+104 -17

No files matched your search

+49
View File
@@ -0,0 +1,49 @@
#!/system/bin/sh
#shellcheck shell=ash
# LuminPro 手动提升/恢复亮度触发脚本
# 解析模块工作目录
MODDIR="$(dirname "$(readlink -f "$0")")"
CONFIG_DIR="$MODDIR/config"
PATH_CONFIG_DIR="$CONFIG_DIR/path"
PID_DIR="$MODDIR/pid"
BOOST_FLAG="$PID_DIR/boost.flag"
# 默认设备路径
DEFAULT_NOW_BRI_FILE="/sys/class/backlight/panel0-backlight/brightness"
# 读取配置的路径,如果不存在则回退至默认值
if [ -f "$PATH_CONFIG_DIR/now_bri_file.txt" ]; then
now_bri_file="$(cat "$PATH_CONFIG_DIR/now_bri_file.txt" 2>/dev/null | tr -d ' \n')"
fi
[ -z "$now_bri_file" ] && now_bri_file="$DEFAULT_NOW_BRI_FILE"
# 确保节点存在
if [ ! -f "$now_bri_file" ]; then
exit 1
fi
if [ -f "$BOOST_FLAG" ]; then
restore_bri="$(cat "$BOOST_FLAG" 2>/dev/null | tr -d ' \n')"
if [ -n "$restore_bri" ]; then
echo -n "$restore_bri" >"$now_bri_file" 2>/dev/null
fi
rm -f "$BOOST_FLAG"
else
max_bri="$(cat "$CONFIG_DIR/max_bri.txt" 2>/dev/null | tr -d ' \n')"
if [ -z "$max_bri" ]; then
exit 1
fi
# 读取当前亮度并存档
now_bri="$(cat "$now_bri_file" 2>/dev/null | tr -d ' \n')"
mkdir -p "$PID_DIR"
echo -n "$now_bri" >"$BOOST_FLAG"
# 执行写入将亮度设定为峰值极限
echo -n "$max_bri" >"$now_bri_file" 2>/dev/null
fi
exit 0
-1
View File
@@ -1,6 +1,5 @@
import fs from 'fs';
import archiver from 'archiver';
import { spawn } from 'child_process';
// 读取版本信息用以命名
const propContent = fs.readFileSync('module.prop', 'utf-8');
+21
View File
@@ -349,6 +349,26 @@ ENSURE_DEFAULTS() {
[ ! -s "$mod_config/log_max_size.txt" ] && echo "500" >"$mod_config/log_max_size.txt"
}
# 机型兼容性校验
CHECK_DEVICE_COMPATIBILITY() {
local model prefix
model="$(getprop ro.product.model)"
prefix="$(echo "$model" | cut -c 1-9)"
if [ "$prefix" = "25128PNA1" ] || [ "$prefix" = "2512BPNDA" ]; then
echo ""
echo "[!] 您可能是 Xiaomi 17 Ultra 用户,建议您使用 '0' 事件作为监测对象,否则模块可能不生效"
echo "[?] 是否将 inotifyd 监测事件修改为 '0'? (按音量 + 确认,按音量 - 跳过)"
if [ "$(button_listener)" = "0" ]; then
echo -n "0" >"$mod_config/inotify_events.txt"
echo "[OK] 已设置为 0 事件监测"
else
echo "[*] 已跳过配置更改"
fi
sleep 1
fi
}
# 创建备份 (用于 WebUI 恢复默认)
CREATE_BACKUP() {
mkdir -p "$mod_config/.backup"
@@ -370,6 +390,7 @@ MAIN() {
TEST_UI_MAX_BRI
fi
ENSURE_DEFAULTS
CHECK_DEVICE_COMPATIBILITY
CREATE_BACKUP
END
}
+1 -1
View File
@@ -1,7 +1,7 @@
id=LuminPro
name=LuminPro丨日用屏幕亮度强化
version=V2.2
versionCode=2203
versionCode=2204
author=酷安@Yule
description=本模块旨在让你的 Android 设备随时可以使用高亮度显示屏幕内容。无论设备当前亮度如何,只要满足设定的前台触发亮度条件,模块便会自动且平滑地提升屏幕亮度至硬件支持的峰值状态,确保你在强光室外也能获得清晰的显示效果
updateJson=https://share.yule.ink/magisk/mod/luminpro/update.json
+2 -2
View File
@@ -1,6 +1,6 @@
{
"versionCode": 2203,
"versionCode": 2204,
"version": "V2.2",
"zipUrl": "https://share.yule.ink/magisk/mod/luminpro/module/LuminPro_V2.2-2203.zip",
"zipUrl": "https://share.yule.ink/magisk/mod/luminpro/module/LuminPro_V2.2-2204.zip",
"changelog": "https://share.yule.ink/magisk/mod/luminpro/changelog.md"
}
+3 -1
View File
@@ -6,7 +6,7 @@
<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-CMU1LKW8.js"></script>
<script type="module" crossorigin src="/assets/index-B_73ZWwP.js"></script>
<link rel="stylesheet" crossorigin href="/assets/index-BsOofCBH.css">
</head>
@@ -32,6 +32,7 @@
<div class="card-header">
<h2>实时状态</h2>
<div class="header-actions">
<button class="btn-text-s" id="btn-refresh-status">刷新</button>
<button class="btn-text-s" id="btn-toggle-service">暂停</button>
<button class="btn-text-s" id="btn-restart-service">重启</button>
</div>
@@ -194,6 +195,7 @@
<div class="config-label">
<span class="config-name">inotifyd 监听事件</span>
<span class="config-desc">默认 c。修改需重启服务</span>
<button class="btn-text-s" id="btn-view-inotifyd-help" style="margin-top: 6px; padding: 2px 6px;">查看支持事件</button>
</div>
<div class="config-value">
<input type="text" id="input-inotify-events" class="config-input" placeholder="c" />
+1
View File
@@ -31,6 +31,7 @@
<div class="card-header">
<h2>实时状态</h2>
<div class="header-actions">
<button class="btn-text-s" id="btn-refresh-status">刷新</button>
<button class="btn-text-s" id="btn-toggle-service">暂停</button>
<button class="btn-text-s" id="btn-restart-service">重启</button>
</div>
+27 -12
View File
@@ -15,6 +15,9 @@ let NOW_BRI_FILE = DEFAULT_NOW_BRI_FILE;
let SYS_MAX_BRI_FILE = DEFAULT_SYS_MAX_BRI_FILE;
let INOTIFY_EVENTS = 'c';
let cachedCurrentBri = null;
let cachedSysMaxBri = null;
// Web UI 配置
let statusLogRefreshInterval = 1000; // 状态/日志刷新间隔(默认1秒)
let configRefreshInterval = 5000; // 配置卡片刷新间隔(默认5秒)
@@ -328,10 +331,17 @@ async function handleReset() {
}
// 3. 刷新实时状态
async function loadStatus() {
const [curRes, sysRes, pidRes, stopRes, autoBriRes] = await Promise.all([
runCmd(`cat "${NOW_BRI_FILE}"`),
runCmd(`cat "${SYS_MAX_BRI_FILE}"`),
async function loadStatus(forceFull = false) {
if (forceFull || cachedCurrentBri === null || cachedSysMaxBri === null) {
const [cRes, sRes] = await Promise.all([
runCmd(`cat "${NOW_BRI_FILE}"`),
runCmd(`cat "${SYS_MAX_BRI_FILE}"`)
]);
if (cRes.errno === 0) cachedCurrentBri = cRes.stdout.trim();
if (sRes.errno === 0) cachedSysMaxBri = sRes.stdout.trim();
}
const [pidRes, stopRes, autoBriRes] = await Promise.all([
runCmd(`cat "${PID_FILE}"`),
runCmd(`[ -f "${STOP_FLAG_FILE}" ] && echo "1" || echo "0"`),
runCmd(`settings get system screen_brightness_mode`)
@@ -369,14 +379,14 @@ async function loadStatus() {
}
// 填入数值
const currentBri = curRes.errno === 0 ? curRes.stdout.trim() : '0';
const currentBri = cachedCurrentBri || '0';
document.getElementById('status-current-bri').textContent = currentBri;
document.getElementById('status-sys-max-bri').textContent = sysRes.errno === 0 ? sysRes.stdout.trim() : '—';
document.getElementById('status-sys-max-bri').textContent = cachedSysMaxBri || '—';
document.getElementById('status-inotifyd-pid').textContent = running ? pidRes.stdout.trim() : '离线';
// 更新亮度滑条
const brightnessSlider = document.getElementById('brightness-slider');
const sysMaxBri = sysRes.errno === 0 ? parseInt(sysRes.stdout.trim(), 10) : 255;
const sysMaxBri = cachedSysMaxBri ? parseInt(cachedSysMaxBri, 10) : 255;
brightnessSlider.max = sysMaxBri;
const currentBriValue = parseInt(currentBri, 10) || 0;
brightnessSlider.value = currentBriValue;
@@ -420,7 +430,7 @@ async function toggleService() {
} else {
showToast('操作失败: ' + res.stderr);
}
await loadStatus();
await loadStatus(true);
}
async function restartService() {
const btn = document.getElementById('btn-restart-service');
@@ -439,7 +449,7 @@ async function restartService() {
// 延迟刷新状态以确保 PID 文件已写入
setTimeout(async () => {
await loadStatus();
await loadStatus(true);
btn.disabled = false;
}, 1000);
}
@@ -453,6 +463,7 @@ async function handleBrightnessChange(e) {
// 立即更新 UI(不等待文件 IO)
document.getElementById('brightness-display').textContent = percentage + '%';
cachedCurrentBri = String(newBri);
// 直接写入文件,无防抖
const cmd = `echo -n '${newBri}' > '${NOW_BRI_FILE}' 2>/dev/null && echo 'OK'`;
@@ -460,11 +471,11 @@ async function handleBrightnessChange(e) {
if (!(res.errno === 0 && res.stdout.includes('OK'))) {
showToast('亮度设置失败,已恢复');
await loadStatus(); // 恢复旧值
await loadStatus(true); // 恢复旧值
}
} catch (error) {
showToast('设置亮度出错: ' + error.message);
await loadStatus();
await loadStatus(true);
}
}
@@ -598,7 +609,7 @@ async function startAutoRefreshConfig() {
async function startAutoRefresh() {
// 立即执行一次状态/日志刷新
await Promise.all([loadStatus(), loadLogs()]);
await Promise.all([loadStatus(true), loadLogs()]);
// 启动定时刷新
autoRefreshStatusLogTimer = setTimeout(startAutoRefreshStatusLog, statusLogRefreshInterval);
@@ -690,6 +701,10 @@ async function init() {
setupNavbar();
// 绑定事件
document.getElementById('btn-refresh-status').addEventListener('click', async () => {
showToast('刷新状态...');
await loadStatus(true);
});
document.getElementById('btn-save').addEventListener('click', saveConfig);
document.getElementById('btn-save-advanced').addEventListener('click', saveAdvancedConfig);
document.getElementById('btn-save-webui-config').addEventListener('click', saveWebUIConfig);