feat: 支持自动亮度休眠;支持自定义调整步数

This commit is contained in:
YuleBest committed 2026-04-05 00:14:39 +08:00
1 parent c048f3e0c3
commit 106110d546
12 files changed
+662 -72

No files matched your search

+42
View File
@@ -134,6 +134,15 @@ IMPORT_OLD_CONFIG() {
if [ -s "$old_config/sleep_time.txt" ]; then
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/关闭/')"
fi
if [ -s "$old_config/steps_num.txt" ]; then
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
echo ""
echo "* 按音量 + 沿用旧配置, 按音量 - 重新测试"
@@ -142,6 +151,22 @@ IMPORT_OLD_CONFIG() {
cp -f "$old_config/ui_max_bri.txt" "$mod_config/"
cp -f "$old_config/max_bri.txt" "$mod_config/"
[ -s "$old_config/sleep_time.txt" ] && cp -f "$old_config/sleep_time.txt" "$mod_config/"
[ -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/"
# 版本迁移逻辑 (针对 2101 及更早版本)
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 版本升级, 正在补全备份目录..."
mkdir -p "$mod_config/.backup"
cp -f "$mod_config/"*.txt "$mod_config/.backup/" 2>/dev/null
else
# 正常备份同步
mkdir -p "$mod_config/.backup"
[ -d "$old_config/.backup" ] && cp -rf "$old_config/.backup/." "$mod_config/.backup/"
fi
return 0
else
echo "- 将重新测试"
@@ -156,7 +181,23 @@ INIT_CONFIG() {
touch "$mod_config/ui_max_bri.txt"
touch "$mod_config/max_bri.txt"
touch "$mod_config/sleep_time.txt"
touch "$mod_config/steps_num.txt"
touch "$mod_config/log_max_size.txt"
echo "1900-0600" >"$mod_config/sleep_time.txt"
echo "1" >"$mod_config/auto_bri_sleep.txt"
echo "50" >"$mod_config/steps_num.txt"
echo "500" >"$mod_config/log_max_size.txt"
}
# 创建备份 (用于 WebUI 恢复默认)
CREATE_BACKUP() {
mkdir -p "$mod_config/.backup"
cp -f "$mod_config/ui_max_bri.txt" "$mod_config/.backup/"
cp -f "$mod_config/max_bri.txt" "$mod_config/.backup/"
cp -f "$mod_config/sleep_time.txt" "$mod_config/.backup/"
cp -f "$mod_config/auto_bri_sleep.txt" "$mod_config/.backup/"
cp -f "$mod_config/steps_num.txt" "$mod_config/.backup/"
cp -f "$mod_config/log_max_size.txt" "$mod_config/.backup/"
}
# 主函数
@@ -166,6 +207,7 @@ MAIN() {
INIT_CONFIG
CHECK_FILES
TEST_UI_MAX_BRI
CREATE_BACKUP
fi
END
}
+87 -22
View File
@@ -33,38 +33,100 @@
<h2>亮度配置</h2>
</div>
<div class="config-item">
<div class="config-label">
<span class="config-name">前台最大亮度</span>
<span class="config-desc">触发亮度提升的阈值</span>
<!-- 分类: 亮度调节 -->
<div class="config-group">
<h3 class="group-title">亮度调节</h3>
<div class="config-item">
<div class="config-label">
<span class="config-name">前台最大亮度</span>
<span class="config-desc">触发亮度提升的阈值</span>
</div>
<div class="config-value">
<input type="number" id="input-ui-max-bri" class="config-input" min="0" />
</div>
</div>
<div class="config-value">
<input type="number" id="input-ui-max-bri" class="config-input" min="0" />
<div class="config-item">
<div class="config-label">
<span class="config-name">峰值最大亮度</span>
<span class="config-desc">亮度提升的目标值</span>
</div>
<div class="config-value">
<input type="number" id="input-max-bri" class="config-input" min="0" />
</div>
</div>
<div class="config-item">
<div class="config-label">
<span class="config-name">亮度提升步数</span>
<span class="config-desc">约 0.02 秒 / 步</span>
</div>
<div class="config-value">
<input type="number" id="input-steps-num" class="config-input" min="1" max="500" />
</div>
</div>
</div>
<div class="config-item">
<div class="config-label">
<span class="config-name">峰值最大亮度</span>
<span class="config-desc">亮度提升的目标值</span>
<!-- 分类: 执行策略 -->
<div class="config-group">
<h3 class="group-title">执行策略</h3>
<div class="config-item">
<div class="config-label">
<span class="config-name">自动亮度时休眠</span>
<span class="config-desc">开启自动亮度时不提升</span>
</div>
<div class="config-value">
<label class="switch">
<input type="checkbox" id="input-auto-bri-sleep">
<span class="slider"></span>
</label>
</div>
</div>
<div class="config-value">
<input type="number" id="input-max-bri" class="config-input" min="0" />
<div class="config-item">
<div class="config-label">
<span class="config-name">定时休眠</span>
<span class="config-desc">设定时段内不提升亮度</span>
</div>
<div class="config-value">
<label class="switch">
<input type="checkbox" id="input-sleep-mode">
<span class="slider"></span>
</label>
</div>
</div>
<div class="config-item-expand" id="sleep-time-expand">
<div class="custom-time-picker">
<div class="time-unit">
<input type="number" id="input-sleep-start-h" class="time-input" min="0" max="23" placeholder="00" />
<span>:</span>
<input type="number" id="input-sleep-start-m" class="time-input" min="0" max="59" placeholder="00" />
</div>
<span class="time-sep">至</span>
<div class="time-unit">
<input type="number" id="input-sleep-end-h" class="time-input" min="0" max="23" placeholder="00" />
<span>:</span>
<input type="number" id="input-sleep-end-m" class="time-input" min="0" max="59" placeholder="00" />
</div>
</div>
</div>
</div>
<div class="config-item">
<div class="config-label">
<span class="config-name">休眠时间</span>
<span class="config-desc">该时段内不提升亮度</span>
</div>
<div class="config-value">
<input type="text" id="input-sleep-time" class="config-input config-input-wide"
placeholder="如 1900-0600" />
<!-- 分类: 系统管理 -->
<div class="config-group">
<h3 class="group-title">系统管理</h3>
<div class="config-item">
<div class="config-label">
<span class="config-name">日志大小限制</span>
<span class="config-desc">单位: KB</span>
</div>
<div class="config-value">
<input type="number" id="input-log-max-size" class="config-input" min="1" max="10240" />
</div>
</div>
</div>
<div class="card-actions">
<button class="btn btn-outline" id="btn-reset">
恢复默认
</button>
<button class="btn btn-primary" id="btn-save">
<span class="btn-icon"><i data-lucide="save"></i></span> 保存配置
</button>
@@ -76,7 +138,10 @@
<div class="card-header">
<span class="card-icon"><i data-lucide="activity"></i></span>
<h2>实时状态</h2>
<button class="btn-icon-only" id="btn-refresh-status" title="刷新"><i data-lucide="refresh-cw"></i></button>
<div class="header-actions">
<button class="btn-text-s" id="btn-restart-service">重启</button>
<button class="btn-text-s" id="btn-refresh-status">刷新</button>
</div>
</div>
<div class="status-grid">
@@ -104,7 +169,7 @@
<div class="card-header">
<span class="card-icon"><i data-lucide="file-text"></i></span>
<h2>运行日志</h2>
<button class="btn-icon-only" id="btn-refresh-log" title="刷新"><i data-lucide="refresh-cw"></i></button>
<button class="btn-text-s" id="btn-refresh-log">刷新</button>
</div>
<pre class="log-output" id="log-output">加载中...</pre>
</section>
+2 -2
View File
@@ -1,6 +1,6 @@
id=LuminPro
name=LuminPro丨日用屏幕亮度强化
version=V2.1
versionCode=2101
version=V2.2
versionCode=2201
author=酷安@Yule
description=本模块旨在让你的 Android 设备随时可以使用高亮度显示屏幕内容。无论设备当前亮度如何,只要满足设定的前台触发亮度条件,模块便会自动且平滑地提升屏幕亮度至硬件支持的峰值状态,确保你在强光室外也能获得清晰的显示效果
+34
View File
@@ -0,0 +1,34 @@
#!/system/bin/sh
# LuminPro 服务重启脚本
MODDIR="${0%/*/*}"
PID_DIR="$MODDIR/pid"
pid_file="$PID_DIR/inotifyd.pid"
flag_file="$PID_DIR/up.flag"
now_bri_file="/sys/class/backlight/panel0-backlight/brightness"
log_file="$MODDIR/service.log"
_log() {
printf '[%s] [service.restart] %s\n' "$(date '+%d %H:%M:%S.%3N')" "$1" >>"$log_file"
}
_log "正在手动重启服务..."
# 1. 杀死正在进行的 inotifyd
if [ -f "$pid_file" ]; then
kill -9 "$(cat "$pid_file")" 2>/dev/null
_log "已杀死现有 inotifyd ($(cat "$pid_file"))"
fi
# 2. 清理遗留文件
rm -f "$pid_file"
rm -f "$flag_file"
_log "已清理 pid 和 flag 文件"
# 3. 重新启动 inotifyd
inotifyd "$MODDIR/script/up.sh" "$now_bri_file:c" &
inotifyd_pid="$!"
echo "$inotifyd_pid" >"$pid_file"
_log "inotifyd ($inotifyd_pid) 重新启动成功"
exit 0
+37 -2
View File
@@ -11,6 +11,19 @@ log_file="$MODDIR/service.log"
# 日志函数
_log() {
local max_size
max_size="$(cat "$CONFIG_DIR/log_max_size.txt" 2>/dev/null)"
[ -z "$max_size" ] && max_size="500" # 默认 500 KB
# 获取当前日志大小 (KB)
if [ -f "$log_file" ]; then
local cur_size
cur_size=$(du -k "$log_file" | cut -f1)
if [ "$cur_size" -ge "$max_size" ]; then
echo "[$(date '+%d %H:%M:%S.%3N')] [service.up] 日志过大 ($cur_size KB), 自动重置" >"$log_file"
fi
fi
printf '[%s] [service.up] %s\n' "$(date '+%d %H:%M:%S.%3N')" "$1" >>"$log_file"
}
@@ -30,6 +43,7 @@ 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")"
sleep_time="$(cat "$CONFIG_DIR/sleep_time.txt" 2>/dev/null)"
auto_bri_sleep="$(cat "$CONFIG_DIR/auto_bri_sleep.txt" 2>/dev/null)"
# 解析休眠时间 (格式: HHMM-HHMM, 例如 1900-0600)
sleep_start="${sleep_time%-*}" # 1900
@@ -56,7 +70,8 @@ IS_SLEEP_TIME() {
# 目标亮度
target_bri="$max_bri"
steps_num="50" # 步数
steps_num="$(cat "$CONFIG_DIR/steps_num.txt" 2>/dev/null)"
[ -z "$steps_num" ] && steps_num="50" # 步数 (默认 50)
# 循环调整
update_all() {
@@ -111,6 +126,18 @@ CHECK_BRI() {
return 2
}
# 判断是否开启了自动亮度且需要休眠
IS_AUTO_BRI_SLEEP() {
if [ "$auto_bri_sleep" = "1" ]; then
local mode
mode="$(settings get system screen_brightness_mode 2>/dev/null)"
if [ "$mode" = "1" ]; then
return 0 # 需要休眠
fi
fi
return 1 # 不需要休眠
}
MAIN() {
# 休眠时段内不调整亮度
if IS_SLEEP_TIME; then
@@ -121,10 +148,18 @@ MAIN() {
return
fi
if IS_AUTO_BRI_SLEEP; then
_log "($$) 当前为自动亮度模式, 根据设置跳过本次调整"
_log "--------------------"
sleep 1
rm -f "$flag_file"
return
fi
_log "($$) 亮度被调整, 将在 0.5s 后检测是否符合条件"
sleep 0.5
CHECK_BRI
sleep 0.5 # 稍微延迟一会避免 inotifyd 刚启动就检测到亮度变化
sleep 0.5 # 稍微延迟一会避免 inotifyd 刚启动就检测到亮度变化
rm -f "$flag_file" # 删除 flag, 允许下一次调整
}
+195 -16
View File
@@ -2,6 +2,7 @@ import { exec } from 'kernelsu';
import { createIcons, Sun, Settings, Save, Activity, RefreshCw, FileText } from 'lucide';
const CONFIG_DIR = '/data/adb/modules/LuminPro/config';
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 LOG_FILE = '/data/adb/modules/LuminPro/service.log';
@@ -41,22 +42,81 @@ async function writeFile(path, content) {
// 1. 加载配置
async function loadConfig() {
const [uiRes, maxRes, sleepRes] = await Promise.all([
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"`),
runCmd(`cat "${CONFIG_DIR}/sleep_time.txt"`)
runCmd(`cat "${CONFIG_DIR}/sleep_time.txt"`),
runCmd(`cat "${CONFIG_DIR}/auto_bri_sleep.txt"`),
runCmd(`cat "${CONFIG_DIR}/steps_num.txt"`),
runCmd(`cat "${CONFIG_DIR}/log_max_size.txt"`)
]);
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();
if (sleepRes.errno === 0) document.getElementById('input-sleep-time').value = sleepRes.stdout.trim();
if (sleepRes.errno === 0) {
const timeVal = sleepRes.stdout.trim();
const modeSwitch = document.getElementById('input-sleep-mode');
const expandArea = document.getElementById('sleep-time-expand');
if(timeVal && timeVal.includes('-')) {
modeSwitch.checked = true;
expandArea.classList.add('show');
const [start, end] = timeVal.split('-');
if(start.length === 4) {
document.getElementById('input-sleep-start-h').value = start.slice(0, 2);
document.getElementById('input-sleep-start-m').value = start.slice(2);
}
if(end.length === 4) {
document.getElementById('input-sleep-end-h').value = end.slice(0, 2);
document.getElementById('input-sleep-end-m').value = end.slice(2);
}
} else {
modeSwitch.checked = false;
expandArea.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 (autoRes.errno === 0) document.getElementById('input-auto-bri-sleep').checked = autoRes.stdout.trim() === '1';
if (stepsRes.errno === 0) {
const v = stepsRes.stdout.trim();
document.getElementById('input-steps-num').value = v ? v : '50';
} else {
document.getElementById('input-steps-num').value = '50';
}
if (logSizeRes.errno === 0) {
const v = logSizeRes.stdout.trim();
document.getElementById('input-log-max-size').value = v ? v : '500';
} else {
document.getElementById('input-log-max-size').value = '500';
}
}
// 2. 保存配置并重启服务
async function saveConfig() {
const uiMax = document.getElementById('input-ui-max-bri').value;
const maxBri = document.getElementById('input-max-bri').value;
const sleepTime = document.getElementById('input-sleep-time').value;
const pad = (v) => String(v).padStart(2, '0');
const sleepMode = document.getElementById('input-sleep-mode').checked;
let sleepTime = "";
if (sleepMode) {
const sH = pad(document.getElementById('input-sleep-start-h').value);
const sM = pad(document.getElementById('input-sleep-start-m').value);
const eH = pad(document.getElementById('input-sleep-end-h').value);
const eM = pad(document.getElementById('input-sleep-end-m').value);
sleepTime = `${sH}${sM}-${eH}${eM}`;
}
const autoBriSleep = document.getElementById('input-auto-bri-sleep').checked ? '1' : '0';
const stepsNum = document.getElementById('input-steps-num').value || '50';
const logMaxSize = document.getElementById('input-log-max-size').value || '500';
if (!uiMax || !maxBri) {
showToast('亮度值不能为空');
@@ -69,6 +129,9 @@ async function saveConfig() {
await writeFile(`${CONFIG_DIR}/ui_max_bri.txt`, uiMax);
await writeFile(`${CONFIG_DIR}/max_bri.txt`, maxBri);
await writeFile(`${CONFIG_DIR}/sleep_time.txt`, sleepTime);
await writeFile(`${CONFIG_DIR}/auto_bri_sleep.txt`, autoBriSleep);
await writeFile(`${CONFIG_DIR}/steps_num.txt`, stepsNum);
await writeFile(`${CONFIG_DIR}/log_max_size.txt`, logMaxSize);
// 通过写亮度节点一个无变化的值,强制触发 inotifyd 执行 up.sh 以重新读取配置
// 注意:需要先清除 flag 以防 up.sh 挂起
@@ -85,6 +148,85 @@ async function saveConfig() {
}
}
// 2.5 恢复默认
let isResetConfirming = false;
let resetTimer = null;
function resetRestoreButton() {
const btn = document.getElementById('btn-reset');
btn.textContent = '恢复默认';
btn.classList.remove('btn-danger');
isResetConfirming = false;
if(resetTimer) clearTimeout(resetTimer);
}
async function handleReset() {
const btn = document.getElementById('btn-reset');
if (!isResetConfirming) {
// 进入确认状态
isResetConfirming = true;
btn.textContent = '确认';
btn.classList.add('btn-danger');
// 5秒后自动重置回原来状态
resetTimer = setTimeout(resetRestoreButton, 5000);
return;
}
// 执行恢复动作
showToast('正在恢复默认配置...');
resetRestoreButton();
// 读取备份 (或者回退到默认逻辑)
const [uiRes, maxRes, sleepRes, autoRes, stepsRes, logSizeRes] = await Promise.all([
runCmd(`cat "${BACKUP_DIR}/ui_max_bri.txt"`),
runCmd(`cat "${BACKUP_DIR}/max_bri.txt"`),
runCmd(`cat "${BACKUP_DIR}/sleep_time.txt"`),
runCmd(`cat "${BACKUP_DIR}/auto_bri_sleep.txt"`),
runCmd(`cat "${BACKUP_DIR}/steps_num.txt"`),
runCmd(`cat "${BACKUP_DIR}/log_max_size.txt"`)
]);
// 填入值
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();
if (sleepRes.errno === 0) {
const tV = sleepRes.stdout.trim();
const modeSwitch = document.getElementById('input-sleep-mode');
const expandArea = document.getElementById('sleep-time-expand');
if(tV.includes('-')) {
modeSwitch.checked = true;
expandArea.classList.add('show');
const [s, e] = tV.split('-');
if(s.length === 4) {
document.getElementById('input-sleep-start-h').value = s.slice(0, 2);
document.getElementById('input-sleep-start-m').value = s.slice(2);
}
if(e.length === 4) {
document.getElementById('input-sleep-end-h').value = e.slice(0, 2);
document.getElementById('input-sleep-end-m').value = e.slice(2);
}
}
} else {
document.getElementById('input-sleep-mode').checked = true;
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 = (autoRes.errno === 0) ? (autoRes.stdout.trim() === '1') : true;
document.getElementById('input-steps-num').value = (stepsRes.errno === 0) ? stepsRes.stdout.trim() : '50';
document.getElementById('input-log-max-size').value = (logSizeRes.errno === 0) ? logSizeRes.stdout.trim() : '500';
// 直接触发保存
await saveConfig();
}
// 3. 刷新实时状态
async function loadStatus() {
const [curRes, sysRes, pidRes] = await Promise.all([
@@ -112,24 +254,49 @@ async function loadStatus() {
}
// 简易判断当前休眠状态 (只为了前端展示,不影响后端核心)
const sleepInput = document.getElementById('input-sleep-time').value;
const isEnabled = document.getElementById('input-sleep-mode').checked;
const sH = document.getElementById('input-sleep-start-h').value;
const sM = document.getElementById('input-sleep-start-m').value;
const eH = document.getElementById('input-sleep-end-h').value;
const eM = document.getElementById('input-sleep-end-m').value;
let isSleep = false;
if(sleepInput && sleepInput.includes('-')) {
const [start, end] = sleepInput.split('-');
const d = new Date();
const now = d.getHours() * 100 + d.getMinutes();
const s = parseInt(start, 10);
const e = parseInt(end, 10);
if (s > e) {
if(now >= s || now < e) isSleep = true;
} else if (s < e) {
if(now >= s && now < e) isSleep = true;
if(isEnabled && sH && sM && eH && eM) {
const now = new Date();
const nV = now.getHours() * 100 + now.getMinutes();
const sNum = parseInt(sH, 10) * 100 + parseInt(sM, 10);
const eNum = parseInt(eH, 10) * 100 + parseInt(eM, 10);
if (sNum > eNum) {
if(nV >= sNum || nV < eNum) isSleep = true;
} else if (sNum < eNum) {
if(nV >= sNum && nV < eNum) isSleep = true;
}
}
document.getElementById('status-sleep').textContent = isSleep ? '休眠中' : '非休眠';
}
// 4. 加载日志
// 5. 重启服务
async function restartService() {
const btn = document.getElementById('btn-restart-service');
showToast('正在重启服务...');
btn.disabled = true;
// 执行重启脚本
const res = await runCmd(`sh /data/adb/modules/LuminPro/script/restart.sh`);
if (res.errno === 0) {
showToast('服务已成功重启');
} else {
showToast('重启失败: ' + res.stderr);
}
// 延迟刷新状态以确保 PID 文件已写入
setTimeout(async () => {
await loadStatus();
btn.disabled = false;
}, 1000);
}
async function loadLogs() {
const logEl = document.getElementById('log-output');
// 读取最后 50 行日志
@@ -162,9 +329,21 @@ async function init() {
// 绑定事件
document.getElementById('btn-save').addEventListener('click', saveConfig);
document.getElementById('btn-reset').addEventListener('click', handleReset);
document.getElementById('btn-restart-service').addEventListener('click', restartService);
document.getElementById('btn-refresh-status').addEventListener('click', loadStatus);
document.getElementById('btn-refresh-log').addEventListener('click', loadLogs);
// 定时休眠折叠逻辑
document.getElementById('input-sleep-mode').addEventListener('change', (e) => {
const expandArea = document.getElementById('sleep-time-expand');
if (e.target.checked) {
expandArea.classList.add('show');
} else {
expandArea.classList.remove('show');
}
});
// 初次加载数据
await loadConfig();
await loadStatus();
+171 -1
View File
@@ -141,6 +141,22 @@ body {
}
/* Config Items */
.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;
font-size: 0.875rem;
font-weight: 600;
color: var(--md-sys-color-primary);
text-transform: uppercase;
letter-spacing: 0.5px;
}
.config-item {
display: flex;
justify-content: space-between;
@@ -149,7 +165,6 @@ body {
.config-item + .config-item {
margin-top: var(--spacing-m);
padding-top: var(--spacing-m);
}
.config-label {
@@ -190,6 +205,111 @@ body {
width: 140px;
}
.config-item-expand {
display: flex;
justify-content: flex-end;
margin-top: var(--spacing-s);
max-height: 0;
overflow: hidden;
opacity: 0;
transition: all 0.3s ease;
}
.config-item-expand.show {
max-height: 100px; /* 调整为适合内容的高度 */
opacity: 1;
margin-bottom: var(--spacing-m);
}
/* Custom Time Picker Styles */
.custom-time-picker {
display: flex;
align-items: center;
gap: 12px;
}
.time-unit {
display: flex;
align-items: center;
gap: 4px;
background-color: var(--md-sys-color-surface-container-high);
padding: 4px 8px;
border-radius: var(--border-radius-s);
border: 1px solid var(--md-sys-color-outline);
}
.time-input {
width: 42px;
background-color: transparent;
color: var(--md-sys-color-on-surface);
border: none;
font-size: 1rem;
text-align: center;
font-family: 'Google Sans Code', monospace;
outline: none;
-moz-appearance: textfield;
}
.time-input::-webkit-outer-spin-button,
.time-input::-webkit-inner-spin-button {
-webkit-appearance: none;
margin: 0;
}
.time-sep {
color: var(--md-sys-color-on-surface-variant);
font-size: 0.875rem;
}
/* Switch Styles */
.switch {
position: relative;
display: inline-block;
width: 52px;
height: 32px;
}
.switch input {
opacity: 0;
width: 0;
height: 0;
}
.slider {
position: absolute;
cursor: pointer;
top: 0;
left: 0;
right: 0;
bottom: 0;
background-color: var(--md-sys-color-surface-container-high);
transition: .4s;
border-radius: 34px;
border: 2px solid var(--md-sys-color-outline);
}
.slider:before {
position: absolute;
content: "";
height: 24px;
width: 24px;
left: 2px;
bottom: 2px;
background-color: var(--md-sys-color-outline);
transition: .4s;
border-radius: 50%;
}
input:checked + .slider {
background-color: var(--md-sys-color-primary-container);
border-color: var(--md-sys-color-primary);
}
input:checked + .slider:before {
transform: translateX(20px);
background-color: var(--md-sys-color-primary);
}
/* Status Grid */
.status-grid {
display: grid;
@@ -222,6 +342,7 @@ body {
.card-actions {
display: flex;
justify-content: flex-end;
gap: 12px;
margin-top: var(--spacing-l);
padding-top: var(--spacing-m);
border-top: 1px solid var(--md-sys-color-outline-variant);
@@ -252,6 +373,46 @@ body {
color: var(--md-sys-color-on-primary);
}
.btn-outline {
background-color: transparent;
border: 1px solid var(--md-sys-color-outline);
color: var(--md-sys-color-primary);
}
.btn-outline-s, .btn-text-s {
background-color: transparent;
border: 1px solid var(--md-sys-color-outline-variant);
color: var(--md-sys-color-primary);
padding: 4px 10px;
min-width: 50px;
height: 28px;
font-size: 0.75rem;
border-radius: var(--border-radius-s);
cursor: pointer;
display: inline-flex;
align-items: center;
justify-content: center;
transition: all 0.2s;
white-space: nowrap;
}
.btn-text-s:active {
background-color: var(--md-sys-color-surface-container-high);
}
.btn-danger {
background-color: var(--md-sys-color-error) !important;
color: var(--md-sys-color-on-error) !important;
border: none !important;
}
/* Header Actions container */
.header-actions {
display: flex;
align-items: center;
gap: 8px;
}
.btn-icon-only {
background: transparent;
border: none;
@@ -269,6 +430,15 @@ body {
background-color: var(--md-sys-color-surface-container-high);
}
.animate-spin {
animation: spin 1s linear infinite;
}
@keyframes spin {
from { transform: rotate(0deg); }
to { transform: rotate(360deg); }
}
/* Logs */
.log-output {
font-family: 'Google Sans Code', 'Consolas', 'Courier New', monospace;
-1
View File
@@ -1 +0,0 @@
:root{--md-sys-color-background:#111318;--md-sys-color-on-background:#e2e2e9;--md-sys-color-surface:#1e1f25;--md-sys-color-surface-container:#212429;--md-sys-color-surface-container-high:#2b2930;--md-sys-color-on-surface:#e2e2e9;--md-sys-color-on-surface-variant:#c4c6d0;--md-sys-color-primary:#a8c7fa;--md-sys-color-on-primary:#062e6f;--md-sys-color-primary-container:#1b4b9b;--md-sys-color-on-primary-container:#d3e3fd;--md-sys-color-outline:#8e9099;--md-sys-color-outline-variant:#44474f;--md-sys-color-error:#ffb4ab;--md-sys-color-on-error:#690005;--border-radius-m:16px;--border-radius-s:8px;--spacing-s:8px;--spacing-m:16px;--spacing-l:24px}@font-face{font-family:Geist;src:url(/Geist-VariableFont_wght.ttf)format("truetype");font-weight:100 900;font-style:normal}@font-face{font-family:Google Sans Code;src:url(/GoogleSansCode-VariableFont_wght.ttf)format("truetype");font-weight:100 900;font-style:normal}*{box-sizing:border-box;-webkit-tap-highlight-color:transparent}body{padding:0;padding-top:var(--safe-area-inset-top,0);padding-bottom:var(--safe-area-inset-bottom,0);background-color:var(--md-sys-color-background);color:var(--md-sys-color-on-background);margin:0;font-family:Geist,system-ui,-apple-system,sans-serif;line-height:1.5}#app{padding:var(--spacing-m);gap:var(--spacing-m);flex-direction:column;max-width:600px;margin:0 auto;display:flex}.app-header{padding:var(--spacing-m) 0;justify-content:space-between;align-items:center;display:flex}.header-content{align-items:center;gap:var(--spacing-m);display:flex}.header-icon{background:var(--md-sys-color-surface-container-high);border-radius:50%;justify-content:center;align-items:center;width:48px;height:48px;font-size:2rem;display:flex}.header-text h1{color:var(--md-sys-color-on-background);margin:0;font-size:1.25rem;font-weight:500}.header-subtitle{color:var(--md-sys-color-on-surface-variant);margin:0;font-size:.875rem}.header-status{background:var(--md-sys-color-surface-container);border-radius:100px;align-items:center;gap:6px;padding:4px 12px;font-size:.875rem;display:flex}.status-dot{background-color:var(--md-sys-color-error);border-radius:50%;width:8px;height:8px}.card{background-color:var(--md-sys-color-surface);border-radius:var(--border-radius-m);padding:var(--spacing-l);box-shadow:0 1px 3px #0000004d,0 4px 8px 3px #00000026}.card-header{align-items:center;gap:var(--spacing-s);margin-bottom:var(--spacing-l);display:flex}.card-header h2{color:var(--md-sys-color-on-surface);flex-grow:1;margin:0;font-size:1.125rem;font-weight:500}.config-item{justify-content:space-between;align-items:center;display:flex}.config-item+.config-item{margin-top:var(--spacing-m);padding-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}.status-grid{gap:var(--spacing-m);grid-template-columns:1fr 1fr;display:grid}.status-item{background-color:var(--md-sys-color-surface-container);padding:var(--spacing-m);border-radius:var(--border-radius-s);flex-direction:column;display:flex}.status-label{color:var(--md-sys-color-on-surface-variant);margin-bottom:4px;font-size:.75rem}.status-value{color:var(--md-sys-color-primary);word-break:break-all;font-size:1.125rem;font-weight:500}.card-actions{margin-top:var(--spacing-l);padding-top:var(--spacing-m);border-top:1px solid var(--md-sys-color-outline-variant);justify-content:flex-end;display:flex}.btn{cursor:pointer;border:none;border-radius:100px;justify-content:center;align-items:center;gap:8px;padding:10px 24px;font-family:inherit;font-size:.875rem;font-weight:500;transition:background-color .2s,opacity .2s;display:inline-flex}.btn:active{opacity:.8}.btn-primary{background-color:var(--md-sys-color-primary);color:var(--md-sys-color-on-primary)}.btn-icon-only{color:var(--md-sys-color-on-surface-variant);cursor:pointer;background:0 0;border:none;border-radius:50%;justify-content:center;align-items:center;padding:4px;font-size:1.25rem;display:flex}.btn-icon-only:active{background-color:var(--md-sys-color-surface-container-high)}.log-output{padding:var(--spacing-s);border-radius:var(--border-radius-s);white-space:pre-wrap;word-wrap:break-word;height:200px;margin:0;font-family:Google Sans Code,Consolas,Courier New,monospace;font-size:.75rem;overflow-y:auto}.toast{background-color:var(--md-sys-color-on-surface);color:var(--md-sys-color-surface);border-radius:var(--border-radius-s);z-index:1000;text-align:center;width:max-content;max-width:90vw;padLine truncated
+1
View File
@@ -0,0 +1 @@
:root{--md-sys-color-background:#111318;--md-sys-color-on-background:#e2e2e9;--md-sys-color-surface:#1e1f25;--md-sys-color-surface-container:#212429;--md-sys-color-surface-container-high:#2b2930;--md-sys-color-on-surface:#e2e2e9;--md-sys-color-on-surface-variant:#c4c6d0;--md-sys-color-primary:#a8c7fa;--md-sys-color-on-primary:#062e6f;--md-sys-color-primary-container:#1b4b9b;--md-sys-color-on-primary-container:#d3e3fd;--md-sys-color-outline:#8e9099;--md-sys-color-outline-variant:#44474f;--md-sys-color-error:#ffb4ab;--md-sys-color-on-error:#690005;--border-radius-m:16px;--border-radius-s:8px;--spacing-s:8px;--spacing-m:16px;--spacing-l:24px}@font-face{font-family:Geist;src:url(/Geist-VariableFont_wght.ttf)format("truetype");font-weight:100 900;font-style:normal}@font-face{font-family:Google Sans Code;src:url(/GoogleSansCode-VariableFont_wght.ttf)format("truetype");font-weight:100 900;font-style:normal}*{box-sizing:border-box;-webkit-tap-highlight-color:transparent}body{padding:0;padding-top:var(--safe-area-inset-top,0);padding-bottom:var(--safe-area-inset-bottom,0);background-color:var(--md-sys-color-background);color:var(--md-sys-color-on-background);margin:0;font-family:Geist,system-ui,-apple-system,sans-serif;line-height:1.5}#app{padding:var(--spacing-m);gap:var(--spacing-m);flex-direction:column;max-width:600px;margin:0 auto;display:flex}.app-header{padding:var(--spacing-m) 0;justify-content:space-between;align-items:center;display:flex}.header-content{align-items:center;gap:var(--spacing-m);display:flex}.header-icon{background:var(--md-sys-color-surface-container-high);border-radius:50%;justify-content:center;align-items:center;width:48px;height:48px;font-size:2rem;display:flex}.header-text h1{color:var(--md-sys-color-on-background);margin:0;font-size:1.25rem;font-weight:500}.header-subtitle{color:var(--md-sys-color-on-surface-variant);margin:0;font-size:.875rem}.header-status{background:var(--md-sys-color-surface-container);border-radius:100px;align-items:center;gap:6px;padding:4px 12px;font-size:.875rem;display:flex}.status-dot{background-color:var(--md-sys-color-error);border-radius:50%;width:8px;height:8px}.card{background-color:var(--md-sys-color-surface);border-radius:var(--border-radius-m);padding:var(--spacing-l);box-shadow:0 1px 3px #0000004d,0 4px 8px 3px #00000026}.card-header{align-items:center;gap:var(--spacing-s);margin-bottom:var(--spacing-l);display:flex}.card-header h2{color:var(--md-sys-color-on-surface);flex-grow:1;margin:0;font-size:1.125rem;font-weight:500}.config-group{margin-bottom:var(--spacing-l);padding:var(--spacing-m);background-color:var(--md-sys-color-surface-container);border-radius:var(--border-radius-s)}.group-title{margin:0 0 var(--spacing-m) 0;color:var(--md-sys-color-primary);text-transform:uppercase;letter-spacing:.5px;font-size:.875rem;font-weight:600}.config-item{justify-content:space-between;align-items:center;display:flex}.config-item+.config-item{margin-top:var(--spacing-m)}.config-label{flex-direction:column;display:flex}.config-name{color:var(--md-sys-color-on-surface);font-size:1rem}.config-desc{color:var(--md-sys-color-on-surface-variant);font-size:.875rem}.config-input{background-color:var(--md-sys-color-surface-container-high);color:var(--md-sys-color-on-surface);border:1px solid var(--md-sys-color-outline);border-radius:var(--border-radius-s);text-align:right;outline:none;width:100px;padding:8px 12px;font-family:inherit;font-size:1rem;transition:border-color .2s,box-shadow .2s}.config-input:focus{border-color:var(--md-sys-color-primary);box-shadow:0 0 0 2px #a8c7fa4d}.config-input-wide{width:140px}.config-item-expand{margin-top:var(--spacing-s);opacity:0;justify-content:flex-end;max-height:0;transition:all .3s;display:flex;overflow:hidden}.config-item-expand.show{opacity:1;max-height:100px;margin-bottom:var(--spacing-m)}.custom-time-picker{align-items:center;gap:12px;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:4px;padding:4px 8px;display:flex}.time-input{width:42px;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:1rem}.time-input::-webkit-outer-spin-button{-webkit-appearance:none;margin:0}.time-input::-webkit-inner-spin-button{-webkit-appearance:none;margin:0}.time-sep{color:var(--md-sys-color-on-surface-variant);font-size:.875rem}.switch{width:52px;height:32px;display:inline-block;position:relative}.switch input{opacity:0;width:0;height:0}.slider{cursor:pointer;background-color:var(--md-sys-color-surface-container-high);border:2px solid var(--md-sys-color-outline);border-radius:34px;transition:all .4s;position:absolute;inset:0}.slider:before{content:"";background-color:var(--md-sys-color-outline);border-radius:50%;width:24px;height:24px;transition:all .4s;position:absolute;bottom:2px;lLine truncated
+4
View File
@@ -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/.backup`,w=`/data/adb/modules/LuminPro/pid/inotifyd.pid`,T=`/data/adb/modules/LuminPro/pid/up.flag`,E=`/data/adb/modules/LuminPro/service.log`,D=`/sys/class/backlight/panel0-backlight/brightness`,O=`/sys/class/backlight/panel0-backlight/max_brightness`;function k(e){let t=document.getElementById(`toast`);t.textContent=e,t.classList.add(`show`),setTimeout(()=>t.classList.remove(`show`),3e3)}async function A(e){try{return await n(e)}catch(e){return console.error(e),{errno:-1,stdout:``,stderr:String(e)}}}async function j(e,t){return A(`echo -n '${String(t).replace(/'/g,`'\\''`)}' > "${e}"`)}async function M(){let[e,t,n,r,i,a]=await Promise.all([A(`cat "${S}/ui_max_bri.txt"`),A(`cat "${S}/max_bri.txt"`),A(`cat "${S}/sleep_time.txt"`),A(`cat "${S}/auto_bri_sleep.txt"`),A(`cat "${S}/steps_num.txt"`),A(`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 N(){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){k(`亮度值不能为空`);return}k(`保存中...`),await j(`${S}/ui_max_bri.txt`,e),await j(`${S}/max_bri.txt`,t),await j(`${S}/sleep_time.txt`,i),await j(`${S}/auto_bri_sleep.txt`,a),await j(`${S}/steps_num.txt`,o),await j(`${S}/log_max_size.txt`,s),await A(`rm -f "${T}"`);let c=await A(`cat "${w}"`);c.errno===0&&c.stdout.trim()?k(`配置已保存 (可能需要在下次调整时生效)`):k(`配置已保存 (服务未运行)`)}var P=!1,F=null;function I(){let e=document.getElementById(`btn-reset`);e.textContent=`恢复默认`,e.classList.remove(`btn-danger`),P=!1,F&&clearTimeout(F)}async function L(){let e=document.getElementById(`btn-reset`);if(!P){P=!0,e.textContent=`确认`,e.classList.add(`btn-danger`),F=setTimeout(I,5e3);return}k(`正在恢复默认配置...`),I();let[t,n,r,i,a,o]=await Promise.all([A(`cat "${C}/ui_max_bri.txt"`),A(`cat "${C}/max_bri.txt"`),A(`cat "${C}/sleep_time.txt"`),A(`cat "${C}/auto_bri_sleep.txt"`),A(`cat "${C}/steps_num.txt"`),A(`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&&(docLine truncated
-4
View File
@@ -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/pid/inotifyd.pid`,w=`/data/adb/modules/LuminPro/pid/up.flag`,T=`/data/adb/modules/LuminPro/service.log`,E=`/sys/class/backlight/panel0-backlight/brightness`,D=`/sys/class/backlight/panel0-backlight/max_brightness`;function O(e){let t=document.getElementById(`toast`);t.textContent=e,t.classList.add(`show`),setTimeout(()=>t.classList.remove(`show`),3e3)}async function k(e){try{return await n(e)}catch(e){return console.error(e),{errno:-1,stdout:``,stderr:String(e)}}}async function A(e,t){return k(`echo -n '${String(t).replace(/'/g,`'\\''`)}' > "${e}"`)}async function j(){let[e,t,n]=await Promise.all([k(`cat "${S}/ui_max_bri.txt"`),k(`cat "${S}/max_bri.txt"`),k(`cat "${S}/sleep_time.txt"`)]);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&&(document.getElementById(`input-sleep-time`).value=n.stdout.trim())}async function M(){let e=document.getElementById(`input-ui-max-bri`).value,t=document.getElementById(`input-max-bri`).value,n=document.getElementById(`input-sleep-time`).value;if(!e||!t){O(`亮度值不能为空`);return}O(`保存中...`),await A(`${S}/ui_max_bri.txt`,e),await A(`${S}/max_bri.txt`,t),await A(`${S}/sleep_time.txt`,n),await k(`rm -f "${w}"`);let r=await k(`cat "${C}"`);r.errno===0&&r.stdout.trim()?O(`配置已保存 (可能需要在下次调整时生效)`):O(`配置已保存 (服务未运行)`)}async function N(){let[e,t,n]=await Promise.all([k(`cat "${E}"`),k(`cat "${D}"`),k(`cat "${C}"`)]);document.getElementById(`status-current-bri`).textContent=e.errno===0?e.stdout.trim():`N/A`,document.getElementById(`status-sys-max-bri`).textContent=t.errno===0?t.stdout.trim():`N/A`;let r=n.errno===0?n.stdout.trim():``,i=document.getElementById(`status-inotifyd-pid`),a=document.querySelector(`.status-dot`),o=document.querySelector(`.status-text`);r?(i.textContent=r,a.style.backgroundColor=`#4caf50`,o.textContent=`运行中`):(i.textContent=`未运行`,a.style.backgroundColor=`var(--md-sys-color-error)`,o.textContent=`已停止`);let s=document.getElementById(`input-sleep-time`).value,c=!1;if(s&&s.includes(`-`)){let[e,t]=s.split(`-`),n=new Date,r=n.getHours()*100+n.getMinutes(),i=parseInt(e,10),a=parseInt(t,10);i>a?(r>=i||r<a)&&(c=!0):i<a&&r>=i&&r<a&&(c=!0)}document.getElementById(`status-sleep`).textContent=c?`休眠中`:`非休眠`}async function P(){let e=document.getElementById(`log-output`),t=await k(`tail -n 50 "${T}"`);t.errno===0&&t.stdout?e.textContent=t.stdout:e.textContent=`暂无日志或读取失败`,e.scrollTop=e.scrollHeight}async function F(){x({icons:{Sun:b,Settings:y,Save:v,Activity:h,RefreshCw:_,FileText:g}}),document.getElementById(`btn-save`).addEventListener(`click`,M),document.getElementById(`btn-refresh-status`).addEventListener(`click`,N),document.getElementById(`btn-refresh-log`).addEventListener(`click`,P),await j(),await N(),await P()}document.addEventListener(`DOMContentLoaded`,F);
+89 -24
View File
@@ -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-_esaoEhK.js"></script>
<link rel="stylesheet" crossorigin href="/assets/index-CRYvfSfT.css">
<script type="module" crossorigin src="/assets/index-DfP8X78P.js"></script>
<link rel="stylesheet" crossorigin href="/assets/index-DAJ7hj2r.css">
</head>
<body>
@@ -34,38 +34,100 @@
<h2>亮度配置</h2>
</div>
<div class="config-item">
<div class="config-label">
<span class="config-name">前台最大亮度</span>
<span class="config-desc">触发亮度提升的阈值</span>
<!-- 分类: 亮度调节 -->
<div class="config-group">
<h3 class="group-title">亮度调节</h3>
<div class="config-item">
<div class="config-label">
<span class="config-name">前台最大亮度</span>
<span class="config-desc">触发亮度提升的阈值</span>
</div>
<div class="config-value">
<input type="number" id="input-ui-max-bri" class="config-input" min="0" />
</div>
</div>
<div class="config-value">
<input type="number" id="input-ui-max-bri" class="config-input" min="0" />
<div class="config-item">
<div class="config-label">
<span class="config-name">峰值最大亮度</span>
<span class="config-desc">亮度提升的目标值</span>
</div>
<div class="config-value">
<input type="number" id="input-max-bri" class="config-input" min="0" />
</div>
</div>
<div class="config-item">
<div class="config-label">
<span class="config-name">亮度提升步数</span>
<span class="config-desc">约 0.02 秒 / 步</span>
</div>
<div class="config-value">
<input type="number" id="input-steps-num" class="config-input" min="1" max="500" />
</div>
</div>
</div>
<div class="config-item">
<div class="config-label">
<span class="config-name">峰值最大亮度</span>
<span class="config-desc">亮度提升的目标值</span>
<!-- 分类: 执行策略 -->
<div class="config-group">
<h3 class="group-title">执行策略</h3>
<div class="config-item">
<div class="config-label">
<span class="config-name">自动亮度时休眠</span>
<span class="config-desc">开启自动亮度时不提升</span>
</div>
<div class="config-value">
<label class="switch">
<input type="checkbox" id="input-auto-bri-sleep">
<span class="slider"></span>
</label>
</div>
</div>
<div class="config-value">
<input type="number" id="input-max-bri" class="config-input" min="0" />
<div class="config-item">
<div class="config-label">
<span class="config-name">定时休眠</span>
<span class="config-desc">设定时段内不提升亮度</span>
</div>
<div class="config-value">
<label class="switch">
<input type="checkbox" id="input-sleep-mode">
<span class="slider"></span>
</label>
</div>
</div>
<div class="config-item-expand" id="sleep-time-expand">
<div class="custom-time-picker">
<div class="time-unit">
<input type="number" id="input-sleep-start-h" class="time-input" min="0" max="23" placeholder="00" />
<span>:</span>
<input type="number" id="input-sleep-start-m" class="time-input" min="0" max="59" placeholder="00" />
</div>
<span class="time-sep">至</span>
<div class="time-unit">
<input type="number" id="input-sleep-end-h" class="time-input" min="0" max="23" placeholder="00" />
<span>:</span>
<input type="number" id="input-sleep-end-m" class="time-input" min="0" max="59" placeholder="00" />
</div>
</div>
</div>
</div>
<div class="config-item">
<div class="config-label">
<span class="config-name">休眠时间</span>
<span class="config-desc">该时段内不提升亮度</span>
</div>
<div class="config-value">
<input type="text" id="input-sleep-time" class="config-input config-input-wide"
placeholder="如 1900-0600" />
<!-- 分类: 系统管理 -->
<div class="config-group">
<h3 class="group-title">系统管理</h3>
<div class="config-item">
<div class="config-label">
<span class="config-name">日志大小限制</span>
<span class="config-desc">单位: KB</span>
</div>
<div class="config-value">
<input type="number" id="input-log-max-size" class="config-input" min="1" max="10240" />
</div>
</div>
</div>
<div class="card-actions">
<button class="btn btn-outline" id="btn-reset">
恢复默认
</button>
<button class="btn btn-primary" id="btn-save">
<span class="btn-icon"><i data-lucide="save"></i></span> 保存配置
</button>
@@ -77,7 +139,10 @@
<div class="card-header">
<span class="card-icon"><i data-lucide="activity"></i></span>
<h2>实时状态</h2>
<button class="btn-icon-only" id="btn-refresh-status" title="刷新"><i data-lucide="refresh-cw"></i></button>
<div class="header-actions">
<button class="btn-text-s" id="btn-restart-service">重启</button>
<button class="btn-text-s" id="btn-refresh-status">刷新</button>
</div>
</div>
<div class="status-grid">
@@ -105,7 +170,7 @@
<div class="card-header">
<span class="card-icon"><i data-lucide="file-text"></i></span>
<h2>运行日志</h2>
<button class="btn-icon-only" id="btn-refresh-log" title="刷新"><i data-lucide="refresh-cw"></i></button>
<button class="btn-text-s" id="btn-refresh-log">刷新</button>
</div>
<pre class="log-output" id="log-output">加载中...</pre>
</section>