mirror of
https://github.com/YuleBest/LuminPro.git
synced 2026-12-04 00:54:42 +08:00
Compare commits
44
Commits
v2.5.0-beta.1
...
v2.5.0
No files matched your search
@@ -0,0 +1,80 @@
|
||||
name: Bug 反馈
|
||||
description: 提交一个 Bug,帮助我们定位和修复问题。
|
||||
title: '[Bug]: '
|
||||
labels: ['bug']
|
||||
body:
|
||||
- type: markdown
|
||||
attributes:
|
||||
value: |
|
||||
感谢你提交 Bug!请尽量填写完整,带 * 的为必填项。
|
||||
提交前请先搜索是否已有类似 Issue。
|
||||
|
||||
- type: textarea
|
||||
id: what-happened
|
||||
attributes:
|
||||
label: 遇到了什么?
|
||||
description: 请描述实际发生了什么,以及你期望发生什么。
|
||||
placeholder: 例如:点击保存按钮后页面崩溃,期望正常保存并提示成功。
|
||||
validations:
|
||||
required: true
|
||||
|
||||
- type: textarea
|
||||
id: steps-to-reproduce
|
||||
attributes:
|
||||
label: 操作步骤
|
||||
description: 请按顺序列出可复现问题的步骤。
|
||||
placeholder: |
|
||||
1. 打开...
|
||||
2. 点击...
|
||||
3. 看到...
|
||||
validations:
|
||||
required: true
|
||||
|
||||
- type: dropdown
|
||||
id: version-channel
|
||||
attributes:
|
||||
label: 版本渠道
|
||||
description: 你使用的是哪个版本渠道?
|
||||
options:
|
||||
- Release
|
||||
- Beta
|
||||
- Dev
|
||||
validations:
|
||||
required: true
|
||||
|
||||
- type: input
|
||||
id: version-number
|
||||
attributes:
|
||||
label: 版本号
|
||||
description: 请填写完整版本号,例如 1.2.3 或 1.2.3-beta.1
|
||||
placeholder: 例如 1.2.3
|
||||
validations:
|
||||
required: true
|
||||
|
||||
- type: textarea
|
||||
id: screenshots
|
||||
attributes:
|
||||
label: 截图(可选)
|
||||
description: 可以直接拖拽图片到此处上传,或粘贴图片链接。
|
||||
placeholder: 拖拽截图到这里...
|
||||
validations:
|
||||
required: false
|
||||
|
||||
- type: textarea
|
||||
id: logs
|
||||
attributes:
|
||||
label: 日志(可选)
|
||||
description: 请粘贴相关日志、错误堆栈或控制台输出。注意删除敏感信息。
|
||||
render: shell
|
||||
placeholder: 粘贴日志...
|
||||
validations:
|
||||
required: false
|
||||
|
||||
- type: textarea
|
||||
id: additional-info
|
||||
attributes:
|
||||
label: 更多信息(可选)
|
||||
description: 其他有助于定位问题的信息,例如系统环境等。
|
||||
placeholder: 其他信息...
|
||||
validations:
|
||||
required: false
|
||||
@@ -0,0 +1,69 @@
|
||||
name: 改进建议
|
||||
description: 提交一个功能建议或改进想法。
|
||||
title: '[建议]: '
|
||||
labels: ['enhancement']
|
||||
body:
|
||||
- type: markdown
|
||||
attributes:
|
||||
value: |
|
||||
感谢你的建议!请尽量描述清楚你的使用场景和期望效果。
|
||||
提交前请先搜索是否已有类似 Issue。
|
||||
|
||||
- type: dropdown
|
||||
id: suggestion-type
|
||||
attributes:
|
||||
label: 建议类型
|
||||
description: 这个建议主要属于哪一类?
|
||||
options:
|
||||
- 新功能
|
||||
- 体验优化
|
||||
- 性能改进
|
||||
- 文档改进
|
||||
- 其他
|
||||
validations:
|
||||
required: true
|
||||
|
||||
- type: textarea
|
||||
id: problem
|
||||
attributes:
|
||||
label: 当前问题 / 使用场景
|
||||
description: 描述你遇到了什么不便,或这个建议能解决什么问题。
|
||||
placeholder: 例如:目前导出数据需要手动逐个复制,效率很低。
|
||||
validations:
|
||||
required: true
|
||||
|
||||
- type: textarea
|
||||
id: proposal
|
||||
attributes:
|
||||
label: 期望的改进
|
||||
description: 描述你希望增加或改变什么,越具体越好。
|
||||
placeholder: 例如:希望支持一键导出全部数据为 CSV。
|
||||
validations:
|
||||
required: true
|
||||
|
||||
- type: textarea
|
||||
id: alternatives
|
||||
attributes:
|
||||
label: 替代方案(可选)
|
||||
description: 你考虑过的其他实现方式,或目前的临时解决办法。
|
||||
placeholder: 例如:目前只能通过脚本调用 API 实现。
|
||||
validations:
|
||||
required: false
|
||||
|
||||
- type: textarea
|
||||
id: screenshots
|
||||
attributes:
|
||||
label: 截图 / 示例(可选)
|
||||
description: 可以拖拽图片到此处上传,或粘贴参考链接、示例代码。
|
||||
placeholder: 拖拽截图到这里,或粘贴示例链接...
|
||||
validations:
|
||||
required: false
|
||||
|
||||
- type: textarea
|
||||
id: additional-info
|
||||
attributes:
|
||||
label: 更多信息(可选)
|
||||
description: 其他补充信息,例如优先级、影响范围、相关 Issue 等。
|
||||
placeholder: 其他信息...
|
||||
validations:
|
||||
required: false
|
||||
+58
-17
@@ -38,27 +38,49 @@ CGO_ENABLED=0 GOOS=android GOARCH=arm64 go build -trimpath -ldflags="-s -w" -o .
|
||||
|
||||
## 3. WebUI 开发
|
||||
|
||||
WebUI 负责所有可视化配置与状态显示。
|
||||
WebUI 是 Vue 3 + Vite 单页应用,UI 基于 **Material Design 3**(`@material/web` 组件 + 自有 MD3 token)。
|
||||
|
||||
### 目录结构
|
||||
|
||||
```
|
||||
webui/src/
|
||||
mwc.js @material/web 按需引入清单(唯一入口,勿在别处 import)
|
||||
theme/tokens.css MD3 令牌:颜色全角色 / 字阶 / 形状 / 动效 / 状态层
|
||||
theme/base.css 字体、重置、insets、缩放、排版与表面工具类
|
||||
theme/components.css 跨视图模式(设置行、状态徽标、折叠区、状态网格、列表行)
|
||||
theme/app.css 壳层布局(顶栏、页面轨、导航栏、操作锁横幅、snackbar)
|
||||
api/ksu.js exec 封装 + shellQuote + 开发环境 mock
|
||||
api/luminpro.js Go JSON API 客户端
|
||||
composables/ useStatus / useConfig / useLog / useApps / useSnackbar
|
||||
components/ 顶栏、导航栏、对话框、菜单、snackbar、操作锁横幅
|
||||
views/ 状态 / 配置 / 黑名单 / 日志 / 关于(样式写在各自的 <style scoped>)
|
||||
```
|
||||
|
||||
### 数据层规则
|
||||
|
||||
- 所有模块读写都走 Go 的 JSON API(`luminpro status|oplock|brightness|config|log|focus`),
|
||||
**不要新增 `cat` / `echo >` / `printf >` 这类直接读写文件的命令**——参数校验与原子写都在 Go 侧
|
||||
- 传给 Go 的参数一律用 `shellQuote()` 包装,禁止把未校验输入直接拼进命令
|
||||
- 模块状态放 `config.json`(由 Go 管理);`localStorage` 只放主题、缩放、刷新频率等纯前端偏好
|
||||
|
||||
### 本地预览
|
||||
|
||||
```bash
|
||||
# 安装依赖
|
||||
npm install
|
||||
|
||||
# 启动开发服务器
|
||||
npm run dev
|
||||
pnpm install
|
||||
pnpm dev
|
||||
```
|
||||
|
||||
> [!TIP]
|
||||
> 由于 WebUI 依赖 `kernelsu` JavaScript API,在普通浏览器中预览时,部分 API 调用(如 `exec`)会失效。建议配合 KernelSU 管理器的「自定义页面」功能进行实机调试。
|
||||
> 普通浏览器没有 KernelSU bridge,`exec` 会失败;此时 `api/devMock.js` 会返回模拟数据(仅 DEV 构建),
|
||||
> 界面可以正常调试。真机行为请在 KernelSU 管理器的「自定义页面」中验证。
|
||||
|
||||
### 编译前端
|
||||
|
||||
生成的静态文件会自动同步到根目录的 `webroot/`。
|
||||
|
||||
```bash
|
||||
npm run build
|
||||
pnpm build:webui # 仅编译前端
|
||||
pnpm build # 前端 + 模块打包(需要 bin/luminpro 已存在)
|
||||
```
|
||||
|
||||
---
|
||||
@@ -80,17 +102,21 @@ npm run build
|
||||
`version` 采用语义化命名(不含 versionCode),`versionCode` 单独维护:
|
||||
|
||||
```
|
||||
versionCode = 主版本 × 1000000 + 次版本 × 10000 + 修订 × 100 + 段位
|
||||
versionCode = 基础号 × 100 + 段位
|
||||
基础号 = 主版本 × 10000 + 次版本 × 100 + 修订
|
||||
```
|
||||
|
||||
以 `V2.5.0` 为例,基础号为 `20500`,末两位即段位:
|
||||
|
||||
| 段位 | 段位值 | version 示例 | versionCode |
|
||||
| --- | --- | --- | --- |
|
||||
| 正式 | `00` | `V2.5.0` | `2050000` |
|
||||
| beta | `51–99` | `V2.5.0-beta.1` | `2050051` |
|
||||
| dev | `01–49` | `V2.5.0-dev.1` | `2050001` |
|
||||
| beta | `51–59` | `V2.5.0-beta.1` | `2050051` |
|
||||
| 正式 | `90`(9x) | `V2.5.0` | `2050090` |
|
||||
|
||||
排序恒为 `dev < beta < 下一个正式版`:dev 测试者可平滑收到 beta,beta 用户会平滑收到
|
||||
下一个正式版。同周期内从 beta/dev 回退到正式版需手动刷包(管理器不支持降级)。
|
||||
末两位约定:**`5x` 表示 beta,`9x` 表示正式版**。排序恒为
|
||||
`dev < beta < 同周期正式版`:dev 测试者可平滑收到 beta,beta 用户会平滑收到同周期的
|
||||
正式版。只有从 beta/dev 回退到已发布的正式版才需要手动刷包(管理器不支持降级)。
|
||||
|
||||
tag 名 = version 的小写形式(如 `v2.5.0-beta.1`),Release 资产名为
|
||||
`LuminPro_<version>.zip`。
|
||||
@@ -128,8 +154,20 @@ CI 会依次:跑 Go 单测 → 交叉编译 → 按通道打包 → 建 GitHub
|
||||
| `internal/system` | `dumpsys` / `settings` 调用,接口化以便注入假实现 |
|
||||
| `internal/config` | config.json 读写、补默认值、旧配置迁移(安装脚本用它替代 jq) |
|
||||
| `internal/logging` | service.log 写入(格式与 WebUI 过滤兼容) |
|
||||
| `internal/api` | WebUI 的 JSON API:状态聚合、操作锁、daemon 状态文件、日志解析 |
|
||||
| `internal/daemon` | 主循环、操作锁、boost / restart 实现 |
|
||||
|
||||
WebUI 使用的子命令(全部输出 JSON):
|
||||
|
||||
| 子命令 | 用途 |
|
||||
| --- | --- |
|
||||
| `status [--no-display]` | 聚合状态;`--no-display` 跳过 dumpsys/settings 供高频刷新 |
|
||||
| `oplock` | 操作锁状态(含类型文案,供横幅显示) |
|
||||
| `focus` | 当前前台 Activity(黑名单的活动抓取向导) |
|
||||
| `brightness set <值>` | 设置亮度(校验范围后持锁写入) |
|
||||
| `config read \| patch <json>` | 读取 / 浅合并写入配置(patch 走 argv 或 stdin,严格校验类型) |
|
||||
| `log tail [-n N] [--raw] \| clear \| export [目录]` | 日志读取与导出 |
|
||||
|
||||
```bash
|
||||
cd go
|
||||
go test ./... # 全部单测(含真 inotify 集成测试)
|
||||
@@ -165,13 +203,16 @@ node build-module.js
|
||||
|
||||
### 操作锁 (oplock)
|
||||
|
||||
`pid/oplock` 是守护进程与 WebUI 之间的约定文件:任何会写亮度节点或重建监听的操作
|
||||
(渐变期间、`boost` 全程、`restart` 全程)都会把自己的 PID 写入该文件,结束时删除。
|
||||
WebUI 轮询此文件,发现持锁时暂停状态刷新并禁用写操作入口(配置保存、黑名单保存、
|
||||
亮度滑条、重启模块),顶部显示提示横幅。
|
||||
`pid/oplock` 是守护进程与 WebUI 之间的约定文件,内容是 JSON:
|
||||
`{"pid":…,"kind":"ramp|boost|restart|manual","startedAt":…}`。
|
||||
|
||||
任何会写亮度节点或重建监听的操作(渐变期间、`boost` 全程、`restart` 全程、WebUI 手动设置亮度)
|
||||
都会在开始时写入、结束时删除。WebUI 通过 `luminpro oplock` 查询,锁定时暂停状态刷新并禁用
|
||||
写操作入口(配置保存、黑名单保存、亮度滑条、重启模块),顶部按 `kind` 显示具体提示。
|
||||
|
||||
- 查询约定:文件存在且其中的 PID 在 `/proc` 中存活 → 锁定中;否则视为遗留锁,由查询方
|
||||
就地清理(避免进程被 SIGKILL 后 WebUI 永久卡在锁定态)。
|
||||
- 兼容旧版裸 PID 格式的锁文件。
|
||||
- `service.sh` 开机时清理该文件;WebUI 侧的实现见 `webui/src/composables/useOplock.js`。
|
||||
|
||||
---
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
=======================================
|
||||
LuminPro V2.3 — 日用屏幕亮度强化
|
||||
=======================================
|
||||
LuminPro — 日用屏幕亮度强化
|
||||
作者: 酷安@Yule
|
||||
=======================================
|
||||
|
||||
|
||||
@@ -1,18 +1,16 @@
|
||||
#!/system/bin/sh
|
||||
# 快速切换脚本
|
||||
#shellcheck shell=ash
|
||||
# 快速启停切换(管理器「操作」按钮 / WebUI 调用)
|
||||
|
||||
MODDIR="/data/adb/modules/LuminPro"
|
||||
PID_DIR="$MODDIR/pid"
|
||||
STOP_FLAG="$PID_DIR/stop.flag"
|
||||
UP_FLAG="$PID_DIR/up.flag"
|
||||
|
||||
# 切换逻辑
|
||||
if [ -f "$STOP_FLAG" ]; then
|
||||
rm -f "$STOP_FLAG"
|
||||
echo "LuminPro: 服务已启用"
|
||||
else
|
||||
touch "$STOP_FLAG"
|
||||
rm -f "$UP_FLAG"
|
||||
echo "LuminPro: 服务已暂停"
|
||||
fi
|
||||
|
||||
|
||||
Executable
BIN
Binary file not shown.
+13
-4
@@ -1,15 +1,24 @@
|
||||
# 更新日志
|
||||
|
||||
## V2.5.0-beta.1
|
||||
## V2.5.0
|
||||
|
||||
- 重构: 核心逻辑全量迁移至 Go,单一常驻守护进程负责监听、判定与渐变写入,移除 Rust 监听器与 jq 依赖(模块体积减少约 1.8MB)
|
||||
- 重构: **核心逻辑全量迁移至 Go**,单一常驻守护进程负责监听、判定与渐变写入,移除 Rust 监听器与 jq 依赖,模块体积减少约 1.8MB
|
||||
- 新增: **Go JSON API** —— 状态、操作锁、亮度、配置、日志改为一次调用取回结构化数据,刷新更快、更省资源
|
||||
- 新增: **操作锁** —— 后台写亮度期间 WebUI 自动暂停刷新、禁用写操作入口并显示顶部提示
|
||||
- 新增: HDR 休眠双阈值迟滞机制,进入/退出阈值可在 WebUI 自定义(默认 1.15 / 1.05)
|
||||
- 新增: **HDR 休眠双阈值迟滞**,进入/退出阈值可在 WebUI 自定义(默认 1.15 / 1.05),避免在阈值附近抖动
|
||||
- 新增: 版本通道(正式 / 预览),两类用户互不干扰,预览版可平滑升级到正式版
|
||||
- 重构: **WebUI 全量重写为 Material Design 3**(基于 @material/web),补全颜色/字阶/形状/动效令牌,支持涟漪与状态层反馈
|
||||
- 新增: 黑名单列表虚拟滚动,500+ 应用时滑动依然流畅
|
||||
- 新增: 版本通道(正式 / 预览),预览版与正式版互不干扰
|
||||
- 新增: 底部导航栏适配手势导航条(色块填充),顶栏适配状态栏安全区
|
||||
- 优化: 顶栏瘦身并采用 M3 固定样式;「重启模块」移入更多菜单并与刷新区分
|
||||
- 优化: 亮度滑条改为拖动中实时应用(按 3% 节流)、松手应用最终值
|
||||
- 优化: 提示改为 M3 snackbar,确认/输入改用 M3 对话框,菜单改用 M3 菜单
|
||||
- 优化: 状态页移除「自动亮度调节」开关;「智能选择」提为一级按钮
|
||||
- 优化: 配置页改用「已保存 / 未保存」徽标,「系统管理」并入高级设置
|
||||
- 修复: 低亮度保护失效——现在拖动中即拦在 5% 安全下限,确认后才放开
|
||||
- 修复: 设备默认亮度节点不可用时改为允许安装但功能保持关闭
|
||||
- 修复: 亮度设置与配置写入统一由 Go 侧校验并原子保存,不再拼接 shell 字符串
|
||||
- 修复: 文档预览支持 HTML 与 GitHub 提示块;活动抓取忽略桌面与系统界面
|
||||
|
||||
## V2.4-2401
|
||||
|
||||
|
||||
+2
-2
@@ -246,7 +246,7 @@ CHECK_DEVICE_COMPATIBILITY() {
|
||||
if [ "$prefix" = "25128PNA1" ] || [ "$prefix" = "2512BPNDA" ]; then
|
||||
echo ""
|
||||
echo " ✿ 您可能是 Xiaomi 17 Ultra 用户,建议使用 '0' 事件作为监测对象"
|
||||
echo " ✿ 是否将 inotifyd 监测事件修改为 '0'? (音量 + 确认,音量 - 跳过)"
|
||||
echo " ✿ 是否将监听事件修改为 '0'? (音量 + 确认,音量 - 跳过)"
|
||||
if [ "$(btn)" = "0" ]; then
|
||||
"$BIN" config set inotify_events=0 >/dev/null 2>&1
|
||||
echo " ✦ 已设置为 0 事件监测"
|
||||
@@ -327,7 +327,7 @@ END() {
|
||||
else
|
||||
echo " - 休眠时段: 未配置"
|
||||
fi
|
||||
echo " - inotifyd 事件: $inotify"
|
||||
echo " - 监听事件: $inotify"
|
||||
echo " - 当前亮度节点: $now_path"
|
||||
echo " - 最大亮度节点: $max_path"
|
||||
[ ! -f "$now_path" ] && echo " ⚠ 当前亮度节点不存在, 重启后功能将不会启用"
|
||||
|
||||
+186
-19
@@ -2,11 +2,19 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
"io"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"sort"
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/YuleBest/LuminPro/go/internal/api"
|
||||
"github.com/YuleBest/LuminPro/go/internal/brightness"
|
||||
"github.com/YuleBest/LuminPro/go/internal/config"
|
||||
"github.com/YuleBest/LuminPro/go/internal/daemon"
|
||||
"github.com/YuleBest/LuminPro/go/internal/logging"
|
||||
@@ -28,7 +36,7 @@ func run(args []string) error {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
paths := daemon.DefaultPaths(moduleDir)
|
||||
paths := api.DefaultPaths(moduleDir)
|
||||
log := logging.New(paths.LogFile, config.DefaultLogLevel, config.DefaultLogMaxSize)
|
||||
|
||||
switch args[0] {
|
||||
@@ -51,8 +59,19 @@ func run(args []string) error {
|
||||
return err
|
||||
}
|
||||
return daemon.Restart(paths, self, log)
|
||||
case "status":
|
||||
return runStatus(paths, args[1:])
|
||||
case "oplock":
|
||||
return emitJSON(api.ReadOplock(paths.Oplock))
|
||||
case "focus":
|
||||
focus := system.Focus{Runner: system.ExecRunner{}}
|
||||
return emitJSON(map[string]any{"focus": focus.CurrentFocus()})
|
||||
case "brightness":
|
||||
return runBrightness(paths, args[1:])
|
||||
case "config":
|
||||
return runConfig(paths, args[1:])
|
||||
case "log":
|
||||
return runLog(paths, args[1:])
|
||||
case "help", "-h", "--help":
|
||||
return usage()
|
||||
default:
|
||||
@@ -64,16 +83,21 @@ func usage() error {
|
||||
fmt.Print(`luminpro - LuminPro 模块守护进程
|
||||
|
||||
用法:
|
||||
luminpro daemon 启动守护进程(监听亮度节点并自动提升)
|
||||
luminpro boost 一键提升到峰值亮度 / 再次调用恢复
|
||||
luminpro restart 重启模块(daemon 未运行时按需拉起)
|
||||
luminpro config <操作> 配置管理
|
||||
init 写入默认配置(已存在则补齐字段)
|
||||
ensure 补齐缺失字段
|
||||
set key=value [...] 写入字段(按字段类型编码)
|
||||
inspect <旧目录> 输出旧配置字段(key=value 行)
|
||||
migrate <旧目录> [目标] 迁移旧配置
|
||||
remove-old-txt <旧目录> 删除旧版 txt 配置
|
||||
luminpro daemon 启动守护进程(监听亮度节点并自动提升)
|
||||
luminpro boost 一键提升到峰值亮度 / 再次调用恢复
|
||||
luminpro restart 重启模块(daemon 未运行时按需拉起)
|
||||
|
||||
luminpro status [--no-display] 聚合状态(JSON)
|
||||
luminpro oplock 操作锁状态(JSON)
|
||||
luminpro focus 当前前台 Activity(JSON)
|
||||
luminpro brightness set <值> 设置亮度(JSON)
|
||||
|
||||
luminpro config <操作> 配置管理(JSON)
|
||||
read | patch(stdin JSON) | get <key> | set k=v [...] | summary
|
||||
init | ensure | inspect <旧目录> | migrate <旧目录> [目标] | remove-old-txt <旧目录>
|
||||
|
||||
luminpro log <操作>
|
||||
tail [-n 行数] [--raw] | clear | export [目录]
|
||||
|
||||
模块目录默认由可执行文件位置推导,可用环境变量 LUMINPRO_MODDIR 覆盖(调试用)。
|
||||
`)
|
||||
@@ -95,7 +119,116 @@ func resolveModuleDir() (string, error) {
|
||||
return filepath.Dir(filepath.Dir(exe)), nil
|
||||
}
|
||||
|
||||
func runConfig(paths daemon.Paths, args []string) error {
|
||||
// emitJSON 输出 JSON(不转义 HTML,供前端直接解析)。
|
||||
func emitJSON(v any) error {
|
||||
enc := json.NewEncoder(os.Stdout)
|
||||
enc.SetEscapeHTML(false)
|
||||
return enc.Encode(v)
|
||||
}
|
||||
|
||||
func runStatus(paths api.Paths, args []string) error {
|
||||
includeDisplay := true
|
||||
for _, arg := range args {
|
||||
if arg == "--no-display" {
|
||||
includeDisplay = false
|
||||
}
|
||||
}
|
||||
cfg, err := config.Load(paths.ConfigFile)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
status := api.BuildStatus(paths, cfg, api.StatusDeps{
|
||||
AutoBrightness: system.AutoBrightness{Runner: system.ExecRunner{}},
|
||||
HDR: system.HdrRatio{Runner: system.ExecRunner{}},
|
||||
Now: time.Now,
|
||||
}, api.StatusOptions{IncludeDisplay: includeDisplay})
|
||||
return emitJSON(status)
|
||||
}
|
||||
|
||||
func runBrightness(paths api.Paths, args []string) error {
|
||||
if len(args) < 2 || args[0] != "set" {
|
||||
return errors.New("用法: luminpro brightness set <值>")
|
||||
}
|
||||
value, err := strconv.Atoi(strings.TrimSpace(args[1]))
|
||||
if err != nil {
|
||||
return fmt.Errorf("亮度值必须是整数: %q", args[1])
|
||||
}
|
||||
if value < 0 {
|
||||
return errors.New("亮度值不能为负")
|
||||
}
|
||||
cfg, err := config.Load(paths.ConfigFile)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if max, err := brightness.ReadInt(cfg.MaxBriFile); err == nil && max > 0 && value > max {
|
||||
return fmt.Errorf("亮度值需在 0~%d 之间", max)
|
||||
}
|
||||
if !api.FileExists(cfg.NowBriFile) {
|
||||
return fmt.Errorf("亮度节点不存在: %s", cfg.NowBriFile)
|
||||
}
|
||||
|
||||
if err := os.MkdirAll(paths.PIDDir, 0o755); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := api.WriteOplock(paths.Oplock, api.KindManual); err != nil {
|
||||
return err
|
||||
}
|
||||
defer api.RemoveOplock(paths.Oplock)
|
||||
|
||||
if err := brightness.WriteInt(cfg.NowBriFile, value); err != nil {
|
||||
return err
|
||||
}
|
||||
return emitJSON(map[string]any{"ok": true, "value": value})
|
||||
}
|
||||
|
||||
func runLog(paths api.Paths, args []string) error {
|
||||
if len(args) == 0 {
|
||||
return errors.New("用法: luminpro log tail|clear|export")
|
||||
}
|
||||
switch args[0] {
|
||||
case "tail":
|
||||
lines, raw := 100, false
|
||||
for i := 1; i < len(args); i++ {
|
||||
switch {
|
||||
case args[i] == "--raw":
|
||||
raw = true
|
||||
case args[i] == "-n" && i+1 < len(args):
|
||||
if n, err := strconv.Atoi(args[i+1]); err == nil {
|
||||
lines = n
|
||||
}
|
||||
i++
|
||||
case strings.HasPrefix(args[i], "-n="):
|
||||
if n, err := strconv.Atoi(strings.TrimPrefix(args[i], "-n=")); err == nil {
|
||||
lines = n
|
||||
}
|
||||
}
|
||||
}
|
||||
page, err := api.TailLog(paths.LogFile, lines, raw)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return emitJSON(page)
|
||||
case "clear":
|
||||
if err := api.ClearLog(paths.LogFile); err != nil {
|
||||
return err
|
||||
}
|
||||
return emitJSON(map[string]any{"ok": true})
|
||||
case "export":
|
||||
dir := "/sdcard"
|
||||
if len(args) > 1 {
|
||||
dir = args[1]
|
||||
}
|
||||
path, err := api.ExportLog(paths.LogFile, dir)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return emitJSON(map[string]any{"ok": true, "path": path})
|
||||
default:
|
||||
return fmt.Errorf("未知 log 操作: %s", args[0])
|
||||
}
|
||||
}
|
||||
|
||||
func runConfig(paths api.Paths, args []string) error {
|
||||
if len(args) == 0 {
|
||||
return usage()
|
||||
}
|
||||
@@ -104,14 +237,48 @@ func runConfig(paths daemon.Paths, args []string) error {
|
||||
return config.Init(paths.ConfigFile)
|
||||
case "ensure":
|
||||
return config.Ensure(paths.ConfigFile)
|
||||
case "read":
|
||||
cfg, err := config.Load(paths.ConfigFile)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
data, err := cfg.JSON()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
_, err = os.Stdout.Write(append(data, '\n'))
|
||||
return err
|
||||
case "patch":
|
||||
// 支持两种传参:命令行参数(WebUI 用,exec 无 stdin)或标准输入(脚本用)
|
||||
var input []byte
|
||||
var err error
|
||||
if len(args) >= 2 {
|
||||
input = []byte(args[1])
|
||||
} else {
|
||||
input, err = io.ReadAll(os.Stdin)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
var patch map[string]json.RawMessage
|
||||
if err := json.Unmarshal(input, &patch); err != nil {
|
||||
return fmt.Errorf("补丁必须是 JSON 对象: %w", err)
|
||||
}
|
||||
if err := config.Patch(paths.ConfigFile, patch); err != nil {
|
||||
return err
|
||||
}
|
||||
return emitJSON(map[string]any{"ok": true, "patched": len(patch)})
|
||||
case "set":
|
||||
if len(args) < 2 {
|
||||
return fmt.Errorf("set 需要至少一个 key=value")
|
||||
return errors.New("set 需要至少一个 key=value")
|
||||
}
|
||||
return config.Set(paths.ConfigFile, args[1:])
|
||||
if err := config.Set(paths.ConfigFile, args[1:]); err != nil {
|
||||
return err
|
||||
}
|
||||
return emitJSON(map[string]any{"ok": true})
|
||||
case "get":
|
||||
if len(args) < 2 {
|
||||
return fmt.Errorf("get 需要字段名")
|
||||
return errors.New("get 需要字段名")
|
||||
}
|
||||
cfg, err := config.Load(paths.ConfigFile)
|
||||
if err != nil {
|
||||
@@ -132,17 +299,17 @@ func runConfig(paths daemon.Paths, args []string) error {
|
||||
return nil
|
||||
case "inspect":
|
||||
if len(args) < 2 {
|
||||
return fmt.Errorf("inspect 需要旧配置目录")
|
||||
return errors.New("inspect 需要旧配置目录")
|
||||
}
|
||||
old, ok := config.InspectOld(args[1])
|
||||
if !ok {
|
||||
return fmt.Errorf("未找到可迁移的旧配置")
|
||||
return errors.New("未找到可迁移的旧配置")
|
||||
}
|
||||
printOld(old)
|
||||
return nil
|
||||
case "migrate":
|
||||
if len(args) < 2 {
|
||||
return fmt.Errorf("migrate 需要旧配置目录")
|
||||
return errors.New("migrate 需要旧配置目录")
|
||||
}
|
||||
target := paths.ConfigFile
|
||||
if len(args) >= 3 {
|
||||
@@ -156,7 +323,7 @@ func runConfig(paths daemon.Paths, args []string) error {
|
||||
return nil
|
||||
case "remove-old-txt":
|
||||
if len(args) < 2 {
|
||||
return fmt.Errorf("remove-old-txt 需要旧配置目录")
|
||||
return errors.New("remove-old-txt 需要旧配置目录")
|
||||
}
|
||||
return config.RemoveOldTxt(args[1])
|
||||
default:
|
||||
|
||||
@@ -0,0 +1,347 @@
|
||||
package api
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strconv"
|
||||
"sync"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/YuleBest/LuminPro/go/internal/config"
|
||||
"github.com/YuleBest/LuminPro/go/internal/system"
|
||||
)
|
||||
|
||||
// scriptRunner 是可编程的命令假实现。
|
||||
type scriptRunner struct {
|
||||
mu sync.Mutex
|
||||
outputs map[string]string
|
||||
}
|
||||
|
||||
func (r *scriptRunner) Output(name string, args ...string) (string, error) {
|
||||
r.mu.Lock()
|
||||
defer r.mu.Unlock()
|
||||
key := name
|
||||
for _, a := range args {
|
||||
key += " " + a
|
||||
}
|
||||
if v, ok := r.outputs[key]; ok {
|
||||
return v, nil
|
||||
}
|
||||
return "", errors.New("no output")
|
||||
}
|
||||
|
||||
func TestParseLogLine(t *testing.T) {
|
||||
cases := []struct {
|
||||
line string
|
||||
want LogEntry
|
||||
}{
|
||||
{
|
||||
"[09-10 12:34:56] [luminpro] [INFO] 触发提升",
|
||||
LogEntry{Time: "09-10 12:34:56", Tag: "luminpro", Level: "INFO", Message: "触发提升"},
|
||||
},
|
||||
{
|
||||
"[09-10 12:34:56] [luminpro] [SUCCESS] 亮度提升完成 (3000)",
|
||||
LogEntry{Time: "09-10 12:34:56", Tag: "luminpro", Level: "SUCCESS", Message: "亮度提升完成 (3000)"},
|
||||
},
|
||||
{
|
||||
"没有格式的一行",
|
||||
LogEntry{Message: "没有格式的一行"},
|
||||
},
|
||||
}
|
||||
for _, tc := range cases {
|
||||
if got := ParseLogLine(tc.line); got != tc.want {
|
||||
t.Errorf("ParseLogLine(%q) = %+v, 期望 %+v", tc.line, got, tc.want)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestTailLog(t *testing.T) {
|
||||
dir := t.TempDir()
|
||||
path := filepath.Join(dir, "service.log")
|
||||
content := "[09-10 12:00:00] [luminpro] [INFO] 第一条\n" +
|
||||
"[09-10 12:00:01] [luminpro] [WARN] 第二条\n" +
|
||||
"[09-10 12:00:02] [luminpro] [ERROR] 第三条\n"
|
||||
if err := os.WriteFile(path, []byte(content), 0o644); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
page, err := TailLog(path, 2, false)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if page.Total != 3 || len(page.Entries) != 2 {
|
||||
t.Fatalf("应取末 2 条(共 3 条): total=%d len=%d", page.Total, len(page.Entries))
|
||||
}
|
||||
if page.Entries[0].Level != "WARN" || page.Entries[1].Message != "第三条" {
|
||||
t.Fatalf("条目内容不正确: %+v", page.Entries)
|
||||
}
|
||||
|
||||
raw, err := TailLog(path, 1, true)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if raw.Raw == "" || len(raw.Entries) != 0 {
|
||||
t.Fatalf("--raw 模式应只返回原文: %+v", raw)
|
||||
}
|
||||
|
||||
missing, err := TailLog(filepath.Join(dir, "不存在.log"), 10, false)
|
||||
if err != nil || len(missing.Entries) != 0 {
|
||||
t.Fatalf("缺失文件应返回空页且不报错: %+v %v", missing, err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestClearAndExportLog(t *testing.T) {
|
||||
dir := t.TempDir()
|
||||
src := filepath.Join(dir, "service.log")
|
||||
if err := os.WriteFile(src, []byte("data\n"), 0o644); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
outDir := filepath.Join(dir, "out")
|
||||
if err := os.Mkdir(outDir, 0o755); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
path, err := ExportLog(src, outDir)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if data, err := os.ReadFile(path); err != nil || string(data) != "data\n" {
|
||||
t.Fatalf("导出内容不正确: %q %v", string(data), err)
|
||||
}
|
||||
if _, err := ExportLog(src, filepath.Join(dir, "缺失目录")); err == nil {
|
||||
t.Fatal("导出目录不可用时应报错")
|
||||
}
|
||||
|
||||
if err := ClearLog(src); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if data, _ := os.ReadFile(src); len(data) != 0 {
|
||||
t.Fatalf("清空后应为空文件: %q", string(data))
|
||||
}
|
||||
}
|
||||
|
||||
func TestOplockLifecycle(t *testing.T) {
|
||||
path := filepath.Join(t.TempDir(), "oplock")
|
||||
|
||||
if got := ReadOplock(path); got.Locked {
|
||||
t.Fatal("无锁文件应返回未锁定")
|
||||
}
|
||||
|
||||
if err := WriteOplock(path, KindRamp); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
got := ReadOplock(path)
|
||||
if !got.Locked || got.PID != os.Getpid() || got.Kind != KindRamp {
|
||||
t.Fatalf("锁状态不正确: %+v", got)
|
||||
}
|
||||
if got.Label != "正在调整亮度" {
|
||||
t.Fatalf("锁文案不正确: %q", got.Label)
|
||||
}
|
||||
|
||||
RemoveOplock(path)
|
||||
if got := ReadOplock(path); got.Locked {
|
||||
t.Fatal("释放后应返回未锁定")
|
||||
}
|
||||
}
|
||||
|
||||
// 遗留锁(持锁进程已死)应被就地清理。
|
||||
func TestOplockSelfHeals(t *testing.T) {
|
||||
path := filepath.Join(t.TempDir(), "oplock")
|
||||
if err := os.WriteFile(path, []byte(`{"pid":999999,"kind":"ramp","startedAt":1}`), 0o644); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if got := ReadOplock(path); got.Locked {
|
||||
t.Fatal("进程已死的锁应视为未锁定")
|
||||
}
|
||||
if _, err := os.Stat(path); err == nil {
|
||||
t.Fatal("遗留锁文件应被清理")
|
||||
}
|
||||
}
|
||||
|
||||
// 兼容旧版裸 PID 格式的锁文件。
|
||||
func TestOplockLegacyFormat(t *testing.T) {
|
||||
path := filepath.Join(t.TempDir(), "oplock")
|
||||
if err := os.WriteFile(path, []byte(strconv.Itoa(os.Getpid())), 0o644); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
got := ReadOplock(path)
|
||||
if !got.Locked || got.PID != os.Getpid() {
|
||||
t.Fatalf("旧格式应可识别: %+v", got)
|
||||
}
|
||||
|
||||
if err := os.WriteFile(path, []byte("garbage"), 0o644); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if got := ReadOplock(path); got.Locked {
|
||||
t.Fatal("无法解析的内容应视为未锁定")
|
||||
}
|
||||
}
|
||||
|
||||
func TestChannelOf(t *testing.T) {
|
||||
cases := map[string]string{
|
||||
"V2.5.0": "stable",
|
||||
"V2.5.0-beta.1": "beta",
|
||||
"V2.5.0-Beta.2": "beta",
|
||||
"V2.5.0-dev.3": "dev",
|
||||
"V2.4-2401": "stable",
|
||||
}
|
||||
for version, want := range cases {
|
||||
if got := ChannelOf(version); got != want {
|
||||
t.Errorf("ChannelOf(%q) = %q, 期望 %q", version, got, want)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestReadModuleInfo(t *testing.T) {
|
||||
dir := t.TempDir()
|
||||
prop := "id=LuminPro\nname=LuminPro丨测试\nversion=V2.5.0-beta.2\nversionCode=2050052\n"
|
||||
if err := os.WriteFile(filepath.Join(dir, "module.prop"), []byte(prop), 0o644); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
info := ReadModuleInfo(dir)
|
||||
if info.ID != "LuminPro" || info.Version != "V2.5.0-beta.2" || info.VersionCode != 2050052 || info.Channel != "beta" {
|
||||
t.Fatalf("module.prop 解析不正确: %+v", info)
|
||||
}
|
||||
// 缺失文件时回退默认值
|
||||
if info := ReadModuleInfo(filepath.Join(dir, "不存在")); info.Channel != "stable" {
|
||||
t.Fatalf("缺失 module.prop 应回退 stable: %+v", info)
|
||||
}
|
||||
}
|
||||
|
||||
// fixedNow 是状态聚合测试的基准时间:运行时长等字段依赖「当前时间」,
|
||||
// 必须与写入 state 的 startedAt 用同一基准,否则测试会随执行时机漂移。
|
||||
var fixedNow = time.Date(2026, 9, 10, 12, 0, 0, 0, time.Local)
|
||||
|
||||
func TestBuildStatus(t *testing.T) {
|
||||
dir := t.TempDir()
|
||||
paths := DefaultPaths(dir)
|
||||
if err := os.MkdirAll(paths.PIDDir, 0o755); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if err := os.MkdirAll(filepath.Dir(paths.ConfigFile), 0o755); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
node := filepath.Join(dir, "brightness")
|
||||
maxNode := filepath.Join(dir, "max_brightness")
|
||||
if err := os.WriteFile(node, []byte("1200"), 0o644); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if err := os.WriteFile(maxNode, []byte("4000"), 0o644); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
cfg := config.Default()
|
||||
cfg.NowBriFile = node
|
||||
cfg.MaxBriFile = maxNode
|
||||
cfg.UIMaxBri = 1000
|
||||
cfg.MaxBri = 3000
|
||||
cfg.SleepTime = "2300-0700"
|
||||
cfg.BlacklistApps = []string{"com.a"}
|
||||
if err := cfg.Save(paths.ConfigFile); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
// daemon 状态
|
||||
if err := os.WriteFile(paths.PIDFile, []byte(strconv.Itoa(os.Getpid())), 0o644); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if err := WriteState(paths.StateFile, DaemonState{
|
||||
PID: os.Getpid(),
|
||||
StartedAt: fixedNow.Add(-90 * time.Second).Unix(),
|
||||
Mode: "event",
|
||||
Ratio: &RatioInfo{Value: 1.08, At: fixedNow.Unix()},
|
||||
HdrSleep: true,
|
||||
}); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if err := WriteOplock(paths.Oplock, KindRamp); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
runner := &scriptRunner{outputs: map[string]string{
|
||||
"settings get system screen_brightness_mode": "1\n",
|
||||
"dumpsys display": "hdrSdrRatio 1.02\n",
|
||||
}}
|
||||
status := BuildStatus(paths, cfg, StatusDeps{
|
||||
AutoBrightness: system.AutoBrightness{Runner: runner},
|
||||
HDR: system.HdrRatio{Runner: runner},
|
||||
Now: func() time.Time { return fixedNow },
|
||||
}, StatusOptions{IncludeDisplay: true})
|
||||
|
||||
if status.Module.Version != "" && status.Module.Channel != "stable" {
|
||||
t.Fatalf("模块信息不正确: %+v", status.Module)
|
||||
}
|
||||
if !status.Daemon.Running || status.Daemon.PID != os.Getpid() || status.Daemon.Mode != "event" {
|
||||
t.Fatalf("daemon 状态不正确: %+v", status.Daemon)
|
||||
}
|
||||
if status.Daemon.UptimeSec < 80 {
|
||||
t.Fatalf("运行时长计算不正确: %d", status.Daemon.UptimeSec)
|
||||
}
|
||||
if status.Brightness.Current != 1200 || status.Brightness.Max != 4000 || status.Brightness.Percent != 30 {
|
||||
t.Fatalf("亮度信息不正确: %+v", status.Brightness)
|
||||
}
|
||||
if status.Sleep.Window != "2300-0700" || status.Sleep.Active {
|
||||
t.Fatalf("休眠状态不正确: %+v", status.Sleep)
|
||||
}
|
||||
if !status.Oplock.Locked || status.Oplock.Kind != KindRamp {
|
||||
t.Fatalf("操作锁不正确: %+v", status.Oplock)
|
||||
}
|
||||
if status.Config.UIMaxBri != 1000 || status.Config.BlacklistCount != 1 {
|
||||
t.Fatalf("配置摘要不正确: %+v", status.Config)
|
||||
}
|
||||
if status.Display == nil || status.Display.HdrRatio != 1.02 || !status.Display.HdrKnown || !status.Display.AutoBrightness || !status.Display.HdrSleep {
|
||||
t.Fatalf("显示信息不正确: %+v", status.Display)
|
||||
}
|
||||
|
||||
// --no-display:不调用 dumpsys/settings,改用 daemon 缓存
|
||||
light := BuildStatus(paths, cfg, StatusDeps{
|
||||
AutoBrightness: system.AutoBrightness{Runner: runner},
|
||||
HDR: system.HdrRatio{Runner: runner},
|
||||
}, StatusOptions{IncludeDisplay: false})
|
||||
if light.Display != nil {
|
||||
t.Fatalf("--no-display 不应包含显示信息: %+v", light.Display)
|
||||
}
|
||||
|
||||
// JSON 可序列化
|
||||
if _, err := json.Marshal(light); err != nil {
|
||||
t.Fatalf("状态无法序列化: %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
// dumpsys 读取失败时回退到 daemon 缓存并标记 stale。
|
||||
func TestBuildStatusFallsBackToCachedRatio(t *testing.T) {
|
||||
dir := t.TempDir()
|
||||
paths := DefaultPaths(dir)
|
||||
if err := os.MkdirAll(paths.PIDDir, 0o755); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
node := filepath.Join(dir, "brightness")
|
||||
if err := os.WriteFile(node, []byte("500"), 0o644); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
cfg := config.Default()
|
||||
cfg.NowBriFile = node
|
||||
if err := cfg.Save(paths.ConfigFile); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if err := WriteState(paths.StateFile, DaemonState{
|
||||
PID: os.Getpid(),
|
||||
Ratio: &RatioInfo{Value: 1.30, At: time.Now().Unix()},
|
||||
}); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
runner := &scriptRunner{outputs: map[string]string{}} // 全部失败
|
||||
status := BuildStatus(paths, cfg, StatusDeps{
|
||||
AutoBrightness: system.AutoBrightness{Runner: runner},
|
||||
HDR: system.HdrRatio{Runner: runner},
|
||||
}, StatusOptions{IncludeDisplay: true})
|
||||
|
||||
if status.Display == nil || !status.Display.HdrKnown || !status.Display.HdrStale || status.Display.HdrRatio != 1.30 {
|
||||
t.Fatalf("应回退到缓存的比率并标记 stale: %+v", status.Display)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,117 @@
|
||||
package api
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
"time"
|
||||
)
|
||||
|
||||
// LogEntry 是一条结构化日志。
|
||||
type LogEntry struct {
|
||||
Time string `json:"time"`
|
||||
Tag string `json:"tag"`
|
||||
Level string `json:"level"`
|
||||
Message string `json:"message"`
|
||||
}
|
||||
|
||||
// LogPage 是 log tail 的输出。
|
||||
type LogPage struct {
|
||||
Entries []LogEntry `json:"entries"`
|
||||
Raw string `json:"raw,omitempty"`
|
||||
SizeKB int `json:"sizeKB"`
|
||||
Total int `json:"total"`
|
||||
}
|
||||
|
||||
// ParseLogLine 解析 `[09-10 12:34:56] [luminpro] [INFO] msg`。
|
||||
// 不匹配时整行作为 message,level/tag 留空,前端可原样展示。
|
||||
func ParseLogLine(line string) LogEntry {
|
||||
rest := line
|
||||
var entry LogEntry
|
||||
|
||||
if strings.HasPrefix(rest, "[") {
|
||||
if end := strings.Index(rest, "]"); end > 0 {
|
||||
entry.Time = strings.TrimSpace(rest[1:end])
|
||||
rest = strings.TrimSpace(rest[end+1:])
|
||||
}
|
||||
}
|
||||
if strings.HasPrefix(rest, "[") {
|
||||
if end := strings.Index(rest, "]"); end > 0 {
|
||||
entry.Tag = strings.TrimSpace(rest[1:end])
|
||||
rest = strings.TrimSpace(rest[end+1:])
|
||||
}
|
||||
}
|
||||
if strings.HasPrefix(rest, "[") {
|
||||
if end := strings.Index(rest, "]"); end > 0 {
|
||||
entry.Level = strings.ToUpper(strings.TrimSpace(rest[1:end]))
|
||||
rest = strings.TrimSpace(rest[end+1:])
|
||||
}
|
||||
}
|
||||
entry.Message = rest
|
||||
return entry
|
||||
}
|
||||
|
||||
// TailLog 读取日志末尾若干行。
|
||||
func TailLog(path string, lines int, raw bool) (LogPage, error) {
|
||||
page := LogPage{Entries: []LogEntry{}}
|
||||
|
||||
data, err := os.ReadFile(path)
|
||||
if err != nil {
|
||||
if os.IsNotExist(err) {
|
||||
return page, nil
|
||||
}
|
||||
return page, err
|
||||
}
|
||||
page.SizeKB = int(int64(len(data)) / 1024)
|
||||
|
||||
text := strings.TrimRight(string(data), "\n")
|
||||
if text == "" {
|
||||
return page, nil
|
||||
}
|
||||
all := strings.Split(text, "\n")
|
||||
page.Total = len(all)
|
||||
|
||||
if lines > 0 && len(all) > lines {
|
||||
all = all[len(all)-lines:]
|
||||
}
|
||||
if raw {
|
||||
page.Raw = strings.Join(all, "\n")
|
||||
return page, nil
|
||||
}
|
||||
for _, line := range all {
|
||||
page.Entries = append(page.Entries, ParseLogLine(line))
|
||||
}
|
||||
return page, nil
|
||||
}
|
||||
|
||||
// ClearLog 清空日志文件。
|
||||
func ClearLog(path string) error {
|
||||
return os.WriteFile(path, nil, 0o644)
|
||||
}
|
||||
|
||||
// ExportLog 把日志复制到目标目录,返回最终路径。
|
||||
func ExportLog(src, dir string) (string, error) {
|
||||
if dir == "" {
|
||||
dir = "/sdcard"
|
||||
}
|
||||
if info, err := os.Stat(dir); err != nil || !info.IsDir() {
|
||||
return "", fmt.Errorf("导出目录不可用: %s", dir)
|
||||
}
|
||||
name := fmt.Sprintf("LuminPro_%s.log", time.Now().Format("20060102_150405"))
|
||||
dst := filepath.Join(dir, name)
|
||||
|
||||
data, err := os.ReadFile(src)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
if err := os.WriteFile(dst, data, 0o644); err != nil {
|
||||
return "", err
|
||||
}
|
||||
return dst, nil
|
||||
}
|
||||
|
||||
// FormatLogEntry 反向格式化,供需要时使用。
|
||||
func FormatLogEntry(e LogEntry) string {
|
||||
return fmt.Sprintf("[%s] [%s] [%s] %s", e.Time, e.Tag, e.Level, e.Message)
|
||||
}
|
||||
@@ -0,0 +1,149 @@
|
||||
package api
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"os"
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
)
|
||||
|
||||
// 操作锁类型,用于前端显示更具体的提示文案。
|
||||
const (
|
||||
KindRamp = "ramp" // 亮度渐变写入
|
||||
KindBoost = "boost" // 一键峰值 / 恢复
|
||||
KindRestart = "restart" // 重启模块
|
||||
KindManual = "manual" // 前端手动设置亮度
|
||||
)
|
||||
|
||||
// OplockFile 是 pid/oplock 的内容。
|
||||
type OplockFile struct {
|
||||
PID int `json:"pid"`
|
||||
Kind string `json:"kind"`
|
||||
StartedAt int64 `json:"startedAt"`
|
||||
}
|
||||
|
||||
// OplockStatus 是给前端的操作锁状态。
|
||||
type OplockStatus struct {
|
||||
Locked bool `json:"locked"`
|
||||
PID int `json:"pid,omitempty"`
|
||||
Kind string `json:"kind,omitempty"`
|
||||
Label string `json:"label,omitempty"`
|
||||
Seconds int `json:"seconds"`
|
||||
}
|
||||
|
||||
// KindLabel 返回操作类型的中文说明。
|
||||
func KindLabel(kind string) string {
|
||||
switch kind {
|
||||
case KindRamp:
|
||||
return "正在调整亮度"
|
||||
case KindBoost:
|
||||
return "正在执行一键提升"
|
||||
case KindRestart:
|
||||
return "正在重启模块"
|
||||
case KindManual:
|
||||
return "正在设置亮度"
|
||||
default:
|
||||
return "正在执行后台操作"
|
||||
}
|
||||
}
|
||||
|
||||
// WriteOplock 写入操作锁(持锁进程把自己的 PID 与操作类型写进去)。
|
||||
func WriteOplock(path, kind string) error {
|
||||
info := OplockFile{PID: os.Getpid(), Kind: kind, StartedAt: time.Now().Unix()}
|
||||
data, err := json.Marshal(info)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return os.WriteFile(path, data, 0o644)
|
||||
}
|
||||
|
||||
// RemoveOplock 释放操作锁。
|
||||
func RemoveOplock(path string) {
|
||||
_ = os.Remove(path)
|
||||
}
|
||||
|
||||
// ReadOplock 读取并校验操作锁;持锁进程已不存在时视为遗留锁并就地清理。
|
||||
func ReadOplock(path string) OplockStatus {
|
||||
data, err := os.ReadFile(path)
|
||||
if err != nil {
|
||||
return OplockStatus{}
|
||||
}
|
||||
text := strings.TrimSpace(string(data))
|
||||
if text == "" {
|
||||
_ = os.Remove(path)
|
||||
return OplockStatus{}
|
||||
}
|
||||
|
||||
var info OplockFile
|
||||
if err := json.Unmarshal([]byte(text), &info); err != nil {
|
||||
// 兼容旧版裸 PID 格式
|
||||
if pid, perr := strconv.Atoi(text); perr == nil {
|
||||
info = OplockFile{PID: pid}
|
||||
} else {
|
||||
_ = os.Remove(path)
|
||||
return OplockStatus{}
|
||||
}
|
||||
}
|
||||
|
||||
if info.PID <= 0 || !ProcessAlive(info.PID) {
|
||||
_ = os.Remove(path) // 遗留锁:进程已被 SIGKILL 等
|
||||
return OplockStatus{}
|
||||
}
|
||||
|
||||
seconds := 0
|
||||
if info.StartedAt > 0 {
|
||||
if d := time.Now().Unix() - info.StartedAt; d > 0 {
|
||||
seconds = int(d)
|
||||
}
|
||||
}
|
||||
return OplockStatus{
|
||||
Locked: true,
|
||||
PID: info.PID,
|
||||
Kind: info.Kind,
|
||||
Label: KindLabel(info.Kind),
|
||||
Seconds: seconds,
|
||||
}
|
||||
}
|
||||
|
||||
// ProcessAlive 通过 /proc 判断进程是否存活。
|
||||
func ProcessAlive(pid int) bool {
|
||||
if pid <= 0 {
|
||||
return false
|
||||
}
|
||||
_, err := os.Stat("/proc/" + strconv.Itoa(pid))
|
||||
return err == nil
|
||||
}
|
||||
|
||||
// DaemonPID 读取 daemon PID 文件并确认进程存活。
|
||||
func DaemonPID(pidFile string) (int, bool) {
|
||||
data, err := os.ReadFile(pidFile)
|
||||
if err != nil {
|
||||
return 0, false
|
||||
}
|
||||
pid, err := strconv.Atoi(strings.TrimSpace(string(data)))
|
||||
if err != nil || pid <= 0 {
|
||||
return 0, false
|
||||
}
|
||||
if !ProcessAlive(pid) {
|
||||
return 0, false
|
||||
}
|
||||
return pid, true
|
||||
}
|
||||
|
||||
// ProcessState 读取 /proc/<pid>/status 的状态字符(R/S/D/Z/T/I)。
|
||||
func ProcessState(pid int) string {
|
||||
data, err := os.ReadFile("/proc/" + strconv.Itoa(pid) + "/status")
|
||||
if err != nil {
|
||||
return ""
|
||||
}
|
||||
for _, line := range strings.Split(string(data), "\n") {
|
||||
if strings.HasPrefix(line, "State:") {
|
||||
fields := strings.Fields(line)
|
||||
if len(fields) >= 2 {
|
||||
return fields[1]
|
||||
}
|
||||
}
|
||||
}
|
||||
return ""
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
// Package api 提供 WebUI 使用的 JSON API:状态聚合、操作锁、daemon 运行状态与日志读取。
|
||||
//
|
||||
// 设计目标:把过去前端要跑 5~6 条 shell 命令(cat /proc、dumpsys、settings、读节点)
|
||||
// 才能拿到的信息合并成一次调用,并让所有写操作走 argv/stdin 而不是拼接 shell 字符串。
|
||||
package api
|
||||
|
||||
import (
|
||||
"os"
|
||||
"path/filepath"
|
||||
)
|
||||
|
||||
// Paths 是模块内的文件布局(与 WebUI 的契约)。
|
||||
type Paths struct {
|
||||
ModuleDir string
|
||||
PIDDir string
|
||||
ConfigFile string
|
||||
LogFile string
|
||||
PIDFile string
|
||||
StopFlag string
|
||||
PauseFlag string
|
||||
Oplock string
|
||||
BoostFlag string
|
||||
StateFile string
|
||||
}
|
||||
|
||||
// DefaultPaths 按模块目录推导全部路径。
|
||||
func DefaultPaths(moduleDir string) Paths {
|
||||
pidDir := filepath.Join(moduleDir, "pid")
|
||||
return Paths{
|
||||
ModuleDir: moduleDir,
|
||||
PIDDir: pidDir,
|
||||
ConfigFile: filepath.Join(moduleDir, "config", "config.json"),
|
||||
LogFile: filepath.Join(moduleDir, "service.log"),
|
||||
PIDFile: filepath.Join(pidDir, "daemon.pid"),
|
||||
StopFlag: filepath.Join(pidDir, "stop.flag"),
|
||||
PauseFlag: filepath.Join(pidDir, "daemon.pause"),
|
||||
Oplock: filepath.Join(pidDir, "oplock"),
|
||||
BoostFlag: filepath.Join(pidDir, "boost.flag"),
|
||||
StateFile: filepath.Join(pidDir, "state.json"),
|
||||
}
|
||||
}
|
||||
|
||||
// FileExists 判断普通文件是否存在。
|
||||
func FileExists(path string) bool {
|
||||
info, err := os.Stat(path)
|
||||
return err == nil && !info.IsDir()
|
||||
}
|
||||
@@ -0,0 +1,85 @@
|
||||
package api
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"os"
|
||||
)
|
||||
|
||||
// daemon 运行状态文件的 DTO。daemon 每次判定后刷新,status 直接读取,
|
||||
// 避免前端高频刷新时反复调用 dumpsys。
|
||||
|
||||
// EventInfo 最近一次监听到的事件。
|
||||
type EventInfo struct {
|
||||
Letters string `json:"letters"`
|
||||
At int64 `json:"at"`
|
||||
}
|
||||
|
||||
// ActionInfo 最近一次亮度操作。
|
||||
type ActionInfo struct {
|
||||
Kind string `json:"kind"`
|
||||
From int `json:"from"`
|
||||
To int `json:"to"`
|
||||
At int64 `json:"at"`
|
||||
}
|
||||
|
||||
// RatioInfo 最近一次读到的 HDR/SDR 比率。
|
||||
type RatioInfo struct {
|
||||
Value float64 `json:"value"`
|
||||
At int64 `json:"at"`
|
||||
}
|
||||
|
||||
// BoolInfo 带时间戳的布尔值。
|
||||
type BoolInfo struct {
|
||||
Value bool `json:"value"`
|
||||
At int64 `json:"at"`
|
||||
}
|
||||
|
||||
// IntInfo 带时间戳的整数。
|
||||
type IntInfo struct {
|
||||
Value int `json:"value"`
|
||||
At int64 `json:"at"`
|
||||
}
|
||||
|
||||
// DaemonState 是 pid/state.json 的内容。
|
||||
type DaemonState struct {
|
||||
PID int `json:"pid"`
|
||||
StartedAt int64 `json:"startedAt"`
|
||||
Mode string `json:"mode"` // event | polling
|
||||
Node string `json:"node"`
|
||||
Paused bool `json:"paused"`
|
||||
HdrSleep bool `json:"hdrSleep"`
|
||||
LastEvent *EventInfo `json:"lastEvent,omitempty"`
|
||||
LastAction *ActionInfo `json:"lastAction,omitempty"`
|
||||
Ratio *RatioInfo `json:"ratio,omitempty"`
|
||||
AutoBrightness *BoolInfo `json:"autoBrightness,omitempty"`
|
||||
Brightness *IntInfo `json:"brightness,omitempty"`
|
||||
}
|
||||
|
||||
// WriteState 原子写入运行状态。
|
||||
func WriteState(path string, s DaemonState) error {
|
||||
data, err := json.Marshal(s)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
tmp := path + ".tmp"
|
||||
if err := os.WriteFile(tmp, data, 0o644); err != nil {
|
||||
return err
|
||||
}
|
||||
return os.Rename(tmp, path)
|
||||
}
|
||||
|
||||
// ReadState 读取运行状态;文件缺失或损坏时返回 false。
|
||||
func ReadState(path string) (DaemonState, bool) {
|
||||
var s DaemonState
|
||||
data, err := os.ReadFile(path)
|
||||
if err != nil {
|
||||
return s, false
|
||||
}
|
||||
if err := json.Unmarshal(data, &s); err != nil {
|
||||
return s, false
|
||||
}
|
||||
if s.PID <= 0 || !ProcessAlive(s.PID) {
|
||||
return s, false
|
||||
}
|
||||
return s, true
|
||||
}
|
||||
@@ -0,0 +1,271 @@
|
||||
package api
|
||||
|
||||
import (
|
||||
"bufio"
|
||||
"fmt"
|
||||
"os"
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/YuleBest/LuminPro/go/internal/config"
|
||||
"github.com/YuleBest/LuminPro/go/internal/policy"
|
||||
"github.com/YuleBest/LuminPro/go/internal/system"
|
||||
)
|
||||
|
||||
// ModuleInfo 来自 module.prop。
|
||||
type ModuleInfo struct {
|
||||
ID string `json:"id"`
|
||||
Name string `json:"name"`
|
||||
Version string `json:"version"`
|
||||
VersionCode int `json:"versionCode"`
|
||||
Channel string `json:"channel"`
|
||||
}
|
||||
|
||||
// ReadModuleInfo 解析模块根目录下的 module.prop,并从版本号推导发布通道。
|
||||
func ReadModuleInfo(moduleDir string) ModuleInfo {
|
||||
info := ModuleInfo{ID: "LuminPro", Channel: "stable"}
|
||||
f, err := os.Open(moduleDir + "/module.prop")
|
||||
if err != nil {
|
||||
return info
|
||||
}
|
||||
defer f.Close()
|
||||
|
||||
scanner := bufio.NewScanner(f)
|
||||
for scanner.Scan() {
|
||||
line := strings.TrimSpace(scanner.Text())
|
||||
if line == "" || strings.HasPrefix(line, "#") {
|
||||
continue
|
||||
}
|
||||
key, value, ok := strings.Cut(line, "=")
|
||||
if !ok {
|
||||
continue
|
||||
}
|
||||
value = strings.TrimSpace(value)
|
||||
switch strings.TrimSpace(key) {
|
||||
case "id":
|
||||
info.ID = value
|
||||
case "name":
|
||||
info.Name = value
|
||||
case "version":
|
||||
info.Version = value
|
||||
case "versionCode":
|
||||
if n, err := strconv.Atoi(value); err == nil {
|
||||
info.VersionCode = n
|
||||
}
|
||||
}
|
||||
}
|
||||
info.Channel = ChannelOf(info.Version)
|
||||
return info
|
||||
}
|
||||
|
||||
// ChannelOf 依据版本号判断发布通道。
|
||||
func ChannelOf(version string) string {
|
||||
v := strings.ToLower(version)
|
||||
switch {
|
||||
case strings.Contains(v, "-beta"):
|
||||
return "beta"
|
||||
case strings.Contains(v, "-dev"):
|
||||
return "dev"
|
||||
default:
|
||||
return "stable"
|
||||
}
|
||||
}
|
||||
|
||||
// DaemonPart 是守护进程状态。
|
||||
type DaemonPart struct {
|
||||
PID int `json:"pid"`
|
||||
Running bool `json:"running"`
|
||||
State string `json:"state"`
|
||||
Mode string `json:"mode"`
|
||||
Paused bool `json:"paused"`
|
||||
UptimeSec int `json:"uptimeSec"`
|
||||
}
|
||||
|
||||
// BrightnessPart 是亮度信息。
|
||||
type BrightnessPart struct {
|
||||
Current int `json:"current"`
|
||||
Max int `json:"max"`
|
||||
Percent int `json:"percent"`
|
||||
Node string `json:"node"`
|
||||
MaxNode string `json:"maxNode"`
|
||||
Error string `json:"error,omitempty"`
|
||||
}
|
||||
|
||||
// DisplayPart 是屏幕相关状态(需要 dumpsys / settings)。
|
||||
type DisplayPart struct {
|
||||
HdrRatio float64 `json:"hdrRatio"`
|
||||
HdrKnown bool `json:"hdrKnown"`
|
||||
HdrStale bool `json:"hdrStale"`
|
||||
HdrSleep bool `json:"hdrSleep"`
|
||||
AutoBrightness bool `json:"autoBrightness"`
|
||||
}
|
||||
|
||||
// SleepPart 是休眠时段状态。
|
||||
type SleepPart struct {
|
||||
Window string `json:"window"`
|
||||
Active bool `json:"active"`
|
||||
}
|
||||
|
||||
// ConfigPart 是前端展示需要的配置子集。
|
||||
type ConfigPart struct {
|
||||
UIMaxBri int `json:"uiMaxBri"`
|
||||
MaxBri int `json:"maxBri"`
|
||||
StepsNum int `json:"stepsNum"`
|
||||
SleepTime string `json:"sleepTime"`
|
||||
AutoBriSleep int `json:"autoBriSleep"`
|
||||
DisplayHdrSleep int `json:"displayHdrSleep"`
|
||||
HdrEnterRatio float64 `json:"hdrEnterRatio"`
|
||||
HdrExitRatio float64 `json:"hdrExitRatio"`
|
||||
CompatibilityMode int `json:"compatibilityMode"`
|
||||
LogLevel string `json:"logLevel"`
|
||||
LogMaxSize int `json:"logMaxSize"`
|
||||
DebugMode int `json:"debugMode"`
|
||||
NowBriFile string `json:"nowBriFile"`
|
||||
MaxBriFile string `json:"maxBriFile"`
|
||||
BlacklistCount int `json:"blacklistCount"`
|
||||
}
|
||||
|
||||
// LogPart 是日志文件信息。
|
||||
type LogPart struct {
|
||||
Path string `json:"path"`
|
||||
SizeKB int `json:"sizeKB"`
|
||||
}
|
||||
|
||||
// Status 是 status 子命令的输出。
|
||||
type Status struct {
|
||||
Module ModuleInfo `json:"module"`
|
||||
Daemon DaemonPart `json:"daemon"`
|
||||
Brightness BrightnessPart `json:"brightness"`
|
||||
Display *DisplayPart `json:"display,omitempty"`
|
||||
Sleep SleepPart `json:"sleep"`
|
||||
Oplock OplockStatus `json:"oplock"`
|
||||
Config ConfigPart `json:"config"`
|
||||
Log LogPart `json:"log"`
|
||||
}
|
||||
|
||||
// StatusDeps 是状态聚合用到的系统调用(测试可注入)。
|
||||
type StatusDeps struct {
|
||||
AutoBrightness system.AutoBrightness
|
||||
HDR system.HdrRatio
|
||||
Now func() time.Time
|
||||
}
|
||||
|
||||
// StatusOptions 控制是否读取需要系统调用的字段。
|
||||
type StatusOptions struct {
|
||||
// IncludeDisplay=false 时跳过 dumpsys/settings,仅用 daemon 缓存的数值,
|
||||
// 供前端高频刷新(例如操作锁轮询)使用。
|
||||
IncludeDisplay bool
|
||||
}
|
||||
|
||||
// BuildStatus 聚合一次完整状态。
|
||||
func BuildStatus(p Paths, cfg config.Config, deps StatusDeps, opts StatusOptions) Status {
|
||||
now := deps.Now
|
||||
if now == nil {
|
||||
now = time.Now
|
||||
}
|
||||
|
||||
st := Status{
|
||||
Module: ReadModuleInfo(p.ModuleDir),
|
||||
Oplock: ReadOplock(p.Oplock),
|
||||
Sleep: SleepPart{
|
||||
Window: cfg.SleepTime,
|
||||
Active: policy.InSleepWindow(cfg.SleepTime, now()),
|
||||
},
|
||||
Config: ConfigPart{
|
||||
UIMaxBri: cfg.UIMaxBri,
|
||||
MaxBri: cfg.MaxBri,
|
||||
StepsNum: cfg.StepsNum,
|
||||
SleepTime: cfg.SleepTime,
|
||||
AutoBriSleep: cfg.AutoBriSleep,
|
||||
DisplayHdrSleep: cfg.DisplayHdrSleep,
|
||||
HdrEnterRatio: cfg.HdrEnterRatio,
|
||||
HdrExitRatio: cfg.HdrExitRatio,
|
||||
CompatibilityMode: cfg.CompatibilityMode,
|
||||
LogLevel: cfg.LogLevel,
|
||||
LogMaxSize: cfg.LogMaxSize,
|
||||
DebugMode: cfg.DebugMode,
|
||||
NowBriFile: cfg.NowBriFile,
|
||||
MaxBriFile: cfg.MaxBriFile,
|
||||
BlacklistCount: len(cfg.BlacklistApps),
|
||||
},
|
||||
}
|
||||
|
||||
// 守护进程
|
||||
daemonState, hasState := ReadState(p.StateFile)
|
||||
if pid, alive := DaemonPID(p.PIDFile); alive {
|
||||
st.Daemon = DaemonPart{
|
||||
PID: pid,
|
||||
Running: true,
|
||||
State: ProcessState(pid),
|
||||
}
|
||||
if hasState {
|
||||
st.Daemon.Mode = daemonState.Mode
|
||||
if daemonState.StartedAt > 0 {
|
||||
if d := now().Unix() - daemonState.StartedAt; d > 0 {
|
||||
st.Daemon.UptimeSec = int(d)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
st.Daemon.Paused = FileExists(p.StopFlag)
|
||||
|
||||
// 亮度节点
|
||||
st.Brightness = BrightnessPart{Node: cfg.NowBriFile, MaxNode: cfg.MaxBriFile}
|
||||
current, err := readIntFile(cfg.NowBriFile)
|
||||
if err != nil {
|
||||
st.Brightness.Error = err.Error()
|
||||
}
|
||||
maxBri, err := readIntFile(cfg.MaxBriFile)
|
||||
if err != nil && st.Brightness.Error == "" {
|
||||
st.Brightness.Error = err.Error()
|
||||
}
|
||||
st.Brightness.Current = current
|
||||
st.Brightness.Max = maxBri
|
||||
if maxBri > 0 {
|
||||
st.Brightness.Percent = current * 100 / maxBri
|
||||
}
|
||||
|
||||
// 日志
|
||||
st.Log = LogPart{Path: p.LogFile}
|
||||
if fi, err := os.Stat(p.LogFile); err == nil {
|
||||
st.Log.SizeKB = int(fi.Size() / 1024)
|
||||
}
|
||||
|
||||
if !opts.IncludeDisplay {
|
||||
return st
|
||||
}
|
||||
|
||||
display := &DisplayPart{}
|
||||
if deps.HDR.Runner != nil {
|
||||
if ratio, ok := deps.HDR.Ratio(); ok {
|
||||
display.HdrRatio = ratio
|
||||
display.HdrKnown = true
|
||||
} else if hasState && daemonState.Ratio != nil {
|
||||
display.HdrRatio = daemonState.Ratio.Value
|
||||
display.HdrKnown = true
|
||||
display.HdrStale = true
|
||||
}
|
||||
}
|
||||
if deps.AutoBrightness.Runner != nil {
|
||||
display.AutoBrightness = deps.AutoBrightness.Enabled()
|
||||
} else if hasState && daemonState.AutoBrightness != nil {
|
||||
display.AutoBrightness = daemonState.AutoBrightness.Value
|
||||
}
|
||||
display.HdrSleep = hasState && daemonState.HdrSleep
|
||||
st.Display = display
|
||||
return st
|
||||
}
|
||||
|
||||
func readIntFile(path string) (int, error) {
|
||||
data, err := os.ReadFile(path)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
text := strings.TrimSpace(string(data))
|
||||
v, err := strconv.Atoi(text)
|
||||
if err != nil {
|
||||
return 0, fmt.Errorf("节点内容不是整数: %q", text)
|
||||
}
|
||||
return v, nil
|
||||
}
|
||||
@@ -227,8 +227,38 @@ func parseValue(s string) any {
|
||||
}
|
||||
|
||||
// applyRaw 用原始键值填充强类型字段,未识别的键留在 extra。
|
||||
// 单个字段损坏时保留默认值,不阻断整体加载(与旧 get_cfg 的降级一致)。
|
||||
func (c *Config) applyRaw(raw map[string]json.RawMessage) {
|
||||
known := map[string]any{
|
||||
_ = c.apply(raw, false)
|
||||
}
|
||||
|
||||
// apply 填充字段;strict=true 时字段类型不匹配直接报错(用于写路径)。
|
||||
func (c *Config) apply(raw map[string]json.RawMessage, strict bool) error {
|
||||
known := fieldTargets(c)
|
||||
|
||||
c.extra = nil
|
||||
for key, value := range raw {
|
||||
dst, ok := known[key]
|
||||
if !ok {
|
||||
if c.extra == nil {
|
||||
c.extra = map[string]json.RawMessage{}
|
||||
}
|
||||
c.extra[key] = value
|
||||
continue
|
||||
}
|
||||
if err := json.Unmarshal(value, dst); err != nil && strict {
|
||||
return fmt.Errorf("字段 %s 的值类型不正确: %w", key, err)
|
||||
}
|
||||
}
|
||||
if c.BlacklistApps == nil {
|
||||
c.BlacklistApps = []string{}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// fieldTargets 返回已知字段名到目标字段指针的映射。
|
||||
func fieldTargets(c *Config) map[string]any {
|
||||
return map[string]any{
|
||||
"ui_max_bri": &c.UIMaxBri,
|
||||
"max_bri": &c.MaxBri,
|
||||
"steps_num": &c.StepsNum,
|
||||
@@ -246,22 +276,30 @@ func (c *Config) applyRaw(raw map[string]json.RawMessage) {
|
||||
"debug_mode": &c.DebugMode,
|
||||
"blacklist_apps": &c.BlacklistApps,
|
||||
}
|
||||
}
|
||||
|
||||
c.extra = nil
|
||||
for key, value := range raw {
|
||||
if dst, ok := known[key]; ok {
|
||||
// 单个字段损坏时保留默认值,不阻断整体加载。
|
||||
_ = json.Unmarshal(value, dst)
|
||||
continue
|
||||
}
|
||||
if c.extra == nil {
|
||||
c.extra = map[string]json.RawMessage{}
|
||||
}
|
||||
c.extra[key] = value
|
||||
// JSON 返回完整配置(含全部已知字段,缺失项已补默认值)。
|
||||
func (c Config) JSON() ([]byte, error) {
|
||||
return json.Marshal(c.toRawMap())
|
||||
}
|
||||
|
||||
// Patch 用一份 JSON 对象浅合并配置并原子保存。
|
||||
// 与 Load 不同,这里对已知字段做严格类型校验,避免写坏配置。
|
||||
func Patch(path string, patch map[string]json.RawMessage) error {
|
||||
c, err := Load(path)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if c.BlacklistApps == nil {
|
||||
c.BlacklistApps = []string{}
|
||||
raw := c.toRawMap()
|
||||
for key, value := range patch {
|
||||
raw[key] = value
|
||||
}
|
||||
|
||||
probe := Default()
|
||||
if err := probe.apply(raw, true); err != nil {
|
||||
return err
|
||||
}
|
||||
return probe.Save(path)
|
||||
}
|
||||
|
||||
// toRawMap 导出为原始键值表(含未知键)。
|
||||
|
||||
@@ -166,6 +166,111 @@ func TestInitCreatesAndEnsureFills(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestPatchMergesShallowly(t *testing.T) {
|
||||
path := filepath.Join(t.TempDir(), "config.json")
|
||||
if err := Set(path, []string{"ui_max_bri=1000", "max_bri=3000", "sleep_time=2200-0700"}); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
// 注入一个未知字段,验证 patch 后仍保留
|
||||
raw, _ := os.ReadFile(path)
|
||||
var withUnknown map[string]json.RawMessage
|
||||
_ = json.Unmarshal(raw, &withUnknown)
|
||||
withUnknown["future_field"] = json.RawMessage(`"keep-me"`)
|
||||
merged, _ := json.Marshal(withUnknown)
|
||||
if err := os.WriteFile(path, merged, 0o644); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
patch := map[string]json.RawMessage{
|
||||
"ui_max_bri": json.RawMessage(`1500`),
|
||||
"blacklist_apps": json.RawMessage(`["com.a","com.b"]`),
|
||||
}
|
||||
if err := Patch(path, patch); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
c, err := Load(path)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if c.UIMaxBri != 1500 {
|
||||
t.Fatalf("patch 未生效: %d", c.UIMaxBri)
|
||||
}
|
||||
if c.MaxBri != 3000 || c.SleepTime != "2200-0700" {
|
||||
t.Fatalf("未 patch 的字段被改动: %+v", c)
|
||||
}
|
||||
if len(c.BlacklistApps) != 2 {
|
||||
t.Fatalf("数组字段未写入: %v", c.BlacklistApps)
|
||||
}
|
||||
|
||||
// 未知字段保留
|
||||
data, _ := os.ReadFile(path)
|
||||
var check map[string]json.RawMessage
|
||||
_ = json.Unmarshal(data, &check)
|
||||
if _, ok := check["future_field"]; !ok {
|
||||
t.Fatal("patch 后未知字段丢失")
|
||||
}
|
||||
}
|
||||
|
||||
func TestPatchRejectsWrongTypeAndKeepsFile(t *testing.T) {
|
||||
path := filepath.Join(t.TempDir(), "config.json")
|
||||
if err := Set(path, []string{"ui_max_bri=1000"}); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
before, _ := os.ReadFile(path)
|
||||
|
||||
err := Patch(path, map[string]json.RawMessage{
|
||||
"ui_max_bri": json.RawMessage(`"不是数字"`),
|
||||
})
|
||||
if err == nil {
|
||||
t.Fatal("类型错误应被拒绝")
|
||||
}
|
||||
after, _ := os.ReadFile(path)
|
||||
if string(before) != string(after) {
|
||||
t.Fatal("校验失败时不应改动配置文件")
|
||||
}
|
||||
|
||||
if err := Patch(path, map[string]json.RawMessage{
|
||||
"blacklist_apps": json.RawMessage(`{"not":"an array"}`),
|
||||
}); err == nil {
|
||||
t.Fatal("数组字段类型错误应被拒绝")
|
||||
}
|
||||
}
|
||||
|
||||
func TestConfigJSONIsComplete(t *testing.T) {
|
||||
path := filepath.Join(t.TempDir(), "config.json")
|
||||
if err := os.WriteFile(path, []byte(`{"ui_max_bri":800}`), 0o644); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
c, err := Load(path)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
data, err := c.JSON()
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
var raw map[string]json.RawMessage
|
||||
if err := json.Unmarshal(data, &raw); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
for _, key := range []string{
|
||||
"ui_max_bri", "max_bri", "steps_num", "log_max_size", "auto_bri_sleep",
|
||||
"display_hdr_sleep", "hdr_enter_ratio", "hdr_exit_ratio", "compatibility_mode",
|
||||
"sleep_time", "inotify_events", "now_bri_file", "max_bri_file", "log_level",
|
||||
"debug_mode", "blacklist_apps",
|
||||
} {
|
||||
if _, ok := raw[key]; !ok {
|
||||
t.Errorf("JSON 缺少字段 %s", key)
|
||||
}
|
||||
}
|
||||
var ui int
|
||||
_ = json.Unmarshal(raw["ui_max_bri"], &ui)
|
||||
if ui != 800 {
|
||||
t.Fatalf("已有值未保留: %d", ui)
|
||||
}
|
||||
}
|
||||
|
||||
func TestInspectAndMigrateOldTxt(t *testing.T) {
|
||||
oldDir := t.TempDir()
|
||||
write := func(name, content string) {
|
||||
|
||||
+108
-49
@@ -8,13 +8,13 @@ import (
|
||||
"fmt"
|
||||
"os"
|
||||
"os/signal"
|
||||
"path/filepath"
|
||||
"strconv"
|
||||
"strings"
|
||||
"sync"
|
||||
"syscall"
|
||||
"time"
|
||||
|
||||
"github.com/YuleBest/LuminPro/go/internal/api"
|
||||
"github.com/YuleBest/LuminPro/go/internal/brightness"
|
||||
"github.com/YuleBest/LuminPro/go/internal/config"
|
||||
"github.com/YuleBest/LuminPro/go/internal/inotify"
|
||||
@@ -24,33 +24,10 @@ import (
|
||||
)
|
||||
|
||||
// Paths 是模块内的文件布局(与 WebUI 的契约,不可随意改名)。
|
||||
type Paths struct {
|
||||
ModuleDir string
|
||||
PIDDir string
|
||||
ConfigFile string
|
||||
LogFile string
|
||||
PIDFile string
|
||||
StopFlag string
|
||||
PauseFlag string
|
||||
Oplock string
|
||||
BoostFlag string
|
||||
}
|
||||
type Paths = api.Paths
|
||||
|
||||
// DefaultPaths 按模块目录推导全部路径。
|
||||
func DefaultPaths(moduleDir string) Paths {
|
||||
pidDir := filepath.Join(moduleDir, "pid")
|
||||
return Paths{
|
||||
ModuleDir: moduleDir,
|
||||
PIDDir: pidDir,
|
||||
ConfigFile: filepath.Join(moduleDir, "config", "config.json"),
|
||||
LogFile: filepath.Join(moduleDir, "service.log"),
|
||||
PIDFile: filepath.Join(pidDir, "inotifyd.pid"),
|
||||
StopFlag: filepath.Join(pidDir, "stop.flag"),
|
||||
PauseFlag: filepath.Join(pidDir, "daemon.pause"),
|
||||
Oplock: filepath.Join(pidDir, "oplock"),
|
||||
BoostFlag: filepath.Join(pidDir, "boost.flag"),
|
||||
}
|
||||
}
|
||||
func DefaultPaths(moduleDir string) Paths { return api.DefaultPaths(moduleDir) }
|
||||
|
||||
// Deps 是守护进程的外部依赖,测试时可注入假实现。
|
||||
type Deps struct {
|
||||
@@ -99,17 +76,30 @@ type Daemon struct {
|
||||
ratioCache float64
|
||||
haveRatioCache bool
|
||||
nodeMissingLogged bool
|
||||
|
||||
// 运行状态(供 WebUI 的 status 读取,避免前端反复调用 dumpsys)
|
||||
stateMu sync.Mutex
|
||||
state api.DaemonState
|
||||
}
|
||||
|
||||
// New 创建守护进程并加载初始配置。
|
||||
func New(paths Paths, deps Deps) (*Daemon, error) {
|
||||
deps.withDefaults()
|
||||
d := &Daemon{paths: paths, deps: deps}
|
||||
d := &Daemon{
|
||||
paths: paths,
|
||||
deps: deps,
|
||||
state: api.DaemonState{
|
||||
PID: os.Getpid(),
|
||||
StartedAt: time.Now().Unix(),
|
||||
Mode: "event",
|
||||
},
|
||||
}
|
||||
cfg, err := config.Load(paths.ConfigFile)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
d.setConfig(cfg)
|
||||
d.state.Node = cfg.NowBriFile
|
||||
return d, nil
|
||||
}
|
||||
|
||||
@@ -132,6 +122,7 @@ func (d *Daemon) Run() error {
|
||||
defer d.cleanup()
|
||||
|
||||
d.log().Info("守护进程已启动")
|
||||
d.flushState()
|
||||
|
||||
sigCh := make(chan os.Signal, 4)
|
||||
signal.Notify(sigCh, syscall.SIGHUP, syscall.SIGTERM, syscall.SIGINT)
|
||||
@@ -197,8 +188,10 @@ func (d *Daemon) serve(sigCh chan os.Signal, cfgCh chan struct{}) exitReason {
|
||||
|
||||
if cfg.CompatibilityMode == 1 {
|
||||
d.log().Warn("兼容模式已开启 (轮询驱动)")
|
||||
d.setStateMode("polling")
|
||||
go d.compatLoop(stop)
|
||||
} else {
|
||||
d.setStateMode("event")
|
||||
w, err := inotify.New()
|
||||
if err != nil {
|
||||
d.log().Error("初始化 inotify 失败: " + err.Error())
|
||||
@@ -223,6 +216,7 @@ func (d *Daemon) serve(sigCh chan os.Signal, cfgCh chan struct{}) exitReason {
|
||||
}
|
||||
return
|
||||
}
|
||||
d.recordEvent(ev.Letters)
|
||||
d.evaluate()
|
||||
}, runStop)
|
||||
}()
|
||||
@@ -267,16 +261,20 @@ func (d *Daemon) compatLoop(stop <-chan struct{}) {
|
||||
|
||||
// evaluate 执行一次完整判定;满足条件时执行亮度提升。
|
||||
func (d *Daemon) evaluate() {
|
||||
defer d.flushState()
|
||||
|
||||
// 服务暂停 / 守护进程挂起:静默跳过(与旧脚本一致)
|
||||
if fileExists(d.paths.StopFlag) || fileExists(d.paths.PauseFlag) {
|
||||
if api.FileExists(d.paths.StopFlag) || api.FileExists(d.paths.PauseFlag) {
|
||||
d.setStatePaused(api.FileExists(d.paths.StopFlag))
|
||||
return
|
||||
}
|
||||
d.setStatePaused(false)
|
||||
|
||||
cfg := d.currentConfig()
|
||||
if cfg.UIMaxBri <= 0 || cfg.MaxBri <= 0 {
|
||||
return // 未校准,等价于旧脚本的 `now >= 0 && now < 0`
|
||||
}
|
||||
if !fileExists(cfg.NowBriFile) {
|
||||
if !api.FileExists(cfg.NowBriFile) {
|
||||
return // 节点缺失由外层循环负责记录与重试,这里静默
|
||||
}
|
||||
|
||||
@@ -284,9 +282,13 @@ func (d *Daemon) evaluate() {
|
||||
d.log().Info(fmt.Sprintf("处于休眠时段 (%s),跳过提升", cfg.SleepTime))
|
||||
return
|
||||
}
|
||||
if cfg.AutoBriSleep == 1 && d.deps.AutoBrightness.Enabled() {
|
||||
d.log().Info("自动亮度已启用,跳过提升")
|
||||
return
|
||||
if cfg.AutoBriSleep == 1 {
|
||||
autoBri := d.deps.AutoBrightness.Enabled()
|
||||
d.setStateAutoBrightness(autoBri)
|
||||
if autoBri {
|
||||
d.log().Info("自动亮度已启用,跳过提升")
|
||||
return
|
||||
}
|
||||
}
|
||||
if len(cfg.BlacklistApps) > 0 {
|
||||
focus := d.deps.Focus.CurrentFocus()
|
||||
@@ -311,6 +313,7 @@ func (d *Daemon) evaluateHdr(cfg config.Config) bool {
|
||||
}
|
||||
if ok {
|
||||
d.ratioCache, d.haveRatioCache = ratio, true
|
||||
d.setStateRatio(ratio)
|
||||
}
|
||||
|
||||
decision := d.hdr.Evaluate(ratio, ok, cfg.HdrEnterRatio, cfg.HdrExitRatio)
|
||||
@@ -322,6 +325,7 @@ func (d *Daemon) evaluateHdr(cfg config.Config) bool {
|
||||
case decision.Skip:
|
||||
d.log().Info("HDR 休眠中,跳过提升")
|
||||
}
|
||||
d.setStateHdrSleep(d.hdr.InSleep())
|
||||
return !decision.Skip
|
||||
}
|
||||
|
||||
@@ -337,6 +341,7 @@ func (d *Daemon) boost(cfg config.Config) {
|
||||
d.log().Error("读取亮度节点失败: " + err.Error())
|
||||
return
|
||||
}
|
||||
d.setStateBrightness(now)
|
||||
if policy.ShouldBoost(now, cfg.UIMaxBri, cfg.MaxBri) {
|
||||
d.log().Info(fmt.Sprintf("触发提升: 当前亮度 %d ≥ 阈值 %d,目标 %d", now, cfg.UIMaxBri, cfg.MaxBri))
|
||||
if err := d.ramp(cfg, now); err != nil {
|
||||
@@ -357,11 +362,15 @@ func (d *Daemon) boost(cfg config.Config) {
|
||||
// ramp 执行渐变写入,期间持操作锁。
|
||||
func (d *Daemon) ramp(cfg config.Config, start int) error {
|
||||
d.log().Info(fmt.Sprintf("开始渐变调整: %d → %d (%d 步)", start, cfg.MaxBri, cfg.StepsNum))
|
||||
if err := d.writeOplock(); err != nil {
|
||||
if err := api.WriteOplock(d.paths.Oplock, api.KindRamp); err != nil {
|
||||
d.log().Warn("写入操作锁失败: " + err.Error())
|
||||
}
|
||||
defer d.removeOplock()
|
||||
return brightness.Ramp(cfg.NowBriFile, start, cfg.MaxBri, cfg.StepsNum, d.deps.StepDelay, nil)
|
||||
defer api.RemoveOplock(d.paths.Oplock)
|
||||
|
||||
err := brightness.Ramp(cfg.NowBriFile, start, cfg.MaxBri, cfg.StepsNum, d.deps.StepDelay, nil)
|
||||
d.setStateAction(api.KindRamp, start, cfg.MaxBri)
|
||||
d.setStateBrightness(cfg.MaxBri)
|
||||
return err
|
||||
}
|
||||
|
||||
// pollConfig 定期比对 config.json 的 mtime/大小,变更时通知主循环。
|
||||
@@ -459,23 +468,73 @@ func (d *Daemon) writePID() error {
|
||||
return os.WriteFile(d.paths.PIDFile, []byte(strconv.Itoa(os.Getpid())), 0o644)
|
||||
}
|
||||
|
||||
func (d *Daemon) writeOplock() error {
|
||||
if err := os.MkdirAll(d.paths.PIDDir, 0o755); err != nil {
|
||||
return err
|
||||
}
|
||||
return os.WriteFile(d.paths.Oplock, []byte(strconv.Itoa(os.Getpid())), 0o644)
|
||||
}
|
||||
|
||||
func (d *Daemon) removeOplock() {
|
||||
_ = os.Remove(d.paths.Oplock)
|
||||
}
|
||||
|
||||
func (d *Daemon) cleanup() {
|
||||
_ = os.Remove(d.paths.PIDFile)
|
||||
_ = os.Remove(d.paths.Oplock)
|
||||
_ = os.Remove(d.paths.StateFile)
|
||||
}
|
||||
|
||||
func fileExists(path string) bool {
|
||||
info, err := os.Stat(path)
|
||||
return err == nil && !info.IsDir()
|
||||
// ── 运行状态维护(供 WebUI 的 status 子命令读取)────────────────────────────
|
||||
|
||||
func (d *Daemon) updateState(fn func(s *api.DaemonState)) {
|
||||
d.stateMu.Lock()
|
||||
defer d.stateMu.Unlock()
|
||||
fn(&d.state)
|
||||
}
|
||||
|
||||
func (d *Daemon) flushState() {
|
||||
d.stateMu.Lock()
|
||||
snapshot := d.state
|
||||
d.stateMu.Unlock()
|
||||
if err := api.WriteState(d.paths.StateFile, snapshot); err != nil {
|
||||
d.log().Warn("写入运行状态失败: " + err.Error())
|
||||
}
|
||||
}
|
||||
|
||||
func (d *Daemon) recordEvent(letters string) {
|
||||
now := time.Now().Unix()
|
||||
d.updateState(func(s *api.DaemonState) {
|
||||
s.LastEvent = &api.EventInfo{Letters: letters, At: now}
|
||||
})
|
||||
}
|
||||
|
||||
func (d *Daemon) setStateMode(mode string) {
|
||||
d.updateState(func(s *api.DaemonState) { s.Mode = mode })
|
||||
d.flushState()
|
||||
}
|
||||
|
||||
func (d *Daemon) setStatePaused(paused bool) {
|
||||
d.updateState(func(s *api.DaemonState) { s.Paused = paused })
|
||||
}
|
||||
|
||||
func (d *Daemon) setStateRatio(ratio float64) {
|
||||
now := time.Now().Unix()
|
||||
d.updateState(func(s *api.DaemonState) {
|
||||
s.Ratio = &api.RatioInfo{Value: ratio, At: now}
|
||||
})
|
||||
}
|
||||
|
||||
func (d *Daemon) setStateAutoBrightness(on bool) {
|
||||
now := time.Now().Unix()
|
||||
d.updateState(func(s *api.DaemonState) {
|
||||
s.AutoBrightness = &api.BoolInfo{Value: on, At: now}
|
||||
})
|
||||
}
|
||||
|
||||
func (d *Daemon) setStateHdrSleep(asleep bool) {
|
||||
d.updateState(func(s *api.DaemonState) { s.HdrSleep = asleep })
|
||||
}
|
||||
|
||||
func (d *Daemon) setStateBrightness(value int) {
|
||||
now := time.Now().Unix()
|
||||
d.updateState(func(s *api.DaemonState) {
|
||||
s.Brightness = &api.IntInfo{Value: value, At: now}
|
||||
})
|
||||
}
|
||||
|
||||
func (d *Daemon) setStateAction(kind string, from, to int) {
|
||||
now := time.Now().Unix()
|
||||
d.updateState(func(s *api.DaemonState) {
|
||||
s.LastAction = &api.ActionInfo{Kind: kind, From: from, To: to, At: now}
|
||||
})
|
||||
}
|
||||
@@ -10,6 +10,7 @@ import (
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/YuleBest/LuminPro/go/internal/api"
|
||||
"github.com/YuleBest/LuminPro/go/internal/config"
|
||||
"github.com/YuleBest/LuminPro/go/internal/logging"
|
||||
"github.com/YuleBest/LuminPro/go/internal/system"
|
||||
@@ -298,21 +299,21 @@ func TestBoostRejectsMissingNode(t *testing.T) {
|
||||
|
||||
func TestReadDaemonPID(t *testing.T) {
|
||||
dir := t.TempDir()
|
||||
pidFile := filepath.Join(dir, "inotifyd.pid")
|
||||
pidFile := filepath.Join(dir, "daemon.pid")
|
||||
|
||||
if _, alive := readDaemonPID(pidFile); alive {
|
||||
if _, alive := api.DaemonPID(pidFile); alive {
|
||||
t.Fatal("文件不存在应视为未运行")
|
||||
}
|
||||
_ = os.WriteFile(pidFile, []byte("notanumber"), 0o644)
|
||||
if _, alive := readDaemonPID(pidFile); alive {
|
||||
if _, alive := api.DaemonPID(pidFile); alive {
|
||||
t.Fatal("非法内容应视为未运行")
|
||||
}
|
||||
_ = os.WriteFile(pidFile, []byte("999999"), 0o644)
|
||||
if _, alive := readDaemonPID(pidFile); alive {
|
||||
if _, alive := api.DaemonPID(pidFile); alive {
|
||||
t.Fatal("不存在的 PID 应视为未运行")
|
||||
}
|
||||
_ = os.WriteFile(pidFile, []byte(strconv.Itoa(os.Getpid())), 0o644)
|
||||
if pid, alive := readDaemonPID(pidFile); !alive || pid != os.Getpid() {
|
||||
if pid, alive := api.DaemonPID(pidFile); !alive || pid != os.Getpid() {
|
||||
t.Fatal("当前进程 PID 应视为存活")
|
||||
}
|
||||
}
|
||||
@@ -10,6 +10,7 @@ import (
|
||||
"syscall"
|
||||
"time"
|
||||
|
||||
"github.com/YuleBest/LuminPro/go/internal/api"
|
||||
"github.com/YuleBest/LuminPro/go/internal/brightness"
|
||||
"github.com/YuleBest/LuminPro/go/internal/config"
|
||||
"github.com/YuleBest/LuminPro/go/internal/logging"
|
||||
@@ -21,7 +22,7 @@ func Boost(paths Paths, log *logging.Logger) error {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if !fileExists(cfg.NowBriFile) {
|
||||
if !api.FileExists(cfg.NowBriFile) {
|
||||
return fmt.Errorf("亮度节点不存在: %s", cfg.NowBriFile)
|
||||
}
|
||||
|
||||
@@ -57,10 +58,10 @@ func Boost(paths Paths, log *logging.Logger) error {
|
||||
// writeWithOplock 在持操作锁的前提下写一次亮度节点。
|
||||
func writeWithOplock(paths Paths, log *logging.Logger, node string, value int) {
|
||||
_ = os.MkdirAll(paths.PIDDir, 0o755)
|
||||
if err := os.WriteFile(paths.Oplock, []byte(strconv.Itoa(os.Getpid())), 0o644); err != nil && log != nil {
|
||||
if err := api.WriteOplock(paths.Oplock, api.KindBoost); err != nil && log != nil {
|
||||
log.Warn("写入操作锁失败: " + err.Error())
|
||||
}
|
||||
defer func() { _ = os.Remove(paths.Oplock) }()
|
||||
defer api.RemoveOplock(paths.Oplock)
|
||||
if err := brightness.WriteInt(node, value); err != nil && log != nil {
|
||||
log.Error("写入亮度节点失败: " + err.Error())
|
||||
}
|
||||
@@ -73,12 +74,12 @@ func Restart(paths Paths, selfPath string, log *logging.Logger) error {
|
||||
return err
|
||||
}
|
||||
// 整个重启窗口持操作锁,WebUI 会据此暂停刷新
|
||||
if err := os.WriteFile(paths.Oplock, []byte(strconv.Itoa(os.Getpid())), 0o644); err != nil {
|
||||
if err := api.WriteOplock(paths.Oplock, api.KindRestart); err != nil {
|
||||
return err
|
||||
}
|
||||
defer func() { _ = os.Remove(paths.Oplock) }()
|
||||
defer api.RemoveOplock(paths.Oplock)
|
||||
|
||||
if pid, alive := readDaemonPID(paths.PIDFile); alive {
|
||||
if pid, alive := api.DaemonPID(paths.PIDFile); alive {
|
||||
start := time.Now()
|
||||
if err := syscall.Kill(pid, syscall.SIGHUP); err != nil {
|
||||
return fmt.Errorf("通知守护进程失败: %w", err)
|
||||
@@ -92,7 +93,7 @@ func Restart(paths Paths, selfPath string, log *logging.Logger) error {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if !fileExists(cfg.NowBriFile) {
|
||||
if !api.FileExists(cfg.NowBriFile) {
|
||||
return fmt.Errorf("亮度节点不存在: %s,无法启动服务,请先在配置页填写正确路径", cfg.NowBriFile)
|
||||
}
|
||||
|
||||
@@ -105,22 +106,6 @@ func Restart(paths Paths, selfPath string, log *logging.Logger) error {
|
||||
return cmd.Process.Release()
|
||||
}
|
||||
|
||||
// readDaemonPID 读取 PID 文件并确认进程存活(/proc 检测,等价于旧脚本的 [ -d /proc/$pid ])。
|
||||
func readDaemonPID(pidFile string) (int, bool) {
|
||||
data, err := os.ReadFile(pidFile)
|
||||
if err != nil {
|
||||
return 0, false
|
||||
}
|
||||
pid, err := strconv.Atoi(strings.TrimSpace(string(data)))
|
||||
if err != nil || pid <= 0 {
|
||||
return 0, false
|
||||
}
|
||||
if _, err := os.Stat(fmt.Sprintf("/proc/%d", pid)); err != nil {
|
||||
return 0, false
|
||||
}
|
||||
return pid, true
|
||||
}
|
||||
|
||||
// waitForPIDRewrite 等待 PID 文件在 start 之后被重写。
|
||||
func waitForPIDRewrite(pidFile string, start time.Time, timeout time.Duration) bool {
|
||||
deadline := time.Now().Add(timeout)
|
||||
|
||||
@@ -155,13 +155,22 @@ func (w *Watcher) Add(path, letters string) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// Close 释放资源。
|
||||
// Close 释放资源。重复调用安全。
|
||||
func (w *Watcher) Close() error {
|
||||
w.mu.Lock()
|
||||
defer w.mu.Unlock()
|
||||
_ = unix.Close(w.wakeR)
|
||||
_ = unix.Close(w.wakeW)
|
||||
w.wakeR, w.wakeW = -1, -1
|
||||
// 先唤醒 Run:直接关闭 fd 会让阻塞中的 poll 拿不到退出信号
|
||||
if w.wakeW >= 0 {
|
||||
_, _ = unix.Write(w.wakeW, []byte{1})
|
||||
}
|
||||
if w.wakeR >= 0 {
|
||||
_ = unix.Close(w.wakeR)
|
||||
w.wakeR = -1
|
||||
}
|
||||
if w.wakeW >= 0 {
|
||||
_ = unix.Close(w.wakeW)
|
||||
w.wakeW = -1
|
||||
}
|
||||
if w.fd >= 0 {
|
||||
err := unix.Close(w.fd)
|
||||
w.fd = -1
|
||||
@@ -170,10 +179,13 @@ func (w *Watcher) Close() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// wake 唤醒正在 poll 的 Run。
|
||||
// wake 唤醒正在 poll 的 Run。并发/重复调用安全。
|
||||
func (w *Watcher) wake() {
|
||||
if w.wakeW >= 0 {
|
||||
_, _ = unix.Write(w.wakeW, []byte{1})
|
||||
w.mu.Lock()
|
||||
fd := w.wakeW
|
||||
w.mu.Unlock()
|
||||
if fd >= 0 {
|
||||
_, _ = unix.Write(fd, []byte{1})
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -80,6 +80,8 @@ func startRunner(t *testing.T, w *Watcher, debounce time.Duration, handler func(
|
||||
_ = w.NewRunner(debounce, nil).Run(handler, stop)
|
||||
}()
|
||||
t.Cleanup(func() {
|
||||
// 必须先让 Run 退出,再关闭 watcher:反过来会先关掉唤醒管道,
|
||||
// Stop 的唤醒丢失,Run 会卡在 poll 里直到超时(CI 上偶发)
|
||||
close(stop)
|
||||
w.Stop()
|
||||
select {
|
||||
@@ -87,6 +89,7 @@ func startRunner(t *testing.T, w *Watcher, debounce time.Duration, handler func(
|
||||
case <-time.After(2 * time.Second):
|
||||
t.Error("Run 未能退出")
|
||||
}
|
||||
w.Close()
|
||||
})
|
||||
return stop
|
||||
}
|
||||
@@ -113,7 +116,6 @@ func TestWatchModifyDeliversEvent(t *testing.T) {
|
||||
if err != nil {
|
||||
t.Skipf("当前环境不支持 inotify: %v", err)
|
||||
}
|
||||
defer w.Close()
|
||||
if err := w.Add(path, "c"); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
@@ -144,7 +146,6 @@ func TestCloseWriteLetter(t *testing.T) {
|
||||
if err != nil {
|
||||
t.Skipf("当前环境不支持 inotify: %v", err)
|
||||
}
|
||||
defer w.Close()
|
||||
if err := w.Add(path, "w"); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
@@ -181,7 +182,6 @@ func TestCloseNoWriteLetter(t *testing.T) {
|
||||
if err != nil {
|
||||
t.Skipf("当前环境不支持 inotify: %v", err)
|
||||
}
|
||||
defer w.Close()
|
||||
if err := w.Add(path, "0"); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
@@ -216,25 +216,26 @@ func TestDebounceCoalescesBurst(t *testing.T) {
|
||||
if err != nil {
|
||||
t.Skipf("当前环境不支持 inotify: %v", err)
|
||||
}
|
||||
defer w.Close()
|
||||
if err := w.Add(path, "c"); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
c := &collector{}
|
||||
startRunner(t, w, 200*time.Millisecond, c.add)
|
||||
// 防抖窗口取大一些:CI 上单次写文件可能耗时数十毫秒,
|
||||
// 窗口过短会让连写跨越窗口边界,产生第 2 次触发(测试因此偶发失败)
|
||||
const debounceWindow = 800 * time.Millisecond
|
||||
startRunner(t, w, debounceWindow, c.add)
|
||||
|
||||
for i := 0; i < 5; i++ {
|
||||
if err := os.WriteFile(path, []byte("x"), 0o644); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
time.Sleep(10 * time.Millisecond)
|
||||
}
|
||||
|
||||
if !waitFor(t, 2*time.Second, func() bool { return len(c.snapshot()) > 0 }) {
|
||||
if !waitFor(t, 3*time.Second, func() bool { return len(c.snapshot()) > 0 }) {
|
||||
t.Fatal("未收到事件")
|
||||
}
|
||||
time.Sleep(300 * time.Millisecond) // 等超过一个防抖窗口
|
||||
time.Sleep(debounceWindow + 400*time.Millisecond) // 等超过一个防抖窗口
|
||||
if got := len(c.snapshot()); got != 1 {
|
||||
t.Fatalf("防抖后应只触发 1 次, 实际 %d 次", got)
|
||||
}
|
||||
@@ -251,7 +252,6 @@ func TestDrainPreventsRecursion(t *testing.T) {
|
||||
if err != nil {
|
||||
t.Skipf("当前环境不支持 inotify: %v", err)
|
||||
}
|
||||
defer w.Close()
|
||||
if err := w.Add(path, "c"); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
@@ -287,7 +287,6 @@ func TestStopExitsBlockingRun(t *testing.T) {
|
||||
if err != nil {
|
||||
t.Skipf("当前环境不支持 inotify: %v", err)
|
||||
}
|
||||
defer w.Close()
|
||||
if err := w.Add(path, "c"); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
@@ -317,7 +316,6 @@ func TestAddMissingPathFails(t *testing.T) {
|
||||
if err != nil {
|
||||
t.Skipf("当前环境不支持 inotify: %v", err)
|
||||
}
|
||||
defer w.Close()
|
||||
if err := w.Add(filepath.Join(t.TempDir(), "不存在"), "c"); err == nil {
|
||||
t.Fatal("监听不存在的路径应报错")
|
||||
}
|
||||
|
||||
+2
-2
@@ -1,7 +1,7 @@
|
||||
id=LuminPro
|
||||
name=LuminPro丨日用屏幕亮度强化
|
||||
version=V2.5.0-beta.1
|
||||
versionCode=2050051
|
||||
version=V2.5.0
|
||||
versionCode=2050090
|
||||
author=酷安@Yule
|
||||
description=本模块旨在让你的 Android 设备随时可以使用高亮度显示屏幕内容。无论设备当前亮度如何,只要满足设定的前台触发亮度条件,模块便会自动且平滑地提升屏幕亮度至硬件支持的峰值状态,确保你在强光室外也能获得清晰的显示效果
|
||||
updateJson=https://raw.githubusercontent.com/YuleBest/LuminPro/main/update.json
|
||||
+1
-7
@@ -14,25 +14,19 @@
|
||||
"fmt:check": "oxfmt webui/ --check"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@tailwindcss/vite": "^4.2.2",
|
||||
"archiver": "^7.0.1",
|
||||
"kernelsu": "^3.0.2",
|
||||
"oxfmt": "^0.44.0",
|
||||
"oxlint": "^1.59.0",
|
||||
"tailwindcss": "^4.2.2",
|
||||
"tw-animate-css": "^1.4.0",
|
||||
"vite": "^8.0.3"
|
||||
},
|
||||
"dependencies": {
|
||||
"@material/web": "^2.5.0",
|
||||
"@tanstack/vue-virtual": "^3.13.37",
|
||||
"@vitejs/plugin-vue": "^6.0.5",
|
||||
"class-variance-authority": "^0.7.1",
|
||||
"clsx": "^2.1.1",
|
||||
"lucide": "^1.7.0",
|
||||
"lucide-vue-next": "^1.0.0",
|
||||
"markdown-it": "^14.1.1",
|
||||
"pinyin-match": "^1.2.10",
|
||||
"tailwind-merge": "^3.5.0",
|
||||
"vue": "^3.5.32"
|
||||
}
|
||||
}
|
||||
Generated
+61
-261
@@ -8,21 +8,15 @@ importers:
|
||||
|
||||
.:
|
||||
dependencies:
|
||||
'@material/web':
|
||||
specifier: ^2.5.0
|
||||
version: 2.5.0
|
||||
'@tanstack/vue-virtual':
|
||||
specifier: ^3.13.37
|
||||
version: 3.13.37(vue@3.5.32)
|
||||
'@vitejs/plugin-vue':
|
||||
specifier: ^6.0.5
|
||||
version: 6.0.5(vite@8.0.3(@emnapi/core@1.9.2)(@emnapi/runtime@1.9.2)(jiti@2.6.1))(vue@3.5.32)
|
||||
class-variance-authority:
|
||||
specifier: ^0.7.1
|
||||
version: 0.7.1
|
||||
clsx:
|
||||
specifier: ^2.1.1
|
||||
version: 2.1.1
|
||||
lucide:
|
||||
specifier: ^1.7.0
|
||||
version: 1.7.0
|
||||
lucide-vue-next:
|
||||
specifier: ^1.0.0
|
||||
version: 1.0.0(vue@3.5.32)
|
||||
@@ -32,16 +26,10 @@ importers:
|
||||
pinyin-match:
|
||||
specifier: ^1.2.10
|
||||
version: 1.2.10
|
||||
tailwind-merge:
|
||||
specifier: ^3.5.0
|
||||
version: 3.5.0
|
||||
vue:
|
||||
specifier: ^3.5.32
|
||||
version: 3.5.32
|
||||
devDependencies:
|
||||
'@tailwindcss/vite':
|
||||
specifier: ^4.2.2
|
||||
version: 4.2.2(vite@8.0.3(@emnapi/core@1.9.2)(@emnapi/runtime@1.9.2)(jiti@2.6.1))
|
||||
archiver:
|
||||
specifier: ^7.0.1
|
||||
version: 7.0.1
|
||||
@@ -54,12 +42,6 @@ importers:
|
||||
oxlint:
|
||||
specifier: ^1.59.0
|
||||
version: 1.59.0
|
||||
tailwindcss:
|
||||
specifier: ^4.2.2
|
||||
version: 4.2.2
|
||||
tw-animate-css:
|
||||
specifier: ^1.4.0
|
||||
version: 1.4.0
|
||||
vite:
|
||||
specifier: ^8.0.3
|
||||
version: 8.0.3(@emnapi/core@1.9.2)(@emnapi/runtime@1.9.2)(jiti@2.6.1)
|
||||
@@ -96,21 +78,20 @@ packages:
|
||||
resolution: {integrity: sha512-O8jcjabXaleOG9DQ0+ARXWZBTfnP4WNAqzuiJK7ll44AmxGKv/J2M4TPjxjY3znBCfvBXFzucm1twdyFybFqEA==}
|
||||
engines: {node: '>=12'}
|
||||
|
||||
'@jridgewell/gen-mapping@0.3.13':
|
||||
resolution: {integrity: sha512-2kkt/7niJ6MgEPxF0bYdQ6etZaA+fQvDcLKckhy1yIQOzaoKjBBjSj63/aLVjYE3qhRt5dvM+uUyfCg6UKCBbA==}
|
||||
|
||||
'@jridgewell/remapping@2.3.5':
|
||||
resolution: {integrity: sha512-LI9u/+laYG4Ds1TDKSJW2YPrIlcVYOwi2fUC6xB43lueCjgxV4lffOCZCtYFiH6TNOX+tQKXx97T4IKHbhyHEQ==}
|
||||
|
||||
'@jridgewell/resolve-uri@3.1.2':
|
||||
resolution: {integrity: sha512-bRISgCIjP20/tbWSPWMEi54QVPRZExkuD9lJL+UIxUKtwVJA8wW1Trb1jMs1RFXo1CBTNZ/5hpC9QvmKWdopKw==}
|
||||
engines: {node: '>=6.0.0'}
|
||||
|
||||
'@jridgewell/sourcemap-codec@1.5.5':
|
||||
resolution: {integrity: sha512-cYQ9310grqxueWbl+WuIUIaiUaDcj7WOq5fVhEljNVgRfOUhY9fy2zTvfoqWsnebh8Sl70VScFbICvJnLKB0Og==}
|
||||
|
||||
'@jridgewell/trace-mapping@0.3.31':
|
||||
resolution: {integrity: sha512-zzNR+SdQSDJzc8joaeP8QQoCQr8NuYx2dIIytl1QeBEZHJ9uW6hebsrYgbz8hJwUQao3TWCMtmfV8Nu1twOLAw==}
|
||||
'@lit-labs/ssr-dom-shim@1.6.0':
|
||||
resolution: {integrity: sha512-VHb0ALPMTlgKjM6yIxxoQNnpKyUKLD04VzeQdsiXkMqkvYlAHxq9glGLmgbb889/1GsohSOAjvQYoiBppXFqrQ==}
|
||||
|
||||
'@lit/context@1.1.6':
|
||||
resolution: {integrity: sha512-M26qDE6UkQbZA2mQ3RjJ3Gzd8TxP+/0obMgE5HfkfLhEEyYE3Bui4A5XHiGPjy0MUGAyxB3QgVuw2ciS0kHn6A==}
|
||||
|
||||
'@lit/reactive-element@2.1.2':
|
||||
resolution: {integrity: sha512-pbCDiVMnne1lYUIaYNN5wrwQXDtHaYtg7YEFPeW+hws6U47WeFvISGUWekPGKWOP1ygrs0ef0o1VJMk1exos5A==}
|
||||
|
||||
'@material/web@2.5.0':
|
||||
resolution: {integrity: sha512-x2Uovyq8E/Zc1xHXd9s1eBMXF5pMHVAt70pISKd0fL3Ajj4L6zQaQUY/awcfR2RDAMKXC7i4+vr0arv1YaOR/g==}
|
||||
|
||||
'@napi-rs/wasm-runtime@1.1.2':
|
||||
resolution: {integrity: sha512-sNXv5oLJ7ob93xkZ1XnxisYhGYXfaG9f65/ZgYuAu3qt7b3NadcOEhLvx28hv31PgX8SZJRYrAIPQilQmFpLVw==}
|
||||
@@ -470,100 +451,6 @@ packages:
|
||||
'@rolldown/pluginutils@1.0.0-rc.2':
|
||||
resolution: {integrity: sha512-izyXV/v+cHiRfozX62W9htOAvwMo4/bXKDrQ+vom1L1qRuexPock/7VZDAhnpHCLNejd3NJ6hiab+tO0D44Rgw==}
|
||||
|
||||
'@tailwindcss/node@4.2.2':
|
||||
resolution: {integrity: sha512-pXS+wJ2gZpVXqFaUEjojq7jzMpTGf8rU6ipJz5ovJV6PUGmlJ+jvIwGrzdHdQ80Sg+wmQxUFuoW1UAAwHNEdFA==}
|
||||
|
||||
'@tailwindcss/oxide-android-arm64@4.2.2':
|
||||
resolution: {integrity: sha512-dXGR1n+P3B6748jZO/SvHZq7qBOqqzQ+yFrXpoOWWALWndF9MoSKAT3Q0fYgAzYzGhxNYOoysRvYlpixRBBoDg==}
|
||||
engines: {node: '>= 20'}
|
||||
cpu: [arm64]
|
||||
os: [android]
|
||||
|
||||
'@tailwindcss/oxide-darwin-arm64@4.2.2':
|
||||
resolution: {integrity: sha512-iq9Qjr6knfMpZHj55/37ouZeykwbDqF21gPFtfnhCCKGDcPI/21FKC9XdMO/XyBM7qKORx6UIhGgg6jLl7BZlg==}
|
||||
engines: {node: '>= 20'}
|
||||
cpu: [arm64]
|
||||
os: [darwin]
|
||||
|
||||
'@tailwindcss/oxide-darwin-x64@4.2.2':
|
||||
resolution: {integrity: sha512-BlR+2c3nzc8f2G639LpL89YY4bdcIdUmiOOkv2GQv4/4M0vJlpXEa0JXNHhCHU7VWOKWT/CjqHdTP8aUuDJkuw==}
|
||||
engines: {node: '>= 20'}
|
||||
cpu: [x64]
|
||||
os: [darwin]
|
||||
|
||||
'@tailwindcss/oxide-freebsd-x64@4.2.2':
|
||||
resolution: {integrity: sha512-YUqUgrGMSu2CDO82hzlQ5qSb5xmx3RUrke/QgnoEx7KvmRJHQuZHZmZTLSuuHwFf0DJPybFMXMYf+WJdxHy/nQ==}
|
||||
engines: {node: '>= 20'}
|
||||
cpu: [x64]
|
||||
os: [freebsd]
|
||||
|
||||
'@tailwindcss/oxide-linux-arm-gnueabihf@4.2.2':
|
||||
resolution: {integrity: sha512-FPdhvsW6g06T9BWT0qTwiVZYE2WIFo2dY5aCSpjG/S/u1tby+wXoslXS0kl3/KXnULlLr1E3NPRRw0g7t2kgaQ==}
|
||||
engines: {node: '>= 20'}
|
||||
cpu: [arm]
|
||||
os: [linux]
|
||||
|
||||
'@tailwindcss/oxide-linux-arm64-gnu@4.2.2':
|
||||
resolution: {integrity: sha512-4og1V+ftEPXGttOO7eCmW7VICmzzJWgMx+QXAJRAhjrSjumCwWqMfkDrNu1LXEQzNAwz28NCUpucgQPrR4S2yw==}
|
||||
engines: {node: '>= 20'}
|
||||
cpu: [arm64]
|
||||
os: [linux]
|
||||
libc: [glibc]
|
||||
|
||||
'@tailwindcss/oxide-linux-arm64-musl@4.2.2':
|
||||
resolution: {integrity: sha512-oCfG/mS+/+XRlwNjnsNLVwnMWYH7tn/kYPsNPh+JSOMlnt93mYNCKHYzylRhI51X+TbR+ufNhhKKzm6QkqX8ag==}
|
||||
engines: {node: '>= 20'}
|
||||
cpu: [arm64]
|
||||
os: [linux]
|
||||
libc: [musl]
|
||||
|
||||
'@tailwindcss/oxide-linux-x64-gnu@4.2.2':
|
||||
resolution: {integrity: sha512-rTAGAkDgqbXHNp/xW0iugLVmX62wOp2PoE39BTCGKjv3Iocf6AFbRP/wZT/kuCxC9QBh9Pu8XPkv/zCZB2mcMg==}
|
||||
engines: {node: '>= 20'}
|
||||
cpu: [x64]
|
||||
os: [linux]
|
||||
libc: [glibc]
|
||||
|
||||
'@tailwindcss/oxide-linux-x64-musl@4.2.2':
|
||||
resolution: {integrity: sha512-XW3t3qwbIwiSyRCggeO2zxe3KWaEbM0/kW9e8+0XpBgyKU4ATYzcVSMKteZJ1iukJ3HgHBjbg9P5YPRCVUxlnQ==}
|
||||
engines: {node: '>= 20'}
|
||||
cpu: [x64]
|
||||
os: [linux]
|
||||
libc: [musl]
|
||||
|
||||
'@tailwindcss/oxide-wasm32-wasi@4.2.2':
|
||||
resolution: {integrity: sha512-eKSztKsmEsn1O5lJ4ZAfyn41NfG7vzCg496YiGtMDV86jz1q/irhms5O0VrY6ZwTUkFy/EKG3RfWgxSI3VbZ8Q==}
|
||||
engines: {node: '>=14.0.0'}
|
||||
cpu: [wasm32]
|
||||
bundledDependencies:
|
||||
- '@napi-rs/wasm-runtime'
|
||||
- '@emnapi/core'
|
||||
- '@emnapi/runtime'
|
||||
- '@tybys/wasm-util'
|
||||
- '@emnapi/wasi-threads'
|
||||
- tslib
|
||||
|
||||
'@tailwindcss/oxide-win32-arm64-msvc@4.2.2':
|
||||
resolution: {integrity: sha512-qPmaQM4iKu5mxpsrWZMOZRgZv1tOZpUm+zdhhQP0VhJfyGGO3aUKdbh3gDZc/dPLQwW4eSqWGrrcWNBZWUWaXQ==}
|
||||
engines: {node: '>= 20'}
|
||||
cpu: [arm64]
|
||||
os: [win32]
|
||||
|
||||
'@tailwindcss/oxide-win32-x64-msvc@4.2.2':
|
||||
resolution: {integrity: sha512-1T/37VvI7WyH66b+vqHj/cLwnCxt7Qt3WFu5Q8hk65aOvlwAhs7rAp1VkulBJw/N4tMirXjVnylTR72uI0HGcA==}
|
||||
engines: {node: '>= 20'}
|
||||
cpu: [x64]
|
||||
os: [win32]
|
||||
|
||||
'@tailwindcss/oxide@4.2.2':
|
||||
resolution: {integrity: sha512-qEUA07+E5kehxYp9BVMpq9E8vnJuBHfJEC0vPC5e7iL/hw7HR61aDKoVoKzrG+QKp56vhNZe4qwkRmMC0zDLvg==}
|
||||
engines: {node: '>= 20'}
|
||||
|
||||
'@tailwindcss/vite@4.2.2':
|
||||
resolution: {integrity: sha512-mEiF5HO1QqCLXoNEfXVA1Tzo+cYsrqV7w9Juj2wdUFyW07JRenqMG225MvPwr3ZD9N1bFQj46X7r33iHxLUW0w==}
|
||||
peerDependencies:
|
||||
vite: ^5.2.0 || ^6 || ^7 || ^8
|
||||
|
||||
'@tanstack/virtual-core@3.17.9':
|
||||
resolution: {integrity: sha512-M8Bzy7CCMvUjRiuoHVH9mRjyUVczRs8v8RcUEphLFGc445ZP4KQ15Y1sLqhQqJi/HgGJrxfCHnEnIX0x9mVrBg==}
|
||||
|
||||
@@ -575,6 +462,9 @@ packages:
|
||||
'@tybys/wasm-util@0.10.1':
|
||||
resolution: {integrity: sha512-9tTaPJLSiejZKx+Bmog4uSubteqTvFrVrURwkmHixBo0G4seD0zUxp98E1DzUBJxLQ3NPwXrGKDiVjwx/DpPsg==}
|
||||
|
||||
'@types/trusted-types@2.0.7':
|
||||
resolution: {integrity: sha512-ScaPdn1dQczgbl0QFTeTOmVHFULt394XJgOQNoyVhZ6r2vLnMLJfBPd53SB52T/3G36VI1/g2MZaX0cwDuXsfw==}
|
||||
|
||||
'@vitejs/plugin-vue@6.0.5':
|
||||
resolution: {integrity: sha512-bL3AxKuQySfk1iGcBsQnoRVexTPJq0Z/ixFVM8OhVJAP6ZXXXLtM7NFKWhLl30Kg7uTBqIaPXbh+nuQCuBDedg==}
|
||||
engines: {node: ^20.19.0 || >=22.12.0}
|
||||
@@ -710,13 +600,6 @@ packages:
|
||||
buffer@6.0.3:
|
||||
resolution: {integrity: sha512-FTiCpNxtwiZZHEZbcbTIcZjERVICn9yq/pDFkTl95/AxzD1naBctN7YO68riM/gLSDY7sdrMby8hofADYuuqOA==}
|
||||
|
||||
class-variance-authority@0.7.1:
|
||||
resolution: {integrity: sha512-Ka+9Trutv7G8M6WT6SeiRWz792K5qEqIGEGzXKhAE6xOWAY6pPH8U+9IY3oCMv6kqTmLsv7Xh/2w2RigkePMsg==}
|
||||
|
||||
clsx@2.1.1:
|
||||
resolution: {integrity: sha512-eYm0QWBtUrBWZWG0d386OGAw16Z995PiOVo2B7bjWSbHedGl5e0ZWaq65kOGgUSNesEIDkB9ISbTg/JK9dhCZA==}
|
||||
engines: {node: '>=6'}
|
||||
|
||||
color-convert@2.0.1:
|
||||
resolution: {integrity: sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==}
|
||||
engines: {node: '>=7.0.0'}
|
||||
@@ -760,10 +643,6 @@ packages:
|
||||
emoji-regex@9.2.2:
|
||||
resolution: {integrity: sha512-L18DaJsXSUk2+42pv8mLs5jJT2hqFkFE4j21wOmgbUqsZ2hL72NsUU785g9RXgo3s0ZNgVl42TiHp3ZtOv/Vyg==}
|
||||
|
||||
enhanced-resolve@5.20.1:
|
||||
resolution: {integrity: sha512-Qohcme7V1inbAfvjItgw0EaxVX5q2rdVEZHRBrEQdRZTssLDGsL8Lwrznl8oQ/6kuTJONLaDcGjkNP247XEhcA==}
|
||||
engines: {node: '>=10.13.0'}
|
||||
|
||||
entities@4.5.0:
|
||||
resolution: {integrity: sha512-V0hjH4dGPh9Ao5p0MoRY6BVqtwCjhz6vI5LT8AJ55H+4g9/4vbHx1I54fS0XuclLhDHArPQCiMjDxjaL8fPxhw==}
|
||||
engines: {node: '>=0.12'}
|
||||
@@ -925,6 +804,15 @@ packages:
|
||||
linkify-it@5.0.0:
|
||||
resolution: {integrity: sha512-5aHCbzQRADcdP+ATqnDuhhJ/MRIqDkZX5pyjFHRRysS8vZ5AbqGEoFIb6pYHPZ+L/OC2Lc+xT8uHVVR5CAK/wQ==}
|
||||
|
||||
lit-element@4.2.2:
|
||||
resolution: {integrity: sha512-aFKhNToWxoyhkNDmWZwEva2SlQia+jfG0fjIWV//YeTaWrVnOxD89dPKfigCUspXFmjzOEUQpOkejH5Ly6sG0w==}
|
||||
|
||||
lit-html@3.3.3:
|
||||
resolution: {integrity: sha512-el8M6jK2o3RXBnrSHX3ZKrsN8zEV63pSExTO1wYJz7QndGYZ8353e2a5PPX+qHe2aGayfnchQmkAojaWAREOIA==}
|
||||
|
||||
lit@3.3.3:
|
||||
resolution: {integrity: sha512-fycuvZg/hkpozL00lm1pEJH5nN/lr9ZXd6mJI2HSN4+Bzc+LDNdEApJ6HFbPkdFNHLvOplIIuJvxkS4XUxqirw==}
|
||||
|
||||
lodash@4.18.1:
|
||||
resolution: {integrity: sha512-dMInicTPVE8d1e5otfwmmjlxkZoUpiVLwyeTdUsi/Caj/gfzzblBcCE5sRHV/AsjuCmxWrte2TNGSYuCeCq+0Q==}
|
||||
|
||||
@@ -937,9 +825,6 @@ packages:
|
||||
peerDependencies:
|
||||
vue: '>=3.0.1'
|
||||
|
||||
lucide@1.7.0:
|
||||
resolution: {integrity: sha512-aYNogbuIxea3a8offpKjdMGf2FsUk9GECFh0B4iJgXlJOX41+7/ncvLVluKki8477SoybEdyGGf+qGYLBDiEsA==}
|
||||
|
||||
magic-string@0.30.21:
|
||||
resolution: {integrity: sha512-vd2F4YUyEXKGcLHoq+TEyCjxueSeHnFxyyjNp80yg0XV4vUhnDer/lvvlqM/arB5bXQN5K2/3oinyCRyx8T2CQ==}
|
||||
|
||||
@@ -1084,16 +969,6 @@ packages:
|
||||
resolution: {integrity: sha512-yDPMNjp4WyfYBkHnjIRLfca1i6KMyGCtsVgoKe/z1+6vukgaENdgGBZt+ZmKPc4gavvEZ5OgHfHdrazhgNyG7w==}
|
||||
engines: {node: '>=12'}
|
||||
|
||||
tailwind-merge@3.5.0:
|
||||
resolution: {integrity: sha512-I8K9wewnVDkL1NTGoqWmVEIlUcB9gFriAEkXkfCjX5ib8ezGxtR3xD7iZIxrfArjEsH7F1CHD4RFUtxefdqV/A==}
|
||||
|
||||
tailwindcss@4.2.2:
|
||||
resolution: {integrity: sha512-KWBIxs1Xb6NoLdMVqhbhgwZf2PGBpPEiwOqgI4pFIYbNTfBXiKYyWoTsXgBQ9WFg/OlhnvHaY+AEpW7wSmFo2Q==}
|
||||
|
||||
tapable@2.3.2:
|
||||
resolution: {integrity: sha512-1MOpMXuhGzGL5TTCZFItxCc0AARf1EZFQkGqMm7ERKj8+Hgr5oLvJOVFcC+lRmR8hCe2S3jC4T5D7Vg/d7/fhA==}
|
||||
engines: {node: '>=6'}
|
||||
|
||||
tar-stream@3.1.8:
|
||||
resolution: {integrity: sha512-U6QpVRyCGHva435KoNWy9PRoi2IFYCgtEhq9nmrPPpbRacPs9IH4aJ3gbrFC8dPcXvdSZ4XXfXT5Fshbp2MtlQ==}
|
||||
|
||||
@@ -1114,9 +989,6 @@ packages:
|
||||
tslib@2.8.1:
|
||||
resolution: {integrity: sha512-oJFu94HQb+KVduSUQL7wnpmqnfmLsOA/nAh6b6EH0wCEoK0/mPeXU6c3wKDV83MkOuHPRHtSXKKU99IBazS/2w==}
|
||||
|
||||
tw-animate-css@1.4.0:
|
||||
resolution: {integrity: sha512-7bziOlRqH0hJx80h/3mbicLW7o8qLsH5+RaLR2t+OHM3D0JlWGODQKQ4cxbK7WlvmUxpcj6Kgu6EKqjrGFe3QQ==}
|
||||
|
||||
uc.micro@2.1.0:
|
||||
resolution: {integrity: sha512-ARDJmphmdvUk6Glw7y9DQ2bFkKBHwQHLi2lsaH6PPmz/Ka9sFOBsBluozhDltWmnv9u/cF6Rt87znRTPV+yp/A==}
|
||||
|
||||
@@ -1231,24 +1103,23 @@ snapshots:
|
||||
wrap-ansi: 8.1.0
|
||||
wrap-ansi-cjs: wrap-ansi@7.0.0
|
||||
|
||||
'@jridgewell/gen-mapping@0.3.13':
|
||||
dependencies:
|
||||
'@jridgewell/sourcemap-codec': 1.5.5
|
||||
'@jridgewell/trace-mapping': 0.3.31
|
||||
|
||||
'@jridgewell/remapping@2.3.5':
|
||||
dependencies:
|
||||
'@jridgewell/gen-mapping': 0.3.13
|
||||
'@jridgewell/trace-mapping': 0.3.31
|
||||
|
||||
'@jridgewell/resolve-uri@3.1.2': {}
|
||||
|
||||
'@jridgewell/sourcemap-codec@1.5.5': {}
|
||||
|
||||
'@jridgewell/trace-mapping@0.3.31':
|
||||
'@lit-labs/ssr-dom-shim@1.6.0': {}
|
||||
|
||||
'@lit/context@1.1.6':
|
||||
dependencies:
|
||||
'@jridgewell/resolve-uri': 3.1.2
|
||||
'@jridgewell/sourcemap-codec': 1.5.5
|
||||
'@lit/reactive-element': 2.1.2
|
||||
|
||||
'@lit/reactive-element@2.1.2':
|
||||
dependencies:
|
||||
'@lit-labs/ssr-dom-shim': 1.6.0
|
||||
|
||||
'@material/web@2.5.0':
|
||||
dependencies:
|
||||
'@lit/context': 1.1.6
|
||||
lit: 3.3.3
|
||||
tslib: 2.8.1
|
||||
|
||||
'@napi-rs/wasm-runtime@1.1.2(@emnapi/core@1.9.2)(@emnapi/runtime@1.9.2)':
|
||||
dependencies:
|
||||
@@ -1430,74 +1301,6 @@ snapshots:
|
||||
|
||||
'@rolldown/pluginutils@1.0.0-rc.2': {}
|
||||
|
||||
'@tailwindcss/node@4.2.2':
|
||||
dependencies:
|
||||
'@jridgewell/remapping': 2.3.5
|
||||
enhanced-resolve: 5.20.1
|
||||
jiti: 2.6.1
|
||||
lightningcss: 1.32.0
|
||||
magic-string: 0.30.21
|
||||
source-map-js: 1.2.1
|
||||
tailwindcss: 4.2.2
|
||||
|
||||
'@tailwindcss/oxide-android-arm64@4.2.2':
|
||||
optional: true
|
||||
|
||||
'@tailwindcss/oxide-darwin-arm64@4.2.2':
|
||||
optional: true
|
||||
|
||||
'@tailwindcss/oxide-darwin-x64@4.2.2':
|
||||
optional: true
|
||||
|
||||
'@tailwindcss/oxide-freebsd-x64@4.2.2':
|
||||
optional: true
|
||||
|
||||
'@tailwindcss/oxide-linux-arm-gnueabihf@4.2.2':
|
||||
optional: true
|
||||
|
||||
'@tailwindcss/oxide-linux-arm64-gnu@4.2.2':
|
||||
optional: true
|
||||
|
||||
'@tailwindcss/oxide-linux-arm64-musl@4.2.2':
|
||||
optional: true
|
||||
|
||||
'@tailwindcss/oxide-linux-x64-gnu@4.2.2':
|
||||
optional: true
|
||||
|
||||
'@tailwindcss/oxide-linux-x64-musl@4.2.2':
|
||||
optional: true
|
||||
|
||||
'@tailwindcss/oxide-wasm32-wasi@4.2.2':
|
||||
optional: true
|
||||
|
||||
'@tailwindcss/oxide-win32-arm64-msvc@4.2.2':
|
||||
optional: true
|
||||
|
||||
'@tailwindcss/oxide-win32-x64-msvc@4.2.2':
|
||||
optional: true
|
||||
|
||||
'@tailwindcss/oxide@4.2.2':
|
||||
optionalDependencies:
|
||||
'@tailwindcss/oxide-android-arm64': 4.2.2
|
||||
'@tailwindcss/oxide-darwin-arm64': 4.2.2
|
||||
'@tailwindcss/oxide-darwin-x64': 4.2.2
|
||||
'@tailwindcss/oxide-freebsd-x64': 4.2.2
|
||||
'@tailwindcss/oxide-linux-arm-gnueabihf': 4.2.2
|
||||
'@tailwindcss/oxide-linux-arm64-gnu': 4.2.2
|
||||
'@tailwindcss/oxide-linux-arm64-musl': 4.2.2
|
||||
'@tailwindcss/oxide-linux-x64-gnu': 4.2.2
|
||||
'@tailwindcss/oxide-linux-x64-musl': 4.2.2
|
||||
'@tailwindcss/oxide-wasm32-wasi': 4.2.2
|
||||
'@tailwindcss/oxide-win32-arm64-msvc': 4.2.2
|
||||
'@tailwindcss/oxide-win32-x64-msvc': 4.2.2
|
||||
|
||||
'@tailwindcss/vite@4.2.2(vite@8.0.3(@emnapi/core@1.9.2)(@emnapi/runtime@1.9.2)(jiti@2.6.1))':
|
||||
dependencies:
|
||||
'@tailwindcss/node': 4.2.2
|
||||
'@tailwindcss/oxide': 4.2.2
|
||||
tailwindcss: 4.2.2
|
||||
vite: 8.0.3(@emnapi/core@1.9.2)(@emnapi/runtime@1.9.2)(jiti@2.6.1)
|
||||
|
||||
'@tanstack/virtual-core@3.17.9': {}
|
||||
|
||||
'@tanstack/vue-virtual@3.13.37(vue@3.5.32)':
|
||||
@@ -1510,6 +1313,8 @@ snapshots:
|
||||
tslib: 2.8.1
|
||||
optional: true
|
||||
|
||||
'@types/trusted-types@2.0.7': {}
|
||||
|
||||
'@vitejs/plugin-vue@6.0.5(vite@8.0.3(@emnapi/core@1.9.2)(@emnapi/runtime@1.9.2)(jiti@2.6.1))(vue@3.5.32)':
|
||||
dependencies:
|
||||
'@rolldown/pluginutils': 1.0.0-rc.2
|
||||
@@ -1661,12 +1466,6 @@ snapshots:
|
||||
base64-js: 1.5.1
|
||||
ieee754: 1.2.1
|
||||
|
||||
class-variance-authority@0.7.1:
|
||||
dependencies:
|
||||
clsx: 2.1.1
|
||||
|
||||
clsx@2.1.1: {}
|
||||
|
||||
color-convert@2.0.1:
|
||||
dependencies:
|
||||
color-name: 1.1.4
|
||||
@@ -1706,11 +1505,6 @@ snapshots:
|
||||
|
||||
emoji-regex@9.2.2: {}
|
||||
|
||||
enhanced-resolve@5.20.1:
|
||||
dependencies:
|
||||
graceful-fs: 4.2.11
|
||||
tapable: 2.3.2
|
||||
|
||||
entities@4.5.0: {}
|
||||
|
||||
entities@7.0.1: {}
|
||||
@@ -1770,7 +1564,8 @@ snapshots:
|
||||
optionalDependencies:
|
||||
'@pkgjs/parseargs': 0.11.0
|
||||
|
||||
jiti@2.6.1: {}
|
||||
jiti@2.6.1:
|
||||
optional: true
|
||||
|
||||
kernelsu@3.0.2: {}
|
||||
|
||||
@@ -1831,6 +1626,22 @@ snapshots:
|
||||
dependencies:
|
||||
uc.micro: 2.1.0
|
||||
|
||||
lit-element@4.2.2:
|
||||
dependencies:
|
||||
'@lit-labs/ssr-dom-shim': 1.6.0
|
||||
'@lit/reactive-element': 2.1.2
|
||||
lit-html: 3.3.3
|
||||
|
||||
lit-html@3.3.3:
|
||||
dependencies:
|
||||
'@types/trusted-types': 2.0.7
|
||||
|
||||
lit@3.3.3:
|
||||
dependencies:
|
||||
'@lit/reactive-element': 2.1.2
|
||||
lit-element: 4.2.2
|
||||
lit-html: 3.3.3
|
||||
|
||||
lodash@4.18.1: {}
|
||||
|
||||
lru-cache@10.4.3: {}
|
||||
@@ -1839,8 +1650,6 @@ snapshots:
|
||||
dependencies:
|
||||
vue: 3.5.32
|
||||
|
||||
lucide@1.7.0: {}
|
||||
|
||||
magic-string@0.30.21:
|
||||
dependencies:
|
||||
'@jridgewell/sourcemap-codec': 1.5.5
|
||||
@@ -2040,12 +1849,6 @@ snapshots:
|
||||
dependencies:
|
||||
ansi-regex: 6.2.2
|
||||
|
||||
tailwind-merge@3.5.0: {}
|
||||
|
||||
tailwindcss@4.2.2: {}
|
||||
|
||||
tapable@2.3.2: {}
|
||||
|
||||
tar-stream@3.1.8:
|
||||
dependencies:
|
||||
b4a: 1.8.0
|
||||
@@ -2077,10 +1880,7 @@ snapshots:
|
||||
|
||||
tinypool@2.1.0: {}
|
||||
|
||||
tslib@2.8.1:
|
||||
optional: true
|
||||
|
||||
tw-animate-css@1.4.0: {}
|
||||
tslib@2.8.1: {}
|
||||
|
||||
uc.micro@2.1.0: {}
|
||||
|
||||
|
||||
+1
-1
@@ -26,7 +26,7 @@ _log() {
|
||||
sleep 30
|
||||
|
||||
# 清理上次遗留的标记文件
|
||||
rm -f "$MODDIR/pid/"*.flag "$MODDIR/pid/"*.pause "$MODDIR/pid/"*.lock "$MODDIR/pid/oplock" "$MODDIR/pid/.hdr_ratio_cache"
|
||||
rm -f "$MODDIR/pid/"*.flag "$MODDIR/pid/"*.pause "$MODDIR/pid/"*.lock "$MODDIR/pid/oplock" "$MODDIR/pid/state.json" "$MODDIR/pid/.hdr_ratio_cache"
|
||||
|
||||
_log "LuminPro 服务启动" "INFO"
|
||||
|
||||
|
||||
+3
-3
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"versionCode": 2050051,
|
||||
"version": "V2.5.0-beta.1",
|
||||
"zipUrl": "https://github.com/YuleBest/LuminPro/releases/download/v2.5.0-beta.1/LuminPro_V2.5.0-beta.1.zip",
|
||||
"versionCode": 2050056,
|
||||
"version": "V2.5.0-beta.6",
|
||||
"zipUrl": "https://github.com/YuleBest/LuminPro/releases/download/v2.5.0-beta.6/LuminPro_V2.5.0-beta.6.zip",
|
||||
"changelog": "https://raw.githubusercontent.com/YuleBest/LuminPro/beta/changelog.md"
|
||||
}
|
||||
+3
-3
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"versionCode": 2401,
|
||||
"version": "V2.4-2401",
|
||||
"zipUrl": "https://github.com/YuleBest/LuminPro/releases/download/v2.4-2401/LuminPro_V2.4-2401-f2c489e.zip",
|
||||
"versionCode": 2050090,
|
||||
"version": "V2.5.0",
|
||||
"zipUrl": "https://github.com/YuleBest/LuminPro/releases/download/v2.5.0/LuminPro_V2.5.0.zip",
|
||||
"changelog": "https://raw.githubusercontent.com/YuleBest/LuminPro/main/changelog.md"
|
||||
}
|
||||
@@ -1,20 +0,0 @@
|
||||
{
|
||||
"$schema": "https://shadcn-vue.com/schema.json",
|
||||
"style": "default",
|
||||
"typescript": false,
|
||||
"tailwind": {
|
||||
"config": "",
|
||||
"css": "src/index.css",
|
||||
"baseColor": "slate",
|
||||
"cssVariables": true,
|
||||
"prefix": ""
|
||||
},
|
||||
"aliases": {
|
||||
"components": "@/components",
|
||||
"utils": "@/lib/utils",
|
||||
"ui": "@/components/ui",
|
||||
"lib": "@/lib",
|
||||
"composables": "@/composables"
|
||||
},
|
||||
"registries": []
|
||||
}
|
||||
+1
-1
@@ -2,7 +2,7 @@
|
||||
<html lang="zh-CN">
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no, viewport-fit=cover" />
|
||||
<title>LuminPro</title>
|
||||
<link rel="stylesheet" type="text/css" href="/internal/insets.css" />
|
||||
</head>
|
||||
|
||||
+105
-206
@@ -1,12 +1,17 @@
|
||||
<script setup>
|
||||
import { ref, computed, provide, onMounted, onUnmounted, watch, nextTick } from 'vue'
|
||||
import { moduleInfo } from 'kernelsu'
|
||||
import { runCmd, showToast } from './utils.js'
|
||||
import { ref, computed, provide, onMounted, onUnmounted, watch } from 'vue'
|
||||
import { useStatus } from './composables/useStatus.js'
|
||||
import { useConfig } from './composables/useConfig.js'
|
||||
import { useLog } from './composables/useLog.js'
|
||||
import { useOplock } from './composables/useOplock.js'
|
||||
import BottomNav from './components/BottomNav.vue'
|
||||
import { useApps } from './composables/useApps.js'
|
||||
import { useSnackbar, useWebUIPrefs } from './composables/useSnackbar.js'
|
||||
import { moduleVersion } from './api/ksu.js'
|
||||
|
||||
import AppTopBar from './components/AppTopBar.vue'
|
||||
import AppBottomNav from './components/AppBottomNav.vue'
|
||||
import SnackbarHost from './components/SnackbarHost.vue'
|
||||
import OpLockBanner from './components/OpLockBanner.vue'
|
||||
|
||||
import StatusView from './views/StatusView.vue'
|
||||
import ConfigView from './views/ConfigView.vue'
|
||||
import AppsView from './views/AppsView.vue'
|
||||
@@ -15,240 +20,134 @@ import AboutView from './views/AboutView.vue'
|
||||
|
||||
const NAV_ORDER = ['status', 'config', 'apps', 'log', 'about']
|
||||
const currentView = ref('status')
|
||||
const headerEl = ref(null)
|
||||
const headerHidden = ref(false)
|
||||
// 操作锁横幅实测高度,用于把 header 与页面内容整体下移,避免被横幅遮挡
|
||||
const bannerEl = ref(null)
|
||||
const oplockOffset = ref('0px')
|
||||
const scrolled = ref(false)
|
||||
const version = ref(moduleVersion())
|
||||
|
||||
const trackStyle = computed(() => {
|
||||
const idx = NAV_ORDER.indexOf(currentView.value)
|
||||
return { transform: `translateX(${-idx * 100}%)` }
|
||||
})
|
||||
const moduleVersion = ref('')
|
||||
// 通道徽标:版本号里带 -beta / -dev 即为对应通道(打包时写入)
|
||||
const channelBadge = computed(() => {
|
||||
const v = moduleVersion.value.toLowerCase()
|
||||
if (v.includes('-beta')) return 'Beta'
|
||||
if (v.includes('-dev')) return 'Dev'
|
||||
return ''
|
||||
})
|
||||
const snackbar = useSnackbar()
|
||||
const status = useStatus()
|
||||
const config = useConfig()
|
||||
const log = useLog()
|
||||
const oplock = useOplock()
|
||||
const apps = useApps()
|
||||
const prefs = useWebUIPrefs()
|
||||
|
||||
// 供子组件使用
|
||||
provide('showToast', showToast)
|
||||
provide('snackbar', snackbar.show)
|
||||
provide('status', status)
|
||||
provide('config', config)
|
||||
provide('log', log)
|
||||
provide('oplock', oplock)
|
||||
provide('apps', apps)
|
||||
provide('prefs', prefs)
|
||||
|
||||
// 操作锁探测间隔:锁定期间用短间隔以便尽快感知结束;自动刷新关闭时用较轻的空闲间隔
|
||||
const trackStyle = computed(() => ({
|
||||
transform: `translateX(${-NAV_ORDER.indexOf(currentView.value) * 100}%)`,
|
||||
}))
|
||||
const locked = computed(() => status.oplock.value.locked)
|
||||
|
||||
// ── 刷新循环 ────────────────────────────────────────────────────────
|
||||
// 锁定期间只轮询操作锁(轻量),解锁后按用户频率刷新状态与日志;
|
||||
// dumpsys/settings 每 N 次完整刷新才读一次,避免无谓开销。
|
||||
const LOCK_POLL_INTERVAL = 300
|
||||
const LOCK_IDLE_INTERVAL = 2000
|
||||
let refreshTimer = null
|
||||
let refreshStopped = false
|
||||
let _prevLocked = false
|
||||
const DISPLAY_EVERY = 5
|
||||
let timer = null
|
||||
let stopped = false
|
||||
let ticks = 0
|
||||
|
||||
function startRefresh() {
|
||||
stopRefresh()
|
||||
refreshStopped = false
|
||||
refreshTimer = setTimeout(tick, config.statusRefreshInterval.value)
|
||||
}
|
||||
|
||||
function stopRefresh() {
|
||||
refreshStopped = true
|
||||
if (refreshTimer) {
|
||||
clearTimeout(refreshTimer)
|
||||
refreshTimer = null
|
||||
}
|
||||
function schedule(ms) {
|
||||
timer = setTimeout(tick, ms)
|
||||
}
|
||||
|
||||
async function tick() {
|
||||
refreshTimer = null
|
||||
if (refreshStopped) return
|
||||
timer = null
|
||||
if (stopped) return
|
||||
|
||||
let locked = false
|
||||
try {
|
||||
locked = await oplock.refresh()
|
||||
} catch {}
|
||||
|
||||
if (locked) {
|
||||
// 锁定期间不刷新数据,仅以更短间隔探测锁释放
|
||||
_prevLocked = true
|
||||
refreshTimer = setTimeout(tick, LOCK_POLL_INTERVAL)
|
||||
await status.refreshOplock()
|
||||
if (status.oplock.value.locked) {
|
||||
schedule(LOCK_POLL_INTERVAL)
|
||||
return
|
||||
}
|
||||
|
||||
// 锁刚释放时强制全量刷新,否则亮度值会停留在操作前的旧值
|
||||
try {
|
||||
if (config.autoRefresh.value) {
|
||||
await Promise.all([status.load(_prevLocked), log.load()])
|
||||
} else if (_prevLocked) {
|
||||
await status.load(true)
|
||||
}
|
||||
} catch {}
|
||||
_prevLocked = false
|
||||
|
||||
const next = config.autoRefresh.value ? config.statusRefreshInterval.value : LOCK_IDLE_INTERVAL
|
||||
refreshTimer = setTimeout(tick, next)
|
||||
ticks += 1
|
||||
const withDisplay = ticks % DISPLAY_EVERY === 1
|
||||
await Promise.all([status.load({ display: withDisplay }), log.load()])
|
||||
schedule(Math.max(200, prefs.refreshInterval.value))
|
||||
}
|
||||
|
||||
function restartRefresh(enabled, interval) {
|
||||
config.autoRefresh.value = enabled
|
||||
config.statusRefreshInterval.value = interval
|
||||
startRefresh()
|
||||
function startRefresh() {
|
||||
stopRefresh()
|
||||
stopped = false
|
||||
schedule(Math.max(200, prefs.refreshInterval.value))
|
||||
}
|
||||
provide('restartRefresh', restartRefresh)
|
||||
|
||||
// 横幅出现/消失时测量其高度,作为 header 与页面内容的下移量
|
||||
watch(oplock.isLocked, async (locked) => {
|
||||
await nextTick()
|
||||
oplockOffset.value = locked && bannerEl.value ? `${bannerEl.value.offsetHeight}px` : '0px'
|
||||
function stopRefresh() {
|
||||
stopped = true
|
||||
if (timer) {
|
||||
clearTimeout(timer)
|
||||
timer = null
|
||||
}
|
||||
}
|
||||
|
||||
async function manualRefresh() {
|
||||
await Promise.all([status.load({ display: true }), log.load()])
|
||||
snackbar.show('已刷新')
|
||||
}
|
||||
|
||||
function onPageScroll(event) {
|
||||
if (!event.target?.classList?.contains('page-slide')) return
|
||||
scrolled.value = event.target.scrollTop > 8
|
||||
}
|
||||
|
||||
function onViewChange(view) {
|
||||
currentView.value = view
|
||||
scrolled.value = false
|
||||
const slides = document.querySelectorAll('.page-slide')
|
||||
const slide = slides[NAV_ORDER.indexOf(view)]
|
||||
if (slide) slide.scrollTop = 0
|
||||
}
|
||||
|
||||
// 应用列表较慢,首次进入黑名单页再加载
|
||||
watch(currentView, (view) => {
|
||||
if (view === 'apps' && apps.apps.value.length === 0 && !apps.isLoading.value) apps.load()
|
||||
})
|
||||
|
||||
// 跟随系统色彩偏好变化
|
||||
let _mq = null
|
||||
function _onSystemTheme() {
|
||||
if (config.themeMode.value === 'system') config.applyTheme('system')
|
||||
}
|
||||
|
||||
onMounted(async () => {
|
||||
// 应用 UI 缩放 + 主题
|
||||
config.applyZoom()
|
||||
config.applyTheme(config.themeMode.value)
|
||||
_mq = window.matchMedia('(prefers-color-scheme: light)')
|
||||
_mq.addEventListener('change', _onSystemTheme)
|
||||
|
||||
// 读取模块版本
|
||||
try {
|
||||
const info = JSON.parse(moduleInfo())
|
||||
moduleVersion.value = info.version || ''
|
||||
} catch {
|
||||
moduleVersion.value = '[debug]'
|
||||
}
|
||||
|
||||
window.removeEventListener('scroll', onPageScroll)
|
||||
|
||||
// 测量 header 高度,用于隐藏时 viewport 补位
|
||||
if (headerEl.value) {
|
||||
const h = headerEl.value.offsetHeight
|
||||
const appEl = document.getElementById('app')
|
||||
if (appEl) appEl.style.setProperty('--header-height', h + 'px')
|
||||
}
|
||||
|
||||
// 初始加载
|
||||
try {
|
||||
await Promise.all([status.load(true), config.load(), log.load()])
|
||||
} catch {}
|
||||
|
||||
prefs.applyZoom()
|
||||
prefs.applyTheme(prefs.themeMode.value)
|
||||
await Promise.all([status.load({ display: true }), config.load(), log.load()])
|
||||
startRefresh()
|
||||
})
|
||||
|
||||
onUnmounted(() => {
|
||||
stopRefresh()
|
||||
_mq?.removeEventListener('change', _onSystemTheme)
|
||||
})
|
||||
|
||||
function onPageScroll(e) {
|
||||
// 只响应 .page-slide 的滚动,忽略内部子滚动容器(如应用列表)
|
||||
if (!e.target.classList.contains('page-slide')) return
|
||||
const topBlur = document.querySelector('.top-blur')
|
||||
const { scrollTop } = e.target
|
||||
if (topBlur) topBlur.classList.toggle('scrolled', scrollTop > 10)
|
||||
headerHidden.value = scrollTop > 0
|
||||
}
|
||||
|
||||
function handleViewChange(view) {
|
||||
currentView.value = view
|
||||
headerHidden.value = false // 切换页面时恢复显示 header
|
||||
|
||||
const idx = NAV_ORDER.indexOf(view)
|
||||
const slides = document.querySelectorAll('.page-slide')
|
||||
const slide = slides[idx]
|
||||
|
||||
// 切换页面时回顶
|
||||
if (slide) slide.scrollTop = 0
|
||||
|
||||
// 切换后 top-blur 跟随新页面状态(已回顶故一定为 false)
|
||||
const topBlur = document.querySelector('.top-blur')
|
||||
if (topBlur) topBlur.classList.remove('scrolled')
|
||||
}
|
||||
onUnmounted(stopRefresh)
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="min-h-screen bg-background text-foreground">
|
||||
<!-- 顶部状态栏渐变模糊 -->
|
||||
<div class="top-blur"></div>
|
||||
<AppTopBar
|
||||
:version="version"
|
||||
:status-text="status.statusText.value"
|
||||
:status-class="status.statusClass.value"
|
||||
:paused="status.isPaused.value"
|
||||
:locked="locked"
|
||||
:scrolled="scrolled"
|
||||
@refresh="manualRefresh"
|
||||
@toggle-service="status.toggleService(snackbar.show)"
|
||||
@restart="status.restart(snackbar.show)"
|
||||
/>
|
||||
|
||||
<div
|
||||
id="app"
|
||||
:class="{ 'header-hidden': headerHidden }"
|
||||
:style="{ '--oplock-offset': oplockOffset }"
|
||||
>
|
||||
<!-- 操作锁横幅 -->
|
||||
<Transition name="oplock-fade">
|
||||
<div v-if="oplock.isLocked.value" class="oplock-banner" role="status" ref="bannerEl">
|
||||
<span class="oplock-spinner"></span>
|
||||
<span>正在执行后台操作,已暂停刷新</span>
|
||||
</div>
|
||||
</Transition>
|
||||
<OpLockBanner
|
||||
:locked="locked"
|
||||
:label="status.oplock.value.label || '正在执行后台操作'"
|
||||
:seconds="status.oplock.value.seconds || 0"
|
||||
/>
|
||||
|
||||
<!-- 顶部头 -->
|
||||
<header class="app-header" ref="headerEl">
|
||||
<div class="header-content">
|
||||
<div class="header-text">
|
||||
<h1>LuminPro</h1>
|
||||
<p class="header-subtitle">日用屏幕亮度强化</p>
|
||||
<p class="header-version">
|
||||
{{ moduleVersion || 'V2.2' }}
|
||||
<span v-if="channelBadge" class="version-channel">{{ channelBadge }}</span>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="header-status-container">
|
||||
<div class="header-status" id="module-status" :class="status.statusClass.value">
|
||||
<span class="status-dot"></span>
|
||||
<span class="status-text">{{ status.statusText.value }}</span>
|
||||
</div>
|
||||
<div class="header-status-actions">
|
||||
<button
|
||||
class="btn-status-action"
|
||||
id="btn-toggle-service"
|
||||
@click="status.toggleService(showToast)"
|
||||
>
|
||||
{{ status.isPaused.value ? '启用' : '暂停' }}
|
||||
</button>
|
||||
<button
|
||||
class="btn-status-action"
|
||||
id="btn-restart-service"
|
||||
:disabled="oplock.isLocked.value"
|
||||
@click="status.restartService(showToast)"
|
||||
>
|
||||
重启模块
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</header>
|
||||
|
||||
<!-- 左右滑动页面区 -->
|
||||
<div class="page-viewport" @scroll.capture.passive="onPageScroll">
|
||||
<div class="page-track" :style="trackStyle">
|
||||
<div class="page-slide"><StatusView /></div>
|
||||
<div class="page-slide"><ConfigView /></div>
|
||||
<div class="page-slide"><AppsView /></div>
|
||||
<div class="page-slide"><LogView /></div>
|
||||
<div class="page-slide"><AboutView /></div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="page-viewport" @scroll.capture.passive="onPageScroll">
|
||||
<div class="page-track" :style="trackStyle">
|
||||
<div class="page-slide"><StatusView /></div>
|
||||
<div class="page-slide"><ConfigView /></div>
|
||||
<div class="page-slide"><AppsView /></div>
|
||||
<div class="page-slide"><LogView /></div>
|
||||
<div class="page-slide"><AboutView /></div>
|
||||
</div>
|
||||
|
||||
<!-- 底栏导航 -->
|
||||
<BottomNav v-model="currentView" @update:model-value="handleViewChange" />
|
||||
|
||||
<!-- Toast (保持 id="toast" 供 utils.js showToast 使用) -->
|
||||
<div class="toast" id="toast"></div>
|
||||
</div>
|
||||
|
||||
<AppBottomNav :model-value="currentView" @update:model-value="onViewChange" />
|
||||
|
||||
<SnackbarHost :messages="snackbar.messages.value" />
|
||||
</template>
|
||||
@@ -1,330 +0,0 @@
|
||||
/* ==========================================
|
||||
About View Styles
|
||||
========================================== */
|
||||
.about-hero {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
padding: var(--spacing-l) 0 var(--spacing-m);
|
||||
gap: 8px;
|
||||
}
|
||||
.about-logo {
|
||||
width: 72px;
|
||||
height: 72px;
|
||||
border-radius: 20px;
|
||||
background: linear-gradient(
|
||||
135deg,
|
||||
var(--md-sys-color-primary-container),
|
||||
var(--md-sys-color-secondary-container)
|
||||
);
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
color: var(--md-sys-color-primary);
|
||||
margin-bottom: 4px;
|
||||
}
|
||||
.about-name {
|
||||
margin: 0;
|
||||
font-size: 1.5rem;
|
||||
font-weight: 700;
|
||||
color: var(--md-sys-color-on-surface);
|
||||
}
|
||||
.about-desc {
|
||||
margin: 0;
|
||||
font-size: 0.875rem;
|
||||
color: var(--md-sys-color-on-surface-variant);
|
||||
}
|
||||
.about-version-badge {
|
||||
display: inline-block;
|
||||
padding: 2px 10px;
|
||||
background-color: var(--md-sys-color-primary-container);
|
||||
color: var(--md-sys-color-on-primary-container);
|
||||
border-radius: 100px;
|
||||
font-size: 0.75rem;
|
||||
font-weight: 600;
|
||||
letter-spacing: 0.3px;
|
||||
}
|
||||
.about-section-title {
|
||||
font-size: 0.75rem;
|
||||
font-weight: 600;
|
||||
color: var(--md-sys-color-primary);
|
||||
text-transform: uppercase;
|
||||
letter-spacing: 1px;
|
||||
margin: var(--spacing-l) 0 var(--spacing-s);
|
||||
}
|
||||
.about-list {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 2px;
|
||||
background-color: var(--md-sys-color-surface-container);
|
||||
border-radius: var(--border-radius-m);
|
||||
overflow: hidden;
|
||||
}
|
||||
.about-list-item {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 12px;
|
||||
padding: 14px 16px;
|
||||
background: transparent;
|
||||
border: none;
|
||||
color: var(--md-sys-color-on-surface);
|
||||
font-size: 0.9375rem;
|
||||
font-family: inherit;
|
||||
cursor: pointer;
|
||||
text-decoration: none;
|
||||
transition: background-color 0.15s;
|
||||
text-align: left;
|
||||
width: 100%;
|
||||
}
|
||||
.about-list-item + .about-list-item {
|
||||
border-top: 1px solid rgba(var(--md-sys-color-on-surface-rgb, 0, 0, 0), 0.06);
|
||||
}
|
||||
.about-list-item:active {
|
||||
background-color: var(--md-sys-color-surface-container-high);
|
||||
}
|
||||
.about-list-icon {
|
||||
color: var(--md-sys-color-primary);
|
||||
flex-shrink: 0;
|
||||
}
|
||||
.about-list-chevron {
|
||||
margin-left: auto;
|
||||
color: var(--md-sys-color-on-surface-variant);
|
||||
opacity: 0.5;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
.about-footer {
|
||||
text-align: center;
|
||||
color: var(--md-sys-color-on-surface-variant);
|
||||
font-size: 0.8125rem;
|
||||
margin-top: var(--spacing-l);
|
||||
padding-top: var(--spacing-m);
|
||||
border-top: 1px solid rgba(var(--md-sys-color-outline-variant-rgb, 142, 144, 153), 0.15);
|
||||
}
|
||||
|
||||
/* ==========================================
|
||||
Doc Sheet (Bottom drawer)
|
||||
========================================== */
|
||||
.doc-sheet-backdrop {
|
||||
position: fixed;
|
||||
inset: 0;
|
||||
background: rgba(0, 0, 0, 0.5);
|
||||
backdrop-filter: blur(4px);
|
||||
z-index: 1999;
|
||||
opacity: 0;
|
||||
pointer-events: none;
|
||||
transition: opacity 0.3s ease;
|
||||
}
|
||||
.doc-sheet-backdrop.show {
|
||||
opacity: 1;
|
||||
pointer-events: auto;
|
||||
}
|
||||
.doc-sheet {
|
||||
position: fixed;
|
||||
left: 0;
|
||||
right: 0;
|
||||
bottom: 0;
|
||||
max-height: 90vh;
|
||||
background-color: var(--md-sys-color-surface-container-high);
|
||||
border-radius: 28px 28px 0 0;
|
||||
z-index: 2000;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
transform: translateY(100%);
|
||||
transition: transform 0.35s cubic-bezier(0.19, 1, 0.22, 1);
|
||||
box-shadow: 0 -8px 32px rgba(0, 0, 0, 0.3);
|
||||
overflow: hidden;
|
||||
}
|
||||
.doc-sheet.show {
|
||||
transform: translateY(0);
|
||||
}
|
||||
.doc-sheet-header {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
padding: 16px 16px 12px;
|
||||
border-bottom: 1px solid rgba(var(--md-sys-color-on-surface-rgb, 0, 0, 0), 0.07);
|
||||
gap: 12px;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
.doc-sheet-title {
|
||||
font-size: 1.0625rem;
|
||||
font-weight: 600;
|
||||
color: var(--md-sys-color-on-surface);
|
||||
flex: 1;
|
||||
}
|
||||
.doc-sheet-close {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
width: 32px;
|
||||
height: 32px;
|
||||
border-radius: 50%;
|
||||
border: none;
|
||||
background: transparent;
|
||||
color: var(--md-sys-color-on-surface-variant);
|
||||
cursor: pointer;
|
||||
transition: background-color 0.15s;
|
||||
}
|
||||
.doc-sheet-close:active {
|
||||
background-color: var(--md-sys-color-surface-container);
|
||||
}
|
||||
.doc-sheet-body {
|
||||
flex: 1;
|
||||
overflow-y: auto;
|
||||
padding: 20px 20px 48px;
|
||||
scrollbar-width: none;
|
||||
}
|
||||
.doc-sheet-body::-webkit-scrollbar {
|
||||
display: none;
|
||||
}
|
||||
.doc-sheet-loading {
|
||||
text-align: center;
|
||||
padding: 48px 20px;
|
||||
color: var(--md-sys-color-on-surface-variant);
|
||||
}
|
||||
.doc-sheet-content {
|
||||
font-size: 0.9rem;
|
||||
line-height: 1.75;
|
||||
color: var(--md-sys-color-on-surface);
|
||||
word-break: break-word;
|
||||
}
|
||||
.doc-sheet-content h1,
|
||||
.doc-sheet-content h2 {
|
||||
color: var(--md-sys-color-primary);
|
||||
margin-top: 1.4em;
|
||||
margin-bottom: 0.4em;
|
||||
}
|
||||
.doc-sheet-content h3,
|
||||
.doc-sheet-content h4 {
|
||||
color: var(--md-sys-color-on-primary-container);
|
||||
margin-top: 1.2em;
|
||||
margin-bottom: 0.3em;
|
||||
}
|
||||
.doc-sheet-content p {
|
||||
margin: 0.6em 0;
|
||||
}
|
||||
.doc-sheet-content a {
|
||||
color: var(--md-sys-color-primary);
|
||||
text-decoration: underline;
|
||||
word-break: break-all;
|
||||
}
|
||||
.doc-sheet-content ul,
|
||||
.doc-sheet-content ol {
|
||||
padding-left: 1.4em;
|
||||
margin: 0.5em 0;
|
||||
}
|
||||
.doc-sheet-content li {
|
||||
margin: 0.25em 0;
|
||||
}
|
||||
.doc-sheet-content code {
|
||||
background-color: var(--md-sys-color-surface-container);
|
||||
padding: 2px 6px;
|
||||
border-radius: 4px;
|
||||
font-family: 'Geist Mono', monospace;
|
||||
font-size: 0.85em;
|
||||
}
|
||||
.doc-sheet-content pre {
|
||||
background-color: var(--md-sys-color-surface-container);
|
||||
border-radius: 8px;
|
||||
padding: 12px 14px;
|
||||
overflow-x: auto;
|
||||
margin: 0.75em 0;
|
||||
}
|
||||
.doc-sheet-content pre code {
|
||||
background: none;
|
||||
padding: 0;
|
||||
border-radius: 0;
|
||||
font-size: 0.82em;
|
||||
line-height: 1.6;
|
||||
}
|
||||
.doc-sheet-content blockquote {
|
||||
border-left: 3px solid var(--md-sys-color-primary-container);
|
||||
margin: 0.75em 0;
|
||||
padding: 0.2em 0.75em;
|
||||
color: var(--md-sys-color-on-surface-variant);
|
||||
background-color: rgba(var(--md-sys-color-primary-rgb), 0.06);
|
||||
border-radius: 0 4px 4px 0;
|
||||
}
|
||||
.doc-sheet-content hr {
|
||||
border: none;
|
||||
border-top: 1px solid var(--md-sys-color-outline-variant);
|
||||
margin: 1.2em 0;
|
||||
}
|
||||
.doc-sheet-content table {
|
||||
border-collapse: collapse;
|
||||
width: 100%;
|
||||
margin: 0.75em 0;
|
||||
font-size: 0.85em;
|
||||
}
|
||||
.doc-sheet-content th,
|
||||
.doc-sheet-content td {
|
||||
border: 1px solid var(--md-sys-color-outline-variant);
|
||||
padding: 6px 10px;
|
||||
text-align: left;
|
||||
}
|
||||
.doc-sheet-content th {
|
||||
background-color: var(--md-sys-color-surface-container);
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
/* ==========================================
|
||||
Log Filter Tabs
|
||||
========================================== */
|
||||
.log-filter-container {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: var(--spacing-s);
|
||||
}
|
||||
.log-filter-tabs {
|
||||
display: flex;
|
||||
gap: 4px;
|
||||
background-color: var(--md-sys-color-surface-container);
|
||||
padding: 4px;
|
||||
border-radius: var(--border-radius-s);
|
||||
}
|
||||
.log-filter-tab {
|
||||
padding: 4px 12px;
|
||||
border-radius: calc(var(--border-radius-s) - 2px);
|
||||
border: none;
|
||||
background: transparent;
|
||||
color: var(--md-sys-color-on-surface-variant);
|
||||
font-size: 0.8125rem;
|
||||
font-weight: 500;
|
||||
font-family: inherit;
|
||||
cursor: pointer;
|
||||
transition: all 0.2s;
|
||||
}
|
||||
.log-filter-tab.active {
|
||||
background-color: var(--md-sys-color-surface-container-high);
|
||||
color: var(--md-sys-color-primary);
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
/* ==========================================
|
||||
Theme Segmented Button
|
||||
========================================== */
|
||||
.theme-seg {
|
||||
display: flex;
|
||||
gap: 2px;
|
||||
background-color: var(--md-sys-color-surface-container);
|
||||
padding: 3px;
|
||||
border-radius: var(--border-radius-s);
|
||||
flex-shrink: 0;
|
||||
}
|
||||
.theme-seg-btn {
|
||||
padding: 4px 12px;
|
||||
border-radius: calc(var(--border-radius-s) - 2px);
|
||||
border: none;
|
||||
background: transparent;
|
||||
color: var(--md-sys-color-on-surface-variant);
|
||||
font-size: 0.8125rem;
|
||||
font-weight: 500;
|
||||
font-family: inherit;
|
||||
cursor: pointer;
|
||||
transition: all 0.18s ease;
|
||||
white-space: nowrap;
|
||||
}
|
||||
.theme-seg-btn.active {
|
||||
background-color: var(--md-sys-color-primary-container);
|
||||
color: var(--md-sys-color-on-primary-container);
|
||||
font-weight: 600;
|
||||
}
|
||||
@@ -0,0 +1,82 @@
|
||||
/**
|
||||
* 开发环境(浏览器直开、无 KernelSU bridge)下返回模拟数据,
|
||||
* 便于在电脑上调试界面。真机永远不会走到这里。
|
||||
*/
|
||||
|
||||
const mockStatus = (display) => ({
|
||||
module: { id: 'LuminPro', name: 'LuminPro', version: 'V2.5.0-beta.2', versionCode: 2050052, channel: 'beta' },
|
||||
daemon: { pid: 12345, running: true, state: 'S', mode: 'event', paused: false, uptimeSec: 3620 },
|
||||
brightness: { current: 1200, max: 4095, percent: 29, node: '/sys/mock/brightness', maxNode: '/sys/mock/max_brightness' },
|
||||
display: display
|
||||
? { hdrRatio: 1.02, hdrKnown: true, hdrStale: false, hdrSleep: false, autoBrightness: false }
|
||||
: undefined,
|
||||
sleep: { window: '2300-0700', active: false },
|
||||
oplock: { locked: false, seconds: 0 },
|
||||
config: {
|
||||
uiMaxBri: 1000,
|
||||
maxBri: 3500,
|
||||
stepsNum: 50,
|
||||
sleepTime: '2300-0700',
|
||||
autoBriSleep: 1,
|
||||
displayHdrSleep: 0,
|
||||
hdrEnterRatio: 1.15,
|
||||
hdrExitRatio: 1.05,
|
||||
compatibilityMode: 0,
|
||||
logLevel: 'info',
|
||||
logMaxSize: 512,
|
||||
debugMode: 0,
|
||||
nowBriFile: '/sys/class/backlight/panel0-backlight/brightness',
|
||||
maxBriFile: '/sys/class/backlight/panel0-backlight/max_brightness',
|
||||
blacklistCount: 3,
|
||||
},
|
||||
log: { path: '/data/adb/modules/LuminPro/service.log', sizeKB: 12 },
|
||||
})
|
||||
|
||||
const mockConfig = () => ({
|
||||
ui_max_bri: 1000,
|
||||
max_bri: 3500,
|
||||
steps_num: 50,
|
||||
log_max_size: 512,
|
||||
auto_bri_sleep: 1,
|
||||
display_hdr_sleep: 0,
|
||||
hdr_enter_ratio: 1.15,
|
||||
hdr_exit_ratio: 1.05,
|
||||
compatibility_mode: 0,
|
||||
sleep_time: '2300-0700',
|
||||
inotify_events: 'c',
|
||||
now_bri_file: '/sys/mock/brightness',
|
||||
max_bri_file: '/sys/mock/max_brightness',
|
||||
log_level: 'info',
|
||||
debug_mode: 0,
|
||||
blacklist_apps: ['com.example.video'],
|
||||
})
|
||||
|
||||
const mockLogEntries = [
|
||||
{ time: '09-10 12:00:01', tag: 'luminpro', level: 'INFO', message: '守护进程已启动' },
|
||||
{ time: '09-10 12:00:03', tag: 'luminpro', level: 'INFO', message: '正在监听: /sys/mock/brightness, 事件: c' },
|
||||
{ time: '09-10 12:01:12', tag: 'luminpro', level: 'INFO', message: '触发提升: 当前亮度 1200 ≥ 阈值 1000,目标 3500' },
|
||||
{ time: '09-10 12:01:12', tag: 'luminpro', level: 'WARN', message: 'HDR 比率读取为空,使用缓存值: 1.02' },
|
||||
{ time: '09-10 12:01:13', tag: 'luminpro', level: 'SUCCESS', message: '亮度提升完成 (3500)' },
|
||||
]
|
||||
|
||||
const ok = (obj) => ({ ok: true, errno: 0, stdout: JSON.stringify(obj), stderr: '' })
|
||||
|
||||
/** 依据命令内容返回模拟响应;无法识别时返回 null */
|
||||
export function devMock(command) {
|
||||
// 参数经 shellQuote 包装过,比较前先去掉单引号
|
||||
const plain = command.replace(/'/g, '')
|
||||
if (plain.includes(' config read')) return ok(mockConfig())
|
||||
if (plain.includes(' config patch') || plain.includes(' config set')) return ok({ ok: true })
|
||||
if (plain.includes(' status')) return ok(mockStatus(!plain.includes('--no-display')))
|
||||
if (plain.includes(' oplock')) return ok({ locked: false, seconds: 0 })
|
||||
if (plain.includes(' focus')) return ok({ focus: 'com.example.video/.MainActivity' })
|
||||
if (plain.includes(' brightness set')) return ok({ ok: true, value: 2000 })
|
||||
if (plain.includes(' log tail')) {
|
||||
return ok({ entries: mockLogEntries, sizeKB: 12, total: mockLogEntries.length })
|
||||
}
|
||||
if (plain.includes(' log clear') || plain.includes(' log export')) return ok({ ok: true })
|
||||
if (plain.includes('boost') || plain.includes('restart') || plain.includes('action.sh')) {
|
||||
return { ok: true, errno: 0, stdout: 'LuminPro: 服务已启用', stderr: '' }
|
||||
}
|
||||
return null
|
||||
}
|
||||
@@ -0,0 +1,70 @@
|
||||
import { exec, moduleInfo } from 'kernelsu'
|
||||
import { devMock } from './devMock.js'
|
||||
|
||||
export const MODULE_DIR = '/data/adb/modules/LuminPro'
|
||||
export const BIN = `${MODULE_DIR}/bin/luminpro`
|
||||
|
||||
/** 是否为 KernelSU 环境(exec 可用) */
|
||||
let available = true
|
||||
|
||||
export function isKsuAvailable() {
|
||||
return available
|
||||
}
|
||||
|
||||
/**
|
||||
* 执行 shell 命令。所有命令都是固定字符串或经 shellQuote 处理过的参数,
|
||||
* 不把未校验的用户输入直接拼进命令。
|
||||
*/
|
||||
export async function runCmd(command) {
|
||||
try {
|
||||
const res = await exec(command)
|
||||
available = true
|
||||
return {
|
||||
ok: res.errno === 0,
|
||||
errno: res.errno,
|
||||
stdout: res.stdout ?? '',
|
||||
stderr: res.stderr ?? '',
|
||||
}
|
||||
} catch (err) {
|
||||
available = false
|
||||
// 仅开发环境回退到模拟数据,真机上失败就是失败
|
||||
if (import.meta.env.DEV) {
|
||||
const mocked = devMock(command)
|
||||
if (mocked) return mocked
|
||||
}
|
||||
return { ok: false, errno: -1, stdout: '', stderr: String(err) }
|
||||
}
|
||||
}
|
||||
|
||||
/** 把任意字符串安全地包成 shell 单引号参数 */
|
||||
export function shellQuote(value) {
|
||||
return `'${String(value).replace(/'/g, "'\\''")}'`
|
||||
}
|
||||
|
||||
/**
|
||||
* 启用 edge-to-edge:内容延伸至状态栏/手势条区域,insets.css 的
|
||||
* --window-inset-* / --safe-area-inset-* 随之生效。
|
||||
*
|
||||
* 注意:不能直接调用从 npm 包 import 的 enableEdgeToEdge——该绑定总是存在,
|
||||
* 不支持时是包内部调用 ksu 对象时抛错,会打断后续脚本(FontMM 踩过同样的坑)。
|
||||
* 这里改为探测全局 ksu 对象,并兼容 KernelSU-Next 的 enableInsets 命名。
|
||||
*/
|
||||
export function applyEdgeToEdge() {
|
||||
try {
|
||||
const ksuApi = globalThis.ksu
|
||||
if (!ksuApi) return
|
||||
const fn = ksuApi.enableEdgeToEdge ?? ksuApi.enableInsets
|
||||
if (typeof fn === 'function') fn.call(ksuApi, true)
|
||||
} catch {
|
||||
/* 老版本没有该 API:布局仍可用,只是安全区取 0 */
|
||||
}
|
||||
}
|
||||
|
||||
/** 读取模块版本(module.prop 的 version) */
|
||||
export function moduleVersion() {
|
||||
try {
|
||||
return JSON.parse(moduleInfo()).version || ''
|
||||
} catch {
|
||||
return import.meta.env.DEV ? 'V2.5.0-dev.0' : ''
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,85 @@
|
||||
/**
|
||||
* Go 侧 JSON API 客户端。所有读写都经由 `luminpro` 子命令:
|
||||
* 一次调用拿回结构化数据,避免前端拼多条 shell 命令与字符串转义。
|
||||
*/
|
||||
import { BIN, MODULE_DIR, runCmd, shellQuote } from './ksu.js'
|
||||
|
||||
/** 调用返回 JSON 的子命令 */
|
||||
async function callJSON(subcommand, args = []) {
|
||||
const command = [BIN, subcommand, ...args.map(shellQuote)].join(' ')
|
||||
const res = await runCmd(command)
|
||||
if (!res.ok) {
|
||||
throw new Error(res.stderr.trim() || `命令执行失败: luminpro ${subcommand}`)
|
||||
}
|
||||
try {
|
||||
return JSON.parse(res.stdout)
|
||||
} catch {
|
||||
throw new Error(`输出不是合法 JSON: luminpro ${subcommand}`)
|
||||
}
|
||||
}
|
||||
|
||||
/** 聚合状态;display=false 时跳过 dumpsys/settings 读取 */
|
||||
export function fetchStatus({ display = true } = {}) {
|
||||
return callJSON('status', display ? [] : ['--no-display'])
|
||||
}
|
||||
|
||||
/** 操作锁状态(轻量,供高频轮询) */
|
||||
export function fetchOplock() {
|
||||
return callJSON('oplock')
|
||||
}
|
||||
|
||||
/** 当前前台 Activity(活动抓取向导用) */
|
||||
export function fetchFocus() {
|
||||
return callJSON('focus')
|
||||
}
|
||||
|
||||
/** 设置亮度 */
|
||||
export function setBrightness(value) {
|
||||
return callJSON('brightness', ['set', String(value)])
|
||||
}
|
||||
|
||||
/** 读取完整配置 */
|
||||
export function fetchConfig() {
|
||||
return callJSON('config', ['read'])
|
||||
}
|
||||
|
||||
/** 浅合并写入配置(只传变化字段) */
|
||||
export function patchConfig(patch) {
|
||||
return callJSON('config', ['patch', JSON.stringify(patch)])
|
||||
}
|
||||
|
||||
/** 读取日志 */
|
||||
export function fetchLog(lines = 200) {
|
||||
return callJSON('log', ['tail', '-n', String(lines)])
|
||||
}
|
||||
|
||||
/** 清空日志 */
|
||||
export function clearLog() {
|
||||
return callJSON('log', ['clear'])
|
||||
}
|
||||
|
||||
/** 导出日志到 /sdcard */
|
||||
export function exportLog(dir = '/sdcard') {
|
||||
return callJSON('log', ['export', dir])
|
||||
}
|
||||
|
||||
/** 一键提升 / 恢复 */
|
||||
export function boost() {
|
||||
return runCmd(`${BIN} boost`)
|
||||
}
|
||||
|
||||
/** 重启模块 */
|
||||
export function restart() {
|
||||
return runCmd(`${BIN} restart`)
|
||||
}
|
||||
|
||||
/** 启停切换(沿用 action.sh,管理器「操作」按钮与之共用同一实现) */
|
||||
export function toggleService() {
|
||||
return runCmd(`sh ${MODULE_DIR}/action.sh`)
|
||||
}
|
||||
|
||||
/** 模块文档内容(关于页) */
|
||||
export async function readModuleFile(name) {
|
||||
const res = await runCmd(`cat ${shellQuote(`${MODULE_DIR}/${name}`)} 2>/dev/null`)
|
||||
return res.ok ? res.stdout : ''
|
||||
}
|
||||
@@ -1,562 +0,0 @@
|
||||
.app-list-hint {
|
||||
font-size: 0.8125rem;
|
||||
color: var(--md-sys-color-on-surface-variant);
|
||||
margin-top: 0;
|
||||
margin-bottom: var(--spacing-m);
|
||||
}
|
||||
|
||||
/* App Search */
|
||||
.app-search-container {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
background-color: var(--md-sys-color-surface-container-high);
|
||||
border: 1px solid var(--md-sys-color-outline-variant);
|
||||
border-radius: var(--border-radius-m);
|
||||
padding: 8px 12px;
|
||||
margin-bottom: var(--spacing-m);
|
||||
transition:
|
||||
border-color 0.2s,
|
||||
box-shadow 0.2s;
|
||||
}
|
||||
|
||||
.app-search-container:focus-within {
|
||||
border-color: var(--md-sys-color-primary);
|
||||
box-shadow: 0 0 0 2px rgba(168, 199, 250, 0.3);
|
||||
}
|
||||
|
||||
.search-icon {
|
||||
width: 18px;
|
||||
height: 18px;
|
||||
color: var(--md-sys-color-on-surface-variant);
|
||||
margin-right: 8px;
|
||||
}
|
||||
|
||||
.app-search-input {
|
||||
flex: 1;
|
||||
width: 100%;
|
||||
min-width: 0;
|
||||
background: transparent;
|
||||
border: none;
|
||||
color: var(--md-sys-color-on-surface);
|
||||
font-size: 0.875rem;
|
||||
outline: none;
|
||||
font-family: inherit;
|
||||
}
|
||||
|
||||
.app-search-input::placeholder {
|
||||
color: var(--md-sys-color-on-surface-variant);
|
||||
}
|
||||
|
||||
.count-badge {
|
||||
background-color: var(--md-sys-color-primary-container);
|
||||
color: var(--md-sys-color-on-primary-container);
|
||||
font-size: 0.75rem;
|
||||
font-weight: 600;
|
||||
padding: 2px 8px;
|
||||
border-radius: 20px;
|
||||
margin-left: 8px;
|
||||
white-space: nowrap;
|
||||
opacity: 0.85;
|
||||
}
|
||||
|
||||
/* App List */
|
||||
.app-list-container {
|
||||
max-height: 60vh;
|
||||
overflow-y: auto;
|
||||
border-radius: var(--border-radius-m);
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
.app-list-container::-webkit-scrollbar {
|
||||
display: none;
|
||||
}
|
||||
|
||||
/* 虚拟滚动:spacer 撑起总高度,行绝对定位;
|
||||
行间距由 item 的 padding-bottom 提供,保证测量行高包含间距 */
|
||||
.app-virtual-spacer {
|
||||
position: relative;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.app-virtual-item {
|
||||
position: absolute;
|
||||
top: 0;
|
||||
left: 0;
|
||||
width: 100%;
|
||||
padding-bottom: var(--spacing-s);
|
||||
}
|
||||
|
||||
.app-list-item {
|
||||
display: flex;
|
||||
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;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.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);
|
||||
}
|
||||
|
||||
.app-checkbox-label {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
cursor: pointer;
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.app-checkbox {
|
||||
opacity: 0;
|
||||
position: absolute;
|
||||
width: 0;
|
||||
height: 0;
|
||||
}
|
||||
|
||||
.app-checkbox-custom {
|
||||
width: 20px;
|
||||
height: 20px;
|
||||
border: 2px solid var(--md-sys-color-outline);
|
||||
border-radius: 4px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
transition: all 0.2s;
|
||||
}
|
||||
|
||||
.app-checkbox:checked + .app-checkbox-custom {
|
||||
background-color: var(--md-sys-color-primary);
|
||||
border-color: var(--md-sys-color-primary);
|
||||
}
|
||||
|
||||
.app-checkbox.unsaved:checked + .app-checkbox-custom {
|
||||
background-color: #4caf50;
|
||||
border-color: #4caf50;
|
||||
}
|
||||
|
||||
.app-checkbox:checked + .app-checkbox-custom::after {
|
||||
content: '';
|
||||
width: 5px;
|
||||
height: 10px;
|
||||
border: solid var(--md-sys-color-on-primary);
|
||||
border-width: 0 2px 2px 0;
|
||||
transform: rotate(45deg);
|
||||
margin-bottom: 2px;
|
||||
}
|
||||
|
||||
.app-info {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
flex: 1;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.app-name {
|
||||
font-size: 1rem;
|
||||
font-weight: 500;
|
||||
color: var(--md-sys-color-on-surface);
|
||||
white-space: nowrap;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
}
|
||||
|
||||
.app-pkg {
|
||||
font-size: 0.8125rem;
|
||||
color: var(--md-sys-color-on-surface-variant);
|
||||
font-family: 'Geist Mono', monospace;
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
align-items: center;
|
||||
gap: 6px;
|
||||
word-break: break-all;
|
||||
line-height: 1.4;
|
||||
}
|
||||
|
||||
.app-badge {
|
||||
background-color: var(--md-sys-color-primary-container);
|
||||
color: var(--md-sys-color-on-primary-container);
|
||||
padding: 0 4px;
|
||||
border-radius: 4px;
|
||||
font-size: 0.65rem;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.app-icon {
|
||||
width: 40px;
|
||||
height: 40px;
|
||||
border-radius: 8px;
|
||||
object-fit: cover;
|
||||
flex-shrink: 0;
|
||||
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
|
||||
}
|
||||
|
||||
.app-icon-fallback {
|
||||
width: 40px;
|
||||
height: 40px;
|
||||
border-radius: 8px;
|
||||
background: linear-gradient(
|
||||
135deg,
|
||||
var(--md-sys-color-primary-container),
|
||||
rgba(168, 199, 250, 0.5)
|
||||
);
|
||||
color: var(--md-sys-color-on-primary-container);
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
font-size: 1.25rem;
|
||||
font-weight: bold;
|
||||
flex-shrink: 0;
|
||||
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
|
||||
}
|
||||
|
||||
.app-uid {
|
||||
font-size: 0.65rem;
|
||||
color: var(--md-sys-color-on-surface-variant);
|
||||
background-color: var(--md-sys-color-surface-container-high);
|
||||
border: 1px solid var(--md-sys-color-outline-variant);
|
||||
padding: 0 4px;
|
||||
border-radius: 4px;
|
||||
font-family: 'Geist Mono', monospace;
|
||||
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: 'Geist Mono', '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-header {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
}
|
||||
|
||||
.activity-block-label {
|
||||
font-size: 0.8125rem;
|
||||
font-weight: 500;
|
||||
color: var(--md-sys-color-on-surface);
|
||||
}
|
||||
|
||||
.btn-picker-trigger {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 4px;
|
||||
background: none;
|
||||
border: 1px solid var(--md-sys-color-outline-variant);
|
||||
border-radius: var(--border-radius-s);
|
||||
color: var(--md-sys-color-primary);
|
||||
font-size: 0.75rem;
|
||||
font-weight: 500;
|
||||
padding: 3px 8px;
|
||||
cursor: pointer;
|
||||
transition:
|
||||
background-color 0.2s,
|
||||
border-color 0.2s;
|
||||
white-space: nowrap;
|
||||
font-family: inherit;
|
||||
}
|
||||
|
||||
.btn-picker-trigger:hover {
|
||||
background-color: var(--md-sys-color-primary-container);
|
||||
border-color: var(--md-sys-color-primary);
|
||||
}
|
||||
|
||||
.activity-block-row {
|
||||
display: flex;
|
||||
gap: 8px;
|
||||
align-items: stretch;
|
||||
}
|
||||
|
||||
.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: 'Geist Mono', '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);
|
||||
}
|
||||
|
||||
/* ========================
|
||||
获取活动名向导覆盖层
|
||||
======================== */
|
||||
.activity-picker-overlay {
|
||||
position: fixed;
|
||||
inset: 0;
|
||||
background: var(--md-sys-color-background);
|
||||
z-index: 950;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
transform: translateX(100%);
|
||||
transition: transform 0.35s cubic-bezier(0.25, 1, 0.5, 1);
|
||||
}
|
||||
|
||||
.activity-picker-overlay.show {
|
||||
transform: translateX(0);
|
||||
}
|
||||
|
||||
.activity-picker-header {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 12px;
|
||||
padding: calc(var(--safe-area-inset-top, 0px) + 16px) 16px 12px;
|
||||
border-bottom: 1px solid var(--md-sys-color-outline-variant);
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.picker-back-btn {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
width: 36px;
|
||||
height: 36px;
|
||||
background: none;
|
||||
border: none;
|
||||
border-radius: 50%;
|
||||
color: var(--md-sys-color-on-surface);
|
||||
cursor: pointer;
|
||||
transition: background-color 0.2s;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.picker-back-btn:hover {
|
||||
background-color: var(--md-sys-color-surface-container);
|
||||
}
|
||||
|
||||
.picker-title {
|
||||
font-size: 1.0625rem;
|
||||
font-weight: 600;
|
||||
color: var(--md-sys-color-on-surface);
|
||||
}
|
||||
|
||||
.picker-steps-indicator {
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
padding: 16px 0 0;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.picker-step-dot {
|
||||
width: 6px;
|
||||
height: 6px;
|
||||
border-radius: 50%;
|
||||
background-color: var(--md-sys-color-outline-variant);
|
||||
transition:
|
||||
background-color 0.3s,
|
||||
transform 0.3s,
|
||||
width 0.3s;
|
||||
}
|
||||
|
||||
.picker-step-dot.active {
|
||||
background-color: var(--md-sys-color-primary);
|
||||
transform: scale(1.2);
|
||||
width: 18px;
|
||||
border-radius: 4px;
|
||||
}
|
||||
|
||||
.activity-picker-body {
|
||||
flex: 1;
|
||||
overflow-y: auto;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
.picker-step {
|
||||
flex: 1;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
padding: 32px 32px calc(var(--safe-area-inset-bottom, 0px) + 48px);
|
||||
text-align: center;
|
||||
gap: 14px;
|
||||
}
|
||||
|
||||
.picker-step-icon {
|
||||
color: var(--md-sys-color-primary);
|
||||
opacity: 0.9;
|
||||
margin-bottom: 4px;
|
||||
}
|
||||
|
||||
.picker-step-title {
|
||||
font-size: 1.25rem;
|
||||
font-weight: 600;
|
||||
color: var(--md-sys-color-on-background);
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.picker-step-desc {
|
||||
font-size: 0.9375rem;
|
||||
color: var(--md-sys-color-on-surface-variant);
|
||||
line-height: 1.65;
|
||||
max-width: 300px;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.picker-action-btn {
|
||||
margin-top: 12px;
|
||||
padding: 12px 32px;
|
||||
border-radius: 24px;
|
||||
font-size: 0.9375rem;
|
||||
}
|
||||
|
||||
.picker-status-text {
|
||||
display: inline-block;
|
||||
font-weight: 500;
|
||||
color: var(--md-sys-color-primary);
|
||||
}
|
||||
|
||||
.picker-status-text.polling {
|
||||
animation: picker-pulse 1.2s ease-in-out infinite;
|
||||
}
|
||||
|
||||
@keyframes picker-pulse {
|
||||
0%,
|
||||
100% {
|
||||
opacity: 1;
|
||||
}
|
||||
50% {
|
||||
opacity: 0.35;
|
||||
}
|
||||
}
|
||||
|
||||
.picker-result-box {
|
||||
background: var(--md-sys-color-surface-container-high);
|
||||
border: 1.5px solid var(--md-sys-color-primary);
|
||||
border-radius: var(--border-radius-m);
|
||||
padding: 14px 18px;
|
||||
font-family: 'Geist Mono', 'Roboto Mono', monospace;
|
||||
font-size: 0.875rem;
|
||||
color: var(--md-sys-color-on-surface);
|
||||
word-break: break-all;
|
||||
line-height: 1.55;
|
||||
max-width: 320px;
|
||||
width: 100%;
|
||||
text-align: left;
|
||||
}
|
||||
|
||||
.picker-result-actions {
|
||||
display: flex;
|
||||
gap: 12px;
|
||||
margin-top: 4px;
|
||||
}
|
||||
@@ -1,734 +0,0 @@
|
||||
// oxlint-disable no-unused-expressions
|
||||
import { listPackages, getPackagesInfo } from 'kernelsu'
|
||||
import { createIcons, Eye, EyeOff } from 'lucide'
|
||||
import PinyinMatch from 'pinyin-match'
|
||||
import { showToast, runCmd, readConfig, updateConfig } from './utils.js'
|
||||
|
||||
let showingSystemApps = true
|
||||
let savedBlacklist = new Set()
|
||||
let activityEntries = new Set() // 活动级黑名单条目(格式:pkg/ActivityClass)
|
||||
|
||||
export function updateUnsavedStyling() {
|
||||
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')
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
export function reorderDOMApps() {
|
||||
const container = document.getElementById('app-list-container')
|
||||
if (!container) return
|
||||
const items = Array.from(container.children)
|
||||
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))
|
||||
}
|
||||
|
||||
export 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)
|
||||
})
|
||||
}
|
||||
|
||||
export 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 {
|
||||
// 读取已保存的黑名单(从 JSON 配置读取)
|
||||
const cfg = await readConfig()
|
||||
const allSaved = Array.isArray(cfg.blacklist_apps) ? cfg.blacklist_apps : []
|
||||
savedBlacklist = new Set(allSaved)
|
||||
const savedPkgEntries = new Set(allSaved.filter((e) => !e.includes('/')))
|
||||
activityEntries = new Set(allSaved.filter((e) => e.includes('/')))
|
||||
|
||||
let infoList = []
|
||||
try {
|
||||
const pkgs = await listPackages()
|
||||
if (pkgs && pkgs.length > 0) {
|
||||
infoList = await getPackagesInfo(pkgs)
|
||||
} else {
|
||||
throw new Error('No packages found')
|
||||
}
|
||||
} catch {
|
||||
// 模拟 150 个应用包数据用于调试
|
||||
console.log('[DEBUG] 使用模拟应用列表数据')
|
||||
infoList = Array.from({ length: 150 }, (_, i) => ({
|
||||
packageName: `com.mock.app${i}`,
|
||||
appLabel: i % 10 === 0 ? `测试应用 ${i} (含抖音关键字)` : `模拟应用 ${i}`,
|
||||
isSystem: i % 5 === 0,
|
||||
uid: 10000 + i,
|
||||
}))
|
||||
}
|
||||
|
||||
// 过滤系统应用
|
||||
if (!showingSystemApps) {
|
||||
infoList = infoList.filter((app) => !app.isSystem)
|
||||
}
|
||||
|
||||
container.innerHTML = ''
|
||||
|
||||
// 排序:非系统优先,按名称
|
||||
infoList.sort((a, b) => {
|
||||
if (a.isSystem !== b.isSystem) return a.isSystem ? 1 : -1
|
||||
return (a.appLabel || '').localeCompare(b.appLabel || '')
|
||||
})
|
||||
|
||||
if (infoList.length === 0) {
|
||||
infoList.push(
|
||||
{
|
||||
packageName: 'com.example.app1',
|
||||
appLabel: '示例 1',
|
||||
isSystem: false,
|
||||
uid: 10123,
|
||||
},
|
||||
{
|
||||
packageName: 'com.example.app2',
|
||||
appLabel: '示例 2',
|
||||
isSystem: false,
|
||||
uid: 10124,
|
||||
},
|
||||
{
|
||||
packageName: 'com.example.sys1',
|
||||
appLabel: '系统示例 1',
|
||||
isSystem: true,
|
||||
uid: 1000,
|
||||
},
|
||||
{
|
||||
packageName: 'com.example.sys2',
|
||||
appLabel: '系统示例 2',
|
||||
isSystem: true,
|
||||
uid: 1001,
|
||||
},
|
||||
)
|
||||
if (!showingSystemApps) {
|
||||
infoList = infoList.filter((app) => !app.isSystem)
|
||||
}
|
||||
}
|
||||
|
||||
// uid 去重
|
||||
const seenUids = new Set()
|
||||
infoList = infoList.filter((app) => {
|
||||
if (app.uid === undefined || app.uid === null) return true
|
||||
if (seenUids.has(app.uid)) return false
|
||||
seenUids.add(app.uid)
|
||||
return true
|
||||
})
|
||||
|
||||
infoList.forEach((app) => {
|
||||
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 = app.packageName
|
||||
|
||||
// 依据已保存包名条目勾选(不含活动条目)
|
||||
checkbox.checked = savedPkgEntries.has(app.packageName)
|
||||
checkbox.addEventListener('change', () => {
|
||||
updateUnsavedStyling()
|
||||
reorderDOMApps()
|
||||
})
|
||||
|
||||
const customCheckbox = document.createElement('span')
|
||||
customCheckbox.className = 'app-checkbox-custom'
|
||||
checkboxLabel.appendChild(checkbox)
|
||||
checkboxLabel.appendChild(customCheckbox)
|
||||
|
||||
const infoDiv = document.createElement('div')
|
||||
infoDiv.className = 'app-info'
|
||||
|
||||
const nameSpan = document.createElement('span')
|
||||
nameSpan.className = 'app-name'
|
||||
nameSpan.appendChild(document.createTextNode(app.appLabel || 'Unknown'))
|
||||
|
||||
if (app.uid !== undefined) {
|
||||
const uidBadge = document.createElement('span')
|
||||
uidBadge.className = 'app-uid'
|
||||
uidBadge.textContent = String(app.uid)
|
||||
nameSpan.appendChild(uidBadge)
|
||||
}
|
||||
|
||||
const pkgSpan = document.createElement('span')
|
||||
pkgSpan.className = 'app-pkg'
|
||||
pkgSpan.textContent = app.packageName || ''
|
||||
|
||||
if (app.isSystem) {
|
||||
const sysBadge = document.createElement('span')
|
||||
sysBadge.className = 'app-badge'
|
||||
sysBadge.textContent = '系统'
|
||||
pkgSpan.appendChild(sysBadge)
|
||||
}
|
||||
|
||||
infoDiv.appendChild(nameSpan)
|
||||
infoDiv.appendChild(pkgSpan)
|
||||
|
||||
// 活动展开箭头
|
||||
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()
|
||||
|
||||
const badge = document.getElementById('app-count-badge')
|
||||
if (badge) badge.textContent = infoList.length
|
||||
|
||||
if (infoList.length === 0) {
|
||||
container.innerHTML =
|
||||
'<div style="text-align:center;padding:20px;color:var(--md-sys-color-on-surface-variant);">无应用</div>'
|
||||
}
|
||||
} catch (e) {
|
||||
container.innerHTML = `<div style="text-align:center;padding:20px;color:var(--md-sys-color-error);">加载失败: ${e.message || String(e)}</div>`
|
||||
}
|
||||
}
|
||||
|
||||
export function setupAppsEvents() {
|
||||
// 下拉菜单控制
|
||||
const btnAppsMenu = document.getElementById('btn-apps-menu')
|
||||
const appsDropdownMenu = document.getElementById('apps-dropdown-menu')
|
||||
|
||||
if (btnAppsMenu && appsDropdownMenu) {
|
||||
btnAppsMenu.addEventListener('click', (e) => {
|
||||
e.stopPropagation()
|
||||
appsDropdownMenu.classList.toggle('show')
|
||||
})
|
||||
document.addEventListener('click', (e) => {
|
||||
if (!btnAppsMenu.contains(e.target) && !appsDropdownMenu.contains(e.target)) {
|
||||
appsDropdownMenu.classList.remove('show')
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
// 切换系统应用显示
|
||||
const btnToggleSysApps = document.getElementById('btn-toggle-sys-apps')
|
||||
if (btnToggleSysApps) {
|
||||
btnToggleSysApps.addEventListener('click', () => {
|
||||
showingSystemApps = !showingSystemApps
|
||||
|
||||
const textSpan = document.getElementById('sys-apps-text')
|
||||
const iconWrap = document.getElementById('sys-apps-icon')
|
||||
|
||||
if (textSpan) textSpan.textContent = showingSystemApps ? '隐藏系统应用' : '显示系统应用'
|
||||
|
||||
if (iconWrap) {
|
||||
const p = iconWrap.parentNode
|
||||
const newIcon = document.createElement('i')
|
||||
newIcon.setAttribute('data-lucide', showingSystemApps ? 'eye-off' : 'eye')
|
||||
newIcon.id = 'sys-apps-icon'
|
||||
p.replaceChild(newIcon, iconWrap)
|
||||
createIcons({ icons: { Eye, EyeOff }, nameAttr: 'data-lucide' })
|
||||
}
|
||||
|
||||
loadApps()
|
||||
appsDropdownMenu && appsDropdownMenu.classList.remove('show')
|
||||
})
|
||||
}
|
||||
|
||||
// 智能选择
|
||||
const btnSmartSelect = document.getElementById('btn-smart-select')
|
||||
if (btnSmartSelect) {
|
||||
const smartKeywords = [
|
||||
'相册',
|
||||
'抖音',
|
||||
'快手',
|
||||
'视频',
|
||||
'哔哩哔哩',
|
||||
'bili',
|
||||
'pili',
|
||||
'netflix',
|
||||
'youtube',
|
||||
'tiktok',
|
||||
'x',
|
||||
]
|
||||
btnSmartSelect.addEventListener('click', () => {
|
||||
const items = document.querySelectorAll('.app-list-item')
|
||||
items.forEach((item) => {
|
||||
const name = item.querySelector('.app-name').textContent.toLowerCase()
|
||||
const checkbox = item.querySelector('.app-checkbox')
|
||||
let match = false
|
||||
for (const kw of smartKeywords) {
|
||||
if (kw === 'x') {
|
||||
if (name === 'x' || name === 'x (twitter)') {
|
||||
match = true
|
||||
break
|
||||
}
|
||||
} else if (name.includes(kw)) {
|
||||
match = true
|
||||
break
|
||||
}
|
||||
}
|
||||
if (match) checkbox.checked = true
|
||||
})
|
||||
updateUnsavedStyling()
|
||||
reorderDOMApps()
|
||||
appsDropdownMenu && appsDropdownMenu.classList.remove('show')
|
||||
})
|
||||
}
|
||||
|
||||
// 手动添加包名
|
||||
const btnManualAdd = document.getElementById('btn-manual-add')
|
||||
if (btnManualAdd) {
|
||||
btnManualAdd.addEventListener('click', async () => {
|
||||
appsDropdownMenu && appsDropdownMenu.classList.remove('show')
|
||||
const pkg = prompt('请输入你要彻底屏蔽的完整应用包名(例如: com.example.app):')
|
||||
if (!pkg || !pkg.trim()) return
|
||||
|
||||
const realPkg = pkg.trim()
|
||||
const existing = document.querySelector(`.app-checkbox[data-pkg="${realPkg}"]`)
|
||||
if (existing) {
|
||||
existing.checked = true
|
||||
updateUnsavedStyling()
|
||||
reorderDOMApps()
|
||||
showToast('该应用已在列表中,已为你自动勾选并置顶')
|
||||
return
|
||||
}
|
||||
|
||||
showToast('正在尝试获取应用信息...')
|
||||
let appData = {
|
||||
packageName: realPkg,
|
||||
appLabel: '未知 (手动添加)',
|
||||
isSystem: false,
|
||||
uid: '自定义',
|
||||
}
|
||||
try {
|
||||
const info = await getPackagesInfo([realPkg])
|
||||
if (info && info.length > 0) appData = info[0]
|
||||
} catch {
|
||||
/* ignore */
|
||||
}
|
||||
|
||||
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()
|
||||
reorderDOMApps()
|
||||
})
|
||||
|
||||
const customCheckbox = document.createElement('span')
|
||||
customCheckbox.className = 'app-checkbox-custom'
|
||||
checkboxLabel.appendChild(checkbox)
|
||||
checkboxLabel.appendChild(customCheckbox)
|
||||
|
||||
const infoDiv = document.createElement('div')
|
||||
infoDiv.className = 'app-info'
|
||||
|
||||
const nameSpan = document.createElement('span')
|
||||
nameSpan.className = 'app-name'
|
||||
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)
|
||||
|
||||
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('已成功添加并勾选')
|
||||
})
|
||||
}
|
||||
|
||||
// 全选
|
||||
const btnSelectAll = document.getElementById('btn-select-all')
|
||||
if (btnSelectAll) {
|
||||
btnSelectAll.addEventListener('click', () => {
|
||||
document.querySelectorAll('.app-checkbox').forEach((cb) => {
|
||||
cb.checked = true
|
||||
})
|
||||
updateUnsavedStyling()
|
||||
appsDropdownMenu && appsDropdownMenu.classList.remove('show')
|
||||
})
|
||||
}
|
||||
|
||||
// 全不选
|
||||
const btnSelectNone = document.getElementById('btn-select-none')
|
||||
if (btnSelectNone) {
|
||||
btnSelectNone.addEventListener('click', () => {
|
||||
document.querySelectorAll('.app-checkbox').forEach((cb) => {
|
||||
cb.checked = false
|
||||
})
|
||||
updateUnsavedStyling()
|
||||
appsDropdownMenu && appsDropdownMenu.classList.remove('show')
|
||||
})
|
||||
}
|
||||
|
||||
// 反选
|
||||
const btnInvertSelection = document.getElementById('btn-invert-selection')
|
||||
if (btnInvertSelection) {
|
||||
btnInvertSelection.addEventListener('click', () => {
|
||||
document.querySelectorAll('.app-checkbox').forEach((cb) => {
|
||||
cb.checked = !cb.checked
|
||||
})
|
||||
updateUnsavedStyling()
|
||||
appsDropdownMenu && appsDropdownMenu.classList.remove('show')
|
||||
})
|
||||
}
|
||||
|
||||
// 刷新(重排)
|
||||
const btnAppsRefresh = document.getElementById('btn-apps-refresh')
|
||||
if (btnAppsRefresh) {
|
||||
btnAppsRefresh.addEventListener('click', () => {
|
||||
reorderDOMApps()
|
||||
})
|
||||
}
|
||||
|
||||
// 保存黑名单
|
||||
const btnSaveBlacklist = document.getElementById('btn-save-blacklist')
|
||||
if (btnSaveBlacklist) {
|
||||
btnSaveBlacklist.addEventListener('click', async () => {
|
||||
showToast('保存中...')
|
||||
const selectedPkgs = []
|
||||
document.querySelectorAll('.app-checkbox').forEach((cb) => {
|
||||
if (cb.checked) selectedPkgs.push(cb.dataset.pkg)
|
||||
})
|
||||
const allEntries = [...selectedPkgs, ...activityEntries]
|
||||
const res = await updateConfig({ blacklist_apps: allEntries })
|
||||
if (res.errno === 0 || res.stdout?.includes('OK')) {
|
||||
showToast('黑名单保存成功')
|
||||
savedBlacklist = new Set(allEntries)
|
||||
updateUnsavedStyling()
|
||||
reorderDOMApps()
|
||||
} else {
|
||||
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) {
|
||||
inputAppSearch.addEventListener('input', (e) => {
|
||||
const keyword = e.target.value.trim().toLowerCase()
|
||||
const items = document.querySelectorAll('.app-list-item')
|
||||
let visibleCount = 0
|
||||
items.forEach((item) => {
|
||||
const name = item.querySelector('.app-name').textContent
|
||||
const pkg = item.querySelector('.app-pkg').textContent.toLowerCase()
|
||||
if (!keyword || pkg.includes(keyword) || PinyinMatch.match(name, keyword)) {
|
||||
item.style.display = 'flex'
|
||||
visibleCount++
|
||||
} else {
|
||||
item.style.display = 'none'
|
||||
}
|
||||
})
|
||||
const badge = document.getElementById('app-count-badge')
|
||||
if (badge) badge.textContent = visibleCount
|
||||
})
|
||||
}
|
||||
|
||||
setupActivityPicker()
|
||||
}
|
||||
|
||||
function setupActivityPicker() {
|
||||
const overlay = document.getElementById('activity-picker-overlay')
|
||||
if (!overlay) return
|
||||
|
||||
const btnPickActivity = document.getElementById('btn-pick-activity')
|
||||
const btnPickerBack = document.getElementById('btn-picker-back')
|
||||
const step1 = document.getElementById('picker-step-1')
|
||||
const step2 = document.getElementById('picker-step-2')
|
||||
const step3 = document.getElementById('picker-step-3')
|
||||
const dots = [
|
||||
document.getElementById('picker-dot-1'),
|
||||
document.getElementById('picker-dot-2'),
|
||||
document.getElementById('picker-dot-3'),
|
||||
]
|
||||
const btnStep1Next = document.getElementById('btn-picker-step1-next')
|
||||
const btnPickerStart = document.getElementById('btn-picker-start')
|
||||
const btnPickerRetry = document.getElementById('btn-picker-retry')
|
||||
const btnPickerConfirm = document.getElementById('btn-picker-confirm')
|
||||
const pickerStatusText = document.getElementById('picker-status-text')
|
||||
const pickerResultText = document.getElementById('picker-result-text')
|
||||
|
||||
let pollingTimer = null
|
||||
let detectedActivity = null
|
||||
|
||||
function showStep(n) {
|
||||
;[step1, step2, step3].forEach((s, i) => {
|
||||
if (s) s.style.display = i + 1 === n ? 'flex' : 'none'
|
||||
})
|
||||
dots.forEach((d, i) => {
|
||||
d?.classList.toggle('active', i + 1 === n)
|
||||
})
|
||||
}
|
||||
|
||||
function stopPolling() {
|
||||
if (pollingTimer) {
|
||||
clearInterval(pollingTimer)
|
||||
pollingTimer = null
|
||||
}
|
||||
}
|
||||
|
||||
function openPicker() {
|
||||
stopPolling()
|
||||
detectedActivity = null
|
||||
if (btnPickerStart) btnPickerStart.disabled = false
|
||||
if (pickerStatusText) {
|
||||
pickerStatusText.textContent = '等待中...'
|
||||
pickerStatusText.classList.remove('polling')
|
||||
}
|
||||
showStep(1)
|
||||
overlay.classList.add('show')
|
||||
}
|
||||
|
||||
function closePicker() {
|
||||
stopPolling()
|
||||
overlay.classList.remove('show')
|
||||
}
|
||||
|
||||
btnPickActivity?.addEventListener('click', openPicker)
|
||||
btnPickerBack?.addEventListener('click', closePicker)
|
||||
btnStep1Next?.addEventListener('click', () => showStep(2))
|
||||
|
||||
btnPickerStart?.addEventListener('click', () => {
|
||||
btnPickerStart.disabled = true
|
||||
if (pickerStatusText) {
|
||||
pickerStatusText.textContent = '检测中,请切换到目标界面...'
|
||||
pickerStatusText.classList.add('polling')
|
||||
}
|
||||
stopPolling()
|
||||
pollingTimer = setInterval(async () => {
|
||||
try {
|
||||
const res = await runCmd(
|
||||
`dumpsys window 2>/dev/null | grep mCurrentFocus | sed 's/.*u[0-9][0-9]* //' | sed 's/}.*//'`,
|
||||
)
|
||||
if (res.errno !== 0) return
|
||||
const activity = res.stdout.trim()
|
||||
// 空值或仍在 WebUI 内则继续等待
|
||||
if (!activity || activity.toLowerCase().includes('webui')) return
|
||||
stopPolling()
|
||||
detectedActivity = activity
|
||||
if (pickerStatusText) pickerStatusText.classList.remove('polling')
|
||||
if (pickerResultText) pickerResultText.textContent = activity
|
||||
if (btnPickerStart) btnPickerStart.disabled = false
|
||||
showStep(3)
|
||||
} catch {
|
||||
/* 忽略,继续轮询 */
|
||||
}
|
||||
}, 600)
|
||||
})
|
||||
|
||||
btnPickerRetry?.addEventListener('click', () => {
|
||||
stopPolling()
|
||||
detectedActivity = null
|
||||
if (btnPickerStart) btnPickerStart.disabled = false
|
||||
if (pickerStatusText) {
|
||||
pickerStatusText.textContent = '等待中...'
|
||||
pickerStatusText.classList.remove('polling')
|
||||
}
|
||||
showStep(2)
|
||||
})
|
||||
|
||||
btnPickerConfirm?.addEventListener('click', () => {
|
||||
if (!detectedActivity) return
|
||||
activityEntries.add(detectedActivity)
|
||||
const pkg = detectedActivity.split('/')[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(`已添加: ${detectedActivity}`)
|
||||
closePicker()
|
||||
})
|
||||
}
|
||||
@@ -1,663 +0,0 @@
|
||||
/* Cards */
|
||||
.card {
|
||||
background-color: var(--md-sys-color-surface);
|
||||
border-radius: var(--border-radius-m);
|
||||
padding: var(--spacing-l);
|
||||
box-shadow:
|
||||
0 1px 3px 0 rgba(0, 0, 0, 0.3),
|
||||
0 4px 8px 3px rgba(0, 0, 0, 0.15);
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
/* Collapsible card header */
|
||||
.card-header-toggle {
|
||||
cursor: pointer;
|
||||
user-select: none;
|
||||
-webkit-user-select: none;
|
||||
border-radius: var(--border-radius-s);
|
||||
transition: background-color 0.15s;
|
||||
margin: calc(-1 * var(--spacing-l));
|
||||
padding: var(--spacing-l);
|
||||
}
|
||||
.card-header-toggle:active {
|
||||
background-color: rgba(var(--md-sys-color-primary-rgb), 0.06);
|
||||
}
|
||||
.collapse-chevron {
|
||||
color: var(--md-sys-color-on-surface-variant);
|
||||
transition: transform 0.3s cubic-bezier(0.25, 1, 0.5, 1);
|
||||
flex-shrink: 0;
|
||||
}
|
||||
.collapse-chevron.open {
|
||||
transform: rotate(180deg);
|
||||
}
|
||||
|
||||
/* grid-template-rows collapse animation */
|
||||
.collapsible-body {
|
||||
display: grid;
|
||||
grid-template-rows: 0fr;
|
||||
transition: grid-template-rows 0.35s cubic-bezier(0.25, 1, 0.5, 1);
|
||||
}
|
||||
.collapsible-body.open {
|
||||
grid-template-rows: 1fr;
|
||||
}
|
||||
.collapsible-body > div {
|
||||
overflow: hidden;
|
||||
padding-top: 0;
|
||||
transition: padding-top 0.35s cubic-bezier(0.25, 1, 0.5, 1);
|
||||
}
|
||||
.collapsible-body.open > div {
|
||||
padding-top: var(--spacing-l);
|
||||
overflow: visible;
|
||||
}
|
||||
|
||||
/* Page Transitions */
|
||||
.card-animate-in {
|
||||
animation: cardFadeIn 0.4s cubic-bezier(0.2, 0, 0, 1) forwards;
|
||||
}
|
||||
|
||||
.navbar-slider {
|
||||
left: 0;
|
||||
}
|
||||
|
||||
@keyframes cardFadeIn {
|
||||
from {
|
||||
opacity: 0;
|
||||
transform: translateY(12px) scale(0.985);
|
||||
}
|
||||
to {
|
||||
opacity: 1;
|
||||
transform: translateY(0) scale(1);
|
||||
}
|
||||
}
|
||||
|
||||
#log-section {
|
||||
flex: 1;
|
||||
min-height: calc(100vh - 220px);
|
||||
}
|
||||
|
||||
.card-header {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: var(--spacing-s);
|
||||
}
|
||||
|
||||
.card-header h2 {
|
||||
margin: 0;
|
||||
font-size: 1.125rem;
|
||||
font-weight: 500;
|
||||
color: var(--md-sys-color-on-surface);
|
||||
flex-grow: 1;
|
||||
}
|
||||
|
||||
/* Config Items */
|
||||
.config-group {
|
||||
margin-top: 12px;
|
||||
margin-bottom: 0;
|
||||
padding: 12px;
|
||||
background-color: var(--md-sys-color-surface-container);
|
||||
border-radius: var(--border-radius-m);
|
||||
border: 1px solid rgba(var(--md-sys-color-on-surface-rgb, 0, 0, 0), 0.05);
|
||||
}
|
||||
|
||||
.group-title {
|
||||
margin: 0 0 10px 0;
|
||||
color: var(--md-sys-color-primary);
|
||||
font-size: 0.875rem;
|
||||
font-weight: 600;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
.group-title i,
|
||||
.group-title svg {
|
||||
width: 16px;
|
||||
height: 16px;
|
||||
}
|
||||
|
||||
.config-item {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
padding: 4px 0;
|
||||
}
|
||||
|
||||
#advanced-section .config-item {
|
||||
flex-direction: column;
|
||||
align-items: flex-start;
|
||||
gap: 12px;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
#advanced-section .config-value {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.config-item + .config-item {
|
||||
margin-top: 10px;
|
||||
border-top: 1px solid rgba(var(--md-sys-color-outline-variant-rgb, 142, 144, 153), 0.1);
|
||||
padding-top: 10px;
|
||||
}
|
||||
|
||||
.config-label {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
.config-name {
|
||||
font-size: 1rem;
|
||||
color: var(--md-sys-color-on-surface);
|
||||
}
|
||||
|
||||
.config-desc {
|
||||
font-size: 0.875rem;
|
||||
color: var(--md-sys-color-on-surface-variant);
|
||||
}
|
||||
|
||||
.config-input {
|
||||
width: 100px;
|
||||
padding: 8px 12px;
|
||||
background-color: var(--md-sys-color-surface-container-high);
|
||||
border: 1px solid var(--md-sys-color-outline-variant);
|
||||
border-radius: var(--border-radius-s);
|
||||
color: var(--md-sys-color-on-surface);
|
||||
font-size: 1rem;
|
||||
font-family: inherit;
|
||||
text-align: right;
|
||||
outline: none;
|
||||
transition: all 0.2s ease;
|
||||
}
|
||||
|
||||
.config-input:focus {
|
||||
border-color: var(--md-sys-color-primary);
|
||||
box-shadow: 0 0 0 2px rgba(var(--md-sys-color-primary-rgb), 0.2);
|
||||
background-color: var(--md-sys-color-surface);
|
||||
}
|
||||
|
||||
.config-select {
|
||||
padding: 8px 12px;
|
||||
background-color: var(--md-sys-color-surface-container-high);
|
||||
border: 1px solid var(--md-sys-color-outline-variant);
|
||||
border-radius: var(--border-radius-s);
|
||||
color: var(--md-sys-color-on-surface);
|
||||
font-size: 1rem;
|
||||
font-family: inherit;
|
||||
outline: none;
|
||||
cursor: pointer;
|
||||
transition: all 0.2s ease;
|
||||
}
|
||||
|
||||
.config-select:focus {
|
||||
border-color: var(--md-sys-color-primary);
|
||||
box-shadow: 0 0 0 2px rgba(var(--md-sys-color-primary-rgb), 0.2);
|
||||
background-color: var(--md-sys-color-surface);
|
||||
}
|
||||
|
||||
#advanced-section .config-input {
|
||||
width: 100%;
|
||||
text-align: left;
|
||||
}
|
||||
|
||||
.config-textarea {
|
||||
background-color: var(--md-sys-color-surface-container-high);
|
||||
width: 100%;
|
||||
min-height: 60px;
|
||||
max-height: 300px;
|
||||
color: var(--md-sys-color-on-surface);
|
||||
border: 1px solid var(--md-sys-color-outline-variant);
|
||||
border-radius: var(--border-radius-m);
|
||||
resize: vertical;
|
||||
padding: 10px 14px;
|
||||
font-family: 'Geist Mono', system-ui, monospace;
|
||||
font-size: 0.875rem;
|
||||
line-height: 1.4;
|
||||
transition: all 0.2s ease;
|
||||
outline: none;
|
||||
}
|
||||
|
||||
.config-textarea:focus {
|
||||
border-color: var(--md-sys-color-primary);
|
||||
box-shadow: 0 0 0 2px rgba(var(--md-sys-color-primary-rgb), 0.2);
|
||||
background-color: var(--md-sys-color-surface);
|
||||
}
|
||||
|
||||
.config-input-wide {
|
||||
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: 8px;
|
||||
}
|
||||
|
||||
.time-unit {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 2px;
|
||||
background-color: var(--md-sys-color-surface-container-high);
|
||||
padding: 2px 6px;
|
||||
border-radius: var(--border-radius-s);
|
||||
border: 1px solid var(--md-sys-color-outline);
|
||||
}
|
||||
|
||||
.time-input {
|
||||
width: 32px;
|
||||
background-color: transparent;
|
||||
color: var(--md-sys-color-on-surface);
|
||||
border: none;
|
||||
font-size: 0.875rem;
|
||||
text-align: center;
|
||||
font-family: 'Geist Mono', monospace;
|
||||
outline: none;
|
||||
-moz-appearance: textfield;
|
||||
}
|
||||
|
||||
.time-input-wide {
|
||||
width: 48px;
|
||||
}
|
||||
|
||||
.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: 0.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: 0.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;
|
||||
grid-template-columns: 1fr 1fr;
|
||||
gap: var(--spacing-m);
|
||||
margin-top: var(--spacing-m);
|
||||
}
|
||||
|
||||
.status-item {
|
||||
background-color: var(--md-sys-color-surface-container);
|
||||
padding: var(--spacing-m);
|
||||
border-radius: var(--border-radius-m);
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 8px;
|
||||
border: 1px solid rgba(var(--md-sys-color-on-surface-rgb, 0, 0, 0), 0.04);
|
||||
transition: transform 0.2s ease;
|
||||
}
|
||||
|
||||
.status-item:active {
|
||||
transform: scale(0.98);
|
||||
}
|
||||
|
||||
.status-item-header {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 6px;
|
||||
color: var(--md-sys-color-on-surface-variant);
|
||||
}
|
||||
|
||||
.status-item-header svg {
|
||||
width: 14px;
|
||||
height: 14px;
|
||||
opacity: 0.7;
|
||||
}
|
||||
|
||||
.status-label {
|
||||
font-size: 0.75rem;
|
||||
font-weight: 500;
|
||||
}
|
||||
|
||||
.status-value {
|
||||
font-size: 1.125rem;
|
||||
font-weight: 600;
|
||||
color: var(--md-sys-color-primary);
|
||||
word-break: break-all;
|
||||
}
|
||||
|
||||
/* Brightness Section */
|
||||
.brightness-section {
|
||||
margin-top: var(--spacing-l);
|
||||
padding: var(--spacing-m);
|
||||
background: linear-gradient(
|
||||
135deg,
|
||||
var(--md-sys-color-surface-container-high) 0%,
|
||||
var(--md-sys-color-surface-container) 100%
|
||||
);
|
||||
border-radius: var(--border-radius-m);
|
||||
border: 1px solid var(--md-sys-color-outline-variant);
|
||||
}
|
||||
|
||||
.brightness-header {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
margin-bottom: var(--spacing-m);
|
||||
}
|
||||
|
||||
.brightness-title {
|
||||
font-size: 1rem;
|
||||
font-weight: 600;
|
||||
color: var(--md-sys-color-on-surface);
|
||||
letter-spacing: 0.5px;
|
||||
}
|
||||
|
||||
.brightness-percent {
|
||||
font-size: 1.25rem;
|
||||
font-weight: 700;
|
||||
color: var(--md-sys-color-primary);
|
||||
min-width: 50px;
|
||||
text-align: right;
|
||||
}
|
||||
|
||||
/* Brightness Slider Container */
|
||||
.brightness-container {
|
||||
position: relative;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
margin-bottom: var(--spacing-m);
|
||||
padding: var(--spacing-s) 0;
|
||||
}
|
||||
|
||||
.brightness-label {
|
||||
font-size: 0.75rem;
|
||||
color: var(--md-sys-color-on-surface-variant);
|
||||
min-width: 24px;
|
||||
text-align: center;
|
||||
font-weight: 500;
|
||||
}
|
||||
|
||||
/* Brightness Slider (Progress Bar Style) */
|
||||
.brightness-slider {
|
||||
flex: 1;
|
||||
height: 24px;
|
||||
border-radius: 12px;
|
||||
/* 背景将由 JS 通过 linear-gradient 动态更新实现进度条效果 */
|
||||
background: var(--md-sys-color-surface-container-high);
|
||||
outline: none;
|
||||
-webkit-appearance: none;
|
||||
appearance: none;
|
||||
cursor: grab;
|
||||
transition:
|
||||
background 0.35s ease,
|
||||
height 0.2s,
|
||||
box-shadow 0.2s;
|
||||
border: 1px solid rgba(255, 255, 255, 0.03);
|
||||
box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.2);
|
||||
overflow: hidden; /* 确保进度条颜色不溢出圆角 */
|
||||
}
|
||||
|
||||
.brightness-slider:hover {
|
||||
height: 28px;
|
||||
}
|
||||
|
||||
.brightness-slider:disabled {
|
||||
opacity: 0.5;
|
||||
cursor: not-allowed;
|
||||
}
|
||||
|
||||
.brightness-slider:disabled:hover {
|
||||
height: 24px;
|
||||
}
|
||||
|
||||
.brightness-slider::-webkit-slider-thumb {
|
||||
-webkit-appearance: none;
|
||||
appearance: none;
|
||||
width: 0;
|
||||
height: 0;
|
||||
background: transparent;
|
||||
cursor: grab;
|
||||
border: none;
|
||||
}
|
||||
|
||||
.brightness-slider::-webkit-slider-thumb:active {
|
||||
cursor: grabbing;
|
||||
}
|
||||
|
||||
.brightness-slider::-moz-range-thumb {
|
||||
width: 28px;
|
||||
height: 28px;
|
||||
border-radius: 50%;
|
||||
background: var(--md-sys-color-primary);
|
||||
cursor: grab;
|
||||
border: 2px solid var(--md-sys-color-surface);
|
||||
box-shadow:
|
||||
0 2px 8px rgba(0, 0, 0, 0.4),
|
||||
inset 0 1px 2px rgba(255, 255, 255, 0.3);
|
||||
transition: all 0.2s;
|
||||
}
|
||||
|
||||
.brightness-slider::-moz-range-thumb:hover {
|
||||
box-shadow:
|
||||
0 4px 12px rgba(0, 0, 0, 0.5),
|
||||
inset 0 1px 2px rgba(255, 255, 255, 0.3);
|
||||
transform: scale(1.1);
|
||||
}
|
||||
|
||||
.brightness-slider::-moz-range-thumb:active {
|
||||
cursor: grabbing;
|
||||
box-shadow: 0 0 0 10px rgba(168, 199, 250, 0.2);
|
||||
}
|
||||
|
||||
.brightness-slider::-moz-range-track {
|
||||
background: transparent;
|
||||
border: none;
|
||||
}
|
||||
|
||||
/* Actions */
|
||||
.save-badge {
|
||||
margin-left: auto;
|
||||
flex-shrink: 0;
|
||||
padding: 2px 10px;
|
||||
border-radius: 999px;
|
||||
font-size: 0.75rem;
|
||||
font-weight: 600;
|
||||
line-height: 1.5;
|
||||
}
|
||||
|
||||
.save-badge.unsaved {
|
||||
color: var(--color-warning);
|
||||
background: color-mix(in srgb, var(--color-warning) 15%, transparent);
|
||||
}
|
||||
|
||||
.save-badge.saved {
|
||||
color: #2f9e63;
|
||||
background: rgba(47, 158, 99, 0.14);
|
||||
}
|
||||
|
||||
.card-actions {
|
||||
display: flex;
|
||||
justify-content: flex-end;
|
||||
gap: 12px;
|
||||
margin-top: 16px;
|
||||
padding-top: 12px;
|
||||
border-top: 1px solid var(--md-sys-color-outline-variant);
|
||||
}
|
||||
|
||||
/* Buttons */
|
||||
.btn {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
gap: 8px;
|
||||
padding: 10px 24px;
|
||||
border-radius: 100px;
|
||||
border: none;
|
||||
font-size: 0.875rem;
|
||||
font-weight: 500;
|
||||
font-family: inherit;
|
||||
cursor: pointer;
|
||||
transition:
|
||||
background-color 0.2s,
|
||||
opacity 0.2s;
|
||||
}
|
||||
|
||||
.btn:active {
|
||||
opacity: 0.8;
|
||||
}
|
||||
|
||||
.btn-primary {
|
||||
background-color: var(--md-sys-color-primary);
|
||||
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;
|
||||
color: var(--md-sys-color-on-surface-variant);
|
||||
font-size: 1.25rem;
|
||||
cursor: pointer;
|
||||
padding: 4px;
|
||||
border-radius: 50%;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
.btn-icon-only-s {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
width: 32px;
|
||||
height: 32px;
|
||||
border-radius: 8px;
|
||||
border: none;
|
||||
background-color: var(--md-sys-color-surface-container-high);
|
||||
color: var(--md-sys-color-primary);
|
||||
cursor: pointer;
|
||||
transition: all 0.2s ease;
|
||||
}
|
||||
|
||||
.btn-icon-only-s:active {
|
||||
background-color: var(--md-sys-color-primary-container);
|
||||
transform: scale(0.9);
|
||||
}
|
||||
|
||||
.btn-icon-only-s i,
|
||||
.btn-icon-only-s svg {
|
||||
width: 16px;
|
||||
height: 16px;
|
||||
}
|
||||
|
||||
.animate-spin {
|
||||
animation: spin 1s linear infinite;
|
||||
}
|
||||
|
||||
@keyframes spin {
|
||||
from {
|
||||
transform: rotate(0deg);
|
||||
}
|
||||
to {
|
||||
transform: rotate(360deg);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
<script setup>
|
||||
import { ref } from 'vue'
|
||||
import { MoreVertical } from 'lucide-vue-next'
|
||||
|
||||
defineProps({
|
||||
items: { type: Array, default: () => [] }, // [{ key, label }]
|
||||
title: { type: String, default: '更多' },
|
||||
disabled: { type: Boolean, default: false },
|
||||
})
|
||||
const emit = defineEmits(['select'])
|
||||
|
||||
const open = ref(false)
|
||||
const anchorEl = ref(null)
|
||||
const menuEl = ref(null)
|
||||
|
||||
function toggle() {
|
||||
const menu = menuEl.value
|
||||
if (!menu) return
|
||||
// 注意:md-menu 的 anchor 是 idref 字符串,元素引用必须用 anchorElement;
|
||||
// 且必须在打开前设置——菜单打开时会立刻按锚点定位
|
||||
if (anchorEl.value) menu.anchorElement = anchorEl.value
|
||||
open.value = !open.value
|
||||
}
|
||||
|
||||
function pick(item) {
|
||||
open.value = false
|
||||
setTimeout(() => emit('select', item.key), 0)
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<md-icon-button ref="anchorEl" :title="title" :disabled="disabled" @click="toggle">
|
||||
<MoreVertical :size="20" />
|
||||
</md-icon-button>
|
||||
<!-- 菜单挂到 body 并用窗口定位:
|
||||
页面滑轨带 transform,若菜单留在原地,包含块会变成 .page-track,
|
||||
再被 .page-viewport 的 overflow:hidden 裁掉(表现为点了没反应) -->
|
||||
<Teleport to="body">
|
||||
<md-menu ref="menuEl" positioning="fixed" :open="open" @closed="open = false">
|
||||
<md-menu-item v-for="item in items" :key="item.key" @click="pick(item)">
|
||||
<span slot="headline">{{ item.label }}</span>
|
||||
</md-menu-item>
|
||||
</md-menu>
|
||||
</Teleport>
|
||||
</template>
|
||||
@@ -0,0 +1,33 @@
|
||||
<script setup>
|
||||
import { Activity, SlidersHorizontal, LayoutList, ScrollText, Info } from 'lucide-vue-next'
|
||||
|
||||
defineProps({
|
||||
modelValue: { type: String, required: true },
|
||||
})
|
||||
const emit = defineEmits(['update:modelValue'])
|
||||
|
||||
const tabs = [
|
||||
{ key: 'status', label: '状态', icon: Activity },
|
||||
{ key: 'config', label: '配置', icon: SlidersHorizontal },
|
||||
{ key: 'apps', label: '黑名单', icon: LayoutList },
|
||||
{ key: 'log', label: '日志', icon: ScrollText },
|
||||
{ key: 'about', label: '关于', icon: Info },
|
||||
]
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<nav class="bottom-nav">
|
||||
<md-navigation-bar>
|
||||
<md-navigation-tab
|
||||
v-for="tab in tabs"
|
||||
:key="tab.key"
|
||||
:label="tab.label"
|
||||
:active="modelValue === tab.key"
|
||||
@click="emit('update:modelValue', tab.key)"
|
||||
>
|
||||
<component :is="tab.icon" slot="active-icon" :size="24" />
|
||||
<component :is="tab.icon" slot="inactive-icon" :size="24" />
|
||||
</md-navigation-tab>
|
||||
</md-navigation-bar>
|
||||
</nav>
|
||||
</template>
|
||||
@@ -0,0 +1,28 @@
|
||||
<script setup>
|
||||
/** 设置行:左侧标题/说明 + 右侧 M3 开关 */
|
||||
defineProps({
|
||||
modelValue: { type: Boolean, default: false },
|
||||
name: { type: String, default: '' },
|
||||
support: { type: String, default: '' },
|
||||
warning: { type: String, default: '' },
|
||||
disabled: { type: Boolean, default: false },
|
||||
})
|
||||
const emit = defineEmits(['update:modelValue'])
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="row">
|
||||
<div class="row__labels">
|
||||
<span class="row__name">{{ name }}</span>
|
||||
<span v-if="support" class="row__support">{{ support }}</span>
|
||||
<span v-if="warning" class="row__support warning">{{ warning }}</span>
|
||||
</div>
|
||||
<div class="row__control">
|
||||
<md-switch
|
||||
:selected="modelValue"
|
||||
:disabled="disabled"
|
||||
@change="emit('update:modelValue', $event.target.selected)"
|
||||
></md-switch>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
@@ -0,0 +1,36 @@
|
||||
<script setup>
|
||||
/** md-outlined-text-field 的 v-model 封装(MWC 用属性而非 Vue props,需手动接线) */
|
||||
defineProps({
|
||||
modelValue: { type: [String, Number], default: '' },
|
||||
label: { type: String, default: '' },
|
||||
type: { type: String, default: 'text' },
|
||||
min: { type: [String, Number], default: undefined },
|
||||
max: { type: [String, Number], default: undefined },
|
||||
step: { type: [String, Number], default: undefined },
|
||||
supportingText: { type: String, default: '' },
|
||||
disabled: { type: Boolean, default: false },
|
||||
placeholder: { type: String, default: '' },
|
||||
})
|
||||
const emit = defineEmits(['update:modelValue'])
|
||||
|
||||
function onInput(event) {
|
||||
emit('update:modelValue', event.target.value)
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<md-outlined-text-field
|
||||
:label="label"
|
||||
:type="type"
|
||||
:value="modelValue"
|
||||
:min="min"
|
||||
:max="max"
|
||||
:step="step"
|
||||
:supporting-text="supportingText"
|
||||
:disabled="disabled"
|
||||
:placeholder="placeholder"
|
||||
autocomplete="off"
|
||||
spellcheck="false"
|
||||
@input="onInput"
|
||||
></md-outlined-text-field>
|
||||
</template>
|
||||
@@ -0,0 +1,63 @@
|
||||
<script setup>
|
||||
import { computed } from 'vue'
|
||||
import { Pause, Play } from 'lucide-vue-next'
|
||||
import ActionMenu from './ActionMenu.vue'
|
||||
|
||||
const props = defineProps({
|
||||
version: { type: String, default: '' },
|
||||
statusText: { type: String, default: '—' },
|
||||
statusClass: { type: String, default: 'stopped' },
|
||||
paused: { type: Boolean, default: false },
|
||||
locked: { type: Boolean, default: false },
|
||||
scrolled: { type: Boolean, default: false },
|
||||
})
|
||||
|
||||
const emit = defineEmits(['toggle-service', 'refresh', 'restart'])
|
||||
|
||||
/** 通道徽标:版本号里带 -beta / -dev 即为对应通道 */
|
||||
const channel = computed(() => {
|
||||
const v = props.version.toLowerCase()
|
||||
if (v.includes('-beta')) return 'Beta'
|
||||
if (v.includes('-dev')) return 'Dev'
|
||||
return ''
|
||||
})
|
||||
|
||||
// 刷新与重启都收进「更多」:文字标签比图标更不容易混淆
|
||||
const menuItems = [
|
||||
{ key: 'refresh', label: '刷新状态' },
|
||||
{ key: 'restart', label: '重启模块' },
|
||||
]
|
||||
|
||||
function onMenuSelect(key) {
|
||||
if (key === 'refresh') emit('refresh')
|
||||
else if (key === 'restart') emit('restart')
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<header class="app-bar" :class="{ scrolled }">
|
||||
<div class="app-bar__text">
|
||||
<h1 class="app-bar__title ts-title-lg">
|
||||
LuminPro
|
||||
<span v-if="channel" class="channel-badge">{{ channel }}</span>
|
||||
</h1>
|
||||
<span class="app-bar__meta ts-body-sm">
|
||||
<span class="status-dot" :class="statusClass"></span>
|
||||
{{ statusText }}
|
||||
<template v-if="version"> · {{ version }}</template>
|
||||
</span>
|
||||
</div>
|
||||
|
||||
<div class="app-bar__actions">
|
||||
<md-icon-button
|
||||
:title="paused ? '启用' : '暂停'"
|
||||
:disabled="locked"
|
||||
@click="emit('toggle-service')"
|
||||
>
|
||||
<Play v-if="paused" :size="20" />
|
||||
<Pause v-else :size="20" />
|
||||
</md-icon-button>
|
||||
<ActionMenu :items="menuItems" :disabled="locked" title="更多操作" @select="onMenuSelect" />
|
||||
</div>
|
||||
</header>
|
||||
</template>
|
||||
@@ -1,143 +0,0 @@
|
||||
<script setup>
|
||||
import { ref, onMounted, onUnmounted, watch } from 'vue'
|
||||
import {
|
||||
Activity as IconActivity,
|
||||
Settings as IconSettings,
|
||||
AppWindow as IconApps,
|
||||
ScrollText as IconLog,
|
||||
Info as IconInfo,
|
||||
} from 'lucide-vue-next'
|
||||
|
||||
const props = defineProps({ modelValue: { type: String, default: 'status' } })
|
||||
const emit = defineEmits(['update:modelValue'])
|
||||
|
||||
const navItems = [
|
||||
{ key: 'status', label: '状态', icon: IconActivity },
|
||||
{ key: 'config', label: '配置', icon: IconSettings },
|
||||
{ key: 'apps', label: '黑名单', icon: IconApps },
|
||||
{ key: 'log', label: '日志', icon: IconLog },
|
||||
{ key: 'about', label: '关于', icon: IconInfo },
|
||||
]
|
||||
|
||||
const navbarEl = ref(null)
|
||||
const sliderEl = ref(null)
|
||||
const btnRefs = ref([])
|
||||
|
||||
const TRANSITION_ON = 'transform 0.3s cubic-bezier(0.25, 1, 0.5, 1), width 0.3s ease'
|
||||
|
||||
function updateSlider(key, animate = true) {
|
||||
const idx = navItems.findIndex((n) => n.key === key)
|
||||
if (idx < 0) return
|
||||
const btn = btnRefs.value[idx]
|
||||
if (!btn || !sliderEl.value) return
|
||||
sliderEl.value.style.transition = animate ? TRANSITION_ON : 'none'
|
||||
sliderEl.value.style.width = btn.offsetWidth + 'px'
|
||||
sliderEl.value.style.transform = `translateX(${btn.offsetLeft}px)`
|
||||
}
|
||||
|
||||
function select(key) {
|
||||
emit('update:modelValue', key)
|
||||
}
|
||||
|
||||
watch(
|
||||
() => props.modelValue,
|
||||
(v) => updateSlider(v),
|
||||
)
|
||||
|
||||
// ---- 拖拽逻辑 ----
|
||||
let isDragging = false
|
||||
let isActuallyDragging = false
|
||||
let startX = 0
|
||||
let startSliderX = 0
|
||||
|
||||
function onPointerDown(e) {
|
||||
isDragging = true
|
||||
isActuallyDragging = false
|
||||
startX = e.clientX
|
||||
const idx = navItems.findIndex((n) => n.key === props.modelValue)
|
||||
startSliderX = idx >= 0 && btnRefs.value[idx] ? btnRefs.value[idx].offsetLeft : 0
|
||||
}
|
||||
|
||||
function onPointerMove(e) {
|
||||
if (!isDragging) return
|
||||
const dx = e.clientX - startX
|
||||
if (!isActuallyDragging && Math.abs(dx) > 10) {
|
||||
isActuallyDragging = true
|
||||
navbarEl.value?.setPointerCapture(e.pointerId)
|
||||
}
|
||||
if (!isActuallyDragging || !sliderEl.value) return
|
||||
const first = btnRefs.value[0]
|
||||
const last = btnRefs.value[btnRefs.value.length - 1]
|
||||
const minX = first ? first.offsetLeft : 0
|
||||
const maxX = last ? last.offsetLeft : 0
|
||||
let tx = startSliderX + dx
|
||||
if (tx < minX) tx = minX + (tx - minX) * 0.3
|
||||
if (tx > maxX) tx = maxX + (tx - maxX) * 0.3
|
||||
sliderEl.value.style.transition = 'none'
|
||||
sliderEl.value.style.transform = `translateX(${tx}px)`
|
||||
}
|
||||
|
||||
function onPointerUp(e) {
|
||||
if (!isDragging) return
|
||||
const wasDragging = isActuallyDragging
|
||||
isDragging = false
|
||||
isActuallyDragging = false
|
||||
navbarEl.value?.releasePointerCapture(e.pointerId)
|
||||
|
||||
if (wasDragging && sliderEl.value) {
|
||||
const sliderRect = sliderEl.value.getBoundingClientRect()
|
||||
const navRect = navbarEl.value?.getBoundingClientRect()
|
||||
const currentX = navRect ? sliderRect.left - navRect.left : 0
|
||||
let closest = navItems[0].key
|
||||
let minDist = Infinity
|
||||
btnRefs.value.forEach((btn, i) => {
|
||||
if (!btn) return
|
||||
const dist = Math.abs(btn.offsetLeft - currentX)
|
||||
if (dist < minDist) {
|
||||
minDist = dist
|
||||
closest = navItems[i].key
|
||||
}
|
||||
})
|
||||
select(closest)
|
||||
} else {
|
||||
updateSlider(props.modelValue)
|
||||
}
|
||||
}
|
||||
|
||||
function onResize() {
|
||||
updateSlider(props.modelValue, false)
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
updateSlider(props.modelValue, false)
|
||||
window.addEventListener('resize', onResize)
|
||||
})
|
||||
onUnmounted(() => {
|
||||
window.removeEventListener('resize', onResize)
|
||||
})
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<nav
|
||||
class="floating-navbar"
|
||||
ref="navbarEl"
|
||||
@pointerdown="onPointerDown"
|
||||
@pointermove="onPointerMove"
|
||||
@pointerup="onPointerUp"
|
||||
>
|
||||
<div class="navbar-slider" ref="sliderEl"></div>
|
||||
|
||||
<button
|
||||
v-for="(item, i) in navItems"
|
||||
:key="item.key"
|
||||
:ref="(el) => (btnRefs[i] = el)"
|
||||
class="navbar-btn"
|
||||
:class="{ active: modelValue === item.key }"
|
||||
:data-section="item.key"
|
||||
@click="select(item.key)"
|
||||
>
|
||||
<component :is="item.icon" :size="20" :stroke-width="1.75" />
|
||||
<span>{{ item.label }}</span>
|
||||
</button>
|
||||
</nav>
|
||||
</template>
|
||||
@@ -0,0 +1,54 @@
|
||||
<script setup>
|
||||
import { ref, watch, nextTick } from 'vue'
|
||||
|
||||
const props = defineProps({
|
||||
open: { type: Boolean, default: false },
|
||||
headline: { type: String, default: '确认操作' },
|
||||
description: { type: String, default: '' },
|
||||
confirmText: { type: String, default: '确认' },
|
||||
cancelText: { type: String, default: '取消' },
|
||||
danger: { type: Boolean, default: false },
|
||||
})
|
||||
const emit = defineEmits(['confirm', 'cancel'])
|
||||
|
||||
const dialogEl = ref(null)
|
||||
|
||||
watch(
|
||||
() => props.open,
|
||||
async (open) => {
|
||||
await nextTick()
|
||||
if (!dialogEl.value) return
|
||||
if (open) dialogEl.value.show()
|
||||
else dialogEl.value.close()
|
||||
},
|
||||
)
|
||||
|
||||
function onClosed() {
|
||||
if (props.open) emit('cancel') // 点击遮罩/ESC 关闭
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<md-dialog ref="dialogEl" @closed="onClosed">
|
||||
<div slot="headline">{{ headline }}</div>
|
||||
<div slot="content" class="dialog-content">{{ description }}</div>
|
||||
<div slot="actions">
|
||||
<md-text-button @click="emit('cancel')">{{ cancelText }}</md-text-button>
|
||||
<md-filled-button :class="{ danger }" @click="emit('confirm')">
|
||||
{{ confirmText }}
|
||||
</md-filled-button>
|
||||
</div>
|
||||
</md-dialog>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.dialog-content {
|
||||
color: var(--md-sys-color-on-surface-variant);
|
||||
white-space: pre-line;
|
||||
}
|
||||
|
||||
md-filled-button.danger {
|
||||
--md-filled-button-container-color: var(--md-sys-color-error);
|
||||
--md-filled-button-label-text-color: var(--md-sys-color-on-error);
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,17 @@
|
||||
<script setup>
|
||||
defineProps({
|
||||
locked: { type: Boolean, default: false },
|
||||
label: { type: String, default: '正在执行后台操作' },
|
||||
seconds: { type: Number, default: 0 },
|
||||
})
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Transition name="oplock">
|
||||
<div v-if="locked" class="oplock-banner" role="status">
|
||||
<span class="oplock-banner__spinner"></span>
|
||||
<span class="oplock-banner__text">{{ label }},已暂停刷新</span>
|
||||
<span v-if="seconds > 0" class="oplock-banner__elapsed">{{ seconds }}s</span>
|
||||
</div>
|
||||
</Transition>
|
||||
</template>
|
||||
@@ -0,0 +1,68 @@
|
||||
<script setup>
|
||||
import { ref, watch, nextTick } from 'vue'
|
||||
|
||||
const props = defineProps({
|
||||
open: { type: Boolean, default: false },
|
||||
headline: { type: String, default: '输入' },
|
||||
label: { type: String, default: '' },
|
||||
description: { type: String, default: '' },
|
||||
confirmText: { type: String, default: '确认' },
|
||||
cancelText: { type: String, default: '取消' },
|
||||
})
|
||||
const emit = defineEmits(['confirm', 'cancel'])
|
||||
|
||||
const dialogEl = ref(null)
|
||||
const value = ref('')
|
||||
|
||||
watch(
|
||||
() => props.open,
|
||||
async (open) => {
|
||||
await nextTick()
|
||||
if (!dialogEl.value) return
|
||||
if (open) {
|
||||
value.value = ''
|
||||
dialogEl.value.show()
|
||||
} else {
|
||||
dialogEl.value.close()
|
||||
}
|
||||
},
|
||||
)
|
||||
|
||||
function confirm() {
|
||||
emit('confirm', value.value.trim())
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<md-dialog ref="dialogEl" @closed="emit('cancel')">
|
||||
<div slot="headline">{{ headline }}</div>
|
||||
<div slot="content" class="prompt-content">
|
||||
<p v-if="description" class="ts-body supporting">{{ description }}</p>
|
||||
<md-outlined-text-field
|
||||
:label="label"
|
||||
:value="value"
|
||||
autocomplete="off"
|
||||
spellcheck="false"
|
||||
@input="value = $event.target.value"
|
||||
@keydown.enter="confirm"
|
||||
></md-outlined-text-field>
|
||||
</div>
|
||||
<div slot="actions">
|
||||
<md-text-button @click="emit('cancel')">{{ cancelText }}</md-text-button>
|
||||
<md-filled-button @click="confirm">{{ confirmText }}</md-filled-button>
|
||||
</div>
|
||||
</md-dialog>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.prompt-content {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: var(--md-sys-spacing-3);
|
||||
min-width: min(320px, 70vw);
|
||||
}
|
||||
|
||||
.prompt-content p {
|
||||
margin: 0;
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,15 @@
|
||||
<script setup>
|
||||
defineProps({
|
||||
messages: { type: Array, default: () => [] },
|
||||
})
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="snackbar-host">
|
||||
<TransitionGroup name="snackbar">
|
||||
<div v-for="message in messages" :key="message.id" class="snackbar" role="status">
|
||||
{{ message.text }}
|
||||
</div>
|
||||
</TransitionGroup>
|
||||
</div>
|
||||
</template>
|
||||
@@ -1,32 +0,0 @@
|
||||
<script setup>
|
||||
import { cn } from '@/lib/utils'
|
||||
import { cva } from 'class-variance-authority'
|
||||
|
||||
const badgeVariants = cva(
|
||||
'inline-flex items-center rounded-full px-2 py-0.5 text-xs font-medium transition-colors',
|
||||
{
|
||||
variants: {
|
||||
variant: {
|
||||
default: 'bg-primary/20 text-primary border border-primary/30',
|
||||
secondary: 'bg-secondary text-secondary-foreground',
|
||||
destructive: 'bg-destructive/20 text-destructive border border-destructive/30',
|
||||
outline: 'border border-border text-foreground',
|
||||
success: 'bg-green-500/20 text-green-400 border border-green-500/30',
|
||||
warning: 'bg-amber-500/20 text-amber-400 border border-amber-500/30',
|
||||
},
|
||||
},
|
||||
defaultVariants: { variant: 'default' },
|
||||
},
|
||||
)
|
||||
|
||||
const props = defineProps({
|
||||
variant: { type: String, default: 'default' },
|
||||
class: { type: String, default: '' },
|
||||
})
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<span :class="cn(badgeVariants({ variant }), props.class)">
|
||||
<slot />
|
||||
</span>
|
||||
</template>
|
||||
@@ -1,53 +0,0 @@
|
||||
<script setup>
|
||||
import { cn } from '@/lib/utils'
|
||||
import { cva } from 'class-variance-authority'
|
||||
|
||||
const buttonVariants = cva(
|
||||
'inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0',
|
||||
{
|
||||
variants: {
|
||||
variant: {
|
||||
default: 'bg-primary text-primary-foreground hover:bg-primary/90 active:bg-primary/80',
|
||||
destructive:
|
||||
'bg-destructive/20 text-destructive border border-destructive/40 hover:bg-destructive/30',
|
||||
outline:
|
||||
'border border-border bg-transparent hover:bg-secondary hover:text-secondary-foreground',
|
||||
secondary: 'bg-secondary text-secondary-foreground hover:bg-secondary/80',
|
||||
ghost: 'hover:bg-secondary hover:text-secondary-foreground',
|
||||
link: 'text-primary underline-offset-4 hover:underline',
|
||||
},
|
||||
size: {
|
||||
default: 'h-9 px-4 py-2',
|
||||
sm: 'h-8 rounded-md px-3 text-xs',
|
||||
lg: 'h-10 rounded-md px-8',
|
||||
icon: 'h-9 w-9',
|
||||
'icon-sm': 'h-8 w-8',
|
||||
},
|
||||
},
|
||||
defaultVariants: {
|
||||
variant: 'default',
|
||||
size: 'default',
|
||||
},
|
||||
},
|
||||
)
|
||||
|
||||
const props = defineProps({
|
||||
variant: { type: String, default: 'default' },
|
||||
size: { type: String, default: 'default' },
|
||||
class: { type: String, default: '' },
|
||||
disabled: { type: Boolean, default: false },
|
||||
type: { type: String, default: 'button' },
|
||||
as: { type: String, default: 'button' },
|
||||
})
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<component
|
||||
:is="as"
|
||||
:type="as === 'button' ? type : undefined"
|
||||
:disabled="disabled || undefined"
|
||||
:class="cn(buttonVariants({ variant, size }), props.class)"
|
||||
>
|
||||
<slot />
|
||||
</component>
|
||||
</template>
|
||||
@@ -1,17 +0,0 @@
|
||||
<script setup>
|
||||
import { cn } from '@/lib/utils'
|
||||
|
||||
const props = defineProps({
|
||||
class: { type: String, default: '' },
|
||||
})
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div
|
||||
:class="
|
||||
cn('rounded-xl border border-border/40 bg-card text-card-foreground shadow-md', props.class)
|
||||
"
|
||||
>
|
||||
<slot />
|
||||
</div>
|
||||
</template>
|
||||
@@ -1,38 +0,0 @@
|
||||
<script setup>
|
||||
import { cn } from '@/lib/utils'
|
||||
|
||||
const props = defineProps({
|
||||
class: { type: String, default: '' },
|
||||
modelValue: { type: [String, Number], default: '' },
|
||||
type: { type: String, default: 'text' },
|
||||
placeholder: { type: String, default: '' },
|
||||
disabled: { type: Boolean, default: false },
|
||||
min: { type: [String, Number], default: undefined },
|
||||
max: { type: [String, Number], default: undefined },
|
||||
autocomplete: { type: String, default: 'off' },
|
||||
spellcheck: { type: Boolean, default: false },
|
||||
})
|
||||
|
||||
const emit = defineEmits(['update:modelValue'])
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<input
|
||||
v-bind="$attrs"
|
||||
:type="type"
|
||||
:value="modelValue"
|
||||
:placeholder="placeholder"
|
||||
:disabled="disabled"
|
||||
:min="min"
|
||||
:max="max"
|
||||
:autocomplete="autocomplete"
|
||||
:spellcheck="spellcheck"
|
||||
:class="
|
||||
cn(
|
||||
'flex h-9 w-full rounded-md border border-input bg-muted px-3 py-1 text-sm text-foreground shadow-sm transition-colors placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:border-primary disabled:cursor-not-allowed disabled:opacity-50',
|
||||
props.class,
|
||||
)
|
||||
"
|
||||
@input="emit('update:modelValue', $event.target.value)"
|
||||
/>
|
||||
</template>
|
||||
@@ -1,22 +0,0 @@
|
||||
<script setup>
|
||||
import { cn } from '@/lib/utils'
|
||||
|
||||
const props = defineProps({
|
||||
class: { type: String, default: '' },
|
||||
for: { type: String, default: undefined },
|
||||
})
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<label
|
||||
:for="props.for"
|
||||
:class="
|
||||
cn(
|
||||
'text-sm font-medium leading-none text-foreground peer-disabled:cursor-not-allowed peer-disabled:opacity-70',
|
||||
props.class,
|
||||
)
|
||||
"
|
||||
>
|
||||
<slot />
|
||||
</label>
|
||||
</template>
|
||||
@@ -1,21 +0,0 @@
|
||||
<script setup>
|
||||
import { cn } from '@/lib/utils'
|
||||
|
||||
const props = defineProps({
|
||||
class: { type: String, default: '' },
|
||||
vertical: { type: Boolean, default: false },
|
||||
})
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div
|
||||
:role="'separator'"
|
||||
:class="
|
||||
cn(
|
||||
vertical ? 'inline-flex h-full w-px' : 'flex h-px w-full',
|
||||
'bg-border shrink-0',
|
||||
props.class,
|
||||
)
|
||||
"
|
||||
/>
|
||||
</template>
|
||||
@@ -1,43 +0,0 @@
|
||||
<script setup>
|
||||
import { cn } from '@/lib/utils'
|
||||
|
||||
const props = defineProps({
|
||||
class: { type: String, default: '' },
|
||||
modelValue: { type: Boolean, default: false },
|
||||
disabled: { type: Boolean, default: false },
|
||||
id: { type: String, default: undefined },
|
||||
})
|
||||
|
||||
const emit = defineEmits(['update:modelValue'])
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<button
|
||||
type="button"
|
||||
role="switch"
|
||||
:aria-checked="modelValue"
|
||||
:disabled="disabled"
|
||||
:id="id"
|
||||
:class="
|
||||
cn(
|
||||
'relative inline-flex h-6 w-11 shrink-0 cursor-pointer items-center rounded-full transition-colors duration-200 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50',
|
||||
modelValue
|
||||
? 'bg-primary border-2 border-transparent'
|
||||
: 'bg-transparent border-2 border-muted-foreground/40',
|
||||
props.class,
|
||||
)
|
||||
"
|
||||
@click="emit('update:modelValue', !modelValue)"
|
||||
>
|
||||
<span
|
||||
:class="
|
||||
cn(
|
||||
'pointer-events-none block rounded-full shadow-sm ring-0 transition-all duration-200',
|
||||
modelValue
|
||||
? 'h-5 w-5 translate-x-5 bg-white'
|
||||
: 'h-4 w-4 translate-x-0.5 bg-muted-foreground/60',
|
||||
)
|
||||
"
|
||||
/>
|
||||
</button>
|
||||
</template>
|
||||
@@ -1,30 +0,0 @@
|
||||
<script setup>
|
||||
import { cn } from '@/lib/utils'
|
||||
|
||||
const props = defineProps({
|
||||
class: { type: String, default: '' },
|
||||
modelValue: { type: String, default: '' },
|
||||
placeholder: { type: String, default: '' },
|
||||
disabled: { type: Boolean, default: false },
|
||||
rows: { type: Number, default: 2 },
|
||||
})
|
||||
|
||||
const emit = defineEmits(['update:modelValue'])
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<textarea
|
||||
v-bind="$attrs"
|
||||
:value="modelValue"
|
||||
:placeholder="placeholder"
|
||||
:disabled="disabled"
|
||||
:rows="rows"
|
||||
:class="
|
||||
cn(
|
||||
'flex min-h-15 w-full rounded-md border border-input bg-muted px-3 py-2 text-sm font-mono text-foreground shadow-sm transition-colors placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:border-primary disabled:cursor-not-allowed disabled:opacity-50 resize-vertical',
|
||||
props.class,
|
||||
)
|
||||
"
|
||||
@input="emit('update:modelValue', $event.target.value)"
|
||||
/>
|
||||
</template>
|
||||
@@ -1,8 +1,21 @@
|
||||
import { ref, reactive } from 'vue'
|
||||
import { ref, reactive, computed } from 'vue'
|
||||
import { listPackages, getPackagesInfo } from 'kernelsu'
|
||||
import PinyinMatch from 'pinyin-match'
|
||||
import { readConfig, updateConfig } from '../utils.js'
|
||||
import { fetchConfig, patchConfig } from '../api/luminpro.js'
|
||||
|
||||
/** 拼音匹配库体积较大,进入黑名单页后再按需加载 */
|
||||
let PinyinMatch = null
|
||||
const pinyinReady = ref(false)
|
||||
async function ensurePinyin() {
|
||||
if (PinyinMatch || pinyinReady.value) return
|
||||
try {
|
||||
PinyinMatch = (await import('pinyin-match')).default
|
||||
} catch {
|
||||
PinyinMatch = null
|
||||
}
|
||||
pinyinReady.value = true
|
||||
}
|
||||
|
||||
/** 黑名单管理:应用列表来自 KernelSU API,黑名单本身存在 config.json */
|
||||
export function useApps() {
|
||||
const apps = ref([])
|
||||
const isLoading = ref(false)
|
||||
@@ -12,13 +25,14 @@ export function useApps() {
|
||||
const savedBlacklist = ref(new Set())
|
||||
const activityEntries = ref(new Set())
|
||||
|
||||
/** 每个 app 条目结构: { packageName, appLabel, isSystem, uid, checked, hasActivities } */
|
||||
/** 条目结构: { packageName, appLabel, isSystem, uid, checked, expanded } */
|
||||
|
||||
async function load() {
|
||||
isLoading.value = true
|
||||
loadError.value = ''
|
||||
ensurePinyin() // 后台加载拼音库,不阻塞列表
|
||||
try {
|
||||
const cfg = await readConfig()
|
||||
const cfg = await fetchConfig()
|
||||
const allSaved = Array.isArray(cfg.blacklist_apps) ? cfg.blacklist_apps : []
|
||||
savedBlacklist.value = new Set(allSaved)
|
||||
const savedPkgSet = new Set(allSaved.filter((e) => !e.includes('/')))
|
||||
@@ -30,7 +44,6 @@ export function useApps() {
|
||||
if (pkgs && pkgs.length > 0) infoList = await getPackagesInfo(pkgs)
|
||||
else throw new Error('no pkgs')
|
||||
} catch {
|
||||
console.log('[DEBUG] 使用模拟数据')
|
||||
infoList = Array.from({ length: 150 }, (_, i) => ({
|
||||
packageName: `com.mock.app${i}`,
|
||||
appLabel: i % 10 === 0 ? `测试应用 ${i} (含抖音关键字)` : `模拟应用 ${i}`,
|
||||
@@ -64,8 +77,7 @@ export function useApps() {
|
||||
expanded: false,
|
||||
}),
|
||||
)
|
||||
|
||||
_reorder()
|
||||
reorder()
|
||||
} catch (e) {
|
||||
loadError.value = e.message || String(e)
|
||||
} finally {
|
||||
@@ -73,7 +85,7 @@ export function useApps() {
|
||||
}
|
||||
}
|
||||
|
||||
function _reorder() {
|
||||
function reorder() {
|
||||
apps.value.sort((a, b) => {
|
||||
const stateA = a.checked ? 2 : hasActivity(a.packageName) ? 1 : 0
|
||||
const stateB = b.checked ? 2 : hasActivity(b.packageName) ? 1 : 0
|
||||
@@ -82,7 +94,10 @@ export function useApps() {
|
||||
}
|
||||
|
||||
function hasActivity(pkg) {
|
||||
return [...activityEntries.value].some((e) => e.startsWith(pkg + '/'))
|
||||
for (const entry of activityEntries.value) {
|
||||
if (entry.startsWith(pkg + '/')) return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
function getActivities(pkg) {
|
||||
@@ -91,53 +106,44 @@ export function useApps() {
|
||||
|
||||
function addActivity(entry) {
|
||||
activityEntries.value.add(entry)
|
||||
_reorder()
|
||||
reorder()
|
||||
}
|
||||
|
||||
function removeActivity(entry) {
|
||||
activityEntries.value.delete(entry)
|
||||
_reorder()
|
||||
reorder()
|
||||
}
|
||||
|
||||
async function save(toast) {
|
||||
toast('保存中...')
|
||||
const selectedPkgs = apps.value.filter((a) => a.checked).map((a) => a.packageName)
|
||||
const allEntries = [...selectedPkgs, ...activityEntries.value]
|
||||
const res = await updateConfig({ blacklist_apps: allEntries })
|
||||
if (res.errno === 0) {
|
||||
savedBlacklist.value = new Set(allEntries)
|
||||
toast('黑名单保存成功')
|
||||
} else {
|
||||
toast('保存失败: ' + res.stderr)
|
||||
async function save(snackbar) {
|
||||
const selected = apps.value.filter((a) => a.checked).map((a) => a.packageName)
|
||||
const all = [...selected, ...activityEntries.value]
|
||||
try {
|
||||
await patchConfig({ blacklist_apps: all })
|
||||
savedBlacklist.value = new Set(all)
|
||||
snackbar?.('黑名单已保存')
|
||||
} catch (e) {
|
||||
snackbar?.(`保存失败: ${e.message}`)
|
||||
}
|
||||
}
|
||||
|
||||
function onCheckboxChange() {
|
||||
_reorder()
|
||||
}
|
||||
|
||||
function toggleSystemApps() {
|
||||
showingSystemApps.value = !showingSystemApps.value
|
||||
load()
|
||||
}
|
||||
|
||||
function selectAll() {
|
||||
apps.value.forEach((a) => {
|
||||
a.checked = true
|
||||
})
|
||||
_reorder()
|
||||
for (const app of apps.value) app.checked = true
|
||||
reorder()
|
||||
}
|
||||
|
||||
function selectNone() {
|
||||
apps.value.forEach((a) => {
|
||||
a.checked = false
|
||||
})
|
||||
_reorder()
|
||||
for (const app of apps.value) app.checked = false
|
||||
reorder()
|
||||
}
|
||||
|
||||
function invertSelection() {
|
||||
apps.value.forEach((a) => {
|
||||
a.checked = !a.checked
|
||||
})
|
||||
_reorder()
|
||||
for (const app of apps.value) app.checked = !app.checked
|
||||
reorder()
|
||||
}
|
||||
|
||||
const smartKeywords = [
|
||||
@@ -166,35 +172,53 @@ export function useApps() {
|
||||
'x',
|
||||
]
|
||||
|
||||
function smartSelect() {
|
||||
apps.value.forEach((a) => {
|
||||
const name = (a.appLabel || '').toLowerCase()
|
||||
const pkg = (a.packageName || '').toLowerCase()
|
||||
for (const kw of smartKeywords) {
|
||||
if (kw === 'x') {
|
||||
function smartSelect(snackbar) {
|
||||
let count = 0
|
||||
for (const app of apps.value) {
|
||||
const name = (app.appLabel || '').toLowerCase()
|
||||
const pkg = (app.packageName || '').toLowerCase()
|
||||
for (const keyword of smartKeywords) {
|
||||
if (keyword === 'x') {
|
||||
if (name === 'x' || name === 'x (twitter)') {
|
||||
a.checked = true
|
||||
if (!app.checked) count++
|
||||
app.checked = true
|
||||
break
|
||||
}
|
||||
} else if (name.includes(kw) || pkg.includes(kw)) {
|
||||
a.checked = true
|
||||
} else if (name.includes(keyword) || pkg.includes(keyword)) {
|
||||
if (!app.checked) count++
|
||||
app.checked = true
|
||||
break
|
||||
}
|
||||
}
|
||||
})
|
||||
_reorder()
|
||||
}
|
||||
reorder()
|
||||
snackbar?.(count > 0 ? `已智能勾选 ${count} 个应用` : '没有匹配到可勾选的应用')
|
||||
}
|
||||
|
||||
// 过滤后的列表
|
||||
/** 过滤后的列表(供虚拟滚动使用) */
|
||||
function getFilteredApps() {
|
||||
const kw = searchKeyword.value.trim().toLowerCase()
|
||||
if (!kw) return apps.value
|
||||
const keyword = searchKeyword.value.trim().toLowerCase()
|
||||
if (!keyword) return apps.value
|
||||
return apps.value.filter((a) => {
|
||||
const pkg = a.packageName.toLowerCase()
|
||||
return pkg.includes(kw) || PinyinMatch.match(a.appLabel, kw)
|
||||
if (pkg.includes(keyword)) return true
|
||||
// 拼音库未就绪时退化为普通子串匹配
|
||||
if (!pinyinReady.value || !PinyinMatch) {
|
||||
return (a.appLabel || '').toLowerCase().includes(keyword)
|
||||
}
|
||||
return !!PinyinMatch.match(a.appLabel, keyword)
|
||||
})
|
||||
}
|
||||
|
||||
const unsavedCount = computed(() => {
|
||||
const selected = apps.value.filter((a) => a.checked).map((a) => a.packageName)
|
||||
const all = [...selected, ...activityEntries.value]
|
||||
const saved = [...savedBlacklist.value]
|
||||
if (all.length !== saved.length) return 1
|
||||
const savedSet = new Set(saved)
|
||||
return all.some((e) => !savedSet.has(e)) ? 1 : 0
|
||||
})
|
||||
|
||||
return {
|
||||
apps,
|
||||
isLoading,
|
||||
@@ -203,13 +227,14 @@ export function useApps() {
|
||||
showingSystemApps,
|
||||
savedBlacklist,
|
||||
activityEntries,
|
||||
unsavedCount,
|
||||
load,
|
||||
save,
|
||||
hasActivity,
|
||||
getActivities,
|
||||
addActivity,
|
||||
removeActivity,
|
||||
onCheckboxChange,
|
||||
reorder,
|
||||
toggleSystemApps,
|
||||
selectAll,
|
||||
selectNone,
|
||||
|
||||
+153
-252
@@ -1,286 +1,187 @@
|
||||
import { ref, watch } from 'vue'
|
||||
import {
|
||||
runCmd,
|
||||
readConfig,
|
||||
writeConfig,
|
||||
updateConfig,
|
||||
BACKUP_CONFIG_FILE,
|
||||
PID_FILE,
|
||||
DEFAULT_NOW_BRI_FILE,
|
||||
DEFAULT_SYS_MAX_BRI_FILE,
|
||||
} from '../utils.js'
|
||||
import { ref, reactive, computed } from 'vue'
|
||||
import { fetchConfig, patchConfig, readModuleFile } from '../api/luminpro.js'
|
||||
|
||||
/** 主配置卡片负责的字段 */
|
||||
const MAIN_KEYS = [
|
||||
'ui_max_bri',
|
||||
'max_bri',
|
||||
'steps_num',
|
||||
'auto_bri_sleep',
|
||||
'display_hdr_sleep',
|
||||
'hdr_enter_ratio',
|
||||
'hdr_exit_ratio',
|
||||
'compatibility_mode',
|
||||
'sleep_time',
|
||||
]
|
||||
|
||||
/** 高级设置负责的字段 */
|
||||
const ADVANCED_KEYS = ['now_bri_file', 'max_bri_file', 'inotify_events', 'debug_mode', 'log_max_size', 'log_level']
|
||||
|
||||
const INT_KEYS = new Set([
|
||||
'ui_max_bri',
|
||||
'max_bri',
|
||||
'steps_num',
|
||||
'log_max_size',
|
||||
'auto_bri_sleep',
|
||||
'display_hdr_sleep',
|
||||
'compatibility_mode',
|
||||
'debug_mode',
|
||||
])
|
||||
const FLOAT_KEYS = new Set(['hdr_enter_ratio', 'hdr_exit_ratio'])
|
||||
|
||||
/** 配置改动的类型还原:表单里统一用字符串,写回时按字段类型转换 */
|
||||
function toTyped(key, value) {
|
||||
if (INT_KEYS.has(key)) return parseInt(value, 10) || 0
|
||||
if (FLOAT_KEYS.has(key)) return parseFloat(value) || 0
|
||||
return value
|
||||
}
|
||||
|
||||
/** 配置对象 -> 表单字符串(数组字段保持数组) */
|
||||
function toForm(cfg, keys) {
|
||||
const out = {}
|
||||
for (const key of keys) {
|
||||
const value = cfg[key]
|
||||
if (Array.isArray(value)) out[key] = value
|
||||
else if (value === null || value === undefined) out[key] = ''
|
||||
else out[key] = String(value)
|
||||
}
|
||||
return out
|
||||
}
|
||||
|
||||
export function useConfig() {
|
||||
// 亮度配置
|
||||
const uiMaxBri = ref('')
|
||||
const maxBri = ref('')
|
||||
const stepsNum = ref('50')
|
||||
const saved = ref({})
|
||||
const loading = ref(false)
|
||||
const error = ref('')
|
||||
|
||||
// 执行策略
|
||||
const autoBriSleep = ref(false)
|
||||
const displayHdrSleep = ref(false)
|
||||
const hdrEnterRatio = ref('1.15')
|
||||
const hdrExitRatio = ref('1.05')
|
||||
const compatibilityMode = ref(false)
|
||||
const sleepMode = ref(false)
|
||||
const sleepStartH = ref('19')
|
||||
const sleepStartM = ref('00')
|
||||
const sleepEndH = ref('06')
|
||||
const sleepEndM = ref('00')
|
||||
|
||||
// 高级设置
|
||||
const nowBriFile = ref(DEFAULT_NOW_BRI_FILE)
|
||||
const sysMaxBriFile = ref(DEFAULT_SYS_MAX_BRI_FILE)
|
||||
const inotifyEvents = ref('c')
|
||||
const debugMode = ref(false)
|
||||
const logLevel = ref('info')
|
||||
const logMaxSize = ref('500')
|
||||
|
||||
// 脸污标记
|
||||
const dirty = ref(false)
|
||||
const dirtyAdvanced = ref(false)
|
||||
let _silent = false
|
||||
|
||||
// Web UI 配置 (localStorage 持久化)
|
||||
const autoRefresh = ref(localStorage.getItem('autoRefresh') !== 'false')
|
||||
const statusRefreshInterval = ref(
|
||||
Math.max(100, parseInt(localStorage.getItem('statusLogRefreshInterval') || '1000', 10)),
|
||||
)
|
||||
const uiZoom = ref(
|
||||
Math.min(150, Math.max(50, parseInt(localStorage.getItem('uiZoom') || '100', 10))),
|
||||
)
|
||||
const themeMode = ref(localStorage.getItem('themeMode') || 'system')
|
||||
|
||||
// 监听主配置字段
|
||||
watch(
|
||||
[
|
||||
uiMaxBri,
|
||||
maxBri,
|
||||
stepsNum,
|
||||
autoBriSleep,
|
||||
displayHdrSleep,
|
||||
hdrEnterRatio,
|
||||
hdrExitRatio,
|
||||
compatibilityMode,
|
||||
sleepMode,
|
||||
sleepStartH,
|
||||
sleepStartM,
|
||||
sleepEndH,
|
||||
sleepEndM,
|
||||
],
|
||||
() => {
|
||||
if (!_silent) dirty.value = true
|
||||
},
|
||||
)
|
||||
// 监听高级设置字段 (系统管理的日志项也随「保存设置」写入)
|
||||
watch([nowBriFile, sysMaxBriFile, inotifyEvents, debugMode, logLevel, logMaxSize], () => {
|
||||
if (!_silent) dirtyAdvanced.value = true
|
||||
const form = reactive({
|
||||
...toForm({}, [...MAIN_KEYS, ...ADVANCED_KEYS]),
|
||||
blacklist_apps: [],
|
||||
})
|
||||
|
||||
function hydrate(cfg) {
|
||||
saved.value = { ...cfg }
|
||||
Object.assign(form, toForm(cfg, [...MAIN_KEYS, ...ADVANCED_KEYS]))
|
||||
form.blacklist_apps = Array.isArray(cfg.blacklist_apps) ? [...cfg.blacklist_apps] : []
|
||||
}
|
||||
|
||||
async function load() {
|
||||
_silent = true
|
||||
const cfg = await readConfig()
|
||||
if (!cfg || Object.keys(cfg).length === 0) {
|
||||
_silent = false
|
||||
loading.value = true
|
||||
try {
|
||||
hydrate(await fetchConfig())
|
||||
error.value = ''
|
||||
} catch (e) {
|
||||
error.value = e.message
|
||||
} finally {
|
||||
loading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
/** 某组字段中相对已保存配置发生变化的项(已按类型还原) */
|
||||
function changedKeys(keys) {
|
||||
const patch = {}
|
||||
for (const key of keys) {
|
||||
const current = key === 'blacklist_apps' ? JSON.stringify(form[key]) : String(form[key])
|
||||
const original = Array.isArray(saved.value[key])
|
||||
? JSON.stringify(saved.value[key])
|
||||
: String(saved.value[key] ?? '')
|
||||
if (current !== original) patch[key] = toTyped(key, form[key])
|
||||
}
|
||||
return patch
|
||||
}
|
||||
|
||||
/** 整型开关字段(0/1)与布尔值之间的桥接:md-switch 给出的是布尔值 */
|
||||
function intBool(key) {
|
||||
return computed({
|
||||
get: () => Number(form[key]) === 1,
|
||||
set: (on) => {
|
||||
form[key] = on ? '1' : '0'
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
const autoBriSleep = intBool('auto_bri_sleep')
|
||||
const displayHdrSleep = intBool('display_hdr_sleep')
|
||||
const compatibilityMode = intBool('compatibility_mode')
|
||||
const debugMode = intBool('debug_mode')
|
||||
|
||||
const diffMain = computed(() => changedKeys(MAIN_KEYS))
|
||||
const diffAdvanced = computed(() => changedKeys(ADVANCED_KEYS))
|
||||
const dirtyMain = computed(() => Object.keys(diffMain.value).length > 0)
|
||||
const dirtyAdvanced = computed(() => Object.keys(diffAdvanced.value).length > 0)
|
||||
|
||||
async function save(patch, snackbar, message) {
|
||||
if (Object.keys(patch).length === 0) {
|
||||
snackbar?.('没有需要保存的改动')
|
||||
return
|
||||
}
|
||||
|
||||
uiMaxBri.value = cfg.ui_max_bri != null ? String(cfg.ui_max_bri) : ''
|
||||
maxBri.value = cfg.max_bri != null ? String(cfg.max_bri) : ''
|
||||
stepsNum.value = cfg.steps_num != null ? String(cfg.steps_num) : '50'
|
||||
logMaxSize.value = cfg.log_max_size != null ? String(cfg.log_max_size) : '500'
|
||||
autoBriSleep.value = cfg.auto_bri_sleep === 1
|
||||
displayHdrSleep.value = cfg.display_hdr_sleep === 1
|
||||
hdrEnterRatio.value = cfg.hdr_enter_ratio != null ? String(cfg.hdr_enter_ratio) : '1.15'
|
||||
hdrExitRatio.value = cfg.hdr_exit_ratio != null ? String(cfg.hdr_exit_ratio) : '1.05'
|
||||
compatibilityMode.value = cfg.compatibility_mode === 1
|
||||
nowBriFile.value = cfg.now_bri_file || DEFAULT_NOW_BRI_FILE
|
||||
sysMaxBriFile.value = cfg.max_bri_file || DEFAULT_SYS_MAX_BRI_FILE
|
||||
inotifyEvents.value = cfg.inotify_events || 'c'
|
||||
debugMode.value = cfg.debug_mode === 1
|
||||
logLevel.value = cfg.log_level || 'info'
|
||||
|
||||
const st = cfg.sleep_time || ''
|
||||
if (st && st.includes('-')) {
|
||||
sleepMode.value = true
|
||||
const [s, e] = st.split('-')
|
||||
if (s.length === 4) {
|
||||
sleepStartH.value = s.slice(0, 2)
|
||||
sleepStartM.value = s.slice(2)
|
||||
}
|
||||
if (e.length === 4) {
|
||||
sleepEndH.value = e.slice(0, 2)
|
||||
sleepEndM.value = e.slice(2)
|
||||
}
|
||||
} else {
|
||||
sleepMode.value = false
|
||||
try {
|
||||
await patchConfig(patch)
|
||||
await load()
|
||||
snackbar?.(message)
|
||||
} catch (e) {
|
||||
snackbar?.(`保存失败: ${e.message}`)
|
||||
}
|
||||
dirty.value = false
|
||||
dirtyAdvanced.value = false
|
||||
_silent = false
|
||||
}
|
||||
|
||||
function getSleepTimeStr() {
|
||||
if (!sleepMode.value) return ''
|
||||
const pad = (v) => String(v).padStart(2, '0')
|
||||
return `${pad(sleepStartH.value)}${pad(sleepStartM.value)}-${pad(sleepEndH.value)}${pad(sleepEndM.value)}`
|
||||
}
|
||||
const saveMain = (snackbar) => save(diffMain.value, snackbar, '配置已保存')
|
||||
const saveAdvanced = (snackbar) => save(diffAdvanced.value, snackbar, '高级设置已保存,需重启模块生效')
|
||||
|
||||
async function save(toast) {
|
||||
if (!uiMaxBri.value || !maxBri.value) {
|
||||
toast('亮度値不能为空')
|
||||
return
|
||||
}
|
||||
toast('保存中...')
|
||||
// 读取当前配置(保留 blacklist_apps 等其他字段)
|
||||
const current = await readConfig()
|
||||
await writeConfig({
|
||||
...current,
|
||||
ui_max_bri: parseInt(uiMaxBri.value) || 0,
|
||||
max_bri: parseInt(maxBri.value) || 0,
|
||||
steps_num: parseInt(stepsNum.value) || 50,
|
||||
auto_bri_sleep: autoBriSleep.value ? 1 : 0,
|
||||
display_hdr_sleep: displayHdrSleep.value ? 1 : 0,
|
||||
hdr_enter_ratio: parseFloat(hdrEnterRatio.value) || 1.15,
|
||||
hdr_exit_ratio: parseFloat(hdrExitRatio.value) || 1.05,
|
||||
compatibility_mode: compatibilityMode.value ? 1 : 0,
|
||||
sleep_time: getSleepTimeStr(),
|
||||
})
|
||||
const pidRes = await runCmd(`cat "${PID_FILE}"`)
|
||||
toast(
|
||||
pidRes.errno === 0 && pidRes.stdout.trim()
|
||||
? '配置已保存 (下次重启模块或触发时生效)'
|
||||
: '配置已保存 (服务未运行)',
|
||||
)
|
||||
dirty.value = false
|
||||
}
|
||||
|
||||
async function saveAdvanced(toast, onPathsChanged) {
|
||||
toast('保存中...')
|
||||
await updateConfig({
|
||||
now_bri_file: nowBriFile.value || DEFAULT_NOW_BRI_FILE,
|
||||
max_bri_file: sysMaxBriFile.value || DEFAULT_SYS_MAX_BRI_FILE,
|
||||
inotify_events: inotifyEvents.value || 'c',
|
||||
debug_mode: debugMode.value ? 1 : 0,
|
||||
log_max_size: parseInt(logMaxSize.value) || 500,
|
||||
log_level: logLevel.value,
|
||||
})
|
||||
onPathsChanged?.()
|
||||
toast('高级设置已保存,需重启模块生效')
|
||||
dirtyAdvanced.value = false
|
||||
}
|
||||
|
||||
async function resetToDefaults(toast) {
|
||||
toast('正在恢复默认配置...')
|
||||
const backupRes = await runCmd(`cat "${BACKUP_CONFIG_FILE}"`)
|
||||
if (backupRes.errno !== 0 || !backupRes.stdout.trim()) {
|
||||
toast('备份文件不存在,无法恢复')
|
||||
/** 从安装时备份恢复默认值(只改表单,需再点保存) */
|
||||
async function restoreBackup(snackbar) {
|
||||
const raw = await readModuleFile('config/.backup/config.json')
|
||||
if (!raw.trim()) {
|
||||
snackbar?.('备份文件不存在,无法恢复')
|
||||
return
|
||||
}
|
||||
let backup
|
||||
try {
|
||||
backup = JSON.parse(backupRes.stdout)
|
||||
backup = JSON.parse(raw)
|
||||
} catch {
|
||||
toast('备份文件损坏')
|
||||
snackbar?.('备份文件损坏')
|
||||
return
|
||||
}
|
||||
|
||||
uiMaxBri.value = backup.ui_max_bri != null ? String(backup.ui_max_bri) : ''
|
||||
maxBri.value = backup.max_bri != null ? String(backup.max_bri) : ''
|
||||
autoBriSleep.value = backup.auto_bri_sleep === 1
|
||||
displayHdrSleep.value = backup.display_hdr_sleep === 1
|
||||
hdrEnterRatio.value = backup.hdr_enter_ratio != null ? String(backup.hdr_enter_ratio) : '1.15'
|
||||
hdrExitRatio.value = backup.hdr_exit_ratio != null ? String(backup.hdr_exit_ratio) : '1.05'
|
||||
compatibilityMode.value = backup.compatibility_mode === 1
|
||||
stepsNum.value = backup.steps_num != null ? String(backup.steps_num) : '50'
|
||||
logMaxSize.value = backup.log_max_size != null ? String(backup.log_max_size) : '500'
|
||||
nowBriFile.value = backup.now_bri_file || DEFAULT_NOW_BRI_FILE
|
||||
sysMaxBriFile.value = backup.max_bri_file || DEFAULT_SYS_MAX_BRI_FILE
|
||||
inotifyEvents.value = backup.inotify_events || 'c'
|
||||
|
||||
const st = backup.sleep_time || ''
|
||||
if (st && st.includes('-')) {
|
||||
sleepMode.value = true
|
||||
const [s, e] = st.split('-')
|
||||
if (s.length === 4) {
|
||||
sleepStartH.value = s.slice(0, 2)
|
||||
sleepStartM.value = s.slice(2)
|
||||
}
|
||||
if (e.length === 4) {
|
||||
sleepEndH.value = e.slice(0, 2)
|
||||
sleepEndM.value = e.slice(2)
|
||||
}
|
||||
} else {
|
||||
sleepMode.value = true
|
||||
sleepStartH.value = '19'
|
||||
sleepStartM.value = '00'
|
||||
sleepEndH.value = '06'
|
||||
sleepEndM.value = '00'
|
||||
}
|
||||
await save(toast)
|
||||
await saveAdvanced(toast)
|
||||
hydrate({ ...saved.value, ...backup })
|
||||
snackbar?.('已载入安装时的配置,点击保存生效')
|
||||
}
|
||||
|
||||
function saveWebUIConfig(toast, newAutoRefresh, newInterval, newZoom, newTheme, onRestart) {
|
||||
const interval = Math.max(100, parseInt(newInterval, 10) || 1000)
|
||||
const zoom = Math.min(150, Math.max(50, parseInt(newZoom, 10) || 100))
|
||||
localStorage.setItem('autoRefresh', newAutoRefresh)
|
||||
localStorage.setItem('statusLogRefreshInterval', interval)
|
||||
localStorage.setItem('uiZoom', zoom)
|
||||
localStorage.setItem('themeMode', newTheme)
|
||||
autoRefresh.value = newAutoRefresh
|
||||
statusRefreshInterval.value = interval
|
||||
uiZoom.value = zoom
|
||||
themeMode.value = newTheme
|
||||
document.documentElement.style.zoom = zoom / 100
|
||||
applyTheme(newTheme)
|
||||
onRestart?.(newAutoRefresh, interval)
|
||||
toast('Web UI 配置已保存')
|
||||
}
|
||||
// ── 定时休眠:字符串 <-> 开关 + 四个时间输入 ──────────────────────
|
||||
const sleepEnabled = computed({
|
||||
get: () => !!form.sleep_time,
|
||||
set: (on) => {
|
||||
form.sleep_time = on ? form.sleep_time || '2300-0700' : ''
|
||||
},
|
||||
})
|
||||
|
||||
function applyZoom() {
|
||||
document.documentElement.style.zoom = uiZoom.value / 100
|
||||
}
|
||||
const sleepParts = computed(() => {
|
||||
const text = String(form.sleep_time || '')
|
||||
const match = /^(\d{2})(\d{2})-(\d{2})(\d{2})$/.exec(text)
|
||||
if (!match) return ['23', '00', '07', '00']
|
||||
return [match[1], match[2], match[3], match[4]]
|
||||
})
|
||||
|
||||
function applyTheme(mode) {
|
||||
const html = document.documentElement
|
||||
html.classList.remove('light', 'dark')
|
||||
if (mode === 'light') html.classList.add('light')
|
||||
else if (mode === 'dark') html.classList.add('dark')
|
||||
function setSleepPart(index, value) {
|
||||
const parts = [...sleepParts.value]
|
||||
parts[index] = String(value).padStart(2, '0').slice(-2)
|
||||
form.sleep_time = `${parts[0]}${parts[1]}-${parts[2]}${parts[3]}`
|
||||
}
|
||||
|
||||
return {
|
||||
uiMaxBri,
|
||||
maxBri,
|
||||
stepsNum,
|
||||
logMaxSize,
|
||||
saved,
|
||||
form,
|
||||
loading,
|
||||
error,
|
||||
dirtyMain,
|
||||
dirtyAdvanced,
|
||||
autoBriSleep,
|
||||
displayHdrSleep,
|
||||
hdrEnterRatio,
|
||||
hdrExitRatio,
|
||||
compatibilityMode,
|
||||
sleepMode,
|
||||
sleepStartH,
|
||||
sleepStartM,
|
||||
sleepEndH,
|
||||
sleepEndM,
|
||||
nowBriFile,
|
||||
sysMaxBriFile,
|
||||
inotifyEvents,
|
||||
debugMode,
|
||||
logLevel,
|
||||
dirty,
|
||||
dirtyAdvanced,
|
||||
autoRefresh,
|
||||
statusRefreshInterval,
|
||||
uiZoom,
|
||||
themeMode,
|
||||
load,
|
||||
save,
|
||||
saveMain,
|
||||
saveAdvanced,
|
||||
resetToDefaults,
|
||||
saveWebUIConfig,
|
||||
applyZoom,
|
||||
applyTheme,
|
||||
restoreBackup,
|
||||
sleepEnabled,
|
||||
sleepParts,
|
||||
setSleepPart,
|
||||
}
|
||||
}
|
||||
@@ -1,58 +1,68 @@
|
||||
import { ref, computed } from 'vue'
|
||||
import { runCmd, LOG_FILE } from '../utils.js'
|
||||
import { fetchLog, clearLog, exportLog } from '../api/luminpro.js'
|
||||
|
||||
const LEVELS = ['', 'INFO', 'WARN', 'ERROR', 'SUCCESS']
|
||||
|
||||
/** 日志:数据来自 Go 侧 `luminpro log tail`,等级过滤在前端进行 */
|
||||
export function useLog() {
|
||||
const fullLog = ref('')
|
||||
const filterLevel = ref('')
|
||||
const isLoading = ref(false)
|
||||
const entries = ref([])
|
||||
const level = ref('')
|
||||
const error = ref('')
|
||||
const loading = ref(false)
|
||||
|
||||
const filteredLog = computed(() => {
|
||||
if (!fullLog.value) return '暂无日志'
|
||||
if (!filterLevel.value) return fullLog.value
|
||||
const lines = fullLog.value.split('\n').filter((l) => l.includes(`[${filterLevel.value}]`))
|
||||
return lines.length > 0 ? lines.join('\n') : `暂无 [${filterLevel.value}] 等级的日志`
|
||||
})
|
||||
const levels = LEVELS
|
||||
const filtered = computed(() =>
|
||||
level.value ? entries.value.filter((e) => e.level === level.value) : entries.value,
|
||||
)
|
||||
|
||||
const asText = (list = filtered.value) =>
|
||||
list.map((e) => `[${e.time}] [${e.tag}] [${e.level}] ${e.message}`.trim()).join('\n')
|
||||
|
||||
async function load() {
|
||||
const res = await runCmd(`tail -n 100 "${LOG_FILE}"`)
|
||||
fullLog.value =
|
||||
res.errno === 0 ? res.stdout.trim() || '暂无日志' : '无法读取日志 (可能模块尚未产生日志文件)'
|
||||
loading.value = true
|
||||
try {
|
||||
const page = await fetchLog(200)
|
||||
entries.value = page.entries ?? []
|
||||
error.value = ''
|
||||
} catch (e) {
|
||||
error.value = e.message
|
||||
} finally {
|
||||
loading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
async function clear(toast) {
|
||||
toast('正在清空日志...')
|
||||
const res = await runCmd(`> "${LOG_FILE}"`)
|
||||
if (res.errno === 0) {
|
||||
fullLog.value = ''
|
||||
toast('日志已清空')
|
||||
} else toast('清空失败: ' + (res.stderr || '未知错误'))
|
||||
async function clear(snackbar) {
|
||||
try {
|
||||
await clearLog()
|
||||
entries.value = []
|
||||
snackbar?.('日志已清空')
|
||||
} catch (e) {
|
||||
snackbar?.(`清空失败: ${e.message}`)
|
||||
}
|
||||
}
|
||||
|
||||
async function copy(toast) {
|
||||
const res = await runCmd(`tail -n 50 "${LOG_FILE}"`)
|
||||
if (res.errno !== 0 || !res.stdout.trim()) {
|
||||
toast('暂无日志内容')
|
||||
async function exportTo(snackbar) {
|
||||
try {
|
||||
const res = await exportLog('/sdcard')
|
||||
snackbar?.(`已导出到 ${res.path}`)
|
||||
} catch (e) {
|
||||
snackbar?.(`导出失败: ${e.message}`)
|
||||
}
|
||||
}
|
||||
|
||||
async function copy(snackbar) {
|
||||
const text = asText()
|
||||
if (!text) {
|
||||
snackbar?.('暂无日志可复制')
|
||||
return
|
||||
}
|
||||
try {
|
||||
await navigator.clipboard.writeText(res.stdout.trim())
|
||||
await navigator.clipboard.writeText(text)
|
||||
snackbar?.('日志已复制到剪贴板')
|
||||
} catch {
|
||||
const ta = document.createElement('textarea')
|
||||
ta.value = res.stdout.trim()
|
||||
ta.style.cssText = 'position:fixed;opacity:0;pointer-events:none'
|
||||
document.body.appendChild(ta)
|
||||
ta.select()
|
||||
document.execCommand('copy')
|
||||
document.body.removeChild(ta)
|
||||
snackbar?.('复制失败,请手动选择文本')
|
||||
}
|
||||
toast('已复制最新 50 条日志')
|
||||
}
|
||||
|
||||
async function exportLog(toast) {
|
||||
toast('正在导出...')
|
||||
const res = await runCmd(`cp "${LOG_FILE}" "/sdcard/LuminPro_$(date '+%Y%m%d_%H%M%S').log"`)
|
||||
toast(res.errno === 0 ? '日志已导出到 /sdcard' : '导出失败: ' + (res.stderr || '未知错误'))
|
||||
}
|
||||
|
||||
return { fullLog, filterLevel, filteredLog, isLoading, load, clear, copy, exportLog }
|
||||
return { entries, filtered, level, levels, error, loading, asText, load, clear, exportTo, copy }
|
||||
}
|
||||
@@ -1,23 +0,0 @@
|
||||
import { ref } from 'vue'
|
||||
import { runCmd, OPLOCK_FILE } from '../utils.js'
|
||||
|
||||
/**
|
||||
* 操作锁:后台脚本 (up.sh 渐变 / boost.sh 峰值 / restart.sh 重启) 写亮度节点期间
|
||||
* 会创建 oplock 并写入自身 PID。WebUI 据此暂停刷新、禁用写操作。
|
||||
* 锁文件中的 PID 不存在时视为遗留锁,就地清理并放行。
|
||||
*/
|
||||
export function useOplock() {
|
||||
const isLocked = ref(false)
|
||||
|
||||
async function refresh() {
|
||||
const res = await runCmd(
|
||||
`F="${OPLOCK_FILE}"; if [ -f "$F" ]; then P="$(cat "$F" 2>/dev/null)"; ` +
|
||||
`if [ -n "$P" ] && [ -d "/proc/$P" ]; then echo locked; ` +
|
||||
`else rm -f "$F"; echo free; fi; else echo free; fi`,
|
||||
)
|
||||
isLocked.value = res.errno === 0 && res.stdout.trim() === 'locked'
|
||||
return isLocked.value
|
||||
}
|
||||
|
||||
return { isLocked, refresh }
|
||||
}
|
||||
@@ -0,0 +1,70 @@
|
||||
import { ref, computed } from 'vue'
|
||||
|
||||
/** Snackbar(M3):底部浮层提示,自动消失 */
|
||||
export function useSnackbar() {
|
||||
const messages = ref([])
|
||||
let seq = 0
|
||||
|
||||
function show(text, { duration = 3000 } = {}) {
|
||||
if (!text) return
|
||||
const id = ++seq
|
||||
messages.value.push({ id, text })
|
||||
if (messages.value.length > 3) messages.value.shift()
|
||||
setTimeout(() => dismiss(id), duration)
|
||||
}
|
||||
|
||||
function dismiss(id) {
|
||||
messages.value = messages.value.filter((m) => m.id !== id)
|
||||
}
|
||||
|
||||
return { messages, show, dismiss }
|
||||
}
|
||||
|
||||
/**
|
||||
* 主题 / 缩放 / 刷新频率等纯前端偏好(localStorage)。
|
||||
* 模块状态不放这里——它属于 config.json。
|
||||
*/
|
||||
export function useWebUIPrefs() {
|
||||
const autoRefresh = ref(localStorage.getItem('autoRefresh') !== 'false')
|
||||
const refreshInterval = ref(
|
||||
Math.max(100, parseInt(localStorage.getItem('statusLogRefreshInterval') || '1000', 10)),
|
||||
)
|
||||
const zoom = ref(Math.min(150, Math.max(50, parseInt(localStorage.getItem('uiZoom') || '100', 10))))
|
||||
const themeMode = ref(localStorage.getItem('themeMode') || 'system')
|
||||
|
||||
const zoomScale = computed(() => zoom.value / 100)
|
||||
|
||||
function applyZoom() {
|
||||
document.documentElement.style.zoom = String(zoomScale.value)
|
||||
}
|
||||
|
||||
function applyTheme(mode) {
|
||||
const root = document.documentElement
|
||||
root.classList.remove('light', 'dark')
|
||||
if (mode === 'light' || mode === 'dark') root.classList.add(mode)
|
||||
}
|
||||
|
||||
function save({ autoRefresh: ar, refreshInterval: ri, zoom: z, themeMode: tm }) {
|
||||
autoRefresh.value = ar
|
||||
refreshInterval.value = Math.max(100, parseInt(ri, 10) || 1000)
|
||||
zoom.value = Math.min(150, Math.max(50, parseInt(z, 10) || 100))
|
||||
themeMode.value = tm
|
||||
localStorage.setItem('autoRefresh', String(autoRefresh.value))
|
||||
localStorage.setItem('statusLogRefreshInterval', String(refreshInterval.value))
|
||||
localStorage.setItem('uiZoom', String(zoom.value))
|
||||
localStorage.setItem('themeMode', themeMode.value)
|
||||
applyZoom()
|
||||
applyTheme(themeMode.value)
|
||||
}
|
||||
|
||||
return {
|
||||
autoRefresh,
|
||||
refreshInterval,
|
||||
zoom,
|
||||
themeMode,
|
||||
zoomScale,
|
||||
applyZoom,
|
||||
applyTheme,
|
||||
save,
|
||||
}
|
||||
}
|
||||
@@ -1,150 +1,108 @@
|
||||
import { ref, computed } from 'vue'
|
||||
import {
|
||||
runCmd,
|
||||
readConfig,
|
||||
PID_FILE,
|
||||
STOP_FLAG_FILE,
|
||||
DEFAULT_NOW_BRI_FILE,
|
||||
DEFAULT_SYS_MAX_BRI_FILE,
|
||||
} from '../utils.js'
|
||||
fetchStatus,
|
||||
fetchOplock,
|
||||
setBrightness as apiSetBrightness,
|
||||
boost as apiBoost,
|
||||
restart as apiRestart,
|
||||
toggleService as apiToggleService,
|
||||
} from '../api/luminpro.js'
|
||||
|
||||
/** 守护进程与亮度状态:数据来自 Go 侧 `luminpro status` */
|
||||
export function useStatus() {
|
||||
// 亮度
|
||||
const currentBri = ref(null)
|
||||
const sysMaxBri = ref(null)
|
||||
const status = ref(null)
|
||||
const oplock = ref({ locked: false })
|
||||
const error = ref('')
|
||||
|
||||
// 服务状态
|
||||
const inotifydPid = ref('—')
|
||||
const inotifydState = ref('—')
|
||||
const isRunning = ref(false)
|
||||
const isPaused = ref(false)
|
||||
const statusClass = computed(() => {
|
||||
if (isPaused.value) return 'status-paused'
|
||||
if (isRunning.value) return 'status-running'
|
||||
return 'status-loading'
|
||||
const moduleInfo = computed(() => status.value?.module ?? {})
|
||||
const daemon = computed(() => status.value?.daemon ?? {})
|
||||
const brightness = computed(() => status.value?.brightness ?? { current: 0, max: 0, percent: 0 })
|
||||
const display = computed(() => status.value?.display ?? null)
|
||||
const sleep = computed(() => status.value?.sleep ?? { window: '', active: false })
|
||||
const cfg = computed(() => status.value?.config ?? {})
|
||||
|
||||
const isPaused = computed(() => !!daemon.value.paused)
|
||||
const isRunning = computed(() => !!daemon.value.running && !daemon.value.paused)
|
||||
const statusText = computed(() => (isPaused.value ? '已暂停' : isRunning.value ? '运行中' : '未运行'))
|
||||
const statusClass = computed(() =>
|
||||
isPaused.value ? 'paused' : isRunning.value ? 'running' : 'stopped',
|
||||
)
|
||||
const sleepText = computed(() => {
|
||||
if (!sleep.value.window) return '未配置'
|
||||
return sleep.value.active ? '休眠中' : '非休眠'
|
||||
})
|
||||
const statusText = computed(() => {
|
||||
if (isPaused.value) return '已暂停'
|
||||
if (isRunning.value) return '运行中'
|
||||
return '未运行'
|
||||
const hdrText = computed(() => {
|
||||
const d = display.value
|
||||
if (!d || !d.hdrKnown) return '—'
|
||||
return `${d.hdrRatio.toFixed(2)}${d.hdrStale ? '*' : ''}`
|
||||
})
|
||||
|
||||
// HDR / 睡眠状态
|
||||
const hdrRatio = ref('—')
|
||||
const sleepStatus = ref('—')
|
||||
|
||||
// 缓存配置字段(避免每次刷新都 readConfig)
|
||||
let _nowBriFile = null
|
||||
let _sysMaxBriFile = null
|
||||
let _sleepTime = null
|
||||
|
||||
async function _ensurePaths() {
|
||||
if (_nowBriFile && _sysMaxBriFile) return
|
||||
const cfg = await readConfig()
|
||||
_nowBriFile = cfg.now_bri_file || DEFAULT_NOW_BRI_FILE
|
||||
_sysMaxBriFile = cfg.max_bri_file || DEFAULT_SYS_MAX_BRI_FILE
|
||||
_sleepTime = cfg.sleep_time || ''
|
||||
}
|
||||
|
||||
function invalidatePaths() {
|
||||
_nowBriFile = null
|
||||
_sysMaxBriFile = null
|
||||
_sleepTime = null
|
||||
}
|
||||
|
||||
async function load(forceFull = false) {
|
||||
await _ensurePaths()
|
||||
|
||||
const needBri = forceFull || currentBri.value === null || sysMaxBri.value === null
|
||||
|
||||
// 所有 Shell 命令一次并发,消除多轮顺序等待
|
||||
// PID + 进程状态合并为一条命令以减少 exec 次数
|
||||
const [pidStateRes, stopRes, hdrRes, cBriRes, sBriRes] = await Promise.all([
|
||||
runCmd(
|
||||
`PID=$(cat "${PID_FILE}" 2>/dev/null || true); printf '%s\\n' "$PID"; [ -n "$PID" ] && grep '^State:' "/proc/$PID/status" 2>/dev/null | awk '{print $2}' || true`,
|
||||
),
|
||||
runCmd(`[ -f "${STOP_FLAG_FILE}" ] && echo "1" || echo "0"`),
|
||||
runCmd(
|
||||
`dumpsys display 2>/dev/null | sed -n 's/.*hdrSdrRatio \\([0-9.]*\\).*/\\1/p' | head -n 1`,
|
||||
),
|
||||
needBri ? runCmd(`cat "${_nowBriFile}"`) : Promise.resolve({ errno: -1, stdout: '' }),
|
||||
needBri ? runCmd(`cat "${_sysMaxBriFile}"`) : Promise.resolve({ errno: -1, stdout: '' }),
|
||||
])
|
||||
|
||||
if (needBri) {
|
||||
currentBri.value = cBriRes.errno === 0 ? cBriRes.stdout.trim() : '0'
|
||||
sysMaxBri.value = sBriRes.errno === 0 ? sBriRes.stdout.trim() : '255'
|
||||
async function load({ display = true } = {}) {
|
||||
try {
|
||||
const next = await fetchStatus({ display })
|
||||
// --no-display 时后端不返回 display 字段,沿用上一次的结果避免界面闪烁
|
||||
if (!display && !next.display && status.value?.display) {
|
||||
next.display = status.value.display
|
||||
}
|
||||
status.value = next
|
||||
error.value = ''
|
||||
} catch (e) {
|
||||
error.value = e.message
|
||||
}
|
||||
|
||||
const psLines = (pidStateRes.errno === 0 ? pidStateRes.stdout : '').split('\n')
|
||||
const pidStr = psLines[0]?.trim() || ''
|
||||
const stateChar = psLines[1]?.trim() || ''
|
||||
|
||||
isPaused.value = stopRes.errno === 0 && stopRes.stdout.trim() === '1'
|
||||
isRunning.value = !isPaused.value && !!pidStr
|
||||
inotifydPid.value = pidStr || '离线'
|
||||
inotifydState.value = isRunning.value ? stateChar || '已退出' : '离线'
|
||||
|
||||
const hdrRaw = hdrRes.errno === 0 ? hdrRes.stdout.trim() : ''
|
||||
hdrRatio.value = hdrRaw && /^\d+(\.\d+)?$/.test(hdrRaw) ? parseFloat(hdrRaw).toFixed(2) : '-'
|
||||
|
||||
sleepStatus.value = _calcSleep(_sleepTime)
|
||||
}
|
||||
|
||||
function _calcSleep(sleepTime) {
|
||||
if (!sleepTime || !sleepTime.includes('-')) return '非休眠'
|
||||
const [s, e] = sleepTime.split('-')
|
||||
if (s.length !== 4 || e.length !== 4) return '非休眠'
|
||||
const now = new Date()
|
||||
const nV = now.getHours() * 100 + now.getMinutes()
|
||||
const sNum = parseInt(s.slice(0, 2), 10) * 100 + parseInt(s.slice(2), 10)
|
||||
const eNum = parseInt(e.slice(0, 2), 10) * 100 + parseInt(e.slice(2), 10)
|
||||
if (sNum > eNum) {
|
||||
return nV >= sNum || nV < eNum ? '休眠中' : '非休眠'
|
||||
async function refreshOplock() {
|
||||
try {
|
||||
oplock.value = await fetchOplock()
|
||||
} catch {
|
||||
/* 忽略:下次轮询会重试 */
|
||||
}
|
||||
return nV >= sNum && nV < eNum ? '休眠中' : '非休眠'
|
||||
}
|
||||
|
||||
async function toggleService(toast) {
|
||||
const res = await runCmd(`sh /data/adb/modules/LuminPro/action.sh`)
|
||||
toast(res.errno === 0 ? res.stdout.trim() || '状态已切换' : '操作失败: ' + res.stderr)
|
||||
await load(true)
|
||||
async function setBrightness(value) {
|
||||
await apiSetBrightness(value)
|
||||
await load({ display: false })
|
||||
}
|
||||
|
||||
async function restartService(toast) {
|
||||
toast('正在重启模块...')
|
||||
const res = await runCmd(`sh /data/adb/modules/LuminPro/script/restart.sh`)
|
||||
setTimeout(async () => {
|
||||
await load(true)
|
||||
}, 1000)
|
||||
toast(res.errno === 0 ? '模块重启成功' : '模块重启失败: ' + res.stderr)
|
||||
async function toggleService(snackbar) {
|
||||
const res = await apiToggleService()
|
||||
snackbar?.(res.ok ? res.stdout.trim() || '状态已切换' : '操作失败: ' + res.stderr)
|
||||
await load({ display: false })
|
||||
}
|
||||
|
||||
async function setBrightness(newBri, toast) {
|
||||
currentBri.value = String(newBri)
|
||||
const cmd = `echo -n '${newBri}' > '${_nowBriFile}' 2>/dev/null && echo 'OK'`
|
||||
const res = await runCmd(cmd)
|
||||
if (!(res.errno === 0 && res.stdout.includes('OK'))) {
|
||||
toast('亮度设置失败,已恢复')
|
||||
await load(true)
|
||||
}
|
||||
async function boost(snackbar) {
|
||||
const res = await apiBoost()
|
||||
snackbar?.(res.ok ? '已切换峰值亮度' : '操作失败: ' + res.stderr)
|
||||
await load({ display: false })
|
||||
}
|
||||
|
||||
async function restart(snackbar) {
|
||||
const res = await apiRestart()
|
||||
snackbar?.(res.ok ? '模块已重启' : '模块重启失败: ' + res.stderr)
|
||||
setTimeout(() => load({ display: false }), 600)
|
||||
}
|
||||
|
||||
return {
|
||||
currentBri,
|
||||
sysMaxBri,
|
||||
inotifydPid,
|
||||
inotifydState,
|
||||
status,
|
||||
oplock,
|
||||
error,
|
||||
moduleInfo,
|
||||
daemon,
|
||||
brightness,
|
||||
display,
|
||||
sleep,
|
||||
cfg,
|
||||
isRunning,
|
||||
isPaused,
|
||||
statusClass,
|
||||
statusText,
|
||||
hdrRatio,
|
||||
sleepStatus,
|
||||
statusClass,
|
||||
sleepText,
|
||||
hdrText,
|
||||
load,
|
||||
invalidatePaths,
|
||||
toggleService,
|
||||
restartService,
|
||||
refreshOplock,
|
||||
setBrightness,
|
||||
toggleService,
|
||||
boost,
|
||||
restart,
|
||||
}
|
||||
}
|
||||
@@ -1,220 +0,0 @@
|
||||
/* Header */
|
||||
.app-header {
|
||||
position: absolute;
|
||||
top: var(--oplock-offset, 0);
|
||||
left: 0;
|
||||
right: 0;
|
||||
z-index: 10;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
padding: 25px 25px;
|
||||
transition: transform 0.35s cubic-bezier(0.25, 1, 0.5, 1);
|
||||
will-change: transform;
|
||||
}
|
||||
|
||||
.header-content {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 16px;
|
||||
flex: 1;
|
||||
}
|
||||
|
||||
.header-icon {
|
||||
font-size: 2.5rem;
|
||||
background: linear-gradient(
|
||||
135deg,
|
||||
var(--md-sys-color-primary-container),
|
||||
var(--md-sys-color-secondary-container)
|
||||
);
|
||||
width: 56px;
|
||||
height: 56px;
|
||||
border-radius: 12px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.12);
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.header-text {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 2px;
|
||||
}
|
||||
|
||||
.header-text h1 {
|
||||
margin: 0;
|
||||
font-size: 1.5rem;
|
||||
font-weight: 700;
|
||||
color: var(--md-sys-color-on-background);
|
||||
letter-spacing: -0.3px;
|
||||
}
|
||||
|
||||
.header-subtitle {
|
||||
margin: 0;
|
||||
font-size: 0.9rem;
|
||||
color: var(--md-sys-color-on-surface-variant);
|
||||
font-weight: 400;
|
||||
}
|
||||
|
||||
.header-version {
|
||||
margin: 0;
|
||||
font-size: 0.75rem;
|
||||
color: var(--md-sys-color-primary);
|
||||
font-weight: 600;
|
||||
letter-spacing: 0.5px;
|
||||
text-transform: uppercase;
|
||||
}
|
||||
|
||||
/* 版本通道徽标 (Beta / Dev) */
|
||||
.version-channel {
|
||||
display: inline-block;
|
||||
margin-left: 6px;
|
||||
padding: 1px 6px;
|
||||
border-radius: 999px;
|
||||
font-size: 0.6875rem;
|
||||
font-weight: 700;
|
||||
color: var(--color-warning);
|
||||
background: color-mix(in srgb, var(--color-warning) 18%, transparent);
|
||||
vertical-align: middle;
|
||||
}
|
||||
|
||||
.header-status-container {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: flex-end;
|
||||
gap: 12px;
|
||||
}
|
||||
|
||||
.header-status {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
background: var(--md-sys-color-surface-container-high);
|
||||
padding: 8px 16px;
|
||||
border-radius: 12px;
|
||||
font-size: 0.8125rem;
|
||||
color: var(--md-sys-color-on-surface);
|
||||
font-weight: 500;
|
||||
box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08);
|
||||
border: 1px solid rgba(var(--md-sys-color-on-surface-rgb, 0, 0, 0), 0.08);
|
||||
}
|
||||
|
||||
.header-status-actions {
|
||||
display: flex;
|
||||
gap: 16px;
|
||||
}
|
||||
|
||||
.btn-status-action {
|
||||
background: transparent;
|
||||
border: none;
|
||||
color: var(--md-sys-color-primary);
|
||||
font-size: 0.8125rem;
|
||||
font-weight: 600;
|
||||
cursor: pointer;
|
||||
padding: 2px 4px;
|
||||
border-radius: 4px;
|
||||
transition: all 0.2s;
|
||||
opacity: 0.9;
|
||||
}
|
||||
|
||||
.btn-status-action:active {
|
||||
background-color: var(--md-sys-color-primary-container);
|
||||
opacity: 1;
|
||||
}
|
||||
|
||||
.btn-status-action:disabled {
|
||||
opacity: 0.4;
|
||||
cursor: not-allowed;
|
||||
pointer-events: none;
|
||||
}
|
||||
|
||||
/* 操作锁横幅 */
|
||||
.oplock-banner {
|
||||
position: fixed;
|
||||
top: var(--safe-area-inset-top, 0px);
|
||||
left: 0;
|
||||
right: 0;
|
||||
z-index: 20;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
gap: 8px;
|
||||
padding: 8px 16px;
|
||||
font-size: 0.8125rem;
|
||||
font-weight: 500;
|
||||
color: var(--md-sys-color-on-surface);
|
||||
background: var(--md-sys-color-surface-container-high);
|
||||
border-bottom: 1px solid var(--md-sys-color-outline-variant);
|
||||
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.12);
|
||||
}
|
||||
|
||||
.oplock-spinner {
|
||||
width: 14px;
|
||||
height: 14px;
|
||||
flex-shrink: 0;
|
||||
border: 2px solid var(--md-sys-color-primary);
|
||||
border-top-color: transparent;
|
||||
border-radius: 50%;
|
||||
animation: oplock-spin 0.8s linear infinite;
|
||||
}
|
||||
|
||||
@keyframes oplock-spin {
|
||||
to {
|
||||
transform: rotate(360deg);
|
||||
}
|
||||
}
|
||||
|
||||
.oplock-fade-enter-active,
|
||||
.oplock-fade-leave-active {
|
||||
transition:
|
||||
opacity 0.2s,
|
||||
transform 0.2s;
|
||||
}
|
||||
|
||||
.oplock-fade-enter-from,
|
||||
.oplock-fade-leave-to {
|
||||
opacity: 0;
|
||||
transform: translateY(-100%);
|
||||
}
|
||||
|
||||
.status-dot {
|
||||
width: 10px;
|
||||
height: 10px;
|
||||
border-radius: 50%;
|
||||
background-color: var(--md-sys-color-error);
|
||||
box-shadow: 0 0 8px rgba(244, 67, 54, 0.5);
|
||||
animation: status-pulse 2s infinite;
|
||||
}
|
||||
|
||||
@keyframes status-pulse {
|
||||
0%,
|
||||
100% {
|
||||
box-shadow: 0 0 8px rgba(244, 67, 54, 0.5);
|
||||
}
|
||||
50% {
|
||||
box-shadow: 0 0 12px rgba(244, 67, 54, 0.8);
|
||||
}
|
||||
}
|
||||
|
||||
@keyframes status-pulse-green {
|
||||
0%,
|
||||
100% {
|
||||
box-shadow: 0 0 8px rgba(76, 175, 80, 0.6);
|
||||
}
|
||||
50% {
|
||||
box-shadow: 0 0 12px rgba(76, 175, 80, 0.8);
|
||||
}
|
||||
}
|
||||
|
||||
.header-status.status-running .status-dot {
|
||||
background-color: #4caf50;
|
||||
box-shadow: 0 0 8px rgba(76, 175, 80, 0.6);
|
||||
animation: status-pulse-green 2s infinite;
|
||||
}
|
||||
|
||||
.header-status.status-paused .status-dot,
|
||||
.header-status.status-loading .status-dot {
|
||||
animation: status-pulse 2s infinite;
|
||||
}
|
||||
@@ -1,175 +0,0 @@
|
||||
@import 'tailwindcss';
|
||||
@import 'tw-animate-css';
|
||||
|
||||
@custom-variant dark (&:is(.dark *));
|
||||
|
||||
@theme inline {
|
||||
--color-background: var(--background);
|
||||
--color-foreground: var(--foreground);
|
||||
--color-card: var(--card);
|
||||
--color-card-foreground: var(--card-foreground);
|
||||
--color-popover: var(--popover);
|
||||
--color-popover-foreground: var(--popover-foreground);
|
||||
--color-primary: var(--primary);
|
||||
--color-primary-foreground: var(--primary-foreground);
|
||||
--color-secondary: var(--secondary);
|
||||
--color-secondary-foreground: var(--secondary-foreground);
|
||||
--color-muted: var(--muted);
|
||||
--color-muted-foreground: var(--muted-foreground);
|
||||
--color-accent: var(--accent);
|
||||
--color-accent-foreground: var(--accent-foreground);
|
||||
--color-destructive: var(--destructive);
|
||||
--color-border: var(--border);
|
||||
--color-input: var(--input);
|
||||
--color-ring: var(--ring);
|
||||
--radius-sm: calc(var(--radius) - 4px);
|
||||
--radius-md: calc(var(--radius) - 2px);
|
||||
--radius-lg: var(--radius);
|
||||
--radius-xl: calc(var(--radius) + 4px);
|
||||
--font-sans: Geist, system-ui, -apple-system, sans-serif;
|
||||
--font-mono: 'Geist Mono', 'Roboto Mono', monospace;
|
||||
}
|
||||
|
||||
/* ===============================
|
||||
Shadcn 主题 Token (暗色, MD3 调色板)
|
||||
=============================== */
|
||||
:root,
|
||||
:root.dark {
|
||||
--radius: 0.75rem;
|
||||
|
||||
/* Shadcn tokens */
|
||||
--background: #111318;
|
||||
--foreground: #e2e2e9;
|
||||
--card: #1e1f25;
|
||||
--card-foreground: #e2e2e9;
|
||||
--popover: #2b2930;
|
||||
--popover-foreground: #e2e2e9;
|
||||
--primary: #a8c7fa;
|
||||
--primary-foreground: #062e6f;
|
||||
--secondary: #2b2930;
|
||||
--secondary-foreground: #e2e2e9;
|
||||
--muted: #212429;
|
||||
--muted-foreground: #c4c6d0;
|
||||
--accent: #1b4b9b;
|
||||
--accent-foreground: #d3e3fd;
|
||||
--destructive: #ffb4ab;
|
||||
--border: #44474f;
|
||||
--input: #44474f;
|
||||
--ring: rgba(168, 199, 250, 0.5);
|
||||
|
||||
/* MD3 tokens (保留,legacy CSS 仍在使用) */
|
||||
--md-sys-color-background: #111318;
|
||||
--md-sys-color-background-rgb: 17, 19, 24;
|
||||
--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-surface-container-high-rgb: 43, 41, 48;
|
||||
--md-sys-color-on-surface: #e2e2e9;
|
||||
--md-sys-color-on-surface-variant: #c4c6d0;
|
||||
--md-sys-color-primary: #a8c7fa;
|
||||
--md-sys-color-primary-rgb: 168, 199, 250;
|
||||
--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;
|
||||
--md-sys-color-error-container: #93000a;
|
||||
--border-radius-m: 16px;
|
||||
--border-radius-s: 8px;
|
||||
--spacing-s: 8px;
|
||||
--spacing-m: 16px;
|
||||
--spacing-l: 24px;
|
||||
--color-warning: #f59e0b;
|
||||
}
|
||||
|
||||
/* ===============================
|
||||
浅色主题 Token
|
||||
=============================== */
|
||||
@media (prefers-color-scheme: light) {
|
||||
:root:not(.dark) {
|
||||
--background: #f8f9fc;
|
||||
--foreground: #191c20;
|
||||
--card: #ffffff;
|
||||
--card-foreground: #191c20;
|
||||
--popover: #ffffff;
|
||||
--popover-foreground: #191c20;
|
||||
--primary: #0b57d0;
|
||||
--primary-foreground: #ffffff;
|
||||
--secondary: #e8eaf0;
|
||||
--secondary-foreground: #191c20;
|
||||
--muted: #eff1f6;
|
||||
--muted-foreground: #44474f;
|
||||
--accent: #d3e3fd;
|
||||
--accent-foreground: #062e6f;
|
||||
--destructive: #b3261e;
|
||||
--border: #c4c7d0;
|
||||
--input: #c4c7d0;
|
||||
--ring: rgba(11, 87, 208, 0.3);
|
||||
/* MD3 */
|
||||
--md-sys-color-background: #f8f9fc;
|
||||
--md-sys-color-background-rgb: 248, 249, 252;
|
||||
--md-sys-color-on-background: #191c20;
|
||||
--md-sys-color-surface: #ffffff;
|
||||
--md-sys-color-surface-container: #eff1f6;
|
||||
--md-sys-color-surface-container-high: #e8eaf0;
|
||||
--md-sys-color-surface-container-high-rgb: 232, 234, 240;
|
||||
--md-sys-color-on-surface: #191c20;
|
||||
--md-sys-color-on-surface-variant: #44474f;
|
||||
--md-sys-color-primary: #0b57d0;
|
||||
--md-sys-color-primary-rgb: 11, 87, 208;
|
||||
--md-sys-color-on-primary: #ffffff;
|
||||
--md-sys-color-primary-container: #d3e3fd;
|
||||
--md-sys-color-on-primary-container: #062e6f;
|
||||
--md-sys-color-outline: #74777f;
|
||||
--md-sys-color-outline-variant: #c4c7d0;
|
||||
--md-sys-color-error: #b3261e;
|
||||
--md-sys-color-on-error: #ffffff;
|
||||
--md-sys-color-error-container: #f9dedc;
|
||||
--color-warning: #b45309;
|
||||
}
|
||||
}
|
||||
|
||||
:root.light {
|
||||
--background: #f8f9fc;
|
||||
--foreground: #191c20;
|
||||
--card: #ffffff;
|
||||
--card-foreground: #191c20;
|
||||
--popover: #ffffff;
|
||||
--popover-foreground: #191c20;
|
||||
--primary: #0b57d0;
|
||||
--primary-foreground: #ffffff;
|
||||
--secondary: #e8eaf0;
|
||||
--secondary-foreground: #191c20;
|
||||
--muted: #eff1f6;
|
||||
--muted-foreground: #44474f;
|
||||
--accent: #d3e3fd;
|
||||
--accent-foreground: #062e6f;
|
||||
--destructive: #b3261e;
|
||||
--border: #c4c7d0;
|
||||
--input: #c4c7d0;
|
||||
--ring: rgba(11, 87, 208, 0.3);
|
||||
/* MD3 */
|
||||
--md-sys-color-background: #f8f9fc;
|
||||
--md-sys-color-background-rgb: 248, 249, 252;
|
||||
--md-sys-color-on-background: #191c20;
|
||||
--md-sys-color-surface: #ffffff;
|
||||
--md-sys-color-surface-container: #eff1f6;
|
||||
--md-sys-color-surface-container-high: #e8eaf0;
|
||||
--md-sys-color-surface-container-high-rgb: 232, 234, 240;
|
||||
--md-sys-color-on-surface: #191c20;
|
||||
--md-sys-color-on-surface-variant: #44474f;
|
||||
--md-sys-color-primary: #0b57d0;
|
||||
--md-sys-color-primary-rgb: 11, 87, 208;
|
||||
--md-sys-color-on-primary: #ffffff;
|
||||
--md-sys-color-primary-container: #d3e3fd;
|
||||
--md-sys-color-on-primary-container: #062e6f;
|
||||
--md-sys-color-outline: #74777f;
|
||||
--md-sys-color-outline-variant: #c4c7d0;
|
||||
--md-sys-color-error: #b3261e;
|
||||
--md-sys-color-on-error: #ffffff;
|
||||
--md-sys-color-error-container: #f9dedc;
|
||||
--color-warning: #b45309;
|
||||
}
|
||||
@@ -1,6 +0,0 @@
|
||||
import { clsx } from 'clsx'
|
||||
import { twMerge } from 'tailwind-merge'
|
||||
|
||||
export function cn(...inputs) {
|
||||
return twMerge(clsx(inputs))
|
||||
}
|
||||
@@ -1,265 +0,0 @@
|
||||
/* Logs */
|
||||
.log-output {
|
||||
font-family: 'Geist Mono', 'JetBrains Mono', 'Consolas', monospace;
|
||||
font-size: 0.6875rem;
|
||||
padding: var(--spacing-m);
|
||||
background-color: #0d0e12;
|
||||
color: #e3e3e3;
|
||||
border-radius: var(--border-radius-m);
|
||||
border: 1px solid rgba(255, 255, 255, 0.05);
|
||||
flex: 1;
|
||||
max-height: 60vh;
|
||||
overflow-y: auto;
|
||||
margin: 0;
|
||||
white-space: pre-wrap;
|
||||
word-wrap: break-word;
|
||||
line-height: 1.5;
|
||||
scrollbar-width: thin;
|
||||
scrollbar-color: var(--md-sys-color-outline-variant) transparent;
|
||||
}
|
||||
|
||||
.log-output::-webkit-scrollbar {
|
||||
width: 4px;
|
||||
}
|
||||
|
||||
.log-output::-webkit-scrollbar-thumb {
|
||||
background-color: var(--md-sys-color-outline-variant);
|
||||
border-radius: 4px;
|
||||
}
|
||||
|
||||
.log-filter-select {
|
||||
padding: 0 12px;
|
||||
border: 1px solid var(--md-sys-color-outline-variant);
|
||||
border-radius: 8px;
|
||||
background-color: var(--md-sys-color-surface-container-high);
|
||||
color: var(--md-sys-color-on-surface);
|
||||
font-family: inherit;
|
||||
font-size: 0.8125rem;
|
||||
height: 32px;
|
||||
cursor: pointer;
|
||||
outline: none;
|
||||
transition: all 0.22s ease;
|
||||
}
|
||||
|
||||
.log-filter-select:focus {
|
||||
border-color: var(--md-sys-color-primary);
|
||||
box-shadow: 0 0 0 2px rgba(var(--md-sys-color-primary-rgb), 0.2);
|
||||
}
|
||||
|
||||
.log-output::-webkit-scrollbar {
|
||||
display: none; /* Chrome, Safari */
|
||||
}
|
||||
|
||||
/* Simple Toast */
|
||||
.top-blur {
|
||||
position: fixed;
|
||||
top: 0;
|
||||
left: 0;
|
||||
right: 0;
|
||||
height: calc(85px + var(--safe-area-inset-top, 0px));
|
||||
z-index: 998;
|
||||
pointer-events: none;
|
||||
/* 基础暗色背景,增强状态栏文字可读性 */
|
||||
background: linear-gradient(
|
||||
to bottom,
|
||||
rgba(var(--md-sys-color-background-rgb, 17, 19, 24), 0.85) 0%,
|
||||
rgba(var(--md-sys-color-background-rgb, 17, 19, 24), 0.4) 40%,
|
||||
rgba(var(--md-sys-color-background-rgb, 17, 19, 24), 0) 100%
|
||||
);
|
||||
/* 核心:毛玻璃滤镜 */
|
||||
-webkit-backdrop-filter: blur(16px);
|
||||
backdrop-filter: blur(16px);
|
||||
/* 梯度蒙版:越往上越模糊的核心逻辑 */
|
||||
-webkit-mask-image: linear-gradient(
|
||||
to bottom,
|
||||
rgba(0, 0, 0, 1) 0%,
|
||||
rgba(0, 0, 0, 1) 30%,
|
||||
rgba(0, 0, 0, 0.7) 60%,
|
||||
rgba(0, 0, 0, 0) 100%
|
||||
);
|
||||
mask-image: linear-gradient(
|
||||
to bottom,
|
||||
rgba(0, 0, 0, 1) 0%,
|
||||
rgba(0, 0, 0, 1) 30%,
|
||||
rgba(0, 0, 0, 0.7) 60%,
|
||||
rgba(0, 0, 0, 0) 100%
|
||||
);
|
||||
transform: translateZ(0); /* 开启 GPU 加速 */
|
||||
opacity: 0;
|
||||
transition: opacity 0.3s ease;
|
||||
}
|
||||
|
||||
.top-blur.scrolled {
|
||||
opacity: 1;
|
||||
}
|
||||
|
||||
.toast {
|
||||
position: fixed;
|
||||
bottom: 24px;
|
||||
left: 50%;
|
||||
transform: translateX(-50%) translateY(100px);
|
||||
background-color: var(--md-sys-color-on-surface);
|
||||
color: var(--md-sys-color-surface);
|
||||
padding: 12px 24px;
|
||||
border-radius: var(--border-radius-s);
|
||||
font-size: 0.875rem;
|
||||
box-shadow: 0 2px 5px rgba(0, 0, 0, 0.4);
|
||||
transition: transform 0.3s cubic-bezier(0.18, 0.89, 0.32, 1.28);
|
||||
z-index: 1000;
|
||||
width: max-content;
|
||||
max-width: 90vw;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.toast.show {
|
||||
transform: translateX(-50%) translateY(0);
|
||||
}
|
||||
|
||||
/* Floating Navigation Bar */
|
||||
.floating-navbar {
|
||||
position: fixed;
|
||||
bottom: calc(18px + var(--safe-area-inset-bottom, 0px));
|
||||
left: 50%;
|
||||
transform: translateX(-50%) translateZ(0);
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
background: rgba(var(--md-sys-color-surface-container-high-rgb, 43, 41, 48), 0.75);
|
||||
-webkit-backdrop-filter: blur(12px);
|
||||
backdrop-filter: blur(12px);
|
||||
will-change: transform;
|
||||
padding: 8px 16px;
|
||||
border-radius: 28px;
|
||||
border: 1px solid rgba(255, 255, 255, 0.08);
|
||||
box-shadow:
|
||||
0 4px 12px rgba(0, 0, 0, 0.15),
|
||||
0 8px 32px rgba(0, 0, 0, 0.3);
|
||||
z-index: 999;
|
||||
width: fit-content;
|
||||
max-width: calc(100% - 32px);
|
||||
user-select: none;
|
||||
-webkit-user-select: none;
|
||||
-webkit-tap-highlight-color: transparent;
|
||||
touch-action: none;
|
||||
}
|
||||
|
||||
.navbar-slider {
|
||||
position: absolute;
|
||||
left: 0;
|
||||
top: 8px;
|
||||
bottom: 8px;
|
||||
height: auto;
|
||||
background: var(--md-sys-color-primary-container);
|
||||
border-radius: 20px;
|
||||
will-change: transform, width;
|
||||
pointer-events: none;
|
||||
z-index: 0;
|
||||
}
|
||||
|
||||
.navbar-btn {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
gap: 5px;
|
||||
padding: 6px 12px;
|
||||
background-color: transparent;
|
||||
border: none;
|
||||
color: var(--md-sys-color-on-surface-variant);
|
||||
font-size: 0.75rem;
|
||||
cursor: pointer;
|
||||
border-radius: 8px;
|
||||
transition: all 0.2s ease;
|
||||
flex: 1;
|
||||
max-width: 90px;
|
||||
white-space: nowrap;
|
||||
position: relative;
|
||||
z-index: 1;
|
||||
}
|
||||
|
||||
.navbar-btn i,
|
||||
.navbar-btn svg {
|
||||
width: 20px;
|
||||
height: 20px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
.navbar-btn span {
|
||||
font-size: 0.75rem;
|
||||
}
|
||||
|
||||
.navbar-btn:active {
|
||||
/* No scaling here, we rely on the slider feedback */
|
||||
}
|
||||
|
||||
.navbar-btn.active {
|
||||
color: var(--md-sys-color-on-primary-container);
|
||||
}
|
||||
|
||||
/* Dropdown Menu */
|
||||
.dropdown-container {
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.dropdown-menu {
|
||||
position: absolute;
|
||||
top: 100%;
|
||||
right: 0;
|
||||
margin-top: 8px;
|
||||
background-color: var(--md-sys-color-surface-container-high);
|
||||
border: 1px solid var(--md-sys-color-outline-variant);
|
||||
border-radius: var(--border-radius-s);
|
||||
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
|
||||
min-width: 160px;
|
||||
opacity: 0;
|
||||
visibility: hidden;
|
||||
transform: translateY(-8px);
|
||||
transition: all 0.2s cubic-bezier(0.18, 0.89, 0.32, 1.28);
|
||||
z-index: 100;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
padding: 4px;
|
||||
}
|
||||
|
||||
.dropdown-menu.show {
|
||||
opacity: 1;
|
||||
visibility: visible;
|
||||
transform: translateY(0);
|
||||
}
|
||||
|
||||
.dropdown-item {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 12px;
|
||||
padding: 10px 12px;
|
||||
border-radius: 4px;
|
||||
cursor: pointer;
|
||||
color: var(--md-sys-color-on-surface);
|
||||
font-size: 0.875rem;
|
||||
transition: background-color 0.2s;
|
||||
}
|
||||
|
||||
.dropdown-item:hover {
|
||||
background-color: var(--md-sys-color-surface-container);
|
||||
}
|
||||
|
||||
.dropdown-item:active {
|
||||
background-color: var(--md-sys-color-surface);
|
||||
}
|
||||
|
||||
.dropdown-item svg {
|
||||
color: var(--md-sys-color-primary);
|
||||
width: 18px;
|
||||
height: 18px;
|
||||
}
|
||||
|
||||
.dropdown-item-danger {
|
||||
color: var(--md-sys-color-error, #cf6679);
|
||||
}
|
||||
|
||||
.dropdown-item-danger svg {
|
||||
color: var(--md-sys-color-error, #cf6679);
|
||||
}
|
||||
+10
-8
@@ -1,11 +1,13 @@
|
||||
import { createApp } from 'vue'
|
||||
import App from './App.vue'
|
||||
import './index.css'
|
||||
import './style.css'
|
||||
import './header.css'
|
||||
import './components.css'
|
||||
import './about.css'
|
||||
import './apps.css'
|
||||
import './log.css'
|
||||
import { applyEdgeToEdge } from './api/ksu.js'
|
||||
import './mwc.js'
|
||||
|
||||
import './theme/tokens.css'
|
||||
import './theme/base.css'
|
||||
import './theme/components.css'
|
||||
import './theme/app.css'
|
||||
|
||||
import App from './App.vue'
|
||||
|
||||
applyEdgeToEdge()
|
||||
createApp(App).mount('#app')
|
||||
@@ -0,0 +1,31 @@
|
||||
// @material/web 组件的唯一引入入口:只 import 本项目实际用到的组件,避免打包体积膨胀。
|
||||
// 说明:Material Web Components 官方处于维护模式,不包含 M3 Expressive 的动效;
|
||||
// 导航栏(navigationbar/navigationtab)位于 labs/ 目录。
|
||||
|
||||
// 按钮与图标按钮
|
||||
import '@material/web/button/filled-button.js'
|
||||
import '@material/web/button/outlined-button.js'
|
||||
import '@material/web/button/text-button.js'
|
||||
import '@material/web/iconbutton/icon-button.js'
|
||||
|
||||
// 输入类
|
||||
import '@material/web/textfield/outlined-text-field.js'
|
||||
import '@material/web/select/outlined-select.js'
|
||||
import '@material/web/select/select-option.js'
|
||||
import '@material/web/switch/switch.js'
|
||||
import '@material/web/slider/slider.js'
|
||||
import '@material/web/checkbox/checkbox.js'
|
||||
|
||||
// 容器与浮层
|
||||
import '@material/web/dialog/dialog.js'
|
||||
import '@material/web/menu/menu.js'
|
||||
import '@material/web/menu/menu-item.js'
|
||||
import '@material/web/divider/divider.js'
|
||||
|
||||
// 反馈
|
||||
import '@material/web/chips/chip-set.js'
|
||||
import '@material/web/chips/filter-chip.js'
|
||||
|
||||
// 导航(labs)
|
||||
import '@material/web/labs/navigationbar/navigation-bar.js'
|
||||
import '@material/web/labs/navigationtab/navigation-tab.js'
|
||||
@@ -1,131 +0,0 @@
|
||||
:root,
|
||||
:root.dark {
|
||||
--md-sys-color-background: #111318;
|
||||
--md-sys-color-background-rgb: 17, 19, 24;
|
||||
--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-surface-container-high-rgb: 43, 41, 48;
|
||||
--md-sys-color-on-surface: #e2e2e9;
|
||||
--md-sys-color-on-surface-variant: #c4c6d0;
|
||||
--md-sys-color-primary: #a8c7fa;
|
||||
--md-sys-color-primary-rgb: 168, 199, 250;
|
||||
--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[wght].woff2') format('woff2');
|
||||
font-weight: 100 900;
|
||||
font-style: normal;
|
||||
}
|
||||
|
||||
@font-face {
|
||||
font-family: 'Geist Mono';
|
||||
src: url('/GeistMono[wght].woff2') format('woff2');
|
||||
font-weight: 100 900;
|
||||
font-style: normal;
|
||||
}
|
||||
|
||||
* {
|
||||
box-sizing: border-box;
|
||||
-webkit-tap-highlight-color: transparent;
|
||||
}
|
||||
|
||||
/* 隐藏所有滚动条 */
|
||||
html {
|
||||
scrollbar-width: none; /* Firefox */
|
||||
-ms-overflow-style: none; /* IE/Edge */
|
||||
background-color: var(--md-sys-color-background);
|
||||
}
|
||||
|
||||
html::-webkit-scrollbar {
|
||||
display: none; /* Chrome, Safari */
|
||||
}
|
||||
|
||||
body {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
zoom: 0.95;
|
||||
/* insets 会在这里被 internal/insets.css 处理,我们预留顶底内边距 */
|
||||
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);
|
||||
font-family:
|
||||
'Geist',
|
||||
system-ui,
|
||||
-apple-system,
|
||||
sans-serif;
|
||||
line-height: 1.5;
|
||||
scrollbar-width: none; /* Firefox */
|
||||
-ms-overflow-style: none; /* IE/Edge */
|
||||
}
|
||||
|
||||
body::-webkit-scrollbar {
|
||||
display: none; /* Chrome, Safari */
|
||||
}
|
||||
|
||||
#app {
|
||||
position: relative;
|
||||
padding: 0;
|
||||
max-width: 600px;
|
||||
margin: 0 auto;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
height: calc(100dvh / 0.95);
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
/* header 自动隐藏 */
|
||||
#app.header-hidden .app-header {
|
||||
transform: translateY(-100%);
|
||||
}
|
||||
|
||||
/* 滑动页面轨道 */
|
||||
.page-viewport {
|
||||
flex: 1;
|
||||
min-height: 0;
|
||||
overflow: hidden;
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.page-track {
|
||||
display: flex;
|
||||
height: 100%;
|
||||
transition: transform 0.38s cubic-bezier(0.25, 1, 0.5, 1);
|
||||
will-change: transform;
|
||||
}
|
||||
|
||||
.page-slide {
|
||||
width: 100%;
|
||||
flex-shrink: 0;
|
||||
height: 100%;
|
||||
overflow-y: auto;
|
||||
overflow-x: hidden;
|
||||
padding: 12px;
|
||||
padding-top: calc(var(--header-height, 120px) + var(--oplock-offset, 0px));
|
||||
padding-bottom: calc(16px + 80px + var(--safe-area-inset-bottom, 0px));
|
||||
scrollbar-width: none;
|
||||
-ms-overflow-style: none;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: var(--spacing-m);
|
||||
}
|
||||
|
||||
.page-slide::-webkit-scrollbar {
|
||||
display: none;
|
||||
}
|
||||
@@ -0,0 +1,271 @@
|
||||
/* ==========================================================================
|
||||
应用外壳:顶栏 / 页面滑动轨 / M3 导航栏 / 操作锁横幅 / snackbar
|
||||
========================================================================== */
|
||||
|
||||
#app {
|
||||
position: relative;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
max-width: 600px;
|
||||
margin: 0 auto;
|
||||
height: calc(100dvh / 0.95);
|
||||
overflow: hidden;
|
||||
background-color: var(--md-sys-color-background);
|
||||
}
|
||||
|
||||
/* ── M3 small top app bar ─────────────────────────────────────────── */
|
||||
.app-bar {
|
||||
position: relative;
|
||||
z-index: 3;
|
||||
flex: 0 0 auto;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: var(--md-sys-spacing-1);
|
||||
min-height: 64px;
|
||||
padding: calc(var(--md-sys-spacing-2) + var(--safe-area-inset-top, var(--window-inset-top, 0px)))
|
||||
var(--md-sys-spacing-1) var(--md-sys-spacing-2) var(--md-sys-spacing-4);
|
||||
background-color: var(--md-sys-color-background);
|
||||
transition: background-color var(--md-sys-motion-duration-medium2)
|
||||
var(--md-sys-motion-easing-standard);
|
||||
}
|
||||
|
||||
.app-bar.scrolled {
|
||||
background-color: var(--md-sys-color-surface-container);
|
||||
}
|
||||
|
||||
.app-bar__text {
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 2px;
|
||||
}
|
||||
|
||||
.app-bar__title {
|
||||
margin: 0;
|
||||
color: var(--md-sys-color-on-surface);
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: var(--md-sys-spacing-2);
|
||||
}
|
||||
|
||||
.app-bar__meta {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 6px;
|
||||
color: var(--md-sys-color-on-surface-variant);
|
||||
}
|
||||
|
||||
.status-dot {
|
||||
flex: 0 0 auto;
|
||||
width: 8px;
|
||||
height: 8px;
|
||||
border-radius: 50%;
|
||||
background-color: var(--md-sys-color-outline);
|
||||
}
|
||||
|
||||
.status-dot.running {
|
||||
background-color: var(--lp-color-success);
|
||||
animation: status-pulse 2.4s var(--md-sys-motion-easing-standard) infinite;
|
||||
}
|
||||
|
||||
.status-dot.paused {
|
||||
background-color: var(--lp-color-warning);
|
||||
}
|
||||
|
||||
.status-dot.stopped {
|
||||
background-color: var(--md-sys-color-error);
|
||||
animation: status-pulse 2s var(--md-sys-motion-easing-standard) infinite;
|
||||
}
|
||||
|
||||
/* 发布通道徽标(Beta / Dev) */
|
||||
.channel-badge {
|
||||
flex: 0 0 auto;
|
||||
padding: 2px 8px;
|
||||
border-radius: var(--md-sys-shape-corner-full);
|
||||
background-color: var(--lp-color-warning-container);
|
||||
color: var(--lp-color-warning);
|
||||
font-size: var(--md-sys-typescale-label-small-size);
|
||||
line-height: var(--md-sys-typescale-label-small-line-height);
|
||||
font-weight: 700;
|
||||
text-transform: uppercase;
|
||||
}
|
||||
|
||||
@keyframes status-pulse {
|
||||
0%,
|
||||
100% {
|
||||
opacity: 1;
|
||||
}
|
||||
50% {
|
||||
opacity: 0.45;
|
||||
}
|
||||
}
|
||||
|
||||
.app-bar__actions {
|
||||
flex: 0 0 auto;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 2px;
|
||||
}
|
||||
|
||||
/* ── 页面滑动轨 ───────────────────────────────────────────────────── */
|
||||
.page-viewport {
|
||||
flex: 1;
|
||||
min-height: 0;
|
||||
overflow: hidden;
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.page-track {
|
||||
display: flex;
|
||||
height: 100%;
|
||||
transition: transform var(--md-sys-motion-duration-medium4)
|
||||
var(--md-sys-motion-easing-emphasized);
|
||||
will-change: transform;
|
||||
}
|
||||
|
||||
.page-slide {
|
||||
flex: 0 0 100%;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
overflow-y: auto;
|
||||
overflow-x: hidden;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: var(--md-sys-spacing-3);
|
||||
padding: var(--md-sys-spacing-3) var(--md-sys-spacing-3) var(--md-sys-spacing-5);
|
||||
scrollbar-width: none;
|
||||
}
|
||||
|
||||
/* ── M3 导航栏 ────────────────────────────────────────────────────── */
|
||||
/* 底栏容器:色块填充法——容器背景延伸至屏幕最底部,手势导航条区域
|
||||
与导航栏同色;内边距把导航内容抬到手势条之上。
|
||||
安全区变量在不同 KernelSU 版本命名不同,最后兜底 env()。 */
|
||||
.bottom-nav {
|
||||
flex: 0 0 auto;
|
||||
background-color: var(--md-sys-color-surface-container);
|
||||
padding-bottom: var(--safe-area-inset-bottom, var(--window-inset-bottom, env(safe-area-inset-bottom, 0px)));
|
||||
}
|
||||
|
||||
md-navigation-bar {
|
||||
--md-navigation-bar-container-color: var(--md-sys-color-surface-container);
|
||||
/* 去掉容器阴影:手势条区域用同色填充,阴影会在底部露出一条边 */
|
||||
--md-navigation-bar-container-elevation: 0;
|
||||
box-shadow: none;
|
||||
--md-navigation-bar-active-indicator-color: var(--md-sys-color-secondary-container);
|
||||
--md-navigation-bar-active-icon-color: var(--md-sys-color-on-secondary-container);
|
||||
--md-navigation-bar-active-label-text-color: var(--md-sys-color-on-surface);
|
||||
--md-navigation-bar-inactive-icon-color: var(--md-sys-color-on-surface-variant);
|
||||
--md-navigation-bar-inactive-label-text-color: var(--md-sys-color-on-surface-variant);
|
||||
}
|
||||
|
||||
md-navigation-tab {
|
||||
--md-navigation-tab-active-indicator-shape: var(--md-sys-shape-corner-full);
|
||||
}
|
||||
|
||||
/* ── 操作锁横幅 ───────────────────────────────────────────────────── */
|
||||
.oplock-banner {
|
||||
/* 参与正常流(并排在顶栏之前):出现时把内容整体下推,而不是盖住顶栏 */
|
||||
order: -1;
|
||||
flex: 0 0 auto;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: var(--md-sys-spacing-2);
|
||||
padding: var(--md-sys-spacing-2) var(--md-sys-spacing-4);
|
||||
background-color: var(--md-sys-color-surface-container-highest);
|
||||
border-bottom: 1px solid var(--md-sys-color-outline-variant);
|
||||
color: var(--md-sys-color-on-surface);
|
||||
}
|
||||
|
||||
.oplock-banner__spinner {
|
||||
flex: 0 0 auto;
|
||||
width: 16px;
|
||||
height: 16px;
|
||||
border: 2px solid var(--md-sys-color-primary);
|
||||
border-top-color: transparent;
|
||||
border-radius: 50%;
|
||||
animation: oplock-spin 0.8s linear infinite;
|
||||
}
|
||||
|
||||
@keyframes oplock-spin {
|
||||
to {
|
||||
transform: rotate(360deg);
|
||||
}
|
||||
}
|
||||
|
||||
.oplock-banner__text {
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
font-size: var(--md-sys-typescale-title-small-size);
|
||||
line-height: var(--md-sys-typescale-title-small-line-height);
|
||||
font-weight: var(--md-sys-typescale-title-small-weight);
|
||||
}
|
||||
|
||||
.oplock-banner__elapsed {
|
||||
font-family: var(--md-sys-typescale-font-mono);
|
||||
font-size: var(--md-sys-typescale-label-medium-size);
|
||||
color: var(--md-sys-color-on-surface-variant);
|
||||
}
|
||||
|
||||
.oplock-enter-active,
|
||||
.oplock-leave-active {
|
||||
transition:
|
||||
opacity var(--md-sys-motion-duration-short4) var(--md-sys-motion-easing-standard),
|
||||
transform var(--md-sys-motion-duration-short4) var(--md-sys-motion-easing-standard);
|
||||
}
|
||||
|
||||
.oplock-enter-from,
|
||||
.oplock-leave-to {
|
||||
opacity: 0;
|
||||
transform: translateY(-100%);
|
||||
}
|
||||
|
||||
/* ── Snackbar(M3:反色表面 + 4dp 圆角)───────────────────────────── */
|
||||
.snackbar-host {
|
||||
position: absolute;
|
||||
left: var(--md-sys-spacing-3);
|
||||
right: var(--md-sys-spacing-3);
|
||||
bottom: calc(96px + var(--safe-area-inset-bottom, var(--window-inset-bottom, 0px)));
|
||||
z-index: 7;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
gap: var(--md-sys-spacing-2);
|
||||
pointer-events: none;
|
||||
}
|
||||
|
||||
.snackbar {
|
||||
pointer-events: auto;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: var(--md-sys-spacing-3);
|
||||
width: 100%;
|
||||
min-height: 48px;
|
||||
padding: var(--md-sys-spacing-3) var(--md-sys-spacing-4);
|
||||
border-radius: var(--md-sys-shape-corner-extra-small);
|
||||
background-color: var(--md-sys-color-inverse-surface);
|
||||
color: var(--md-sys-color-inverse-on-surface);
|
||||
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
|
||||
font-size: var(--md-sys-typescale-body-medium-size);
|
||||
line-height: var(--md-sys-typescale-body-medium-line-height);
|
||||
}
|
||||
|
||||
.snackbar-enter-active,
|
||||
.snackbar-leave-active {
|
||||
transition:
|
||||
opacity var(--md-sys-motion-duration-short4) var(--md-sys-motion-easing-standard),
|
||||
transform var(--md-sys-motion-duration-short4) var(--md-sys-motion-easing-emphasized-decelerate);
|
||||
}
|
||||
|
||||
.snackbar-enter-from,
|
||||
.snackbar-leave-to {
|
||||
opacity: 0;
|
||||
transform: translateY(16px);
|
||||
}
|
||||
|
||||
/* ── 对话框:宽屏居中、窄屏留边 ───────────────────────────────────── */
|
||||
md-dialog {
|
||||
--md-dialog-container-shape: var(--md-sys-shape-corner-extra-large);
|
||||
max-width: min(560px, calc(100vw - 48px));
|
||||
max-height: calc(100dvh - 96px);
|
||||
}
|
||||
@@ -0,0 +1,219 @@
|
||||
/* ==========================================================================
|
||||
基础层:字体、重置、insets、缩放、滚动条与通用排版/表面类
|
||||
========================================================================== */
|
||||
|
||||
@font-face {
|
||||
font-family: 'Geist';
|
||||
src: url('/Geist[wght].woff2') format('woff2');
|
||||
font-weight: 100 900;
|
||||
font-style: normal;
|
||||
font-display: swap;
|
||||
}
|
||||
|
||||
@font-face {
|
||||
font-family: 'Geist Mono';
|
||||
src: url('/GeistMono[wght].woff2') format('woff2');
|
||||
font-weight: 100 900;
|
||||
font-style: normal;
|
||||
font-display: swap;
|
||||
}
|
||||
|
||||
*,
|
||||
*::before,
|
||||
*::after {
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
html,
|
||||
body {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
body {
|
||||
/* 全局 0.95 视觉缩放;用户自定义缩放叠加在 html 上(沿用既有策略) */
|
||||
zoom: 0.95;
|
||||
/* edge-to-edge:安全区由顶栏/底部导航栏各自内缩处理,
|
||||
这样系统栏区域的背景色能延伸到屏幕边缘(参考 FontMM) */
|
||||
background-color: var(--md-sys-color-background);
|
||||
color: var(--md-sys-color-on-background);
|
||||
font-family: var(--md-sys-typescale-font);
|
||||
font-size: var(--md-sys-typescale-body-medium-size);
|
||||
line-height: var(--md-sys-typescale-body-medium-line-height);
|
||||
font-weight: var(--md-sys-typescale-body-medium-weight);
|
||||
letter-spacing: var(--md-sys-typescale-body-medium-tracking);
|
||||
-webkit-font-smoothing: antialiased;
|
||||
-webkit-tap-highlight-color: transparent;
|
||||
}
|
||||
|
||||
button,
|
||||
input,
|
||||
select,
|
||||
textarea {
|
||||
font: inherit;
|
||||
color: inherit;
|
||||
}
|
||||
|
||||
/* 隐藏滚动条(保持移动端观感) */
|
||||
html,
|
||||
body,
|
||||
.scroll-area {
|
||||
scrollbar-width: none;
|
||||
-ms-overflow-style: none;
|
||||
}
|
||||
|
||||
html::-webkit-scrollbar,
|
||||
body::-webkit-scrollbar,
|
||||
.scroll-area::-webkit-scrollbar {
|
||||
display: none;
|
||||
}
|
||||
|
||||
/* ── 排版工具类(直接映射 typescale)───────────────────────────────── */
|
||||
.ts-display {
|
||||
font-size: var(--md-sys-typescale-display-small-size);
|
||||
line-height: var(--md-sys-typescale-display-small-line-height);
|
||||
font-weight: var(--md-sys-typescale-display-small-weight);
|
||||
}
|
||||
.ts-headline {
|
||||
font-size: var(--md-sys-typescale-headline-small-size);
|
||||
line-height: var(--md-sys-typescale-headline-small-line-height);
|
||||
font-weight: var(--md-sys-typescale-headline-small-weight);
|
||||
}
|
||||
.ts-title-lg {
|
||||
font-size: var(--md-sys-typescale-title-large-size);
|
||||
line-height: var(--md-sys-typescale-title-large-line-height);
|
||||
font-weight: var(--md-sys-typescale-title-large-weight);
|
||||
}
|
||||
.ts-title-md {
|
||||
font-size: var(--md-sys-typescale-title-medium-size);
|
||||
line-height: var(--md-sys-typescale-title-medium-line-height);
|
||||
font-weight: var(--md-sys-typescale-title-medium-weight);
|
||||
letter-spacing: var(--md-sys-typescale-title-medium-tracking);
|
||||
}
|
||||
.ts-title-sm {
|
||||
font-size: var(--md-sys-typescale-title-small-size);
|
||||
line-height: var(--md-sys-typescale-title-small-line-height);
|
||||
font-weight: var(--md-sys-typescale-title-small-weight);
|
||||
letter-spacing: var(--md-sys-typescale-title-small-tracking);
|
||||
}
|
||||
.ts-body-lg {
|
||||
font-size: var(--md-sys-typescale-body-large-size);
|
||||
line-height: var(--md-sys-typescale-body-large-line-height);
|
||||
}
|
||||
.ts-body {
|
||||
font-size: var(--md-sys-typescale-body-medium-size);
|
||||
line-height: var(--md-sys-typescale-body-medium-line-height);
|
||||
letter-spacing: var(--md-sys-typescale-body-medium-tracking);
|
||||
}
|
||||
.ts-body-sm {
|
||||
font-size: var(--md-sys-typescale-body-small-size);
|
||||
line-height: var(--md-sys-typescale-body-small-line-height);
|
||||
letter-spacing: var(--md-sys-typescale-body-small-tracking);
|
||||
}
|
||||
.ts-label {
|
||||
font-size: var(--md-sys-typescale-label-large-size);
|
||||
line-height: var(--md-sys-typescale-label-large-line-height);
|
||||
font-weight: var(--md-sys-typescale-label-large-weight);
|
||||
letter-spacing: var(--md-sys-typescale-label-large-tracking);
|
||||
}
|
||||
.ts-label-sm {
|
||||
font-size: var(--md-sys-typescale-label-small-size);
|
||||
line-height: var(--md-sys-typescale-label-small-line-height);
|
||||
font-weight: var(--md-sys-typescale-label-small-weight);
|
||||
letter-spacing: var(--md-sys-typescale-label-small-tracking);
|
||||
}
|
||||
|
||||
.supporting {
|
||||
color: var(--md-sys-color-on-surface-variant);
|
||||
}
|
||||
|
||||
.mono {
|
||||
font-family: var(--md-sys-typescale-font-mono);
|
||||
font-variant-numeric: tabular-nums;
|
||||
}
|
||||
|
||||
/* 中英混排的数值:用页面字体 + 等宽数字,避免中文落到等宽栈的 CJK 兜底字体 */
|
||||
.tabular {
|
||||
font-variant-numeric: tabular-nums;
|
||||
}
|
||||
|
||||
/* ── 表面:MD3 用色调层级而非阴影表达层级 ─────────────────────────── */
|
||||
.section {
|
||||
background-color: var(--md-sys-color-surface-container-low);
|
||||
border-radius: var(--md-sys-shape-corner-large);
|
||||
padding: var(--md-sys-spacing-4);
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: var(--md-sys-spacing-3);
|
||||
}
|
||||
|
||||
.section-header {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: var(--md-sys-spacing-2);
|
||||
min-height: 40px;
|
||||
}
|
||||
|
||||
.section-header .section-title {
|
||||
flex: 1;
|
||||
margin: 0;
|
||||
color: var(--md-sys-color-on-surface);
|
||||
}
|
||||
|
||||
.divider {
|
||||
height: 1px;
|
||||
background-color: var(--md-sys-color-outline-variant);
|
||||
border: 0;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
/* 可点击行:用状态层表达交互反馈(MD3 state layer) */
|
||||
.state-layer {
|
||||
position: relative;
|
||||
overflow: hidden;
|
||||
cursor: pointer;
|
||||
transition: background-color var(--md-sys-motion-duration-short4)
|
||||
var(--md-sys-motion-easing-standard);
|
||||
}
|
||||
|
||||
.state-layer::after {
|
||||
content: '';
|
||||
position: absolute;
|
||||
inset: 0;
|
||||
background-color: currentColor;
|
||||
opacity: 0;
|
||||
pointer-events: none;
|
||||
transition: opacity var(--md-sys-motion-duration-short2)
|
||||
var(--md-sys-motion-easing-standard);
|
||||
}
|
||||
|
||||
.state-layer:hover::after {
|
||||
opacity: var(--md-sys-state-hover-opacity);
|
||||
}
|
||||
|
||||
.state-layer:focus-visible::after {
|
||||
opacity: var(--md-sys-state-focus-opacity);
|
||||
}
|
||||
|
||||
.state-layer:active::after {
|
||||
opacity: var(--md-sys-state-pressed-opacity);
|
||||
}
|
||||
|
||||
/* 焦点环(不做全局关闭,保证键盘/无障碍可见) */
|
||||
:focus-visible {
|
||||
outline: 2px solid var(--md-sys-color-primary);
|
||||
outline-offset: 2px;
|
||||
}
|
||||
|
||||
/* 屏幕阅读器专用文本 */
|
||||
.sr-only {
|
||||
position: absolute;
|
||||
width: 1px;
|
||||
height: 1px;
|
||||
padding: 0;
|
||||
margin: -1px;
|
||||
overflow: hidden;
|
||||
clip: rect(0, 0, 0, 0);
|
||||
white-space: nowrap;
|
||||
border: 0;
|
||||
}
|
||||
@@ -0,0 +1,183 @@
|
||||
/* ==========================================================================
|
||||
跨视图复用的模式:设置行 / 状态徽标 / 空状态 / 折叠区 / 状态网格 / 列表行
|
||||
视图专属样式放在各自的 <style scoped> 中。
|
||||
========================================================================== */
|
||||
|
||||
/* ── 设置行(标签 + 控件)─────────────────────────────────────────── */
|
||||
.row {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: var(--md-sys-spacing-4);
|
||||
padding: var(--md-sys-spacing-2) 0;
|
||||
min-height: 48px;
|
||||
}
|
||||
|
||||
.row__labels {
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 2px;
|
||||
}
|
||||
|
||||
.row__name {
|
||||
color: var(--md-sys-color-on-surface);
|
||||
font-size: var(--md-sys-typescale-body-large-size);
|
||||
line-height: var(--md-sys-typescale-body-large-line-height);
|
||||
font-weight: 500;
|
||||
}
|
||||
|
||||
.row__support {
|
||||
color: var(--md-sys-color-on-surface-variant);
|
||||
font-size: var(--md-sys-typescale-body-small-size);
|
||||
line-height: var(--md-sys-typescale-body-small-line-height);
|
||||
}
|
||||
|
||||
.row__support.warning {
|
||||
color: var(--lp-color-warning);
|
||||
}
|
||||
|
||||
.row__control {
|
||||
flex: 0 0 auto;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: var(--md-sys-spacing-2);
|
||||
}
|
||||
|
||||
/* ── 状态徽标(已保存 / 未保存、计数等)───────────────────────────── */
|
||||
.state-badge {
|
||||
flex: 0 0 auto;
|
||||
padding: 2px 10px;
|
||||
border-radius: var(--md-sys-shape-corner-full);
|
||||
font-size: var(--md-sys-typescale-label-small-size);
|
||||
line-height: var(--md-sys-typescale-label-small-line-height);
|
||||
font-weight: 700;
|
||||
}
|
||||
|
||||
.state-badge.is-saved {
|
||||
background-color: var(--lp-color-success-container);
|
||||
color: var(--lp-color-success);
|
||||
}
|
||||
|
||||
.state-badge.is-unsaved {
|
||||
background-color: var(--lp-color-warning-container);
|
||||
color: var(--lp-color-warning);
|
||||
}
|
||||
|
||||
/* ── 折叠区(grid-template-rows 动画)────────────────────────────── */
|
||||
/* 注意:折叠时子元素自身的 padding 仍会撑出高度,所以间距必须由本组件统一
|
||||
控制(--collapse-gap),子元素上不要再写上下 padding。 */
|
||||
.collapse {
|
||||
display: grid;
|
||||
grid-template-rows: 0fr;
|
||||
margin-top: 0;
|
||||
transition:
|
||||
grid-template-rows var(--md-sys-motion-duration-medium2)
|
||||
var(--md-sys-motion-easing-emphasized),
|
||||
margin-top var(--md-sys-motion-duration-medium2) var(--md-sys-motion-easing-emphasized);
|
||||
}
|
||||
|
||||
.collapse.open {
|
||||
grid-template-rows: 1fr;
|
||||
}
|
||||
|
||||
.collapse > * {
|
||||
overflow: hidden;
|
||||
min-height: 0;
|
||||
padding-top: 0;
|
||||
padding-bottom: 0;
|
||||
transition: padding var(--md-sys-motion-duration-medium2)
|
||||
var(--md-sys-motion-easing-emphasized);
|
||||
}
|
||||
|
||||
.collapse.open > * {
|
||||
padding-top: var(--collapse-gap, 0px);
|
||||
padding-bottom: var(--collapse-gap, 0px);
|
||||
}
|
||||
|
||||
/* 收起时高度为 0 但仍参与父容器 gap,会多留一段空白;抵消其中一次间距 */
|
||||
.collapse:not(.open) {
|
||||
margin-top: calc(-1 * var(--md-sys-spacing-3));
|
||||
}
|
||||
|
||||
.collapse--gap {
|
||||
--collapse-gap: var(--md-sys-spacing-3);
|
||||
}
|
||||
|
||||
/* ── 空状态 ───────────────────────────────────────────────────────── */
|
||||
.empty-state {
|
||||
padding: var(--md-sys-spacing-6) var(--md-sys-spacing-4);
|
||||
text-align: center;
|
||||
color: var(--md-sys-color-on-surface-variant);
|
||||
font-size: var(--md-sys-typescale-body-medium-size);
|
||||
}
|
||||
|
||||
.empty-state.error {
|
||||
color: var(--md-sys-color-error);
|
||||
}
|
||||
|
||||
/* ── 状态网格(实时状态页)────────────────────────────────────────── */
|
||||
.status-grid {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(2, minmax(0, 1fr));
|
||||
gap: var(--md-sys-spacing-2);
|
||||
}
|
||||
|
||||
.status-item {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 2px;
|
||||
padding: var(--md-sys-spacing-3);
|
||||
border-radius: var(--md-sys-shape-corner-medium);
|
||||
background-color: var(--md-sys-color-surface-container);
|
||||
}
|
||||
|
||||
.status-item__label {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 6px;
|
||||
color: var(--md-sys-color-on-surface-variant);
|
||||
font-size: var(--md-sys-typescale-label-medium-size);
|
||||
line-height: var(--md-sys-typescale-label-medium-line-height);
|
||||
}
|
||||
|
||||
.status-item__value {
|
||||
color: var(--md-sys-color-on-surface);
|
||||
font-size: var(--md-sys-typescale-title-medium-size);
|
||||
line-height: var(--md-sys-typescale-title-medium-line-height);
|
||||
font-weight: var(--md-sys-typescale-title-medium-weight);
|
||||
word-break: break-all;
|
||||
}
|
||||
|
||||
/* ── 列表行(黑名单 / 文档 / 菜单项)──────────────────────────────── */
|
||||
.list {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: var(--md-sys-spacing-2);
|
||||
}
|
||||
|
||||
.list-item {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: var(--md-sys-spacing-3);
|
||||
padding: var(--md-sys-spacing-3) var(--md-sys-spacing-4);
|
||||
border-radius: var(--md-sys-shape-corner-medium);
|
||||
background-color: var(--md-sys-color-surface-container);
|
||||
color: var(--md-sys-color-on-surface);
|
||||
}
|
||||
|
||||
/* ── 扫描/进行中 的脉冲文字 ───────────────────────────────────────── */
|
||||
.pulse-text {
|
||||
color: var(--lp-color-warning);
|
||||
animation: status-pulse 1.6s var(--md-sys-motion-easing-standard) infinite;
|
||||
}
|
||||
|
||||
@keyframes status-pulse {
|
||||
0%,
|
||||
100% {
|
||||
opacity: 1;
|
||||
}
|
||||
50% {
|
||||
opacity: 0.45;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,296 @@
|
||||
/* ==========================================================================
|
||||
MD3 设计令牌
|
||||
- 颜色:完整 MD3 角色集,沿用项目既有的 Google Blue 调色板
|
||||
- 字阶 / 形状 / 动效 / 状态层:官方命名(--md-sys-*)
|
||||
暗色为默认;浅色通过「系统偏好」或手动 .light 类生效。
|
||||
========================================================================== */
|
||||
|
||||
:root {
|
||||
/* ── 字阶 typescale ─────────────────────────────────────────────── */
|
||||
--md-sys-typescale-display-large-size: 3.5625rem; /* 57sp */
|
||||
--md-sys-typescale-display-large-line-height: 4rem;
|
||||
--md-sys-typescale-display-large-weight: 400;
|
||||
--md-sys-typescale-display-medium-size: 2.8125rem; /* 45sp */
|
||||
--md-sys-typescale-display-medium-line-height: 3.25rem;
|
||||
--md-sys-typescale-display-medium-weight: 400;
|
||||
--md-sys-typescale-display-small-size: 2.25rem; /* 36sp */
|
||||
--md-sys-typescale-display-small-line-height: 2.75rem;
|
||||
--md-sys-typescale-display-small-weight: 400;
|
||||
|
||||
--md-sys-typescale-headline-large-size: 2rem; /* 32sp */
|
||||
--md-sys-typescale-headline-large-line-height: 2.5rem;
|
||||
--md-sys-typescale-headline-large-weight: 400;
|
||||
--md-sys-typescale-headline-medium-size: 1.75rem; /* 28sp */
|
||||
--md-sys-typescale-headline-medium-line-height: 2.25rem;
|
||||
--md-sys-typescale-headline-medium-weight: 400;
|
||||
--md-sys-typescale-headline-small-size: 1.5rem; /* 24sp */
|
||||
--md-sys-typescale-headline-small-line-height: 2rem;
|
||||
--md-sys-typescale-headline-small-weight: 400;
|
||||
|
||||
--md-sys-typescale-title-large-size: 1.375rem; /* 22sp */
|
||||
--md-sys-typescale-title-large-line-height: 1.75rem;
|
||||
--md-sys-typescale-title-large-weight: 400;
|
||||
--md-sys-typescale-title-medium-size: 1rem; /* 16sp */
|
||||
--md-sys-typescale-title-medium-line-height: 1.5rem;
|
||||
--md-sys-typescale-title-medium-weight: 500;
|
||||
--md-sys-typescale-title-medium-tracking: 0.0094em;
|
||||
--md-sys-typescale-title-small-size: 0.875rem; /* 14sp */
|
||||
--md-sys-typescale-title-small-line-height: 1.25rem;
|
||||
--md-sys-typescale-title-small-weight: 500;
|
||||
--md-sys-typescale-title-small-tracking: 0.0063em;
|
||||
|
||||
--md-sys-typescale-body-large-size: 1rem; /* 16sp */
|
||||
--md-sys-typescale-body-large-line-height: 1.5rem;
|
||||
--md-sys-typescale-body-large-weight: 400;
|
||||
--md-sys-typescale-body-large-tracking: 0.0313em;
|
||||
--md-sys-typescale-body-medium-size: 0.875rem; /* 14sp */
|
||||
--md-sys-typescale-body-medium-line-height: 1.25rem;
|
||||
--md-sys-typescale-body-medium-weight: 400;
|
||||
--md-sys-typescale-body-medium-tracking: 0.0156em;
|
||||
--md-sys-typescale-body-small-size: 0.75rem; /* 12sp */
|
||||
--md-sys-typescale-body-small-line-height: 1rem;
|
||||
--md-sys-typescale-body-small-weight: 400;
|
||||
--md-sys-typescale-body-small-tracking: 0.025em;
|
||||
|
||||
--md-sys-typescale-label-large-size: 0.875rem; /* 14sp */
|
||||
--md-sys-typescale-label-large-line-height: 1.25rem;
|
||||
--md-sys-typescale-label-large-weight: 500;
|
||||
--md-sys-typescale-label-large-tracking: 0.0063em;
|
||||
--md-sys-typescale-label-medium-size: 0.75rem; /* 12sp */
|
||||
--md-sys-typescale-label-medium-line-height: 1rem;
|
||||
--md-sys-typescale-label-medium-weight: 500;
|
||||
--md-sys-typescale-label-medium-tracking: 0.0313em;
|
||||
--md-sys-typescale-label-small-size: 0.6875rem; /* 11sp */
|
||||
--md-sys-typescale-label-small-line-height: 1rem;
|
||||
--md-sys-typescale-label-small-weight: 500;
|
||||
--md-sys-typescale-label-small-tracking: 0.0313em;
|
||||
|
||||
--md-sys-typescale-font: 'Geist', system-ui, -apple-system, sans-serif;
|
||||
/* 等宽栈要带上 CJK 无衬线兜底:Geist Mono 无中文字形,直接落到通用 monospace
|
||||
会在 Windows 上显示为宋体 */
|
||||
--md-sys-typescale-font-mono:
|
||||
'Geist Mono', ui-monospace, 'Microsoft YaHei', 'PingFang SC', 'Noto Sans CJK SC', monospace;
|
||||
|
||||
/* @material/web 组件内部的字体族取自 ref typeface(默认回退 Roboto),
|
||||
必须显式指向项目字体,否则组件内文字与页面字体不一致 */
|
||||
--md-ref-typeface-brand: 'Geist', system-ui, -apple-system, sans-serif;
|
||||
--md-ref-typeface-plain: 'Geist', system-ui, -apple-system, sans-serif;
|
||||
--md-ref-typeface-weight-regular: 400;
|
||||
--md-ref-typeface-weight-medium: 500;
|
||||
|
||||
/* ── 形状 shape ─────────────────────────────────────────────────── */
|
||||
--md-sys-shape-corner-none: 0;
|
||||
--md-sys-shape-corner-extra-small: 4px;
|
||||
--md-sys-shape-corner-small: 8px;
|
||||
--md-sys-shape-corner-medium: 12px;
|
||||
--md-sys-shape-corner-large: 16px;
|
||||
--md-sys-shape-corner-large-increased: 20px;
|
||||
--md-sys-shape-corner-extra-large: 28px;
|
||||
--md-sys-shape-corner-extra-large-increased: 32px;
|
||||
--md-sys-shape-corner-full: 9999px;
|
||||
|
||||
/* ── 间距(8dp 系统)────────────────────────────────────────────── */
|
||||
--md-sys-spacing-1: 4px;
|
||||
--md-sys-spacing-2: 8px;
|
||||
--md-sys-spacing-3: 12px;
|
||||
--md-sys-spacing-4: 16px;
|
||||
--md-sys-spacing-5: 24px;
|
||||
--md-sys-spacing-6: 32px;
|
||||
|
||||
/* ── 动效 motion ────────────────────────────────────────────────── */
|
||||
--md-sys-motion-duration-short2: 100ms;
|
||||
--md-sys-motion-duration-short4: 200ms;
|
||||
--md-sys-motion-duration-medium2: 300ms;
|
||||
--md-sys-motion-duration-medium4: 400ms;
|
||||
--md-sys-motion-duration-long2: 500ms;
|
||||
--md-sys-motion-easing-standard: cubic-bezier(0.2, 0, 0, 1);
|
||||
--md-sys-motion-easing-standard-decelerate: cubic-bezier(0, 0, 0, 1);
|
||||
--md-sys-motion-easing-standard-accelerate: cubic-bezier(0.3, 0, 1, 1);
|
||||
--md-sys-motion-easing-emphasized: cubic-bezier(0.2, 0, 0, 1);
|
||||
--md-sys-motion-easing-emphasized-decelerate: cubic-bezier(0.05, 0.7, 0.1, 1);
|
||||
--md-sys-motion-easing-emphasized-accelerate: cubic-bezier(0.3, 0, 0.8, 0.15);
|
||||
|
||||
/* ── 状态层 state layer ─────────────────────────────────────────── */
|
||||
--md-sys-state-hover-opacity: 0.08;
|
||||
--md-sys-state-focus-opacity: 0.1;
|
||||
--md-sys-state-pressed-opacity: 0.1;
|
||||
--md-sys-state-dragged-opacity: 0.16;
|
||||
|
||||
/* ── 项目扩展角色(MD3 无 warning/success)──────────────────────── */
|
||||
--lp-color-warning: #f59e0b;
|
||||
--lp-color-success: #4ade80;
|
||||
}
|
||||
|
||||
/* ==========================================================================
|
||||
暗色(默认)
|
||||
========================================================================== */
|
||||
:root,
|
||||
:root.dark {
|
||||
--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-secondary: #bec6dc;
|
||||
--md-sys-color-on-secondary: #283141;
|
||||
--md-sys-color-secondary-container: #3e4759;
|
||||
--md-sys-color-on-secondary-container: #dae2f9;
|
||||
|
||||
--md-sys-color-tertiary: #d6bee4;
|
||||
--md-sys-color-on-tertiary: #3b2948;
|
||||
--md-sys-color-tertiary-container: #523f5f;
|
||||
--md-sys-color-on-tertiary-container: #f2daff;
|
||||
|
||||
--md-sys-color-error: #ffb4ab;
|
||||
--md-sys-color-on-error: #690005;
|
||||
--md-sys-color-error-container: #93000a;
|
||||
--md-sys-color-on-error-container: #ffdad6;
|
||||
|
||||
--md-sys-color-background: #111318;
|
||||
--md-sys-color-on-background: #e2e2e9;
|
||||
--md-sys-color-surface: #1e1f25;
|
||||
--md-sys-color-on-surface: #e2e2e9;
|
||||
--md-sys-color-surface-variant: #44474f;
|
||||
--md-sys-color-on-surface-variant: #c4c6d0;
|
||||
|
||||
--md-sys-color-surface-dim: #111318;
|
||||
--md-sys-color-surface-bright: #37393f;
|
||||
--md-sys-color-surface-container-lowest: #0d0e12;
|
||||
--md-sys-color-surface-container-low: #1a1c22;
|
||||
--md-sys-color-surface-container: #212429;
|
||||
--md-sys-color-surface-container-high: #2b2930;
|
||||
--md-sys-color-surface-container-highest: #36343b;
|
||||
|
||||
--md-sys-color-inverse-surface: #e2e2e9;
|
||||
--md-sys-color-inverse-on-surface: #2f3033;
|
||||
--md-sys-color-inverse-primary: #0b57d0;
|
||||
|
||||
--md-sys-color-outline: #8e9099;
|
||||
--md-sys-color-outline-variant: #44474f;
|
||||
--md-sys-color-shadow: #000000;
|
||||
--md-sys-color-scrim: #000000;
|
||||
|
||||
--lp-color-warning: #f59e0b;
|
||||
--lp-color-warning-container: rgba(245, 158, 11, 0.16);
|
||||
--lp-color-success: #4ade80;
|
||||
--lp-color-success-container: rgba(74, 222, 128, 0.16);
|
||||
--md-sys-color-scrim-rgb: 0, 0, 0;
|
||||
}
|
||||
|
||||
/* ==========================================================================
|
||||
浅色
|
||||
========================================================================== */
|
||||
@media (prefers-color-scheme: light) {
|
||||
:root:not(.dark) {
|
||||
--md-sys-color-primary: #0b57d0;
|
||||
--md-sys-color-on-primary: #ffffff;
|
||||
--md-sys-color-primary-container: #d3e3fd;
|
||||
--md-sys-color-on-primary-container: #041e49;
|
||||
|
||||
--md-sys-color-secondary: #565e71;
|
||||
--md-sys-color-on-secondary: #ffffff;
|
||||
--md-sys-color-secondary-container: #dae2f9;
|
||||
--md-sys-color-on-secondary-container: #131c2b;
|
||||
|
||||
--md-sys-color-tertiary: #6b5778;
|
||||
--md-sys-color-on-tertiary: #ffffff;
|
||||
--md-sys-color-tertiary-container: #f2daff;
|
||||
--md-sys-color-on-tertiary-container: #251431;
|
||||
|
||||
--md-sys-color-error: #b3261e;
|
||||
--md-sys-color-on-error: #ffffff;
|
||||
--md-sys-color-error-container: #f9dedc;
|
||||
--md-sys-color-on-error-container: #410e0b;
|
||||
|
||||
--md-sys-color-background: #f8f9fc;
|
||||
--md-sys-color-on-background: #191c20;
|
||||
--md-sys-color-surface: #ffffff;
|
||||
--md-sys-color-on-surface: #191c20;
|
||||
--md-sys-color-surface-variant: #e1e2ec;
|
||||
--md-sys-color-on-surface-variant: #44474f;
|
||||
|
||||
--md-sys-color-surface-dim: #d9dae0;
|
||||
--md-sys-color-surface-bright: #ffffff;
|
||||
--md-sys-color-surface-container-lowest: #ffffff;
|
||||
--md-sys-color-surface-container-low: #f3f4f9;
|
||||
--md-sys-color-surface-container: #eff1f6;
|
||||
--md-sys-color-surface-container-high: #e8eaf0;
|
||||
--md-sys-color-surface-container-highest: #e2e4eb;
|
||||
|
||||
--md-sys-color-inverse-surface: #2f3033;
|
||||
--md-sys-color-inverse-on-surface: #f1f0f4;
|
||||
--md-sys-color-inverse-primary: #a8c7fa;
|
||||
|
||||
--md-sys-color-outline: #74777f;
|
||||
--md-sys-color-outline-variant: #c4c7d0;
|
||||
|
||||
--lp-color-warning: #b45309;
|
||||
--lp-color-warning-container: rgba(180, 83, 9, 0.14);
|
||||
--lp-color-success: #2f9e63;
|
||||
--lp-color-success-container: rgba(47, 158, 99, 0.14);
|
||||
}
|
||||
}
|
||||
|
||||
/* 手动指定浅色(Web UI 设置里的「浅色」)*/
|
||||
:root.light {
|
||||
--md-sys-color-primary: #0b57d0;
|
||||
--md-sys-color-on-primary: #ffffff;
|
||||
--md-sys-color-primary-container: #d3e3fd;
|
||||
--md-sys-color-on-primary-container: #041e49;
|
||||
|
||||
--md-sys-color-secondary: #565e71;
|
||||
--md-sys-color-on-secondary: #ffffff;
|
||||
--md-sys-color-secondary-container: #dae2f9;
|
||||
--md-sys-color-on-secondary-container: #131c2b;
|
||||
|
||||
--md-sys-color-tertiary: #6b5778;
|
||||
--md-sys-color-on-tertiary: #ffffff;
|
||||
--md-sys-color-tertiary-container: #f2daff;
|
||||
--md-sys-color-on-tertiary-container: #251431;
|
||||
|
||||
--md-sys-color-error: #b3261e;
|
||||
--md-sys-color-on-error: #ffffff;
|
||||
--md-sys-color-error-container: #f9dedc;
|
||||
--md-sys-color-on-error-container: #410e0b;
|
||||
|
||||
--md-sys-color-background: #f8f9fc;
|
||||
--md-sys-color-on-background: #191c20;
|
||||
--md-sys-color-surface: #ffffff;
|
||||
--md-sys-color-on-surface: #191c20;
|
||||
--md-sys-color-surface-variant: #e1e2ec;
|
||||
--md-sys-color-on-surface-variant: #44474f;
|
||||
|
||||
--md-sys-color-surface-dim: #d9dae0;
|
||||
--md-sys-color-surface-bright: #ffffff;
|
||||
--md-sys-color-surface-container-lowest: #ffffff;
|
||||
--md-sys-color-surface-container-low: #f3f4f9;
|
||||
--md-sys-color-surface-container: #eff1f6;
|
||||
--md-sys-color-surface-container-high: #e8eaf0;
|
||||
--md-sys-color-surface-container-highest: #e2e4eb;
|
||||
|
||||
--md-sys-color-inverse-surface: #2f3033;
|
||||
--md-sys-color-inverse-on-surface: #f1f0f4;
|
||||
--md-sys-color-inverse-primary: #a8c7fa;
|
||||
|
||||
--md-sys-color-outline: #74777f;
|
||||
--md-sys-color-outline-variant: #c4c7d0;
|
||||
--md-sys-color-scrim-rgb: 0, 0, 0;
|
||||
|
||||
--lp-color-warning: #b45309;
|
||||
--lp-color-warning-container: rgba(180, 83, 9, 0.14);
|
||||
--lp-color-success: #2f9e63;
|
||||
--lp-color-success-container: rgba(47, 158, 99, 0.14);
|
||||
}
|
||||
|
||||
/* ==========================================================================
|
||||
@material/web 组件接入令牌
|
||||
========================================================================== */
|
||||
:root {
|
||||
/* 默认控件高度与形状对齐 MD3 */
|
||||
--md-filled-button-container-shape: var(--md-sys-shape-corner-full);
|
||||
--md-outlined-button-container-shape: var(--md-sys-shape-corner-full);
|
||||
--md-text-button-container-shape: var(--md-sys-shape-corner-full);
|
||||
--md-filled-tonal-button-container-shape: var(--md-sys-shape-corner-full);
|
||||
--md-outlined-text-field-container-shape: var(--md-sys-shape-corner-small);
|
||||
--md-outlined-select-text-field-container-shape: var(--md-sys-shape-corner-small);
|
||||
}
|
||||
@@ -1,113 +0,0 @@
|
||||
import { exec } from 'kernelsu'
|
||||
|
||||
export const MODULE_DIR = '/data/adb/modules/LuminPro'
|
||||
export const CONFIG_DIR = `${MODULE_DIR}/config`
|
||||
export const CONFIG_FILE = `${MODULE_DIR}/config/config.json`
|
||||
export const BACKUP_CONFIG_FILE = `${MODULE_DIR}/config/.backup/config.json`
|
||||
export const PID_FILE = `${MODULE_DIR}/pid/inotifyd.pid`
|
||||
export const STOP_FLAG_FILE = `${MODULE_DIR}/pid/stop.flag`
|
||||
export const OPLOCK_FILE = `${MODULE_DIR}/pid/oplock`
|
||||
export const LOG_FILE = `${MODULE_DIR}/service.log`
|
||||
export const DEFAULT_NOW_BRI_FILE = '/sys/class/backlight/panel0-backlight/brightness'
|
||||
export const DEFAULT_SYS_MAX_BRI_FILE = '/sys/class/backlight/panel0-backlight/max_brightness'
|
||||
|
||||
export function showToast(msg) {
|
||||
const toast = document.getElementById('toast')
|
||||
toast.textContent = msg
|
||||
toast.classList.add('show')
|
||||
setTimeout(() => toast.classList.remove('show'), 3000)
|
||||
}
|
||||
|
||||
export async function runCmd(cmd) {
|
||||
try {
|
||||
const res = await exec(cmd)
|
||||
return res
|
||||
} catch (e) {
|
||||
console.warn(`[DEBUG] 执行命令失败 (可能是非 KSU 环境): ${cmd}`)
|
||||
|
||||
// JSON 配置模拟
|
||||
if (cmd.includes('cat') && cmd.includes('config.json')) {
|
||||
return {
|
||||
errno: 0,
|
||||
stdout: JSON.stringify({
|
||||
ui_max_bri: 4095,
|
||||
max_bri: 3500,
|
||||
steps_num: 100,
|
||||
log_max_size: 1024,
|
||||
auto_bri_sleep: 1,
|
||||
display_hdr_sleep: 0,
|
||||
hdr_enter_ratio: 1.15,
|
||||
hdr_exit_ratio: 1.05,
|
||||
sleep_time: '1900-0600',
|
||||
inotify_events: 'c',
|
||||
now_bri_file: '/sys/mock/brightness',
|
||||
max_bri_file: '/sys/mock/max_brightness',
|
||||
blacklist_apps: ['com.example.app'],
|
||||
}),
|
||||
stderr: '',
|
||||
}
|
||||
}
|
||||
|
||||
// 状态模拟
|
||||
if (cmd.includes('cat') && cmd.includes('inotifyd.pid'))
|
||||
return { errno: 0, stdout: '12345', stderr: '' }
|
||||
if (cmd.includes('[ -f') && cmd.includes('stop.flag'))
|
||||
return { errno: 0, stdout: '0', stderr: '' }
|
||||
if (cmd.includes('oplock')) return { errno: 0, stdout: 'free', stderr: '' }
|
||||
if (cmd.includes('cat') && (cmd.includes('brightness') || cmd.includes('now_bri')))
|
||||
return { errno: 0, stdout: '1200', stderr: '' }
|
||||
if (cmd.includes('cat') && (cmd.includes('max_brightness') || cmd.includes('max_bri')))
|
||||
return { errno: 0, stdout: '4095', stderr: '' }
|
||||
|
||||
// 日志模拟
|
||||
if (cmd.includes('tail') && cmd.includes('service.log')) {
|
||||
return {
|
||||
errno: 0,
|
||||
stdout:
|
||||
'[04-07 15:40:01] [service] [INFO ] LuminPro 服务启动\n[04-07 15:41:05] [up] [INFO ] 触发提升: 当前亮度 1200 ≥ 阈値 1000\n[04-07 15:42:10] [up] [SUCCESS ] 亮度提升完成 (3500)',
|
||||
stderr: '',
|
||||
}
|
||||
}
|
||||
|
||||
// 文档模拟
|
||||
if (cmd.includes('cat') && cmd.includes('.md'))
|
||||
return {
|
||||
errno: 0,
|
||||
stdout: '# 调试模式\n\n当前处于 **Web 调试模式**,显示的是模拟测试数据。',
|
||||
stderr: '',
|
||||
}
|
||||
if (cmd.includes('cat') && cmd.includes('.txt'))
|
||||
return { errno: 0, stdout: '这是 NOTE.txt 的模拟内容。', stderr: '' }
|
||||
|
||||
return { errno: -1, stdout: '', stderr: String(e) }
|
||||
}
|
||||
}
|
||||
|
||||
// 读取完整 JSON 配置
|
||||
export async function readConfig() {
|
||||
const res = await runCmd(`cat "${CONFIG_FILE}"`)
|
||||
if (res.errno !== 0 || !res.stdout.trim()) return {}
|
||||
try {
|
||||
return JSON.parse(res.stdout)
|
||||
} catch {
|
||||
return {}
|
||||
}
|
||||
}
|
||||
|
||||
// 写入完整 JSON 配置
|
||||
export async function writeConfig(obj) {
|
||||
const content = JSON.stringify(obj).replace(/'/g, "'\\''")
|
||||
return runCmd(`printf '%s' '${content}' > "${CONFIG_FILE}"`)
|
||||
}
|
||||
|
||||
// 合并更新 JSON 配置(保留其他字段)
|
||||
export async function updateConfig(updates) {
|
||||
const current = await readConfig()
|
||||
return writeConfig({ ...current, ...updates })
|
||||
}
|
||||
|
||||
// 将文件内容写入指定路径
|
||||
export async function writeFile(path, content) {
|
||||
const safeContent = String(content).replace(/'/g, "'\\''")
|
||||
return runCmd(`printf '%s' '${safeContent}' > "${path}"`)
|
||||
}
|
||||
+316
-90
@@ -1,105 +1,331 @@
|
||||
<script setup>
|
||||
import { ref } from 'vue'
|
||||
import MarkdownIt from 'markdown-it'
|
||||
import Button from '@/components/ui/Button.vue'
|
||||
import { BookOpen, ScrollText, StickyNote, X, Github } from 'lucide-vue-next'
|
||||
import { runCmd } from '../utils.js'
|
||||
import { inject, ref, computed, nextTick } from 'vue'
|
||||
import { BookOpen, ScrollText, StickyNote, Github, ExternalLink } from 'lucide-vue-next'
|
||||
import { readModuleFile } from '../api/luminpro.js'
|
||||
import { runCmd, shellQuote } from '../api/ksu.js'
|
||||
|
||||
const MODULE_DIR = '/data/adb/modules/LuminPro'
|
||||
const status = inject('status')
|
||||
const snackbar = inject('snackbar')
|
||||
|
||||
const sheetOpen = ref(false)
|
||||
const sheetTitle = ref('')
|
||||
const sheetContent = ref('')
|
||||
const sheetLoading = ref(false)
|
||||
/** markdown-it 体积较大且只有文档页用得到,打开文档时再按需加载 */
|
||||
let renderMarkdown = null
|
||||
async function ensureMarkdown() {
|
||||
if (renderMarkdown) return renderMarkdown
|
||||
const { default: MarkdownIt } = await import('markdown-it')
|
||||
// README 使用了 HTML 与 GitHub 提示块(> [!TIP]),需要一并支持
|
||||
const md = new MarkdownIt({ html: true, linkify: true, breaks: true })
|
||||
|
||||
const md = new MarkdownIt({ html: true, linkify: true, typographer: true })
|
||||
md.core.ruler.push('github-alerts', (state) => {
|
||||
const tokens = state.tokens
|
||||
for (let i = 0; i < tokens.length; i++) {
|
||||
const token = tokens[i]
|
||||
if (token.type !== 'blockquote_open') continue
|
||||
const inline = tokens[i + 2]
|
||||
if (!inline || inline.type !== 'inline') continue
|
||||
const match = /^\[!([A-Z]+)\]\s*/.exec(inline.content)
|
||||
if (!match) continue
|
||||
const kind = match[1].toLowerCase()
|
||||
const label = ALERT_LABELS[kind]
|
||||
if (!label) continue
|
||||
token.attrJoin('class', `md-alert md-alert--${kind}`)
|
||||
inline.content = inline.content.replace(match[0], '')
|
||||
inline.children[0].content = inline.children[0].content.replace(match[0], '')
|
||||
const marker = new state.Token('html_block', '', 0)
|
||||
marker.content = `<p class="md-alert__title">${label}</p>`
|
||||
const closeIdx = findBlockquoteClose(tokens, i)
|
||||
if (closeIdx > 0) tokens.splice(closeIdx, 0, marker)
|
||||
}
|
||||
return true
|
||||
})
|
||||
|
||||
const moduleDocs = [
|
||||
{ title: 'README', file: `${MODULE_DIR}/README.md`, icon: BookOpen, md: true },
|
||||
{ title: 'README (EN)', file: `${MODULE_DIR}/README_en.md`, icon: BookOpen, md: true },
|
||||
{ title: '更新日志', file: `${MODULE_DIR}/changelog.md`, icon: ScrollText, md: true },
|
||||
{ title: 'NOTE', file: `${MODULE_DIR}/NOTE.txt`, icon: StickyNote, md: false },
|
||||
]
|
||||
|
||||
async function openModuleDoc(doc) {
|
||||
sheetTitle.value = doc.title
|
||||
sheetContent.value = ''
|
||||
sheetLoading.value = true
|
||||
sheetOpen.value = true
|
||||
try {
|
||||
const res = await runCmd(`cat "${doc.file}" 2>/dev/null`)
|
||||
if (res.errno !== 0 || !res.stdout.trim()) throw new Error('文件不存在或为空')
|
||||
sheetContent.value = doc.md
|
||||
? md.render(res.stdout)
|
||||
: res.stdout
|
||||
.replace(/&/g, '&')
|
||||
.replace(/</g, '<')
|
||||
.replace(/>/g, '>')
|
||||
.replace(/\n/g, '<br>')
|
||||
} catch (e) {
|
||||
sheetContent.value = `加载失败: ${e.message}`
|
||||
} finally {
|
||||
sheetLoading.value = false
|
||||
}
|
||||
renderMarkdown = (text) => md.render(text)
|
||||
return renderMarkdown
|
||||
}
|
||||
|
||||
function closeSheet() {
|
||||
sheetOpen.value = false
|
||||
/** GitHub 提示块的标题文案 */
|
||||
const ALERT_LABELS = {
|
||||
note: '备注',
|
||||
tip: '提示',
|
||||
important: '重要',
|
||||
warning: '警告',
|
||||
caution: '注意',
|
||||
}
|
||||
|
||||
/** 找到与 openIdx 配对的 blockquote_close 下标 */
|
||||
function findBlockquoteClose(tokens, openIdx) {
|
||||
let depth = 0
|
||||
for (let i = openIdx; i < tokens.length; i++) {
|
||||
if (tokens[i].type === 'blockquote_open') depth++
|
||||
else if (tokens[i].type === 'blockquote_close') {
|
||||
depth--
|
||||
if (depth === 0) return i
|
||||
}
|
||||
}
|
||||
return -1
|
||||
}
|
||||
|
||||
const docs = [
|
||||
{ key: 'README.md', label: '模块说明', icon: BookOpen },
|
||||
{ key: 'changelog.md', label: '更新日志', icon: ScrollText },
|
||||
{ key: 'NOTE.txt', label: '注意事项', icon: StickyNote },
|
||||
]
|
||||
|
||||
const docOpen = ref(false)
|
||||
const docTitle = ref('')
|
||||
const docHtml = ref('')
|
||||
const docDialog = ref(null)
|
||||
const loading = ref(false)
|
||||
|
||||
const module = computed(() => status.moduleInfo.value)
|
||||
const version = computed(() => module.value.version || '—')
|
||||
const channel = computed(() => {
|
||||
const value = module.value.channel
|
||||
if (!value || value === 'stable') return ''
|
||||
return value === 'beta' ? 'Beta' : 'Dev'
|
||||
})
|
||||
|
||||
async function openDoc(doc) {
|
||||
loading.value = true
|
||||
docTitle.value = doc.label
|
||||
docHtml.value = ''
|
||||
docOpen.value = true
|
||||
await nextTick()
|
||||
docDialog.value?.show()
|
||||
|
||||
const text = await readModuleFile(doc.key)
|
||||
loading.value = false
|
||||
if (!text.trim()) {
|
||||
docHtml.value = '<p>无法读取该文档。</p>'
|
||||
return
|
||||
}
|
||||
docHtml.value = doc.key.endsWith('.md')
|
||||
? (await ensureMarkdown())(text)
|
||||
: `<pre class="plain">${text.replace(/</g, '<')}</pre>`
|
||||
}
|
||||
|
||||
function closeDoc() {
|
||||
docOpen.value = false
|
||||
docDialog.value?.close()
|
||||
}
|
||||
|
||||
async function openLink(url) {
|
||||
const res = await runCmd(`am start -a android.intent.action.VIEW -d ${shellQuote(url)}`)
|
||||
if (!res.ok) snackbar('无法打开链接')
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div style="display: contents">
|
||||
<section class="card" id="about-section">
|
||||
<!-- 模块文档 -->
|
||||
<div class="about-section-title">模块文档</div>
|
||||
<div class="about-list">
|
||||
<button
|
||||
v-for="doc in moduleDocs"
|
||||
:key="doc.file"
|
||||
class="about-list-item"
|
||||
@click="openModuleDoc(doc)"
|
||||
>
|
||||
<component :is="doc.icon" :size="18" class="about-list-icon" />
|
||||
<span>{{ doc.title }}</span>
|
||||
</button>
|
||||
</div>
|
||||
<section class="section">
|
||||
<div class="section-header">
|
||||
<h2 class="section-title ts-title-md">关于 LuminPro</h2>
|
||||
<span v-if="channel" class="channel-badge">{{ channel }}</span>
|
||||
</div>
|
||||
|
||||
<!-- 链接列表 -->
|
||||
<div class="about-section-title">链接</div>
|
||||
<div class="about-list">
|
||||
<button
|
||||
class="about-list-item"
|
||||
@click="
|
||||
runCmd(
|
||||
'am start -a android.intent.action.VIEW -d \'https://github.com/YuleBest/LuminPro\'',
|
||||
)
|
||||
"
|
||||
>
|
||||
<Github :size="18" class="about-list-icon" />
|
||||
<span>GitHub 项目主页</span>
|
||||
</button>
|
||||
<div class="about-meta">
|
||||
<div class="about-meta__item">
|
||||
<span class="ts-body-sm supporting">版本</span>
|
||||
<span class="ts-body mono">{{ version }}</span>
|
||||
</div>
|
||||
|
||||
<p class="about-footer">Made with ❤ by Yule</p>
|
||||
</section>
|
||||
|
||||
<!-- 文档底部弹出抽屉 -->
|
||||
<Teleport to="body">
|
||||
<div class="doc-sheet-backdrop" :class="{ show: sheetOpen }" @click="closeSheet"></div>
|
||||
<div class="doc-sheet" :class="{ show: sheetOpen }">
|
||||
<div class="doc-sheet-header">
|
||||
<span class="doc-sheet-title">{{ sheetTitle }}</span>
|
||||
<button class="doc-sheet-close" @click="closeSheet">
|
||||
<X :size="20" />
|
||||
</button>
|
||||
</div>
|
||||
<div class="doc-sheet-body">
|
||||
<div v-if="sheetLoading" class="doc-sheet-loading">加载中...</div>
|
||||
<!-- eslint-disable-next-line vue/no-v-html -->
|
||||
<div v-else class="doc-sheet-content" v-html="sheetContent"></div>
|
||||
</div>
|
||||
<div class="about-meta__item">
|
||||
<span class="ts-body-sm supporting">作者</span>
|
||||
<span class="ts-body">酷安 @于乐yule</span>
|
||||
</div>
|
||||
</Teleport>
|
||||
</div>
|
||||
<div class="about-meta__item">
|
||||
<span class="ts-body-sm supporting">状态</span>
|
||||
<span class="ts-body">{{ status.statusText.value }}</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<p class="ts-body-sm supporting">
|
||||
模块在亮度达到设定阈值时平滑提升到硬件峰值亮度,并支持休眠时段、应用黑名单与 HDR 内容避让。
|
||||
</p>
|
||||
</section>
|
||||
|
||||
<section class="section">
|
||||
<h2 class="section-title ts-title-md">文档</h2>
|
||||
<div class="list">
|
||||
<button
|
||||
v-for="doc in docs"
|
||||
:key="doc.key"
|
||||
class="list-item state-layer"
|
||||
@click="openDoc(doc)"
|
||||
>
|
||||
<component :is="doc.icon" :size="18" />
|
||||
<span class="ts-body">{{ doc.label }}</span>
|
||||
</button>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section class="section">
|
||||
<h2 class="section-title ts-title-md">链接</h2>
|
||||
<div class="list">
|
||||
<button
|
||||
class="list-item state-layer"
|
||||
@click="openLink('https://github.com/YuleBest/LuminPro')"
|
||||
>
|
||||
<Github :size="18" />
|
||||
<span class="ts-body">GitHub 仓库</span>
|
||||
<ExternalLink :size="16" class="link-trail" />
|
||||
</button>
|
||||
<button
|
||||
class="list-item state-layer"
|
||||
@click="openLink('https://github.com/YuleBest/LuminPro/releases')"
|
||||
>
|
||||
<ExternalLink :size="18" />
|
||||
<span class="ts-body">版本发布与更新通道</span>
|
||||
<ExternalLink :size="16" class="link-trail" />
|
||||
</button>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<md-dialog ref="docDialog" @closed="docOpen = false">
|
||||
<div slot="headline">{{ docTitle }}</div>
|
||||
<div slot="content" class="doc-content">
|
||||
<div v-if="loading" class="ts-body supporting">加载中…</div>
|
||||
<div v-else class="markdown" v-html="docHtml"></div>
|
||||
</div>
|
||||
<div slot="actions">
|
||||
<md-filled-button @click="closeDoc">关闭</md-filled-button>
|
||||
</div>
|
||||
</md-dialog>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
/* GitHub 提示块(> [!TIP] 等) */
|
||||
.markdown :deep(.md-alert) {
|
||||
margin: 0 0 var(--md-sys-spacing-3);
|
||||
padding: var(--md-sys-spacing-3);
|
||||
border-radius: var(--md-sys-shape-corner-small);
|
||||
border-inline-start: 4px solid var(--md-sys-color-primary);
|
||||
background-color: var(--md-sys-color-surface-container);
|
||||
}
|
||||
|
||||
.markdown :deep(.md-alert__title) {
|
||||
margin: 0 0 4px;
|
||||
font-weight: 600;
|
||||
color: var(--md-sys-color-primary);
|
||||
}
|
||||
|
||||
.markdown :deep(.md-alert--tip) {
|
||||
border-inline-start-color: var(--lp-color-success);
|
||||
}
|
||||
|
||||
.markdown :deep(.md-alert--tip .md-alert__title) {
|
||||
color: var(--lp-color-success);
|
||||
}
|
||||
|
||||
.markdown :deep(.md-alert--warning),
|
||||
.markdown :deep(.md-alert--caution) {
|
||||
border-inline-start-color: var(--lp-color-warning);
|
||||
}
|
||||
|
||||
.markdown :deep(.md-alert--warning .md-alert__title),
|
||||
.markdown :deep(.md-alert--caution .md-alert__title) {
|
||||
color: var(--lp-color-warning);
|
||||
}
|
||||
|
||||
.markdown :deep(.md-alert--important) {
|
||||
border-inline-start-color: var(--md-sys-color-error);
|
||||
}
|
||||
|
||||
.markdown :deep(.md-alert--important .md-alert__title) {
|
||||
color: var(--md-sys-color-error);
|
||||
}
|
||||
|
||||
/* README 的居中容器与徽章 */
|
||||
.markdown :deep([align='center']) {
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.markdown :deep(img) {
|
||||
max-width: 100%;
|
||||
height: auto;
|
||||
}
|
||||
|
||||
.about-meta {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: var(--md-sys-spacing-4);
|
||||
}
|
||||
|
||||
.about-meta__item {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 2px;
|
||||
}
|
||||
|
||||
.list-item {
|
||||
border: 0;
|
||||
text-align: left;
|
||||
font: inherit;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.link-trail {
|
||||
margin-left: auto;
|
||||
color: var(--md-sys-color-on-surface-variant);
|
||||
}
|
||||
|
||||
.doc-content {
|
||||
max-height: 60vh;
|
||||
overflow-y: auto;
|
||||
min-width: min(360px, 78vw);
|
||||
}
|
||||
|
||||
.markdown {
|
||||
color: var(--md-sys-color-on-surface);
|
||||
font-size: var(--md-sys-typescale-body-medium-size);
|
||||
line-height: 1.7;
|
||||
}
|
||||
|
||||
.markdown :deep(h1),
|
||||
.markdown :deep(h2),
|
||||
.markdown :deep(h3) {
|
||||
font-size: var(--md-sys-typescale-title-medium-size);
|
||||
line-height: var(--md-sys-typescale-title-medium-line-height);
|
||||
margin: var(--md-sys-spacing-4) 0 var(--md-sys-spacing-2);
|
||||
}
|
||||
|
||||
.markdown :deep(h1) {
|
||||
font-size: var(--md-sys-typescale-title-large-size);
|
||||
}
|
||||
|
||||
.markdown :deep(p),
|
||||
.markdown :deep(li) {
|
||||
margin: 0 0 var(--md-sys-spacing-2);
|
||||
}
|
||||
|
||||
.markdown :deep(code) {
|
||||
font-family: var(--md-sys-typescale-font-mono);
|
||||
background-color: var(--md-sys-color-surface-container-high);
|
||||
padding: 1px 4px;
|
||||
border-radius: var(--md-sys-shape-corner-extra-small);
|
||||
}
|
||||
|
||||
.markdown :deep(pre) {
|
||||
background-color: var(--md-sys-color-surface-container-high);
|
||||
padding: var(--md-sys-spacing-3);
|
||||
border-radius: var(--md-sys-shape-corner-small);
|
||||
overflow-x: auto;
|
||||
}
|
||||
|
||||
.markdown :deep(a) {
|
||||
color: var(--md-sys-color-primary);
|
||||
}
|
||||
|
||||
.markdown :deep(.plain) {
|
||||
white-space: pre-wrap;
|
||||
}
|
||||
|
||||
.markdown :deep(table) {
|
||||
border-collapse: collapse;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.markdown :deep(th),
|
||||
.markdown :deep(td) {
|
||||
border-bottom: 1px solid var(--md-sys-color-outline-variant);
|
||||
padding: 6px 8px;
|
||||
text-align: left;
|
||||
}
|
||||
</style>
|
||||
+503
-377
@@ -1,67 +1,99 @@
|
||||
<script setup>
|
||||
import { inject, ref, computed, onMounted, reactive } from 'vue'
|
||||
import { getPackagesInfo } from 'kernelsu'
|
||||
import { inject, ref, computed, onUnmounted, nextTick } from 'vue'
|
||||
import { useVirtualizer } from '@tanstack/vue-virtual'
|
||||
import { useApps } from '@/composables/useApps.js'
|
||||
import { runCmd } from '../utils.js'
|
||||
import Button from '@/components/ui/Button.vue'
|
||||
import {
|
||||
RefreshCw,
|
||||
Eye,
|
||||
EyeOff,
|
||||
Sparkles,
|
||||
Plus,
|
||||
CheckCheck,
|
||||
Square,
|
||||
CheckSquare,
|
||||
Search,
|
||||
Save,
|
||||
X,
|
||||
Check,
|
||||
ChevronDown,
|
||||
ScanSearch,
|
||||
ChevronLeft,
|
||||
Monitor,
|
||||
Clock,
|
||||
CircleCheck,
|
||||
Check,
|
||||
} from 'lucide-vue-next'
|
||||
import ActionMenu from '../components/ActionMenu.vue'
|
||||
import AppTextField from '../components/AppTextField.vue'
|
||||
import PromptDialog from '../components/PromptDialog.vue'
|
||||
import { fetchFocus } from '../api/luminpro.js'
|
||||
|
||||
const showToast = inject('showToast')
|
||||
const oplock = inject('oplock')
|
||||
const appsMenuOpen = ref(false)
|
||||
const appsApi = inject('apps')
|
||||
const status = inject('status')
|
||||
const snackbar = inject('snackbar')
|
||||
|
||||
const {
|
||||
apps,
|
||||
isLoading,
|
||||
loadError,
|
||||
searchKeyword,
|
||||
showingSystemApps,
|
||||
savedBlacklist,
|
||||
activityEntries,
|
||||
load,
|
||||
save,
|
||||
hasActivity,
|
||||
getActivities,
|
||||
addActivity,
|
||||
removeActivity,
|
||||
onCheckboxChange,
|
||||
toggleSystemApps,
|
||||
selectAll,
|
||||
selectNone,
|
||||
invertSelection,
|
||||
smartSelect,
|
||||
getFilteredApps,
|
||||
} = useApps()
|
||||
const locked = computed(() => status.oplock.value.locked)
|
||||
|
||||
const filteredApps = computed(() => getFilteredApps())
|
||||
const menuItems = computed(() => [
|
||||
{
|
||||
key: 'toggle-system',
|
||||
label: appsApi.showingSystemApps.value ? '隐藏系统应用' : '显示系统应用',
|
||||
},
|
||||
{ key: 'smart', label: '智能选择' },
|
||||
{ key: 'manual', label: '手动添加包名' },
|
||||
{ key: 'all', label: '全选' },
|
||||
{ key: 'none', label: '全不选' },
|
||||
{ key: 'invert', label: '反选' },
|
||||
])
|
||||
|
||||
const filteredApps = computed(() => appsApi.getFilteredApps())
|
||||
const appCount = computed(() => filteredApps.value.length)
|
||||
|
||||
// 虚拟滚动:真机 500+ 应用时只渲染可视区附近的行
|
||||
function onMenuSelect(key) {
|
||||
switch (key) {
|
||||
case 'toggle-system':
|
||||
appsApi.toggleSystemApps()
|
||||
break
|
||||
case 'smart':
|
||||
appsApi.smartSelect(snackbar)
|
||||
break
|
||||
case 'manual':
|
||||
manualOpen.value = true
|
||||
break
|
||||
case 'all':
|
||||
appsApi.selectAll()
|
||||
break
|
||||
case 'none':
|
||||
appsApi.selectNone()
|
||||
break
|
||||
case 'invert':
|
||||
appsApi.invertSelection()
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
// ── 手动添加包名 ───────────────────────────────────────────────────
|
||||
const manualOpen = ref(false)
|
||||
|
||||
async function onManualAdd(pkg) {
|
||||
manualOpen.value = false
|
||||
if (!pkg) return
|
||||
const existing = appsApi.apps.value.find((a) => a.packageName === pkg)
|
||||
if (existing) {
|
||||
existing.checked = true
|
||||
appsApi.reorder()
|
||||
snackbar('已为你自动勾选并置顶')
|
||||
return
|
||||
}
|
||||
appsApi.apps.value.unshift({
|
||||
packageName: pkg,
|
||||
appLabel: '未知 (手动添加)',
|
||||
isSystem: false,
|
||||
uid: '自定义',
|
||||
checked: true,
|
||||
expanded: false,
|
||||
})
|
||||
appsApi.reorder()
|
||||
snackbar('已添加到列表顶部')
|
||||
}
|
||||
|
||||
// ── 虚拟滚动 ───────────────────────────────────────────────────────
|
||||
const listEl = ref(null)
|
||||
const rowVirtualizer = useVirtualizer(
|
||||
computed(() => ({
|
||||
count: filteredApps.value.length,
|
||||
getScrollElement: () => listEl.value,
|
||||
estimateSize: () => 52,
|
||||
estimateSize: () => 64,
|
||||
overscan: 6,
|
||||
})),
|
||||
)
|
||||
@@ -77,391 +109,485 @@ function measureElement(el) {
|
||||
if (el) rowVirtualizer.value.measureElement(el)
|
||||
}
|
||||
|
||||
onMounted(() => load())
|
||||
|
||||
// 关闭下拉菜单 (点击外部)
|
||||
function handleBodyClick() {
|
||||
appsMenuOpen.value = false
|
||||
}
|
||||
|
||||
// 按活动屏蔽
|
||||
// ── 按活动屏蔽 ─────────────────────────────────────────────────────
|
||||
const activityInput = ref('')
|
||||
function doAddActivity() {
|
||||
const val = activityInput.value.trim()
|
||||
if (!val) return
|
||||
const parts = val.split('/')
|
||||
|
||||
function addActivityEntry() {
|
||||
const value = activityInput.value.trim()
|
||||
const parts = value.split('/')
|
||||
if (parts.length !== 2 || !parts[0] || !parts[1]) {
|
||||
showToast('格式错误,请输入 包名/完整活动类名')
|
||||
snackbar('格式错误,请输入 包名/完整活动类名')
|
||||
return
|
||||
}
|
||||
addActivity(val)
|
||||
appsApi.addActivity(value)
|
||||
activityInput.value = ''
|
||||
showToast(`已添加: ${val}`)
|
||||
snackbar(`已添加: ${value}`)
|
||||
}
|
||||
|
||||
function menuToggleSystemApps() {
|
||||
toggleSystemApps()
|
||||
appsMenuOpen.value = false
|
||||
}
|
||||
function menuSelectAll() {
|
||||
selectAll()
|
||||
appsMenuOpen.value = false
|
||||
}
|
||||
function menuSelectNone() {
|
||||
selectNone()
|
||||
appsMenuOpen.value = false
|
||||
}
|
||||
function menuInvertSelection() {
|
||||
invertSelection()
|
||||
appsMenuOpen.value = false
|
||||
}
|
||||
|
||||
// 手动添加包名
|
||||
async function handleManualAdd() {
|
||||
appsMenuOpen.value = false
|
||||
const pkg = prompt('请输入完整应用包名(例如: com.example.app):')
|
||||
if (!pkg?.trim()) return
|
||||
const realPkg = pkg.trim()
|
||||
const existing = apps.value.find((a) => a.packageName === realPkg)
|
||||
if (existing) {
|
||||
existing.checked = true
|
||||
onCheckboxChange()
|
||||
showToast('已为你自动勾选并置顶')
|
||||
return
|
||||
}
|
||||
showToast('正在获取应用信息...')
|
||||
let appData = {
|
||||
packageName: realPkg,
|
||||
appLabel: '未知 (手动添加)',
|
||||
isSystem: false,
|
||||
uid: '自定义',
|
||||
}
|
||||
try {
|
||||
const info = await getPackagesInfo([realPkg])
|
||||
if (info?.length > 0) appData = info[0]
|
||||
} catch {}
|
||||
apps.value.unshift(reactive({ ...appData, checked: true, expanded: false }))
|
||||
onCheckboxChange()
|
||||
showToast('已添加到列表顶部')
|
||||
}
|
||||
|
||||
// Activity Picker
|
||||
const pickerVisible = ref(false)
|
||||
// ── 活动抓取(扫描当前前台 Activity)────────────────────────────────
|
||||
const pickerOpen = ref(false)
|
||||
const pickerStep = ref(1)
|
||||
const pickerStatusText = ref('等待中...')
|
||||
const pickerStatus = ref('等待中...')
|
||||
const pickerPolling = ref(false)
|
||||
const pickerResult = ref('')
|
||||
const pickerDialog = ref(null)
|
||||
let pollingTimer = null
|
||||
|
||||
function openPicker() {
|
||||
stopPolling()
|
||||
async function openPicker() {
|
||||
pickerStep.value = 1
|
||||
pickerStatusText.value = '等待中...'
|
||||
pickerStatus.value = '等待中...'
|
||||
pickerResult.value = ''
|
||||
pickerPolling.value = false
|
||||
pickerVisible.value = true
|
||||
pickerOpen.value = true
|
||||
await nextTick()
|
||||
pickerDialog.value?.show()
|
||||
}
|
||||
|
||||
function closePicker() {
|
||||
stopPolling()
|
||||
pickerVisible.value = false
|
||||
pickerOpen.value = false
|
||||
pickerDialog.value?.close()
|
||||
}
|
||||
|
||||
function stopPolling() {
|
||||
if (pollingTimer) {
|
||||
clearInterval(pollingTimer)
|
||||
pollingTimer = null
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 需要忽略的前台活动:WebUI 自身、系统桌面(切换应用的瞬间会被抓到)、
|
||||
* 输入法、权限弹窗等系统界面。
|
||||
*/
|
||||
const IGNORED_ACTIVITY_PATTERNS = [
|
||||
/webui/i,
|
||||
// 系统桌面(各厂商 launcher)
|
||||
/(^|\.)launcher/i,
|
||||
/com\.android\.systemui/i,
|
||||
/\/com\.android\.internal\.app\.Launcher/i,
|
||||
// 输入法与系统弹窗
|
||||
/\.inputmethod\./i,
|
||||
/com\.android\.permissioncontroller/i,
|
||||
/com\.android\.settings\/com\.android\.settings\.(FallbackHome|Settings)/i,
|
||||
]
|
||||
|
||||
function isIgnoredActivity(activity) {
|
||||
return IGNORED_ACTIVITY_PATTERNS.some((pattern) => pattern.test(activity))
|
||||
}
|
||||
|
||||
function startPolling() {
|
||||
pickerPolling.value = true
|
||||
pickerStatusText.value = '检测中,请切换到目标界面...'
|
||||
pickerStatus.value = '检测中,请切换到目标界面...'
|
||||
stopPolling()
|
||||
pollingTimer = setInterval(async () => {
|
||||
try {
|
||||
const res = await runCmd(
|
||||
`dumpsys window 2>/dev/null | grep mCurrentFocus | sed 's/.*u[0-9][0-9]* //' | sed 's/}.*//'`,
|
||||
)
|
||||
if (res.errno !== 0) return
|
||||
const activity = res.stdout.trim()
|
||||
if (!activity || activity.toLowerCase().includes('webui')) return
|
||||
const res = await fetchFocus()
|
||||
const activity = (res.focus || '').trim()
|
||||
// 空值、WebUI 自身、桌面等系统界面都继续等待
|
||||
if (!activity || isIgnoredActivity(activity)) return
|
||||
stopPolling()
|
||||
pickerPolling.value = false
|
||||
pickerResult.value = activity
|
||||
pickerStep.value = 3
|
||||
} catch {}
|
||||
} catch {
|
||||
/* 忽略单次失败,继续轮询 */
|
||||
}
|
||||
}, 600)
|
||||
}
|
||||
|
||||
function confirmPicker() {
|
||||
if (!pickerResult.value) return
|
||||
addActivity(pickerResult.value)
|
||||
showToast(`已添加: ${pickerResult.value}`)
|
||||
appsApi.addActivity(pickerResult.value)
|
||||
snackbar(`已添加: ${pickerResult.value}`)
|
||||
closePicker()
|
||||
}
|
||||
function retryPicker() {
|
||||
pickerStep.value = 2
|
||||
pickerPolling.value = false
|
||||
stopPolling()
|
||||
}
|
||||
|
||||
onUnmounted(stopPolling)
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div style="display: contents">
|
||||
<section class="card" id="apps-section">
|
||||
<div class="card-header" style="margin-bottom: 8px">
|
||||
<h2>黑名单</h2>
|
||||
<div class="header-actions dropdown-container">
|
||||
<Button variant="ghost" size="icon" @click="load">
|
||||
<RefreshCw :size="18" />
|
||||
</Button>
|
||||
<Button variant="ghost" size="icon" @click="smartSelect">
|
||||
<span class="sr-only">智能选择</span>
|
||||
<Sparkles :size="18" />
|
||||
</Button>
|
||||
<Button variant="ghost" size="icon" @click="appsMenuOpen = !appsMenuOpen">
|
||||
<span class="sr-only">更多</span>
|
||||
<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"
|
||||
>
|
||||
<circle cx="12" cy="12" r="1" />
|
||||
<circle cx="12" cy="5" r="1" />
|
||||
<circle cx="12" cy="19" r="1" />
|
||||
</svg>
|
||||
</Button>
|
||||
<div class="dropdown-menu" :class="{ show: appsMenuOpen }" @click.stop>
|
||||
<div class="dropdown-item" @click="menuToggleSystemApps">
|
||||
<component :is="showingSystemApps ? EyeOff : Eye" :size="18" />
|
||||
<span>{{ showingSystemApps ? '隐藏系统应用' : '显示系统应用' }}</span>
|
||||
</div>
|
||||
<div class="dropdown-item" @click="handleManualAdd">
|
||||
<Plus :size="18" /><span>手动添加包名</span>
|
||||
</div>
|
||||
<div class="dropdown-item" @click="menuSelectAll">
|
||||
<CheckCheck :size="18" /><span>全选</span>
|
||||
</div>
|
||||
<div class="dropdown-item" @click="menuSelectNone">
|
||||
<Square :size="18" /><span>全不选</span>
|
||||
</div>
|
||||
<div class="dropdown-item" @click="menuInvertSelection">
|
||||
<CheckSquare :size="18" /><span>反选</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<section class="section">
|
||||
<div class="section-header">
|
||||
<h2 class="section-title ts-title-md">黑名单</h2>
|
||||
<span
|
||||
v-if="appsApi.unsavedCount.value"
|
||||
class="state-badge is-unsaved"
|
||||
>未保存</span>
|
||||
<ActionMenu :items="menuItems" :disabled="locked" @select="onMenuSelect" />
|
||||
</div>
|
||||
|
||||
<p class="ts-body-sm supporting">
|
||||
被选中的应用在前台时不执行亮度提升。<br />
|
||||
推荐选择视频类、相册等需要展示 HDR 内容的应用。
|
||||
</p>
|
||||
|
||||
<!-- 按活动屏蔽 -->
|
||||
<div class="activity-block">
|
||||
<div class="activity-block__header">
|
||||
<span class="ts-title-sm">按活动屏蔽</span>
|
||||
<md-text-button @click="openPicker">
|
||||
<ScanSearch :size="14" /> 扫描获取
|
||||
</md-text-button>
|
||||
</div>
|
||||
|
||||
<p class="app-list-hint">
|
||||
被选中的应用将不生效本模块<br />推荐选择视频类、相册等需展示 HDR 内容的应用
|
||||
</p>
|
||||
|
||||
<!-- 按活动屏蔽 -->
|
||||
<div class="activity-block-card">
|
||||
<div class="activity-block-header">
|
||||
<span class="activity-block-label">按活动屏蔽</span>
|
||||
<button class="btn-picker-trigger" @click="openPicker">
|
||||
<ScanSearch :size="12" /> 扫描获取
|
||||
</button>
|
||||
</div>
|
||||
<div class="activity-block-row">
|
||||
<input
|
||||
v-model="activityInput"
|
||||
type="text"
|
||||
class="activity-block-input"
|
||||
placeholder="com.pkg/com.pkg.ActivityClass"
|
||||
autocomplete="off"
|
||||
spellcheck="false"
|
||||
@keydown.enter="doAddActivity"
|
||||
/>
|
||||
<Button
|
||||
style="
|
||||
padding: 0 14px;
|
||||
border-radius: var(--border-radius-s);
|
||||
font-size: 0.8125rem;
|
||||
white-space: nowrap;
|
||||
flex-shrink: 0;
|
||||
"
|
||||
@click="doAddActivity"
|
||||
>确认</Button
|
||||
>
|
||||
</div>
|
||||
<div class="activity-block__row">
|
||||
<AppTextField
|
||||
v-model="activityInput"
|
||||
label="com.pkg/com.pkg.ActivityClass"
|
||||
@keydown.enter="addActivityEntry"
|
||||
/>
|
||||
<md-filled-button :disabled="locked" @click="addActivityEntry">确认</md-filled-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">
|
||||
<Search :size="18" class="search-icon" />
|
||||
<input
|
||||
v-model="searchKeyword"
|
||||
type="text"
|
||||
class="app-search-input"
|
||||
placeholder="应用名称或包名"
|
||||
autocomplete="off"
|
||||
spellcheck="false"
|
||||
/>
|
||||
<span class="count-badge">{{ appCount }}</span>
|
||||
</div>
|
||||
<Button
|
||||
style="
|
||||
padding: 0 16px;
|
||||
border-radius: var(--border-radius-s);
|
||||
font-size: 0.8125rem;
|
||||
white-space: nowrap;
|
||||
flex-shrink: 0;
|
||||
"
|
||||
:disabled="oplock.isLocked.value"
|
||||
@click="save(showToast)"
|
||||
>保存</Button
|
||||
>
|
||||
</div>
|
||||
|
||||
<!-- 应用列表 -->
|
||||
<div class="app-list-container" id="app-list-container" ref="listEl">
|
||||
<div
|
||||
v-if="isLoading"
|
||||
style="text-align: center; padding: 20px; color: var(--md-sys-color-on-surface-variant)"
|
||||
>
|
||||
加载中...
|
||||
</div>
|
||||
<div
|
||||
v-else-if="loadError"
|
||||
style="text-align: center; padding: 20px; color: var(--md-sys-color-error)"
|
||||
>
|
||||
加载失败: {{ loadError }}
|
||||
</div>
|
||||
<div v-else class="app-virtual-spacer" :style="{ height: `${totalListHeight}px` }">
|
||||
<div
|
||||
v-for="row in virtualRows"
|
||||
:key="row.app.packageName"
|
||||
:ref="measureElement"
|
||||
:data-index="row.index"
|
||||
class="app-virtual-item"
|
||||
:style="{ transform: `translateY(${row.start}px)` }"
|
||||
>
|
||||
<div class="app-list-item">
|
||||
<div class="app-item-main-row">
|
||||
<label class="app-checkbox-label">
|
||||
<input
|
||||
type="checkbox"
|
||||
class="app-checkbox"
|
||||
:class="{ unsaved: row.app.checked && !savedBlacklist?.has(row.app.packageName) }"
|
||||
:data-pkg="row.app.packageName"
|
||||
v-model="row.app.checked"
|
||||
@change="onCheckboxChange"
|
||||
/>
|
||||
<span
|
||||
class="app-checkbox-custom"
|
||||
:class="{ partial: !row.app.checked && hasActivity(row.app.packageName) }"
|
||||
></span>
|
||||
</label>
|
||||
<div class="app-info">
|
||||
<span class="app-name">
|
||||
{{ row.app.appLabel }}
|
||||
<span class="app-uid">{{ row.app.uid }}</span>
|
||||
</span>
|
||||
<span class="app-pkg">
|
||||
{{ row.app.packageName }}
|
||||
<span v-if="row.app.isSystem" class="app-badge">系统</span>
|
||||
</span>
|
||||
</div>
|
||||
<button
|
||||
v-if="hasActivity(row.app.packageName)"
|
||||
class="app-activities-chevron"
|
||||
:class="{ expanded: row.app.expanded }"
|
||||
@click.stop="row.app.expanded = !row.app.expanded"
|
||||
>
|
||||
<ChevronDown :size="16" />
|
||||
</button>
|
||||
</div>
|
||||
<!-- 活动列表 -->
|
||||
<div
|
||||
v-if="hasActivity(row.app.packageName)"
|
||||
class="app-activities-list"
|
||||
:class="{ show: row.app.expanded }"
|
||||
>
|
||||
<div
|
||||
v-for="entry in getActivities(row.app.packageName)"
|
||||
:key="entry"
|
||||
class="activity-entry-item"
|
||||
>
|
||||
<span class="activity-entry-path">{{ entry.slice(row.app.packageName.length + 1) }}</span>
|
||||
<button class="activity-entry-delete" @click="removeActivity(entry)">
|
||||
<X :size="14" />
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<!-- Activity Picker 覆盖层 -->
|
||||
<Teleport to="body">
|
||||
<div
|
||||
class="activity-picker-overlay"
|
||||
:class="{ show: pickerVisible }"
|
||||
id="activity-picker-overlay"
|
||||
<!-- 搜索 -->
|
||||
<div class="search-row">
|
||||
<md-outlined-text-field
|
||||
:value="appsApi.searchKeyword.value"
|
||||
label="应用名称或包名"
|
||||
autocomplete="off"
|
||||
spellcheck="false"
|
||||
@input="appsApi.searchKeyword.value = $event.target.value"
|
||||
>
|
||||
<div class="activity-picker-header">
|
||||
<button class="picker-back-btn" @click="closePicker">
|
||||
<ChevronLeft :size="20" />
|
||||
</button>
|
||||
<span class="picker-title">获取活动名</span>
|
||||
</div>
|
||||
<div class="picker-steps-indicator">
|
||||
<div
|
||||
v-for="n in 3"
|
||||
:key="n"
|
||||
class="picker-step-dot"
|
||||
:class="{ active: pickerStep === n }"
|
||||
></div>
|
||||
</div>
|
||||
<div class="activity-picker-body">
|
||||
<!-- 步骤 1 -->
|
||||
<div class="picker-step" v-show="pickerStep === 1">
|
||||
<div class="picker-step-icon"><Monitor :size="52" stroke-width="1.5" /></div>
|
||||
<h3 class="picker-step-title">将 Web UI 挂小窗</h3>
|
||||
<p class="picker-step-desc">
|
||||
在开始获取前,请先将当前 Web UI 调整为<strong>小窗模式</strong>。<br /><br />
|
||||
这样在后续步骤中,你可以同时操作目标应用并看到 Web UI 的反馈。
|
||||
</p>
|
||||
<Button class="picker-action-btn" @click="pickerStep = 2">已挂小窗,下一步</Button>
|
||||
</div>
|
||||
<!-- 步骤 2 -->
|
||||
<div class="picker-step" v-show="pickerStep === 2">
|
||||
<div class="picker-step-icon"><Clock :size="52" stroke-width="1.5" /></div>
|
||||
<h3 class="picker-step-title">切换到目标界面</h3>
|
||||
<p class="picker-step-desc">
|
||||
切换到需要屏蔽的应用界面,并点击 「开始获取」<br /><br />
|
||||
检测到非 Web UI 界面后将<strong>自动停止</strong>。<br /><br />
|
||||
<span class="picker-status-text" :class="{ polling: pickerPolling }">{{
|
||||
pickerStatusText
|
||||
}}</span>
|
||||
</p>
|
||||
<Button class="picker-action-btn" :disabled="pickerPolling" @click="startPolling"
|
||||
>开始获取</Button
|
||||
>
|
||||
</div>
|
||||
<!-- 步骤 3 -->
|
||||
<div class="picker-step" v-show="pickerStep === 3">
|
||||
<div class="picker-step-icon">
|
||||
<CircleCheck :size="52" stroke-width="1.5" />
|
||||
<Search slot="leading-icon" :size="18" />
|
||||
</md-outlined-text-field>
|
||||
<md-filled-button :disabled="locked" @click="appsApi.save(snackbar)">
|
||||
<Save :size="16" /> 保存
|
||||
</md-filled-button>
|
||||
</div>
|
||||
|
||||
<div class="count-row ts-body-sm supporting">
|
||||
<span>共 {{ appCount }} 个应用</span>
|
||||
<span v-if="appsApi.isLoading.value">加载中…</span>
|
||||
</div>
|
||||
|
||||
<!-- 应用列表(虚拟滚动) -->
|
||||
<div ref="listEl" class="app-list scroll-area">
|
||||
<div v-if="appsApi.isLoading.value" class="empty-state">加载中…</div>
|
||||
<div v-else-if="appsApi.loadError.value" class="empty-state error">
|
||||
加载失败: {{ appsApi.loadError.value }}
|
||||
</div>
|
||||
<div v-else-if="appCount === 0" class="empty-state">没有匹配的应用</div>
|
||||
<div
|
||||
v-else
|
||||
class="app-virtual-spacer"
|
||||
:style="{ height: `${totalListHeight}px` }"
|
||||
>
|
||||
<div
|
||||
v-for="row in virtualRows"
|
||||
:key="row.app.packageName"
|
||||
:ref="measureElement"
|
||||
:data-index="row.index"
|
||||
class="app-virtual-item"
|
||||
:style="{ transform: `translateY(${row.start}px)` }"
|
||||
>
|
||||
<div class="app-row">
|
||||
<div class="app-row__main">
|
||||
<md-checkbox
|
||||
:checked="row.app.checked"
|
||||
:class="{
|
||||
'is-unsaved':
|
||||
row.app.checked && !appsApi.savedBlacklist.value.has(row.app.packageName),
|
||||
}"
|
||||
@change="row.app.checked = $event.target.checked; appsApi.reorder()"
|
||||
></md-checkbox>
|
||||
<div class="app-row__text" @click="row.app.checked = !row.app.checked; appsApi.reorder()">
|
||||
<span class="app-row__name">
|
||||
{{ row.app.appLabel }}
|
||||
<span class="app-row__uid ts-body-sm supporting">{{ row.app.uid }}</span>
|
||||
</span>
|
||||
<span class="app-row__pkg ts-body-sm supporting">
|
||||
{{ row.app.packageName }}
|
||||
<span v-if="row.app.isSystem" class="app-row__badge">系统</span>
|
||||
</span>
|
||||
</div>
|
||||
<md-icon-button
|
||||
v-if="appsApi.hasActivity(row.app.packageName)"
|
||||
:title="row.app.expanded ? '收起活动' : '展开活动'"
|
||||
@click="row.app.expanded = !row.app.expanded"
|
||||
>
|
||||
<ChevronDown :size="18" :class="['chevron', { open: row.app.expanded }]" />
|
||||
</md-icon-button>
|
||||
</div>
|
||||
<h3 class="picker-step-title">检测到活动</h3>
|
||||
<p class="picker-step-desc">以下活动将被添加到按活动屏蔽列表:</p>
|
||||
<div class="picker-result-box">{{ pickerResult }}</div>
|
||||
<div class="picker-result-actions">
|
||||
<Button variant="secondary" @click="retryPicker">重试</Button>
|
||||
<Button @click="confirmPicker"><Check :size="15" /> 确认添加</Button>
|
||||
|
||||
<div v-if="appsApi.hasActivity(row.app.packageName)" class="app-row__activities" :class="{ open: row.app.expanded }">
|
||||
<div
|
||||
v-for="entry in appsApi.getActivities(row.app.packageName)"
|
||||
:key="entry"
|
||||
class="activity-entry"
|
||||
>
|
||||
<span class="activity-entry__path ts-body-sm mono">
|
||||
{{ entry.slice(row.app.packageName.length + 1) }}
|
||||
</span>
|
||||
<md-icon-button title="移除" @click="appsApi.removeActivity(entry)">
|
||||
<X :size="16" />
|
||||
</md-icon-button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</Teleport>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<PromptDialog
|
||||
:open="manualOpen"
|
||||
headline="手动添加包名"
|
||||
label="应用包名"
|
||||
description="例如 com.example.app;若该应用不在列表中,将直接加入黑名单。"
|
||||
confirm-text="添加"
|
||||
@confirm="onManualAdd"
|
||||
@cancel="manualOpen = false"
|
||||
/>
|
||||
|
||||
<!-- 活动抓取向导 -->
|
||||
<md-dialog ref="pickerDialog" @closed="pickerOpen = false">
|
||||
<div slot="headline">
|
||||
<span class="picker-headline">
|
||||
<md-icon-button @click="closePicker"><ChevronLeft :size="20" /></md-icon-button>
|
||||
获取活动名
|
||||
</span>
|
||||
</div>
|
||||
<div slot="content" class="picker-content">
|
||||
<div v-if="pickerStep === 1" class="picker-step">
|
||||
<Monitor :size="48" :stroke-width="1.5" />
|
||||
<h3 class="ts-title-md">将 Web UI 挂为小窗</h3>
|
||||
<p class="ts-body supporting">
|
||||
开始之前先把当前 Web UI 切到小窗模式,这样后续可以一边操作目标应用,一边看到这里的反馈。
|
||||
</p>
|
||||
<md-filled-button @click="pickerStep = 2">已挂小窗,下一步</md-filled-button>
|
||||
</div>
|
||||
|
||||
<div v-else-if="pickerStep === 2" class="picker-step">
|
||||
<Clock :size="48" :stroke-width="1.5" />
|
||||
<h3 class="ts-title-md">切换到目标界面</h3>
|
||||
<p class="ts-body supporting">
|
||||
切换到需要屏蔽的应用界面,然后点击「开始获取」。检测到非 Web UI 界面后会自动停止。
|
||||
</p>
|
||||
<p class="ts-body" :class="{ 'pulse-text': pickerPolling }">{{ pickerStatus }}</p>
|
||||
<md-filled-button :disabled="pickerPolling" @click="startPolling">开始获取</md-filled-button>
|
||||
</div>
|
||||
|
||||
<div v-else class="picker-step">
|
||||
<CircleCheck :size="48" :stroke-width="1.5" />
|
||||
<h3 class="ts-title-md">检测到活动</h3>
|
||||
<p class="ts-body supporting">以下活动将被添加到按活动屏蔽列表:</p>
|
||||
<code class="picker-result ts-body mono">{{ pickerResult }}</code>
|
||||
</div>
|
||||
</div>
|
||||
<div slot="actions">
|
||||
<md-text-button v-if="pickerStep === 3" @click="pickerStep = 2; pickerPolling = false">
|
||||
重试
|
||||
</md-text-button>
|
||||
<md-filled-button v-if="pickerStep === 3" @click="confirmPicker">
|
||||
<Check :size="16" /> 确认添加
|
||||
</md-filled-button>
|
||||
</div>
|
||||
</md-dialog>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.activity-block {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: var(--md-sys-spacing-2);
|
||||
padding: var(--md-sys-spacing-3);
|
||||
border-radius: var(--md-sys-shape-corner-medium);
|
||||
background-color: var(--md-sys-color-surface-container);
|
||||
}
|
||||
|
||||
.activity-block__header {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: var(--md-sys-spacing-2);
|
||||
}
|
||||
|
||||
.activity-block__row,
|
||||
.search-row {
|
||||
display: flex;
|
||||
align-items: flex-start;
|
||||
gap: var(--md-sys-spacing-2);
|
||||
}
|
||||
|
||||
.activity-block__row > :first-child,
|
||||
.search-row > :first-child {
|
||||
flex: 1;
|
||||
}
|
||||
|
||||
.activity-block__row > md-filled-button,
|
||||
.search-row > md-filled-button {
|
||||
flex: 0 0 auto;
|
||||
margin-top: 4px;
|
||||
}
|
||||
|
||||
.count-row {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
}
|
||||
|
||||
.app-list {
|
||||
max-height: 60vh;
|
||||
overflow-y: auto;
|
||||
border-radius: var(--md-sys-shape-corner-medium);
|
||||
}
|
||||
|
||||
.app-virtual-spacer {
|
||||
position: relative;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.app-virtual-item {
|
||||
position: absolute;
|
||||
top: 0;
|
||||
left: 0;
|
||||
width: 100%;
|
||||
padding-bottom: var(--md-sys-spacing-2);
|
||||
}
|
||||
|
||||
.app-row {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
border-radius: var(--md-sys-shape-corner-medium);
|
||||
background-color: var(--md-sys-color-surface-container);
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.app-row__main {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: var(--md-sys-spacing-2);
|
||||
padding: var(--md-sys-spacing-2) var(--md-sys-spacing-3);
|
||||
min-height: 64px;
|
||||
}
|
||||
|
||||
/* 选中但尚未保存:绿色提示;保存后回到默认主色 */
|
||||
md-checkbox.is-unsaved {
|
||||
--md-checkbox-selected-container-color: var(--lp-color-success);
|
||||
--md-checkbox-selected-hover-container-color: var(--lp-color-success);
|
||||
--md-checkbox-selected-focus-container-color: var(--lp-color-success);
|
||||
--md-checkbox-selected-pressed-container-color: var(--lp-color-success);
|
||||
--md-checkbox-selected-hover-state-layer-color: var(--lp-color-success);
|
||||
--md-checkbox-selected-pressed-state-layer-color: var(--lp-color-success);
|
||||
--md-checkbox-selected-icon-color: var(--md-sys-color-surface);
|
||||
--md-checkbox-selected-hover-icon-color: var(--md-sys-color-surface);
|
||||
--md-checkbox-selected-focus-icon-color: var(--md-sys-color-surface);
|
||||
--md-checkbox-selected-pressed-icon-color: var(--md-sys-color-surface);
|
||||
}
|
||||
|
||||
/* 名称/包名区域也可点击切换(复选框本身只有 18px,触控偏小) */
|
||||
.app-row__text {
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 2px;
|
||||
cursor: pointer;
|
||||
padding: var(--md-sys-spacing-1) 0;
|
||||
}
|
||||
|
||||
.app-row__name {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 6px;
|
||||
color: var(--md-sys-color-on-surface);
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.app-row__uid {
|
||||
flex: 0 0 auto;
|
||||
}
|
||||
|
||||
.app-row__pkg {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 6px;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.app-row__badge {
|
||||
flex: 0 0 auto;
|
||||
padding: 1px 6px;
|
||||
border-radius: var(--md-sys-shape-corner-full);
|
||||
background-color: var(--md-sys-color-surface-container-highest);
|
||||
font-size: var(--md-sys-typescale-label-small-size);
|
||||
}
|
||||
|
||||
.chevron {
|
||||
transition: transform var(--md-sys-motion-duration-short4)
|
||||
var(--md-sys-motion-easing-standard);
|
||||
}
|
||||
|
||||
.chevron.open {
|
||||
transform: rotate(180deg);
|
||||
}
|
||||
|
||||
.app-row__activities {
|
||||
max-height: 0;
|
||||
overflow: hidden;
|
||||
transition: max-height var(--md-sys-motion-duration-medium2)
|
||||
var(--md-sys-motion-easing-emphasized);
|
||||
}
|
||||
|
||||
.app-row__activities.open {
|
||||
max-height: 320px;
|
||||
overflow-y: auto;
|
||||
}
|
||||
|
||||
.activity-entry {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: var(--md-sys-spacing-2);
|
||||
padding: 2px var(--md-sys-spacing-2) 2px var(--md-sys-spacing-4);
|
||||
border-top: 1px solid var(--md-sys-color-outline-variant);
|
||||
}
|
||||
|
||||
.activity-entry__path {
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
color: var(--md-sys-color-on-surface-variant);
|
||||
}
|
||||
|
||||
.picker-headline {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: var(--md-sys-spacing-2);
|
||||
}
|
||||
|
||||
.picker-content {
|
||||
min-width: min(320px, 76vw);
|
||||
}
|
||||
|
||||
.picker-step {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
gap: var(--md-sys-spacing-3);
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.picker-step h3 {
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.picker-step p {
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.picker-result {
|
||||
display: block;
|
||||
width: 100%;
|
||||
padding: var(--md-sys-spacing-3);
|
||||
border-radius: var(--md-sys-shape-corner-small);
|
||||
background-color: var(--md-sys-color-surface-container-high);
|
||||
word-break: break-all;
|
||||
text-align: left;
|
||||
}
|
||||
</style>
|
||||
+357
-395
@@ -1,430 +1,392 @@
|
||||
<script setup>
|
||||
import { inject, ref } from 'vue'
|
||||
import Button from '@/components/ui/Button.vue'
|
||||
import Input from '@/components/ui/Input.vue'
|
||||
import Textarea from '@/components/ui/Textarea.vue'
|
||||
import Switch from '@/components/ui/Switch.vue'
|
||||
import Label from '@/components/ui/Label.vue'
|
||||
import {
|
||||
Save,
|
||||
Settings2,
|
||||
ShieldCheck,
|
||||
FileText,
|
||||
Settings,
|
||||
Monitor,
|
||||
HelpCircle,
|
||||
ChevronDown,
|
||||
} from 'lucide-vue-next'
|
||||
import { runCmd } from '../utils.js'
|
||||
import { inject, ref, computed, nextTick } from 'vue'
|
||||
import { Save, RotateCcw, Settings2, ShieldCheck, Wrench, Palette, ChevronDown, ListTree } from 'lucide-vue-next'
|
||||
import AppTextField from '../components/AppTextField.vue'
|
||||
import AppSwitch from '../components/AppSwitch.vue'
|
||||
import ConfirmDialog from '../components/ConfirmDialog.vue'
|
||||
|
||||
const config = inject('config')
|
||||
const showToast = inject('showToast')
|
||||
const restartRefresh = inject('restartRefresh')
|
||||
const oplock = inject('oplock')
|
||||
const prefs = inject('prefs')
|
||||
const status = inject('status')
|
||||
const snackbar = inject('snackbar')
|
||||
|
||||
const form = config.form
|
||||
const locked = computed(() => status.oplock.value.locked)
|
||||
|
||||
const advancedOpen = ref(false)
|
||||
const webuiOpen = ref(false)
|
||||
const resetOpen = ref(false)
|
||||
const helpOpen = ref(false)
|
||||
const helpDialog = ref(null)
|
||||
|
||||
// 恢复默认二次确认
|
||||
const resetConfirming = ref(false)
|
||||
let resetTimer = null
|
||||
function handleReset() {
|
||||
if (!resetConfirming.value) {
|
||||
resetConfirming.value = true
|
||||
resetTimer = setTimeout(() => {
|
||||
resetConfirming.value = false
|
||||
}, 5000)
|
||||
return
|
||||
}
|
||||
clearTimeout(resetTimer)
|
||||
resetConfirming.value = false
|
||||
config.resetToDefaults(showToast)
|
||||
}
|
||||
|
||||
function setTheme(v) {
|
||||
config.themeMode.value = v
|
||||
config.applyTheme(v)
|
||||
}
|
||||
|
||||
async function viewInotifyHelp() {
|
||||
const msg = `支持的事件字母 (toybox/busybox inotifyd 兼容):
|
||||
a = accessed 读取
|
||||
c = modified 内容修改 (亮度节点推荐用此)
|
||||
const INOTIFY_HELP = `支持的事件字母(与 toybox inotifyd 兼容):
|
||||
a = accessed 读取
|
||||
c = modified 内容修改(亮度节点推荐用此,默认值)
|
||||
e = metadata change 属性变更
|
||||
w = closed (writable) 写入后关闭
|
||||
0 = closed (unwritable) 查看后关闭
|
||||
r = opened 打开
|
||||
n = created 创建
|
||||
d = deleted 删除(目录内)
|
||||
D = deleted (self) 自身被删除
|
||||
M = moved (self) 自身被移动
|
||||
m = moved in 移入目录
|
||||
y = moved out 移出目录
|
||||
u = unmounted 挂载卷卸载
|
||||
* = all events
|
||||
0 = closed (unwritable) 只读打开后关闭
|
||||
r = opened 打开
|
||||
n = created 创建
|
||||
d = deleted 删除(目录内)
|
||||
D = deleted (self) 自身被删除
|
||||
M = moved (self) 自身被移动
|
||||
m = moved in 移入目录
|
||||
y = moved out 移出目录
|
||||
u = unmounted 挂载卷卸载
|
||||
* = all events 全部事件`
|
||||
|
||||
提示: sysfs 亮度节点使用 c (MODIFY),这也是默认值`
|
||||
alert(msg)
|
||||
async function openHelp() {
|
||||
helpOpen.value = true
|
||||
await nextTick()
|
||||
helpDialog.value?.show()
|
||||
}
|
||||
|
||||
function handleSaveWebUI() {
|
||||
config.saveWebUIConfig(
|
||||
showToast,
|
||||
config.autoRefresh.value,
|
||||
config.statusRefreshInterval.value,
|
||||
config.uiZoom.value,
|
||||
config.themeMode.value,
|
||||
restartRefresh,
|
||||
)
|
||||
function closeHelp() {
|
||||
helpDialog.value?.close()
|
||||
helpOpen.value = false
|
||||
}
|
||||
|
||||
// ── 定时休眠:HHMM 起止时间 ────────────────────────────────────────
|
||||
const sleepStart = computed(() => config.sleepParts.value[0] + config.sleepParts.value[1])
|
||||
const sleepEnd = computed(() => config.sleepParts.value[2] + config.sleepParts.value[3])
|
||||
|
||||
function updateSleep(which, value) {
|
||||
const digits = String(value).replace(/\D/g, '').slice(0, 4)
|
||||
const parts = [...config.sleepParts.value]
|
||||
if (which === 'start') {
|
||||
parts[0] = digits.slice(0, 2)
|
||||
parts[1] = digits.slice(2)
|
||||
} else {
|
||||
parts[2] = digits.slice(0, 2)
|
||||
parts[3] = digits.slice(2)
|
||||
}
|
||||
form.sleep_time = `${parts[0].padEnd(2, '0')}${parts[1].padEnd(2, '0')}-${parts[2].padEnd(2, '0')}${parts[3].padEnd(2, '0')}`
|
||||
}
|
||||
|
||||
// ── Web UI 偏好(localStorage,不写模块配置)────────────────────────
|
||||
const webuiForm = ref({
|
||||
autoRefresh: prefs.autoRefresh.value,
|
||||
refreshInterval: String(prefs.refreshInterval.value),
|
||||
zoom: String(prefs.zoom.value),
|
||||
themeMode: prefs.themeMode.value,
|
||||
})
|
||||
|
||||
const webuiDirty = computed(
|
||||
() =>
|
||||
webuiForm.value.autoRefresh !== prefs.autoRefresh.value ||
|
||||
Number(webuiForm.value.refreshInterval) !== prefs.refreshInterval.value ||
|
||||
Number(webuiForm.value.zoom) !== prefs.zoom.value ||
|
||||
webuiForm.value.themeMode !== prefs.themeMode.value,
|
||||
)
|
||||
|
||||
function saveWebUI() {
|
||||
prefs.save(webuiForm.value)
|
||||
webuiForm.value.refreshInterval = String(prefs.refreshInterval.value)
|
||||
webuiForm.value.zoom = String(prefs.zoom.value)
|
||||
snackbar('Web UI 配置已保存')
|
||||
}
|
||||
|
||||
async function confirmReset() {
|
||||
resetOpen.value = false
|
||||
await config.restoreBackup(snackbar)
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div style="display: contents">
|
||||
<!-- === 亮度配置 === -->
|
||||
<section class="card" id="config-section" data-nav-group="config">
|
||||
<div class="card-header">
|
||||
<h2>亮度配置</h2>
|
||||
<span class="save-badge" :class="config.dirty.value ? 'unsaved' : 'saved'">
|
||||
{{ config.dirty.value ? '未保存' : '已保存' }}
|
||||
</span>
|
||||
<!-- ── 亮度配置 ─────────────────────────────────────────────── -->
|
||||
<section class="section">
|
||||
<div class="section-header">
|
||||
<h2 class="section-title ts-title-md">亮度配置</h2>
|
||||
<span class="state-badge" :class="config.dirtyMain.value ? 'is-unsaved' : 'is-saved'">
|
||||
{{ config.dirtyMain.value ? '未保存' : '已保存' }}
|
||||
</span>
|
||||
</div>
|
||||
|
||||
<div class="group-title ts-title-sm supporting">
|
||||
<Settings2 :size="16" aria-hidden="true" /> 亮度调节
|
||||
</div>
|
||||
<AppTextField v-model="form.ui_max_bri" type="number" min="0" label="前台最大亮度"
|
||||
supporting-text="触发亮度提升的阈值" />
|
||||
<AppTextField v-model="form.max_bri" type="number" min="0" label="峰值最大亮度"
|
||||
supporting-text="亮度提升的目标值" />
|
||||
<AppTextField v-model="form.steps_num" type="number" min="1" max="500" label="亮度提升步数"
|
||||
supporting-text="每步约 0.02 秒" />
|
||||
|
||||
<md-divider></md-divider>
|
||||
|
||||
<div class="group-title ts-title-sm supporting">
|
||||
<ShieldCheck :size="16" aria-hidden="true" /> 执行策略
|
||||
</div>
|
||||
<AppSwitch v-model="config.sleepEnabled.value" name="定时休眠" support="设定时段内不提升亮度" />
|
||||
<div class="collapse collapse--gap" :class="{ open: config.sleepEnabled.value }">
|
||||
<div class="sleep-row">
|
||||
<AppTextField
|
||||
:model-value="sleepStart"
|
||||
label="开始 (HHMM)"
|
||||
@update:model-value="updateSleep('start', $event)"
|
||||
/>
|
||||
<AppTextField
|
||||
:model-value="sleepEnd"
|
||||
label="结束 (HHMM)"
|
||||
@update:model-value="updateSleep('end', $event)"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
<AppSwitch v-model="config.autoBriSleep.value" name="自动亮度时休眠" support="系统自动亮度开启时不提升" />
|
||||
<AppSwitch
|
||||
v-model="config.displayHdrSleep.value"
|
||||
name="显示 HDR 内容时休眠"
|
||||
support="比率 ≥ 进入阈值休眠,≤ 退出阈值恢复"
|
||||
/>
|
||||
<div class="collapse collapse--gap" :class="{ open: config.displayHdrSleep.value }">
|
||||
<div class="sleep-row">
|
||||
<AppTextField
|
||||
v-model="form.hdr_enter_ratio"
|
||||
type="number"
|
||||
step="0.01"
|
||||
min="1"
|
||||
max="5"
|
||||
label="进入阈值"
|
||||
supporting-text="≥ 该比率时休眠"
|
||||
/>
|
||||
<AppTextField
|
||||
v-model="form.hdr_exit_ratio"
|
||||
type="number"
|
||||
step="0.01"
|
||||
min="1"
|
||||
max="5"
|
||||
label="退出阈值"
|
||||
supporting-text="≤ 该比率时恢复"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
<AppSwitch
|
||||
v-model="config.compatibilityMode.value"
|
||||
name="兼容模式(轮询驱动)"
|
||||
support="不使用事件监听,改为 2 秒一次轮询"
|
||||
warning="仅在事件驱动失效时开启,会略微增加耗电"
|
||||
/>
|
||||
|
||||
<div class="config-group">
|
||||
<h3 class="group-title"><Settings2 :size="16" /> 亮度调节</h3>
|
||||
<div class="actions">
|
||||
<md-outlined-button :disabled="locked" @click="resetOpen = true">
|
||||
<RotateCcw :size="16" /> 恢复默认
|
||||
</md-outlined-button>
|
||||
<md-filled-button
|
||||
:disabled="locked || !config.dirtyMain.value"
|
||||
@click="config.saveMain(snackbar)"
|
||||
>
|
||||
<Save :size="16" /> 保存配置
|
||||
</md-filled-button>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<div class="config-item">
|
||||
<div class="config-label">
|
||||
<span class="config-name">前台最大亮度</span>
|
||||
<span class="config-desc">触发亮度提升的阈值</span>
|
||||
</div>
|
||||
<Input v-model="config.uiMaxBri.value" type="number" min="0" class="config-input" />
|
||||
<!-- ── 高级设置 ─────────────────────────────────────────────── -->
|
||||
<section class="section">
|
||||
<button class="section-header toggle" @click="advancedOpen = !advancedOpen">
|
||||
<h2 class="section-title ts-title-md">高级设置</h2>
|
||||
<span class="state-badge" :class="config.dirtyAdvanced.value ? 'is-unsaved' : 'is-saved'">
|
||||
{{ config.dirtyAdvanced.value ? '未保存' : '已保存' }}
|
||||
</span>
|
||||
<ChevronDown :size="18" class="chevron" :class="{ open: advancedOpen }" />
|
||||
</button>
|
||||
|
||||
<div class="collapse collapse--gap" :class="{ open: advancedOpen }">
|
||||
<div class="collapse-inner">
|
||||
<div class="group-title ts-title-sm supporting">
|
||||
<Wrench :size="16" aria-hidden="true" /> 运行环境
|
||||
</div>
|
||||
|
||||
<div class="config-item">
|
||||
<div class="config-label">
|
||||
<span class="config-name">峰值最大亮度</span>
|
||||
<span class="config-desc">亮度提升的目标值</span>
|
||||
</div>
|
||||
<Input v-model="config.maxBri.value" type="number" min="0" class="config-input" />
|
||||
</div>
|
||||
|
||||
<div class="config-item">
|
||||
<div class="config-label">
|
||||
<span class="config-name">亮度提升步数</span>
|
||||
<span class="config-desc">约 0.02 秒 / 步</span>
|
||||
</div>
|
||||
<Input
|
||||
v-model="config.stepsNum.value"
|
||||
type="number"
|
||||
min="1"
|
||||
max="500"
|
||||
class="config-input"
|
||||
<AppSwitch
|
||||
v-model="config.debugMode.value"
|
||||
name="调试模式"
|
||||
support="记录详细事件到日志"
|
||||
warning="需重启模块生效,用完请关闭"
|
||||
/>
|
||||
<div class="field-row">
|
||||
<AppTextField
|
||||
v-model="form.inotify_events"
|
||||
label="监听事件"
|
||||
supporting-text="默认 c,改后需重启模块"
|
||||
/>
|
||||
<md-text-button @click="openHelp">
|
||||
<ListTree :size="16" /> 支持的事件
|
||||
</md-text-button>
|
||||
</div>
|
||||
</div>
|
||||
<AppTextField
|
||||
v-model="form.now_bri_file"
|
||||
label="当前亮度节点"
|
||||
supporting-text="改后需重启模块"
|
||||
/>
|
||||
<AppTextField
|
||||
v-model="form.max_bri_file"
|
||||
label="最大亮度节点"
|
||||
supporting-text="改后需重启模块"
|
||||
/>
|
||||
|
||||
<div class="config-group">
|
||||
<h3 class="group-title"><ShieldCheck :size="16" /> 执行策略</h3>
|
||||
<md-divider></md-divider>
|
||||
|
||||
<div class="config-item">
|
||||
<div class="config-label">
|
||||
<span class="config-name">自动亮度时休眠</span>
|
||||
<span class="config-desc">开启自动亮度时不提升</span>
|
||||
</div>
|
||||
<Switch v-model="config.autoBriSleep.value" />
|
||||
<div class="group-title ts-title-sm supporting">
|
||||
<Settings2 :size="16" aria-hidden="true" /> 系统管理
|
||||
</div>
|
||||
|
||||
<div class="config-item">
|
||||
<div class="config-label">
|
||||
<span class="config-name">显示 HDR 内容时休眠</span>
|
||||
<span class="config-desc">比率 ≥ 进入阈值休眠,≤ 退出阈值恢复</span>
|
||||
<span class="config-desc" style="color: var(--color-warning)"
|
||||
>出现闪屏建议改用黑名单</span
|
||||
>
|
||||
</div>
|
||||
<Switch v-model="config.displayHdrSleep.value" />
|
||||
</div>
|
||||
|
||||
<div class="config-item-expand" :class="{ show: config.displayHdrSleep.value }">
|
||||
<div class="custom-time-picker">
|
||||
<div class="time-unit">
|
||||
<input
|
||||
type="number"
|
||||
v-model="config.hdrEnterRatio.value"
|
||||
class="time-input time-input-wide"
|
||||
min="1"
|
||||
max="5"
|
||||
step="0.01"
|
||||
autocomplete="off"
|
||||
/>
|
||||
<span class="time-sep">进入</span>
|
||||
</div>
|
||||
<div class="time-unit">
|
||||
<input
|
||||
type="number"
|
||||
v-model="config.hdrExitRatio.value"
|
||||
class="time-input time-input-wide"
|
||||
min="1"
|
||||
max="5"
|
||||
step="0.01"
|
||||
autocomplete="off"
|
||||
/>
|
||||
<span class="time-sep">退出</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="config-item">
|
||||
<div class="config-label">
|
||||
<span class="config-name">兼容模式 (轮询驱动)</span>
|
||||
<span class="config-desc">不使用事件监听,改用 2 秒一次轮询</span>
|
||||
<span class="config-desc" style="color: var(--color-warning)"
|
||||
>仅在事件驱动失效时开启,会略微增加耗电</span
|
||||
>
|
||||
</div>
|
||||
<Switch v-model="config.compatibilityMode.value" />
|
||||
</div>
|
||||
|
||||
<div class="config-item">
|
||||
<div class="config-label">
|
||||
<span class="config-name">定时休眠</span>
|
||||
<span class="config-desc">设定时段内不提升亮度</span>
|
||||
</div>
|
||||
<Switch v-model="config.sleepMode.value" />
|
||||
</div>
|
||||
|
||||
<div class="config-item-expand" :class="{ show: config.sleepMode.value }">
|
||||
<div class="custom-time-picker">
|
||||
<div class="time-unit">
|
||||
<input
|
||||
type="number"
|
||||
v-model="config.sleepStartH.value"
|
||||
class="time-input"
|
||||
min="0"
|
||||
max="23"
|
||||
placeholder="00"
|
||||
/>
|
||||
<span>:</span>
|
||||
<input
|
||||
type="number"
|
||||
v-model="config.sleepStartM.value"
|
||||
class="time-input"
|
||||
min="0"
|
||||
max="59"
|
||||
placeholder="00"
|
||||
/>
|
||||
</div>
|
||||
<span class="time-sep">至</span>
|
||||
<div class="time-unit">
|
||||
<input
|
||||
type="number"
|
||||
v-model="config.sleepEndH.value"
|
||||
class="time-input"
|
||||
min="0"
|
||||
max="23"
|
||||
placeholder="00"
|
||||
/>
|
||||
<span>:</span>
|
||||
<input
|
||||
type="number"
|
||||
v-model="config.sleepEndM.value"
|
||||
class="time-input"
|
||||
min="0"
|
||||
max="59"
|
||||
placeholder="00"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="card-actions">
|
||||
<Button
|
||||
variant="outline"
|
||||
:disabled="oplock.isLocked.value"
|
||||
@click="handleReset"
|
||||
:class="resetConfirming ? 'border-destructive text-destructive' : ''"
|
||||
<AppTextField
|
||||
v-model="form.log_max_size"
|
||||
type="number"
|
||||
min="1"
|
||||
max="10240"
|
||||
label="日志大小限制 (KB)"
|
||||
/>
|
||||
<md-outlined-select
|
||||
label="日志等级"
|
||||
supporting-text="低于此级别不写入日志"
|
||||
:value="form.log_level"
|
||||
@change="form.log_level = $event.target.value"
|
||||
>
|
||||
{{ resetConfirming ? '确认恢复?' : '恢复默认' }}
|
||||
</Button>
|
||||
<Button :disabled="oplock.isLocked.value" @click="config.save(showToast)">
|
||||
<Save :size="15" /> 保存配置
|
||||
</Button>
|
||||
</div>
|
||||
</section>
|
||||
<md-select-option value="off"><div slot="headline">关闭</div></md-select-option>
|
||||
<md-select-option value="error"><div slot="headline">仅错误</div></md-select-option>
|
||||
<md-select-option value="warn"><div slot="headline">警告+</div></md-select-option>
|
||||
<md-select-option value="info"><div slot="headline">全部</div></md-select-option>
|
||||
</md-outlined-select>
|
||||
|
||||
<!-- === 高级设置 === -->
|
||||
<section class="card" id="advanced-section" data-nav-group="config">
|
||||
<div class="card-header card-header-toggle" @click="advancedOpen = !advancedOpen">
|
||||
<h2>高级设置</h2>
|
||||
<span class="save-badge" :class="config.dirtyAdvanced.value ? 'unsaved' : 'saved'">
|
||||
{{ config.dirtyAdvanced.value ? '未保存' : '已保存' }}
|
||||
</span>
|
||||
<ChevronDown :size="18" class="collapse-chevron" :class="{ open: advancedOpen }" />
|
||||
</div>
|
||||
<div class="collapsible-body" :class="{ open: advancedOpen }">
|
||||
<div>
|
||||
<div class="config-group">
|
||||
<h3 class="group-title"><Settings :size="16" /> 运行环境</h3>
|
||||
|
||||
<div class="config-item">
|
||||
<div class="config-label">
|
||||
<span class="config-name">调试模式</span>
|
||||
<span class="config-desc">记录详细 inotify 事件到日志</span>
|
||||
<span class="config-desc" style="color: var(--color-warning)"
|
||||
>需重启模块生效,用完请关闭</span
|
||||
>
|
||||
</div>
|
||||
<Switch v-model="config.debugMode.value" />
|
||||
</div>
|
||||
|
||||
<div class="config-item">
|
||||
<div class="config-label">
|
||||
<span class="config-name">监听事件</span>
|
||||
<span class="config-desc">默认 c,改后需重启模块</span>
|
||||
<button
|
||||
class="btn-text-s"
|
||||
style="margin-top: 6px; padding: 2px 6px"
|
||||
@click="viewInotifyHelp"
|
||||
>
|
||||
查看支持事件
|
||||
</button>
|
||||
</div>
|
||||
<Input
|
||||
v-model="config.inotifyEvents.value"
|
||||
type="text"
|
||||
placeholder="c"
|
||||
class="config-input"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div class="config-item" id="advanced-section">
|
||||
<div class="config-label">
|
||||
<span class="config-name">当前亮度节点</span>
|
||||
<span class="config-desc">改后需重启模块</span>
|
||||
</div>
|
||||
<Textarea v-model="config.nowBriFile.value" class="config-textarea" />
|
||||
</div>
|
||||
|
||||
<div class="config-item">
|
||||
<div class="config-label">
|
||||
<span class="config-name">最大亮度节点</span>
|
||||
<span class="config-desc">改后需重启模块</span>
|
||||
</div>
|
||||
<Textarea v-model="config.sysMaxBriFile.value" class="config-textarea" />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="config-group">
|
||||
<h3 class="group-title"><FileText :size="16" /> 系统管理</h3>
|
||||
<div class="config-item">
|
||||
<div class="config-label">
|
||||
<span class="config-name">日志大小限制</span>
|
||||
<span class="config-desc">单位: KB</span>
|
||||
</div>
|
||||
<Input
|
||||
v-model="config.logMaxSize.value"
|
||||
type="number"
|
||||
min="1"
|
||||
max="10240"
|
||||
class="config-input"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div class="config-item">
|
||||
<div class="config-label">
|
||||
<span class="config-name">日志等级</span>
|
||||
<span class="config-desc">低于此级别不写入日志</span>
|
||||
</div>
|
||||
<select v-model="config.logLevel.value" class="config-select">
|
||||
<option value="off">关闭</option>
|
||||
<option value="error">仅错误</option>
|
||||
<option value="warn">警告+</option>
|
||||
<option value="info">全部</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="card-actions">
|
||||
<Button
|
||||
:disabled="oplock.isLocked.value"
|
||||
@click="config.saveAdvanced(showToast, () => {})"
|
||||
>
|
||||
<Save :size="15" /> 保存设置
|
||||
</Button>
|
||||
</div>
|
||||
<div class="actions">
|
||||
<md-filled-button
|
||||
:disabled="locked || !config.dirtyAdvanced.value"
|
||||
@click="config.saveAdvanced(snackbar)"
|
||||
>
|
||||
<Save :size="16" /> 保存设置
|
||||
</md-filled-button>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<!-- === Web UI 配置 === -->
|
||||
<section class="card" id="webui-config-section" data-nav-group="config">
|
||||
<div class="card-header card-header-toggle" @click="webuiOpen = !webuiOpen">
|
||||
<h2>Web UI 配置</h2>
|
||||
<ChevronDown :size="18" class="collapse-chevron" :class="{ open: webuiOpen }" />
|
||||
</div>
|
||||
<div class="collapsible-body" :class="{ open: webuiOpen }">
|
||||
<div>
|
||||
<div class="config-group">
|
||||
<h3 class="group-title"><Monitor :size="16" /> 界面设置</h3>
|
||||
<!-- ── Web UI 配置 ──────────────────────────────────────────── -->
|
||||
<section class="section">
|
||||
<button class="section-header toggle" @click="webuiOpen = !webuiOpen">
|
||||
<h2 class="section-title ts-title-md">Web UI 配置</h2>
|
||||
<span class="state-badge" :class="webuiDirty ? 'is-unsaved' : 'is-saved'">
|
||||
{{ webuiDirty ? '未保存' : '已保存' }}
|
||||
</span>
|
||||
<ChevronDown :size="18" class="chevron" :class="{ open: webuiOpen }" />
|
||||
</button>
|
||||
|
||||
<div class="config-item">
|
||||
<div class="config-label">
|
||||
<span class="config-name">自动刷新</span>
|
||||
<span class="config-desc">定时拉取状态和日志</span>
|
||||
</div>
|
||||
<Switch v-model="config.autoRefresh.value" />
|
||||
</div>
|
||||
<div class="collapse collapse--gap" :class="{ open: webuiOpen }">
|
||||
<div class="collapse-inner">
|
||||
<div class="group-title ts-title-sm supporting">
|
||||
<Palette :size="16" aria-hidden="true" /> 界面设置
|
||||
</div>
|
||||
<AppSwitch v-model="webuiForm.autoRefresh" name="自动刷新" support="定时拉取状态与日志" />
|
||||
<AppTextField
|
||||
v-model="webuiForm.refreshInterval"
|
||||
type="number"
|
||||
min="100"
|
||||
label="刷新间隔 (ms)"
|
||||
supporting-text="最小 100"
|
||||
/>
|
||||
<md-outlined-select
|
||||
label="外观主题"
|
||||
:value="webuiForm.themeMode"
|
||||
@change="webuiForm.themeMode = $event.target.value"
|
||||
>
|
||||
<md-select-option value="system"><div slot="headline">跟随系统</div></md-select-option>
|
||||
<md-select-option value="light"><div slot="headline">浅色</div></md-select-option>
|
||||
<md-select-option value="dark"><div slot="headline">深色</div></md-select-option>
|
||||
</md-outlined-select>
|
||||
<AppTextField
|
||||
v-model="webuiForm.zoom"
|
||||
type="number"
|
||||
min="50"
|
||||
max="150"
|
||||
label="界面缩放 (%)"
|
||||
supporting-text="50–150,立即生效"
|
||||
/>
|
||||
|
||||
<div class="config-item" v-show="config.autoRefresh.value">
|
||||
<div class="config-label">
|
||||
<span class="config-name">状态/日志刷新间隔</span>
|
||||
<span class="config-desc">ms,最小 100</span>
|
||||
</div>
|
||||
<Input
|
||||
v-model="config.statusRefreshInterval.value"
|
||||
type="number"
|
||||
min="100"
|
||||
class="config-input"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div class="config-item">
|
||||
<div class="config-label">
|
||||
<span class="config-name">外观主题</span>
|
||||
</div>
|
||||
<select
|
||||
class="config-select"
|
||||
:value="config.themeMode.value"
|
||||
@change="setTheme($event.target.value)"
|
||||
>
|
||||
<option value="system">跟随系统</option>
|
||||
<option value="light">浅色</option>
|
||||
<option value="dark">深色</option>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<div class="config-item">
|
||||
<div class="config-label">
|
||||
<span class="config-name">界面缩放</span>
|
||||
<span class="config-desc">50%–150%,立即生效</span>
|
||||
</div>
|
||||
<Input
|
||||
v-model="config.uiZoom.value"
|
||||
type="number"
|
||||
min="50"
|
||||
max="150"
|
||||
class="config-input"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="card-actions">
|
||||
<Button @click="handleSaveWebUI"> <Save :size="15" /> 保存配置 </Button>
|
||||
</div>
|
||||
<div class="actions">
|
||||
<md-filled-button :disabled="!webuiDirty" @click="saveWebUI">
|
||||
<Save :size="16" /> 保存配置
|
||||
</md-filled-button>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<ConfirmDialog
|
||||
:open="resetOpen"
|
||||
headline="恢复默认配置"
|
||||
description="将载入安装时备份的配置到表单,需再点击保存才会写入。确定继续吗?"
|
||||
confirm-text="载入备份"
|
||||
@confirm="confirmReset"
|
||||
@cancel="resetOpen = false"
|
||||
/>
|
||||
|
||||
<md-dialog ref="helpDialog" @closed="helpOpen = false">
|
||||
<div slot="headline">支持的事件字母</div>
|
||||
<pre slot="content" class="help-text">{{ INOTIFY_HELP }}</pre>
|
||||
<div slot="actions">
|
||||
<md-filled-button @click="closeHelp">知道了</md-filled-button>
|
||||
</div>
|
||||
</md-dialog>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.group-title {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: var(--md-sys-spacing-2);
|
||||
margin-top: var(--md-sys-spacing-2);
|
||||
}
|
||||
|
||||
.section-header.toggle {
|
||||
width: 100%;
|
||||
background: none;
|
||||
border: 0;
|
||||
padding: 0;
|
||||
cursor: pointer;
|
||||
text-align: left;
|
||||
}
|
||||
|
||||
.chevron {
|
||||
transition: transform var(--md-sys-motion-duration-medium2)
|
||||
var(--md-sys-motion-easing-emphasized);
|
||||
color: var(--md-sys-color-on-surface-variant);
|
||||
}
|
||||
|
||||
.chevron.open {
|
||||
transform: rotate(180deg);
|
||||
}
|
||||
|
||||
.collapse-inner {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: var(--md-sys-spacing-3);
|
||||
}
|
||||
|
||||
.sleep-row {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(2, minmax(0, 1fr));
|
||||
gap: var(--md-sys-spacing-2);
|
||||
}
|
||||
|
||||
.field-row {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: var(--md-sys-spacing-2);
|
||||
}
|
||||
|
||||
.field-row > :first-child {
|
||||
flex: 1;
|
||||
}
|
||||
|
||||
.actions {
|
||||
display: flex;
|
||||
justify-content: flex-end;
|
||||
gap: var(--md-sys-spacing-2);
|
||||
padding-top: var(--md-sys-spacing-2);
|
||||
}
|
||||
|
||||
.help-text {
|
||||
margin: 0;
|
||||
white-space: pre-wrap;
|
||||
font-family: var(--md-sys-typescale-font-mono);
|
||||
font-size: var(--md-sys-typescale-body-small-size);
|
||||
line-height: 1.6;
|
||||
}
|
||||
</style>
|
||||
+106
-88
@@ -1,107 +1,125 @@
|
||||
<script setup>
|
||||
import { inject, ref, onMounted } from 'vue'
|
||||
import Button from '@/components/ui/Button.vue'
|
||||
import { RefreshCw, Copy, Download, Trash2 } from 'lucide-vue-next'
|
||||
import { inject, computed, ref } from 'vue'
|
||||
import { RefreshCw } from 'lucide-vue-next'
|
||||
import ActionMenu from '../components/ActionMenu.vue'
|
||||
import ConfirmDialog from '../components/ConfirmDialog.vue'
|
||||
|
||||
const showToast = inject('showToast')
|
||||
const log = inject('log')
|
||||
const snackbar = inject('snackbar')
|
||||
|
||||
const logMenuOpen = ref(false)
|
||||
const clearConfirming = ref(false)
|
||||
const clearOpen = ref(false)
|
||||
|
||||
let clearConfirmTimer = null
|
||||
function copyLog() {
|
||||
log.copy(showToast)
|
||||
logMenuOpen.value = false
|
||||
}
|
||||
function exportLog() {
|
||||
log.exportLog(showToast)
|
||||
logMenuOpen.value = false
|
||||
}
|
||||
function handleClear() {
|
||||
if (!clearConfirming.value) {
|
||||
clearConfirming.value = true
|
||||
clearConfirmTimer = setTimeout(() => {
|
||||
clearConfirming.value = false
|
||||
}, 3000)
|
||||
return
|
||||
}
|
||||
clearTimeout(clearConfirmTimer)
|
||||
clearConfirming.value = false
|
||||
logMenuOpen.value = false
|
||||
log.clear(showToast)
|
||||
}
|
||||
const menuItems = [
|
||||
{ key: 'copy', label: '复制当前日志' },
|
||||
{ key: 'export', label: '导出到 /sdcard' },
|
||||
{ key: 'clear', label: '清空日志' },
|
||||
]
|
||||
|
||||
// filter options
|
||||
const filterOptions = [
|
||||
const filterItems = computed(() => [
|
||||
{ key: '', label: '全部' },
|
||||
{ key: 'INFO', label: 'INFO' },
|
||||
{ key: 'WARN', label: 'WARN' },
|
||||
{ key: 'ERROR', label: 'ERROR' },
|
||||
]
|
||||
{ key: 'SUCCESS', label: 'SUCCESS' },
|
||||
])
|
||||
|
||||
onMounted(() => log.load())
|
||||
function onMenuSelect(key) {
|
||||
if (key === 'copy') log.copy(snackbar)
|
||||
else if (key === 'export') log.exportTo(snackbar)
|
||||
else if (key === 'clear') clearOpen.value = true
|
||||
}
|
||||
|
||||
const levelClass = (level) => `log-line--${(level || 'plain').toLowerCase()}`
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<section class="card" id="log-section">
|
||||
<div class="card-header" style="margin-bottom: 8px">
|
||||
<h2>运行日志</h2>
|
||||
<div class="header-actions dropdown-container">
|
||||
<Button variant="ghost" size="icon" @click="log.load">
|
||||
<RefreshCw :size="18" />
|
||||
</Button>
|
||||
<Button variant="ghost" size="icon" @click="logMenuOpen = !logMenuOpen">
|
||||
<span class="sr-only">更多操作</span>
|
||||
<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"
|
||||
>
|
||||
<circle cx="12" cy="12" r="1" />
|
||||
<circle cx="12" cy="5" r="1" />
|
||||
<circle cx="12" cy="19" r="1" />
|
||||
</svg>
|
||||
</Button>
|
||||
<div class="dropdown-menu" :class="{ show: logMenuOpen }" @click.stop>
|
||||
<div class="dropdown-item" @click="copyLog"><Copy :size="18" /><span>复制日志</span></div>
|
||||
<div class="dropdown-item" @click="exportLog">
|
||||
<Download :size="18" /><span>导出日志文件</span>
|
||||
</div>
|
||||
<div
|
||||
class="dropdown-item"
|
||||
:class="{ 'dropdown-item-danger': clearConfirming }"
|
||||
@click="handleClear"
|
||||
>
|
||||
<Trash2 :size="18" />
|
||||
<span>{{ clearConfirming ? '再次点击确认清除' : '清除日志' }}</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<section class="section">
|
||||
<div class="section-header">
|
||||
<h2 class="section-title ts-title-md">运行日志</h2>
|
||||
<md-icon-button title="刷新" @click="log.load()">
|
||||
<RefreshCw :size="20" />
|
||||
</md-icon-button>
|
||||
<ActionMenu :items="menuItems" @select="onMenuSelect" />
|
||||
</div>
|
||||
|
||||
<!-- 过滤器 -->
|
||||
<div class="log-filter-container" style="margin-bottom: var(--spacing-s)">
|
||||
<div class="log-filter-tabs">
|
||||
<button
|
||||
v-for="opt in filterOptions"
|
||||
:key="opt.key"
|
||||
class="log-filter-tab"
|
||||
:class="{ active: log.filterLevel.value === opt.key }"
|
||||
@click="log.filterLevel.value = opt.key"
|
||||
>
|
||||
{{ opt.label }}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
<md-chip-set class="filter-chips">
|
||||
<md-filter-chip
|
||||
v-for="item in filterItems"
|
||||
:key="item.key || 'all'"
|
||||
:label="item.label"
|
||||
:selected="log.level.value === item.key"
|
||||
@click="log.level.value = item.key"
|
||||
></md-filter-chip>
|
||||
</md-chip-set>
|
||||
|
||||
<!-- 日志内容 -->
|
||||
<pre class="log-output" id="log-output">{{ log.filteredLog.value || '暂无日志' }}</pre>
|
||||
<div v-if="log.error.value" class="empty-state error">{{ log.error.value }}</div>
|
||||
<div v-else-if="log.filtered.value.length === 0" class="empty-state">
|
||||
暂无{{ log.level.value ? ` [${log.level.value}] ` : '' }}日志
|
||||
</div>
|
||||
<pre v-else class="log-output scroll-area"><code><span
|
||||
v-for="(entry, index) in log.filtered.value"
|
||||
:key="index"
|
||||
:class="levelClass(entry.level)"
|
||||
class="log-line"
|
||||
>[{{ entry.time }}] [{{ entry.tag }}] [{{ entry.level }}] {{ entry.message }}
|
||||
</span></code></pre>
|
||||
</section>
|
||||
|
||||
<ConfirmDialog
|
||||
:open="clearOpen"
|
||||
headline="清空日志"
|
||||
description="日志文件内容将被清空,此操作不可撤销。"
|
||||
confirm-text="清空"
|
||||
danger
|
||||
@confirm="clearOpen = false; log.clear(snackbar)"
|
||||
@cancel="clearOpen = false"
|
||||
/>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.filter-chips {
|
||||
--md-filter-chip-label-text-size: var(--md-sys-typescale-label-medium-size);
|
||||
}
|
||||
|
||||
.log-output {
|
||||
margin: 0;
|
||||
padding: var(--md-sys-spacing-3);
|
||||
max-height: 58vh;
|
||||
overflow: auto;
|
||||
border-radius: var(--md-sys-shape-corner-medium);
|
||||
background-color: var(--md-sys-color-surface-container-lowest);
|
||||
color: var(--md-sys-color-on-surface);
|
||||
font-family: var(--md-sys-typescale-font-mono);
|
||||
font-size: var(--md-sys-typescale-body-small-size);
|
||||
line-height: 1.55;
|
||||
}
|
||||
|
||||
/* UA 样式表给 code 单独设了 font-family: monospace(不继承 pre),
|
||||
必须显式 inherit,否则中文回落到宋体 */
|
||||
.log-output code {
|
||||
font-family: inherit;
|
||||
font-size: inherit;
|
||||
}
|
||||
|
||||
.log-line {
|
||||
display: block;
|
||||
white-space: pre-wrap;
|
||||
word-break: break-all;
|
||||
}
|
||||
|
||||
.log-line--warn {
|
||||
color: var(--lp-color-warning);
|
||||
}
|
||||
|
||||
.log-line--error {
|
||||
color: var(--md-sys-color-error);
|
||||
}
|
||||
|
||||
.log-line--success {
|
||||
color: var(--lp-color-success);
|
||||
}
|
||||
|
||||
.log-line--info {
|
||||
color: var(--md-sys-color-on-surface-variant);
|
||||
}
|
||||
</style>
|
||||
+187
-93
@@ -1,116 +1,210 @@
|
||||
<script setup>
|
||||
import { inject, computed, ref } from 'vue'
|
||||
import Button from '@/components/ui/Button.vue'
|
||||
import Badge from '@/components/ui/Badge.vue'
|
||||
import {
|
||||
RefreshCw,
|
||||
Play,
|
||||
RotateCcw,
|
||||
SunMedium,
|
||||
Smartphone,
|
||||
Activity,
|
||||
Clock,
|
||||
Moon,
|
||||
Layers,
|
||||
} from 'lucide-vue-next'
|
||||
import { SunMedium, Smartphone, Activity, Clock, Moon, Layers, Gauge, RefreshCw } from 'lucide-vue-next'
|
||||
import ConfirmDialog from '../components/ConfirmDialog.vue'
|
||||
|
||||
const status = inject('status')
|
||||
const showToast = inject('showToast')
|
||||
const config = inject('config')
|
||||
const oplock = inject('oplock')
|
||||
const snackbar = inject('snackbar')
|
||||
|
||||
const confirmedLowBri = ref(false)
|
||||
const sliderEl = ref(null)
|
||||
const confirmLowOpen = ref(false)
|
||||
const pendingValue = ref(0)
|
||||
|
||||
// --------- 亮度滑条渐变 ----------
|
||||
const sliderStyle = computed(() => {
|
||||
const sysMax = parseInt(status.sysMaxBri.value) || 255
|
||||
const curr = parseInt(status.currentBri.value) || 0
|
||||
const uiMax = parseInt(config.uiMaxBri.value) || sysMax
|
||||
const c = (curr / sysMax) * 100
|
||||
const u = (uiMax / sysMax) * 100
|
||||
const pri = '#a8c7fa'
|
||||
const bst = '#fb8c00'
|
||||
const trk = 'var(--md-sys-color-surface-container-high)'
|
||||
const btrk = 'rgba(251,140,0,0.15)'
|
||||
if (c <= u) {
|
||||
return `background: linear-gradient(to right, ${pri} 0%, ${pri} ${c}%, ${trk} ${c}%, ${trk} ${u}%, ${btrk} ${u}%, ${btrk} 100%)`
|
||||
}
|
||||
return `background: linear-gradient(to right, ${pri} 0%, ${pri} ${u}%, ${bst} ${u}%, ${bst} ${c}%, ${btrk} ${c}%, ${btrk} 100%)`
|
||||
const DAEMON_STATES = { S: '休眠中', R: '运行中', D: '等待中', T: '已停止', Z: '异常' }
|
||||
|
||||
const items = computed(() => {
|
||||
const daemon = status.daemon.value
|
||||
const brightness = status.brightness.value
|
||||
return [
|
||||
{ label: '当前亮度', value: brightness.current ?? '—', icon: SunMedium },
|
||||
{ label: '系统最大亮度', value: brightness.max || '—', icon: Smartphone },
|
||||
{ label: '守护进程 PID', value: daemon.running ? daemon.pid : '离线', icon: Activity },
|
||||
{
|
||||
label: '守护进程状态',
|
||||
value: daemon.running ? DAEMON_STATES[daemon.state] || daemon.state || '运行中' : '未运行',
|
||||
icon: Clock,
|
||||
},
|
||||
{ label: '休眠状态', value: status.sleepText.value, icon: Moon },
|
||||
{ label: 'HDR/SDR 比率', value: status.hdrText.value, icon: Layers },
|
||||
]
|
||||
})
|
||||
|
||||
const brightnessPercent = computed(() => {
|
||||
const sysMax = parseInt(status.sysMaxBri.value) || 255
|
||||
const curr = parseInt(status.currentBri.value) || 0
|
||||
return Math.round((curr / sysMax) * 100) + '%'
|
||||
})
|
||||
const maxBrightness = computed(() => status.brightness.value.max || 255)
|
||||
const currentBrightness = computed(() => status.brightness.value.current || 0)
|
||||
const percent = computed(() => status.brightness.value.percent ?? 0)
|
||||
const uiThreshold = computed(() => status.cfg.value.uiMaxBri ?? 0)
|
||||
const thresholdPercent = computed(() =>
|
||||
Math.round((uiThreshold.value / maxBrightness.value) * 100),
|
||||
)
|
||||
const autoBrightness = computed(() => status.display.value?.autoBrightness ?? null)
|
||||
const nodeError = computed(() => status.brightness.value.error || '')
|
||||
|
||||
async function onSliderChange(e) {
|
||||
const newBri = parseInt(e.target.value, 10)
|
||||
const sysMax = parseInt(status.sysMaxBri.value) || 255
|
||||
const pct = Math.round((newBri / sysMax) * 100)
|
||||
if (pct < 5 && !confirmedLowBri.value) {
|
||||
const ok = confirm('⚠️ 警告:亮度低于 5% 可能导致屏幕近似黑屏。\n\n确定要继续吗?')
|
||||
if (!ok) {
|
||||
const safe = Math.ceil(sysMax * 0.05)
|
||||
e.target.value = safe
|
||||
return
|
||||
}
|
||||
confirmedLowBri.value = true
|
||||
}
|
||||
if (pct >= 5) confirmedLowBri.value = false
|
||||
await status.setBrightness(newBri, showToast)
|
||||
async function refresh() {
|
||||
await status.load({ display: true })
|
||||
snackbar('已刷新')
|
||||
}
|
||||
|
||||
const statusItems = computed(() => [
|
||||
{ label: '当前亮度', value: status.currentBri.value || '—', icon: SunMedium },
|
||||
{ label: '系统最大亮度', value: status.sysMaxBri.value || '—', icon: Smartphone },
|
||||
{ label: '守护进程 PID', value: status.inotifydPid.value, icon: Activity },
|
||||
{ label: '守护进程状态', value: status.inotifydState.value, icon: Clock },
|
||||
{ label: '休眠状态', value: status.sleepStatus.value, icon: Moon },
|
||||
{ label: 'HDR/SDR 比率', value: status.hdrRatio.value, icon: Layers },
|
||||
])
|
||||
let lastApplied = null
|
||||
|
||||
/** 拖动中节流:距上次应用超过 3% 才写一次节点,避免每个像素都 exec */
|
||||
const DRAG_APPLY_STEP_PERCENT = 3
|
||||
|
||||
/** 低亮度保护:低于该比例视为伪黑屏风险,需用户确认后才允许 */
|
||||
const MIN_PERCENT = 5
|
||||
/** 用户确认过本次会话的低亮度设置(确认后不再重复拦截) */
|
||||
const lowConfirmed = ref(false)
|
||||
|
||||
/** 5% 对应的亮度值,向上取整 */
|
||||
const lowFloor = computed(() => Math.ceil(((maxBrightness.value || 255) * MIN_PERCENT) / 100))
|
||||
|
||||
/** 把滑条与已应用值拉回安全下限 */
|
||||
function snapToFloor() {
|
||||
if (sliderEl.value) sliderEl.value.value = lowFloor.value
|
||||
return lowFloor.value
|
||||
}
|
||||
|
||||
async function applyBrightness(value, { silent = false } = {}) {
|
||||
try {
|
||||
await status.setBrightness(value)
|
||||
lastApplied = value
|
||||
// 回到安全区以上后重置确认状态:下次再往下滑会重新提醒
|
||||
// 注意用严格大于:确认后应用的就是下限值本身,等于时不应重置
|
||||
if (value > lowFloor.value) lowConfirmed.value = false
|
||||
if (!silent) snackbar(`亮度已设为 ${value}`)
|
||||
} catch (e) {
|
||||
if (!silent) snackbar(`设置失败: ${e.message}`)
|
||||
}
|
||||
}
|
||||
|
||||
/** 拖动过程中(input 事件):先做低亮度拦截,再按比例节流应用 */
|
||||
async function onSliderInput(event) {
|
||||
const value = Number(event.target.value)
|
||||
const max = maxBrightness.value || 255
|
||||
|
||||
// 低亮度保护:未确认前直接拦在安全下限,避免滑到伪黑屏
|
||||
if (!lowConfirmed.value && value < lowFloor.value) {
|
||||
const floored = snapToFloor()
|
||||
if (!confirmLowOpen.value) {
|
||||
pendingValue.value = floored
|
||||
confirmLowOpen.value = true
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
if (lastApplied === null) {
|
||||
lastApplied = currentBrightness.value
|
||||
}
|
||||
const step = (max * DRAG_APPLY_STEP_PERCENT) / 100
|
||||
if (Math.abs(value - lastApplied) < step) return
|
||||
await applyBrightness(value, { silent: true })
|
||||
}
|
||||
|
||||
async function onSliderChange(event) {
|
||||
const value = Number(event.target.value)
|
||||
|
||||
// 未确认低亮度时,松手也不允许落在安全下限之下
|
||||
if (!lowConfirmed.value && value < lowFloor.value) {
|
||||
pendingValue.value = lowFloor.value
|
||||
snapToFloor()
|
||||
confirmLowOpen.value = true
|
||||
return
|
||||
}
|
||||
|
||||
await applyBrightness(value)
|
||||
lastApplied = value
|
||||
}
|
||||
|
||||
/** 取消:保持在安全下限,不写节点 */
|
||||
function cancelLow() {
|
||||
confirmLowOpen.value = false
|
||||
if (sliderEl.value) sliderEl.value.value = lowFloor.value
|
||||
}
|
||||
|
||||
/** 确认:本次会话放开低亮度限制,并应用目标值 */
|
||||
async function confirmLow() {
|
||||
confirmLowOpen.value = false
|
||||
lowConfirmed.value = true
|
||||
await applyBrightness(pendingValue.value)
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<section class="card" id="status-section" data-nav-group="status">
|
||||
<div class="card-header">
|
||||
<h2>实时状态</h2>
|
||||
<Button variant="ghost" size="icon" @click="status.load(true)">
|
||||
<RefreshCw :size="18" />
|
||||
</Button>
|
||||
<section class="section">
|
||||
<div class="section-header">
|
||||
<h2 class="section-title ts-title-md">实时状态</h2>
|
||||
<span v-if="status.error.value" class="state-badge is-unsaved">读取失败</span>
|
||||
<md-icon-button title="刷新" @click="refresh">
|
||||
<RefreshCw :size="20" />
|
||||
</md-icon-button>
|
||||
</div>
|
||||
|
||||
<!-- 状态网格 -->
|
||||
<div class="status-grid">
|
||||
<div v-for="item in statusItems" :key="item.label" class="status-item">
|
||||
<div class="status-item-header">
|
||||
<div v-for="item in items" :key="item.label" class="status-item">
|
||||
<span class="status-item__label">
|
||||
<component :is="item.icon" :size="14" aria-hidden="true" />
|
||||
<span class="status-label">{{ item.label }}</span>
|
||||
</div>
|
||||
<span class="status-value">{{ item.value }}</span>
|
||||
{{ item.label }}
|
||||
</span>
|
||||
<span class="status-item__value tabular">{{ item.value }}</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 亮度控制 -->
|
||||
<div class="brightness-section">
|
||||
<div class="brightness-header">
|
||||
<span class="brightness-title">亮度</span>
|
||||
<span class="brightness-percent">{{ brightnessPercent }}</span>
|
||||
</div>
|
||||
<div class="brightness-container">
|
||||
<span class="brightness-label">0%</span>
|
||||
<input
|
||||
type="range"
|
||||
class="brightness-slider"
|
||||
min="0"
|
||||
:max="status.sysMaxBri.value || 255"
|
||||
:value="status.currentBri.value || 0"
|
||||
:style="sliderStyle"
|
||||
:disabled="oplock.isLocked.value"
|
||||
@change="onSliderChange"
|
||||
/>
|
||||
<span class="brightness-label">100%</span>
|
||||
</div>
|
||||
</div>
|
||||
<p v-if="nodeError" class="ts-body-sm supporting">
|
||||
亮度节点不可用:{{ nodeError }}
|
||||
</p>
|
||||
<p v-else-if="autoBrightness" class="ts-body-sm supporting">
|
||||
系统自动亮度已开启,模块会跳过亮度提升
|
||||
</p>
|
||||
</section>
|
||||
|
||||
<section class="section">
|
||||
<div class="section-header">
|
||||
<h2 class="section-title ts-title-md">亮度</h2>
|
||||
<span class="ts-title-md mono">{{ percent }}%</span>
|
||||
</div>
|
||||
|
||||
<div class="slider-row">
|
||||
<Gauge :size="18" aria-hidden="true" />
|
||||
<md-slider
|
||||
ref="sliderEl"
|
||||
class="brightness-slider"
|
||||
:min="0"
|
||||
:max="maxBrightness"
|
||||
:value="currentBrightness"
|
||||
labeled
|
||||
@input="onSliderInput"
|
||||
@change="onSliderChange"
|
||||
></md-slider>
|
||||
</div>
|
||||
|
||||
<p class="ts-body-sm supporting">
|
||||
触发阈值 {{ uiThreshold }}(约 {{ thresholdPercent }}%):亮度达到该值后模块会平滑提升到峰值。
|
||||
</p>
|
||||
</section>
|
||||
|
||||
<ConfirmDialog
|
||||
:open="confirmLowOpen"
|
||||
headline="亮度低于 5%"
|
||||
:description="`低于 ${MIN_PERCENT}% 可能让屏幕看起来像黑屏。\n确认后将临时放开该限制。`"
|
||||
confirm-text="仍然设置"
|
||||
danger
|
||||
@confirm="confirmLow"
|
||||
@cancel="cancelLow"
|
||||
/>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.slider-row {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: var(--md-sys-spacing-3);
|
||||
color: var(--md-sys-color-on-surface-variant);
|
||||
}
|
||||
|
||||
.brightness-slider {
|
||||
flex: 1;
|
||||
--md-slider-active-track-color: var(--md-sys-color-primary);
|
||||
--md-slider-handle-color: var(--md-sys-color-primary);
|
||||
--md-slider-inactive-track-color: var(--md-sys-color-surface-variant);
|
||||
--md-slider-label-container-color: var(--md-sys-color-primary);
|
||||
}
|
||||
</style>
|
||||
+10
-2
@@ -1,10 +1,18 @@
|
||||
import { defineConfig } from 'vite'
|
||||
import vue from '@vitejs/plugin-vue'
|
||||
import tailwindcss from '@tailwindcss/vite'
|
||||
import { fileURLToPath, URL } from 'node:url'
|
||||
|
||||
export default defineConfig({
|
||||
plugins: [vue(), tailwindcss()],
|
||||
plugins: [
|
||||
vue({
|
||||
template: {
|
||||
compilerOptions: {
|
||||
// @material/web 提供的是自定义元素(md-*),交由浏览器处理而非 Vue 组件
|
||||
isCustomElement: (tag) => tag.startsWith('md-'),
|
||||
},
|
||||
},
|
||||
}),
|
||||
],
|
||||
resolve: {
|
||||
alias: {
|
||||
'@': fileURLToPath(new URL('./src', import.meta.url)),
|
||||
|
||||
Reference in new issue
Block a user