mirror of
https://github.com/YuleBest/LuminPro.git
synced 2026-12-04 00:54:42 +08:00
update: 更新到 2208 版本;实现 HDR 避让;实现活动级黑名单
This commit is contained in:
1 parent
a61c845323
commit
b4169ceb1f
12 files changed
+566
-124
No files matched your search
+1
-1
@@ -10,7 +10,7 @@ const version = versionMatch ? versionMatch[1].trim() : 'Unknown';
|
||||
const versionCodeStr = versionCodeMatch ? versionCodeMatch[1].trim() : '0000';
|
||||
const versionCode = parseInt(versionCodeStr, 10);
|
||||
|
||||
const zipName = `LuminPro_${version}-${versionCode}.zip`;
|
||||
const zipName = `LuminPro_${version}.zip`;
|
||||
|
||||
// --- 新增: 自动同步 update.json ---
|
||||
const updateJsonPath = 'update.json';
|
||||
|
||||
@@ -1,3 +1,10 @@
|
||||
## v2.2-2208
|
||||
|
||||
- 新增: 黑名单功能,可在指定应用内禁止模块工作
|
||||
- 新增: Web UI 日志导出、复制功能
|
||||
- 优化: Web UI 外观
|
||||
- 优化: 日志信息
|
||||
|
||||
## V2.2-2204
|
||||
|
||||
- 新增: `boost.sh` 脚本,支持一键将亮度提升至峰值极限
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
1
|
||||
@@ -294,6 +294,7 @@ IMPORT_OLD_CONFIG() {
|
||||
[ -s "$old_config/steps_num.txt" ] && cp -f "$old_config/steps_num.txt" "$mod_config/"
|
||||
[ -s "$old_config/log_max_size.txt" ] && cp -f "$old_config/log_max_size.txt" "$mod_config/"
|
||||
[ -s "$old_config/blacklist_apps.txt" ] && cp -f "$old_config/blacklist_apps.txt" "$mod_config/"
|
||||
[ -s "$old_config/display_hdr_sleep.txt" ] && cp -f "$old_config/display_hdr_sleep.txt" "$mod_config/"
|
||||
|
||||
# 迁移旧的路径配置(如果存在)
|
||||
mkdir -p "$mod_path_config"
|
||||
@@ -340,6 +341,7 @@ INIT_CONFIG() {
|
||||
[ ! -f "$mod_config/steps_num.txt" ] && touch "$mod_config/steps_num.txt"
|
||||
[ ! -f "$mod_config/log_max_size.txt" ] && touch "$mod_config/log_max_size.txt"
|
||||
[ ! -f "$mod_config/blacklist_apps.txt" ] && touch "$mod_config/blacklist_apps.txt"
|
||||
[ ! -f "$mod_config/display_hdr_sleep.txt" ] && touch "$mod_config/display_hdr_sleep.txt"
|
||||
|
||||
# 初始化设备路径配置 (仅在文件不存在时使用默认值,保留用户自定义配置)
|
||||
[ ! -f "$mod_path_config/now_bri_file.txt" ] && echo -n "$DEFAULT_NOW_BRI_FILE" >"$mod_path_config/now_bri_file.txt"
|
||||
@@ -384,6 +386,7 @@ CREATE_BACKUP() {
|
||||
cp -f "$mod_config/steps_num.txt" "$mod_config/.backup/"
|
||||
cp -f "$mod_config/log_max_size.txt" "$mod_config/.backup/"
|
||||
cp -f "$mod_config/blacklist_apps.txt" "$mod_config/.backup/"
|
||||
cp -f "$mod_config/display_hdr_sleep.txt" "$mod_config/.backup/"
|
||||
}
|
||||
|
||||
# 主函数
|
||||
|
||||
+2
-2
@@ -1,7 +1,7 @@
|
||||
id=LuminPro
|
||||
name=LuminPro丨日用屏幕亮度强化
|
||||
version=V2.2
|
||||
versionCode=2204
|
||||
version=V2.2-2208
|
||||
versionCode=2208
|
||||
author=酷安@Yule
|
||||
description=本模块旨在让你的 Android 设备随时可以使用高亮度显示屏幕内容。无论设备当前亮度如何,只要满足设定的前台触发亮度条件,模块便会自动且平滑地提升屏幕亮度至硬件支持的峰值状态,确保你在强光室外也能获得清晰的显示效果
|
||||
updateJson=https://share.yule.ink/magisk/mod/luminpro/update.json
|
||||
+49
-8
@@ -77,6 +77,7 @@ 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)"
|
||||
display_hdr_sleep="$(cat "$CONFIG_DIR/display_hdr_sleep.txt" 2>/dev/null)"
|
||||
|
||||
# 解析休眠时间 (格式: HHMM-HHMM, 例如 1900-0600)
|
||||
sleep_start="${sleep_time%-*}" # 1900
|
||||
@@ -161,7 +162,7 @@ MAIN() {
|
||||
# 解析并判断休眠
|
||||
if IS_SLEEP_TIME; then
|
||||
_log "处于休眠时段 ($sleep_start-$sleep_end),跳过提升" "INFO"
|
||||
rm -f "$flag_file"
|
||||
rm -f "$flag_file" "$pause_file"
|
||||
return
|
||||
fi
|
||||
|
||||
@@ -169,23 +170,63 @@ MAIN() {
|
||||
mode="$(settings get system screen_brightness_mode 2>/dev/null)"
|
||||
if [ "$mode" = "1" ]; then
|
||||
_log "自动亮度已启用,跳过提升" "INFO"
|
||||
rm -f "$flag_file"
|
||||
rm -f "$flag_file" "$pause_file"
|
||||
return
|
||||
fi
|
||||
fi
|
||||
|
||||
# 黑名单应用检测
|
||||
# 黑名单应用检测(支持包名和完整 package/activity 两种格式)
|
||||
local blacklist_file="$CONFIG_DIR/blacklist_apps.txt"
|
||||
if [ -f "$blacklist_file" ] && [ -s "$blacklist_file" ]; then
|
||||
local current_app
|
||||
current_app="$(dumpsys window | grep mCurrentFocus | sed 's/.*u0 \(.*\)\/.*/\1/')"
|
||||
if [ -n "$current_app" ] && grep -qxF "$current_app" "$blacklist_file"; then
|
||||
_log "当前前台应用 ($current_app) 在黑名单中,跳过提升" "INFO"
|
||||
rm -f "$flag_file"
|
||||
local current_focus current_app
|
||||
current_focus="$(dumpsys window | grep mCurrentFocus | sed 's/.*u0 \(.*\)}/\1/')"
|
||||
current_app="${current_focus%%/*}"
|
||||
if [ -n "$current_focus" ] && { grep -qxF "$current_focus" "$blacklist_file" || grep -qxF "$current_app" "$blacklist_file"; }; then
|
||||
_log "当前前台 ($current_focus) 在黑名单中,跳过提升" "INFO"
|
||||
rm -f "$flag_file" "$pause_file"
|
||||
return
|
||||
fi
|
||||
fi
|
||||
|
||||
# 显示 HDR 内容时休眠
|
||||
if [ "$display_hdr_sleep" = "1" ]; then
|
||||
local hdr_flag_file="$PID_DIR/hdr.flag"
|
||||
# 冷却期检查:读取写入时间戳,判断是否在 2 秒内
|
||||
if [ -f "$hdr_flag_file" ]; then
|
||||
local flag_time now
|
||||
flag_time="$(cat "$hdr_flag_file")"
|
||||
now="$(date +%s)"
|
||||
if awk "BEGIN{exit !(($now - $flag_time) < 2)}" 2>/dev/null; then
|
||||
_log "HDR 冷却期内,跳过提升" "INFO"
|
||||
rm -f "$flag_file" "$pause_file"
|
||||
return
|
||||
else
|
||||
rm -f "$hdr_flag_file" # 冷却期已过,清理
|
||||
fi
|
||||
fi
|
||||
local hdr_ratio hdr_ratio_rounded
|
||||
local hdr_cache_file="$PID_DIR/.hdr_ratio_cache"
|
||||
hdr_ratio="$(dumpsys display 2>/dev/null | sed -n 's/.*hdrSdrRatio \([0-9.]*\).*/\1/p' | head -n 1)"
|
||||
if echo "$hdr_ratio" | grep -qE '^[0-9]+\.[0-9]+$'; then
|
||||
# 读取成功,更新缓存
|
||||
echo -n "$hdr_ratio" >"$hdr_cache_file"
|
||||
elif [ -f "$hdr_cache_file" ]; then
|
||||
# 读取为空,使用上次缓存
|
||||
hdr_ratio="$(cat "$hdr_cache_file")"
|
||||
_log "HDR 比率读取为空,使用缓存值: $hdr_ratio" "INFO"
|
||||
fi
|
||||
if echo "$hdr_ratio" | grep -qE '^[0-9]+\.[0-9]+$'; then
|
||||
hdr_ratio_rounded="$(awk "BEGIN{printf \"%.2f\", $hdr_ratio}")"
|
||||
if awk "BEGIN{exit !($hdr_ratio_rounded > 1.00)}" 2>/dev/null; then
|
||||
_log "检测到 HDR 内容 (比率: $hdr_ratio_rounded),跳过提升" "INFO"
|
||||
# 写入当前时间戳作为冷却期起点(2 秒内再次触发直接跳过)
|
||||
date +%s >"$hdr_flag_file"
|
||||
rm -f "$flag_file" "$pause_file"
|
||||
return
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
_log "正在检测亮度变化..." "INFO"
|
||||
# sleep 0.5
|
||||
CHECK_BRI
|
||||
|
||||
@@ -29,6 +29,9 @@ _log() {
|
||||
# 等待系统就绪
|
||||
sleep 30
|
||||
|
||||
# 清理上次遗留的标记文件
|
||||
rm -f "$MODDIR/pid/"*.flag "$MODDIR/pid/"*.pause "$MODDIR/pid/.hdr_ratio_cache"
|
||||
|
||||
_log "LuminPro 服务启动" "INFO"
|
||||
_log "前台最大亮度: $(cat "$CONFIG_DIR/ui_max_bri.txt")" "INFO"
|
||||
_log "峰值最大亮度: $(cat "$CONFIG_DIR/max_bri.txt")" "INFO"
|
||||
|
||||
+3
-3
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"versionCode": 2204,
|
||||
"version": "V2.2",
|
||||
"zipUrl": "https://share.yule.ink/magisk/mod/luminpro/module/LuminPro_V2.2-2204.zip",
|
||||
"versionCode": 2208,
|
||||
"version": "V2.2-2208",
|
||||
"zipUrl": "https://share.yule.ink/magisk/mod/luminpro/module/LuminPro_V2.2-2208.zip",
|
||||
"changelog": "https://share.yule.ink/magisk/mod/luminpro/changelog.md"
|
||||
}
|
||||
+71
-9
@@ -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-BrdAtETm.js"></script>
|
||||
<link rel="stylesheet" crossorigin href="/assets/index-CLWDgMjy.css">
|
||||
<script type="module" crossorigin src="/assets/index-2kIL1kxh.js"></script>
|
||||
<link rel="stylesheet" crossorigin href="/assets/index-C7huTDs1.css">
|
||||
</head>
|
||||
|
||||
<body>
|
||||
@@ -21,7 +21,7 @@
|
||||
<div class="header-text">
|
||||
<h1>LuminPro</h1>
|
||||
<p class="header-subtitle">日用屏幕亮度强化</p>
|
||||
<p class="header-version" id="module-version">V2.2-2204</p>
|
||||
<p class="header-version" id="module-version">V2.2-2208</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="header-status-container">
|
||||
@@ -46,32 +46,46 @@
|
||||
<div class="status-grid">
|
||||
<div class="status-item">
|
||||
<div class="status-item-header">
|
||||
<i data-lucide="sun"></i>
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><circle cx="12" cy="12" r="4"></circle><path d="M12 2v2"></path><path d="M12 20v2"></path><path d="m4.93 4.93 1.41 1.41"></path><path d="m17.66 17.66 1.41 1.41"></path><path d="M2 12h2"></path><path d="M20 12h2"></path><path d="m6.34 17.66-1.41 1.41"></path><path d="m19.07 4.93-1.41 1.41"></path></svg>
|
||||
<span class="status-label">当前亮度</span>
|
||||
</div>
|
||||
<span class="status-value" id="status-current-bri">—</span>
|
||||
</div>
|
||||
<div class="status-item">
|
||||
<div class="status-item-header">
|
||||
<i data-lucide="smartphone"></i>
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><rect width="14" height="20" x="5" y="2" rx="2" ry="2"></rect><path d="M12 18h.01"></path></svg>
|
||||
<span class="status-label">系统最大亮度</span>
|
||||
</div>
|
||||
<span class="status-value" id="status-sys-max-bri">—</span>
|
||||
</div>
|
||||
<div class="status-item">
|
||||
<div class="status-item-header">
|
||||
<i data-lucide="activity"></i>
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M22 12h-4l-3 9L9 3l-3 9H2"></path></svg>
|
||||
<span class="status-label">inotifyd PID</span>
|
||||
</div>
|
||||
<span class="status-value" id="status-inotifyd-pid">—</span>
|
||||
</div>
|
||||
<div class="status-item">
|
||||
<div class="status-item-header">
|
||||
<i data-lucide="moon"></i>
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><circle cx="12" cy="12" r="10"></circle><path d="M12 6v6l4 2"></path></svg>
|
||||
<span class="status-label">inotifyd 状态</span>
|
||||
</div>
|
||||
<span class="status-value" id="status-inotifyd-state">—</span>
|
||||
</div>
|
||||
<div class="status-item">
|
||||
<div class="status-item-header">
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M12 3a6 6 0 0 0 9 9 9 9 0 1 1-9-9Z"></path></svg>
|
||||
<span class="status-label">休眠状态</span>
|
||||
</div>
|
||||
<span class="status-value" id="status-sleep">—</span>
|
||||
</div>
|
||||
<div class="status-item">
|
||||
<div class="status-item-header">
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="m12.83 2.18a2 2 0 0 0-1.66 0L2.6 6.08a1 1 0 0 0 0 1.83l8.58 3.91a2 2 0 0 0 1.66 0l8.58-3.9a1 1 0 0 0 0-1.83Z"></path><path d="m22 17.65-9.17 4.16a2 2 0 0 1-1.66 0L2 17.65"></path><path d="m22 12.65-9.17 4.16a2 2 0 0 1-1.66 0L2 12.65"></path></svg>
|
||||
<span class="status-label">HDR/SDR 比率</span>
|
||||
</div>
|
||||
<span class="status-value" id="status-hdr-ratio">—</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 亮度控制区 -->
|
||||
@@ -148,6 +162,19 @@
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
<div class="config-item">
|
||||
<div class="config-label">
|
||||
<span class="config-name">显示 HDR 内容时休眠</span>
|
||||
<span class="config-desc">HDR/SDR 比率 > 1 时不提升</span>
|
||||
<span class="config-desc" style="color: var(--color-warning, #f59e0b);">建议配合去温控使用(部分系统温控策略较严格,高温时可能不显示 HDR 但仍提升亮度,导致闪屏。出现此情况时,可以使用活动黑名单/应用黑名单功能)</span>
|
||||
</div>
|
||||
<div class="config-value">
|
||||
<label class="switch">
|
||||
<input type="checkbox" id="input-display-hdr-sleep">
|
||||
<span class="slider"></span>
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
<div class="config-item">
|
||||
<div class="config-label">
|
||||
<span class="config-name">定时休眠</span>
|
||||
@@ -213,6 +240,7 @@
|
||||
<div class="config-label">
|
||||
<span class="config-name">inotifyd 监听事件</span>
|
||||
<span class="config-desc">默认 c。修改需重启服务</span>
|
||||
<span class="config-desc" style="color: var(--color-warning, #f59e0b);">为避免性能消耗,修改为 c 以外的事件时建议关闭 Web UI 配置 - 自动刷新</span>
|
||||
<button class="btn-text-s" id="btn-view-inotifyd-help" style="margin-top: 6px; padding: 2px 6px;">查看支持事件</button>
|
||||
</div>
|
||||
<div class="config-value">
|
||||
@@ -255,6 +283,15 @@
|
||||
<div class="config-group">
|
||||
<h3 class="group-title"><i data-lucide="monitor"></i> 界面设置</h3>
|
||||
<div class="config-item">
|
||||
<div class="config-label">
|
||||
<span class="config-name">自动刷新</span>
|
||||
<span class="config-desc">定时刷新状态和日志。监听非 c 事件时建议关闭</span>
|
||||
</div>
|
||||
<div class="config-value">
|
||||
<label class="switch"><input type="checkbox" id="input-auto-refresh" checked /><span class="slider"></span></label>
|
||||
</div>
|
||||
</div>
|
||||
<div class="config-item" id="item-status-refresh-interval">
|
||||
<div class="config-label">
|
||||
<span class="config-name">状态/日志刷新间隔</span>
|
||||
<span class="config-desc">单位: 毫秒 (最小100ms)</span>
|
||||
@@ -325,6 +362,15 @@
|
||||
推荐选择视频类、相册等需展示 HDR 内容的应用
|
||||
</p>
|
||||
|
||||
<!-- 按活动屏蔽 -->
|
||||
<div class="activity-block-card">
|
||||
<span class="activity-block-label">按活动屏蔽</span>
|
||||
<div class="activity-block-row">
|
||||
<input type="text" id="input-activity-entry" class="activity-block-input" placeholder="com.pkg/com.pkg.ActivityClass" autocomplete="off" spellcheck="false" />
|
||||
<button class="btn btn-primary" id="btn-add-activity" style="padding: 0 14px; border-radius: var(--border-radius-m); font-size: 0.8125rem; white-space: nowrap; flex-shrink: 0;">确认</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 搜索栏 -->
|
||||
<div style="display: flex; gap: 8px; align-items: stretch; margin-bottom: var(--spacing-m);">
|
||||
<div class="app-search-container" style="flex: 1; margin-bottom: 0;">
|
||||
@@ -344,7 +390,7 @@
|
||||
<section class="card" id="log-section" data-nav-group="log">
|
||||
<div class="card-header">
|
||||
<h2>运行日志</h2>
|
||||
<div class="header-actions">
|
||||
<div class="header-actions dropdown-container">
|
||||
<select id="log-level-filter" class="log-filter-select">
|
||||
<option value="">全部等级</option>
|
||||
<option value="INFO">INFO</option>
|
||||
@@ -352,7 +398,23 @@
|
||||
<option value="ERROR">ERROR</option>
|
||||
<option value="SUCCESS">SUCCESS</option>
|
||||
</select>
|
||||
<button class="btn-text-s" id="btn-clear-logs">清空日志</button>
|
||||
<button class="btn-icon-only" id="btn-log-menu">
|
||||
<i data-lucide="more-vertical"></i>
|
||||
</button>
|
||||
<div class="dropdown-menu" id="log-dropdown-menu">
|
||||
<div class="dropdown-item" id="btn-copy-log">
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><rect width="14" height="14" x="8" y="8" rx="2" ry="2"></rect><path d="M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2"></path></svg>
|
||||
<span>复制日志</span>
|
||||
</div>
|
||||
<div class="dropdown-item" id="btn-export-log">
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"></path><polyline points="7 10 12 15 17 10"></polyline><line x1="12" x2="12" y1="15" y2="3"></line></svg>
|
||||
<span>导出日志</span>
|
||||
</div>
|
||||
<div class="dropdown-item" id="btn-clear-logs">
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M18 6 6 18"></path><path d="m6 6 12 12"></path></svg>
|
||||
<span>清空日志</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<pre class="log-output" id="log-output">加载中...</pre>
|
||||
|
||||
+51
-5
@@ -20,7 +20,7 @@
|
||||
<div class="header-text">
|
||||
<h1>LuminPro</h1>
|
||||
<p class="header-subtitle">日用屏幕亮度强化</p>
|
||||
<p class="header-version" id="module-version">V2.2-2204</p>
|
||||
<p class="header-version" id="module-version">V2.2-2208</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="header-status-container">
|
||||
@@ -45,32 +45,46 @@
|
||||
<div class="status-grid">
|
||||
<div class="status-item">
|
||||
<div class="status-item-header">
|
||||
<i data-lucide="sun"></i>
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><circle cx="12" cy="12" r="4"></circle><path d="M12 2v2"></path><path d="M12 20v2"></path><path d="m4.93 4.93 1.41 1.41"></path><path d="m17.66 17.66 1.41 1.41"></path><path d="M2 12h2"></path><path d="M20 12h2"></path><path d="m6.34 17.66-1.41 1.41"></path><path d="m19.07 4.93-1.41 1.41"></path></svg>
|
||||
<span class="status-label">当前亮度</span>
|
||||
</div>
|
||||
<span class="status-value" id="status-current-bri">—</span>
|
||||
</div>
|
||||
<div class="status-item">
|
||||
<div class="status-item-header">
|
||||
<i data-lucide="smartphone"></i>
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><rect width="14" height="20" x="5" y="2" rx="2" ry="2"></rect><path d="M12 18h.01"></path></svg>
|
||||
<span class="status-label">系统最大亮度</span>
|
||||
</div>
|
||||
<span class="status-value" id="status-sys-max-bri">—</span>
|
||||
</div>
|
||||
<div class="status-item">
|
||||
<div class="status-item-header">
|
||||
<i data-lucide="activity"></i>
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M22 12h-4l-3 9L9 3l-3 9H2"></path></svg>
|
||||
<span class="status-label">inotifyd PID</span>
|
||||
</div>
|
||||
<span class="status-value" id="status-inotifyd-pid">—</span>
|
||||
</div>
|
||||
<div class="status-item">
|
||||
<div class="status-item-header">
|
||||
<i data-lucide="moon"></i>
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><circle cx="12" cy="12" r="10"></circle><path d="M12 6v6l4 2"></path></svg>
|
||||
<span class="status-label">inotifyd 状态</span>
|
||||
</div>
|
||||
<span class="status-value" id="status-inotifyd-state">—</span>
|
||||
</div>
|
||||
<div class="status-item">
|
||||
<div class="status-item-header">
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M12 3a6 6 0 0 0 9 9 9 9 0 1 1-9-9Z"></path></svg>
|
||||
<span class="status-label">休眠状态</span>
|
||||
</div>
|
||||
<span class="status-value" id="status-sleep">—</span>
|
||||
</div>
|
||||
<div class="status-item">
|
||||
<div class="status-item-header">
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="m12.83 2.18a2 2 0 0 0-1.66 0L2.6 6.08a1 1 0 0 0 0 1.83l8.58 3.91a2 2 0 0 0 1.66 0l8.58-3.9a1 1 0 0 0 0-1.83Z"></path><path d="m22 17.65-9.17 4.16a2 2 0 0 1-1.66 0L2 17.65"></path><path d="m22 12.65-9.17 4.16a2 2 0 0 1-1.66 0L2 12.65"></path></svg>
|
||||
<span class="status-label">HDR/SDR 比率</span>
|
||||
</div>
|
||||
<span class="status-value" id="status-hdr-ratio">—</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 亮度控制区 -->
|
||||
@@ -147,6 +161,19 @@
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
<div class="config-item">
|
||||
<div class="config-label">
|
||||
<span class="config-name">显示 HDR 内容时休眠</span>
|
||||
<span class="config-desc">HDR/SDR 比率 > 1 时不提升</span>
|
||||
<span class="config-desc" style="color: var(--color-warning, #f59e0b);">建议配合去温控使用(部分系统温控策略较严格,高温时可能不显示 HDR 但仍提升亮度,导致闪屏。出现此情况时,可以使用活动黑名单/应用黑名单功能)</span>
|
||||
</div>
|
||||
<div class="config-value">
|
||||
<label class="switch">
|
||||
<input type="checkbox" id="input-display-hdr-sleep">
|
||||
<span class="slider"></span>
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
<div class="config-item">
|
||||
<div class="config-label">
|
||||
<span class="config-name">定时休眠</span>
|
||||
@@ -212,6 +239,7 @@
|
||||
<div class="config-label">
|
||||
<span class="config-name">inotifyd 监听事件</span>
|
||||
<span class="config-desc">默认 c。修改需重启服务</span>
|
||||
<span class="config-desc" style="color: var(--color-warning, #f59e0b);">为避免性能消耗,修改为 c 以外的事件时建议关闭 Web UI 配置 - 自动刷新</span>
|
||||
<button class="btn-text-s" id="btn-view-inotifyd-help" style="margin-top: 6px; padding: 2px 6px;">查看支持事件</button>
|
||||
</div>
|
||||
<div class="config-value">
|
||||
@@ -254,6 +282,15 @@
|
||||
<div class="config-group">
|
||||
<h3 class="group-title"><i data-lucide="monitor"></i> 界面设置</h3>
|
||||
<div class="config-item">
|
||||
<div class="config-label">
|
||||
<span class="config-name">自动刷新</span>
|
||||
<span class="config-desc">定时刷新状态和日志。监听非 c 事件时建议关闭</span>
|
||||
</div>
|
||||
<div class="config-value">
|
||||
<label class="switch"><input type="checkbox" id="input-auto-refresh" checked /><span class="slider"></span></label>
|
||||
</div>
|
||||
</div>
|
||||
<div class="config-item" id="item-status-refresh-interval">
|
||||
<div class="config-label">
|
||||
<span class="config-name">状态/日志刷新间隔</span>
|
||||
<span class="config-desc">单位: 毫秒 (最小100ms)</span>
|
||||
@@ -324,6 +361,15 @@
|
||||
推荐选择视频类、相册等需展示 HDR 内容的应用
|
||||
</p>
|
||||
|
||||
<!-- 按活动屏蔽 -->
|
||||
<div class="activity-block-card">
|
||||
<span class="activity-block-label">按活动屏蔽</span>
|
||||
<div class="activity-block-row">
|
||||
<input type="text" id="input-activity-entry" class="activity-block-input" placeholder="com.pkg/com.pkg.ActivityClass" autocomplete="off" spellcheck="false" />
|
||||
<button class="btn btn-primary" id="btn-add-activity" style="padding: 0 14px; border-radius: var(--border-radius-m); font-size: 0.8125rem; white-space: nowrap; flex-shrink: 0;">确认</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 搜索栏 -->
|
||||
<div style="display: flex; gap: 8px; align-items: stretch; margin-bottom: var(--spacing-m);">
|
||||
<div class="app-search-container" style="flex: 1; margin-bottom: 0;">
|
||||
|
||||
+233
-92
@@ -26,6 +26,7 @@ let configRefreshInterval = 5000; // 配置卡片刷新间隔(默认5秒)
|
||||
let autoRefreshStatusLogTimer = null; // 状态/日志刷新定时器
|
||||
let autoRefreshConfigTimer = null; // 配置刷新定时器
|
||||
let uiZoom = 100; // 界面缩放百分比 (50-150)
|
||||
let autoRefresh = true; // 自动刷新开关(默认开启)
|
||||
|
||||
// ==========================
|
||||
// 工具函数
|
||||
@@ -102,13 +103,14 @@ async function loadConfig() {
|
||||
|
||||
|
||||
// 然后加载其他配置
|
||||
const [uiRes, maxRes, sleepRes, autoRes, stepsRes, logSizeRes] = await Promise.all([
|
||||
const [uiRes, maxRes, sleepRes, autoRes, stepsRes, logSizeRes, hdrSleepRes] = 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}/auto_bri_sleep.txt"`),
|
||||
runCmd(`cat "${CONFIG_DIR}/steps_num.txt"`),
|
||||
runCmd(`cat "${CONFIG_DIR}/log_max_size.txt"`)
|
||||
runCmd(`cat "${CONFIG_DIR}/log_max_size.txt"`),
|
||||
runCmd(`cat "${CONFIG_DIR}/display_hdr_sleep.txt"`)
|
||||
]);
|
||||
|
||||
if (uiRes.errno === 0) document.getElementById('input-ui-max-bri').value = uiRes.stdout.trim();
|
||||
@@ -147,6 +149,7 @@ async function loadConfig() {
|
||||
}
|
||||
|
||||
if (autoRes.errno === 0) document.getElementById('input-auto-bri-sleep').checked = autoRes.stdout.trim() === '1';
|
||||
if (hdrSleepRes.errno === 0) document.getElementById('input-display-hdr-sleep').checked = hdrSleepRes.stdout.trim() === '1';
|
||||
if (stepsRes.errno === 0) {
|
||||
const v = stepsRes.stdout.trim();
|
||||
document.getElementById('input-steps-num').value = v ? v : '50';
|
||||
@@ -174,6 +177,14 @@ async function loadConfig() {
|
||||
document.getElementById('input-status-refresh-interval').value = statusLogRefreshInterval;
|
||||
document.getElementById('input-config-refresh-interval').value = configRefreshInterval;
|
||||
|
||||
const savedAutoRefresh = localStorage.getItem('autoRefresh');
|
||||
if (savedAutoRefresh !== null) autoRefresh = savedAutoRefresh !== 'false';
|
||||
const autoRefreshToggle = document.getElementById('input-auto-refresh');
|
||||
if (autoRefreshToggle) {
|
||||
autoRefreshToggle.checked = autoRefresh;
|
||||
document.getElementById('item-status-refresh-interval').style.display = autoRefresh ? '' : 'none';
|
||||
}
|
||||
|
||||
const uiZoomInput = document.getElementById('input-ui-zoom');
|
||||
if (uiZoomInput) uiZoomInput.value = uiZoom;
|
||||
applyUIZoom(uiZoom);
|
||||
@@ -197,6 +208,7 @@ async function saveConfig() {
|
||||
}
|
||||
|
||||
const autoBriSleep = document.getElementById('input-auto-bri-sleep').checked ? '1' : '0';
|
||||
const displayHdrSleep = document.getElementById('input-display-hdr-sleep').checked ? '1' : '0';
|
||||
const stepsNum = document.getElementById('input-steps-num').value || '50';
|
||||
const logMaxSize = document.getElementById('input-log-max-size').value || '500';
|
||||
|
||||
@@ -212,6 +224,7 @@ async function saveConfig() {
|
||||
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}/display_hdr_sleep.txt`, displayHdrSleep);
|
||||
await writeFile(`${CONFIG_DIR}/steps_num.txt`, stepsNum);
|
||||
await writeFile(`${CONFIG_DIR}/log_max_size.txt`, logMaxSize);
|
||||
|
||||
@@ -254,12 +267,13 @@ async function saveAdvancedConfig() {
|
||||
|
||||
// 2.3 保存 Web UI 配置
|
||||
function saveWebUIConfig() {
|
||||
const newAutoRefresh = document.getElementById('input-auto-refresh').checked;
|
||||
const statusRefresh = parseInt(document.getElementById('input-status-refresh-interval').value, 10) || 1000;
|
||||
const configRefresh = parseInt(document.getElementById('input-config-refresh-interval').value, 10) || 5000;
|
||||
const zoom = parseInt(document.getElementById('input-ui-zoom').value, 10) || 100;
|
||||
|
||||
// 验证最小值
|
||||
if (statusRefresh < 100) {
|
||||
if (newAutoRefresh && statusRefresh < 100) {
|
||||
showToast('状态/日志刷新间隔最小为100ms');
|
||||
document.getElementById('input-status-refresh-interval').value = 100;
|
||||
return;
|
||||
@@ -271,18 +285,20 @@ function saveWebUIConfig() {
|
||||
}
|
||||
|
||||
// 保存到 localStorage
|
||||
localStorage.setItem('autoRefresh', newAutoRefresh);
|
||||
localStorage.setItem('statusLogRefreshInterval', statusRefresh);
|
||||
localStorage.setItem('configRefreshInterval', configRefresh);
|
||||
localStorage.setItem('uiZoom', zoom);
|
||||
|
||||
// 更新全局变量
|
||||
autoRefresh = newAutoRefresh;
|
||||
statusLogRefreshInterval = statusRefresh;
|
||||
configRefreshInterval = configRefresh;
|
||||
uiZoom = zoom;
|
||||
|
||||
// 重启刷新循环
|
||||
stopAutoRefresh();
|
||||
startAutoRefresh();
|
||||
if (autoRefresh) startAutoRefresh();
|
||||
|
||||
applyUIZoom(zoom);
|
||||
showToast('Web UI 配置已保存');
|
||||
@@ -425,14 +441,29 @@ async function loadStatus(forceFull = false) {
|
||||
else cachedSysMaxBri = '255';
|
||||
}
|
||||
|
||||
const [pidRes, stopRes, autoBriRes] = await Promise.all([
|
||||
const [pidRes, stopRes, autoBriRes, hdrRes] = await Promise.all([
|
||||
runCmd(`cat "${PID_FILE}"`),
|
||||
runCmd(`[ -f "${STOP_FLAG_FILE}" ] && echo "1" || echo "0"`),
|
||||
runCmd(`settings get system screen_brightness_mode`)
|
||||
runCmd(`settings get system screen_brightness_mode`),
|
||||
runCmd(`dumpsys display 2>/dev/null | sed -n 's/.*hdrSdrRatio \\([0-9.]*\\).*/\\1/p' | head -n 1`)
|
||||
]);
|
||||
|
||||
const isPaused = stopRes.errno === 0 && stopRes.stdout.trim() === '1';
|
||||
const running = pidRes.errno === 0 && pidRes.stdout.trim();
|
||||
|
||||
// 获取 inotifyd 进程状态
|
||||
let inotifydState = '—';
|
||||
if (running) {
|
||||
const pid = pidRes.stdout.trim();
|
||||
const stateRes = await runCmd(`cat /proc/${pid}/status 2>/dev/null | grep "State:" | sed 's/.*(\(.*\))/\\1/'`);
|
||||
if (stateRes.errno === 0 && stateRes.stdout.trim()) {
|
||||
inotifydState = stateRes.stdout.trim();
|
||||
} else {
|
||||
inotifydState = '已退出';
|
||||
}
|
||||
} else {
|
||||
inotifydState = '离线';
|
||||
}
|
||||
|
||||
const statusDot = document.querySelector('.header-status .status-dot');
|
||||
const statusText = document.querySelector('.header-status .status-text');
|
||||
@@ -467,6 +498,16 @@ async function loadStatus(forceFull = false) {
|
||||
document.getElementById('status-current-bri').textContent = currentBri;
|
||||
document.getElementById('status-sys-max-bri').textContent = cachedSysMaxBri || '—';
|
||||
document.getElementById('status-inotifyd-pid').textContent = running ? pidRes.stdout.trim() : '离线';
|
||||
document.getElementById('status-inotifyd-state').textContent = inotifydState;
|
||||
|
||||
// HDR/SDR 比率
|
||||
const hdrRaw = hdrRes.errno === 0 ? hdrRes.stdout.trim() : '';
|
||||
const hdrEl = document.getElementById('status-hdr-ratio');
|
||||
if (hdrRaw && /^\d+(\.\d+)?$/.test(hdrRaw)) {
|
||||
hdrEl.textContent = parseFloat(hdrRaw).toFixed(2);
|
||||
} else {
|
||||
hdrEl.textContent = '-';
|
||||
}
|
||||
|
||||
// 更新亮度滑条
|
||||
const brightnessSlider = document.getElementById('brightness-slider');
|
||||
@@ -747,6 +788,8 @@ async function startAutoRefresh() {
|
||||
// 立即执行一次状态/日志刷新
|
||||
await Promise.all([loadStatus(true), loadLogs()]);
|
||||
|
||||
if (!autoRefresh) return;
|
||||
|
||||
// 启动定时刷新
|
||||
autoRefreshStatusLogTimer = setTimeout(startAutoRefreshStatusLog, statusLogRefreshInterval);
|
||||
autoRefreshConfigTimer = setTimeout(startAutoRefreshConfig, configRefreshInterval);
|
||||
@@ -934,15 +977,37 @@ function setupNavbar() {
|
||||
|
||||
let showingSystemApps = true;
|
||||
let savedBlacklist = new Set();
|
||||
let activityEntries = new Set(); // 活动级黑名单条目(格式:pkg/ActivityClass)
|
||||
|
||||
function updateUnsavedStyling() {
|
||||
const checkboxes = document.querySelectorAll('.app-checkbox');
|
||||
checkboxes.forEach(cb => {
|
||||
if (cb.checked && !savedBlacklist.has(cb.dataset.pkg)) {
|
||||
const items = document.querySelectorAll('.app-list-item');
|
||||
items.forEach(item => {
|
||||
const cb = item.querySelector('.app-checkbox');
|
||||
const custom = item.querySelector('.app-checkbox-custom');
|
||||
if (!cb || !custom) return;
|
||||
const pkg = cb.dataset.pkg;
|
||||
const hasActivities = pkg && [...activityEntries].some(e => e.startsWith(pkg + '/'));
|
||||
// 部分选中:有活动条目但包名未完全选中
|
||||
if (!cb.checked && hasActivities) {
|
||||
custom.classList.add('partial');
|
||||
} else {
|
||||
custom.classList.remove('partial');
|
||||
}
|
||||
// 未保存高亮
|
||||
if (cb.checked && !savedBlacklist.has(pkg)) {
|
||||
cb.classList.add('unsaved');
|
||||
} else {
|
||||
cb.classList.remove('unsaved');
|
||||
}
|
||||
// 箭头可见性
|
||||
const chevron = item.querySelector('.app-activities-chevron');
|
||||
if (chevron) {
|
||||
chevron.style.display = hasActivities ? '' : 'none';
|
||||
if (!hasActivities) {
|
||||
const actList = item.querySelector('.app-activities-list');
|
||||
if (actList) { actList.classList.remove('show'); chevron.classList.remove('expanded'); }
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -950,31 +1015,61 @@ function reorderDOMApps() {
|
||||
const container = document.getElementById('app-list-container');
|
||||
if (!container) return;
|
||||
const items = Array.from(container.children);
|
||||
|
||||
items.sort((a, b) => {
|
||||
const aChecked = a.querySelector('.app-checkbox')?.checked || false;
|
||||
const bChecked = b.querySelector('.app-checkbox')?.checked || false;
|
||||
if (aChecked && !bChecked) return -1;
|
||||
if (!aChecked && bChecked) return 1;
|
||||
const getState = (item) => {
|
||||
const cb = item.querySelector('.app-checkbox');
|
||||
if (cb?.checked) return 2; // 完全选中
|
||||
const pkg = cb?.dataset.pkg;
|
||||
if (pkg && [...activityEntries].some(e => e.startsWith(pkg + '/'))) return 1; // 部分选中
|
||||
return 0;
|
||||
});
|
||||
|
||||
};
|
||||
items.sort((a, b) => getState(b) - getState(a));
|
||||
items.forEach(item => container.appendChild(item));
|
||||
}
|
||||
|
||||
function renderActivityList(pkg, container) {
|
||||
const entries = [...activityEntries].filter(e => e.startsWith(pkg + '/'));
|
||||
container.innerHTML = '';
|
||||
entries.forEach(entry => {
|
||||
const entryDiv = document.createElement('div');
|
||||
entryDiv.className = 'activity-entry-item';
|
||||
const actPath = document.createElement('span');
|
||||
actPath.className = 'activity-entry-path';
|
||||
actPath.textContent = entry.slice(pkg.length + 1);
|
||||
const delBtn = document.createElement('button');
|
||||
delBtn.className = 'activity-entry-delete';
|
||||
delBtn.innerHTML = '<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M18 6 6 18"/><path d="m6 6 12 12"/></svg>';
|
||||
delBtn.addEventListener('click', (e) => {
|
||||
e.stopPropagation();
|
||||
activityEntries.delete(entry);
|
||||
renderActivityList(pkg, container);
|
||||
const actItem = container.closest('.app-list-item');
|
||||
if (actItem) {
|
||||
const chevron = actItem.querySelector('.app-activities-chevron');
|
||||
const remaining = [...activityEntries].filter(e => e.startsWith(pkg + '/'));
|
||||
if (chevron) chevron.style.display = remaining.length > 0 ? '' : 'none';
|
||||
if (remaining.length === 0) { container.classList.remove('show'); if (chevron) chevron.classList.remove('expanded'); }
|
||||
}
|
||||
updateUnsavedStyling();
|
||||
reorderDOMApps();
|
||||
});
|
||||
entryDiv.appendChild(actPath);
|
||||
entryDiv.appendChild(delBtn);
|
||||
container.appendChild(entryDiv);
|
||||
});
|
||||
}
|
||||
|
||||
async function loadApps() {
|
||||
const container = document.getElementById('app-list-container');
|
||||
if (!container) return;
|
||||
container.innerHTML = '<div style="text-align:center;padding:20px;color:var(--md-sys-color-on-surface-variant);">加载中...</div>';
|
||||
|
||||
try {
|
||||
// 读取已保存的黑名单
|
||||
// 读取已保存的黑名单(包名条目 + 活动条目分开存储)
|
||||
const blRes = await runCmd(`cat "${CONFIG_DIR}/blacklist_apps.txt"`);
|
||||
if (blRes.errno === 0) {
|
||||
savedBlacklist = new Set(blRes.stdout.trim().split('\n').filter(Boolean));
|
||||
} else {
|
||||
savedBlacklist = new Set();
|
||||
}
|
||||
const allSaved = blRes.errno === 0 ? blRes.stdout.trim().split('\n').filter(Boolean) : [];
|
||||
savedBlacklist = new Set(allSaved);
|
||||
const savedPkgEntries = new Set(allSaved.filter(e => !e.includes('/')));
|
||||
activityEntries = new Set(allSaved.filter(e => e.includes('/')));
|
||||
|
||||
let infoList = [];
|
||||
try {
|
||||
@@ -1044,30 +1139,18 @@ async function loadApps() {
|
||||
checkbox.className = 'app-checkbox';
|
||||
checkbox.dataset.pkg = app.packageName;
|
||||
|
||||
// 初始渲染时依据已保存状态勾选
|
||||
checkbox.checked = savedBlacklist.has(app.packageName);
|
||||
|
||||
// 依据已保存包名条目勾选(不含活动条目)
|
||||
checkbox.checked = savedPkgEntries.has(app.packageName);
|
||||
checkbox.addEventListener('change', () => {
|
||||
updateUnsavedStyling();
|
||||
updateUnsavedStyling();
|
||||
reorderDOMApps();
|
||||
});
|
||||
|
||||
|
||||
const customCheckbox = document.createElement('span');
|
||||
customCheckbox.className = 'app-checkbox-custom';
|
||||
|
||||
checkboxLabel.appendChild(checkbox);
|
||||
checkboxLabel.appendChild(customCheckbox);
|
||||
|
||||
const iconImg = document.createElement('img');
|
||||
iconImg.className = 'app-icon';
|
||||
iconImg.src = `ksu://icon/${app.packageName}`;
|
||||
iconImg.loading = 'lazy'; // 性能优化
|
||||
iconImg.onerror = () => {
|
||||
const fallback = document.createElement('div');
|
||||
fallback.className = 'app-icon-fallback';
|
||||
fallback.textContent = (app.appLabel || app.packageName || '?').charAt(0).toUpperCase();
|
||||
iconImg.replaceWith(fallback);
|
||||
};
|
||||
|
||||
|
||||
const infoDiv = document.createElement('div');
|
||||
infoDiv.className = 'app-info';
|
||||
|
||||
@@ -1097,14 +1180,37 @@ async function loadApps() {
|
||||
|
||||
infoDiv.appendChild(nameSpan);
|
||||
infoDiv.appendChild(pkgSpan);
|
||||
|
||||
item.appendChild(checkboxLabel);
|
||||
item.appendChild(iconImg);
|
||||
item.appendChild(infoDiv);
|
||||
|
||||
|
||||
// 活动展开箭头
|
||||
const chevronBtn = document.createElement('button');
|
||||
chevronBtn.className = 'app-activities-chevron';
|
||||
chevronBtn.innerHTML = '<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="m6 9 6 6 6-6"/></svg>';
|
||||
const pkgActivities = [...activityEntries].filter(e => e.startsWith(app.packageName + '/'));
|
||||
chevronBtn.style.display = pkgActivities.length > 0 ? '' : 'none';
|
||||
|
||||
const mainRow = document.createElement('div');
|
||||
mainRow.className = 'app-item-main-row';
|
||||
mainRow.appendChild(checkboxLabel);
|
||||
mainRow.appendChild(infoDiv);
|
||||
mainRow.appendChild(chevronBtn);
|
||||
|
||||
// 活动列表(初始折叠)
|
||||
const actListDiv = document.createElement('div');
|
||||
actListDiv.className = 'app-activities-list';
|
||||
actListDiv.dataset.pkg = app.packageName;
|
||||
renderActivityList(app.packageName, actListDiv);
|
||||
|
||||
chevronBtn.addEventListener('click', (e) => {
|
||||
e.stopPropagation();
|
||||
actListDiv.classList.toggle('show');
|
||||
chevronBtn.classList.toggle('expanded');
|
||||
});
|
||||
|
||||
item.appendChild(mainRow);
|
||||
item.appendChild(actListDiv);
|
||||
container.appendChild(item);
|
||||
});
|
||||
|
||||
|
||||
// 渲染完毕后初始展示排版与状态
|
||||
updateUnsavedStyling();
|
||||
reorderDOMApps();
|
||||
@@ -1175,6 +1281,9 @@ async function init() {
|
||||
document.getElementById('btn-save').addEventListener('click', saveConfig);
|
||||
document.getElementById('btn-save-advanced').addEventListener('click', saveAdvancedConfig);
|
||||
document.getElementById('btn-save-webui-config').addEventListener('click', saveWebUIConfig);
|
||||
document.getElementById('input-auto-refresh').addEventListener('change', (e) => {
|
||||
document.getElementById('item-status-refresh-interval').style.display = e.target.checked ? '' : 'none';
|
||||
});
|
||||
document.getElementById('btn-reset').addEventListener('click', handleReset);
|
||||
document.getElementById('btn-toggle-service').addEventListener('click', toggleService);
|
||||
document.getElementById('btn-restart-service').addEventListener('click', restartService);
|
||||
@@ -1392,70 +1501,75 @@ async function init() {
|
||||
const container = document.getElementById('app-list-container');
|
||||
const item = document.createElement('div');
|
||||
item.className = 'app-list-item';
|
||||
|
||||
|
||||
const checkboxLabel = document.createElement('label');
|
||||
checkboxLabel.className = 'app-checkbox-label';
|
||||
|
||||
|
||||
const checkbox = document.createElement('input');
|
||||
checkbox.type = 'checkbox';
|
||||
checkbox.className = 'app-checkbox';
|
||||
checkbox.dataset.pkg = realPkg;
|
||||
checkbox.checked = true;
|
||||
checkbox.addEventListener('change', updateUnsavedStyling);
|
||||
|
||||
checkbox.addEventListener('change', () => { updateUnsavedStyling(); reorderDOMApps(); });
|
||||
|
||||
const customCheckbox = document.createElement('span');
|
||||
customCheckbox.className = 'app-checkbox-custom';
|
||||
|
||||
checkboxLabel.appendChild(checkbox);
|
||||
checkboxLabel.appendChild(customCheckbox);
|
||||
|
||||
const iconImg = document.createElement('img');
|
||||
iconImg.className = 'app-icon';
|
||||
iconImg.src = `ksu://icon/${realPkg}`;
|
||||
iconImg.loading = 'lazy';
|
||||
iconImg.onerror = () => {
|
||||
const fallback = document.createElement('div');
|
||||
fallback.className = 'app-icon-fallback';
|
||||
fallback.textContent = (appData.appLabel || appData.packageName || '?').charAt(0).toUpperCase();
|
||||
iconImg.replaceWith(fallback);
|
||||
};
|
||||
|
||||
|
||||
const infoDiv = document.createElement('div');
|
||||
infoDiv.className = 'app-info';
|
||||
|
||||
|
||||
const nameSpan = document.createElement('span');
|
||||
nameSpan.className = 'app-name';
|
||||
|
||||
const nameNode = document.createTextNode(appData.appLabel || 'Unknown');
|
||||
nameSpan.appendChild(nameNode);
|
||||
|
||||
nameSpan.appendChild(document.createTextNode(appData.appLabel || 'Unknown'));
|
||||
|
||||
if (appData.uid !== undefined) {
|
||||
const uidBadge = document.createElement('span');
|
||||
uidBadge.className = 'app-uid';
|
||||
uidBadge.textContent = String(appData.uid);
|
||||
nameSpan.appendChild(uidBadge);
|
||||
}
|
||||
|
||||
|
||||
const pkgSpan = document.createElement('span');
|
||||
pkgSpan.className = 'app-pkg';
|
||||
pkgSpan.textContent = realPkg;
|
||||
|
||||
|
||||
if (appData.isSystem) {
|
||||
const sysBadge = document.createElement('span');
|
||||
sysBadge.className = 'app-badge';
|
||||
sysBadge.textContent = '系统';
|
||||
pkgSpan.appendChild(sysBadge);
|
||||
}
|
||||
|
||||
|
||||
infoDiv.appendChild(nameSpan);
|
||||
infoDiv.appendChild(pkgSpan);
|
||||
|
||||
item.appendChild(checkboxLabel);
|
||||
item.appendChild(iconImg);
|
||||
item.appendChild(infoDiv);
|
||||
|
||||
|
||||
const chevronBtn = document.createElement('button');
|
||||
chevronBtn.className = 'app-activities-chevron';
|
||||
chevronBtn.innerHTML = '<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="m6 9 6 6 6-6"/></svg>';
|
||||
chevronBtn.style.display = 'none';
|
||||
|
||||
const mainRow = document.createElement('div');
|
||||
mainRow.className = 'app-item-main-row';
|
||||
mainRow.appendChild(checkboxLabel);
|
||||
mainRow.appendChild(infoDiv);
|
||||
mainRow.appendChild(chevronBtn);
|
||||
|
||||
const actListDiv = document.createElement('div');
|
||||
actListDiv.className = 'app-activities-list';
|
||||
actListDiv.dataset.pkg = realPkg;
|
||||
|
||||
chevronBtn.addEventListener('click', (e) => {
|
||||
e.stopPropagation();
|
||||
actListDiv.classList.toggle('show');
|
||||
chevronBtn.classList.toggle('expanded');
|
||||
});
|
||||
|
||||
item.appendChild(mainRow);
|
||||
item.appendChild(actListDiv);
|
||||
container.appendChild(item);
|
||||
|
||||
|
||||
updateUnsavedStyling();
|
||||
reorderDOMApps();
|
||||
showToast('已成功添加并勾选');
|
||||
@@ -1516,27 +1630,54 @@ async function init() {
|
||||
showToast('保存中...');
|
||||
const checkboxes = document.querySelectorAll('.app-checkbox');
|
||||
const selectedPkgs = [];
|
||||
|
||||
checkboxes.forEach(cb => {
|
||||
if (cb.checked) {
|
||||
selectedPkgs.push(cb.dataset.pkg);
|
||||
}
|
||||
});
|
||||
|
||||
const content = selectedPkgs.join('\n');
|
||||
checkboxes.forEach(cb => { if (cb.checked) selectedPkgs.push(cb.dataset.pkg); });
|
||||
// 合并包名条目 + 活动条目
|
||||
const allEntries = [...selectedPkgs, ...activityEntries];
|
||||
const content = allEntries.join('\n');
|
||||
const res = await writeFile(`${CONFIG_DIR}/blacklist_apps.txt`, content);
|
||||
|
||||
if (res.errno === 0 || res.stdout.includes('OK')) {
|
||||
showToast('黑名单保存成功');
|
||||
savedBlacklist = new Set(selectedPkgs);
|
||||
updateUnsavedStyling();
|
||||
reorderDOMApps();
|
||||
showToast('黑名单保存成功');
|
||||
savedBlacklist = new Set(allEntries);
|
||||
updateUnsavedStyling();
|
||||
reorderDOMApps();
|
||||
} else {
|
||||
showToast('保存失败: ' + res.stderr);
|
||||
showToast('保存失败: ' + res.stderr);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// 按活动屏蔽
|
||||
const btnAddActivity = document.getElementById('btn-add-activity');
|
||||
const inputActivityEntry = document.getElementById('input-activity-entry');
|
||||
if (btnAddActivity && inputActivityEntry) {
|
||||
const doAddActivity = () => {
|
||||
const val = inputActivityEntry.value.trim();
|
||||
if (!val) return;
|
||||
const parts = val.split('/');
|
||||
if (parts.length !== 2 || !parts[0] || !parts[1]) {
|
||||
showToast('格式错误,请输入 包名/完整活动类名');
|
||||
return;
|
||||
}
|
||||
activityEntries.add(val);
|
||||
inputActivityEntry.value = '';
|
||||
const pkg = parts[0];
|
||||
document.querySelectorAll('.app-list-item').forEach(appItem => {
|
||||
const cb = appItem.querySelector('.app-checkbox');
|
||||
if (cb && cb.dataset.pkg === pkg) {
|
||||
const actList = appItem.querySelector('.app-activities-list');
|
||||
const chevron = appItem.querySelector('.app-activities-chevron');
|
||||
if (actList) { renderActivityList(pkg, actList); actList.classList.add('show'); }
|
||||
if (chevron) { chevron.style.display = ''; chevron.classList.add('expanded'); }
|
||||
}
|
||||
});
|
||||
updateUnsavedStyling();
|
||||
reorderDOMApps();
|
||||
showToast(`已添加: ${val}`);
|
||||
};
|
||||
btnAddActivity.addEventListener('click', doAddActivity);
|
||||
inputActivityEntry.addEventListener('keydown', (e) => { if (e.key === 'Enter') doAddActivity(); });
|
||||
}
|
||||
|
||||
// 搜索功能
|
||||
const inputAppSearch = document.getElementById('input-app-search');
|
||||
if (inputAppSearch) {
|
||||
|
||||
+142
-4
@@ -1342,15 +1342,21 @@ input:checked + .slider:before {
|
||||
|
||||
.app-list-item {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: var(--spacing-m);
|
||||
padding: var(--spacing-s) var(--spacing-m);
|
||||
flex-direction: column;
|
||||
background-color: var(--md-sys-color-surface-container-high);
|
||||
border-radius: var(--border-radius-s);
|
||||
transition: background-color 0.2s;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.app-list-item:active {
|
||||
.app-item-main-row {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: var(--spacing-m);
|
||||
padding: var(--spacing-s) var(--spacing-m);
|
||||
}
|
||||
|
||||
.app-item-main-row:active {
|
||||
background-color: var(--md-sys-color-surface-container);
|
||||
}
|
||||
|
||||
@@ -1471,3 +1477,135 @@ input:checked + .slider:before {
|
||||
margin-left: 6px;
|
||||
vertical-align: middle;
|
||||
}
|
||||
|
||||
/* 部分选中状态(有活动条目但包未完全选中)🟥 */
|
||||
.app-checkbox-custom.partial {
|
||||
background-color: var(--md-sys-color-primary-container);
|
||||
border-color: var(--md-sys-color-primary);
|
||||
}
|
||||
|
||||
.app-checkbox-custom.partial::after {
|
||||
content: '';
|
||||
display: block;
|
||||
width: 8px;
|
||||
height: 8px;
|
||||
background-color: var(--md-sys-color-primary);
|
||||
border-radius: 1px;
|
||||
}
|
||||
|
||||
/* 活动列表展开箭头 */
|
||||
.app-activities-chevron {
|
||||
flex-shrink: 0;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
width: 28px;
|
||||
height: 28px;
|
||||
background: none;
|
||||
border: none;
|
||||
border-radius: var(--border-radius-s);
|
||||
color: var(--md-sys-color-on-surface-variant);
|
||||
cursor: pointer;
|
||||
transition: transform 0.2s, background-color 0.2s;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
.app-activities-chevron:hover {
|
||||
background-color: var(--md-sys-color-surface-container);
|
||||
}
|
||||
|
||||
.app-activities-chevron.expanded {
|
||||
transform: rotate(180deg);
|
||||
}
|
||||
|
||||
/* 活动列表容器 */
|
||||
.app-activities-list {
|
||||
display: none;
|
||||
flex-direction: column;
|
||||
padding: 0 var(--spacing-m) var(--spacing-s);
|
||||
border-top: 1px solid var(--md-sys-color-outline-variant);
|
||||
gap: 2px;
|
||||
}
|
||||
|
||||
.app-activities-list.show {
|
||||
display: flex;
|
||||
}
|
||||
|
||||
/* 单条活动条目 */
|
||||
.activity-entry-item {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
padding: 5px 4px;
|
||||
border-radius: var(--border-radius-s);
|
||||
}
|
||||
|
||||
.activity-entry-path {
|
||||
flex: 1;
|
||||
font-family: 'Google Sans Code', 'Roboto Mono', monospace;
|
||||
font-size: 0.75rem;
|
||||
color: var(--md-sys-color-on-surface-variant);
|
||||
word-break: break-all;
|
||||
line-height: 1.4;
|
||||
}
|
||||
|
||||
.activity-entry-delete {
|
||||
flex-shrink: 0;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
width: 24px;
|
||||
height: 24px;
|
||||
background: none;
|
||||
border: none;
|
||||
border-radius: 50%;
|
||||
color: var(--md-sys-color-error);
|
||||
cursor: pointer;
|
||||
padding: 0;
|
||||
transition: background-color 0.2s;
|
||||
}
|
||||
|
||||
.activity-entry-delete:hover {
|
||||
background-color: var(--md-sys-color-error-container);
|
||||
}
|
||||
|
||||
/* 按活动屏蔽输入卡片 */
|
||||
.activity-block-card {
|
||||
background-color: var(--md-sys-color-surface-container-high);
|
||||
border-radius: var(--border-radius-m);
|
||||
padding: var(--spacing-s) var(--spacing-m);
|
||||
margin-bottom: var(--spacing-m);
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
.activity-block-label {
|
||||
font-size: 0.8125rem;
|
||||
font-weight: 500;
|
||||
color: var(--md-sys-color-on-surface);
|
||||
}
|
||||
|
||||
.activity-block-row {
|
||||
display: flex;
|
||||
gap: 8px;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.activity-block-input {
|
||||
flex: 1;
|
||||
background: var(--md-sys-color-surface-container);
|
||||
border: 1px solid var(--md-sys-color-outline-variant);
|
||||
border-radius: var(--border-radius-s);
|
||||
padding: 7px 10px;
|
||||
font-family: 'Google Sans Code', 'Roboto Mono', monospace;
|
||||
font-size: 0.8125rem;
|
||||
color: var(--md-sys-color-on-surface);
|
||||
outline: none;
|
||||
transition: border-color 0.2s, box-shadow 0.2s;
|
||||
}
|
||||
|
||||
.activity-block-input:focus {
|
||||
border-color: var(--md-sys-color-primary);
|
||||
box-shadow: 0 0 0 2px rgba(168, 199, 250, 0.3);
|
||||
}
|
||||
Reference in new issue
Block a user