mirror of
https://github.com/YuleBest/LuminPro.git
synced 2026-12-04 00:54:42 +08:00
Compare commits
100
Commits
No files matched your search
@@ -0,0 +1,120 @@
|
||||
name: Build & Package Module
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [main, beta, dev]
|
||||
tags: ['v*']
|
||||
workflow_dispatch:
|
||||
|
||||
permissions:
|
||||
contents: write
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
# ── 1. WebUI ────────────────────────────────────────────────────────
|
||||
- name: Setup pnpm
|
||||
uses: pnpm/action-setup@v4
|
||||
with:
|
||||
version: latest
|
||||
|
||||
- name: Setup Node.js
|
||||
uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: 22
|
||||
cache: pnpm
|
||||
|
||||
- name: Install Node.js dependencies
|
||||
run: pnpm install --frozen-lockfile
|
||||
|
||||
- name: Build WebUI
|
||||
run: pnpm build:webui
|
||||
|
||||
# ── 2. luminpro 二进制 (Go) ─────────────────────────────────────────
|
||||
- name: Setup Go
|
||||
uses: actions/setup-go@v5
|
||||
with:
|
||||
go-version-file: go/go.mod
|
||||
cache-dependency-path: go/go.sum
|
||||
|
||||
- name: Test Go packages
|
||||
working-directory: go
|
||||
run: |
|
||||
go vet ./...
|
||||
go test ./...
|
||||
|
||||
- name: Build luminpro (android/arm64)
|
||||
working-directory: go
|
||||
run: |
|
||||
mkdir -p ../bin
|
||||
CGO_ENABLED=0 GOOS=android GOARCH=arm64 go build -trimpath -ldflags="-s -w" -o ../bin/luminpro ./cmd/luminpro
|
||||
chmod +x ../bin/luminpro
|
||||
|
||||
# ── 3. 判定发布通道 ─────────────────────────────────────────────────
|
||||
# tag 含 -beta → beta 通道(prerelease);其余 tag → stable;
|
||||
# 分支构建:dev → dev、beta → beta、main → stable(仅出 artifact)
|
||||
- name: Resolve release channel
|
||||
id: channel
|
||||
run: |
|
||||
if [[ "${GITHUB_REF}" == refs/tags/* ]]; then
|
||||
TAG="${GITHUB_REF_NAME}"
|
||||
if [[ "$TAG" == *-beta* ]]; then
|
||||
echo "channel=beta" >> "$GITHUB_OUTPUT"
|
||||
echo "prerelease=true" >> "$GITHUB_OUTPUT"
|
||||
else
|
||||
echo "channel=stable" >> "$GITHUB_OUTPUT"
|
||||
echo "prerelease=false" >> "$GITHUB_OUTPUT"
|
||||
fi
|
||||
else
|
||||
case "${GITHUB_REF_NAME}" in
|
||||
dev) echo "channel=dev" >> "$GITHUB_OUTPUT" ;;
|
||||
beta) echo "channel=beta" >> "$GITHUB_OUTPUT" ;;
|
||||
*) echo "channel=stable" >> "$GITHUB_OUTPUT" ;;
|
||||
esac
|
||||
echo "prerelease=false" >> "$GITHUB_OUTPUT"
|
||||
fi
|
||||
|
||||
# ── 4. 打包模块 ─────────────────────────────────────────────────────
|
||||
- name: Package module
|
||||
run: node build-module.js --channel=${{ steps.channel.outputs.channel }}
|
||||
|
||||
# ── 5a. tag 构建:创建 GitHub Release 并上传资产 ─────────────────────
|
||||
# Release 资产文件名必须与更新清单里的 zipUrl 完全一致
|
||||
- name: Publish release
|
||||
if: startsWith(github.ref, 'refs/tags/')
|
||||
env:
|
||||
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
run: |
|
||||
VERSION=$(grep '^version=' module.prop | cut -d= -f2 | tr -d '[:space:]')
|
||||
ZIP="LuminPro_${VERSION}.zip"
|
||||
NOTES=$(awk '/^## / { if (p) exit; p=1; next } p { print }' changelog.md)
|
||||
[ -n "$NOTES" ] || NOTES="自动构建产物"
|
||||
FLAGS=""
|
||||
if [ "${{ steps.channel.outputs.prerelease }}" = "true" ]; then FLAGS="--prerelease"; fi
|
||||
gh release create "${GITHUB_REF_NAME}" "$ZIP" \
|
||||
--title "${GITHUB_REF_NAME}" \
|
||||
--notes "$NOTES" \
|
||||
$FLAGS
|
||||
|
||||
# ── 5b. 分支构建:重命名后作为 artifact 上传 ────────────────────────
|
||||
- name: Rename artifact with commit hash
|
||||
if: ${{ !startsWith(github.ref, 'refs/tags/') }}
|
||||
id: names
|
||||
run: |
|
||||
VERSION=$(grep '^version=' module.prop | cut -d= -f2 | tr -d '[:space:]')
|
||||
SHORT_SHA=$(git rev-parse --short HEAD)
|
||||
FINAL="LuminPro_${VERSION}-${SHORT_SHA}.zip"
|
||||
mv "LuminPro_${VERSION}.zip" "$FINAL"
|
||||
echo "zip=$FINAL" >> "$GITHUB_OUTPUT"
|
||||
|
||||
- name: Upload module zip
|
||||
if: ${{ !startsWith(github.ref, 'refs/tags/') }}
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: ${{ steps.names.outputs.zip }}
|
||||
path: ${{ steps.names.outputs.zip }}
|
||||
if-no-files-found: error
|
||||
+19
-1
@@ -2,4 +2,22 @@ node_modules/
|
||||
dist/
|
||||
.vite/
|
||||
*.log
|
||||
*.zip
|
||||
*.zip
|
||||
.dist
|
||||
|
||||
# 屏蔽 webroot 下的所有文件,但保留目录本身
|
||||
webroot/*
|
||||
!webroot/.gitkeep
|
||||
|
||||
# Go 编译产物(CI/本地构建生成)
|
||||
bin/luminpro
|
||||
|
||||
# 本地脚本
|
||||
deploy.js
|
||||
.dist-tmp
|
||||
|
||||
# 编辑器 / 会话临时文件
|
||||
.zcode/
|
||||
|
||||
# 构建产物(每次打包重新生成)
|
||||
SHA256SUMS
|
||||
@@ -0,0 +1,8 @@
|
||||
{
|
||||
"$schema": "./node_modules/oxfmt/configuration_schema.json",
|
||||
"printWidth": 100,
|
||||
"semi": false,
|
||||
"singleQuote": true,
|
||||
"tabWidth": 2,
|
||||
"trailingComma": "all",
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"$schema": "./node_modules/oxlint/configuration_schema.json",
|
||||
"categories": {
|
||||
"correctness": "warn"
|
||||
},
|
||||
"rules": {
|
||||
"eslint/no-unused-vars": "warn"
|
||||
}
|
||||
}
|
||||
Vendored
+3
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"recommendations": ["oxc.oxc-vscode", "Vue.volar", "rust-lang.rust-analyzer"]
|
||||
}
|
||||
Vendored
+8
-4
@@ -1,7 +1,11 @@
|
||||
{
|
||||
"editor.formatOnSave": true,
|
||||
"editor.defaultFormatter": "timonwong.shellcheck",
|
||||
"[shellscript]": {
|
||||
"editor.defaultFormatter": "mads-hartmann.bash-ide-vscode"
|
||||
}
|
||||
"editor.codeActionsOnSave": {
|
||||
"source.fixAll.oxc": "always",
|
||||
},
|
||||
"[shellscript]": {
|
||||
"editor.defaultFormatter": "mads-hartmann.bash-ide-vscode",
|
||||
},
|
||||
"oxc.fmt.configPath": ".oxfmtrc.json",
|
||||
"editor.defaultFormatter": "oxc.oxc-vscode",
|
||||
}
|
||||
+240
@@ -0,0 +1,240 @@
|
||||
# LuminPro 开发文档 (Development Guide)
|
||||
|
||||
欢迎回到 LuminPro 的开发!本指南旨在帮助开发者快速找回开发节奏,了解项目结构、构建流程以及如何进行本地调试。
|
||||
|
||||
> [!IMPORTANT]
|
||||
> **无需本地环境全套配置**:本项目已配置完善的 GitHub Actions,每次推送代码到 `main` 分支或发布标签 (`v*`),云端会自动完成前端编译、Go 交叉编译、单元测试及模块打包,并生成可直接刷入的 ZIP 包。
|
||||
|
||||
---
|
||||
|
||||
## 1. 项目架构概览
|
||||
|
||||
LuminPro 是一个基于 KernelSU WebUI 的 Android 亮度增强模块,底层为 Go 常驻守护进程,前端为 Vue 3。
|
||||
|
||||
- `go/`: Go 源码。`cmd/luminpro` 是入口,`internal/` 下按职责分包(见第 5 节)。
|
||||
- `webui/`: 基于 Vite + Vue 3 的前端源码。
|
||||
- `bin/`: 编译产物 `luminpro`(CI 生成,不进版本库)。
|
||||
- `script/`: 仅保留 `restart.sh` 等转发脚本。
|
||||
- `webroot/`: WebUI 编译产物存放地,模块刷入后 KernelSU 会读取此处。
|
||||
- `module.prop`: 模块基础信息。
|
||||
- `build-module.js`: 模块自动化打包脚本。
|
||||
|
||||
---
|
||||
|
||||
## 2. 环境搭建 (本地)
|
||||
|
||||
- **Node.js**: 推荐 v18+ (项目中使用 pnpm/npm),用于 WebUI 与打包。
|
||||
- **Go**: 1.26+,用于守护进程开发与测试(交叉编译到 Android 无需 NDK)。
|
||||
|
||||
```bash
|
||||
cd go
|
||||
go vet ./... && go test ./... # 全部逻辑均可在 host 上测试
|
||||
CGO_ENABLED=0 GOOS=android GOARCH=arm64 go build -trimpath -ldflags="-s -w" -o ../bin/luminpro ./cmd/luminpro
|
||||
```
|
||||
|
||||
守护进程支持 `LUMINPRO_MODDIR` 环境变量覆盖模块目录,配合自定义 `now_bri_file` 即可在电脑上直接跑通全流程(详见第 8 节)。
|
||||
|
||||
---
|
||||
|
||||
## 3. 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
|
||||
pnpm install
|
||||
pnpm dev
|
||||
```
|
||||
|
||||
> [!TIP]
|
||||
> 普通浏览器没有 KernelSU bridge,`exec` 会失败;此时 `api/devMock.js` 会返回模拟数据(仅 DEV 构建),
|
||||
> 界面可以正常调试。真机行为请在 KernelSU 管理器的「自定义页面」中验证。
|
||||
|
||||
### 编译前端
|
||||
|
||||
生成的静态文件会自动同步到根目录的 `webroot/`。
|
||||
|
||||
```bash
|
||||
pnpm build:webui # 仅编译前端
|
||||
pnpm build # 前端 + 模块打包(需要 bin/luminpro 已存在)
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 4. 分支与发布通道
|
||||
|
||||
| 分支 | 通道 | 包内 `updateJson` | 说明 |
|
||||
| --- | --- | --- | --- |
|
||||
| `dev` | 开发 | 无 | 日常开发;产物为 Actions artifact,手动刷入 |
|
||||
| `beta` | 预览 | `beta/update-beta.json` | 预发布版,GitHub Release 标记为 prerelease |
|
||||
| `main` | 正式 | `main/update.json` | 正式版 |
|
||||
|
||||
通道由**刷入的包**决定:KernelSU 只读取已安装模块 `module.prop` 里的 `updateJson`,
|
||||
所以正式版用户永远不会收到 beta 包,反之亦然。`zipUrl` 必须指向 GitHub Release 资产
|
||||
(或 raw),不再使用第三方镜像。
|
||||
|
||||
### 版本号规范
|
||||
|
||||
`version` 采用语义化命名(不含 versionCode),`versionCode` 单独维护:
|
||||
|
||||
```
|
||||
versionCode = 基础号 × 100 + 段位
|
||||
基础号 = 主版本 × 10000 + 次版本 × 100 + 修订
|
||||
```
|
||||
|
||||
以 `V2.5.0` 为例,基础号为 `20500`,末两位即段位:
|
||||
|
||||
| 段位 | 段位值 | version 示例 | versionCode |
|
||||
| --- | --- | --- | --- |
|
||||
| dev | `01–49` | `V2.5.0-dev.1` | `2050001` |
|
||||
| beta | `51–59` | `V2.5.0-beta.1` | `2050051` |
|
||||
| 正式 | `90`(9x) | `V2.5.0` | `2050090` |
|
||||
|
||||
末两位约定:**`5x` 表示 beta,`9x` 表示正式版**。排序恒为
|
||||
`dev < beta < 同周期正式版`:dev 测试者可平滑收到 beta,beta 用户会平滑收到同周期的
|
||||
正式版。只有从 beta/dev 回退到已发布的正式版才需要手动刷包(管理器不支持降级)。
|
||||
|
||||
tag 名 = version 的小写形式(如 `v2.5.0-beta.1`),Release 资产名为
|
||||
`LuminPro_<version>.zip`。
|
||||
|
||||
### 发布流程
|
||||
|
||||
```bash
|
||||
# 1) 在对应分支改 module.prop 的 version / versionCode
|
||||
# 2) 生成更新清单(会写入 update.json / update-beta.json,需一并提交)
|
||||
node build-module.js --channel=stable # main 分支
|
||||
node build-module.js --channel=beta # beta 分支
|
||||
# 3) 提交后打 tag(tag 名 = 版本号小写),推送即触发 CI 建 Release
|
||||
git tag v2.5.0-beta.1 && git push origin v2.5.0-beta.1
|
||||
```
|
||||
|
||||
CI 会依次:跑 Go 单测 → 交叉编译 → 按通道打包 → 建 GitHub Release 并上传
|
||||
`LuminPro_<version>.zip`(beta 自动标记 prerelease)。更新清单里的 `zipUrl` 精确指向该
|
||||
资产,所以**版本号与资产文件名必须一致**。
|
||||
|
||||
分支推送(非 tag)只产出带短哈希的 artifact,不建 Release;默认通道是 `dev`,本地
|
||||
`node build-module.js` 不会改动任何清单文件。
|
||||
|
||||
---
|
||||
|
||||
## 5. Go 守护进程开发
|
||||
|
||||
`go/` 下按职责分包,判定逻辑与 IO 分离,便于在电脑上测试:
|
||||
|
||||
| 包 | 职责 |
|
||||
| --- | --- |
|
||||
| `cmd/luminpro` | 子命令入口:`daemon` / `boost` / `restart` / `config` |
|
||||
| `internal/inotify` | 原始 inotify 封装(事件字母与 toybox 兼容,含防抖与事件排空) |
|
||||
| `internal/policy` | 纯判定逻辑:休眠时段、阈值、黑名单、HDR 迟滞状态机 |
|
||||
| `internal/brightness` | 亮度节点读写与渐变序列计算 |
|
||||
| `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 集成测试)
|
||||
go test ./internal/policy/ -v # 只跑判定逻辑
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 6. 模块打包脚本
|
||||
|
||||
`build-module.js` 负责版本同步、生成校验和并打包。打包前需要先有 `bin/luminpro`:
|
||||
|
||||
```bash
|
||||
# 自动执行:前端编译 + 模块打包(不含 Go 编译)
|
||||
npm run build
|
||||
|
||||
# 完整本地构建:
|
||||
cd go && CGO_ENABLED=0 GOOS=android GOARCH=arm64 go build -trimpath -ldflags="-s -w" -o ../bin/luminpro ./cmd/luminpro && cd ..
|
||||
node build-module.js
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 7. 核心逻辑说明
|
||||
|
||||
- **service.sh**: 开机入口,等待系统就绪后拉起 `luminpro daemon`。
|
||||
- **luminpro daemon**: 常驻进程,负责监听、判定、渐变写入、状态文件维护。
|
||||
- **luminpro boost** / **boost.sh**: 一键提升至峰值亮度 / 恢复原亮度。
|
||||
- **luminpro restart** / **script/restart.sh**: 通知守护进程重建监听;未运行时按需拉起。
|
||||
- **customize.sh**: 刷入时的安装逻辑(校准向导、旧配置迁移),配置读写全部调用
|
||||
`luminpro config ...`,模块内不再需要 jq。
|
||||
- **action.sh**: 快捷启停(管理器操作按钮),仅切换 `pid/stop.flag`。
|
||||
|
||||
### 操作锁 (oplock)
|
||||
|
||||
`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`。
|
||||
|
||||
---
|
||||
|
||||
## 8. 调试技巧
|
||||
|
||||
- **查看日志**: WebUI 日志页,或 `tail -f /data/adb/modules/LuminPro/service.log`。
|
||||
- **手动触发**: `/data/adb/modules/LuminPro/boost.sh`。
|
||||
- **配置文件**: `/data/adb/modules/LuminPro/config/config.json`。
|
||||
- **在电脑上跑守护进程**(无需真机):
|
||||
|
||||
```bash
|
||||
mkdir -p /tmp/lp/{config,pid} && printf 1200 > /tmp/lp/brightness
|
||||
cp bin/luminpro /tmp/lp/ # 或用 go build 出的 host 版二进制
|
||||
LUMINPRO_MODDIR=/tmp/lp ./luminpro config init
|
||||
LUMINPRO_MODDIR=/tmp/lp ./luminpro config set now_bri_file=/tmp/lp/brightness ui_max_bri=1000 max_bri=3000
|
||||
LUMINPRO_MODDIR=/tmp/lp ./luminpro daemon &
|
||||
printf 1500 > /tmp/lp/brightness # 模拟用户调高亮度,观察日志与节点变化
|
||||
```
|
||||
|
||||
`dumpsys` / `settings` 在电脑上不存在时按「无数据」降级,不影响验证监听与渐变主流程。
|
||||
|
||||
---
|
||||
|
||||
祝你开发愉快!如有疑问,请查阅 [README.md](./README.md) 或提交 Issue。
|
||||
@@ -1,50 +1,85 @@
|
||||
------------ 🌸🌸🌸 ------------
|
||||
=======================================
|
||||
LuminPro — 日用屏幕亮度强化
|
||||
作者: 酷安@Yule
|
||||
=======================================
|
||||
|
||||
嗨~亲爱的伙伴!感谢你选择本喵的【日用屏幕亮度强化 (LuminPro V2.1)】ฅ^•ﻌ•^ฅ
|
||||
本喵会努力帮你让屏幕更亮更清晰,但为了守护你和设备的安全,请花几分钟认真阅读以下内容哦~
|
||||
感谢你使用 LuminPro!在开始使用前,请仔细阅读以下内容。
|
||||
|
||||
------------ 🐾【使用约定】🐾 ------------
|
||||
---------------------------------------
|
||||
【使用约定】
|
||||
---------------------------------------
|
||||
|
||||
1. 授权小贴士
|
||||
本喵由 Yule 精心开发,你可以自由使用、修改和分享喵~
|
||||
但请遵守法律法规,并保留本喵的版权小尾巴(开发者信息不能删掉哦!(๑>ᴗ<๑))
|
||||
1. 版权声明
|
||||
本模块由 Yule 开发,你可以自由使用与分享,但请保留开发者信息,
|
||||
且须遵守相关法律法规,不得用于商业用途。
|
||||
|
||||
2. 免责小贴士
|
||||
本喵目前是「测试版小萌新」,可能存在未知小bug~
|
||||
开发者无法对设备损伤、数据丢失或系统罢工负责,
|
||||
请确认你已做好「自己承担风险」的准备啦!( •́ω•̀ )
|
||||
2. 免责声明
|
||||
本模块按"现状"提供,不附带任何明示或暗示的保证。
|
||||
开发者对因使用本模块导致的设备损伤、数据丢失或系统故障不承担责任。
|
||||
使用即代表你已了解并接受相关风险。
|
||||
|
||||
3. 风险说明书(超重要!)
|
||||
使用前请默念三遍:「我接受这些可能性!」
|
||||
🔸 卡顿警告:亮度过高时,设备可能会累到「卡成PPT」!
|
||||
🔸 发热警告:屏幕努力发光时,设备可能会变成暖宝宝🔥
|
||||
🔸 屏幕衰老:长期高亮度会让屏幕「提前长皱纹」甚至烧屏呢(T▽T)
|
||||
🔸 电量告急:亮闪闪的代价是电量咻咻掉~记得随身带充电宝!
|
||||
3. 风险说明
|
||||
⚠ 发热与耗电:长期维持峰值亮度会显著增加设备发热与功耗。
|
||||
⚠ OLED 烧屏:高亮度会加速 OLED 面板老化,严重时导致永久性残影。
|
||||
⚠ 系统干预:部分设备在高亮度下可能触发系统降频或热保护机制。
|
||||
请根据实际使用场景合理配置,切勿超出硬件安全范围。
|
||||
|
||||
------------ 🌼【使用小窍门】🌼 ------------
|
||||
---------------------------------------
|
||||
【功能说明】
|
||||
---------------------------------------
|
||||
|
||||
1. 原生底层监听
|
||||
本喵 V2.1 起已进化为 inotifyd 事件驱动,~零后台耗电,只有你滑亮屏幕时才会默默出力!
|
||||
1. lumipro 底层监听
|
||||
模块采用 Rust 编写的 `lumipro` 二进制程序进行文件事件驱动,
|
||||
内置防抖动与调试模式,仅在亮度节点文件变化时响应,
|
||||
无后台轮询,对电量影响极小。
|
||||
|
||||
2. KernelSU WebUI 支持
|
||||
告别繁琐的配置文件修改!你只需在 KernelSU 管理器中点击模块配置,即可可视化调整「前台触发亮度」、「峰值亮度」和「休眠时间」。
|
||||
2. 守护进程
|
||||
daemon.sh 持续监视 lumipro 进程的存活状态,进程意外退出时
|
||||
自动重启,确保监听链路不中断。
|
||||
|
||||
3. 平滑亮度过渡
|
||||
亮度提升已经过精心打磨,提供 50 步毫秒级顺滑过渡,保护眼睛绝不突兀。(๑•̀ㅂ•́)و✧
|
||||
3. WebUI 可视化配置
|
||||
在 KernelSU 管理器的模块设置中可调整所有参数,保存后立即生效:
|
||||
· 前台最大亮度 — 触发提升的亮度阈值
|
||||
· 峰值最大亮度 — 提升后的目标硬件亮度
|
||||
· 调整步数 — 平滑过渡的步进数(默认 50 步)
|
||||
· 休眠时段 — 不触发提升的时间范围(格式 HHMM-HHMM)
|
||||
· 日志等级 — 控制日志输出量(关闭/仅错误/警告+/全部)
|
||||
· 亮度节点路径 — 非标准设备可自定义 sysfs 路径
|
||||
|
||||
4. 时间管理大师
|
||||
配置 WebUI 中的「休眠时间」(如 1900-0600),夜间不瞎眼,保证睡眠质量!🌙
|
||||
4. 智能跳过
|
||||
以下情形模块会自动跳过本次提升:
|
||||
· 系统自动亮度已开启
|
||||
· 正在播放 HDR 内容(可配置)
|
||||
· 当前前台应用在黑名单中
|
||||
· 处于配置的休眠时段内
|
||||
|
||||
5. 温度安全区
|
||||
请在10°C~35°C环境使用,太冷太热都会让设备「闹脾气」!使用中记得检查设备发热和电量状况。
|
||||
5. 应用黑名单
|
||||
在 WebUI「应用」页面管理黑名单,支持按包名搜索和 Activity 精确匹配。
|
||||
|
||||
------------ 🌟【最后的小星星】🌟 ------------
|
||||
6. 一键峰值触发 (Action)
|
||||
通过管理器的「操作」按钮或 action.sh 可即时将亮度拉至峰值;
|
||||
再次触发则恢复原始亮度。
|
||||
|
||||
本喵的使命是让你的屏幕更清晰明亮,
|
||||
但风险与效果并存,请务必做好权衡与准备~
|
||||
7. 日志管理
|
||||
WebUI「日志」页面支持按 INFO / WARN / ERROR 过滤,
|
||||
并可一键复制或导出日志文件至 /sdcard。
|
||||
可通过「日志等级」配置减少冗余日志写入。
|
||||
|
||||
遇到问题欢迎通过 WebUI 面板查看运行日志,
|
||||
我会摇着尾巴努力帮你解决遇到的问题!
|
||||
感谢你的包容与支持,一起加油吧!ヾ(≧∇≦)ヾ
|
||||
---------------------------------------
|
||||
【安装步骤】
|
||||
---------------------------------------
|
||||
|
||||
------------ 🌸🌸🌸 ------------
|
||||
1. 在支持 KernelSU WebUI 的管理器中刷入本模块 ZIP。
|
||||
2. 按照音量键向导完成亮度校准。
|
||||
(若已有旧版配置,按音量上键直接跳过即可继承原设置)
|
||||
3. 重启设备生效。
|
||||
4. 在管理器模块设置页面调整参数,保存后立即生效。
|
||||
|
||||
---------------------------------------
|
||||
【遇到问题?】
|
||||
---------------------------------------
|
||||
|
||||
请在 WebUI 日志页面导出运行日志,附带日志内容至社区反馈,
|
||||
以便开发者定位并修复问题。
|
||||
|
||||
=======================================
|
||||
@@ -1,51 +1,100 @@
|
||||
<div align="center">
|
||||
|
||||
# 日用屏幕亮度强化 (LuminPro)
|
||||
# LuminPro — 日用屏幕亮度强化
|
||||
|
||||
中文简体 丨 [English](https://github.com/YuleBest/LuminPro/blob/main/README_en.md)
|
||||
**中文简体** 丨 [English](https://github.com/YuleBest/LuminPro/blob/main/README_en.md)
|
||||
|
||||
让你的 Android 设备随时可以使用高亮度显示屏幕内容
|
||||
*基于 KernelSU WebUI + 事件驱动架构*
|
||||
让你的 Android 设备随时可以突破前台亮度上限,将屏幕提升至硬件峰值
|
||||
_基于 KernelSU WebUI + Go 事件驱动架构_
|
||||
|
||||
</div>
|
||||
|
||||
## 模块介绍
|
||||
本模块旨在让你的 Android 设备随时可以使用高亮度显示屏幕内容。无论设备当前亮度如何,只要满足设定的前台触发亮度条件,模块便会自动且平滑地提升屏幕亮度至硬件支持的峰值状态,确保你在强光室外也能获得清晰的显示效果。
|
||||
## 模块介绍
|
||||
|
||||
## V2.1 核心特性一览
|
||||
无论当前屏幕亮度如何,只要触发亮度超过设定阈值,LuminPro 便会自动且平滑地将屏幕提升至硬件支持的峰值亮度,确保你在强光户外也能获得清晰的显示效果。模块采用 Go 编写的常驻守护进程进行底层文件事件监听,零轮询、零空转,配合 KernelSU WebUI 提供完整的可视化配置与状态监控。
|
||||
|
||||
- **零耗电的底层监听 (inotifyd)**
|
||||
彻底告别传统的死循环和轮询检测耗电。LuminPro 全新采用底层的 `inotifyd` 事件驱动架构,仅在屏幕亮度文件发生修改的瞬间响应,最大程度节省你的设备电量。
|
||||
> [!TIP]
|
||||
> 如果你是开发者,请参阅 [开发文档 (DEVELOPMENT.md)](./DEVELOPMENT.md) 了解构建与调试流程。
|
||||
|
||||
- **现代化的 KernelSU WebUI 参数配置**
|
||||
不再需要手动修改枯燥的 `CONFIG.prop` 文本文件!打开 KernelSU 管理器的模块设置,你可以在舒适的暗色可视化面板中实时调节各项亮度参数:
|
||||
- `前台最大亮度`:触发亮度提升的源阈值。
|
||||
- `峰值最大亮度`:亮度触发后提升到的极致目标值。
|
||||
## V2.3+ 核心特性
|
||||
|
||||
- **护眼级平滑亮度提升**
|
||||
亮度瞬间跃升不仅刺眼,还十分突兀——我们为你设计了专属的高刷新率 50 步亮度微调顺滑过渡算法,让屏幕提亮效果更显柔和。
|
||||
- **零耗电底层监听 (luminpro)**
|
||||
彻底告别死循环与轮询。Go 编写的常驻守护进程 (`luminpro`) 直接使用 inotify 监听亮度节点,仅在文件发生变更的瞬间响应,内置 300ms 防抖与事件排空;判定逻辑、渐变写入、状态维护全部在同一进程内完成,无脚本拼接与进程拉起开销,并具备**失效自动修复**机制(监听失效自动重建、遗留锁自动回收)。
|
||||
|
||||
- **勿扰休眠时段**
|
||||
在 WebUI 中随时指定休眠时间段(例如 `1900-0600`)。在设定的夜间休息时间内,模块服务将静默休眠,不再打扰你的睡眠。
|
||||
- **兼容模式 (轮询驱动)**
|
||||
针对部分无法触发 inotify 事件的特殊机型,新增兼容模式。开启后模块切换为 2 秒一次的低频轮询,确保在任何环境下都能正常工作。
|
||||
|
||||
- **实时掌控模块状态**
|
||||
支持通过前端面板直接获取监控系统的核心参数,包含了当前界面的实时亮度、底层拉起的在运行 PID 服务状态,并可以随时抓取详细的运行日志供开发者分析。
|
||||
- **KernelSU WebUI 可视化配置**
|
||||
在管理器的模块设置页面中,通过暗色面板实时调整所有参数,保存后**立即生效**,无需重启:
|
||||
- `前台最大亮度` — 触发提升的亮度阈值
|
||||
- `峰值最大亮度` — 提升后的目标硬件亮度
|
||||
- `调整步数` — 平滑过渡的步进数(默认 50 步)
|
||||
- `休眠时段` — 指定不触发提升的时间范围(如 `2200-0700`)
|
||||
- `日志等级` — 控制日志输出量(关闭 / 仅错误 / 警告+ / 全部)
|
||||
- `亮度/最大亮度节点路径` — 支持自定义设备 sysfs 路径
|
||||
- `inotify 监测事件` — 自定义监听的事件类型
|
||||
|
||||
## 模块工作流程
|
||||
1. **安装期自定义校准**
|
||||
- 通过音量键互动脚本,主动测定你设备通用的 `前台亮度阈值` 及 `硬件峰值亮度`,同时支持无缝继承旧版设定的配置以跳过多余校准。
|
||||
2. **事件监听阶段**
|
||||
- 启动完毕后,`inotifyd` 会作为背景挂起精准监控屏幕亮度的物理底层节点文件变动。
|
||||
3. **防抖与步进调整机制**
|
||||
- 取代了早期版本的参数紊乱,当前在用户手动横滑亮度控制条停止响应后,算法会经过安全延时后计算准确的终点步进结果点亮屏幕。
|
||||
- **平滑亮度过渡**
|
||||
毫秒级 50 步步进算法,避免亮度瞬间跃升带来的视觉不适。步数可在 WebUI 中自由调整。
|
||||
|
||||
## 安装方法
|
||||
1. 在支持 WebUI 标准的管理器环境框架下安装本模块的 ZIP 包。
|
||||
2. 在音量键安装向导中进行简单的第一步初始化按键确认校准(如果已有旧版配置按音量加直接跳过即可)。
|
||||
- **智能跳过机制**
|
||||
以下情况模块将自动跳过本次提升,避免干扰正常使用:
|
||||
- 系统自动亮度已启用
|
||||
- 当前正在播放 HDR 内容(可配置)
|
||||
- 当前前台应用在黑名单中
|
||||
- 处于配置的休眠时段内
|
||||
|
||||
- **应用黑名单**
|
||||
在 WebUI 的「应用」页面中管理黑名单,支持按包名搜索、Activity 精准匹配(可通过内置扫描工具自动获取前台 Activity 名)。黑名单内的应用处于前台时,模块不执行亮度提升。
|
||||
|
||||
- **一键峰值触发 (boost.sh)**
|
||||
通过管理器的「操作」按钮或 `action.sh` 快捷开关,可即时将亮度拉至峰值;再次触发则恢复原始亮度。
|
||||
|
||||
- **实时状态监控与日志**
|
||||
WebUI 状态页实时显示当前亮度值、守护进程 PID 及服务状态。日志页支持按 `INFO` / `WARN` / `ERROR` 等级过滤,并可一键复制或导出到 `/sdcard`。
|
||||
|
||||
## 配置项说明
|
||||
|
||||
| 配置项 | 说明 | 默认值 |
|
||||
| ------------------- | ------------------------------- | ----------------- |
|
||||
| `ui_max_bri` | 前台触发阈值(UI 亮度值) | `0`(需手动校准) |
|
||||
| `max_bri` | 峰值目标亮度 | `0`(需手动校准) |
|
||||
| `compatibility_mode`| 兼容模式(轮询驱动) | `0`(禁用) |
|
||||
| `steps_num` | 亮度过渡步数 | `50` |
|
||||
| `sleep_time` | 休眠时段,格式 `HHMM-HHMM` | 空(禁用) |
|
||||
| `auto_bri_sleep` | 自动亮度开启时跳过 | `1`(启用) |
|
||||
| `display_hdr_sleep` | HDR 内容时跳过 | `0`(禁用) |
|
||||
| `hdr_enter_ratio` | HDR 进入休眠阈值(HDR/SDR 比率)| `1.15` |
|
||||
| `hdr_exit_ratio` | HDR 退出休眠阈值(HDR/SDR 比率)| `1.05` |
|
||||
| `log_level` | 日志等级(off/error/warn/info) | `info` |
|
||||
| `log_max_size` | 日志文件大小上限(KB) | `512` |
|
||||
| `now_bri_file` | 当前亮度节点路径 | 标准 panel0 路径 |
|
||||
| `max_bri_file` | 最大亮度节点路径 | 标准 panel0 路径 |
|
||||
| `blacklist_apps` | 黑名单包名/Activity 列表 | `[]` |
|
||||
| `inotify_events` | 监听事件 | `c` |
|
||||
|
||||
## 安装方法
|
||||
|
||||
1. 在支持 KernelSU WebUI 的管理器中刷入模块 ZIP。
|
||||
2. 在音量键安装向导中完成亮度校准(若已有旧版配置,按音量上键直接继承跳过)。
|
||||
3. 重启设备生效。
|
||||
4. 如需调整参数,只需在管理器中进入模块设置页面进行更改,点击保存**立即生效**。
|
||||
4. 在管理器模块设置页调整各项参数,点击保存立即生效。
|
||||
|
||||
## 注意事项
|
||||
- **长亮降频与烧屏警告**:长期处于高压力的激发峰值亮度,将指数级增加设备的耗电与发热水平,可能会导致设备卡顿并不可逆转地增加 OLED 屏幕烧屏老化几率。
|
||||
- 请确保写入参数数值为你的设备安全范围内的数据,避免超出你硬件屏幕能承受的上限。
|
||||
- 只有确保你在完全理解高亮度带来的体验和危害下,方可能长期启用。功能出现阻断或者其他 BUG 时,请自行保存 WebUI 日志通过社区回馈解决。
|
||||
## 版本通道
|
||||
|
||||
- **正式版**:稳定发布,自动更新只会推正式版
|
||||
- **预览版 (Beta)**:抢先体验新功能,可能不稳定;刷入 beta 包后会自动跟随 beta 更新
|
||||
|
||||
两个通道互不干扰——正式版用户不会收到 beta 包。预览版用户在下一个正式版发布时会自动
|
||||
收到正式版;若想提前回到正式版,手动刷入正式版包即可。
|
||||
|
||||
下载地址:[GitHub Releases](https://github.com/YuleBest/LuminPro/releases)
|
||||
(`v*` 为正式版,`*-beta*` 为预览版)
|
||||
|
||||
## 注意事项
|
||||
|
||||
> ⚠️ **OLED 烧屏与发热警告**
|
||||
> 长期维持峰值亮度会显著加剧 OLED 屏幕老化与烧屏风险,并大幅增加设备发热与耗电。请根据使用场景合理配置,切勿超出设备硬件安全范围。
|
||||
|
||||
- 确保填写的亮度数值在设备硬件支持的安全范围内。
|
||||
- 遇到问题时,请通过 WebUI 日志页导出运行日志后反馈至社区。
|
||||
+64
-35
@@ -1,51 +1,80 @@
|
||||
<div align="center">
|
||||
<div align="center">
|
||||
|
||||
# LuminPro
|
||||
|
||||
[中文简体](https://github.com/YuleBest/LuminPro/blob/main/README.md) 丨 English
|
||||
[中文简体](https://github.com/YuleBest/LuminPro/blob/main/README.md) 丨 **English**
|
||||
|
||||
Enable your Android device to display content at boosted brightness anytime
|
||||
*Based on KernelSU WebUI + Event-Driven Architecture*
|
||||
Break past the Android foreground brightness cap and push your screen to its hardware peak — anytime
|
||||
_Powered by KernelSU WebUI + Go Event-Driven Architecture_
|
||||
|
||||
</div>
|
||||
|
||||
## Module Introduction
|
||||
This module allows your Android device to constantly utilize boosted brightness for screen content display. When manually adjusting brightness over a designated threshold limit, the module automatically and smoothly elevates the screen brightness parameter to its maximum hardware-driven state, ensuring clear readability even in strong outdoor daylight.
|
||||
## Overview
|
||||
|
||||
## V2.1 Core Features
|
||||
LuminPro monitors the system brightness sysfs node via a Go-native resident daemon (`luminpro`). Whenever the current brightness exceeds a configured threshold, it smoothly ramps the display up to the hardware maximum — ideal for outdoor readability. The daemon owns listening, decision-making, ramping and state files in a single process, and the full KernelSU WebUI lets you tune every parameter without a reboot.
|
||||
|
||||
- **Zero Drain Background Monitoring (inotifyd)**
|
||||
Say goodbye to infinite loops and heavy active polling overhead. LuminPro natively utilizes an event-driven `inotifyd` listener to respond *only* when the brightness sysfs node alters, fundamentally preserving your device's overall battery life.
|
||||
## V2.3 Core Features
|
||||
|
||||
- **Modernized KernelSU WebUI**
|
||||
No more manual text editing in generic config files! Simply tap the module settings inside your KernelSU manager to seamlessly adjust options directly in a tailored Dark Mode interface:
|
||||
- `Foreground Max Brightness`: The original UI threshold dragging point that initiates the brightness boost.
|
||||
- `Peak Maximum Brightness`: The extreme and ultimate targeted hardware brightness your screen will soar to.
|
||||
- **Zero-Overhead Event Listener (luminpro)**
|
||||
No polling loops, no background spin. The Go daemon (`luminpro`) watches the brightness node with raw inotify, responds only when the file actually changes, and includes a 300ms debounce plus event draining. It self-heals: a lost watch is rebuilt automatically and stale locks are reclaimed.
|
||||
|
||||
- **Smooth Step Transitions**
|
||||
Abrupt, rigid jumps in brightness ruin visual coherence. LuminPro operates via an embedded millisecond-level, 50-step computation curve that scales backlight inputs naturally and sequentially.
|
||||
- **KernelSU WebUI Configuration**
|
||||
Adjust all settings visually inside the module's settings page. Changes take effect **immediately** — no reboot required:
|
||||
- `Foreground Max Brightness` — UI brightness threshold that triggers a boost
|
||||
- `Peak Max Brightness` — hardware brightness value to ramp up to
|
||||
- `Transition Steps` — number of steps for smooth ramping (default: 50)
|
||||
- `Sleep Hours` — time range to suppress boosts (e.g. `2200-0700`)
|
||||
- `Log Level` — control log verbosity (off / error / warn / info)
|
||||
- `Brightness / Max-Brightness node paths` — custom sysfs paths for non-standard devices
|
||||
- `inotify Event Types` — which events the daemon should watch
|
||||
|
||||
- **Sleep & Quiet Hours**
|
||||
You do not need a blinding torch in bed. Tweak quiet night hours (e.g., `1900-0600`) locally via the WebUI. During your configured timeframe, the module enters a silent hibernation ensuring your retinas and sleep remain undisturbed.
|
||||
- **Smooth Step Transition**
|
||||
Millisecond-level 50-step interpolation prevents jarring brightness jumps. The step count is configurable.
|
||||
|
||||
- **Live Status & Direct Logs Dashboard**
|
||||
Capture crucial runtime performance status at a glance. Attain realtime active backlight parameters, executing daemon service PIDs, and direct service logs dynamically straight from the integrated UI.
|
||||
- **Smart Skip Logic**
|
||||
The module automatically skips boosting when:
|
||||
- System adaptive brightness is active
|
||||
- HDR content is detected on screen (configurable)
|
||||
- The foreground app is on the blacklist
|
||||
- The current time falls within the configured sleep range
|
||||
|
||||
## Operations Workflow
|
||||
1. **Initial Calibration Setup**
|
||||
- Employs minimal physical volume-key prompts during ZIP installation to read and memorize your device’s specific maximum limitations. Users upgrading smoothly bypass calibration logic if previous files are preserved.
|
||||
2. **Event Tracking Mode**
|
||||
- Submits a background `inotifyd` observer attaching safely without looping variables toward the standard Android illumination logic path.
|
||||
3. **Debounce Optimization Engine**
|
||||
- Interacting with display slider changes will safely debounce over sub-second timers, avoiding computational race-conditions. It acknowledges exactly where your sliding ends prior to activating iterative hardware boosts.
|
||||
- **App Blacklist**
|
||||
Manage a package / Activity blacklist directly in the WebUI "Apps" tab. Search by package name, pick specific activities using the built-in Activity scanner, and the module stays hands-off whenever a blacklisted app is in the foreground.
|
||||
|
||||
## Quick Installation Instructions
|
||||
1. Flash the packaged module ZIP directly through any framework manager backing WebUI specification features.
|
||||
2. Walk through standard volume physical key verification presses (you may easily skip recalibrations extending old module environments by just pressing Volume+).
|
||||
3. Soft reboot to engage operations.
|
||||
4. If parameters or constraints require tweaking, manipulate values across the internal interface view. All operations are **persisted instantly**.
|
||||
- **Instant Peak Boost (boost.sh)**
|
||||
Trigger a one-shot peak brightness via the manager's Action button or `action.sh`. A second tap restores the original brightness.
|
||||
|
||||
## Vital Precautions
|
||||
- **OLED Burn-in & Escalated Thermal Warning**: Persistently overriding and enforcing intensive display peak loads aggressively drives heat emissions up. Doing so vastly skyrockets irreversible UI ghosting & OLED burn-in permanent issues respectively.
|
||||
- Verify entered tuning numbers remain securely governed matching acceptable values on your manufacturer's specific screen limit boundaries to avert hardware blackout glitches.
|
||||
- Acknowledge inherent hazards prior to extended utilization. If irregular phenomena transpire, inspect native system output records over the built-in front-end log pane.
|
||||
- **Live Status & Log Dashboard**
|
||||
The WebUI status page shows real-time brightness, the daemon PID, and service state. The log page supports level filtering (`INFO` / `WARN` / `ERROR`) and lets you copy or export logs to `/sdcard` with one tap.
|
||||
|
||||
## Configuration Reference
|
||||
|
||||
| Key | Description | Default |
|
||||
| ------------------- | --------------------------------------- | -------------------------- |
|
||||
| `ui_max_bri` | Foreground brightness trigger threshold | `0` (requires calibration) |
|
||||
| `max_bri` | Target peak brightness value | `0` (requires calibration) |
|
||||
| `steps_num` | Ramp transition steps | `50` |
|
||||
| `sleep_time` | Sleep range, format `HHMM-HHMM` | empty (disabled) |
|
||||
| `auto_bri_sleep` | Skip when adaptive brightness is on | `1` (enabled) |
|
||||
| `display_hdr_sleep` | Skip during HDR playback | `0` (disabled) |
|
||||
| `log_level` | Log verbosity (off/error/warn/info) | `info` |
|
||||
| `log_max_size` | Log file size cap (KB) | `512` |
|
||||
| `now_bri_file` | Current brightness sysfs node path | standard panel0 path |
|
||||
| `max_bri_file` | Max brightness sysfs node path | standard panel0 path |
|
||||
| `blacklist_apps` | Blacklisted packages / activities | `[]` |
|
||||
| `inotify_events` | inotify event mask | `c` |
|
||||
|
||||
## Installation
|
||||
|
||||
1. Flash the module ZIP in any KernelSU-compatible manager that supports WebUI.
|
||||
2. Follow the volume-key calibration wizard during installation. Press Volume Up to inherit an existing configuration and skip recalibration.
|
||||
3. Reboot to activate.
|
||||
4. Open the module settings page in your manager to adjust parameters. All changes are applied instantly on save.
|
||||
|
||||
## Warnings
|
||||
|
||||
> ⚠️ **OLED Burn-in & Thermal Warning**
|
||||
> Sustained peak brightness significantly accelerates OLED panel aging and burn-in, and substantially increases device heat output and power draw. Use responsibly and ensure all values stay within your hardware's safe operating range.
|
||||
|
||||
- Double-check that configured brightness values do not exceed your device's hardware limits.
|
||||
- If issues occur, export the runtime log from the WebUI and include it when reporting to the community.
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
#!/system/bin/sh
|
||||
#shellcheck shell=ash
|
||||
|
||||
# LuminPro 手动提升/恢复亮度(转发到 Go 实现)
|
||||
|
||||
MODDIR="$(dirname "$(readlink -f "$0")")"
|
||||
exec "$MODDIR/bin/luminpro" boost
|
||||
+165
-51
@@ -1,34 +1,91 @@
|
||||
import fs from 'fs';
|
||||
import archiver from 'archiver';
|
||||
import fs from 'fs'
|
||||
import path from 'path'
|
||||
import os from 'os'
|
||||
import crypto from 'crypto'
|
||||
import archiver from 'archiver'
|
||||
|
||||
const REPO = 'YuleBest/LuminPro'
|
||||
|
||||
// ---------------------------------
|
||||
// 发布通道: --channel=dev(默认) | beta | stable
|
||||
// dev 不写更新清单,包内 module.prop 去掉 updateJson(不参与自动更新)
|
||||
// beta 写 update-beta.json,包内 module.prop 指向 beta 分支清单
|
||||
// stable 写 update.json,包内 module.prop 指向 main 分支清单
|
||||
// 通道由「刷入的包」决定:KernelSU 只读取已安装模块 module.prop 里的 updateJson。
|
||||
// ---------------------------------
|
||||
const CHANNELS = {
|
||||
dev: { manifest: null, jsonBranch: 'dev', nameSuffix: ' (Dev)' },
|
||||
beta: { manifest: 'update-beta.json', jsonBranch: 'beta', nameSuffix: ' (Beta)' },
|
||||
stable: { manifest: 'update.json', jsonBranch: 'main', nameSuffix: '' },
|
||||
}
|
||||
|
||||
const channelArg = process.argv.slice(2).find((arg) => arg.startsWith('--channel='))
|
||||
const channel = channelArg ? channelArg.split('=')[1] : 'dev'
|
||||
if (!CHANNELS[channel]) {
|
||||
console.error(`[错误] 未知通道: ${channel}(可选 dev / beta / stable)`)
|
||||
process.exit(1)
|
||||
}
|
||||
const { manifest, jsonBranch, nameSuffix } = CHANNELS[channel]
|
||||
|
||||
// 读取版本信息用以命名
|
||||
const propContent = fs.readFileSync('module.prop', 'utf-8');
|
||||
const versionMatch = propContent.match(/^version=(.*)$/m);
|
||||
const versionCodeMatch = propContent.match(/^versionCode=(.*)$/m);
|
||||
const propContent = fs.readFileSync('module.prop', 'utf-8')
|
||||
const versionMatch = propContent.match(/^version=(.*)$/m)
|
||||
const versionCodeMatch = propContent.match(/^versionCode=(.*)$/m)
|
||||
|
||||
const version = versionMatch ? versionMatch[1].trim() : 'Unknown';
|
||||
const versionCodeStr = versionCodeMatch ? versionCodeMatch[1].trim() : '0000';
|
||||
const versionCode = parseInt(versionCodeStr, 10);
|
||||
const version = versionMatch ? versionMatch[1].trim() : 'Unknown'
|
||||
const versionCodeStr = versionCodeMatch ? versionCodeMatch[1].trim() : '0000'
|
||||
const versionCode = parseInt(versionCodeStr, 10)
|
||||
|
||||
const zipName = `LuminPro_${version}-${versionCode}.zip`;
|
||||
const zipName = `LuminPro_${version}.zip`
|
||||
// 发布 tag 约定为版本号小写,Release 资产文件名即 zipName
|
||||
const tag = version.toLowerCase()
|
||||
const zipUrl = `https://github.com/${REPO}/releases/download/${tag}/${zipName}`
|
||||
|
||||
// --- 新增: 自动同步 update.json ---
|
||||
const updateJsonPath = 'update.json';
|
||||
if (fs.existsSync(updateJsonPath)) {
|
||||
try {
|
||||
const updateJson = JSON.parse(fs.readFileSync(updateJsonPath, 'utf-8'));
|
||||
updateJson.versionCode = versionCode;
|
||||
updateJson.version = version;
|
||||
updateJson.zipUrl = `https://share.yule.ink/magisk/mod/luminpro/module/${zipName}`;
|
||||
fs.writeFileSync(updateJsonPath, JSON.stringify(updateJson, null, 4), 'utf-8');
|
||||
console.log(`>>> [1/2] 已同步 update.json (版本: ${version}, Code: ${versionCode})`);
|
||||
} catch (e) {
|
||||
console.error(`[错误] 无法更新 update.json: ${e.message}`);
|
||||
console.log(`\n>>> 通道: ${channel} | 版本: ${version} (${versionCode})`)
|
||||
|
||||
// --- 同步更新清单(仅 stable / beta)---
|
||||
if (manifest) {
|
||||
const payload = {
|
||||
versionCode,
|
||||
version,
|
||||
zipUrl,
|
||||
changelog: `https://raw.githubusercontent.com/${REPO}/${jsonBranch}/changelog.md`,
|
||||
}
|
||||
fs.writeFileSync(manifest, JSON.stringify(payload, null, 4) + '\n', 'utf-8')
|
||||
console.log(`>>> [1/3] 已写入 ${manifest}`)
|
||||
console.log(` zipUrl: ${zipUrl}`)
|
||||
} else {
|
||||
console.log('>>> [1/3] dev 通道不生成更新清单')
|
||||
}
|
||||
// ---------------------------------
|
||||
|
||||
console.log(`\n>>> [2/2] 创建模块 ZIP 压缩包...`);
|
||||
// --- 生成通道专用的 module.prop(不改动仓库内文件)---
|
||||
const propEntries = []
|
||||
for (const line of propContent.split('\n')) {
|
||||
const trimmed = line.trim()
|
||||
if (!trimmed || trimmed.startsWith('#')) continue
|
||||
const idx = trimmed.indexOf('=')
|
||||
if (idx > 0) propEntries.push([trimmed.slice(0, idx), trimmed.slice(idx + 1)])
|
||||
}
|
||||
const setProp = (key, value) => {
|
||||
const found = propEntries.find(([k]) => k === key)
|
||||
if (found) found[1] = value
|
||||
else propEntries.push([key, value])
|
||||
}
|
||||
|
||||
if (nameSuffix) {
|
||||
const nameEntry = propEntries.find(([k]) => k === 'name')
|
||||
setProp('name', `${nameEntry ? nameEntry[1] : 'LuminPro'}${nameSuffix}`)
|
||||
}
|
||||
if (channel === 'dev') {
|
||||
const idx = propEntries.findIndex(([k]) => k === 'updateJson')
|
||||
if (idx >= 0) propEntries.splice(idx, 1)
|
||||
} else {
|
||||
setProp('updateJson', `https://raw.githubusercontent.com/${REPO}/${jsonBranch}/${manifest}`)
|
||||
}
|
||||
|
||||
const generatedProp = propEntries.map(([k, v]) => `${k}=${v}`).join('\n') + '\n'
|
||||
const propTmpPath = path.join(os.tmpdir(), `luminpro-module-${process.pid}.prop`)
|
||||
fs.writeFileSync(propTmpPath, generatedProp, 'utf-8')
|
||||
|
||||
// 明确需要忽略的文件清单
|
||||
const excludes = [
|
||||
@@ -37,63 +94,120 @@ const excludes = [
|
||||
'package-lock.json',
|
||||
'package.json',
|
||||
'pnpm-lock.yaml',
|
||||
'vite.config.js',
|
||||
'src',
|
||||
'public',
|
||||
'.vscode',
|
||||
'.git',
|
||||
'.gitignore',
|
||||
'.github',
|
||||
'.oxfmtrc.json',
|
||||
'.oxlintrc.json',
|
||||
'build.ps1',
|
||||
'build-module.js',
|
||||
'index.html', // 根目录的 html 已构建至 webroot
|
||||
zipName
|
||||
];
|
||||
'webui', // webui 目录已经构建到 webroot
|
||||
'go', // Go 源码,编译产物已复制到 bin/
|
||||
'dist', // 本地下载的构建产物
|
||||
'.zcode', // 编辑器/会话临时文件
|
||||
zipName,
|
||||
]
|
||||
|
||||
console.log(`\n>>> [2/3] 生成 SHA256SUMS...`)
|
||||
|
||||
// 计算可执行文件(所有 .sh 脚本 + bin/ 二进制)的 SHA256
|
||||
function sha256File(filePath) {
|
||||
return crypto.createHash('sha256').update(fs.readFileSync(filePath)).digest('hex')
|
||||
}
|
||||
|
||||
function collectExecutables(dir, baseDir = dir) {
|
||||
const results = []
|
||||
for (const dirent of fs.readdirSync(dir, { withFileTypes: true })) {
|
||||
const full = path.join(dir, dirent.name)
|
||||
const rel = path.relative(baseDir, full).replace(/\\/g, '/')
|
||||
if (dirent.isDirectory()) {
|
||||
results.push(...collectExecutables(full, baseDir))
|
||||
} else if (dirent.name.endsWith('.sh') || dir.endsWith('bin')) {
|
||||
results.push(rel)
|
||||
}
|
||||
}
|
||||
return results
|
||||
}
|
||||
|
||||
const execFiles = collectExecutables('.').filter((f) => !excludes.some((e) => f.startsWith(e)))
|
||||
const sha256Lines = execFiles.sort().map((f) => `${sha256File(f)} ${f}`)
|
||||
const sha256SumsPath = 'SHA256SUMS'
|
||||
fs.writeFileSync(sha256SumsPath, sha256Lines.join('\n') + '\n', 'utf-8')
|
||||
console.log(`已生成 ${sha256Lines.length} 条记录:\n${sha256Lines.join('\n')}`)
|
||||
|
||||
console.log(`\n>>> [3/3] 创建模块 ZIP 压缩包...`)
|
||||
|
||||
// 初始化归档器
|
||||
const output = fs.createWriteStream(zipName);
|
||||
const output = fs.createWriteStream(zipName)
|
||||
const archive = archiver('zip', {
|
||||
zlib: { level: 9 } // 最高压缩等级
|
||||
});
|
||||
zlib: { level: 9 }, // 最高压缩等级
|
||||
})
|
||||
|
||||
output.on('close', function () {
|
||||
console.log(`-----------------------------------`);
|
||||
console.log(`>>> [成功] 打包完成!`);
|
||||
console.log(`输出文件: ${zipName}`);
|
||||
console.log(`文件大小: ${(archive.pointer() / 1024 / 1024).toFixed(2)} MB`);
|
||||
});
|
||||
fs.rmSync(propTmpPath, { force: true })
|
||||
console.log(`-----------------------------------`)
|
||||
console.log(`>>> [成功] 打包完成!`)
|
||||
console.log(`输出文件: ${zipName}`)
|
||||
console.log(`文件大小: ${(archive.pointer() / 1024 / 1024).toFixed(2)} MB`)
|
||||
})
|
||||
|
||||
archive.on('warning', function (err) {
|
||||
if (err.code === 'ENOENT') {
|
||||
console.warn('[警告]', err);
|
||||
console.warn('[警告]', err)
|
||||
} else {
|
||||
throw err;
|
||||
throw err
|
||||
}
|
||||
});
|
||||
})
|
||||
|
||||
archive.on('error', function (err) {
|
||||
throw err;
|
||||
});
|
||||
fs.rmSync(propTmpPath, { force: true })
|
||||
throw err
|
||||
})
|
||||
|
||||
archive.pipe(output);
|
||||
archive.pipe(output)
|
||||
|
||||
// 将所有 .sh 文件统一转换为 LF 换行符,防止 Windows 环境写入 CRLF 导致 ash 报错
|
||||
function fixLineEndings(dir) {
|
||||
for (const dirent of fs.readdirSync(dir, { withFileTypes: true })) {
|
||||
const full = path.join(dir, dirent.name)
|
||||
if (dirent.isDirectory() && !excludes.includes(dirent.name)) {
|
||||
fixLineEndings(full)
|
||||
} else if (dirent.name.endsWith('.sh')) {
|
||||
const content = fs.readFileSync(full, 'utf8')
|
||||
if (content.includes('\r\n')) {
|
||||
fs.writeFileSync(full, content.replace(/\r\n/g, '\n'), 'utf8')
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
fixLineEndings('.')
|
||||
|
||||
// 将没在排除列表里的文件打进去
|
||||
const dirContents = fs.readdirSync('.', { withFileTypes: true });
|
||||
const dirContents = fs.readdirSync('.', { withFileTypes: true })
|
||||
|
||||
let addedItems = [];
|
||||
let addedItems = []
|
||||
|
||||
for (const dirent of dirContents) {
|
||||
const name = dirent.name;
|
||||
const name = dirent.name
|
||||
// module.prop 用通道专用副本替代,跳过仓库内的原文件
|
||||
if (name === 'module.prop') {
|
||||
continue
|
||||
}
|
||||
// 排除黑名单文件夹,同时排除当前目录下已经打包生成的其它压缩包(避免俄罗斯套娃)
|
||||
if (!excludes.includes(name) && !name.endsWith('.zip')) {
|
||||
addedItems.push(name);
|
||||
addedItems.push(name)
|
||||
if (dirent.isDirectory()) {
|
||||
archive.directory(name, name);
|
||||
archive.directory(name, name)
|
||||
} else {
|
||||
archive.file(name, { name: name });
|
||||
archive.file(name, { name: name })
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
console.log(`正在打包以下内容: \n${addedItems.join(', ')}\n`);
|
||||
archive.file(propTmpPath, { name: 'module.prop' })
|
||||
addedItems.push('module.prop')
|
||||
|
||||
archive.finalize();
|
||||
console.log(`正在打包以下内容: \n${addedItems.join(', ')}\n`)
|
||||
|
||||
archive.finalize()
|
||||
@@ -1,14 +1,92 @@
|
||||
# 更新日志
|
||||
|
||||
## V2.5.0-beta.4
|
||||
|
||||
- 修复: 手势导航条区域未适配(改为色块填充:底栏背景延伸到屏幕底部,与导航栏同色)
|
||||
- 修复: edge-to-edge 在部分 KernelSU 版本未生效(改为探测全局 ksu 对象并兼容 enableInsets 命名)
|
||||
|
||||
## V2.5.0-beta.3
|
||||
|
||||
- 修复: 底部导航栏未适配手势导航条(补 viewport-fit=cover 与 edge-to-edge,安全区变量此前恒为 0)
|
||||
- 修复: 文档预览不渲染 HTML 与 GitHub 提示块(`> [!TIP]` 等)
|
||||
- 修复: 活动抓取会误抓到系统桌面,现忽略桌面/系统界面/输入法
|
||||
- 优化: 亮度滑条改为拖动中按 3% 变化实时应用,松手再应用最终值
|
||||
- 优化: NOTE.txt 去掉过期的版本号
|
||||
|
||||
## V2.5.0-beta.2
|
||||
|
||||
- 重构: WebUI 全量重写为 **Material Design 3**(基于 `@material/web`),补全颜色/字阶/形状/动效令牌,支持涟漪与状态层反馈
|
||||
- 新增: **Go JSON API** —— 状态、操作锁、亮度、配置、日志改为一次调用取回结构化数据,界面刷新更快、更省资源
|
||||
- 优化: 移除 Tailwind 与 shadcn 风格组件层,前端体积大幅精简(CSS 58KB → 30KB)
|
||||
- 优化: 顶栏改为 M3 固定样式;底部导航改为标准 M3 导航栏(不再支持拖拽切页)
|
||||
- 优化: 提示改为 M3 snackbar,确认/输入改用 M3 对话框,菜单改用 M3 菜单
|
||||
- 修复: 亮度设置与配置写入统一由 Go 侧校验并原子保存,不再拼接 shell 字符串
|
||||
|
||||
## V2.5.0-beta.1
|
||||
|
||||
- 重构: 核心逻辑全量迁移至 Go,单一常驻守护进程负责监听、判定与渐变写入,移除 Rust 监听器与 jq 依赖(模块体积减少约 1.8MB)
|
||||
- 新增: **操作锁** —— 后台写亮度期间 WebUI 自动暂停刷新、禁用写操作入口并显示顶部提示
|
||||
- 新增: HDR 休眠双阈值迟滞机制,进入/退出阈值可在 WebUI 自定义(默认 1.15 / 1.05)
|
||||
- 新增: 黑名单列表虚拟滚动,500+ 应用时滑动依然流畅
|
||||
- 新增: 版本通道(正式 / 预览),预览版与正式版互不干扰
|
||||
- 优化: 状态页移除「自动亮度调节」开关;「智能选择」提为一级按钮
|
||||
- 优化: 配置页改用「已保存 / 未保存」徽标,「系统管理」并入高级设置
|
||||
- 修复: 设备默认亮度节点不可用时改为允许安装但功能保持关闭
|
||||
|
||||
## V2.4-2401
|
||||
|
||||
- 新增: **兼容模式 (轮询驱动)**,支持部分无法通过事件驱动监听亮度的机型,增强设备兼容性
|
||||
- 修复: 遗留文件锁 (Stale Lock) 导致脚本失效的问题,引入 PID 存活检测与自动自愈机制
|
||||
- 优化: 提升守护进程与系统服务的健壮性,开机及手动重启会自动刷新环境标记
|
||||
- 新增: 完善 **[DEVELOPMENT.md](./DEVELOPMENT.md)** 开发文档,规范化云端 GitHub Actions 自动化构建流程
|
||||
- 修复: 其他已知逻辑漏洞与 UI 细节显示优化
|
||||
|
||||
## V2.3-2301
|
||||
|
||||
- 新增: 引入 Rust 编写的 `lumipro` 二进制程序,取代 `inotifyd` 作为亮度文件监听器,内置防抖动与调试模式,提升稳定性
|
||||
- 新增: HDR 内容避让功能,播放 HDR 视频时自动退让亮度提升
|
||||
- 新增: 日志等级配置,支持 关闭 / 仅错误 / 警告+ / 全部,有效减少日志量
|
||||
- 新增: 活动级黑名单功能,可指定应用在前台时禁止模块提升亮度
|
||||
- 重构: 配置文件由多个独立文本文件合并为单一 `config.json`
|
||||
- 重构: Web UI 前端框架升级为 Vue 3 + Vite,组件化重构全部页面
|
||||
- 新增: Web UI 界面缩放、日志导出、设置卡片折叠、header 自动收起等功能
|
||||
- 优化: Web UI 页面切换动画、亮度进度条动画、底栏导航动画
|
||||
- 修复: 日志关键字过滤不生效的问题
|
||||
- 修复: 修复其他已知问题
|
||||
|
||||
## v2.2-2208
|
||||
|
||||
- 新增: 黑名单功能,可在指定应用内禁止模块工作
|
||||
- 新增: Web UI 日志导出、复制功能
|
||||
- 优化: Web UI 外观
|
||||
- 优化: 日志信息
|
||||
|
||||
## V2.2-2204
|
||||
|
||||
- 新增: `boost.sh` 脚本,支持一键将亮度提升至峰值极限
|
||||
- 新增: 对于部分设备,支持在刷入时建议更改配置文件以适配
|
||||
- 新增: inotifyd 的进程守护脚本,确保 inotifyd 进程的稳定性
|
||||
- 新增: 支持自定义亮度文件设备路径
|
||||
- 新增: 支持自定义 inotifyd 监测的事件
|
||||
- 优化: Web UI 页面外观优化
|
||||
- 优化: Web UI 的亮度刷新机制,优化性能
|
||||
- 优化: 进程抢占机制,避免同时运行多个提升亮度的进程
|
||||
- 修复: 刷入脚本中的配置继承问题
|
||||
|
||||
## V2.2-2202
|
||||
|
||||
### 核心逻辑
|
||||
|
||||
- 新增: `action.sh` 支持模块管理器“操作”按钮点击快速切换开关状态
|
||||
- 新增: `stop.flag` 机制,支持在不重启服务的情况下拦截亮度提升逻辑
|
||||
- 重构: `up.sh` 逻辑,支持日志内容比对刷新及文件大小自动截断
|
||||
- 新增: 支持自动亮度休眠;支持自定义调整步数
|
||||
- 新增: `restart.sh` 脚本,实现 PID 清理、Flag 重置及服务重启的原子化操作。
|
||||
- 修复: 2.1 版本中,反复重启 inotifyd 造成的卡死问题
|
||||
- 完善 `customize.sh` 的迁移逻辑,支持从 2101 版本自动补全缺失配置及备份目录
|
||||
|
||||
### WebUI
|
||||
|
||||
- 重构: 将配置划分为“亮度调节”、“执行策略”及“系统管理”三大板块
|
||||
- 优化: 移除手动刷新按钮,实现 0.5s 频率的实时动态状态与日志监控
|
||||
- 优化: “定时休眠”采用开关折叠设计,优化窄屏移动端布局
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
{
|
||||
"ui_max_bri": 0,
|
||||
"max_bri": 0,
|
||||
"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,
|
||||
"sleep_time": "",
|
||||
"inotify_events": "c",
|
||||
"now_bri_file": "/sys/class/backlight/panel0-backlight/brightness",
|
||||
"max_bri_file": "/sys/class/backlight/panel0-backlight/max_brightness",
|
||||
"blacklist_apps": []
|
||||
}
|
||||
+307
-165
@@ -1,229 +1,371 @@
|
||||
#!/system/bin/sh
|
||||
#shellcheck shell=ash
|
||||
|
||||
now_bri_file="/sys/class/backlight/panel0-backlight/brightness"
|
||||
max_bri_file="/sys/class/backlight/panel0-backlight/max_brightness"
|
||||
# ==========================
|
||||
# ARM64 架构检查
|
||||
# ==========================
|
||||
ARCH=$(getprop ro.product.cpu.abi)
|
||||
if [ "$ARCH" != "arm64-v8a" ]; then
|
||||
ui_print "********************************"
|
||||
ui_print " 本模块仅支持 ARM64 设备!"
|
||||
ui_print " 当前架构: $ARCH"
|
||||
ui_print "********************************"
|
||||
abort "不支持的架构: $ARCH"
|
||||
fi
|
||||
|
||||
# 默认设备路径
|
||||
DEFAULT_NOW_BRI_FILE="/sys/class/backlight/panel0-backlight/brightness"
|
||||
DEFAULT_MAX_BRI_FILE="/sys/class/backlight/panel0-backlight/max_brightness"
|
||||
|
||||
mod_config="$MODPATH/config"
|
||||
old_config="/data/adb/modules/LuminPro/config"
|
||||
|
||||
# 创建配置目录
|
||||
[ -d "$mod_config" ] || mkdir -p "$mod_config"
|
||||
# Go 二进制(已随模块提取),负责全部 JSON 配置读写
|
||||
BIN="$MODPATH/bin/luminpro"
|
||||
CONFIG_FILE="$mod_config/config.json"
|
||||
|
||||
# 监听音量键函数
|
||||
button_listener() {
|
||||
local choose
|
||||
local branch
|
||||
mkdir -p "$mod_config"
|
||||
chmod 755 "$BIN" 2>/dev/null
|
||||
|
||||
# 亮度节点校验结果: 1 = 默认节点不可用 (安装继续, 但功能不启用)
|
||||
NODE_MISSING=0
|
||||
|
||||
# ==========================
|
||||
# 工具函数
|
||||
# ==========================
|
||||
|
||||
# 读取配置字段,缺失或为空时返回默认值
|
||||
cfg_get() {
|
||||
local key="$1" default="$2" val
|
||||
val="$("$BIN" config get "$key" 2>/dev/null)"
|
||||
if [ -n "$val" ]; then
|
||||
echo "$val"
|
||||
else
|
||||
echo "$default"
|
||||
fi
|
||||
}
|
||||
|
||||
# 取正值字段(0 视为未配置,输出空)
|
||||
cfg_pos() {
|
||||
local v
|
||||
v="$(cfg_get "$1" 0)"
|
||||
case "$v" in
|
||||
'' | 0) echo "" ;;
|
||||
*) echo "$v" ;;
|
||||
esac
|
||||
}
|
||||
|
||||
# 从 key=value 输出中提取字段(供 config inspect / summary 使用)
|
||||
field() {
|
||||
sed -n "s/^$1=//p" | head -n 1
|
||||
}
|
||||
|
||||
# 0/1 转中文
|
||||
onoff() {
|
||||
[ "$1" = "1" ] && echo "开启" || echo "关闭"
|
||||
}
|
||||
|
||||
# ==========================
|
||||
# 安装流程函数
|
||||
# ==========================
|
||||
|
||||
btn() {
|
||||
while :; do
|
||||
choose="$(getevent -qlc 1 | awk '{ print $3 }')"
|
||||
case "$choose" in
|
||||
KEY_VOLUMEUP) branch="0" ;;
|
||||
KEY_VOLUMEDOWN) branch="1" ;;
|
||||
*) continue ;;
|
||||
local c
|
||||
c="$(getevent -qlc 1 | awk '{ print $3 }')"
|
||||
case "$c" in
|
||||
KEY_VOLUMEUP)
|
||||
echo "0"
|
||||
return
|
||||
;;
|
||||
KEY_VOLUMEDOWN)
|
||||
echo "1"
|
||||
return
|
||||
;;
|
||||
esac
|
||||
echo "$branch"
|
||||
break
|
||||
done
|
||||
}
|
||||
|
||||
# 注意事项
|
||||
SHOW_CHANGELOG() {
|
||||
local changelog_file="$MODPATH/changelog.md"
|
||||
if [ -f "$changelog_file" ]; then
|
||||
echo "--------------------------------------"
|
||||
echo "- 本次更新日志:"
|
||||
# 提取第一个二级标题及其内容,直到遇到下一个二级标题或文件结束
|
||||
# 使用更具兼容性的 awk 逻辑
|
||||
awk '/^## / { if (p) exit; p=1; print; next } p { print }' "$changelog_file"
|
||||
echo "--------------------------------------"
|
||||
fi
|
||||
local f="$MODPATH/changelog.md"
|
||||
[ -f "$f" ] || return
|
||||
echo "========================================"
|
||||
echo " ✦ 本次更新日志:"
|
||||
awk '/^## / { if (p) exit; p=1; print; next } p { print }' "$f"
|
||||
echo "========================================"
|
||||
}
|
||||
|
||||
NOTE() {
|
||||
cat "$MODPATH/NOTE.txt"
|
||||
echo ""
|
||||
echo "* 按音量 + 进入下一步, 按音量 - 退出"
|
||||
echo "* 继续则表明你已理解并接受所有风险"
|
||||
|
||||
if [ "$(button_listener)" = "0" ]; then
|
||||
echo "- 已确认进入下一步"
|
||||
else
|
||||
abort "- 已退出"
|
||||
fi
|
||||
echo " ❆ 按音量 + 进入下一步, 按音量 - 退出"
|
||||
echo " ❆ 继续则表明你已理解并接受所有风险"
|
||||
[ "$(btn)" = "0" ] && echo " ✦ 已确认" || abort " ✗ 已退出"
|
||||
}
|
||||
|
||||
# 检查亮度节点文件
|
||||
CHECK_FILES() {
|
||||
sleep 1
|
||||
now_bri_file="$(cfg_get now_bri_file "$DEFAULT_NOW_BRI_FILE")"
|
||||
max_bri_file="$(cfg_get max_bri_file "$DEFAULT_MAX_BRI_FILE")"
|
||||
|
||||
echo ""
|
||||
echo " ✦ 正在验证设备亮度节点..."
|
||||
echo " ✦ 当前亮度节点: $now_bri_file"
|
||||
echo " ✦ 最大亮度节点: $max_bri_file"
|
||||
echo ""
|
||||
|
||||
if [ -f "$now_bri_file" ] && [ -f "$max_bri_file" ]; then
|
||||
echo "- 找到亮度节点文件"
|
||||
else
|
||||
echo "x 未找到亮度节点文件"
|
||||
abort "x 暂不支持您的设备"
|
||||
echo " ✦ 找到亮度节点文件"
|
||||
echo " ✦ 当前亮度: $(cat "$now_bri_file")"
|
||||
echo " ✦ 系统最大亮度: $(cat "$max_bri_file")"
|
||||
return 0
|
||||
fi
|
||||
|
||||
now_bri="$(cat "$now_bri_file")"
|
||||
max_bri="$(cat "$max_bri_file")"
|
||||
|
||||
echo "- 当前亮度: $now_bri"
|
||||
echo "- 最大亮度: $max_bri"
|
||||
# 节点缺失不再中止安装: 继续安装, 但重启后功能不会启用 (见 service.sh)
|
||||
[ ! -f "$now_bri_file" ] && echo " ✗ 当前亮度节点不存在: $now_bri_file"
|
||||
[ ! -f "$max_bri_file" ] && echo " ✗ 最大亮度节点不存在: $max_bri_file"
|
||||
echo ""
|
||||
echo " ◇ 设备默认亮度节点不可用, 将继续安装但功能不会启用"
|
||||
echo " ◇ 安装后可在 Web UI 配置正确的亮度节点路径, 然后重启模块启用"
|
||||
echo " ◇ 查找路径: find /sys -name '*brightness*' 2>/dev/null"
|
||||
NODE_MISSING=1
|
||||
return 1
|
||||
}
|
||||
|
||||
# 测试前台最大亮度
|
||||
TEST_UI_MAX_BRI() {
|
||||
echo ""
|
||||
echo "- 开始测试前台最大亮度"
|
||||
echo " ✿ 开始测试前台最大亮度"
|
||||
echo ""
|
||||
|
||||
sleep 1
|
||||
echo "******** 请关闭自动亮度 ********"
|
||||
echo "* 按音量 + 进入下一步, 按音量 - 退出"
|
||||
|
||||
if [ "$(button_listener)" = "0" ]; then
|
||||
echo "- 已确认进入下一步"
|
||||
else
|
||||
abort "- 已退出"
|
||||
fi
|
||||
echo "======== 请关闭自动亮度 ========"
|
||||
echo " ❆ 按音量 + 进入下一步, 按音量 - 退出"
|
||||
[ "$(btn)" = "0" ] && echo " ✦ 已确认" || abort " ✗ 已退出"
|
||||
|
||||
# 调整亮度前, 记录当前亮度用于之后恢复
|
||||
local restore_bri
|
||||
restore_bri="$(cat "$now_bri_file")"
|
||||
echo ""
|
||||
|
||||
sleep 1
|
||||
echo "******** 请将屏幕亮度调至最大 ********"
|
||||
echo "* 按音量 + 进入下一步, 按音量 - 退出"
|
||||
|
||||
if [ "$(button_listener)" = "0" ]; then
|
||||
echo "- 已确认进入下一步"
|
||||
else
|
||||
abort "- 已退出"
|
||||
fi
|
||||
echo "======== 请将屏幕亮度调至最大 ========"
|
||||
echo " ❆ 按音量 + 进入下一步, 按音量 - 退出"
|
||||
[ "$(btn)" = "0" ] && echo " ✦ 已确认" || abort " ✗ 已退出"
|
||||
|
||||
ui_max_bri="$(cat "$now_bri_file")"
|
||||
echo "- 前台最大亮度: [ $ui_max_bri ]"
|
||||
echo -n "$ui_max_bri" >"$mod_config/ui_max_bri.txt"
|
||||
local measured_ui measured_max
|
||||
measured_ui="$(cat "$now_bri_file")"
|
||||
measured_max="$(cat "$max_bri_file")"
|
||||
echo " ✦ 前台最大亮度: [ $measured_ui ]"
|
||||
echo " ✦ 峰值最大亮度由节点文件获得: [ $measured_max ]"
|
||||
echo " ✦ 若不符合预期,请稍后到 Web UI 更改"
|
||||
|
||||
"$BIN" config set "ui_max_bri=$measured_ui" "max_bri=$measured_max" >/dev/null 2>&1
|
||||
|
||||
echo ""
|
||||
echo "- 峰值最大亮度由节点文件获得: [ $max_bri ]"
|
||||
echo "- 若不符合预期, 请稍后到配置文件或 Web UI 更改"
|
||||
echo -n "$max_bri" >"$mod_config/max_bri.txt"
|
||||
|
||||
echo ""
|
||||
echo "- 测试完成"
|
||||
echo "- 正在为你恢复亮度..."
|
||||
echo " ✦ 测试完成"
|
||||
echo " ✦ 正在恢复亮度..."
|
||||
echo -n "$restore_bri" >"$now_bri_file"
|
||||
}
|
||||
|
||||
# 结束
|
||||
# 导入旧配置(支持 JSON 格式和旧 txt 格式)
|
||||
IMPORT_OLD_CONFIG() {
|
||||
local out format v
|
||||
|
||||
# 让 Go 侧判断是否存在可用旧配置并输出字段
|
||||
out="$("$BIN" config inspect "$old_config" 2>/dev/null)" || return 1
|
||||
format="$(echo "$out" | field format)"
|
||||
|
||||
# 1. 已有 JSON 格式
|
||||
if [ "$format" = "json" ]; then
|
||||
echo ""
|
||||
sleep 1
|
||||
echo " ✦ 检测到已有 JSON 配置:"
|
||||
echo " - 前台最大亮度: $(echo "$out" | field ui_max_bri)"
|
||||
echo " - 峰值最大亮度: $(echo "$out" | field max_bri)"
|
||||
v="$(echo "$out" | field sleep_time)"
|
||||
[ -n "$v" ] && echo " - 休眠时间: $v"
|
||||
echo ""
|
||||
echo " ❆ 按音量 + 沿用旧配置, 按音量 - 重新测试"
|
||||
if [ "$(btn)" = "0" ]; then
|
||||
"$BIN" config migrate "$old_config" >/dev/null 2>&1
|
||||
echo " ✦ 已导入 JSON 配置"
|
||||
return 0
|
||||
fi
|
||||
echo " ❆ 将重新测试"
|
||||
return 1
|
||||
fi
|
||||
|
||||
# 2. 旧 txt 格式迁移
|
||||
if [ "$format" = "txt" ]; then
|
||||
echo ""
|
||||
sleep 1
|
||||
echo " ✦ 检测到旧格式配置,将迁移至 JSON:"
|
||||
echo " - 前台最大亮度: $(echo "$out" | field ui_max_bri)"
|
||||
echo " - 峰值最大亮度: $(echo "$out" | field max_bri)"
|
||||
v="$(echo "$out" | field sleep_time)"
|
||||
[ -n "$v" ] && echo " - 休眠时间: $v"
|
||||
v="$(echo "$out" | field auto_bri_sleep)"
|
||||
[ -n "$v" ] && echo " - 自动亮度时休眠: $(onoff "$v")"
|
||||
v="$(echo "$out" | field steps_num)"
|
||||
[ -n "$v" ] && echo " - 亮度步数: $v"
|
||||
v="$(echo "$out" | field log_max_size)"
|
||||
[ -n "$v" ] && echo " - 日志限制: $v KB"
|
||||
v="$(echo "$out" | field blacklist_count)"
|
||||
[ "$v" != "0" ] && [ -n "$v" ] && echo " - 黑名单: $v 个"
|
||||
echo ""
|
||||
echo " ❆ 按音量 + 沿用旧配置, 按音量 - 重新测试"
|
||||
if [ "$(btn)" = "0" ]; then
|
||||
"$BIN" config migrate "$old_config" >/dev/null 2>&1
|
||||
"$BIN" config remove-old-txt "$old_config" >/dev/null 2>&1
|
||||
echo " ✦ 配置已迁移至 JSON, 旧文件已清理"
|
||||
return 0
|
||||
fi
|
||||
echo " ❆ 将重新测试"
|
||||
return 1
|
||||
fi
|
||||
|
||||
return 1
|
||||
}
|
||||
|
||||
# 初始化默认配置
|
||||
INIT_CONFIG() {
|
||||
mkdir -p "$mod_config"
|
||||
"$BIN" config init 2>/dev/null
|
||||
}
|
||||
|
||||
# 补全缺失字段
|
||||
ENSURE_DEFAULTS() {
|
||||
"$BIN" config ensure 2>/dev/null
|
||||
}
|
||||
|
||||
# 机型兼容性校验
|
||||
CHECK_DEVICE_COMPATIBILITY() {
|
||||
local model prefix
|
||||
model="$(getprop ro.product.model)"
|
||||
prefix="$(echo "$model" | cut -c 1-9)"
|
||||
|
||||
if [ "$prefix" = "25128PNA1" ] || [ "$prefix" = "2512BPNDA" ]; then
|
||||
echo ""
|
||||
echo " ✿ 您可能是 Xiaomi 17 Ultra 用户,建议使用 '0' 事件作为监测对象"
|
||||
echo " ✿ 是否将监听事件修改为 '0'? (音量 + 确认,音量 - 跳过)"
|
||||
if [ "$(btn)" = "0" ]; then
|
||||
"$BIN" config set inotify_events=0 >/dev/null 2>&1
|
||||
echo " ✦ 已设置为 0 事件监测"
|
||||
else
|
||||
echo " ✦ 已跳过"
|
||||
fi
|
||||
sleep 1
|
||||
fi
|
||||
}
|
||||
|
||||
# 创建备份(供 WebUI 恢复默认用)
|
||||
CREATE_BACKUP() {
|
||||
mkdir -p "$mod_config/.backup"
|
||||
cp -f "$CONFIG_FILE" "$mod_config/.backup/config.json"
|
||||
}
|
||||
|
||||
END() {
|
||||
echo ""
|
||||
sleep 1
|
||||
echo "******** 模块策略:"
|
||||
echo "- 当亮度达到 [ $(cat "$mod_config/ui_max_bri.txt") ] 时, 自动提升至 [ $(cat "$mod_config/max_bri.txt") ]"
|
||||
echo "- 配置目录: /data/adb/modules/LuminPro/config"
|
||||
echo "- 也可以使用 Web UI 进行配置"
|
||||
|
||||
local summary
|
||||
summary="$("$BIN" config summary 2>/dev/null)"
|
||||
|
||||
# 确保 now_bri_file / max_bri_file 已设置(import 路径可能未调用 CHECK_FILES)
|
||||
: "${now_bri_file:=$(cfg_get now_bri_file "$DEFAULT_NOW_BRI_FILE")}"
|
||||
: "${max_bri_file:=$(cfg_get max_bri_file "$DEFAULT_MAX_BRI_FILE")}"
|
||||
|
||||
local final_ui final_max
|
||||
final_ui="$(cfg_pos ui_max_bri)"
|
||||
final_max="$(cfg_pos max_bri)"
|
||||
|
||||
if [ -z "$final_max" ] || [ -z "$final_ui" ]; then
|
||||
if [ "$NODE_MISSING" = "1" ]; then
|
||||
echo ""
|
||||
echo "======== 亮度节点不可用 ========"
|
||||
echo " ✕ 已跳过亮度校准 (节点不存在, 无法读写亮度)"
|
||||
echo " ❆ 安装后请在 Web UI 配置亮度节点路径并校准亮度值"
|
||||
echo " ❆ 配置完成后点击「重启模块」即可启用模块功能"
|
||||
else
|
||||
echo ""
|
||||
echo "======== 配置不完整 ========"
|
||||
[ -z "$final_max" ] && echo " ✕ 峰值最大亮度: 未配置" || echo " ✦ 峰值最大亮度: $final_max"
|
||||
[ -z "$final_ui" ] && echo " ✕ 前台最大亮度: 未配置" || echo " ✦ 前台最大亮度: $final_ui"
|
||||
echo ""
|
||||
echo " ❆ 配置缺失, 请重启后通过 Web UI 手动配置"
|
||||
echo " ❆ 或按音量 + 现在进行测试, 按音量 - 跳过"
|
||||
if [ "$(btn)" = "0" ]; then
|
||||
TEST_UI_MAX_BRI
|
||||
final_ui="$(cfg_pos ui_max_bri)"
|
||||
final_max="$(cfg_pos max_bri)"
|
||||
summary="$("$BIN" config summary 2>/dev/null)"
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
local steps log_size auto_bri disp_hdr st inotify bl_count now_path max_path
|
||||
steps="$(echo "$summary" | field steps_num)"
|
||||
log_size="$(echo "$summary" | field log_max_size)"
|
||||
auto_bri="$(echo "$summary" | field auto_bri_sleep)"
|
||||
disp_hdr="$(echo "$summary" | field display_hdr_sleep)"
|
||||
st="$(echo "$summary" | field sleep_time)"
|
||||
inotify="$(echo "$summary" | field inotify_events)"
|
||||
now_path="$(echo "$summary" | field now_bri_file)"
|
||||
max_path="$(echo "$summary" | field max_bri_file)"
|
||||
bl_count="$(echo "$summary" | field blacklist_count)"
|
||||
|
||||
echo ""
|
||||
echo "* 模块已刷入, 请重启手机"
|
||||
echo "- 感谢您的使用"
|
||||
echo "- 作者: 酷安 @于乐yule"
|
||||
echo "======== 将要应用的配置 ========"
|
||||
echo " - 前台最大亮度: $final_ui"
|
||||
echo " - 峰值最大亮度: $final_max"
|
||||
echo " - 亮度渐变步数: $steps"
|
||||
echo " - 日志大小上限: ${log_size} KB"
|
||||
echo " - 自动亮度时跳过: $(onoff "$auto_bri")"
|
||||
echo " - HDR 内容时跳过: $(onoff "$disp_hdr")"
|
||||
echo " - 兼容模式 (轮询): $(onoff "$(echo "$summary" | field compatibility_mode)")"
|
||||
if [ -n "$st" ]; then
|
||||
echo " - 休眠时段: $st"
|
||||
else
|
||||
echo " - 休眠时段: 未配置"
|
||||
fi
|
||||
echo " - 监听事件: $inotify"
|
||||
echo " - 当前亮度节点: $now_path"
|
||||
echo " - 最大亮度节点: $max_path"
|
||||
[ ! -f "$now_path" ] && echo " ⚠ 当前亮度节点不存在, 重启后功能将不会启用"
|
||||
echo " - 黑名单应用: ${bl_count} 个"
|
||||
echo "==============================="
|
||||
echo " ❆ 配置文件: /data/adb/modules/LuminPro/config/config.json"
|
||||
echo " ❆ 也可以使用 Web UI 进行配置"
|
||||
if [ "$NODE_MISSING" = "1" ]; then
|
||||
echo ""
|
||||
echo "======== ⚠ 模块功能未启用 ========"
|
||||
echo " ✗ 设备默认亮度节点不可用, 本次安装不会开启亮度提升"
|
||||
echo " ❆ 请在 Web UI「配置」中填写正确的亮度节点路径并保存"
|
||||
echo " ❆ 然后点击「重启模块」即可启用, 无需重新刷入"
|
||||
fi
|
||||
echo ""
|
||||
echo " ✦ 模块已刷入,请重启手机"
|
||||
echo " ❆ 感谢您的使用"
|
||||
echo " ❆ 作者: 酷安 @于乐yule"
|
||||
echo ""
|
||||
|
||||
sleep 1
|
||||
exit 0
|
||||
}
|
||||
|
||||
# 导入旧配置
|
||||
IMPORT_OLD_CONFIG() {
|
||||
if [ -d "$old_config" ] &&
|
||||
[ -s "$old_config/ui_max_bri.txt" ] &&
|
||||
[ -s "$old_config/max_bri.txt" ]; then
|
||||
|
||||
echo ""
|
||||
sleep 1
|
||||
echo "- 检测到已有配置:"
|
||||
echo " - 前台最大亮度: $(cat "$old_config/ui_max_bri.txt")"
|
||||
echo " - 峰值最大亮度: $(cat "$old_config/max_bri.txt")"
|
||||
if [ -s "$old_config/sleep_time.txt" ]; then
|
||||
echo " - 休眠时间: $(cat "$old_config/sleep_time.txt")"
|
||||
fi
|
||||
if [ -s "$old_config/auto_bri_sleep.txt" ]; then
|
||||
echo " - 自动亮度时休眠: $(cat "$old_config/auto_bri_sleep.txt" | sed 's/1/开启/;s/0/关闭/')"
|
||||
fi
|
||||
if [ -s "$old_config/steps_num.txt" ]; then
|
||||
echo " - 亮度提升步数: $(cat "$old_config/steps_num.txt")"
|
||||
fi
|
||||
if [ -s "$old_config/log_max_size.txt" ]; then
|
||||
echo " - 日志大小限制: $(cat "$old_config/log_max_size.txt") KB"
|
||||
fi
|
||||
echo ""
|
||||
echo "* 按音量 + 沿用旧配置, 按音量 - 重新测试"
|
||||
|
||||
if [ "$(button_listener)" = "0" ]; then
|
||||
echo "- 已沿用旧配置"
|
||||
cp -f "$old_config/ui_max_bri.txt" "$mod_config/"
|
||||
cp -f "$old_config/max_bri.txt" "$mod_config/"
|
||||
[ -s "$old_config/sleep_time.txt" ] && cp -f "$old_config/sleep_time.txt" "$mod_config/"
|
||||
[ -s "$old_config/auto_bri_sleep.txt" ] && cp -f "$old_config/auto_bri_sleep.txt" "$mod_config/"
|
||||
[ -s "$old_config/steps_num.txt" ] && cp -f "$old_config/steps_num.txt" "$mod_config/"
|
||||
[ -s "$old_config/log_max_size.txt" ] && cp -f "$old_config/log_max_size.txt" "$mod_config/"
|
||||
|
||||
# 版本迁移逻辑
|
||||
local old_version_code
|
||||
old_version_code="$(grep_get_prop versionCode "/data/adb/modules/LuminPro/module.prop")"
|
||||
if [ "$old_version_code" = "2101" ] && [ ! -d "$old_config/.backup" ]; then
|
||||
echo "- 检测到从 2101 版本升级, 正在补全备份目录..."
|
||||
mkdir -p "$mod_config/.backup"
|
||||
cp -f "$mod_config/"*.txt "$mod_config/.backup/" 2>/dev/null
|
||||
else
|
||||
# 正常备份同步
|
||||
mkdir -p "$mod_config/.backup"
|
||||
[ -d "$old_config/.backup" ] && cp -rf "$old_config/.backup/." "$mod_config/.backup/"
|
||||
fi
|
||||
return 0
|
||||
else
|
||||
echo "- 将重新测试"
|
||||
return 1
|
||||
fi
|
||||
fi
|
||||
return 1
|
||||
}
|
||||
|
||||
# 初始化默认配置文件
|
||||
INIT_CONFIG() {
|
||||
mkdir -p "$mod_config"
|
||||
touch "$mod_config/ui_max_bri.txt"
|
||||
touch "$mod_config/max_bri.txt"
|
||||
}
|
||||
|
||||
# 补全缺失设置并设定默认值
|
||||
ENSURE_DEFAULTS() {
|
||||
[ ! -s "$mod_config/sleep_time.txt" ] && echo "1900-0600" >"$mod_config/sleep_time.txt"
|
||||
[ ! -s "$mod_config/auto_bri_sleep.txt" ] && echo "1" >"$mod_config/auto_bri_sleep.txt"
|
||||
[ ! -s "$mod_config/steps_num.txt" ] && echo "50" >"$mod_config/steps_num.txt"
|
||||
[ ! -s "$mod_config/log_max_size.txt" ] && echo "500" >"$mod_config/log_max_size.txt"
|
||||
}
|
||||
|
||||
# 创建备份 (用于 WebUI 恢复默认)
|
||||
CREATE_BACKUP() {
|
||||
mkdir -p "$mod_config/.backup"
|
||||
cp -f "$mod_config/ui_max_bri.txt" "$mod_config/.backup/"
|
||||
cp -f "$mod_config/max_bri.txt" "$mod_config/.backup/"
|
||||
cp -f "$mod_config/sleep_time.txt" "$mod_config/.backup/"
|
||||
cp -f "$mod_config/auto_bri_sleep.txt" "$mod_config/.backup/"
|
||||
cp -f "$mod_config/steps_num.txt" "$mod_config/.backup/"
|
||||
cp -f "$mod_config/log_max_size.txt" "$mod_config/.backup/"
|
||||
}
|
||||
|
||||
# 主函数
|
||||
MAIN() {
|
||||
NOTE
|
||||
SHOW_CHANGELOG
|
||||
if ! IMPORT_OLD_CONFIG; then
|
||||
INIT_CONFIG
|
||||
CHECK_FILES
|
||||
TEST_UI_MAX_BRI
|
||||
if [ "$NODE_MISSING" = "1" ]; then
|
||||
echo ""
|
||||
echo " ⚠ 亮度节点不可用, 跳过亮度校准"
|
||||
else
|
||||
TEST_UI_MAX_BRI
|
||||
fi
|
||||
fi
|
||||
ENSURE_DEFAULTS
|
||||
CHECK_DEVICE_COMPATIBILITY
|
||||
CREATE_BACKUP
|
||||
END
|
||||
}
|
||||
|
||||
@@ -0,0 +1,350 @@
|
||||
// 命令 luminpro 是 LuminPro 模块的 Go 实现入口。
|
||||
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"
|
||||
"github.com/YuleBest/LuminPro/go/internal/system"
|
||||
)
|
||||
|
||||
func main() {
|
||||
if err := run(os.Args[1:]); err != nil {
|
||||
fmt.Fprintln(os.Stderr, "luminpro: "+err.Error())
|
||||
os.Exit(1)
|
||||
}
|
||||
}
|
||||
|
||||
func run(args []string) error {
|
||||
if len(args) == 0 {
|
||||
return usage()
|
||||
}
|
||||
moduleDir, err := resolveModuleDir()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
paths := api.DefaultPaths(moduleDir)
|
||||
log := logging.New(paths.LogFile, config.DefaultLogLevel, config.DefaultLogMaxSize)
|
||||
|
||||
switch args[0] {
|
||||
case "daemon":
|
||||
d, err := daemon.New(paths, daemon.Deps{
|
||||
AutoBrightness: system.AutoBrightness{Runner: system.ExecRunner{}},
|
||||
Focus: system.Focus{Runner: system.ExecRunner{}},
|
||||
HDR: system.HdrRatio{Runner: system.ExecRunner{}},
|
||||
Log: log,
|
||||
})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return d.Run()
|
||||
case "boost":
|
||||
return daemon.Boost(paths, log)
|
||||
case "restart":
|
||||
self, err := os.Executable()
|
||||
if err != nil {
|
||||
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:
|
||||
return fmt.Errorf("未知子命令: %s", args[0])
|
||||
}
|
||||
}
|
||||
|
||||
func usage() error {
|
||||
fmt.Print(`luminpro - LuminPro 模块守护进程
|
||||
|
||||
用法:
|
||||
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 覆盖(调试用)。
|
||||
`)
|
||||
return nil
|
||||
}
|
||||
|
||||
// resolveModuleDir 推导模块根目录:<module>/bin/luminpro -> <module>。
|
||||
func resolveModuleDir() (string, error) {
|
||||
if v := os.Getenv("LUMINPRO_MODDIR"); v != "" {
|
||||
return v, nil
|
||||
}
|
||||
exe, err := os.Executable()
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
if resolved, err := filepath.EvalSymlinks(exe); err == nil {
|
||||
exe = resolved
|
||||
}
|
||||
return filepath.Dir(filepath.Dir(exe)), nil
|
||||
}
|
||||
|
||||
// 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()
|
||||
}
|
||||
switch args[0] {
|
||||
case "init":
|
||||
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 errors.New("set 需要至少一个 key=value")
|
||||
}
|
||||
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 errors.New("get 需要字段名")
|
||||
}
|
||||
cfg, err := config.Load(paths.ConfigFile)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
value, ok := cfg.Get(args[1])
|
||||
if !ok {
|
||||
return fmt.Errorf("未知字段: %s", args[1])
|
||||
}
|
||||
fmt.Println(value)
|
||||
return nil
|
||||
case "summary":
|
||||
cfg, err := config.Load(paths.ConfigFile)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
printMap(cfg.Summary())
|
||||
return nil
|
||||
case "inspect":
|
||||
if len(args) < 2 {
|
||||
return errors.New("inspect 需要旧配置目录")
|
||||
}
|
||||
old, ok := config.InspectOld(args[1])
|
||||
if !ok {
|
||||
return errors.New("未找到可迁移的旧配置")
|
||||
}
|
||||
printOld(old)
|
||||
return nil
|
||||
case "migrate":
|
||||
if len(args) < 2 {
|
||||
return errors.New("migrate 需要旧配置目录")
|
||||
}
|
||||
target := paths.ConfigFile
|
||||
if len(args) >= 3 {
|
||||
target = args[2]
|
||||
}
|
||||
old, err := config.MigrateOld(args[1], target)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
printOld(old)
|
||||
return nil
|
||||
case "remove-old-txt":
|
||||
if len(args) < 2 {
|
||||
return errors.New("remove-old-txt 需要旧配置目录")
|
||||
}
|
||||
return config.RemoveOldTxt(args[1])
|
||||
default:
|
||||
return fmt.Errorf("未知 config 操作: %s", args[0])
|
||||
}
|
||||
}
|
||||
|
||||
// printOld 输出 key=value 行,供安装脚本读取展示。
|
||||
func printOld(old config.OldConfig) {
|
||||
fmt.Printf("format=%s\n", old.Format)
|
||||
printMap(old.Values)
|
||||
}
|
||||
|
||||
// printMap 按键排序输出 key=value 行。
|
||||
func printMap(values map[string]string) {
|
||||
keys := make([]string, 0, len(values))
|
||||
for k := range values {
|
||||
keys = append(keys, k)
|
||||
}
|
||||
sort.Strings(keys)
|
||||
for _, k := range keys {
|
||||
fmt.Printf("%s=%s\n", k, values[k])
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
module github.com/YuleBest/LuminPro/go
|
||||
|
||||
go 1.26.0
|
||||
|
||||
require golang.org/x/sys v0.48.0
|
||||
@@ -0,0 +1,2 @@
|
||||
golang.org/x/sys v0.48.0 h1:bbX/i/6MgT9BVLM9RT1thmxL04yeTAhbEz4SyadbXoo=
|
||||
golang.org/x/sys v0.48.0/go.mod h1:hNLxWAXmnKAxqDtdwIYC4bM9oQPEecfsnNMuSxOs3og=
|
||||
@@ -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
|
||||
}
|
||||
@@ -0,0 +1,68 @@
|
||||
// Package brightness 负责亮度 sysfs 节点的读写与渐变计算。
|
||||
package brightness
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
)
|
||||
|
||||
// ReadInt 读取节点当前整数值(对应 shell 的 `cat`)。
|
||||
func ReadInt(path string) (int, error) {
|
||||
data, err := os.ReadFile(path)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
text := strings.TrimSpace(string(data))
|
||||
if text == "" {
|
||||
return 0, fmt.Errorf("亮度节点内容为空: %s", path)
|
||||
}
|
||||
v, err := strconv.Atoi(text)
|
||||
if err != nil {
|
||||
return 0, fmt.Errorf("亮度节点内容不是整数 (%q): %w", text, err)
|
||||
}
|
||||
return v, nil
|
||||
}
|
||||
|
||||
// WriteInt 写入节点(对应 shell 的 `echo -n`,不追加换行)。
|
||||
func WriteInt(path string, value int) error {
|
||||
return os.WriteFile(path, []byte(strconv.Itoa(value)), 0o644)
|
||||
}
|
||||
|
||||
// Steps 计算渐变序列:不含起点,含目标值。
|
||||
//
|
||||
// 与旧 shell 版一致:step = (target-start)/steps 为整除,
|
||||
// 结果为 0 时直接返回单个目标值(差値过小)。
|
||||
func Steps(start, target, steps int) []int {
|
||||
if steps <= 0 {
|
||||
return []int{target}
|
||||
}
|
||||
stepValue := (target - start) / steps
|
||||
if stepValue == 0 {
|
||||
return []int{target}
|
||||
}
|
||||
out := make([]int, 0, steps+1)
|
||||
for i := 1; i <= steps; i++ {
|
||||
out = append(out, start+i*stepValue)
|
||||
}
|
||||
// 末值兜底为精确目标(整除余数导致的偏差)
|
||||
return append(out, target)
|
||||
}
|
||||
|
||||
// Ramp 按渐变序列写入节点,每步之间等待 delay。onStep 可为 nil。
|
||||
func Ramp(path string, start, target, steps int, delay time.Duration, onStep func(step, value int)) error {
|
||||
for i, value := range Steps(start, target, steps) {
|
||||
if err := WriteInt(path, value); err != nil {
|
||||
return err
|
||||
}
|
||||
if onStep != nil {
|
||||
onStep(i+1, value)
|
||||
}
|
||||
if i < steps && delay > 0 {
|
||||
time.Sleep(delay)
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
@@ -0,0 +1,137 @@
|
||||
package brightness
|
||||
|
||||
import (
|
||||
"os"
|
||||
"path/filepath"
|
||||
"testing"
|
||||
"time"
|
||||
)
|
||||
|
||||
func TestReadWriteInt(t *testing.T) {
|
||||
path := filepath.Join(t.TempDir(), "brightness")
|
||||
if err := os.WriteFile(path, []byte("1200\n"), 0o644); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
v, err := ReadInt(path)
|
||||
if err != nil || v != 1200 {
|
||||
t.Fatalf("ReadInt = %d, %v", v, err)
|
||||
}
|
||||
if err := WriteInt(path, 3500); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
data, _ := os.ReadFile(path)
|
||||
if string(data) != "3500" {
|
||||
t.Fatalf("写入内容应为无换行的 3500, 实际 %q", string(data))
|
||||
}
|
||||
}
|
||||
|
||||
func TestReadIntErrors(t *testing.T) {
|
||||
dir := t.TempDir()
|
||||
if _, err := ReadInt(filepath.Join(dir, "缺失")); err == nil {
|
||||
t.Fatal("缺失文件应报错")
|
||||
}
|
||||
empty := filepath.Join(dir, "empty")
|
||||
_ = os.WriteFile(empty, []byte(" \n"), 0o644)
|
||||
if _, err := ReadInt(empty); err == nil {
|
||||
t.Fatal("空内容应报错")
|
||||
}
|
||||
bad := filepath.Join(dir, "bad")
|
||||
_ = os.WriteFile(bad, []byte("abc"), 0o644)
|
||||
if _, err := ReadInt(bad); err == nil {
|
||||
t.Fatal("非整数应报错")
|
||||
}
|
||||
}
|
||||
|
||||
// 与旧 shell 版 update_all 的整除语义对齐
|
||||
func TestStepsMatchesShellSemantics(t *testing.T) {
|
||||
seq := Steps(100, 3500, 50)
|
||||
if len(seq) != 51 {
|
||||
t.Fatalf("序列长度应为 steps+1=51, 实际 %d", len(seq))
|
||||
}
|
||||
if seq[0] != 168 { // 100 + (3400/50)
|
||||
t.Fatalf("首步应为 168, 实际 %d", seq[0])
|
||||
}
|
||||
if seq[len(seq)-1] != 3500 {
|
||||
t.Fatalf("末值应为目标值 3500, 实际 %d", seq[len(seq)-1])
|
||||
}
|
||||
// 整除时末值会与兜底写入重复一次(与旧脚本一致),故用非递减断言
|
||||
for i := 1; i < len(seq); i++ {
|
||||
if seq[i] < seq[i-1] {
|
||||
t.Fatalf("序列应非递减: %v", seq)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestStepsZeroDiffWritesTargetOnce(t *testing.T) {
|
||||
if seq := Steps(2000, 2000, 50); len(seq) != 1 || seq[0] != 2000 {
|
||||
t.Fatalf("差值为 0 应直接写目标值: %v", seq)
|
||||
}
|
||||
// 差值小于步数时整除为 0
|
||||
if seq := Steps(2000, 2010, 50); len(seq) != 1 || seq[0] != 2010 {
|
||||
t.Fatalf("步长整除为 0 应直接写目标值: %v", seq)
|
||||
}
|
||||
}
|
||||
|
||||
func TestStepsNegativeDirection(t *testing.T) {
|
||||
seq := Steps(3500, 100, 50)
|
||||
if len(seq) != 51 || seq[len(seq)-1] != 100 {
|
||||
t.Fatalf("下降渐变末值应为 100: %v", seq)
|
||||
}
|
||||
for i := 1; i < len(seq); i++ {
|
||||
if seq[i] > seq[i-1] {
|
||||
t.Fatalf("下降序列应非递增: %v", seq)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestStepsRemainderEndsAtTarget(t *testing.T) {
|
||||
// 100/30 = 3 整除,最后一步只到 90,需兜底补 100
|
||||
seq := Steps(0, 100, 30)
|
||||
if seq[len(seq)-2] != 90 || seq[len(seq)-1] != 100 {
|
||||
t.Fatalf("末两步应为 90,100, 实际 %v", seq[len(seq)-2:])
|
||||
}
|
||||
}
|
||||
|
||||
func TestStepsNonPositiveStepsFallsBackToTarget(t *testing.T) {
|
||||
for _, steps := range []int{0, -5} {
|
||||
if seq := Steps(100, 500, steps); len(seq) != 1 || seq[0] != 500 {
|
||||
t.Fatalf("steps=%d 应直接写目标值: %v", steps, seq)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestRampWritesSequenceAndCallsOnStep(t *testing.T) {
|
||||
path := filepath.Join(t.TempDir(), "brightness")
|
||||
if err := os.WriteFile(path, []byte("100"), 0o644); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
var values []int
|
||||
err := Ramp(path, 100, 400, 3, time.Millisecond, func(step, value int) {
|
||||
values = append(values, value)
|
||||
})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
// stepValue = 100: 200, 300, 400,末尾再兜底写一次 400(与旧脚本一致)
|
||||
want := []int{200, 300, 400, 400}
|
||||
if len(values) != len(want) {
|
||||
t.Fatalf("回调次数应为 %d, 实际 %v", len(want), values)
|
||||
}
|
||||
for i := range want {
|
||||
if values[i] != want[i] {
|
||||
t.Fatalf("序列不匹配: 期望 %v, 实际 %v", want, values)
|
||||
}
|
||||
}
|
||||
if got, _ := ReadInt(path); got != 400 {
|
||||
t.Fatalf("末值应为 400, 实际 %d", got)
|
||||
}
|
||||
}
|
||||
|
||||
func TestRampReportsWriteError(t *testing.T) {
|
||||
// 指向不存在的目录,写入应失败
|
||||
err := Ramp(filepath.Join(t.TempDir(), "不存在", "node"), 0, 100, 5, 0, nil)
|
||||
if err == nil {
|
||||
t.Fatal("写入失败应返回错误")
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,395 @@
|
||||
// Package config 负责读写模块的 config.json。
|
||||
//
|
||||
// 字段与 WebUI、安装脚本共享,是三方之间的稳定契约:新增字段必须给默认值,
|
||||
// 缺失字段按默认值补齐(等价于旧 shell 版 get_cfg 的 fallback 行为)。
|
||||
package config
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strconv"
|
||||
"strings"
|
||||
)
|
||||
|
||||
// 默认值,与 config/config.json 模板及 customize.sh 保持一致。
|
||||
const (
|
||||
DefaultUIMaxBri = 0
|
||||
DefaultMaxBri = 0
|
||||
DefaultStepsNum = 50
|
||||
DefaultLogMaxSize = 512
|
||||
DefaultAutoBriSleep = 1
|
||||
DefaultDisplayHdrSleep = 0
|
||||
DefaultHdrEnterRatio = 1.15
|
||||
DefaultHdrExitRatio = 1.05
|
||||
DefaultCompatibilityMode = 0
|
||||
DefaultSleepTime = ""
|
||||
DefaultInotifyEvents = "c"
|
||||
DefaultNowBriFile = "/sys/class/backlight/panel0-backlight/brightness"
|
||||
DefaultMaxBriFile = "/sys/class/backlight/panel0-backlight/max_brightness"
|
||||
DefaultLogLevel = "info"
|
||||
DefaultDebugMode = 0
|
||||
)
|
||||
|
||||
// Config 是模块配置的强类型表示。
|
||||
type Config struct {
|
||||
UIMaxBri int `json:"ui_max_bri"`
|
||||
MaxBri int `json:"max_bri"`
|
||||
StepsNum int `json:"steps_num"`
|
||||
LogMaxSize int `json:"log_max_size"`
|
||||
AutoBriSleep int `json:"auto_bri_sleep"`
|
||||
DisplayHdrSleep int `json:"display_hdr_sleep"`
|
||||
HdrEnterRatio float64 `json:"hdr_enter_ratio"`
|
||||
HdrExitRatio float64 `json:"hdr_exit_ratio"`
|
||||
CompatibilityMode int `json:"compatibility_mode"`
|
||||
SleepTime string `json:"sleep_time"`
|
||||
InotifyEvents string `json:"inotify_events"`
|
||||
NowBriFile string `json:"now_bri_file"`
|
||||
MaxBriFile string `json:"max_bri_file"`
|
||||
LogLevel string `json:"log_level"`
|
||||
DebugMode int `json:"debug_mode"`
|
||||
BlacklistApps []string `json:"blacklist_apps"`
|
||||
|
||||
// extra 保存本程序不认识的键,读写时原样保留,避免与 WebUI 抢字段。
|
||||
extra map[string]json.RawMessage
|
||||
}
|
||||
|
||||
// Default 返回带完整默认值的配置。
|
||||
func Default() Config {
|
||||
return Config{
|
||||
UIMaxBri: DefaultUIMaxBri,
|
||||
MaxBri: DefaultMaxBri,
|
||||
StepsNum: DefaultStepsNum,
|
||||
LogMaxSize: DefaultLogMaxSize,
|
||||
AutoBriSleep: DefaultAutoBriSleep,
|
||||
DisplayHdrSleep: DefaultDisplayHdrSleep,
|
||||
HdrEnterRatio: DefaultHdrEnterRatio,
|
||||
HdrExitRatio: DefaultHdrExitRatio,
|
||||
CompatibilityMode: DefaultCompatibilityMode,
|
||||
SleepTime: DefaultSleepTime,
|
||||
InotifyEvents: DefaultInotifyEvents,
|
||||
NowBriFile: DefaultNowBriFile,
|
||||
MaxBriFile: DefaultMaxBriFile,
|
||||
LogLevel: DefaultLogLevel,
|
||||
DebugMode: DefaultDebugMode,
|
||||
BlacklistApps: []string{},
|
||||
}
|
||||
}
|
||||
|
||||
// Load 读取配置。文件不存在或为空时返回默认配置;
|
||||
// 单个字段损坏时保留该字段的默认值(与旧 shell 版 get_cfg 的降级一致)。
|
||||
func Load(path string) (Config, error) {
|
||||
c := Default()
|
||||
data, err := os.ReadFile(path)
|
||||
if errors.Is(err, os.ErrNotExist) {
|
||||
return c, nil
|
||||
}
|
||||
if err != nil {
|
||||
return c, err
|
||||
}
|
||||
if len(strings.TrimSpace(string(data))) == 0 {
|
||||
return c, nil
|
||||
}
|
||||
|
||||
var raw map[string]json.RawMessage
|
||||
if err := json.Unmarshal(data, &raw); err != nil {
|
||||
return c, fmt.Errorf("解析配置失败: %w", err)
|
||||
}
|
||||
c.applyRaw(raw)
|
||||
return c, nil
|
||||
}
|
||||
|
||||
// Save 原子写回配置(临时文件 + rename),保证 WebUI 读到的是完整 JSON。
|
||||
func (c Config) Save(path string) error {
|
||||
raw := c.toRawMap()
|
||||
data, err := json.Marshal(raw)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if dir := filepath.Dir(path); dir != "" {
|
||||
if err := os.MkdirAll(dir, 0o755); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
tmp := path + ".tmp"
|
||||
if err := os.WriteFile(tmp, data, 0o644); err != nil {
|
||||
return err
|
||||
}
|
||||
return os.Rename(tmp, path)
|
||||
}
|
||||
|
||||
// Ensure 补齐缺失字段并落盘。
|
||||
func Ensure(path string) error {
|
||||
c, err := Load(path)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return c.Save(path)
|
||||
}
|
||||
|
||||
// Init 在文件不存在时写入默认配置。
|
||||
func Init(path string) error {
|
||||
if _, err := os.Stat(path); err == nil {
|
||||
return Ensure(path)
|
||||
}
|
||||
return Default().Save(path)
|
||||
}
|
||||
|
||||
// Set 按 key=value 写入字段。值按字段的既有类型编码(与旧脚本里 jq 的
|
||||
// `--arg x | tonumber` / 字符串赋值保持一致),避免 "0" 这类事件字母被写成数字。
|
||||
func Set(path string, pairs []string) error {
|
||||
c, err := Load(path)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
raw := c.toRawMap()
|
||||
for _, p := range pairs {
|
||||
key, value, ok := strings.Cut(p, "=")
|
||||
if !ok || key == "" {
|
||||
return fmt.Errorf("参数格式应为 key=value: %q", p)
|
||||
}
|
||||
b, err := encodeValue(key, value)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
raw[key] = b
|
||||
}
|
||||
|
||||
updated := Default()
|
||||
updated.applyRaw(raw)
|
||||
return updated.Save(path)
|
||||
}
|
||||
|
||||
var intFields = map[string]bool{
|
||||
"ui_max_bri": true,
|
||||
"max_bri": true,
|
||||
"steps_num": true,
|
||||
"log_max_size": true,
|
||||
"auto_bri_sleep": true,
|
||||
"display_hdr_sleep": true,
|
||||
"compatibility_mode": true,
|
||||
"debug_mode": true,
|
||||
}
|
||||
|
||||
var floatFields = map[string]bool{
|
||||
"hdr_enter_ratio": true,
|
||||
"hdr_exit_ratio": true,
|
||||
}
|
||||
|
||||
var stringFields = map[string]bool{
|
||||
"sleep_time": true,
|
||||
"inotify_events": true,
|
||||
"now_bri_file": true,
|
||||
"max_bri_file": true,
|
||||
"log_level": true,
|
||||
}
|
||||
|
||||
// encodeValue 按已知字段类型把字符串编码为 JSON 值;未知字段按 JSON 字面量解析。
|
||||
func encodeValue(key, value string) (json.RawMessage, error) {
|
||||
switch {
|
||||
case intFields[key]:
|
||||
n, err := strconv.Atoi(strings.TrimSpace(value))
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("%s 需要整数: %q", key, value)
|
||||
}
|
||||
return json.Marshal(n)
|
||||
case floatFields[key]:
|
||||
f, err := strconv.ParseFloat(strings.TrimSpace(value), 64)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("%s 需要数值: %q", key, value)
|
||||
}
|
||||
return json.Marshal(f)
|
||||
case stringFields[key]:
|
||||
return json.Marshal(value)
|
||||
case key == "blacklist_apps":
|
||||
var arr []string
|
||||
if err := json.Unmarshal([]byte(value), &arr); err != nil {
|
||||
return nil, fmt.Errorf("blacklist_apps 需要 JSON 数组: %q", value)
|
||||
}
|
||||
if arr == nil {
|
||||
arr = []string{}
|
||||
}
|
||||
return json.Marshal(arr)
|
||||
default:
|
||||
return json.Marshal(parseValue(value))
|
||||
}
|
||||
}
|
||||
|
||||
// parseValue 把字符串解析为 JSON 值;不是合法 JSON 字面量时按字符串处理。
|
||||
func parseValue(s string) any {
|
||||
var v any
|
||||
if err := json.Unmarshal([]byte(s), &v); err == nil {
|
||||
return v
|
||||
}
|
||||
return s
|
||||
}
|
||||
|
||||
// applyRaw 用原始键值填充强类型字段,未识别的键留在 extra。
|
||||
// 单个字段损坏时保留默认值,不阻断整体加载(与旧 get_cfg 的降级一致)。
|
||||
func (c *Config) applyRaw(raw map[string]json.RawMessage) {
|
||||
_ = 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,
|
||||
"log_max_size": &c.LogMaxSize,
|
||||
"auto_bri_sleep": &c.AutoBriSleep,
|
||||
"display_hdr_sleep": &c.DisplayHdrSleep,
|
||||
"hdr_enter_ratio": &c.HdrEnterRatio,
|
||||
"hdr_exit_ratio": &c.HdrExitRatio,
|
||||
"compatibility_mode": &c.CompatibilityMode,
|
||||
"sleep_time": &c.SleepTime,
|
||||
"inotify_events": &c.InotifyEvents,
|
||||
"now_bri_file": &c.NowBriFile,
|
||||
"max_bri_file": &c.MaxBriFile,
|
||||
"log_level": &c.LogLevel,
|
||||
"debug_mode": &c.DebugMode,
|
||||
"blacklist_apps": &c.BlacklistApps,
|
||||
}
|
||||
}
|
||||
|
||||
// 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
|
||||
}
|
||||
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 导出为原始键值表(含未知键)。
|
||||
func (c Config) toRawMap() map[string]json.RawMessage {
|
||||
out := map[string]json.RawMessage{}
|
||||
for key, value := range map[string]any{
|
||||
"ui_max_bri": c.UIMaxBri,
|
||||
"max_bri": c.MaxBri,
|
||||
"steps_num": c.StepsNum,
|
||||
"log_max_size": c.LogMaxSize,
|
||||
"auto_bri_sleep": c.AutoBriSleep,
|
||||
"display_hdr_sleep": c.DisplayHdrSleep,
|
||||
"hdr_enter_ratio": c.HdrEnterRatio,
|
||||
"hdr_exit_ratio": c.HdrExitRatio,
|
||||
"compatibility_mode": c.CompatibilityMode,
|
||||
"sleep_time": c.SleepTime,
|
||||
"inotify_events": c.InotifyEvents,
|
||||
"now_bri_file": c.NowBriFile,
|
||||
"max_bri_file": c.MaxBriFile,
|
||||
"log_level": c.LogLevel,
|
||||
"debug_mode": c.DebugMode,
|
||||
"blacklist_apps": c.BlacklistApps,
|
||||
} {
|
||||
b, err := json.Marshal(value)
|
||||
if err != nil {
|
||||
continue
|
||||
}
|
||||
out[key] = b
|
||||
}
|
||||
for key, value := range c.extra {
|
||||
if _, ok := out[key]; !ok {
|
||||
out[key] = value
|
||||
}
|
||||
}
|
||||
return out
|
||||
}
|
||||
|
||||
// Blacklist 返回黑名单副本,避免调用方误改内部切片。
|
||||
func (c Config) Blacklist() []string {
|
||||
return append([]string(nil), c.BlacklistApps...)
|
||||
}
|
||||
|
||||
// Get 返回字段的纯文本表示(供 shell 使用):字符串原样,数字/布尔去引号,
|
||||
// 数组与对象返回 JSON。第二个返回值表示字段是否存在。
|
||||
func (c Config) Get(key string) (string, bool) {
|
||||
raw, ok := c.toRawMap()[key]
|
||||
if !ok {
|
||||
return "", false
|
||||
}
|
||||
var v any
|
||||
if err := json.Unmarshal(raw, &v); err != nil {
|
||||
return "", false
|
||||
}
|
||||
switch value := v.(type) {
|
||||
case string:
|
||||
return value, true
|
||||
case float64:
|
||||
return strconv.FormatFloat(value, 'f', -1, 64), true
|
||||
case bool:
|
||||
return strconv.FormatBool(value), true
|
||||
case nil:
|
||||
return "", true
|
||||
default:
|
||||
b, err := json.Marshal(v)
|
||||
if err != nil {
|
||||
return "", false
|
||||
}
|
||||
return string(b), true
|
||||
}
|
||||
}
|
||||
|
||||
// Summary 返回安装界面需要展示的字段(key=value 形式),供 shell 读取。
|
||||
func (c Config) Summary() map[string]string {
|
||||
out := map[string]string{
|
||||
"ui_max_bri": strconv.Itoa(c.UIMaxBri),
|
||||
"max_bri": strconv.Itoa(c.MaxBri),
|
||||
"steps_num": strconv.Itoa(c.StepsNum),
|
||||
"log_max_size": strconv.Itoa(c.LogMaxSize),
|
||||
"auto_bri_sleep": strconv.Itoa(c.AutoBriSleep),
|
||||
"display_hdr_sleep": strconv.Itoa(c.DisplayHdrSleep),
|
||||
"hdr_enter_ratio": strconv.FormatFloat(c.HdrEnterRatio, 'f', -1, 64),
|
||||
"hdr_exit_ratio": strconv.FormatFloat(c.HdrExitRatio, 'f', -1, 64),
|
||||
"compatibility_mode": strconv.Itoa(c.CompatibilityMode),
|
||||
"sleep_time": c.SleepTime,
|
||||
"inotify_events": c.InotifyEvents,
|
||||
"now_bri_file": c.NowBriFile,
|
||||
"max_bri_file": c.MaxBriFile,
|
||||
"log_level": c.LogLevel,
|
||||
"debug_mode": strconv.Itoa(c.DebugMode),
|
||||
"blacklist_count": strconv.Itoa(len(c.BlacklistApps)),
|
||||
}
|
||||
return out
|
||||
}
|
||||
@@ -0,0 +1,371 @@
|
||||
package config
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestLoadMissingFileReturnsDefaults(t *testing.T) {
|
||||
path := filepath.Join(t.TempDir(), "config.json")
|
||||
c, err := Load(path)
|
||||
if err != nil {
|
||||
t.Fatalf("Load 出错: %v", err)
|
||||
}
|
||||
if c.StepsNum != DefaultStepsNum || c.HdrEnterRatio != DefaultHdrEnterRatio || c.LogLevel != DefaultLogLevel {
|
||||
t.Fatalf("默认值不正确: %+v", c)
|
||||
}
|
||||
if c.BlacklistApps == nil {
|
||||
t.Fatal("BlacklistApps 不应为 nil")
|
||||
}
|
||||
}
|
||||
|
||||
func TestLoadPartialFileFillsDefaults(t *testing.T) {
|
||||
path := filepath.Join(t.TempDir(), "config.json")
|
||||
if err := os.WriteFile(path, []byte(`{"ui_max_bri":123,"max_bri":4095}`), 0o644); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
c, err := Load(path)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if c.UIMaxBri != 123 || c.MaxBri != 4095 {
|
||||
t.Fatalf("已存在的字段未生效: %+v", c)
|
||||
}
|
||||
if c.StepsNum != DefaultStepsNum {
|
||||
t.Fatalf("缺失字段未补默认值: steps_num=%d", c.StepsNum)
|
||||
}
|
||||
if c.NowBriFile != DefaultNowBriFile {
|
||||
t.Fatalf("缺失字段未补默认值: now_bri_file=%q", c.NowBriFile)
|
||||
}
|
||||
}
|
||||
|
||||
func TestLoadMalformedFieldKeepsDefault(t *testing.T) {
|
||||
path := filepath.Join(t.TempDir(), "config.json")
|
||||
// steps_num 类型错误,ui_max_bri 正常
|
||||
if err := os.WriteFile(path, []byte(`{"ui_max_bri":200,"steps_num":"abc"}`), 0o644); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
c, err := Load(path)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if c.UIMaxBri != 200 {
|
||||
t.Fatalf("正常字段应生效: %d", c.UIMaxBri)
|
||||
}
|
||||
if c.StepsNum != DefaultStepsNum {
|
||||
t.Fatalf("损坏字段应回退默认值: %d", c.StepsNum)
|
||||
}
|
||||
}
|
||||
|
||||
func TestUnknownKeysPreservedOnSave(t *testing.T) {
|
||||
path := filepath.Join(t.TempDir(), "config.json")
|
||||
if err := os.WriteFile(path, []byte(`{"ui_max_bri":100,"future_field":"keep-me"}`), 0o644); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
c, err := Load(path)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
c.MaxBri = 999
|
||||
if err := c.Save(path); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
var raw map[string]json.RawMessage
|
||||
data, _ := os.ReadFile(path)
|
||||
if err := json.Unmarshal(data, &raw); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
var kept string
|
||||
if err := json.Unmarshal(raw["future_field"], &kept); err != nil || kept != "keep-me" {
|
||||
t.Fatalf("未知字段未保留: %v %q", err, kept)
|
||||
}
|
||||
if _, ok := raw["steps_num"]; !ok {
|
||||
t.Fatal("保存后应包含全部已知字段")
|
||||
}
|
||||
}
|
||||
|
||||
func TestSetParsesTypes(t *testing.T) {
|
||||
path := filepath.Join(t.TempDir(), "config.json")
|
||||
err := Set(path, []string{
|
||||
"ui_max_bri=1500",
|
||||
"hdr_enter_ratio=1.25",
|
||||
"inotify_events=0",
|
||||
"blacklist_apps=[\"com.a\",\"com.b\"]",
|
||||
"sleep_time=2200-0700",
|
||||
})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
c, err := Load(path)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if c.UIMaxBri != 1500 {
|
||||
t.Fatalf("int 未写入: %d", c.UIMaxBri)
|
||||
}
|
||||
if c.HdrEnterRatio != 1.25 {
|
||||
t.Fatalf("float 未写入: %v", c.HdrEnterRatio)
|
||||
}
|
||||
if c.InotifyEvents != "0" {
|
||||
t.Fatalf("字符串未写入: %q", c.InotifyEvents)
|
||||
}
|
||||
if len(c.BlacklistApps) != 2 || c.BlacklistApps[0] != "com.a" {
|
||||
t.Fatalf("数组未写入: %v", c.BlacklistApps)
|
||||
}
|
||||
if c.SleepTime != "2200-0700" {
|
||||
t.Fatalf("时间串未写入: %q", c.SleepTime)
|
||||
}
|
||||
}
|
||||
|
||||
func TestSetRejectsBadPair(t *testing.T) {
|
||||
path := filepath.Join(t.TempDir(), "config.json")
|
||||
if err := Set(path, []string{"novalue"}); err == nil {
|
||||
t.Fatal("缺少 = 应报错")
|
||||
}
|
||||
}
|
||||
|
||||
func TestSetRejectsBadType(t *testing.T) {
|
||||
path := filepath.Join(t.TempDir(), "config.json")
|
||||
if err := Set(path, []string{"ui_max_bri=1500"}); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if err := Set(path, []string{"ui_max_bri=abc"}); err == nil {
|
||||
t.Fatal("整数字段给非数字应报错")
|
||||
}
|
||||
// 失败时不应破坏已有配置
|
||||
c, err := Load(path)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if c.UIMaxBri != 1500 {
|
||||
t.Fatalf("写入失败不应改动原值: %d", c.UIMaxBri)
|
||||
}
|
||||
}
|
||||
|
||||
func TestInitCreatesAndEnsureFills(t *testing.T) {
|
||||
path := filepath.Join(t.TempDir(), "config.json")
|
||||
if err := Init(path); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if _, err := os.Stat(path); err != nil {
|
||||
t.Fatalf("Init 未创建文件: %v", err)
|
||||
}
|
||||
// 删掉一个字段后 Ensure 应补回
|
||||
if err := os.WriteFile(path, []byte(`{"ui_max_bri":50}`), 0o644); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if err := Ensure(path); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
c, _ := Load(path)
|
||||
if c.UIMaxBri != 50 || c.LogMaxSize != DefaultLogMaxSize {
|
||||
t.Fatalf("Ensure 结果不正确: %+v", c)
|
||||
}
|
||||
}
|
||||
|
||||
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) {
|
||||
p := filepath.Join(oldDir, name)
|
||||
if err := os.MkdirAll(filepath.Dir(p), 0o755); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if err := os.WriteFile(p, []byte(content), 0o644); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
}
|
||||
write("ui_max_bri.txt", "1200\n")
|
||||
write("max_bri.txt", "4095\n")
|
||||
write("sleep_time.txt", "2200-0700\n")
|
||||
write("steps_num.txt", "80\n")
|
||||
write("path/now_bri_file.txt", "/sys/custom/brightness\n")
|
||||
write("blacklist_apps.txt", "com.a\ncom.b\n\n")
|
||||
|
||||
old, ok := InspectOld(oldDir)
|
||||
if !ok || old.Format != "txt" {
|
||||
t.Fatalf("未识别旧 txt 配置: %+v ok=%v", old, ok)
|
||||
}
|
||||
if old.Values["ui_max_bri"] != "1200" || old.Values["blacklist_count"] != "2" {
|
||||
t.Fatalf("inspect 值不正确: %+v", old.Values)
|
||||
}
|
||||
|
||||
target := filepath.Join(t.TempDir(), "config.json")
|
||||
if _, err := MigrateOld(oldDir, target); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
c, err := Load(target)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if c.UIMaxBri != 1200 || c.MaxBri != 4095 || c.StepsNum != 80 {
|
||||
t.Fatalf("迁移数值不正确: %+v", c)
|
||||
}
|
||||
if c.SleepTime != "2200-0700" || c.NowBriFile != "/sys/custom/brightness" {
|
||||
t.Fatalf("迁移字符串不正确: %+v", c)
|
||||
}
|
||||
if len(c.BlacklistApps) != 2 {
|
||||
t.Fatalf("迁移黑名单不正确: %v", c.BlacklistApps)
|
||||
}
|
||||
if c.LogLevel != DefaultLogLevel {
|
||||
t.Fatalf("未迁移字段应取默认值: %q", c.LogLevel)
|
||||
}
|
||||
|
||||
if err := RemoveOldTxt(oldDir); err != nil {
|
||||
t.Fatalf("删除旧 txt 失败: %v", err)
|
||||
}
|
||||
if fileExists(filepath.Join(oldDir, "ui_max_bri.txt")) {
|
||||
t.Fatal("旧 txt 未删除")
|
||||
}
|
||||
}
|
||||
|
||||
func TestMigrateOldJSON(t *testing.T) {
|
||||
oldDir := t.TempDir()
|
||||
oldJSON := `{"ui_max_bri":900,"max_bri":3000,"sleep_time":"0100-0600","blacklist_apps":["com.x"]}`
|
||||
if err := os.WriteFile(filepath.Join(oldDir, "config.json"), []byte(oldJSON), 0o644); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
old, ok := InspectOld(oldDir)
|
||||
if !ok || old.Format != "json" {
|
||||
t.Fatalf("未识别旧 JSON 配置: %+v ok=%v", old, ok)
|
||||
}
|
||||
|
||||
target := filepath.Join(t.TempDir(), "config.json")
|
||||
if _, err := MigrateOld(oldDir, target); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
c, err := Load(target)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if c.UIMaxBri != 900 || c.MaxBri != 3000 || c.SleepTime != "0100-0600" {
|
||||
t.Fatalf("JSON 迁移值不正确: %+v", c)
|
||||
}
|
||||
if len(c.BlacklistApps) != 1 || c.BlacklistApps[0] != "com.x" {
|
||||
t.Fatalf("黑名单未保留: %v", c.BlacklistApps)
|
||||
}
|
||||
if c.HdrEnterRatio != DefaultHdrEnterRatio {
|
||||
t.Fatalf("新字段未补默认值: %v", c.HdrEnterRatio)
|
||||
}
|
||||
}
|
||||
|
||||
func TestInspectOldRejectsEmptyConfig(t *testing.T) {
|
||||
oldDir := t.TempDir()
|
||||
if err := os.WriteFile(filepath.Join(oldDir, "config.json"), []byte(`{"ui_max_bri":0}`), 0o644); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if _, ok := InspectOld(oldDir); ok {
|
||||
t.Fatal("ui_max_bri 为 0 的旧配置不应被视为可用")
|
||||
}
|
||||
if _, ok := InspectOld(t.TempDir()); ok {
|
||||
t.Fatal("空目录不应被视为可用旧配置")
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,185 @@
|
||||
package config
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strconv"
|
||||
"strings"
|
||||
)
|
||||
|
||||
// OldConfig 描述一份可迁移的旧配置。
|
||||
type OldConfig struct {
|
||||
Format string // "json" 或 "txt"
|
||||
Values map[string]string
|
||||
Blacklist []string
|
||||
}
|
||||
|
||||
// 旧版 txt 配置的字段文件名(相对旧配置目录)。
|
||||
var oldTxtFields = map[string]string{
|
||||
"ui_max_bri": "ui_max_bri.txt",
|
||||
"max_bri": "max_bri.txt",
|
||||
"steps_num": "steps_num.txt",
|
||||
"log_max_size": "log_max_size.txt",
|
||||
"auto_bri_sleep": "auto_bri_sleep.txt",
|
||||
"display_hdr_sleep": "display_hdr_sleep.txt",
|
||||
"compatibility_mode": "compatibility_mode.txt",
|
||||
"sleep_time": "sleep_time.txt",
|
||||
"inotify_events": "inotify_events.txt",
|
||||
}
|
||||
|
||||
// InspectOld 检查旧配置目录,返回可展示的字段值。ok 为 false 表示没有可用旧配置。
|
||||
func InspectOld(dir string) (OldConfig, bool) {
|
||||
values := map[string]string{}
|
||||
|
||||
// 1. 已有 JSON 配置(要求 ui_max_bri > 0 才算有效,与旧脚本判断一致)
|
||||
if jsonPath := filepath.Join(dir, "config.json"); fileExists(jsonPath) {
|
||||
var raw map[string]json.RawMessage
|
||||
if data, err := os.ReadFile(jsonPath); err == nil && json.Unmarshal(data, &raw) == nil {
|
||||
var ui int
|
||||
_ = json.Unmarshal(raw["ui_max_bri"], &ui)
|
||||
if ui > 0 {
|
||||
values["ui_max_bri"] = strconv.Itoa(ui)
|
||||
var maxBri int
|
||||
_ = json.Unmarshal(raw["max_bri"], &maxBri)
|
||||
values["max_bri"] = strconv.Itoa(maxBri)
|
||||
var sleepTime string
|
||||
_ = json.Unmarshal(raw["sleep_time"], &sleepTime)
|
||||
values["sleep_time"] = sleepTime
|
||||
return OldConfig{Format: "json", Values: values}, true
|
||||
}
|
||||
}
|
||||
return OldConfig{}, false
|
||||
}
|
||||
|
||||
// 2. 旧 txt 配置(ui_max_bri / max_bri 都非空才算有效)
|
||||
uiTxt := filepath.Join(dir, oldTxtFields["ui_max_bri"])
|
||||
maxTxt := filepath.Join(dir, oldTxtFields["max_bri"])
|
||||
if !fileExists(uiTxt) || !fileExists(maxTxt) || readTrim(uiTxt) == "" || readTrim(maxTxt) == "" {
|
||||
return OldConfig{}, false
|
||||
}
|
||||
|
||||
for key, name := range oldTxtFields {
|
||||
values[key] = readTrim(filepath.Join(dir, name))
|
||||
}
|
||||
values["now_bri_file"] = readTrim(filepath.Join(dir, "path", "now_bri_file.txt"))
|
||||
values["max_bri_file"] = readTrim(filepath.Join(dir, "path", "max_bri_file.txt"))
|
||||
|
||||
bl := readBlacklistTxt(dir)
|
||||
values["blacklist_count"] = strconv.Itoa(len(bl))
|
||||
|
||||
return OldConfig{Format: "txt", Values: values, Blacklist: bl}, true
|
||||
}
|
||||
|
||||
// MigrateOld 把旧配置迁移到 target,返回迁移内容用于安装界面展示。
|
||||
func MigrateOld(dir, target string) (OldConfig, error) {
|
||||
old, ok := InspectOld(dir)
|
||||
if !ok {
|
||||
return old, errors.New("未找到可迁移的旧配置")
|
||||
}
|
||||
|
||||
if old.Format == "json" {
|
||||
data, err := os.ReadFile(filepath.Join(dir, "config.json"))
|
||||
if err != nil {
|
||||
return old, err
|
||||
}
|
||||
if err := os.MkdirAll(filepath.Dir(target), 0o755); err != nil {
|
||||
return old, err
|
||||
}
|
||||
if err := os.WriteFile(target, data, 0o644); err != nil {
|
||||
return old, err
|
||||
}
|
||||
// 补齐新版本新增字段
|
||||
c, err := Load(target)
|
||||
if err != nil {
|
||||
return old, err
|
||||
}
|
||||
// 旧 JSON 缺少 blacklist_apps 时,从 blacklist_apps.txt 补入
|
||||
var raw map[string]json.RawMessage
|
||||
if rawData, err := os.ReadFile(target); err == nil && json.Unmarshal(rawData, &raw) == nil {
|
||||
if _, has := raw["blacklist_apps"]; !has {
|
||||
bl := readBlacklistTxt(dir)
|
||||
c.BlacklistApps = bl
|
||||
}
|
||||
}
|
||||
if err := c.Save(target); err != nil {
|
||||
return old, err
|
||||
}
|
||||
return old, nil
|
||||
}
|
||||
|
||||
// txt -> JSON
|
||||
c := Default()
|
||||
setInt := func(key string, dst *int) {
|
||||
if v := old.Values[key]; v != "" {
|
||||
if n, err := strconv.Atoi(v); err == nil {
|
||||
*dst = n
|
||||
}
|
||||
}
|
||||
}
|
||||
setInt("ui_max_bri", &c.UIMaxBri)
|
||||
setInt("max_bri", &c.MaxBri)
|
||||
setInt("steps_num", &c.StepsNum)
|
||||
setInt("log_max_size", &c.LogMaxSize)
|
||||
setInt("auto_bri_sleep", &c.AutoBriSleep)
|
||||
setInt("display_hdr_sleep", &c.DisplayHdrSleep)
|
||||
setInt("compatibility_mode", &c.CompatibilityMode)
|
||||
if v := old.Values["sleep_time"]; v != "" {
|
||||
c.SleepTime = v
|
||||
}
|
||||
if v := old.Values["inotify_events"]; v != "" {
|
||||
c.InotifyEvents = v
|
||||
}
|
||||
if v := old.Values["now_bri_file"]; v != "" {
|
||||
c.NowBriFile = v
|
||||
}
|
||||
if v := old.Values["max_bri_file"]; v != "" {
|
||||
c.MaxBriFile = v
|
||||
}
|
||||
c.BlacklistApps = old.Blacklist
|
||||
|
||||
if err := c.Save(target); err != nil {
|
||||
return old, err
|
||||
}
|
||||
return old, nil
|
||||
}
|
||||
|
||||
// RemoveOldTxt 删除旧 txt 配置(迁移成功后由安装脚本调用)。
|
||||
func RemoveOldTxt(dir string) error {
|
||||
for _, name := range oldTxtFields {
|
||||
_ = os.Remove(filepath.Join(dir, name))
|
||||
}
|
||||
if err := os.RemoveAll(filepath.Join(dir, "path")); err != nil {
|
||||
return err
|
||||
}
|
||||
return os.Remove(filepath.Join(dir, "blacklist_apps.txt"))
|
||||
}
|
||||
|
||||
func fileExists(path string) bool {
|
||||
info, err := os.Stat(path)
|
||||
return err == nil && !info.IsDir()
|
||||
}
|
||||
|
||||
func readTrim(path string) string {
|
||||
data, err := os.ReadFile(path)
|
||||
if err != nil {
|
||||
return ""
|
||||
}
|
||||
return strings.TrimSpace(string(data))
|
||||
}
|
||||
|
||||
// readBlacklistTxt 读取旧版黑名单文本(每行一条,忽略空行)。
|
||||
func readBlacklistTxt(dir string) []string {
|
||||
data, err := os.ReadFile(filepath.Join(dir, "blacklist_apps.txt"))
|
||||
if err != nil {
|
||||
return []string{}
|
||||
}
|
||||
out := []string{}
|
||||
for _, line := range strings.Split(string(data), "\n") {
|
||||
if line = strings.TrimSpace(line); line != "" {
|
||||
out = append(out, line)
|
||||
}
|
||||
}
|
||||
return out
|
||||
}
|
||||
@@ -0,0 +1,540 @@
|
||||
// Package daemon 实现常驻守护进程,以及 boost / restart 一次性操作。
|
||||
//
|
||||
// 它取代旧的 service.sh + daemon.sh + up.sh + lumipro 四层结构:
|
||||
// 单进程内完成监听、判定、渐变写入与状态文件维护。
|
||||
package daemon
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"os/signal"
|
||||
"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"
|
||||
"github.com/YuleBest/LuminPro/go/internal/logging"
|
||||
"github.com/YuleBest/LuminPro/go/internal/policy"
|
||||
"github.com/YuleBest/LuminPro/go/internal/system"
|
||||
)
|
||||
|
||||
// Paths 是模块内的文件布局(与 WebUI 的契约,不可随意改名)。
|
||||
type Paths = api.Paths
|
||||
|
||||
// DefaultPaths 按模块目录推导全部路径。
|
||||
func DefaultPaths(moduleDir string) Paths { return api.DefaultPaths(moduleDir) }
|
||||
|
||||
// Deps 是守护进程的外部依赖,测试时可注入假实现。
|
||||
type Deps struct {
|
||||
AutoBrightness system.AutoBrightness
|
||||
Focus system.Focus
|
||||
HDR system.HdrRatio
|
||||
Log *logging.Logger
|
||||
Now func() time.Time
|
||||
|
||||
StepDelay time.Duration // 渐变每步间隔,默认 20ms
|
||||
Debounce time.Duration // 事件防抖窗口,默认 300ms
|
||||
CompatInterval time.Duration // 兼容模式轮询间隔,默认 2s
|
||||
NodeRetry time.Duration // 节点缺失重试间隔,默认 10s
|
||||
SettleDelay time.Duration // 等待亮度值落定的间隔,默认 300ms
|
||||
}
|
||||
|
||||
func (d *Deps) withDefaults() {
|
||||
if d.Now == nil {
|
||||
d.Now = time.Now
|
||||
}
|
||||
if d.StepDelay <= 0 {
|
||||
d.StepDelay = 20 * time.Millisecond
|
||||
}
|
||||
if d.Debounce <= 0 {
|
||||
d.Debounce = 300 * time.Millisecond
|
||||
}
|
||||
if d.CompatInterval <= 0 {
|
||||
d.CompatInterval = 2 * time.Second
|
||||
}
|
||||
if d.NodeRetry <= 0 {
|
||||
d.NodeRetry = 10 * time.Second
|
||||
}
|
||||
if d.SettleDelay <= 0 {
|
||||
d.SettleDelay = 300 * time.Millisecond
|
||||
}
|
||||
}
|
||||
|
||||
// Daemon 是守护进程。
|
||||
type Daemon struct {
|
||||
paths Paths
|
||||
deps Deps
|
||||
|
||||
mu sync.RWMutex
|
||||
cfg config.Config
|
||||
hdr policy.HdrState
|
||||
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,
|
||||
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
|
||||
}
|
||||
|
||||
type exitReason int
|
||||
|
||||
const (
|
||||
reasonReload exitReason = iota
|
||||
reasonExit
|
||||
reasonError
|
||||
)
|
||||
|
||||
// Run 启动主循环,直到收到退出信号。
|
||||
func (d *Daemon) Run() error {
|
||||
if err := os.MkdirAll(d.paths.PIDDir, 0o755); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := d.writePID(); err != nil {
|
||||
return err
|
||||
}
|
||||
defer d.cleanup()
|
||||
|
||||
d.log().Info("守护进程已启动")
|
||||
d.flushState()
|
||||
|
||||
sigCh := make(chan os.Signal, 4)
|
||||
signal.Notify(sigCh, syscall.SIGHUP, syscall.SIGTERM, syscall.SIGINT)
|
||||
defer signal.Stop(sigCh)
|
||||
|
||||
cfgCh := make(chan struct{}, 1)
|
||||
stopCfgPoll := d.pollConfig(cfgCh)
|
||||
defer stopCfgPoll()
|
||||
|
||||
for {
|
||||
node := d.currentConfig().NowBriFile
|
||||
if _, err := os.Stat(node); err != nil {
|
||||
d.logNodeMissing(node)
|
||||
select {
|
||||
case <-time.After(d.deps.NodeRetry):
|
||||
d.reloadConfig()
|
||||
continue
|
||||
case sig := <-sigCh:
|
||||
if d.handleSignal(sig) {
|
||||
return nil
|
||||
}
|
||||
d.reloadConfig()
|
||||
continue
|
||||
case <-cfgCh:
|
||||
d.reloadConfig()
|
||||
continue
|
||||
}
|
||||
}
|
||||
if d.nodeMissingLogged {
|
||||
d.log().Info("亮度节点已就绪: " + node)
|
||||
d.nodeMissingLogged = false
|
||||
}
|
||||
|
||||
reason := d.serve(sigCh, cfgCh)
|
||||
switch reason {
|
||||
case reasonExit:
|
||||
return nil
|
||||
case reasonError:
|
||||
select {
|
||||
case <-time.After(time.Second):
|
||||
case sig := <-sigCh:
|
||||
if d.handleSignal(sig) {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
}
|
||||
d.reloadConfig()
|
||||
// 重写 PID 文件,作为「监听已重建」的就绪标记(restart 子命令据此等待)
|
||||
if err := d.writePID(); err != nil {
|
||||
d.log().Warn("重写 PID 文件失败: " + err.Error())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// serve 运行监听循环,直到配置变更/信号/监听失效。
|
||||
func (d *Daemon) serve(sigCh chan os.Signal, cfgCh chan struct{}) exitReason {
|
||||
stop := make(chan struct{})
|
||||
defer close(stop)
|
||||
|
||||
// 事件模式下,节点被删除或监听失效时通过该通道请求重建
|
||||
rebuild := make(chan struct{}, 1)
|
||||
cfg := d.currentConfig()
|
||||
|
||||
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())
|
||||
return reasonError
|
||||
}
|
||||
defer w.Close()
|
||||
|
||||
if err := w.Add(cfg.NowBriFile, cfg.InotifyEvents); err != nil {
|
||||
d.log().Error("监听亮度节点失败: " + err.Error())
|
||||
return reasonError
|
||||
}
|
||||
d.log().Info(fmt.Sprintf("正在监听: %s, 事件: %s", cfg.NowBriFile, cfg.InotifyEvents))
|
||||
|
||||
runStop := make(chan struct{})
|
||||
go func() {
|
||||
_ = w.NewRunner(d.deps.Debounce, d.debugf).Run(func(ev inotify.Event) {
|
||||
// 节点被删除 (D) / 监听失效 (x) / 被移动 (M):交给外层循环重建
|
||||
if strings.ContainsAny(ev.Letters, "xDM") {
|
||||
select {
|
||||
case rebuild <- struct{}{}:
|
||||
default:
|
||||
}
|
||||
return
|
||||
}
|
||||
d.recordEvent(ev.Letters)
|
||||
d.evaluate()
|
||||
}, runStop)
|
||||
}()
|
||||
defer func() {
|
||||
close(runStop)
|
||||
w.Stop()
|
||||
}()
|
||||
}
|
||||
|
||||
for {
|
||||
select {
|
||||
case sig := <-sigCh:
|
||||
if d.handleSignal(sig) {
|
||||
return reasonExit
|
||||
}
|
||||
d.log().Info("收到重载信号,重建监听")
|
||||
return reasonReload
|
||||
case <-cfgCh:
|
||||
d.log().Info("检测到配置变更,重新加载")
|
||||
return reasonReload
|
||||
case <-rebuild:
|
||||
d.log().Warn("亮度节点监听失效,重建监听")
|
||||
return reasonReload
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// compatLoop 兼容模式:定期轮询执行判定。
|
||||
func (d *Daemon) compatLoop(stop <-chan struct{}) {
|
||||
ticker := time.NewTicker(d.deps.CompatInterval)
|
||||
defer ticker.Stop()
|
||||
for {
|
||||
select {
|
||||
case <-stop:
|
||||
d.log().Info("轮询模式已退出")
|
||||
return
|
||||
case <-ticker.C:
|
||||
d.evaluate()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// evaluate 执行一次完整判定;满足条件时执行亮度提升。
|
||||
func (d *Daemon) evaluate() {
|
||||
defer d.flushState()
|
||||
|
||||
// 服务暂停 / 守护进程挂起:静默跳过(与旧脚本一致)
|
||||
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 !api.FileExists(cfg.NowBriFile) {
|
||||
return // 节点缺失由外层循环负责记录与重试,这里静默
|
||||
}
|
||||
|
||||
if policy.InSleepWindow(cfg.SleepTime, d.deps.Now()) {
|
||||
d.log().Info(fmt.Sprintf("处于休眠时段 (%s),跳过提升", cfg.SleepTime))
|
||||
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()
|
||||
if policy.BlacklistMatch(cfg.BlacklistApps, focus) {
|
||||
d.log().Info(fmt.Sprintf("当前前台 (%s) 在黑名单中,跳过提升", focus))
|
||||
return
|
||||
}
|
||||
}
|
||||
if cfg.DisplayHdrSleep == 1 && !d.evaluateHdr(cfg) {
|
||||
return
|
||||
}
|
||||
|
||||
d.boost(cfg)
|
||||
}
|
||||
|
||||
// evaluateHdr 推进 HDR 迟滞状态机,返回是否可以继续提升。
|
||||
func (d *Daemon) evaluateHdr(cfg config.Config) bool {
|
||||
ratio, ok := d.deps.HDR.Ratio()
|
||||
if !ok && d.haveRatioCache {
|
||||
ratio, ok = d.ratioCache, true
|
||||
d.log().Info(fmt.Sprintf("HDR 比率读取为空,使用缓存值: %.2f", ratio))
|
||||
}
|
||||
if ok {
|
||||
d.ratioCache, d.haveRatioCache = ratio, true
|
||||
d.setStateRatio(ratio)
|
||||
}
|
||||
|
||||
decision := d.hdr.Evaluate(ratio, ok, cfg.HdrEnterRatio, cfg.HdrExitRatio)
|
||||
switch {
|
||||
case decision.Entered:
|
||||
d.log().Info(fmt.Sprintf("检测到 HDR 内容 (比率: %.2f ≥ 进入阈值 %.2f),进入休眠", ratio, cfg.HdrEnterRatio))
|
||||
case decision.Exited:
|
||||
d.log().Info(fmt.Sprintf("HDR 休眠解除 (比率: %.2f ≤ 退出阈值 %.2f)", ratio, cfg.HdrExitRatio))
|
||||
case decision.Skip:
|
||||
d.log().Info("HDR 休眠中,跳过提升")
|
||||
}
|
||||
d.setStateHdrSleep(d.hdr.InSleep())
|
||||
return !decision.Skip
|
||||
}
|
||||
|
||||
// boost 读取当前亮度并在满足阈值时执行渐变。
|
||||
//
|
||||
// 与旧 CHECK_BRI 一致:最多 10 次、间隔 0.3s 等待亮度值落定;
|
||||
// 额外优化为「读数稳定且不满足条件时提前退出」,避免无谓占用事件循环。
|
||||
func (d *Daemon) boost(cfg config.Config) {
|
||||
prev := -1
|
||||
for i := 0; i < 10; i++ {
|
||||
now, err := brightness.ReadInt(cfg.NowBriFile)
|
||||
if err != nil {
|
||||
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 {
|
||||
d.log().Error("亮度提升失败: " + err.Error())
|
||||
return
|
||||
}
|
||||
d.log().Success(fmt.Sprintf("亮度提升完成 (%d)", cfg.MaxBri))
|
||||
return
|
||||
}
|
||||
if prev == now {
|
||||
return
|
||||
}
|
||||
prev = now
|
||||
time.Sleep(d.deps.SettleDelay)
|
||||
}
|
||||
}
|
||||
|
||||
// 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 := api.WriteOplock(d.paths.Oplock, api.KindRamp); err != nil {
|
||||
d.log().Warn("写入操作锁失败: " + err.Error())
|
||||
}
|
||||
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/大小,变更时通知主循环。
|
||||
// 用轮询而非 inotify:配置写入可能使用「临时文件 + rename」,会打断对旧 inode 的监听。
|
||||
func (d *Daemon) pollConfig(cfgCh chan struct{}) func() {
|
||||
stop := make(chan struct{})
|
||||
go func() {
|
||||
var lastMod time.Time
|
||||
var lastSize int64
|
||||
if fi, err := os.Stat(d.paths.ConfigFile); err == nil {
|
||||
lastMod, lastSize = fi.ModTime(), fi.Size()
|
||||
}
|
||||
ticker := time.NewTicker(2 * time.Second)
|
||||
defer ticker.Stop()
|
||||
for {
|
||||
select {
|
||||
case <-stop:
|
||||
return
|
||||
case <-ticker.C:
|
||||
fi, err := os.Stat(d.paths.ConfigFile)
|
||||
if err != nil {
|
||||
continue
|
||||
}
|
||||
if fi.ModTime() != lastMod || fi.Size() != lastSize {
|
||||
lastMod, lastSize = fi.ModTime(), fi.Size()
|
||||
select {
|
||||
case cfgCh <- struct{}{}:
|
||||
default:
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}()
|
||||
return func() { close(stop) }
|
||||
}
|
||||
|
||||
func (d *Daemon) handleSignal(sig os.Signal) bool {
|
||||
if sig == syscall.SIGHUP {
|
||||
return false
|
||||
}
|
||||
d.log().Info("收到退出信号,停止守护进程")
|
||||
return true
|
||||
}
|
||||
|
||||
func (d *Daemon) reloadConfig() {
|
||||
cfg, err := config.Load(d.paths.ConfigFile)
|
||||
if err != nil {
|
||||
d.log().Error("加载配置失败: " + err.Error())
|
||||
return
|
||||
}
|
||||
d.setConfig(cfg)
|
||||
d.log().Info("配置已重新加载")
|
||||
}
|
||||
|
||||
func (d *Daemon) setConfig(cfg config.Config) {
|
||||
d.mu.Lock()
|
||||
d.cfg = cfg
|
||||
d.mu.Unlock()
|
||||
|
||||
if d.deps.Log != nil {
|
||||
d.deps.Log.SetLevel(cfg.LogLevel)
|
||||
d.deps.Log.SetMaxSizeKB(cfg.LogMaxSize)
|
||||
d.deps.Log.SetDebug(cfg.DebugMode == 1)
|
||||
}
|
||||
}
|
||||
|
||||
func (d *Daemon) currentConfig() config.Config {
|
||||
d.mu.RLock()
|
||||
defer d.mu.RUnlock()
|
||||
return d.cfg
|
||||
}
|
||||
|
||||
func (d *Daemon) logNodeMissing(node string) {
|
||||
if d.nodeMissingLogged {
|
||||
return
|
||||
}
|
||||
d.log().Error("亮度节点不存在: " + node + ",功能挂起,每 10 秒重试")
|
||||
d.nodeMissingLogged = true
|
||||
}
|
||||
|
||||
func (d *Daemon) log() *logging.Logger {
|
||||
return d.deps.Log
|
||||
}
|
||||
|
||||
func (d *Daemon) debugf(format string, args ...any) {
|
||||
if d.deps.Log != nil {
|
||||
d.deps.Log.Debug(format, args...)
|
||||
}
|
||||
}
|
||||
|
||||
func (d *Daemon) writePID() error {
|
||||
if err := os.MkdirAll(d.paths.PIDDir, 0o755); err != nil {
|
||||
return err
|
||||
}
|
||||
return os.WriteFile(d.paths.PIDFile, []byte(strconv.Itoa(os.Getpid())), 0o644)
|
||||
}
|
||||
|
||||
func (d *Daemon) cleanup() {
|
||||
_ = os.Remove(d.paths.PIDFile)
|
||||
_ = os.Remove(d.paths.Oplock)
|
||||
_ = os.Remove(d.paths.StateFile)
|
||||
}
|
||||
|
||||
// ── 运行状态维护(供 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}
|
||||
})
|
||||
}
|
||||
@@ -0,0 +1,319 @@
|
||||
package daemon
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strconv"
|
||||
"strings"
|
||||
"sync"
|
||||
"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"
|
||||
)
|
||||
|
||||
// scriptRunner 是可编程的命令假实现,用于注入 dumpsys/settings 输出。
|
||||
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 (r *scriptRunner) set(key, value string) {
|
||||
r.mu.Lock()
|
||||
defer r.mu.Unlock()
|
||||
r.outputs[key] = value
|
||||
}
|
||||
|
||||
type fixture struct {
|
||||
daemon *Daemon
|
||||
paths Paths
|
||||
runner *scriptRunner
|
||||
node string
|
||||
logs string
|
||||
}
|
||||
|
||||
func newFixture(t *testing.T, mutate func(*config.Config)) *fixture {
|
||||
t.Helper()
|
||||
dir := t.TempDir()
|
||||
paths := DefaultPaths(dir)
|
||||
if err := os.MkdirAll(filepath.Dir(paths.ConfigFile), 0o755); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
node := filepath.Join(dir, "brightness")
|
||||
if err := os.WriteFile(node, []byte("1200"), 0o644); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
cfg := config.Default()
|
||||
cfg.NowBriFile = node
|
||||
cfg.UIMaxBri = 1000
|
||||
cfg.MaxBri = 3000
|
||||
cfg.StepsNum = 5
|
||||
cfg.AutoBriSleep = 0
|
||||
cfg.DisplayHdrSleep = 0
|
||||
if mutate != nil {
|
||||
mutate(&cfg)
|
||||
}
|
||||
if err := cfg.Save(paths.ConfigFile); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
runner := &scriptRunner{outputs: map[string]string{}}
|
||||
log := logging.New(paths.LogFile, logging.FilterInfo, 512)
|
||||
d, err := New(paths, Deps{
|
||||
AutoBrightness: system.AutoBrightness{Runner: runner},
|
||||
Focus: system.Focus{Runner: runner},
|
||||
HDR: system.HdrRatio{Runner: runner},
|
||||
Log: log,
|
||||
Now: func() time.Time { return time.Date(2026, 9, 10, 12, 0, 0, 0, time.Local) },
|
||||
StepDelay: time.Millisecond,
|
||||
SettleDelay: time.Millisecond,
|
||||
})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
return &fixture{daemon: d, paths: paths, runner: runner, node: node, logs: paths.LogFile}
|
||||
}
|
||||
|
||||
func (f *fixture) nodeValue(t *testing.T) int {
|
||||
t.Helper()
|
||||
data, err := os.ReadFile(f.node)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
v, err := strconv.Atoi(strings.TrimSpace(string(data)))
|
||||
if err != nil {
|
||||
t.Fatalf("节点内容不是整数: %q", string(data))
|
||||
}
|
||||
return v
|
||||
}
|
||||
|
||||
func (f *fixture) logContent(t *testing.T) string {
|
||||
t.Helper()
|
||||
data, err := os.ReadFile(f.logs)
|
||||
if err != nil {
|
||||
return ""
|
||||
}
|
||||
return string(data)
|
||||
}
|
||||
|
||||
func TestEvaluateBoostsWhenAboveThreshold(t *testing.T) {
|
||||
f := newFixture(t, nil)
|
||||
f.daemon.evaluate()
|
||||
|
||||
if got := f.nodeValue(t); got != 3000 {
|
||||
t.Fatalf("应提升到目标亮度 3000, 实际 %d", got)
|
||||
}
|
||||
logs := f.logContent(t)
|
||||
if !strings.Contains(logs, "触发提升") || !strings.Contains(logs, "亮度提升完成 (3000)") {
|
||||
t.Fatalf("日志缺少提升记录: %q", logs)
|
||||
}
|
||||
if _, err := os.Stat(f.paths.Oplock); err == nil {
|
||||
t.Fatal("提升结束后操作锁应被清除")
|
||||
}
|
||||
}
|
||||
|
||||
func TestEvaluateSkipsBelowThreshold(t *testing.T) {
|
||||
f := newFixture(t, nil)
|
||||
if err := os.WriteFile(f.node, []byte("500"), 0o644); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
f.daemon.evaluate()
|
||||
|
||||
if got := f.nodeValue(t); got != 500 {
|
||||
t.Fatalf("低于阈值不应提升, 实际 %d", got)
|
||||
}
|
||||
if strings.Contains(f.logContent(t), "触发提升") {
|
||||
t.Fatal("不应记录提升日志")
|
||||
}
|
||||
}
|
||||
|
||||
func TestEvaluateSkipsWhenUncalibrated(t *testing.T) {
|
||||
f := newFixture(t, func(c *config.Config) { c.MaxBri = 0 })
|
||||
f.daemon.evaluate()
|
||||
if got := f.nodeValue(t); got != 1200 {
|
||||
t.Fatalf("未校准时不应提升, 实际 %d", got)
|
||||
}
|
||||
}
|
||||
|
||||
func TestEvaluateSkipsInSleepWindow(t *testing.T) {
|
||||
// 固定时间 12:00,休眠时段覆盖它
|
||||
f := newFixture(t, func(c *config.Config) { c.SleepTime = "0900-1700" })
|
||||
f.daemon.evaluate()
|
||||
if got := f.nodeValue(t); got != 1200 {
|
||||
t.Fatalf("休眠时段不应提升, 实际 %d", got)
|
||||
}
|
||||
if !strings.Contains(f.logContent(t), "处于休眠时段") {
|
||||
t.Fatal("应记录休眠时段日志")
|
||||
}
|
||||
}
|
||||
|
||||
func TestEvaluateSkipsWhenAutoBrightnessOn(t *testing.T) {
|
||||
f := newFixture(t, func(c *config.Config) { c.AutoBriSleep = 1 })
|
||||
f.runner.set("settings get system screen_brightness_mode", "1\n")
|
||||
f.daemon.evaluate()
|
||||
if got := f.nodeValue(t); got != 1200 {
|
||||
t.Fatalf("自动亮度开启时不应提升, 实际 %d", got)
|
||||
}
|
||||
if !strings.Contains(f.logContent(t), "自动亮度已启用") {
|
||||
t.Fatal("应记录自动亮度日志")
|
||||
}
|
||||
}
|
||||
|
||||
func TestEvaluateSkipsWhenBlacklisted(t *testing.T) {
|
||||
f := newFixture(t, func(c *config.Config) {
|
||||
c.BlacklistApps = []string{"com.video.app/.MainActivity"}
|
||||
})
|
||||
f.runner.set("dumpsys window", " mCurrentFocus=Window{abc u0 com.video.app/.MainActivity}\n")
|
||||
f.daemon.evaluate()
|
||||
if got := f.nodeValue(t); got != 1200 {
|
||||
t.Fatalf("黑名单应用内不应提升, 实际 %d", got)
|
||||
}
|
||||
if !strings.Contains(f.logContent(t), "在黑名单中") {
|
||||
t.Fatal("应记录黑名单日志")
|
||||
}
|
||||
}
|
||||
|
||||
func TestEvaluateHdrHysteresis(t *testing.T) {
|
||||
f := newFixture(t, func(c *config.Config) { c.DisplayHdrSleep = 1 })
|
||||
|
||||
// 比率高于进入阈值:进入休眠,不提升
|
||||
f.runner.set("dumpsys display", "hdrSdrRatio 1.30\n")
|
||||
f.daemon.evaluate()
|
||||
if got := f.nodeValue(t); got != 1200 {
|
||||
t.Fatalf("HDR 内容时不应提升, 实际 %d", got)
|
||||
}
|
||||
if !strings.Contains(f.logContent(t), "进入休眠") {
|
||||
t.Fatal("应记录进入 HDR 休眠")
|
||||
}
|
||||
|
||||
// 比率落到迟滞区间内:仍休眠
|
||||
f.runner.set("dumpsys display", "hdrSdrRatio 1.10\n")
|
||||
f.daemon.evaluate()
|
||||
if got := f.nodeValue(t); got != 1200 {
|
||||
t.Fatalf("迟滞区间内不应提升, 实际 %d", got)
|
||||
}
|
||||
|
||||
// 比率降到退出阈值以下:解除休眠并提升
|
||||
f.runner.set("dumpsys display", "hdrSdrRatio 1.02\n")
|
||||
f.daemon.evaluate()
|
||||
if got := f.nodeValue(t); got != 3000 {
|
||||
t.Fatalf("解除休眠后应提升, 实际 %d", got)
|
||||
}
|
||||
if !strings.Contains(f.logContent(t), "HDR 休眠解除") {
|
||||
t.Fatal("应记录解除休眠")
|
||||
}
|
||||
}
|
||||
|
||||
func TestEvaluateRespectsFlags(t *testing.T) {
|
||||
for _, flag := range []string{"stop.flag", "daemon.pause"} {
|
||||
t.Run(flag, func(t *testing.T) {
|
||||
f := newFixture(t, nil)
|
||||
if err := os.MkdirAll(f.paths.PIDDir, 0o755); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if err := os.WriteFile(filepath.Join(f.paths.PIDDir, flag), nil, 0o644); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
f.daemon.evaluate()
|
||||
if got := f.nodeValue(t); got != 1200 {
|
||||
t.Fatalf("%s 存在时不应提升, 实际 %d", flag, got)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestEvaluateWaitsForSettledValue(t *testing.T) {
|
||||
f := newFixture(t, nil)
|
||||
// 首次读取低于阈值,随后稳定:不应无限等待
|
||||
if err := os.WriteFile(f.node, []byte("500"), 0o644); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
start := time.Now()
|
||||
f.daemon.evaluate()
|
||||
if elapsed := time.Since(start); elapsed > time.Second {
|
||||
t.Fatalf("值稳定后应提前退出,实际耗时 %v", elapsed)
|
||||
}
|
||||
}
|
||||
|
||||
func TestBoostTogglesPeakAndRestore(t *testing.T) {
|
||||
f := newFixture(t, nil)
|
||||
|
||||
if err := Boost(f.paths, nil); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if got := f.nodeValue(t); got != 3000 {
|
||||
t.Fatalf("一键提升应写入峰值 3000, 实际 %d", got)
|
||||
}
|
||||
if _, err := os.Stat(f.paths.BoostFlag); err != nil {
|
||||
t.Fatalf("应记录原亮度标记: %v", err)
|
||||
}
|
||||
if _, err := os.Stat(f.paths.Oplock); err == nil {
|
||||
t.Fatal("写入完成后应释放操作锁")
|
||||
}
|
||||
|
||||
if err := Boost(f.paths, nil); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if got := f.nodeValue(t); got != 1200 {
|
||||
t.Fatalf("再次调用应恢复原亮度 1200, 实际 %d", got)
|
||||
}
|
||||
if _, err := os.Stat(f.paths.BoostFlag); err == nil {
|
||||
t.Fatal("恢复后应清除标记")
|
||||
}
|
||||
}
|
||||
|
||||
func TestBoostRejectsUnconfiguredPeak(t *testing.T) {
|
||||
f := newFixture(t, func(c *config.Config) { c.MaxBri = 0 })
|
||||
if err := Boost(f.paths, nil); err == nil {
|
||||
t.Fatal("未配置峰值亮度应报错")
|
||||
}
|
||||
}
|
||||
|
||||
func TestBoostRejectsMissingNode(t *testing.T) {
|
||||
f := newFixture(t, nil)
|
||||
if err := os.Remove(f.node); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if err := Boost(f.paths, nil); err == nil {
|
||||
t.Fatal("节点不存在应报错")
|
||||
}
|
||||
}
|
||||
|
||||
func TestReadDaemonPID(t *testing.T) {
|
||||
dir := t.TempDir()
|
||||
pidFile := filepath.Join(dir, "daemon.pid")
|
||||
|
||||
if _, alive := api.DaemonPID(pidFile); alive {
|
||||
t.Fatal("文件不存在应视为未运行")
|
||||
}
|
||||
_ = os.WriteFile(pidFile, []byte("notanumber"), 0o644)
|
||||
if _, alive := api.DaemonPID(pidFile); alive {
|
||||
t.Fatal("非法内容应视为未运行")
|
||||
}
|
||||
_ = os.WriteFile(pidFile, []byte("999999"), 0o644)
|
||||
if _, alive := api.DaemonPID(pidFile); alive {
|
||||
t.Fatal("不存在的 PID 应视为未运行")
|
||||
}
|
||||
_ = os.WriteFile(pidFile, []byte(strconv.Itoa(os.Getpid())), 0o644)
|
||||
if pid, alive := api.DaemonPID(pidFile); !alive || pid != os.Getpid() {
|
||||
t.Fatal("当前进程 PID 应视为存活")
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,119 @@
|
||||
package daemon
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"os"
|
||||
"os/exec"
|
||||
"strconv"
|
||||
"strings"
|
||||
"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"
|
||||
)
|
||||
|
||||
// Boost 一键提升至峰值亮度;再次调用恢复原亮度(取代 boost.sh)。
|
||||
func Boost(paths Paths, log *logging.Logger) error {
|
||||
cfg, err := config.Load(paths.ConfigFile)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if !api.FileExists(cfg.NowBriFile) {
|
||||
return fmt.Errorf("亮度节点不存在: %s", cfg.NowBriFile)
|
||||
}
|
||||
|
||||
// 已提升过:恢复并清除标记
|
||||
if data, err := os.ReadFile(paths.BoostFlag); err == nil {
|
||||
restore := strings.TrimSpace(string(data))
|
||||
if restore != "" {
|
||||
if v, err := strconv.Atoi(restore); err == nil {
|
||||
writeWithOplock(paths, log, cfg.NowBriFile, v)
|
||||
}
|
||||
}
|
||||
_ = os.Remove(paths.BoostFlag)
|
||||
return nil
|
||||
}
|
||||
|
||||
if cfg.MaxBri <= 0 {
|
||||
return errors.New("峰值亮度未配置,无法一键提升")
|
||||
}
|
||||
now, err := brightness.ReadInt(cfg.NowBriFile)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if err := os.MkdirAll(paths.PIDDir, 0o755); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := os.WriteFile(paths.BoostFlag, []byte(strconv.Itoa(now)), 0o644); err != nil {
|
||||
return err
|
||||
}
|
||||
writeWithOplock(paths, log, cfg.NowBriFile, cfg.MaxBri)
|
||||
return nil
|
||||
}
|
||||
|
||||
// writeWithOplock 在持操作锁的前提下写一次亮度节点。
|
||||
func writeWithOplock(paths Paths, log *logging.Logger, node string, value int) {
|
||||
_ = os.MkdirAll(paths.PIDDir, 0o755)
|
||||
if err := api.WriteOplock(paths.Oplock, api.KindBoost); err != nil && log != nil {
|
||||
log.Warn("写入操作锁失败: " + err.Error())
|
||||
}
|
||||
defer api.RemoveOplock(paths.Oplock)
|
||||
if err := brightness.WriteInt(node, value); err != nil && log != nil {
|
||||
log.Error("写入亮度节点失败: " + err.Error())
|
||||
}
|
||||
}
|
||||
|
||||
// Restart 实现「重启模块」:daemon 在跑就发 SIGHUP 让它重建监听,
|
||||
// 没跑就检查亮度节点后拉起一个新 daemon(取代 script/restart.sh)。
|
||||
func Restart(paths Paths, selfPath string, log *logging.Logger) error {
|
||||
if err := os.MkdirAll(paths.PIDDir, 0o755); err != nil {
|
||||
return err
|
||||
}
|
||||
// 整个重启窗口持操作锁,WebUI 会据此暂停刷新
|
||||
if err := api.WriteOplock(paths.Oplock, api.KindRestart); err != nil {
|
||||
return err
|
||||
}
|
||||
defer api.RemoveOplock(paths.Oplock)
|
||||
|
||||
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)
|
||||
}
|
||||
// daemon 重建监听后会重写 PID 文件,以其 mtime 变化作为就绪信号
|
||||
waitForPIDRewrite(paths.PIDFile, start, 3*time.Second)
|
||||
return nil
|
||||
}
|
||||
|
||||
cfg, err := config.Load(paths.ConfigFile)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if !api.FileExists(cfg.NowBriFile) {
|
||||
return fmt.Errorf("亮度节点不存在: %s,无法启动服务,请先在配置页填写正确路径", cfg.NowBriFile)
|
||||
}
|
||||
|
||||
cmd := exec.Command(selfPath, "daemon")
|
||||
cmd.SysProcAttr = &syscall.SysProcAttr{Setsid: true}
|
||||
cmd.Stdin, cmd.Stdout, cmd.Stderr = nil, nil, nil
|
||||
if err := cmd.Start(); err != nil {
|
||||
return fmt.Errorf("启动守护进程失败: %w", err)
|
||||
}
|
||||
return cmd.Process.Release()
|
||||
}
|
||||
|
||||
// waitForPIDRewrite 等待 PID 文件在 start 之后被重写。
|
||||
func waitForPIDRewrite(pidFile string, start time.Time, timeout time.Duration) bool {
|
||||
deadline := time.Now().Add(timeout)
|
||||
for time.Now().Before(deadline) {
|
||||
if fi, err := os.Stat(pidFile); err == nil && fi.ModTime().After(start) {
|
||||
return true
|
||||
}
|
||||
time.Sleep(100 * time.Millisecond)
|
||||
}
|
||||
return false
|
||||
}
|
||||
@@ -0,0 +1,346 @@
|
||||
// Package inotify 封装原始 inotify,事件字母与 toybox inotifyd 完全兼容。
|
||||
//
|
||||
// 为什么不用 fsnotify:fsnotify 不暴露 IN_CLOSE_WRITE / IN_CLOSE_NOWRITE,
|
||||
// 而部分机型需要监听 `w` / `0` 事件才能触发亮度提升。
|
||||
package inotify
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"sync"
|
||||
"time"
|
||||
"unsafe"
|
||||
|
||||
"golang.org/x/sys/unix"
|
||||
)
|
||||
|
||||
// Event 是一次监听事件。
|
||||
type Event struct {
|
||||
Letters string // 事件字母串,如 "c"、"0"、"cw"
|
||||
Path string // 触发事件的被监听路径
|
||||
}
|
||||
|
||||
// LettersToMask 把事件字母串转换为 inotify watch mask(与 toybox 兼容)。
|
||||
func LettersToMask(letters string) uint32 {
|
||||
var mask uint32
|
||||
for _, c := range letters {
|
||||
switch c {
|
||||
case 'a':
|
||||
mask |= unix.IN_ACCESS
|
||||
case 'c':
|
||||
mask |= unix.IN_MODIFY
|
||||
case 'e':
|
||||
mask |= unix.IN_ATTRIB
|
||||
case 'w':
|
||||
mask |= unix.IN_CLOSE_WRITE
|
||||
case '0':
|
||||
mask |= unix.IN_CLOSE_NOWRITE
|
||||
case 'r':
|
||||
mask |= unix.IN_OPEN
|
||||
case 'n':
|
||||
mask |= unix.IN_CREATE
|
||||
case 'd':
|
||||
mask |= unix.IN_DELETE
|
||||
case 'D':
|
||||
mask |= unix.IN_DELETE_SELF
|
||||
case 'M':
|
||||
mask |= unix.IN_MOVE_SELF
|
||||
case 'm':
|
||||
mask |= unix.IN_MOVED_TO
|
||||
case 'y':
|
||||
mask |= unix.IN_MOVED_FROM
|
||||
case '*':
|
||||
mask |= unix.IN_ALL_EVENTS
|
||||
case 'u', 'o', 'x':
|
||||
// 内核产生的事件,不设置 watch mask
|
||||
}
|
||||
}
|
||||
return mask
|
||||
}
|
||||
|
||||
// MaskToLetters 把事件 mask 转回字母串(顺序与旧 lumipro 一致)。
|
||||
func MaskToLetters(mask uint32) string {
|
||||
var s []byte
|
||||
if mask&unix.IN_ACCESS != 0 {
|
||||
s = append(s, 'a')
|
||||
}
|
||||
if mask&unix.IN_MODIFY != 0 {
|
||||
s = append(s, 'c')
|
||||
}
|
||||
if mask&unix.IN_ATTRIB != 0 {
|
||||
s = append(s, 'e')
|
||||
}
|
||||
if mask&unix.IN_CLOSE_WRITE != 0 {
|
||||
s = append(s, 'w')
|
||||
}
|
||||
if mask&unix.IN_CLOSE_NOWRITE != 0 {
|
||||
s = append(s, '0')
|
||||
}
|
||||
if mask&unix.IN_OPEN != 0 {
|
||||
s = append(s, 'r')
|
||||
}
|
||||
if mask&unix.IN_MOVED_FROM != 0 {
|
||||
s = append(s, 'y')
|
||||
}
|
||||
if mask&unix.IN_MOVED_TO != 0 {
|
||||
s = append(s, 'm')
|
||||
}
|
||||
if mask&unix.IN_CREATE != 0 {
|
||||
s = append(s, 'n')
|
||||
}
|
||||
if mask&unix.IN_DELETE != 0 {
|
||||
s = append(s, 'd')
|
||||
}
|
||||
if mask&unix.IN_DELETE_SELF != 0 {
|
||||
s = append(s, 'D')
|
||||
}
|
||||
if mask&unix.IN_MOVE_SELF != 0 {
|
||||
s = append(s, 'M')
|
||||
}
|
||||
if mask&unix.IN_UNMOUNT != 0 {
|
||||
s = append(s, 'u')
|
||||
}
|
||||
if mask&unix.IN_Q_OVERFLOW != 0 {
|
||||
s = append(s, 'o')
|
||||
}
|
||||
if mask&unix.IN_IGNORED != 0 {
|
||||
s = append(s, 'x')
|
||||
}
|
||||
if len(s) == 0 {
|
||||
return "?"
|
||||
}
|
||||
return string(s)
|
||||
}
|
||||
|
||||
// Watcher 是一个 inotify 实例。
|
||||
type Watcher struct {
|
||||
fd int
|
||||
wakeR int
|
||||
wakeW int
|
||||
|
||||
mu sync.Mutex
|
||||
watches map[int32]string
|
||||
}
|
||||
|
||||
// New 创建 watcher。
|
||||
func New() (*Watcher, error) {
|
||||
fd, err := unix.InotifyInit1(unix.IN_NONBLOCK | unix.IN_CLOEXEC)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("inotify_init 失败: %w", err)
|
||||
}
|
||||
// 唤醒管道:让 Run 能在阻塞 poll 期间被 Stop 立即唤醒
|
||||
var pipe [2]int
|
||||
if err := unix.Pipe2(pipe[:], unix.O_NONBLOCK|unix.O_CLOEXEC); err != nil {
|
||||
_ = unix.Close(fd)
|
||||
return nil, fmt.Errorf("创建唤醒管道失败: %w", err)
|
||||
}
|
||||
return &Watcher{
|
||||
fd: fd,
|
||||
wakeR: pipe[0],
|
||||
wakeW: pipe[1],
|
||||
watches: map[int32]string{},
|
||||
}, nil
|
||||
}
|
||||
|
||||
// Add 监听路径,letters 为事件字母串。
|
||||
func (w *Watcher) Add(path, letters string) error {
|
||||
mask := LettersToMask(letters)
|
||||
wd, err := unix.InotifyAddWatch(w.fd, path, mask)
|
||||
if err != nil {
|
||||
return fmt.Errorf("监听 %s 失败: %w", path, err)
|
||||
}
|
||||
w.mu.Lock()
|
||||
w.watches[int32(wd)] = path
|
||||
w.mu.Unlock()
|
||||
return nil
|
||||
}
|
||||
|
||||
// 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
|
||||
if w.fd >= 0 {
|
||||
err := unix.Close(w.fd)
|
||||
w.fd = -1
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// wake 唤醒正在 poll 的 Run。
|
||||
func (w *Watcher) wake() {
|
||||
if w.wakeW >= 0 {
|
||||
_, _ = unix.Write(w.wakeW, []byte{1})
|
||||
}
|
||||
}
|
||||
|
||||
// poll 等待 inotify fd 可读或唤醒管道触发。timeoutMs 为 -1 表示永久阻塞。
|
||||
func (w *Watcher) poll(timeoutMs int) (ready, woken bool, err error) {
|
||||
fds := []unix.PollFd{
|
||||
{Fd: int32(w.fd), Events: unix.POLLIN},
|
||||
{Fd: int32(w.wakeR), Events: unix.POLLIN},
|
||||
}
|
||||
n, err := unix.Poll(fds, timeoutMs)
|
||||
if err != nil {
|
||||
if err == unix.EINTR {
|
||||
return false, false, nil
|
||||
}
|
||||
return false, false, err
|
||||
}
|
||||
if n == 0 {
|
||||
return false, false, nil
|
||||
}
|
||||
if fds[1].Revents&unix.POLLIN != 0 {
|
||||
return false, true, nil
|
||||
}
|
||||
return fds[0].Revents&unix.POLLIN != 0, false, nil
|
||||
}
|
||||
|
||||
// ReadEvents 非阻塞读取当前可用的全部事件;无数据时返回空切片。
|
||||
func (w *Watcher) ReadEvents() ([]Event, error) {
|
||||
var events []Event
|
||||
buf := make([]byte, 4096)
|
||||
evSize := int(unsafe.Sizeof(unix.InotifyEvent{}))
|
||||
|
||||
for {
|
||||
n, err := unix.Read(w.fd, buf)
|
||||
if err != nil {
|
||||
if err == unix.EAGAIN || err == unix.EWOULDBLOCK {
|
||||
return events, nil
|
||||
}
|
||||
if err == unix.EINTR {
|
||||
continue
|
||||
}
|
||||
return events, err
|
||||
}
|
||||
if n <= 0 {
|
||||
return events, nil
|
||||
}
|
||||
|
||||
for offset := 0; offset+evSize <= n; {
|
||||
raw := (*unix.InotifyEvent)(unsafe.Pointer(&buf[offset]))
|
||||
// 事件结构后跟 name(已 NUL 结尾),本程序按 wd 定位路径,忽略 name
|
||||
offset += evSize + int(raw.Len)
|
||||
|
||||
w.mu.Lock()
|
||||
path, ok := w.watches[raw.Wd]
|
||||
w.mu.Unlock()
|
||||
if !ok {
|
||||
continue
|
||||
}
|
||||
events = append(events, Event{
|
||||
Letters: MaskToLetters(raw.Mask),
|
||||
Path: path,
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Runner 把 watcher 包装成「防抖 + 执行 handler + 排空积压」的事件循环。
|
||||
type Runner struct {
|
||||
w *Watcher
|
||||
debounce time.Duration
|
||||
debugf func(format string, args ...any)
|
||||
}
|
||||
|
||||
// NewRunner 创建事件循环。debugf 可为 nil。
|
||||
func (w *Watcher) NewRunner(debounce time.Duration, debugf func(string, ...any)) *Runner {
|
||||
if debounce <= 0 {
|
||||
debounce = 300 * time.Millisecond
|
||||
}
|
||||
return &Runner{w: w, debounce: debounce, debugf: debugf}
|
||||
}
|
||||
|
||||
func (r *Runner) debug(format string, args ...any) {
|
||||
if r.debugf != nil {
|
||||
r.debugf(format, args...)
|
||||
}
|
||||
}
|
||||
|
||||
// Run 持续监听并触发 handler,直到 stop 被关闭。
|
||||
// handler 执行期间积压的事件会被全部丢弃(防止自身写入节点造成递归)。
|
||||
func (r *Runner) Run(handler func(Event), stop <-chan struct{}) error {
|
||||
var pending *Event
|
||||
var triggeredAt time.Time
|
||||
|
||||
for {
|
||||
select {
|
||||
case <-stop:
|
||||
return nil
|
||||
default:
|
||||
}
|
||||
|
||||
timeout := -1
|
||||
if pending != nil {
|
||||
elapsed := time.Since(triggeredAt)
|
||||
if elapsed >= r.debounce {
|
||||
timeout = 0
|
||||
} else {
|
||||
timeout = int((r.debounce - elapsed).Milliseconds())
|
||||
if timeout < 0 {
|
||||
timeout = 0
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if timeout != 0 {
|
||||
ready, woken, err := r.w.poll(timeout)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if woken {
|
||||
return nil
|
||||
}
|
||||
if ready {
|
||||
events, err := r.w.ReadEvents()
|
||||
if err != nil {
|
||||
r.debug("读取事件失败: %v", err)
|
||||
continue
|
||||
}
|
||||
for _, ev := range events {
|
||||
ev := ev
|
||||
pending = &ev
|
||||
triggeredAt = time.Now()
|
||||
r.debug("event: %s path: %s", ev.Letters, ev.Path)
|
||||
}
|
||||
continue
|
||||
}
|
||||
}
|
||||
|
||||
if pending == nil {
|
||||
continue
|
||||
}
|
||||
|
||||
ev := *pending
|
||||
pending = nil
|
||||
r.debug("debounce fired → handler: %s %s", ev.Letters, ev.Path)
|
||||
handler(ev)
|
||||
|
||||
// 丢弃 handler 执行期间(亮度渐变写入)积压的全部事件
|
||||
drained := 0
|
||||
for {
|
||||
events, err := r.w.ReadEvents()
|
||||
if err != nil || len(events) == 0 {
|
||||
break
|
||||
}
|
||||
drained += len(events)
|
||||
}
|
||||
if drained > 0 {
|
||||
r.debug("drain: discarded %d event(s)", drained)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Stop 唤醒 Run 使其退出(配合关闭 stop channel 使用)。
|
||||
func (w *Watcher) Stop() { w.wake() }
|
||||
|
||||
// WatchFileModify 是给单文件(如 config.json)做变更监听的便捷封装。
|
||||
func (w *Watcher) WatchFileModify(path string) error {
|
||||
if _, err := os.Stat(path); err != nil {
|
||||
return err
|
||||
}
|
||||
return w.Add(path, "cw")
|
||||
}
|
||||
@@ -0,0 +1,324 @@
|
||||
package inotify
|
||||
|
||||
import (
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
"sync"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"golang.org/x/sys/unix"
|
||||
)
|
||||
|
||||
func TestLettersToMaskMapping(t *testing.T) {
|
||||
cases := map[string]uint32{
|
||||
"a": unix.IN_ACCESS,
|
||||
"c": unix.IN_MODIFY,
|
||||
"e": unix.IN_ATTRIB,
|
||||
"w": unix.IN_CLOSE_WRITE,
|
||||
"0": unix.IN_CLOSE_NOWRITE,
|
||||
"r": unix.IN_OPEN,
|
||||
"n": unix.IN_CREATE,
|
||||
"d": unix.IN_DELETE,
|
||||
"D": unix.IN_DELETE_SELF,
|
||||
"M": unix.IN_MOVE_SELF,
|
||||
"m": unix.IN_MOVED_TO,
|
||||
"y": unix.IN_MOVED_FROM,
|
||||
"*": unix.IN_ALL_EVENTS,
|
||||
}
|
||||
for letter, want := range cases {
|
||||
if got := LettersToMask(letter); got != want {
|
||||
t.Errorf("LettersToMask(%q) = %#x, 期望 %#x", letter, got, want)
|
||||
}
|
||||
}
|
||||
// 内核产生的事件字母不应设置 mask
|
||||
for _, letter := range []string{"u", "o", "x", "z"} {
|
||||
if got := LettersToMask(letter); got != 0 {
|
||||
t.Errorf("LettersToMask(%q) 应为 0, 实际 %#x", letter, got)
|
||||
}
|
||||
}
|
||||
if got := LettersToMask("cw"); got != unix.IN_MODIFY|unix.IN_CLOSE_WRITE {
|
||||
t.Errorf("多字母组合错误: %#x", got)
|
||||
}
|
||||
}
|
||||
|
||||
func TestMaskToLettersOrder(t *testing.T) {
|
||||
var mask uint32 = unix.IN_MODIFY | unix.IN_CLOSE_WRITE | unix.IN_CLOSE_NOWRITE
|
||||
if got := MaskToLetters(mask); got != "cw0" {
|
||||
t.Fatalf("MaskToLetters = %q, 期望 cw0", got)
|
||||
}
|
||||
if got := MaskToLetters(0); got != "?" {
|
||||
t.Fatalf("空 mask 应为 ?, 实际 %q", got)
|
||||
}
|
||||
}
|
||||
|
||||
// collect 在后台运行 Runner,收集事件。
|
||||
type collector struct {
|
||||
mu sync.Mutex
|
||||
events []Event
|
||||
}
|
||||
|
||||
func (c *collector) add(ev Event) {
|
||||
c.mu.Lock()
|
||||
c.events = append(c.events, ev)
|
||||
c.mu.Unlock()
|
||||
}
|
||||
|
||||
func (c *collector) snapshot() []Event {
|
||||
c.mu.Lock()
|
||||
defer c.mu.Unlock()
|
||||
return append([]Event(nil), c.events...)
|
||||
}
|
||||
|
||||
func startRunner(t *testing.T, w *Watcher, debounce time.Duration, handler func(Event)) chan struct{} {
|
||||
t.Helper()
|
||||
stop := make(chan struct{})
|
||||
done := make(chan struct{})
|
||||
go func() {
|
||||
defer close(done)
|
||||
_ = w.NewRunner(debounce, nil).Run(handler, stop)
|
||||
}()
|
||||
t.Cleanup(func() {
|
||||
close(stop)
|
||||
w.Stop()
|
||||
select {
|
||||
case <-done:
|
||||
case <-time.After(2 * time.Second):
|
||||
t.Error("Run 未能退出")
|
||||
}
|
||||
})
|
||||
return stop
|
||||
}
|
||||
|
||||
func waitFor(t *testing.T, timeout time.Duration, cond func() bool) bool {
|
||||
t.Helper()
|
||||
deadline := time.Now().Add(timeout)
|
||||
for time.Now().Before(deadline) {
|
||||
if cond() {
|
||||
return true
|
||||
}
|
||||
time.Sleep(10 * time.Millisecond)
|
||||
}
|
||||
return cond()
|
||||
}
|
||||
|
||||
func TestWatchModifyDeliversEvent(t *testing.T) {
|
||||
path := filepath.Join(t.TempDir(), "brightness")
|
||||
if err := os.WriteFile(path, []byte("100"), 0o644); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
w, err := New()
|
||||
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, 30*time.Millisecond, c.add)
|
||||
|
||||
if err := os.WriteFile(path, []byte("200"), 0o644); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if !waitFor(t, 2*time.Second, func() bool { return len(c.snapshot()) > 0 }) {
|
||||
t.Fatal("未收到 MODIFY 事件")
|
||||
}
|
||||
ev := c.snapshot()[0]
|
||||
if !strings.Contains(ev.Letters, "c") || ev.Path != path {
|
||||
t.Fatalf("事件内容不正确: %+v", ev)
|
||||
}
|
||||
}
|
||||
|
||||
// 关键兼容性测试:fsnotify 不暴露 CLOSE_WRITE,必须能收到 'w'。
|
||||
func TestCloseWriteLetter(t *testing.T) {
|
||||
path := filepath.Join(t.TempDir(), "node")
|
||||
if err := os.WriteFile(path, []byte("1"), 0o644); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
w, err := New()
|
||||
if err != nil {
|
||||
t.Skipf("当前环境不支持 inotify: %v", err)
|
||||
}
|
||||
defer w.Close()
|
||||
if err := w.Add(path, "w"); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
c := &collector{}
|
||||
startRunner(t, w, 30*time.Millisecond, c.add)
|
||||
|
||||
f, err := os.OpenFile(path, os.O_WRONLY|os.O_APPEND, 0o644)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if _, err := f.WriteString("2"); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if err := f.Close(); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
if !waitFor(t, 2*time.Second, func() bool { return len(c.snapshot()) > 0 }) {
|
||||
t.Fatal("未收到 CLOSE_WRITE 事件")
|
||||
}
|
||||
if got := c.snapshot()[0].Letters; !strings.Contains(got, "w") {
|
||||
t.Fatalf("事件字母应为 w, 实际 %q", got)
|
||||
}
|
||||
}
|
||||
|
||||
func TestCloseNoWriteLetter(t *testing.T) {
|
||||
path := filepath.Join(t.TempDir(), "node")
|
||||
if err := os.WriteFile(path, []byte("1"), 0o644); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
w, err := New()
|
||||
if err != nil {
|
||||
t.Skipf("当前环境不支持 inotify: %v", err)
|
||||
}
|
||||
defer w.Close()
|
||||
if err := w.Add(path, "0"); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
c := &collector{}
|
||||
startRunner(t, w, 30*time.Millisecond, c.add)
|
||||
|
||||
f, err := os.Open(path)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
_, _ = f.Read(make([]byte, 1))
|
||||
if err := f.Close(); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
if !waitFor(t, 2*time.Second, func() bool { return len(c.snapshot()) > 0 }) {
|
||||
t.Fatal("未收到 CLOSE_NOWRITE 事件")
|
||||
}
|
||||
if got := c.snapshot()[0].Letters; !strings.Contains(got, "0") {
|
||||
t.Fatalf("事件字母应为 0, 实际 %q", got)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDebounceCoalescesBurst(t *testing.T) {
|
||||
path := filepath.Join(t.TempDir(), "node")
|
||||
if err := os.WriteFile(path, []byte("1"), 0o644); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
w, err := New()
|
||||
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)
|
||||
|
||||
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 }) {
|
||||
t.Fatal("未收到事件")
|
||||
}
|
||||
time.Sleep(300 * time.Millisecond) // 等超过一个防抖窗口
|
||||
if got := len(c.snapshot()); got != 1 {
|
||||
t.Fatalf("防抖后应只触发 1 次, 实际 %d 次", got)
|
||||
}
|
||||
}
|
||||
|
||||
// handler 自身写入被监听文件时,积压事件必须被丢弃,避免递归。
|
||||
func TestDrainPreventsRecursion(t *testing.T) {
|
||||
path := filepath.Join(t.TempDir(), "node")
|
||||
if err := os.WriteFile(path, []byte("1"), 0o644); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
w, err := New()
|
||||
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, 100*time.Millisecond, func(ev Event) {
|
||||
c.add(ev)
|
||||
// 模拟亮度渐变写入
|
||||
for i := 0; i < 5; i++ {
|
||||
_ = os.WriteFile(path, []byte("step"), 0o644)
|
||||
}
|
||||
})
|
||||
|
||||
if err := os.WriteFile(path, []byte("trigger"), 0o644); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if !waitFor(t, 2*time.Second, func() bool { return len(c.snapshot()) > 0 }) {
|
||||
t.Fatal("未收到事件")
|
||||
}
|
||||
time.Sleep(400 * time.Millisecond)
|
||||
if got := len(c.snapshot()); got != 1 {
|
||||
t.Fatalf("渐变写入产生的事件应被丢弃, handler 应只执行 1 次, 实际 %d 次", got)
|
||||
}
|
||||
}
|
||||
|
||||
func TestStopExitsBlockingRun(t *testing.T) {
|
||||
path := filepath.Join(t.TempDir(), "node")
|
||||
if err := os.WriteFile(path, []byte("1"), 0o644); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
w, err := New()
|
||||
if err != nil {
|
||||
t.Skipf("当前环境不支持 inotify: %v", err)
|
||||
}
|
||||
defer w.Close()
|
||||
if err := w.Add(path, "c"); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
stop := make(chan struct{})
|
||||
done := make(chan error, 1)
|
||||
go func() {
|
||||
done <- w.NewRunner(time.Second, nil).Run(func(Event) {}, stop)
|
||||
}()
|
||||
|
||||
time.Sleep(100 * time.Millisecond)
|
||||
close(stop)
|
||||
w.Stop() // 唤醒阻塞中的 poll
|
||||
|
||||
select {
|
||||
case err := <-done:
|
||||
if err != nil {
|
||||
t.Fatalf("Run 返回错误: %v", err)
|
||||
}
|
||||
case <-time.After(2 * time.Second):
|
||||
t.Fatal("Stop 未能唤醒 Run")
|
||||
}
|
||||
}
|
||||
|
||||
func TestAddMissingPathFails(t *testing.T) {
|
||||
w, err := New()
|
||||
if err != nil {
|
||||
t.Skipf("当前环境不支持 inotify: %v", err)
|
||||
}
|
||||
defer w.Close()
|
||||
if err := w.Add(filepath.Join(t.TempDir(), "不存在"), "c"); err == nil {
|
||||
t.Fatal("监听不存在的路径应报错")
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,157 @@
|
||||
// Package logging 写模块的 service.log。
|
||||
//
|
||||
// 格式与旧 shell 版一致:`[MM-DD HH:SS] [luminpro] [LEVEL] msg`。
|
||||
// WebUI 的日志过滤只做 `includes("[LEVEL]")` 子串匹配,因此格式必须保持。
|
||||
package logging
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"sync"
|
||||
"time"
|
||||
)
|
||||
|
||||
// 日志等级。
|
||||
const (
|
||||
LevelInfo = "INFO"
|
||||
LevelWarn = "WARN"
|
||||
LevelError = "ERROR"
|
||||
LevelSuccess = "SUCCESS"
|
||||
)
|
||||
|
||||
// 配置里的 log_level 取值。
|
||||
const (
|
||||
FilterOff = "off"
|
||||
FilterError = "error"
|
||||
FilterWarn = "warn"
|
||||
FilterInfo = "info"
|
||||
)
|
||||
|
||||
// Tag 是所有日志行的来源标记(旧版为 service/daemon/up,Go 版统一)。
|
||||
const Tag = "luminpro"
|
||||
|
||||
// Logger 是并发安全的追加式日志器。
|
||||
type Logger struct {
|
||||
path string
|
||||
level string
|
||||
maxSizeKB int
|
||||
debug bool
|
||||
|
||||
mu sync.Mutex
|
||||
}
|
||||
|
||||
// New 创建日志器。maxSizeKB 为 0 时使用默认值 512。
|
||||
func New(path, level string, maxSizeKB int) *Logger {
|
||||
if level == "" {
|
||||
level = FilterInfo
|
||||
}
|
||||
if maxSizeKB <= 0 {
|
||||
maxSizeKB = 512
|
||||
}
|
||||
return &Logger{path: path, level: level, maxSizeKB: maxSizeKB}
|
||||
}
|
||||
|
||||
// SetLevel 更新等级过滤(配置热重载时调用)。
|
||||
func (l *Logger) SetLevel(level string) {
|
||||
if l == nil {
|
||||
return
|
||||
}
|
||||
l.mu.Lock()
|
||||
defer l.mu.Unlock()
|
||||
if level == "" {
|
||||
level = FilterInfo
|
||||
}
|
||||
l.level = level
|
||||
}
|
||||
|
||||
// SetMaxSizeKB 更新日志大小上限。
|
||||
func (l *Logger) SetMaxSizeKB(kb int) {
|
||||
if l == nil {
|
||||
return
|
||||
}
|
||||
l.mu.Lock()
|
||||
defer l.mu.Unlock()
|
||||
if kb <= 0 {
|
||||
kb = 512
|
||||
}
|
||||
l.maxSizeKB = kb
|
||||
}
|
||||
|
||||
// SetDebug 开启/关闭调试日志(对应配置 debug_mode)。
|
||||
func (l *Logger) SetDebug(on bool) {
|
||||
if l == nil {
|
||||
return
|
||||
}
|
||||
l.mu.Lock()
|
||||
defer l.mu.Unlock()
|
||||
l.debug = on
|
||||
}
|
||||
|
||||
// Info / Warn / Error / Success 写一条对应等级的日志。
|
||||
func (l *Logger) Info(msg string) { l.write(LevelInfo, msg) }
|
||||
func (l *Logger) Warn(msg string) { l.write(LevelWarn, msg) }
|
||||
func (l *Logger) Error(msg string) { l.write(LevelError, msg) }
|
||||
func (l *Logger) Success(msg string) { l.write(LevelSuccess, msg) }
|
||||
|
||||
// Debug 仅在 debug_mode 开启时写 INFO 日志。
|
||||
func (l *Logger) Debug(format string, args ...any) {
|
||||
if l == nil {
|
||||
return
|
||||
}
|
||||
l.mu.Lock()
|
||||
on := l.debug
|
||||
l.mu.Unlock()
|
||||
if !on {
|
||||
return
|
||||
}
|
||||
l.write(LevelInfo, fmt.Sprintf(format, args...))
|
||||
}
|
||||
|
||||
// allowed 判断某等级是否应写入。
|
||||
func (l *Logger) allowed(level string) bool {
|
||||
switch l.level {
|
||||
case FilterOff:
|
||||
return false
|
||||
case FilterError:
|
||||
return level == LevelError
|
||||
case FilterWarn:
|
||||
return level == LevelError || level == LevelWarn
|
||||
default:
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
func (l *Logger) write(level, msg string) {
|
||||
if l == nil || l.path == "" {
|
||||
return
|
||||
}
|
||||
l.mu.Lock()
|
||||
defer l.mu.Unlock()
|
||||
|
||||
if !l.allowed(level) {
|
||||
return
|
||||
}
|
||||
l.rotateLocked()
|
||||
|
||||
f, err := os.OpenFile(l.path, os.O_APPEND|os.O_CREATE|os.O_WRONLY, 0o644)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
defer f.Close()
|
||||
fmt.Fprintf(f, "[%s] [%s] [%s] %s\n", time.Now().Format("01-02 15:04:05"), Tag, level, msg)
|
||||
}
|
||||
|
||||
// rotateLocked 超过大小上限时重置日志文件(与旧 up.sh 行为一致)。
|
||||
func (l *Logger) rotateLocked() {
|
||||
info, err := os.Stat(l.path)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
curKB := int(info.Size() / 1024)
|
||||
if curKB < l.maxSizeKB {
|
||||
return
|
||||
}
|
||||
reset := fmt.Sprintf("[%s] [%s] [%s] 日志超限 (%dKB / %dKB),已自动重置\n",
|
||||
time.Now().Format("01-02 15:04:05"), Tag, LevelWarn, curKB, l.maxSizeKB)
|
||||
_ = os.WriteFile(l.path, []byte(reset), 0o644)
|
||||
}
|
||||
@@ -0,0 +1,145 @@
|
||||
package logging
|
||||
|
||||
import (
|
||||
"os"
|
||||
"path/filepath"
|
||||
"regexp"
|
||||
"strings"
|
||||
"sync"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func readLog(t *testing.T, path string) string {
|
||||
t.Helper()
|
||||
data, err := os.ReadFile(path)
|
||||
if err != nil {
|
||||
t.Fatalf("读取日志失败: %v", err)
|
||||
}
|
||||
return string(data)
|
||||
}
|
||||
|
||||
func TestFormatMatchesWebUIFilter(t *testing.T) {
|
||||
path := filepath.Join(t.TempDir(), "service.log")
|
||||
New(path, FilterInfo, 512).Info("触发提升")
|
||||
|
||||
got := readLog(t, path)
|
||||
// WebUI 用 includes("[INFO]") 过滤,格式必须保持
|
||||
if !strings.Contains(got, "[INFO]") || !strings.Contains(got, "[luminpro]") {
|
||||
t.Fatalf("日志格式不符合 WebUI 过滤预期: %q", got)
|
||||
}
|
||||
re := regexp.MustCompile(`^\[\d{2}-\d{2} \d{2}:\d{2}:\d{2}\] \[luminpro\] \[INFO\] 触发提升\n$`)
|
||||
if !re.MatchString(got) {
|
||||
t.Fatalf("日志格式不匹配: %q", got)
|
||||
}
|
||||
}
|
||||
|
||||
func TestLevelFiltering(t *testing.T) {
|
||||
cases := []struct {
|
||||
filter string
|
||||
want []string
|
||||
}{
|
||||
{FilterOff, nil},
|
||||
{FilterError, []string{"[ERROR]"}},
|
||||
{FilterWarn, []string{"[ERROR]", "[WARN]"}},
|
||||
{FilterInfo, []string{"[ERROR]", "[WARN]", "[INFO]", "[SUCCESS]"}},
|
||||
}
|
||||
for _, tc := range cases {
|
||||
t.Run(tc.filter, func(t *testing.T) {
|
||||
path := filepath.Join(t.TempDir(), "service.log")
|
||||
l := New(path, tc.filter, 512)
|
||||
l.Error("e")
|
||||
l.Warn("w")
|
||||
l.Info("i")
|
||||
l.Success("s")
|
||||
|
||||
data, err := os.ReadFile(path)
|
||||
if tc.want == nil {
|
||||
if err == nil {
|
||||
t.Fatalf("off 模式不应写日志: %q", string(data))
|
||||
}
|
||||
return
|
||||
}
|
||||
if err != nil {
|
||||
t.Fatalf("读取失败: %v", err)
|
||||
}
|
||||
got := string(data)
|
||||
for _, level := range []string{"[ERROR]", "[WARN]", "[INFO]", "[SUCCESS]"} {
|
||||
shouldContain := false
|
||||
for _, w := range tc.want {
|
||||
if w == level {
|
||||
shouldContain = true
|
||||
}
|
||||
}
|
||||
if strings.Contains(got, level) != shouldContain {
|
||||
t.Fatalf("filter=%s level=%s 不符合预期: %q", tc.filter, level, got)
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestRotationResetsOversizedLog(t *testing.T) {
|
||||
path := filepath.Join(t.TempDir(), "service.log")
|
||||
l := New(path, FilterInfo, 1) // 上限 1KB
|
||||
for i := 0; i < 200; i++ {
|
||||
l.Info("填充日志内容填充日志内容填充日志内容填充日志内容")
|
||||
}
|
||||
got := readLog(t, path)
|
||||
if !strings.Contains(got, "日志超限") {
|
||||
t.Fatalf("超限后未重置: %q", got[:min(len(got), 200)])
|
||||
}
|
||||
if len(got) > 2048 {
|
||||
t.Fatalf("重置后文件仍然过大: %d 字节", len(got))
|
||||
}
|
||||
}
|
||||
|
||||
func TestDebugOnlyWhenEnabled(t *testing.T) {
|
||||
path := filepath.Join(t.TempDir(), "service.log")
|
||||
l := New(path, FilterInfo, 512)
|
||||
l.Debug("事件: %s", "c")
|
||||
if _, err := os.Stat(path); err == nil {
|
||||
t.Fatal("debug 关闭时不应写日志")
|
||||
}
|
||||
l.SetDebug(true)
|
||||
l.Debug("事件: %s", "c")
|
||||
if got := readLog(t, path); !strings.Contains(got, "事件: c") {
|
||||
t.Fatalf("debug 开启后应写日志: %q", got)
|
||||
}
|
||||
}
|
||||
|
||||
func TestConcurrentWritesKeepLinesIntact(t *testing.T) {
|
||||
path := filepath.Join(t.TempDir(), "service.log")
|
||||
l := New(path, FilterInfo, 512)
|
||||
|
||||
var wg sync.WaitGroup
|
||||
for i := 0; i < 8; i++ {
|
||||
wg.Add(1)
|
||||
go func() {
|
||||
defer wg.Done()
|
||||
for j := 0; j < 50; j++ {
|
||||
l.Info("并发写入测试内容")
|
||||
}
|
||||
}()
|
||||
}
|
||||
wg.Wait()
|
||||
|
||||
for _, line := range strings.Split(strings.TrimSpace(readLog(t, path)), "\n") {
|
||||
if !strings.HasPrefix(line, "[") || !strings.HasSuffix(line, "并发写入测试内容") {
|
||||
t.Fatalf("出现被截断/交错的日志行: %q", line)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestSetLevelAndMaxSize(t *testing.T) {
|
||||
path := filepath.Join(t.TempDir(), "service.log")
|
||||
l := New(path, FilterInfo, 512)
|
||||
l.SetLevel(FilterError)
|
||||
l.Info("不该出现")
|
||||
l.Error("该出现")
|
||||
got := readLog(t, path)
|
||||
if strings.Contains(got, "不该出现") || !strings.Contains(got, "该出现") {
|
||||
t.Fatalf("SetLevel 未生效: %q", got)
|
||||
}
|
||||
l.SetMaxSizeKB(0) // 应回退默认值,不 panic
|
||||
l.Info("ok")
|
||||
}
|
||||
@@ -0,0 +1,112 @@
|
||||
// Package policy 是纯判定逻辑:休眠时段、阈值、黑名单、HDR 迟滞。
|
||||
//
|
||||
// 全部函数不接触 IO,便于 host 单测;IO 与系统调用在 daemon/system 层。
|
||||
package policy
|
||||
|
||||
import (
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
)
|
||||
|
||||
// InSleepWindow 判断当前是否处于休眠时段(格式 HHMM-HHMM,支持跨午夜)。
|
||||
//
|
||||
// 与旧 shell 版语义一致:格式非法、起止相同或为空时都视为不休眠。
|
||||
func InSleepWindow(sleepTime string, now time.Time) bool {
|
||||
start, end, ok := parseSleepWindow(sleepTime)
|
||||
if !ok || start == end {
|
||||
return false
|
||||
}
|
||||
cur := now.Hour()*100 + now.Minute()
|
||||
if start > end {
|
||||
// 跨午夜,如 2200-0700
|
||||
return cur >= start || cur < end
|
||||
}
|
||||
return cur >= start && cur < end
|
||||
}
|
||||
|
||||
func parseSleepWindow(s string) (start, end int, ok bool) {
|
||||
idx := strings.Index(s, "-")
|
||||
if idx < 0 {
|
||||
return 0, 0, false
|
||||
}
|
||||
left, right := s[:idx], s[idx+1:]
|
||||
if left == "" || right == "" {
|
||||
return 0, 0, false
|
||||
}
|
||||
a, err1 := strconv.Atoi(left)
|
||||
b, err2 := strconv.Atoi(right)
|
||||
if err1 != nil || err2 != nil {
|
||||
return 0, 0, false
|
||||
}
|
||||
return a, b, true
|
||||
}
|
||||
|
||||
// ShouldBoost 判断当前亮度是否满足提升条件:
|
||||
// 已到达前台阈值,且尚未到达目标亮度(对应 shell 的 `-ge ui_max && -lt target`)。
|
||||
func ShouldBoost(nowBri, uiMax, target int) bool {
|
||||
return nowBri >= uiMax && nowBri < target
|
||||
}
|
||||
|
||||
// BlacklistMatch 判断前台焦点是否命中黑名单。
|
||||
// 黑名单项可以是完整 Activity(pkg/Activity)或包名,两者都算命中。
|
||||
func BlacklistMatch(entries []string, focus string) bool {
|
||||
if focus == "" {
|
||||
return false
|
||||
}
|
||||
pkg := focus
|
||||
if i := strings.Index(focus, "/"); i >= 0 {
|
||||
pkg = focus[:i]
|
||||
}
|
||||
for _, entry := range entries {
|
||||
if entry == focus || entry == pkg {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
// HdrDecision 是 HDR 判定结果。
|
||||
type HdrDecision struct {
|
||||
Skip bool // 本次是否跳过提升
|
||||
Entered bool // 本次是否刚进入 HDR 休眠
|
||||
Exited bool // 本次是否刚退出 HDR 休眠
|
||||
}
|
||||
|
||||
// HdrState 是带迟滞的 HDR 休眠状态机(替代旧的 hdr.flag 文件)。
|
||||
//
|
||||
// 比率达到进入阈值后休眠,直到比率降到退出阈值及以下才恢复;
|
||||
// 比率不可读时,休眠中保持休眠,未休眠则放行。
|
||||
type HdrState struct {
|
||||
inSleep bool
|
||||
}
|
||||
|
||||
// InSleep 返回当前是否处于 HDR 休眠。
|
||||
func (h *HdrState) InSleep() bool { return h.inSleep }
|
||||
|
||||
// Evaluate 根据当前比率推进状态机。
|
||||
func (h *HdrState) Evaluate(ratio float64, haveRatio bool, enter, exit float64) HdrDecision {
|
||||
if !haveRatio {
|
||||
if h.inSleep {
|
||||
return HdrDecision{Skip: true}
|
||||
}
|
||||
return HdrDecision{}
|
||||
}
|
||||
|
||||
if h.inSleep {
|
||||
if ratio <= exit {
|
||||
h.inSleep = false
|
||||
return HdrDecision{Exited: true}
|
||||
}
|
||||
return HdrDecision{Skip: true}
|
||||
}
|
||||
|
||||
if ratio >= enter {
|
||||
h.inSleep = true
|
||||
return HdrDecision{Skip: true, Entered: true}
|
||||
}
|
||||
return HdrDecision{}
|
||||
}
|
||||
|
||||
// Reset 清除休眠状态(配置变更或服务重启时使用)。
|
||||
func (h *HdrState) Reset() { h.inSleep = false }
|
||||
@@ -0,0 +1,138 @@
|
||||
package policy
|
||||
|
||||
import (
|
||||
"testing"
|
||||
"time"
|
||||
)
|
||||
|
||||
func at(hour, min int) time.Time {
|
||||
return time.Date(2026, 9, 10, hour, min, 0, 0, time.Local)
|
||||
}
|
||||
|
||||
func TestInSleepWindow(t *testing.T) {
|
||||
cases := []struct {
|
||||
name string
|
||||
sleepTime string
|
||||
now time.Time
|
||||
want bool
|
||||
}{
|
||||
{"空配置不休眠", "", at(23, 0), false},
|
||||
{"无连字符不休眠", "2200", at(23, 0), false},
|
||||
{"跨午夜命中-深夜", "2200-0700", at(23, 0), true},
|
||||
{"跨午夜命中-凌晨", "2200-0700", at(6, 0), true},
|
||||
{"跨午夜起点含", "2200-0700", at(22, 0), true},
|
||||
{"跨午夜终点不含", "2200-0700", at(7, 0), false},
|
||||
{"跨午夜白天不休眠", "2200-0700", at(12, 0), false},
|
||||
{"同日命中", "0900-1700", at(12, 0), true},
|
||||
{"同日起点含", "0900-1700", at(9, 0), true},
|
||||
{"同日终点不含", "0900-1700", at(17, 0), false},
|
||||
{"同日之前不休眠", "0900-1700", at(8, 59), false},
|
||||
{"起止相同不休眠", "1200-1200", at(12, 0), false},
|
||||
{"非法格式不休眠", "abc-def", at(12, 0), false},
|
||||
{"单侧缺失不休眠", "2200-", at(23, 0), false},
|
||||
}
|
||||
for _, tc := range cases {
|
||||
t.Run(tc.name, func(t *testing.T) {
|
||||
if got := InSleepWindow(tc.sleepTime, tc.now); got != tc.want {
|
||||
t.Fatalf("InSleepWindow(%q, %s) = %v, 期望 %v", tc.sleepTime, tc.now.Format("15:04"), got, tc.want)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestShouldBoost(t *testing.T) {
|
||||
cases := []struct {
|
||||
now, uiMax, target int
|
||||
want bool
|
||||
}{
|
||||
{1000, 1000, 2000, true}, // 刚到阈值
|
||||
{999, 1000, 2000, false}, // 低于阈值
|
||||
{2000, 1000, 2000, false}, // 已达目标
|
||||
{2500, 1000, 2000, false}, // 超过目标
|
||||
{1500, 1000, 2000, true}, // 区间内
|
||||
{0, 0, 2000, true}, // 阈值为 0(未校准)时也满足,与旧脚本一致
|
||||
}
|
||||
for _, tc := range cases {
|
||||
if got := ShouldBoost(tc.now, tc.uiMax, tc.target); got != tc.want {
|
||||
t.Errorf("ShouldBoost(%d,%d,%d) = %v, 期望 %v", tc.now, tc.uiMax, tc.target, got, tc.want)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestBlacklistMatch(t *testing.T) {
|
||||
entries := []string{"com.a/.MainActivity", "com.b"}
|
||||
cases := []struct {
|
||||
focus string
|
||||
want bool
|
||||
}{
|
||||
{"com.a/.MainActivity", true}, // 完整 Activity 精确命中
|
||||
{"com.a/.OtherActivity", false}, // 仅包名相同不算命中(与旧 jq 表达式一致)
|
||||
{"com.b/.Main", true}, // 包名条目命中
|
||||
{"com.c/.Main", false},
|
||||
{"", false},
|
||||
{"com.b", true}, // 焦点无斜杠时按包名比较
|
||||
}
|
||||
for _, tc := range cases {
|
||||
if got := BlacklistMatch(entries, tc.focus); got != tc.want {
|
||||
t.Errorf("BlacklistMatch(%q) = %v, 期望 %v", tc.focus, got, tc.want)
|
||||
}
|
||||
}
|
||||
|
||||
// 黑名单里是完整 Activity,焦点只有包名时不应命中(与旧 jq 表达式一致)
|
||||
if BlacklistMatch([]string{"com.a/.Main"}, "com.a") {
|
||||
t.Error("焦点仅包名不应命中仅含 Activity 的黑名单项")
|
||||
}
|
||||
if BlacklistMatch(nil, "com.a/.Main") {
|
||||
t.Error("空黑名单不应命中")
|
||||
}
|
||||
}
|
||||
|
||||
func TestHdrStateMachine(t *testing.T) {
|
||||
var h HdrState
|
||||
const enter, exit = 1.15, 1.05
|
||||
|
||||
// 未达进入阈值:放行
|
||||
if d := h.Evaluate(1.10, true, enter, exit); d.Skip || d.Entered || d.Exited {
|
||||
t.Fatalf("1.10 应放行: %+v", d)
|
||||
}
|
||||
// 达到进入阈值:进入休眠
|
||||
if d := h.Evaluate(1.15, true, enter, exit); !d.Skip || !d.Entered || !h.InSleep() {
|
||||
t.Fatalf("1.15 应进入休眠: %+v", d)
|
||||
}
|
||||
// 迟滞区间内:保持休眠
|
||||
if d := h.Evaluate(1.10, true, enter, exit); !d.Skip || d.Exited {
|
||||
t.Fatalf("1.10 应保持休眠: %+v", d)
|
||||
}
|
||||
// 高于退出阈值:仍休眠
|
||||
if d := h.Evaluate(1.06, true, enter, exit); !d.Skip {
|
||||
t.Fatalf("1.06 应保持休眠: %+v", d)
|
||||
}
|
||||
// 降到退出阈值:解除休眠且本次放行
|
||||
if d := h.Evaluate(1.05, true, enter, exit); !d.Exited || d.Skip || h.InSleep() {
|
||||
t.Fatalf("1.05 应解除休眠: %+v", d)
|
||||
}
|
||||
// 解除后可再次进入
|
||||
if d := h.Evaluate(1.30, true, enter, exit); !d.Entered {
|
||||
t.Fatalf("1.30 应再次进入休眠: %+v", d)
|
||||
}
|
||||
}
|
||||
|
||||
func TestHdrUnreadableRatio(t *testing.T) {
|
||||
var h HdrState
|
||||
const enter, exit = 1.15, 1.05
|
||||
|
||||
// 未休眠且比率不可读:放行
|
||||
if d := h.Evaluate(0, false, enter, exit); d.Skip {
|
||||
t.Fatalf("未休眠且不可读应放行: %+v", d)
|
||||
}
|
||||
// 进入休眠后比率不可读:保持休眠
|
||||
h.Evaluate(1.20, true, enter, exit)
|
||||
if d := h.Evaluate(0, false, enter, exit); !d.Skip || !h.InSleep() {
|
||||
t.Fatalf("休眠中且不可读应保持休眠: %+v", d)
|
||||
}
|
||||
// Reset 后恢复放行
|
||||
h.Reset()
|
||||
if h.InSleep() {
|
||||
t.Fatal("Reset 后不应处于休眠")
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,123 @@
|
||||
// Package system 封装对 Android 系统命令的调用。
|
||||
//
|
||||
// 全部通过接口暴露,daemon 只依赖接口,测试时注入假实现。
|
||||
// 命令失败时按「无数据」处理,与旧 shell 版 `2>/dev/null || default` 语义一致。
|
||||
package system
|
||||
|
||||
import (
|
||||
"context"
|
||||
"os/exec"
|
||||
"regexp"
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
)
|
||||
|
||||
// Runner 执行命令并返回标准输出,便于测试注入。
|
||||
type Runner interface {
|
||||
Output(name string, args ...string) (string, error)
|
||||
}
|
||||
|
||||
// ExecRunner 用 os/exec 执行命令,带超时避免 dumpsys 卡死。
|
||||
type ExecRunner struct {
|
||||
Timeout time.Duration
|
||||
}
|
||||
|
||||
// Output 执行命令。
|
||||
func (r ExecRunner) Output(name string, args ...string) (string, error) {
|
||||
timeout := r.Timeout
|
||||
if timeout <= 0 {
|
||||
timeout = 5 * time.Second
|
||||
}
|
||||
ctx, cancel := context.WithTimeout(context.Background(), timeout)
|
||||
defer cancel()
|
||||
out, err := exec.CommandContext(ctx, name, args...).Output()
|
||||
return string(out), err
|
||||
}
|
||||
|
||||
// AutoBrightness 判断系统自动亮度是否开启。
|
||||
type AutoBrightness struct{ Runner Runner }
|
||||
|
||||
// Enabled 对应 `settings get system screen_brightness_mode`,仅 "1" 视为开启。
|
||||
func (a AutoBrightness) Enabled() bool {
|
||||
if a.Runner == nil {
|
||||
return false
|
||||
}
|
||||
out, err := a.Runner.Output("settings", "get", "system", "screen_brightness_mode")
|
||||
if err != nil {
|
||||
return false
|
||||
}
|
||||
return strings.TrimSpace(out) == "1"
|
||||
}
|
||||
|
||||
// Focus 获取当前前台焦点(pkg/Activity)。
|
||||
type Focus struct{ Runner Runner }
|
||||
|
||||
// CurrentFocus 解析 `dumpsys window` 中的 mCurrentFocus 行。
|
||||
// 无法解析时返回空串(视为无前台应用,不命中黑名单)。
|
||||
func (f Focus) CurrentFocus() string {
|
||||
if f.Runner == nil {
|
||||
return ""
|
||||
}
|
||||
out, err := f.Runner.Output("dumpsys", "window")
|
||||
if err != nil {
|
||||
return ""
|
||||
}
|
||||
for _, line := range strings.Split(out, "\n") {
|
||||
if strings.Contains(line, "mCurrentFocus") {
|
||||
return parseFocusLine(line)
|
||||
}
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
// parseFocusLine 等价于旧脚本的 `sed 's/.*u[0-9][0-9]* //' | sed 's/}.*//'`:
|
||||
// 取最后一个 `u<pid> ` 之后的内容,并截断到第一个 `}`。
|
||||
func parseFocusLine(line string) string {
|
||||
start := -1
|
||||
for i := 0; i < len(line); i++ {
|
||||
if line[i] != 'u' {
|
||||
continue
|
||||
}
|
||||
j := i + 1
|
||||
for j < len(line) && line[j] >= '0' && line[j] <= '9' {
|
||||
j++
|
||||
}
|
||||
if j > i+1 && j < len(line) && line[j] == ' ' {
|
||||
start = j + 1 // 记录最后一个匹配(sed 的 .* 是贪婪的)
|
||||
}
|
||||
}
|
||||
if start < 0 {
|
||||
return ""
|
||||
}
|
||||
s := line[start:]
|
||||
if k := strings.Index(s, "}"); k >= 0 {
|
||||
s = s[:k]
|
||||
}
|
||||
return strings.TrimSpace(s)
|
||||
}
|
||||
|
||||
// HdrRatio 读取 HDR/SDR 比率。
|
||||
type HdrRatio struct{ Runner Runner }
|
||||
|
||||
var hdrRatioRe = regexp.MustCompile(`hdrSdrRatio ([0-9.]+)`)
|
||||
|
||||
// Ratio 解析 `dumpsys display` 中第一处 hdrSdrRatio。第二个返回值表示是否读到。
|
||||
func (h HdrRatio) Ratio() (float64, bool) {
|
||||
if h.Runner == nil {
|
||||
return 0, false
|
||||
}
|
||||
out, err := h.Runner.Output("dumpsys", "display")
|
||||
if err != nil {
|
||||
return 0, false
|
||||
}
|
||||
m := hdrRatioRe.FindStringSubmatch(out)
|
||||
if m == nil {
|
||||
return 0, false
|
||||
}
|
||||
v, err := strconv.ParseFloat(m[1], 64)
|
||||
if err != nil {
|
||||
return 0, false
|
||||
}
|
||||
return v, true
|
||||
}
|
||||
@@ -0,0 +1,96 @@
|
||||
package system
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"testing"
|
||||
)
|
||||
|
||||
type fakeRunner struct {
|
||||
outputs map[string]string
|
||||
err error
|
||||
}
|
||||
|
||||
func (f fakeRunner) Output(name string, args ...string) (string, error) {
|
||||
if f.err != nil {
|
||||
return "", f.err
|
||||
}
|
||||
return f.outputs[name+" "+joinArgs(args)], nil
|
||||
}
|
||||
|
||||
func joinArgs(args []string) string {
|
||||
out := ""
|
||||
for i, a := range args {
|
||||
if i > 0 {
|
||||
out += " "
|
||||
}
|
||||
out += a
|
||||
}
|
||||
return out
|
||||
}
|
||||
|
||||
func TestAutoBrightness(t *testing.T) {
|
||||
on := AutoBrightness{Runner: fakeRunner{outputs: map[string]string{
|
||||
"settings get system screen_brightness_mode": "1\n",
|
||||
}}}
|
||||
if !on.Enabled() {
|
||||
t.Fatal("mode=1 应判定为开启")
|
||||
}
|
||||
off := AutoBrightness{Runner: fakeRunner{outputs: map[string]string{
|
||||
"settings get system screen_brightness_mode": "0\n",
|
||||
}}}
|
||||
if off.Enabled() {
|
||||
t.Fatal("mode=0 应判定为关闭")
|
||||
}
|
||||
fail := AutoBrightness{Runner: fakeRunner{err: errors.New("boom")}}
|
||||
if fail.Enabled() {
|
||||
t.Fatal("命令失败应按关闭处理")
|
||||
}
|
||||
}
|
||||
|
||||
func TestParseFocusLine(t *testing.T) {
|
||||
cases := []struct {
|
||||
line string
|
||||
want string
|
||||
}{
|
||||
{" mCurrentFocus=Window{a1b2c3 u0 com.example/.MainActivity}", "com.example/.MainActivity"},
|
||||
{" mCurrentFocus=Window{abc u12345 com.foo.bar/.BazActivity}", "com.foo.bar/.BazActivity"},
|
||||
{"mCurrentFocus=Window{abc u0 com.a/.B} dumpsys 附加文本", "com.a/.B"},
|
||||
{"mCurrentFocus=null", ""},
|
||||
{"", ""},
|
||||
{"mCurrentFocus=Window{abc u0 com.a/.B", "com.a/.B"}, // 缺右花括号
|
||||
}
|
||||
for _, tc := range cases {
|
||||
if got := parseFocusLine(tc.line); got != tc.want {
|
||||
t.Errorf("parseFocusLine(%q) = %q, 期望 %q", tc.line, got, tc.want)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestFocusPicksFirstMatchingLine(t *testing.T) {
|
||||
f := Focus{Runner: fakeRunner{outputs: map[string]string{
|
||||
"dumpsys window": " mCurrentFocus=Window{x u0 com.first/.Main}\n" +
|
||||
" mFocusedApp=Window{y u0 com.second/.Main}\n",
|
||||
}}}
|
||||
if got := f.CurrentFocus(); got != "com.first/.Main" {
|
||||
t.Fatalf("应取第一处 mCurrentFocus: %q", got)
|
||||
}
|
||||
}
|
||||
|
||||
func TestHdrRatio(t *testing.T) {
|
||||
h := HdrRatio{Runner: fakeRunner{outputs: map[string]string{
|
||||
"dumpsys display": " some line\n hdrSdrRatio 1.25 extra\n hdrSdrRatio 9.99\n",
|
||||
}}}
|
||||
v, ok := h.Ratio()
|
||||
if !ok || v != 1.25 {
|
||||
t.Fatalf("应取第一处比率 1.25, 实际 %v %v", v, ok)
|
||||
}
|
||||
|
||||
none := HdrRatio{Runner: fakeRunner{outputs: map[string]string{"dumpsys display": "no ratio here"}}}
|
||||
if _, ok := none.Ratio(); ok {
|
||||
t.Fatal("无比率时应返回 false")
|
||||
}
|
||||
fail := HdrRatio{Runner: fakeRunner{err: errors.New("boom")}}
|
||||
if _, ok := fail.Ratio(); ok {
|
||||
t.Fatal("命令失败时应返回 false")
|
||||
}
|
||||
}
|
||||
-183
@@ -1,183 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="zh-CN">
|
||||
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no" />
|
||||
<title>LuminPro</title>
|
||||
<link rel="stylesheet" type="text/css" href="/internal/insets.css" />
|
||||
<link rel="stylesheet" href="/src/style.css" />
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div id="app">
|
||||
<!-- 顶部头 -->
|
||||
<header class="app-header">
|
||||
<div class="header-content">
|
||||
<div class="header-icon"><i data-lucide="sun"></i></div>
|
||||
<div class="header-text">
|
||||
<h1>LuminPro</h1>
|
||||
<p class="header-subtitle" id="module-version">日用屏幕亮度强化</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="header-status" id="module-status">
|
||||
<span class="status-dot"></span>
|
||||
<span class="status-text">运行中</span>
|
||||
</div>
|
||||
</header>
|
||||
|
||||
<!-- 配置卡片 -->
|
||||
<section class="card" id="config-section">
|
||||
<div class="card-header">
|
||||
<span class="card-icon"><i data-lucide="settings"></i></span>
|
||||
<h2>亮度配置</h2>
|
||||
</div>
|
||||
|
||||
<!-- 分类: 亮度调节 -->
|
||||
<div class="config-group">
|
||||
<h3 class="group-title">亮度调节</h3>
|
||||
<div class="config-item">
|
||||
<div class="config-label">
|
||||
<span class="config-name">前台最大亮度</span>
|
||||
<span class="config-desc">触发亮度提升的阈值</span>
|
||||
</div>
|
||||
<div class="config-value">
|
||||
<input type="number" id="input-ui-max-bri" class="config-input" min="0" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="config-item">
|
||||
<div class="config-label">
|
||||
<span class="config-name">峰值最大亮度</span>
|
||||
<span class="config-desc">亮度提升的目标值</span>
|
||||
</div>
|
||||
<div class="config-value">
|
||||
<input type="number" id="input-max-bri" class="config-input" min="0" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="config-item">
|
||||
<div class="config-label">
|
||||
<span class="config-name">亮度提升步数</span>
|
||||
<span class="config-desc">约 0.02 秒 / 步</span>
|
||||
</div>
|
||||
<div class="config-value">
|
||||
<input type="number" id="input-steps-num" class="config-input" min="1" max="500" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 分类: 执行策略 -->
|
||||
<div class="config-group">
|
||||
<h3 class="group-title">执行策略</h3>
|
||||
<div class="config-item">
|
||||
<div class="config-label">
|
||||
<span class="config-name">自动亮度时休眠</span>
|
||||
<span class="config-desc">开启自动亮度时不提升</span>
|
||||
</div>
|
||||
<div class="config-value">
|
||||
<label class="switch">
|
||||
<input type="checkbox" id="input-auto-bri-sleep">
|
||||
<span class="slider"></span>
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
<div class="config-item">
|
||||
<div class="config-label">
|
||||
<span class="config-name">定时休眠</span>
|
||||
<span class="config-desc">设定时段内不提升亮度</span>
|
||||
</div>
|
||||
<div class="config-value">
|
||||
<label class="switch">
|
||||
<input type="checkbox" id="input-sleep-mode">
|
||||
<span class="slider"></span>
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
<div class="config-item-expand" id="sleep-time-expand">
|
||||
<div class="custom-time-picker">
|
||||
<div class="time-unit">
|
||||
<input type="number" id="input-sleep-start-h" class="time-input" min="0" max="23" placeholder="00" />
|
||||
<span>:</span>
|
||||
<input type="number" id="input-sleep-start-m" class="time-input" min="0" max="59" placeholder="00" />
|
||||
</div>
|
||||
<span class="time-sep">至</span>
|
||||
<div class="time-unit">
|
||||
<input type="number" id="input-sleep-end-h" class="time-input" min="0" max="23" placeholder="00" />
|
||||
<span>:</span>
|
||||
<input type="number" id="input-sleep-end-m" class="time-input" min="0" max="59" placeholder="00" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 分类: 系统管理 -->
|
||||
<div class="config-group">
|
||||
<h3 class="group-title">系统管理</h3>
|
||||
<div class="config-item">
|
||||
<div class="config-label">
|
||||
<span class="config-name">日志大小限制</span>
|
||||
<span class="config-desc">单位: KB</span>
|
||||
</div>
|
||||
<div class="config-value">
|
||||
<input type="number" id="input-log-max-size" class="config-input" min="1" max="10240" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="card-actions">
|
||||
<button class="btn btn-outline" id="btn-reset">
|
||||
恢复默认
|
||||
</button>
|
||||
<button class="btn btn-primary" id="btn-save">
|
||||
<span class="btn-icon"><i data-lucide="save"></i></span> 保存配置
|
||||
</button>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<!-- 实时状态 -->
|
||||
<section class="card" id="status-section">
|
||||
<div class="card-header">
|
||||
<span class="card-icon"><i data-lucide="activity"></i></span>
|
||||
<h2>实时状态</h2>
|
||||
<div class="header-actions">
|
||||
<button class="btn-text-s" id="btn-toggle-service">暂停</button>
|
||||
<button class="btn-text-s" id="btn-restart-service">重启</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="status-grid">
|
||||
<div class="status-item">
|
||||
<span class="status-label">当前亮度</span>
|
||||
<span class="status-value" id="status-current-bri">—</span>
|
||||
</div>
|
||||
<div class="status-item">
|
||||
<span class="status-label">系统最大亮度</span>
|
||||
<span class="status-value" id="status-sys-max-bri">—</span>
|
||||
</div>
|
||||
<div class="status-item">
|
||||
<span class="status-label">inotifyd PID</span>
|
||||
<span class="status-value" id="status-inotifyd-pid">—</span>
|
||||
</div>
|
||||
<div class="status-item">
|
||||
<span class="status-label">休眠状态</span>
|
||||
<span class="status-value" id="status-sleep">—</span>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<!-- 日志 -->
|
||||
<section class="card" id="log-section">
|
||||
<div class="card-header">
|
||||
<span class="card-icon"><i data-lucide="file-text"></i></span>
|
||||
<h2>运行日志</h2>
|
||||
</div>
|
||||
<pre class="log-output" id="log-output">加载中...</pre>
|
||||
</section>
|
||||
|
||||
<!-- Toast -->
|
||||
<div class="toast" id="toast"></div>
|
||||
</div>
|
||||
|
||||
<script type="module" src="/src/main.js"></script>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
+3
-3
@@ -1,7 +1,7 @@
|
||||
id=LuminPro
|
||||
name=LuminPro丨日用屏幕亮度强化
|
||||
version=V2.2
|
||||
versionCode=2202
|
||||
version=V2.5.0-beta.4
|
||||
versionCode=2050054
|
||||
author=酷安@Yule
|
||||
description=本模块旨在让你的 Android 设备随时可以使用高亮度显示屏幕内容。无论设备当前亮度如何,只要满足设定的前台触发亮度条件,模块便会自动且平滑地提升屏幕亮度至硬件支持的峰值状态,确保你在强光室外也能获得清晰的显示效果
|
||||
updateJson=https://share.yule.ink/magisk/mod/luminpro/update.json
|
||||
updateJson=https://raw.githubusercontent.com/YuleBest/LuminPro/main/update.json
|
||||
Generated
-881
@@ -1,881 +0,0 @@
|
||||
{
|
||||
"name": "luminpro-webui",
|
||||
"version": "2.1.0",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "luminpro-webui",
|
||||
"version": "2.1.0",
|
||||
"devDependencies": {
|
||||
"kernelsu": "^3.0.2",
|
||||
"vite": "^8.0.3"
|
||||
}
|
||||
},
|
||||
"node_modules/@emnapi/core": {
|
||||
"version": "1.9.2",
|
||||
"resolved": "https://registry.npmmirror.com/@emnapi/core/-/core-1.9.2.tgz",
|
||||
"integrity": "sha512-UC+ZhH3XtczQYfOlu3lNEkdW/p4dsJ1r/bP7H8+rhao3TTTMO1ATq/4DdIi23XuGoFY+Cz0JmCbdVl0hz9jZcA==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"optional": true,
|
||||
"peer": true,
|
||||
"dependencies": {
|
||||
"@emnapi/wasi-threads": "1.2.1",
|
||||
"tslib": "^2.4.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@emnapi/runtime": {
|
||||
"version": "1.9.2",
|
||||
"resolved": "https://registry.npmmirror.com/@emnapi/runtime/-/runtime-1.9.2.tgz",
|
||||
"integrity": "sha512-3U4+MIWHImeyu1wnmVygh5WlgfYDtyf0k8AbLhMFxOipihf6nrWC4syIm/SwEeec0mNSafiiNnMJwbza/Is6Lw==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"optional": true,
|
||||
"peer": true,
|
||||
"dependencies": {
|
||||
"tslib": "^2.4.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@emnapi/wasi-threads": {
|
||||
"version": "1.2.1",
|
||||
"resolved": "https://registry.npmmirror.com/@emnapi/wasi-threads/-/wasi-threads-1.2.1.tgz",
|
||||
"integrity": "sha512-uTII7OYF+/Mes/MrcIOYp5yOtSMLBWSIoLPpcgwipoiKbli6k322tcoFsxoIIxPDqW01SQGAgko4EzZi2BNv2w==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"optional": true,
|
||||
"peer": true,
|
||||
"dependencies": {
|
||||
"tslib": "^2.4.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@napi-rs/wasm-runtime": {
|
||||
"version": "1.1.2",
|
||||
"resolved": "https://registry.npmmirror.com/@napi-rs/wasm-runtime/-/wasm-runtime-1.1.2.tgz",
|
||||
"integrity": "sha512-sNXv5oLJ7ob93xkZ1XnxisYhGYXfaG9f65/ZgYuAu3qt7b3NadcOEhLvx28hv31PgX8SZJRYrAIPQilQmFpLVw==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"optional": true,
|
||||
"dependencies": {
|
||||
"@tybys/wasm-util": "^0.10.1"
|
||||
},
|
||||
"funding": {
|
||||
"type": "github",
|
||||
"url": "https://github.com/sponsors/Brooooooklyn"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@emnapi/core": "^1.7.1",
|
||||
"@emnapi/runtime": "^1.7.1"
|
||||
}
|
||||
},
|
||||
"node_modules/@oxc-project/types": {
|
||||
"version": "0.122.0",
|
||||
"resolved": "https://registry.npmmirror.com/@oxc-project/types/-/types-0.122.0.tgz",
|
||||
"integrity": "sha512-oLAl5kBpV4w69UtFZ9xqcmTi+GENWOcPF7FCrczTiBbmC0ibXxCwyvZGbO39rCVEuLGAZM84DH0pUIyyv/YJzA==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"funding": {
|
||||
"url": "https://github.com/sponsors/Boshen"
|
||||
}
|
||||
},
|
||||
"node_modules/@rolldown/binding-android-arm64": {
|
||||
"version": "1.0.0-rc.12",
|
||||
"resolved": "https://registry.npmmirror.com/@rolldown/binding-android-arm64/-/binding-android-arm64-1.0.0-rc.12.tgz",
|
||||
"integrity": "sha512-pv1y2Fv0JybcykuiiD3qBOBdz6RteYojRFY1d+b95WVuzx211CRh+ytI/+9iVyWQ6koTh5dawe4S/yRfOFjgaA==",
|
||||
"cpu": [
|
||||
"arm64"
|
||||
],
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"optional": true,
|
||||
"os": [
|
||||
"android"
|
||||
],
|
||||
"engines": {
|
||||
"node": "^20.19.0 || >=22.12.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@rolldown/binding-darwin-arm64": {
|
||||
"version": "1.0.0-rc.12",
|
||||
"resolved": "https://registry.npmmirror.com/@rolldown/binding-darwin-arm64/-/binding-darwin-arm64-1.0.0-rc.12.tgz",
|
||||
"integrity": "sha512-cFYr6zTG/3PXXF3pUO+umXxt1wkRK/0AYT8lDwuqvRC+LuKYWSAQAQZjCWDQpAH172ZV6ieYrNnFzVVcnSflAg==",
|
||||
"cpu": [
|
||||
"arm64"
|
||||
],
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"optional": true,
|
||||
"os": [
|
||||
"darwin"
|
||||
],
|
||||
"engines": {
|
||||
"node": "^20.19.0 || >=22.12.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@rolldown/binding-darwin-x64": {
|
||||
"version": "1.0.0-rc.12",
|
||||
"resolved": "https://registry.npmmirror.com/@rolldown/binding-darwin-x64/-/binding-darwin-x64-1.0.0-rc.12.tgz",
|
||||
"integrity": "sha512-ZCsYknnHzeXYps0lGBz8JrF37GpE9bFVefrlmDrAQhOEi4IOIlcoU1+FwHEtyXGx2VkYAvhu7dyBf75EJQffBw==",
|
||||
"cpu": [
|
||||
"x64"
|
||||
],
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"optional": true,
|
||||
"os": [
|
||||
"darwin"
|
||||
],
|
||||
"engines": {
|
||||
"node": "^20.19.0 || >=22.12.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@rolldown/binding-freebsd-x64": {
|
||||
"version": "1.0.0-rc.12",
|
||||
"resolved": "https://registry.npmmirror.com/@rolldown/binding-freebsd-x64/-/binding-freebsd-x64-1.0.0-rc.12.tgz",
|
||||
"integrity": "sha512-dMLeprcVsyJsKolRXyoTH3NL6qtsT0Y2xeuEA8WQJquWFXkEC4bcu1rLZZSnZRMtAqwtrF/Ib9Ddtpa/Gkge9Q==",
|
||||
"cpu": [
|
||||
"x64"
|
||||
],
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"optional": true,
|
||||
"os": [
|
||||
"freebsd"
|
||||
],
|
||||
"engines": {
|
||||
"node": "^20.19.0 || >=22.12.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@rolldown/binding-linux-arm-gnueabihf": {
|
||||
"version": "1.0.0-rc.12",
|
||||
"resolved": "https://registry.npmmirror.com/@rolldown/binding-linux-arm-gnueabihf/-/binding-linux-arm-gnueabihf-1.0.0-rc.12.tgz",
|
||||
"integrity": "sha512-YqWjAgGC/9M1lz3GR1r1rP79nMgo3mQiiA+Hfo+pvKFK1fAJ1bCi0ZQVh8noOqNacuY1qIcfyVfP6HoyBRZ85Q==",
|
||||
"cpu": [
|
||||
"arm"
|
||||
],
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"optional": true,
|
||||
"os": [
|
||||
"linux"
|
||||
],
|
||||
"engines": {
|
||||
"node": "^20.19.0 || >=22.12.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@rolldown/binding-linux-arm64-gnu": {
|
||||
"version": "1.0.0-rc.12",
|
||||
"resolved": "https://registry.npmmirror.com/@rolldown/binding-linux-arm64-gnu/-/binding-linux-arm64-gnu-1.0.0-rc.12.tgz",
|
||||
"integrity": "sha512-/I5AS4cIroLpslsmzXfwbe5OmWvSsrFuEw3mwvbQ1kDxJ822hFHIx+vsN/TAzNVyepI/j/GSzrtCIwQPeKCLIg==",
|
||||
"cpu": [
|
||||
"arm64"
|
||||
],
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"optional": true,
|
||||
"os": [
|
||||
"linux"
|
||||
],
|
||||
"engines": {
|
||||
"node": "^20.19.0 || >=22.12.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@rolldown/binding-linux-arm64-musl": {
|
||||
"version": "1.0.0-rc.12",
|
||||
"resolved": "https://registry.npmmirror.com/@rolldown/binding-linux-arm64-musl/-/binding-linux-arm64-musl-1.0.0-rc.12.tgz",
|
||||
"integrity": "sha512-V6/wZztnBqlx5hJQqNWwFdxIKN0m38p8Jas+VoSfgH54HSj9tKTt1dZvG6JRHcjh6D7TvrJPWFGaY9UBVOaWPw==",
|
||||
"cpu": [
|
||||
"arm64"
|
||||
],
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"optional": true,
|
||||
"os": [
|
||||
"linux"
|
||||
],
|
||||
"engines": {
|
||||
"node": "^20.19.0 || >=22.12.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@rolldown/binding-linux-ppc64-gnu": {
|
||||
"version": "1.0.0-rc.12",
|
||||
"resolved": "https://registry.npmmirror.com/@rolldown/binding-linux-ppc64-gnu/-/binding-linux-ppc64-gnu-1.0.0-rc.12.tgz",
|
||||
"integrity": "sha512-AP3E9BpcUYliZCxa3w5Kwj9OtEVDYK6sVoUzy4vTOJsjPOgdaJZKFmN4oOlX0Wp0RPV2ETfmIra9x1xuayFB7g==",
|
||||
"cpu": [
|
||||
"ppc64"
|
||||
],
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"optional": true,
|
||||
"os": [
|
||||
"linux"
|
||||
],
|
||||
"engines": {
|
||||
"node": "^20.19.0 || >=22.12.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@rolldown/binding-linux-s390x-gnu": {
|
||||
"version": "1.0.0-rc.12",
|
||||
"resolved": "https://registry.npmmirror.com/@rolldown/binding-linux-s390x-gnu/-/binding-linux-s390x-gnu-1.0.0-rc.12.tgz",
|
||||
"integrity": "sha512-nWwpvUSPkoFmZo0kQazZYOrT7J5DGOJ/+QHHzjvNlooDZED8oH82Yg67HvehPPLAg5fUff7TfWFHQS8IV1n3og==",
|
||||
"cpu": [
|
||||
"s390x"
|
||||
],
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"optional": true,
|
||||
"os": [
|
||||
"linux"
|
||||
],
|
||||
"engines": {
|
||||
"node": "^20.19.0 || >=22.12.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@rolldown/binding-linux-x64-gnu": {
|
||||
"version": "1.0.0-rc.12",
|
||||
"resolved": "https://registry.npmmirror.com/@rolldown/binding-linux-x64-gnu/-/binding-linux-x64-gnu-1.0.0-rc.12.tgz",
|
||||
"integrity": "sha512-RNrafz5bcwRy+O9e6P8Z/OCAJW/A+qtBczIqVYwTs14pf4iV1/+eKEjdOUta93q2TsT/FI0XYDP3TCky38LMAg==",
|
||||
"cpu": [
|
||||
"x64"
|
||||
],
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"optional": true,
|
||||
"os": [
|
||||
"linux"
|
||||
],
|
||||
"engines": {
|
||||
"node": "^20.19.0 || >=22.12.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@rolldown/binding-linux-x64-musl": {
|
||||
"version": "1.0.0-rc.12",
|
||||
"resolved": "https://registry.npmmirror.com/@rolldown/binding-linux-x64-musl/-/binding-linux-x64-musl-1.0.0-rc.12.tgz",
|
||||
"integrity": "sha512-Jpw/0iwoKWx3LJ2rc1yjFrj+T7iHZn2JDg1Yny1ma0luviFS4mhAIcd1LFNxK3EYu3DHWCps0ydXQ5i/rrJ2ig==",
|
||||
"cpu": [
|
||||
"x64"
|
||||
],
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"optional": true,
|
||||
"os": [
|
||||
"linux"
|
||||
],
|
||||
"engines": {
|
||||
"node": "^20.19.0 || >=22.12.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@rolldown/binding-openharmony-arm64": {
|
||||
"version": "1.0.0-rc.12",
|
||||
"resolved": "https://registry.npmmirror.com/@rolldown/binding-openharmony-arm64/-/binding-openharmony-arm64-1.0.0-rc.12.tgz",
|
||||
"integrity": "sha512-vRugONE4yMfVn0+7lUKdKvN4D5YusEiPilaoO2sgUWpCvrncvWgPMzK00ZFFJuiPgLwgFNP5eSiUlv2tfc+lpA==",
|
||||
"cpu": [
|
||||
"arm64"
|
||||
],
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"optional": true,
|
||||
"os": [
|
||||
"openharmony"
|
||||
],
|
||||
"engines": {
|
||||
"node": "^20.19.0 || >=22.12.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@rolldown/binding-wasm32-wasi": {
|
||||
"version": "1.0.0-rc.12",
|
||||
"resolved": "https://registry.npmmirror.com/@rolldown/binding-wasm32-wasi/-/binding-wasm32-wasi-1.0.0-rc.12.tgz",
|
||||
"integrity": "sha512-ykGiLr/6kkiHc0XnBfmFJuCjr5ZYKKofkx+chJWDjitX+KsJuAmrzWhwyOMSHzPhzOHOy7u9HlFoa5MoAOJ/Zg==",
|
||||
"cpu": [
|
||||
"wasm32"
|
||||
],
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"optional": true,
|
||||
"dependencies": {
|
||||
"@napi-rs/wasm-runtime": "^1.1.1"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=14.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@rolldown/binding-win32-arm64-msvc": {
|
||||
"version": "1.0.0-rc.12",
|
||||
"resolved": "https://registry.npmmirror.com/@rolldown/binding-win32-arm64-msvc/-/binding-win32-arm64-msvc-1.0.0-rc.12.tgz",
|
||||
"integrity": "sha512-5eOND4duWkwx1AzCxadcOrNeighiLwMInEADT0YM7xeEOOFcovWZCq8dadXgcRHSf3Ulh1kFo/qvzoFiCLOL1Q==",
|
||||
"cpu": [
|
||||
"arm64"
|
||||
],
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"optional": true,
|
||||
"os": [
|
||||
"win32"
|
||||
],
|
||||
"engines": {
|
||||
"node": "^20.19.0 || >=22.12.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@rolldown/binding-win32-x64-msvc": {
|
||||
"version": "1.0.0-rc.12",
|
||||
"resolved": "https://registry.npmmirror.com/@rolldown/binding-win32-x64-msvc/-/binding-win32-x64-msvc-1.0.0-rc.12.tgz",
|
||||
"integrity": "sha512-PyqoipaswDLAZtot351MLhrlrh6lcZPo2LSYE+VDxbVk24LVKAGOuE4hb8xZQmrPAuEtTZW8E6D2zc5EUZX4Lw==",
|
||||
"cpu": [
|
||||
"x64"
|
||||
],
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"optional": true,
|
||||
"os": [
|
||||
"win32"
|
||||
],
|
||||
"engines": {
|
||||
"node": "^20.19.0 || >=22.12.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@rolldown/pluginutils": {
|
||||
"version": "1.0.0-rc.12",
|
||||
"resolved": "https://registry.npmmirror.com/@rolldown/pluginutils/-/pluginutils-1.0.0-rc.12.tgz",
|
||||
"integrity": "sha512-HHMwmarRKvoFsJorqYlFeFRzXZqCt2ETQlEDOb9aqssrnVBB1/+xgTGtuTrIk5vzLNX1MjMtTf7W9z3tsSbrxw==",
|
||||
"dev": true,
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/@tybys/wasm-util": {
|
||||
"version": "0.10.1",
|
||||
"resolved": "https://registry.npmmirror.com/@tybys/wasm-util/-/wasm-util-0.10.1.tgz",
|
||||
"integrity": "sha512-9tTaPJLSiejZKx+Bmog4uSubteqTvFrVrURwkmHixBo0G4seD0zUxp98E1DzUBJxLQ3NPwXrGKDiVjwx/DpPsg==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"optional": true,
|
||||
"dependencies": {
|
||||
"tslib": "^2.4.0"
|
||||
}
|
||||
},
|
||||
"node_modules/detect-libc": {
|
||||
"version": "2.1.2",
|
||||
"resolved": "https://registry.npmmirror.com/detect-libc/-/detect-libc-2.1.2.tgz",
|
||||
"integrity": "sha512-Btj2BOOO83o3WyH59e8MgXsxEQVcarkUOpEYrubB0urwnN10yQ364rsiByU11nZlqWYZm05i/of7io4mzihBtQ==",
|
||||
"dev": true,
|
||||
"license": "Apache-2.0",
|
||||
"engines": {
|
||||
"node": ">=8"
|
||||
}
|
||||
},
|
||||
"node_modules/fdir": {
|
||||
"version": "6.5.0",
|
||||
"resolved": "https://registry.npmmirror.com/fdir/-/fdir-6.5.0.tgz",
|
||||
"integrity": "sha512-tIbYtZbucOs0BRGqPJkshJUYdL+SDH7dVM8gjy+ERp3WAUjLEFJE+02kanyHtwjWOnwrKYBiwAmM0p4kLJAnXg==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">=12.0.0"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"picomatch": "^3 || ^4"
|
||||
},
|
||||
"peerDependenciesMeta": {
|
||||
"picomatch": {
|
||||
"optional": true
|
||||
}
|
||||
}
|
||||
},
|
||||
"node_modules/fsevents": {
|
||||
"version": "2.3.3",
|
||||
"resolved": "https://registry.npmmirror.com/fsevents/-/fsevents-2.3.3.tgz",
|
||||
"integrity": "sha512-5xoDfX+fL7faATnagmWPpbFtwh/R77WmMMqqHGS65C3vvB0YHrgF+B1YmZ3441tMj5n63k0212XNoJwzlhffQw==",
|
||||
"dev": true,
|
||||
"hasInstallScript": true,
|
||||
"license": "MIT",
|
||||
"optional": true,
|
||||
"os": [
|
||||
"darwin"
|
||||
],
|
||||
"engines": {
|
||||
"node": "^8.16.0 || ^10.6.0 || >=11.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/kernelsu": {
|
||||
"version": "3.0.2",
|
||||
"resolved": "https://registry.npmmirror.com/kernelsu/-/kernelsu-3.0.2.tgz",
|
||||
"integrity": "sha512-3MTGgIbl3TWCzqnJP6Fun9tHv6VULR3O188U3raeGRSMzK+G3pldL9ySwaZWhsHCtI2BTvlQuu/3p10s4a5c3w==",
|
||||
"dev": true,
|
||||
"license": "Apache-2.0"
|
||||
},
|
||||
"node_modules/lightningcss": {
|
||||
"version": "1.32.0",
|
||||
"resolved": "https://registry.npmmirror.com/lightningcss/-/lightningcss-1.32.0.tgz",
|
||||
"integrity": "sha512-NXYBzinNrblfraPGyrbPoD19C1h9lfI/1mzgWYvXUTe414Gz/X1FD2XBZSZM7rRTrMA8JL3OtAaGifrIKhQ5yQ==",
|
||||
"dev": true,
|
||||
"license": "MPL-2.0",
|
||||
"dependencies": {
|
||||
"detect-libc": "^2.0.3"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 12.0.0"
|
||||
},
|
||||
"funding": {
|
||||
"type": "opencollective",
|
||||
"url": "https://opencollective.com/parcel"
|
||||
},
|
||||
"optionalDependencies": {
|
||||
"lightningcss-android-arm64": "1.32.0",
|
||||
"lightningcss-darwin-arm64": "1.32.0",
|
||||
"lightningcss-darwin-x64": "1.32.0",
|
||||
"lightningcss-freebsd-x64": "1.32.0",
|
||||
"lightningcss-linux-arm-gnueabihf": "1.32.0",
|
||||
"lightningcss-linux-arm64-gnu": "1.32.0",
|
||||
"lightningcss-linux-arm64-musl": "1.32.0",
|
||||
"lightningcss-linux-x64-gnu": "1.32.0",
|
||||
"lightningcss-linux-x64-musl": "1.32.0",
|
||||
"lightningcss-win32-arm64-msvc": "1.32.0",
|
||||
"lightningcss-win32-x64-msvc": "1.32.0"
|
||||
}
|
||||
},
|
||||
"node_modules/lightningcss-android-arm64": {
|
||||
"version": "1.32.0",
|
||||
"resolved": "https://registry.npmmirror.com/lightningcss-android-arm64/-/lightningcss-android-arm64-1.32.0.tgz",
|
||||
"integrity": "sha512-YK7/ClTt4kAK0vo6w3X+Pnm0D2cf2vPHbhOXdoNti1Ga0al1P4TBZhwjATvjNwLEBCnKvjJc2jQgHXH0NEwlAg==",
|
||||
"cpu": [
|
||||
"arm64"
|
||||
],
|
||||
"dev": true,
|
||||
"license": "MPL-2.0",
|
||||
"optional": true,
|
||||
"os": [
|
||||
"android"
|
||||
],
|
||||
"engines": {
|
||||
"node": ">= 12.0.0"
|
||||
},
|
||||
"funding": {
|
||||
"type": "opencollective",
|
||||
"url": "https://opencollective.com/parcel"
|
||||
}
|
||||
},
|
||||
"node_modules/lightningcss-darwin-arm64": {
|
||||
"version": "1.32.0",
|
||||
"resolved": "https://registry.npmmirror.com/lightningcss-darwin-arm64/-/lightningcss-darwin-arm64-1.32.0.tgz",
|
||||
"integrity": "sha512-RzeG9Ju5bag2Bv1/lwlVJvBE3q6TtXskdZLLCyfg5pt+HLz9BqlICO7LZM7VHNTTn/5PRhHFBSjk5lc4cmscPQ==",
|
||||
"cpu": [
|
||||
"arm64"
|
||||
],
|
||||
"dev": true,
|
||||
"license": "MPL-2.0",
|
||||
"optional": true,
|
||||
"os": [
|
||||
"darwin"
|
||||
],
|
||||
"engines": {
|
||||
"node": ">= 12.0.0"
|
||||
},
|
||||
"funding": {
|
||||
"type": "opencollective",
|
||||
"url": "https://opencollective.com/parcel"
|
||||
}
|
||||
},
|
||||
"node_modules/lightningcss-darwin-x64": {
|
||||
"version": "1.32.0",
|
||||
"resolved": "https://registry.npmmirror.com/lightningcss-darwin-x64/-/lightningcss-darwin-x64-1.32.0.tgz",
|
||||
"integrity": "sha512-U+QsBp2m/s2wqpUYT/6wnlagdZbtZdndSmut/NJqlCcMLTWp5muCrID+K5UJ6jqD2BFshejCYXniPDbNh73V8w==",
|
||||
"cpu": [
|
||||
"x64"
|
||||
],
|
||||
"dev": true,
|
||||
"license": "MPL-2.0",
|
||||
"optional": true,
|
||||
"os": [
|
||||
"darwin"
|
||||
],
|
||||
"engines": {
|
||||
"node": ">= 12.0.0"
|
||||
},
|
||||
"funding": {
|
||||
"type": "opencollective",
|
||||
"url": "https://opencollective.com/parcel"
|
||||
}
|
||||
},
|
||||
"node_modules/lightningcss-freebsd-x64": {
|
||||
"version": "1.32.0",
|
||||
"resolved": "https://registry.npmmirror.com/lightningcss-freebsd-x64/-/lightningcss-freebsd-x64-1.32.0.tgz",
|
||||
"integrity": "sha512-JCTigedEksZk3tHTTthnMdVfGf61Fky8Ji2E4YjUTEQX14xiy/lTzXnu1vwiZe3bYe0q+SpsSH/CTeDXK6WHig==",
|
||||
"cpu": [
|
||||
"x64"
|
||||
],
|
||||
"dev": true,
|
||||
"license": "MPL-2.0",
|
||||
"optional": true,
|
||||
"os": [
|
||||
"freebsd"
|
||||
],
|
||||
"engines": {
|
||||
"node": ">= 12.0.0"
|
||||
},
|
||||
"funding": {
|
||||
"type": "opencollective",
|
||||
"url": "https://opencollective.com/parcel"
|
||||
}
|
||||
},
|
||||
"node_modules/lightningcss-linux-arm-gnueabihf": {
|
||||
"version": "1.32.0",
|
||||
"resolved": "https://registry.npmmirror.com/lightningcss-linux-arm-gnueabihf/-/lightningcss-linux-arm-gnueabihf-1.32.0.tgz",
|
||||
"integrity": "sha512-x6rnnpRa2GL0zQOkt6rts3YDPzduLpWvwAF6EMhXFVZXD4tPrBkEFqzGowzCsIWsPjqSK+tyNEODUBXeeVHSkw==",
|
||||
"cpu": [
|
||||
"arm"
|
||||
],
|
||||
"dev": true,
|
||||
"license": "MPL-2.0",
|
||||
"optional": true,
|
||||
"os": [
|
||||
"linux"
|
||||
],
|
||||
"engines": {
|
||||
"node": ">= 12.0.0"
|
||||
},
|
||||
"funding": {
|
||||
"type": "opencollective",
|
||||
"url": "https://opencollective.com/parcel"
|
||||
}
|
||||
},
|
||||
"node_modules/lightningcss-linux-arm64-gnu": {
|
||||
"version": "1.32.0",
|
||||
"resolved": "https://registry.npmmirror.com/lightningcss-linux-arm64-gnu/-/lightningcss-linux-arm64-gnu-1.32.0.tgz",
|
||||
"integrity": "sha512-0nnMyoyOLRJXfbMOilaSRcLH3Jw5z9HDNGfT/gwCPgaDjnx0i8w7vBzFLFR1f6CMLKF8gVbebmkUN3fa/kQJpQ==",
|
||||
"cpu": [
|
||||
"arm64"
|
||||
],
|
||||
"dev": true,
|
||||
"license": "MPL-2.0",
|
||||
"optional": true,
|
||||
"os": [
|
||||
"linux"
|
||||
],
|
||||
"engines": {
|
||||
"node": ">= 12.0.0"
|
||||
},
|
||||
"funding": {
|
||||
"type": "opencollective",
|
||||
"url": "https://opencollective.com/parcel"
|
||||
}
|
||||
},
|
||||
"node_modules/lightningcss-linux-arm64-musl": {
|
||||
"version": "1.32.0",
|
||||
"resolved": "https://registry.npmmirror.com/lightningcss-linux-arm64-musl/-/lightningcss-linux-arm64-musl-1.32.0.tgz",
|
||||
"integrity": "sha512-UpQkoenr4UJEzgVIYpI80lDFvRmPVg6oqboNHfoH4CQIfNA+HOrZ7Mo7KZP02dC6LjghPQJeBsvXhJod/wnIBg==",
|
||||
"cpu": [
|
||||
"arm64"
|
||||
],
|
||||
"dev": true,
|
||||
"license": "MPL-2.0",
|
||||
"optional": true,
|
||||
"os": [
|
||||
"linux"
|
||||
],
|
||||
"engines": {
|
||||
"node": ">= 12.0.0"
|
||||
},
|
||||
"funding": {
|
||||
"type": "opencollective",
|
||||
"url": "https://opencollective.com/parcel"
|
||||
}
|
||||
},
|
||||
"node_modules/lightningcss-linux-x64-gnu": {
|
||||
"version": "1.32.0",
|
||||
"resolved": "https://registry.npmmirror.com/lightningcss-linux-x64-gnu/-/lightningcss-linux-x64-gnu-1.32.0.tgz",
|
||||
"integrity": "sha512-V7Qr52IhZmdKPVr+Vtw8o+WLsQJYCTd8loIfpDaMRWGUZfBOYEJeyJIkqGIDMZPwPx24pUMfwSxxI8phr/MbOA==",
|
||||
"cpu": [
|
||||
"x64"
|
||||
],
|
||||
"dev": true,
|
||||
"license": "MPL-2.0",
|
||||
"optional": true,
|
||||
"os": [
|
||||
"linux"
|
||||
],
|
||||
"engines": {
|
||||
"node": ">= 12.0.0"
|
||||
},
|
||||
"funding": {
|
||||
"type": "opencollective",
|
||||
"url": "https://opencollective.com/parcel"
|
||||
}
|
||||
},
|
||||
"node_modules/lightningcss-linux-x64-musl": {
|
||||
"version": "1.32.0",
|
||||
"resolved": "https://registry.npmmirror.com/lightningcss-linux-x64-musl/-/lightningcss-linux-x64-musl-1.32.0.tgz",
|
||||
"integrity": "sha512-bYcLp+Vb0awsiXg/80uCRezCYHNg1/l3mt0gzHnWV9XP1W5sKa5/TCdGWaR/zBM2PeF/HbsQv/j2URNOiVuxWg==",
|
||||
"cpu": [
|
||||
"x64"
|
||||
],
|
||||
"dev": true,
|
||||
"license": "MPL-2.0",
|
||||
"optional": true,
|
||||
"os": [
|
||||
"linux"
|
||||
],
|
||||
"engines": {
|
||||
"node": ">= 12.0.0"
|
||||
},
|
||||
"funding": {
|
||||
"type": "opencollective",
|
||||
"url": "https://opencollective.com/parcel"
|
||||
}
|
||||
},
|
||||
"node_modules/lightningcss-win32-arm64-msvc": {
|
||||
"version": "1.32.0",
|
||||
"resolved": "https://registry.npmmirror.com/lightningcss-win32-arm64-msvc/-/lightningcss-win32-arm64-msvc-1.32.0.tgz",
|
||||
"integrity": "sha512-8SbC8BR40pS6baCM8sbtYDSwEVQd4JlFTOlaD3gWGHfThTcABnNDBda6eTZeqbofalIJhFx0qKzgHJmcPTnGdw==",
|
||||
"cpu": [
|
||||
"arm64"
|
||||
],
|
||||
"dev": true,
|
||||
"license": "MPL-2.0",
|
||||
"optional": true,
|
||||
"os": [
|
||||
"win32"
|
||||
],
|
||||
"engines": {
|
||||
"node": ">= 12.0.0"
|
||||
},
|
||||
"funding": {
|
||||
"type": "opencollective",
|
||||
"url": "https://opencollective.com/parcel"
|
||||
}
|
||||
},
|
||||
"node_modules/lightningcss-win32-x64-msvc": {
|
||||
"version": "1.32.0",
|
||||
"resolved": "https://registry.npmmirror.com/lightningcss-win32-x64-msvc/-/lightningcss-win32-x64-msvc-1.32.0.tgz",
|
||||
"integrity": "sha512-Amq9B/SoZYdDi1kFrojnoqPLxYhQ4Wo5XiL8EVJrVsB8ARoC1PWW6VGtT0WKCemjy8aC+louJnjS7U18x3b06Q==",
|
||||
"cpu": [
|
||||
"x64"
|
||||
],
|
||||
"dev": true,
|
||||
"license": "MPL-2.0",
|
||||
"optional": true,
|
||||
"os": [
|
||||
"win32"
|
||||
],
|
||||
"engines": {
|
||||
"node": ">= 12.0.0"
|
||||
},
|
||||
"funding": {
|
||||
"type": "opencollective",
|
||||
"url": "https://opencollective.com/parcel"
|
||||
}
|
||||
},
|
||||
"node_modules/nanoid": {
|
||||
"version": "3.3.11",
|
||||
"resolved": "https://registry.npmmirror.com/nanoid/-/nanoid-3.3.11.tgz",
|
||||
"integrity": "sha512-N8SpfPUnUp1bK+PMYW8qSWdl9U+wwNWI4QKxOYDy9JAro3WMX7p2OeVRF9v+347pnakNevPmiHhNmZ2HbFA76w==",
|
||||
"dev": true,
|
||||
"funding": [
|
||||
{
|
||||
"type": "github",
|
||||
"url": "https://github.com/sponsors/ai"
|
||||
}
|
||||
],
|
||||
"license": "MIT",
|
||||
"bin": {
|
||||
"nanoid": "bin/nanoid.cjs"
|
||||
},
|
||||
"engines": {
|
||||
"node": "^10 || ^12 || ^13.7 || ^14 || >=15.0.1"
|
||||
}
|
||||
},
|
||||
"node_modules/picocolors": {
|
||||
"version": "1.1.1",
|
||||
"resolved": "https://registry.npmmirror.com/picocolors/-/picocolors-1.1.1.tgz",
|
||||
"integrity": "sha512-xceH2snhtb5M9liqDsmEw56le376mTZkEX/jEb/RxNFyegNul7eNslCXP9FDj/Lcu0X8KEyMceP2ntpaHrDEVA==",
|
||||
"dev": true,
|
||||
"license": "ISC"
|
||||
},
|
||||
"node_modules/picomatch": {
|
||||
"version": "4.0.4",
|
||||
"resolved": "https://registry.npmmirror.com/picomatch/-/picomatch-4.0.4.tgz",
|
||||
"integrity": "sha512-QP88BAKvMam/3NxH6vj2o21R6MjxZUAd6nlwAS/pnGvN9IVLocLHxGYIzFhg6fUQ+5th6P4dv4eW9jX3DSIj7A==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">=12"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://github.com/sponsors/jonschlinkert"
|
||||
}
|
||||
},
|
||||
"node_modules/postcss": {
|
||||
"version": "8.5.8",
|
||||
"resolved": "https://registry.npmmirror.com/postcss/-/postcss-8.5.8.tgz",
|
||||
"integrity": "sha512-OW/rX8O/jXnm82Ey1k44pObPtdblfiuWnrd8X7GJ7emImCOstunGbXUpp7HdBrFQX6rJzn3sPT397Wp5aCwCHg==",
|
||||
"dev": true,
|
||||
"funding": [
|
||||
{
|
||||
"type": "opencollective",
|
||||
"url": "https://opencollective.com/postcss/"
|
||||
},
|
||||
{
|
||||
"type": "tidelift",
|
||||
"url": "https://tidelift.com/funding/github/npm/postcss"
|
||||
},
|
||||
{
|
||||
"type": "github",
|
||||
"url": "https://github.com/sponsors/ai"
|
||||
}
|
||||
],
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"nanoid": "^3.3.11",
|
||||
"picocolors": "^1.1.1",
|
||||
"source-map-js": "^1.2.1"
|
||||
},
|
||||
"engines": {
|
||||
"node": "^10 || ^12 || >=14"
|
||||
}
|
||||
},
|
||||
"node_modules/rolldown": {
|
||||
"version": "1.0.0-rc.12",
|
||||
"resolved": "https://registry.npmmirror.com/rolldown/-/rolldown-1.0.0-rc.12.tgz",
|
||||
"integrity": "sha512-yP4USLIMYrwpPHEFB5JGH1uxhcslv6/hL0OyvTuY+3qlOSJvZ7ntYnoWpehBxufkgN0cvXxppuTu5hHa/zPh+A==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@oxc-project/types": "=0.122.0",
|
||||
"@rolldown/pluginutils": "1.0.0-rc.12"
|
||||
},
|
||||
"bin": {
|
||||
"rolldown": "bin/cli.mjs"
|
||||
},
|
||||
"engines": {
|
||||
"node": "^20.19.0 || >=22.12.0"
|
||||
},
|
||||
"optionalDependencies": {
|
||||
"@rolldown/binding-android-arm64": "1.0.0-rc.12",
|
||||
"@rolldown/binding-darwin-arm64": "1.0.0-rc.12",
|
||||
"@rolldown/binding-darwin-x64": "1.0.0-rc.12",
|
||||
"@rolldown/binding-freebsd-x64": "1.0.0-rc.12",
|
||||
"@rolldown/binding-linux-arm-gnueabihf": "1.0.0-rc.12",
|
||||
"@rolldown/binding-linux-arm64-gnu": "1.0.0-rc.12",
|
||||
"@rolldown/binding-linux-arm64-musl": "1.0.0-rc.12",
|
||||
"@rolldown/binding-linux-ppc64-gnu": "1.0.0-rc.12",
|
||||
"@rolldown/binding-linux-s390x-gnu": "1.0.0-rc.12",
|
||||
"@rolldown/binding-linux-x64-gnu": "1.0.0-rc.12",
|
||||
"@rolldown/binding-linux-x64-musl": "1.0.0-rc.12",
|
||||
"@rolldown/binding-openharmony-arm64": "1.0.0-rc.12",
|
||||
"@rolldown/binding-wasm32-wasi": "1.0.0-rc.12",
|
||||
"@rolldown/binding-win32-arm64-msvc": "1.0.0-rc.12",
|
||||
"@rolldown/binding-win32-x64-msvc": "1.0.0-rc.12"
|
||||
}
|
||||
},
|
||||
"node_modules/source-map-js": {
|
||||
"version": "1.2.1",
|
||||
"resolved": "https://registry.npmmirror.com/source-map-js/-/source-map-js-1.2.1.tgz",
|
||||
"integrity": "sha512-UXWMKhLOwVKb728IUtQPXxfYU+usdybtUrK/8uGE8CQMvrhOpwvzDBwj0QhSL7MQc7vIsISBG8VQ8+IDQxpfQA==",
|
||||
"dev": true,
|
||||
"license": "BSD-3-Clause",
|
||||
"engines": {
|
||||
"node": ">=0.10.0"
|
||||
}
|
||||
},
|
||||
"node_modules/tinyglobby": {
|
||||
"version": "0.2.15",
|
||||
"resolved": "https://registry.npmmirror.com/tinyglobby/-/tinyglobby-0.2.15.tgz",
|
||||
"integrity": "sha512-j2Zq4NyQYG5XMST4cbs02Ak8iJUdxRM0XI5QyxXuZOzKOINmWurp3smXu3y5wDcJrptwpSjgXHzIQxR0omXljQ==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"fdir": "^6.5.0",
|
||||
"picomatch": "^4.0.3"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=12.0.0"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://github.com/sponsors/SuperchupuDev"
|
||||
}
|
||||
},
|
||||
"node_modules/tslib": {
|
||||
"version": "2.8.1",
|
||||
"resolved": "https://registry.npmmirror.com/tslib/-/tslib-2.8.1.tgz",
|
||||
"integrity": "sha512-oJFu94HQb+KVduSUQL7wnpmqnfmLsOA/nAh6b6EH0wCEoK0/mPeXU6c3wKDV83MkOuHPRHtSXKKU99IBazS/2w==",
|
||||
"dev": true,
|
||||
"license": "0BSD",
|
||||
"optional": true
|
||||
},
|
||||
"node_modules/vite": {
|
||||
"version": "8.0.3",
|
||||
"resolved": "https://registry.npmmirror.com/vite/-/vite-8.0.3.tgz",
|
||||
"integrity": "sha512-B9ifbFudT1TFhfltfaIPgjo9Z3mDynBTJSUYxTjOQruf/zHH+ezCQKcoqO+h7a9Pw9Nm/OtlXAiGT1axBgwqrQ==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"lightningcss": "^1.32.0",
|
||||
"picomatch": "^4.0.4",
|
||||
"postcss": "^8.5.8",
|
||||
"rolldown": "1.0.0-rc.12",
|
||||
"tinyglobby": "^0.2.15"
|
||||
},
|
||||
"bin": {
|
||||
"vite": "bin/vite.js"
|
||||
},
|
||||
"engines": {
|
||||
"node": "^20.19.0 || >=22.12.0"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://github.com/vitejs/vite?sponsor=1"
|
||||
},
|
||||
"optionalDependencies": {
|
||||
"fsevents": "~2.3.3"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@types/node": "^20.19.0 || >=22.12.0",
|
||||
"@vitejs/devtools": "^0.1.0",
|
||||
"esbuild": "^0.27.0",
|
||||
"jiti": ">=1.21.0",
|
||||
"less": "^4.0.0",
|
||||
"sass": "^1.70.0",
|
||||
"sass-embedded": "^1.70.0",
|
||||
"stylus": ">=0.54.8",
|
||||
"sugarss": "^5.0.0",
|
||||
"terser": "^5.16.0",
|
||||
"tsx": "^4.8.1",
|
||||
"yaml": "^2.4.2"
|
||||
},
|
||||
"peerDependenciesMeta": {
|
||||
"@types/node": {
|
||||
"optional": true
|
||||
},
|
||||
"@vitejs/devtools": {
|
||||
"optional": true
|
||||
},
|
||||
"esbuild": {
|
||||
"optional": true
|
||||
},
|
||||
"jiti": {
|
||||
"optional": true
|
||||
},
|
||||
"less": {
|
||||
"optional": true
|
||||
},
|
||||
"sass": {
|
||||
"optional": true
|
||||
},
|
||||
"sass-embedded": {
|
||||
"optional": true
|
||||
},
|
||||
"stylus": {
|
||||
"optional": true
|
||||
},
|
||||
"sugarss": {
|
||||
"optional": true
|
||||
},
|
||||
"terser": {
|
||||
"optional": true
|
||||
},
|
||||
"tsx": {
|
||||
"optional": true
|
||||
},
|
||||
"yaml": {
|
||||
"optional": true
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+17
-4
@@ -4,16 +4,29 @@
|
||||
"version": "2.1.0",
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
"dev": "vite",
|
||||
"build": "vite build && node build-module.js",
|
||||
"preview": "vite preview"
|
||||
"dev": "cd webui && vite",
|
||||
"build": "cd webui && vite build && cd .. && node build-module.js",
|
||||
"build:webui": "cd webui && vite build",
|
||||
"preview": "cd webui && vite preview",
|
||||
"lint": "oxlint webui/",
|
||||
"lint:fix": "oxlint --fix webui/",
|
||||
"fmt": "oxfmt webui/",
|
||||
"fmt:check": "oxfmt webui/ --check"
|
||||
},
|
||||
"devDependencies": {
|
||||
"archiver": "^7.0.1",
|
||||
"kernelsu": "^3.0.2",
|
||||
"oxfmt": "^0.44.0",
|
||||
"oxlint": "^1.59.0",
|
||||
"vite": "^8.0.3"
|
||||
},
|
||||
"dependencies": {
|
||||
"lucide": "^1.7.0"
|
||||
"@material/web": "^2.5.0",
|
||||
"@tanstack/vue-virtual": "^3.13.37",
|
||||
"@vitejs/plugin-vue": "^6.0.5",
|
||||
"lucide-vue-next": "^1.0.0",
|
||||
"markdown-it": "^14.1.1",
|
||||
"pinyin-match": "^1.2.10",
|
||||
"vue": "^3.5.32"
|
||||
}
|
||||
}
|
||||
Generated
+771
-10
@@ -8,9 +8,27 @@ importers:
|
||||
|
||||
.:
|
||||
dependencies:
|
||||
lucide:
|
||||
specifier: ^1.7.0
|
||||
version: 1.7.0
|
||||
'@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)
|
||||
lucide-vue-next:
|
||||
specifier: ^1.0.0
|
||||
version: 1.0.0(vue@3.5.32)
|
||||
markdown-it:
|
||||
specifier: ^14.1.1
|
||||
version: 14.1.1
|
||||
pinyin-match:
|
||||
specifier: ^1.2.10
|
||||
version: 1.2.10
|
||||
vue:
|
||||
specifier: ^3.5.32
|
||||
version: 3.5.32
|
||||
devDependencies:
|
||||
archiver:
|
||||
specifier: ^7.0.1
|
||||
@@ -18,12 +36,35 @@ importers:
|
||||
kernelsu:
|
||||
specifier: ^3.0.2
|
||||
version: 3.0.2
|
||||
oxfmt:
|
||||
specifier: ^0.44.0
|
||||
version: 0.44.0
|
||||
oxlint:
|
||||
specifier: ^1.59.0
|
||||
version: 1.59.0
|
||||
vite:
|
||||
specifier: ^8.0.3
|
||||
version: 8.0.3(@emnapi/core@1.9.2)(@emnapi/runtime@1.9.2)
|
||||
version: 8.0.3(@emnapi/core@1.9.2)(@emnapi/runtime@1.9.2)(jiti@2.6.1)
|
||||
|
||||
packages:
|
||||
|
||||
'@babel/helper-string-parser@7.27.1':
|
||||
resolution: {integrity: sha512-qMlSxKbpRlAridDExk92nSobyDdpPijUq2DW6oDnUqd0iOGxmQjyqhMIihI9+zv4LPyZdRje2cavWPbCbWm3eA==}
|
||||
engines: {node: '>=6.9.0'}
|
||||
|
||||
'@babel/helper-validator-identifier@7.28.5':
|
||||
resolution: {integrity: sha512-qSs4ifwzKJSV39ucNjsvc6WVHs6b7S03sOh2OcHF9UHfVPqWWALUsNUVzhSBiItjRZoLHx7nIarVjqKVusUZ1Q==}
|
||||
engines: {node: '>=6.9.0'}
|
||||
|
||||
'@babel/parser@7.29.2':
|
||||
resolution: {integrity: sha512-4GgRzy/+fsBa72/RZVJmGKPmZu9Byn8o4MoLpmNe1m8ZfYnz5emHLQz3U4gLud6Zwl0RZIcgiLD7Uq7ySFuDLA==}
|
||||
engines: {node: '>=6.0.0'}
|
||||
hasBin: true
|
||||
|
||||
'@babel/types@7.29.0':
|
||||
resolution: {integrity: sha512-LwdZHpScM4Qz8Xw2iKSzS+cfglZzJGvofQICy7W7v4caru4EaAmyUuO6BGrbyQ2mYV11W0U8j5mBhd14dd3B0A==}
|
||||
engines: {node: '>=6.9.0'}
|
||||
|
||||
'@emnapi/core@1.9.2':
|
||||
resolution: {integrity: sha512-UC+ZhH3XtczQYfOlu3lNEkdW/p4dsJ1r/bP7H8+rhao3TTTMO1ATq/4DdIi23XuGoFY+Cz0JmCbdVl0hz9jZcA==}
|
||||
|
||||
@@ -37,6 +78,21 @@ packages:
|
||||
resolution: {integrity: sha512-O8jcjabXaleOG9DQ0+ARXWZBTfnP4WNAqzuiJK7ll44AmxGKv/J2M4TPjxjY3znBCfvBXFzucm1twdyFybFqEA==}
|
||||
engines: {node: '>=12'}
|
||||
|
||||
'@jridgewell/sourcemap-codec@1.5.5':
|
||||
resolution: {integrity: sha512-cYQ9310grqxueWbl+WuIUIaiUaDcj7WOq5fVhEljNVgRfOUhY9fy2zTvfoqWsnebh8Sl70VScFbICvJnLKB0Og==}
|
||||
|
||||
'@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==}
|
||||
peerDependencies:
|
||||
@@ -46,6 +102,250 @@ packages:
|
||||
'@oxc-project/types@0.122.0':
|
||||
resolution: {integrity: sha512-oLAl5kBpV4w69UtFZ9xqcmTi+GENWOcPF7FCrczTiBbmC0ibXxCwyvZGbO39rCVEuLGAZM84DH0pUIyyv/YJzA==}
|
||||
|
||||
'@oxfmt/binding-android-arm-eabi@0.44.0':
|
||||
resolution: {integrity: sha512-5UvghMd9SA/yvKTWCAxMAPXS1d2i054UeOf4iFjZjfayTwCINcC3oaSXjtbZfCaEpxgJod7XiOjTtby5yEv/BQ==}
|
||||
engines: {node: ^20.19.0 || >=22.12.0}
|
||||
cpu: [arm]
|
||||
os: [android]
|
||||
|
||||
'@oxfmt/binding-android-arm64@0.44.0':
|
||||
resolution: {integrity: sha512-IVudM1BWfvrYO++Khtzr8q9n5Rxu7msUvoFMqzGJVdX7HfUXUDHwaH2zHZNB58svx2J56pmCUzophyaPFkcG/A==}
|
||||
engines: {node: ^20.19.0 || >=22.12.0}
|
||||
cpu: [arm64]
|
||||
os: [android]
|
||||
|
||||
'@oxfmt/binding-darwin-arm64@0.44.0':
|
||||
resolution: {integrity: sha512-eWCLAIKAHfx88EqEP1Ga2yz7qVcqDU5lemn4xck+07bH182hDdprOHjbogyk0In1Djys3T0/pO2JepFnRJ41Mg==}
|
||||
engines: {node: ^20.19.0 || >=22.12.0}
|
||||
cpu: [arm64]
|
||||
os: [darwin]
|
||||
|
||||
'@oxfmt/binding-darwin-x64@0.44.0':
|
||||
resolution: {integrity: sha512-eHTBznHLM49++dwz07MblQ2cOXyIgeedmE3Wgy4ptUESj38/qYZyRi1MPwC9olQJWssMeY6WI3UZ7YmU5ggvyQ==}
|
||||
engines: {node: ^20.19.0 || >=22.12.0}
|
||||
cpu: [x64]
|
||||
os: [darwin]
|
||||
|
||||
'@oxfmt/binding-freebsd-x64@0.44.0':
|
||||
resolution: {integrity: sha512-jLMmbj0u0Ft43QpkUVr/0v1ZfQCGWAvU+WznEHcN3wZC/q6ox7XeSJtk9P36CCpiDSUf3sGnzbIuG1KdEMEDJQ==}
|
||||
engines: {node: ^20.19.0 || >=22.12.0}
|
||||
cpu: [x64]
|
||||
os: [freebsd]
|
||||
|
||||
'@oxfmt/binding-linux-arm-gnueabihf@0.44.0':
|
||||
resolution: {integrity: sha512-n+A/u/ByK1qV8FVGOwyaSpw5NPNl0qlZfgTBqHeGIqr8Qzq1tyWZ4lAaxPoe5mZqE3w88vn3+jZtMxriHPE7tg==}
|
||||
engines: {node: ^20.19.0 || >=22.12.0}
|
||||
cpu: [arm]
|
||||
os: [linux]
|
||||
|
||||
'@oxfmt/binding-linux-arm-musleabihf@0.44.0':
|
||||
resolution: {integrity: sha512-5eax+FkxyCqAi3Rw0mrZFr7+KTt/XweFsbALR+B5ljWBLBl8nHe4ADrUnb1gLEfQCJLl+Ca5FIVD4xEt95AwIw==}
|
||||
engines: {node: ^20.19.0 || >=22.12.0}
|
||||
cpu: [arm]
|
||||
os: [linux]
|
||||
|
||||
'@oxfmt/binding-linux-arm64-gnu@0.44.0':
|
||||
resolution: {integrity: sha512-58l8JaHxSGOmOMOG2CIrNsnkRJAj0YcHQCmvNACniOa/vd1iRHhlPajczegzS5jwMENlqgreyiTR9iNlke8qCw==}
|
||||
engines: {node: ^20.19.0 || >=22.12.0}
|
||||
cpu: [arm64]
|
||||
os: [linux]
|
||||
libc: [glibc]
|
||||
|
||||
'@oxfmt/binding-linux-arm64-musl@0.44.0':
|
||||
resolution: {integrity: sha512-AlObQIXyVRZ96LbtVljtFq0JqH5B92NU+BQeDFrXWBUWlCKAM0wF5GLfIhCLT5kQ3Sl+U0YjRJ7Alqj5hGQaCg==}
|
||||
engines: {node: ^20.19.0 || >=22.12.0}
|
||||
cpu: [arm64]
|
||||
os: [linux]
|
||||
libc: [musl]
|
||||
|
||||
'@oxfmt/binding-linux-ppc64-gnu@0.44.0':
|
||||
resolution: {integrity: sha512-YcFE8/q/BbrCiIiM5piwbkA6GwJc5QqhMQp2yDrqQ2fuVkZ7CInb1aIijZ/k8EXc72qXMSwKpVlBv1w/MsGO/A==}
|
||||
engines: {node: ^20.19.0 || >=22.12.0}
|
||||
cpu: [ppc64]
|
||||
os: [linux]
|
||||
libc: [glibc]
|
||||
|
||||
'@oxfmt/binding-linux-riscv64-gnu@0.44.0':
|
||||
resolution: {integrity: sha512-eOdzs6RqkRzuqNHUX5C8ISN5xfGh4xDww8OEd9YAmc3OWN8oAe5bmlIqQ+rrHLpv58/0BuU48bxkhnIGjA/ATQ==}
|
||||
engines: {node: ^20.19.0 || >=22.12.0}
|
||||
cpu: [riscv64]
|
||||
os: [linux]
|
||||
libc: [glibc]
|
||||
|
||||
'@oxfmt/binding-linux-riscv64-musl@0.44.0':
|
||||
resolution: {integrity: sha512-YBgNTxntD/QvlFUfgvh8bEdwOhXiquX8gaofZJAwYa/Xp1S1DQrFVZEeck7GFktr24DztsSp8N8WtWCBwxs0Hw==}
|
||||
engines: {node: ^20.19.0 || >=22.12.0}
|
||||
cpu: [riscv64]
|
||||
os: [linux]
|
||||
libc: [musl]
|
||||
|
||||
'@oxfmt/binding-linux-s390x-gnu@0.44.0':
|
||||
resolution: {integrity: sha512-GLIh1R6WHWshl/i4QQDNgj0WtT25aRO4HNUWEoitxiywyRdhTFmFEYT2rXlcl9U6/26vhmOqG5cRlMLG3ocaIA==}
|
||||
engines: {node: ^20.19.0 || >=22.12.0}
|
||||
cpu: [s390x]
|
||||
os: [linux]
|
||||
libc: [glibc]
|
||||
|
||||
'@oxfmt/binding-linux-x64-gnu@0.44.0':
|
||||
resolution: {integrity: sha512-gZOpgTlOsLcLfAF9qgpTr7FIIFSKnQN3hDf/0JvQ4CIwMY7h+eilNjxq/CorqvYcEOu+LRt1W4ZS7KccEHLOdA==}
|
||||
engines: {node: ^20.19.0 || >=22.12.0}
|
||||
cpu: [x64]
|
||||
os: [linux]
|
||||
libc: [glibc]
|
||||
|
||||
'@oxfmt/binding-linux-x64-musl@0.44.0':
|
||||
resolution: {integrity: sha512-1CyS9JTB+pCUFYFI6pkQGGZaT/AY5gnhHVrQQLhFba6idP9AzVYm1xbdWfywoldTYvjxQJV6x4SuduCIfP3W+A==}
|
||||
engines: {node: ^20.19.0 || >=22.12.0}
|
||||
cpu: [x64]
|
||||
os: [linux]
|
||||
libc: [musl]
|
||||
|
||||
'@oxfmt/binding-openharmony-arm64@0.44.0':
|
||||
resolution: {integrity: sha512-bmEv70Ak6jLr1xotCbF5TxIKjsmQaiX+jFRtnGtfA03tJPf6VG3cKh96S21boAt3JZc+Vjx8PYcDuLj39vM2Pw==}
|
||||
engines: {node: ^20.19.0 || >=22.12.0}
|
||||
cpu: [arm64]
|
||||
os: [openharmony]
|
||||
|
||||
'@oxfmt/binding-win32-arm64-msvc@0.44.0':
|
||||
resolution: {integrity: sha512-yWzB+oCpSnP/dmw85eFLAT5o35Ve5pkGS2uF/UCISpIwDqf1xa7OpmtomiqY/Vzg8VyvMbuf6vroF2khF/+1Vg==}
|
||||
engines: {node: ^20.19.0 || >=22.12.0}
|
||||
cpu: [arm64]
|
||||
os: [win32]
|
||||
|
||||
'@oxfmt/binding-win32-ia32-msvc@0.44.0':
|
||||
resolution: {integrity: sha512-TcWpo18xEIE3AmIG2kpr3kz5IEhQgnx0lazl2+8L+3eTopOAUevQcmlr4nhguImNWz0OMeOZrYZOhJNCf16nlQ==}
|
||||
engines: {node: ^20.19.0 || >=22.12.0}
|
||||
cpu: [ia32]
|
||||
os: [win32]
|
||||
|
||||
'@oxfmt/binding-win32-x64-msvc@0.44.0':
|
||||
resolution: {integrity: sha512-oj8aLkPJZppIM4CMQNsyir9ybM1Xw/CfGPTSsTnzpVGyljgfbdP0EVUlURiGM0BDrmw5psQ6ArmGCcUY/yABaQ==}
|
||||
engines: {node: ^20.19.0 || >=22.12.0}
|
||||
cpu: [x64]
|
||||
os: [win32]
|
||||
|
||||
'@oxlint/binding-android-arm-eabi@1.59.0':
|
||||
resolution: {integrity: sha512-etYDw/UaEv936AQUd/CRMBVd+e+XuuU6wC+VzOv1STvsTyZenLChepLWqLtnyTTp4YMlM22ypzogDDwqYxv5cg==}
|
||||
engines: {node: ^20.19.0 || >=22.12.0}
|
||||
cpu: [arm]
|
||||
os: [android]
|
||||
|
||||
'@oxlint/binding-android-arm64@1.59.0':
|
||||
resolution: {integrity: sha512-TgLc7XVLKH2a4h8j3vn1MDjfK33i9MY60f/bKhRGWyVzbk5LCZ4X01VZG7iHrMmi5vYbAp8//Ponigx03CLsdw==}
|
||||
engines: {node: ^20.19.0 || >=22.12.0}
|
||||
cpu: [arm64]
|
||||
os: [android]
|
||||
|
||||
'@oxlint/binding-darwin-arm64@1.59.0':
|
||||
resolution: {integrity: sha512-DXyFPf5ZKldMLloRHx/B9fsxsiTQomaw7cmEW3YIJko2HgCh+GUhp9gGYwHrqlLJPsEe3dYj9JebjX92D3j3AA==}
|
||||
engines: {node: ^20.19.0 || >=22.12.0}
|
||||
cpu: [arm64]
|
||||
os: [darwin]
|
||||
|
||||
'@oxlint/binding-darwin-x64@1.59.0':
|
||||
resolution: {integrity: sha512-LgvrsdgVLX1qWqIEmNsSmMXJhpAWdtUQ0M+oR0CySwi+9IHWyOGuIL8w8+u/kbZNMyZr4WUyYB5i0+D+AKgkLg==}
|
||||
engines: {node: ^20.19.0 || >=22.12.0}
|
||||
cpu: [x64]
|
||||
os: [darwin]
|
||||
|
||||
'@oxlint/binding-freebsd-x64@1.59.0':
|
||||
resolution: {integrity: sha512-bOJhqX/ny4hrFuTPlyk8foSRx/vLRpxJh0jOOKN2NWW6FScXHPAA5rQbrwdQPcgGB5V8Ua51RS03fke8ssBcug==}
|
||||
engines: {node: ^20.19.0 || >=22.12.0}
|
||||
cpu: [x64]
|
||||
os: [freebsd]
|
||||
|
||||
'@oxlint/binding-linux-arm-gnueabihf@1.59.0':
|
||||
resolution: {integrity: sha512-vVUXxYMF9trXCsz4m9H6U0IjehosVHxBzVgJUxly1uz4W1PdDyicaBnpC0KRXsHYretLVe+uS9pJy8iM57Kujw==}
|
||||
engines: {node: ^20.19.0 || >=22.12.0}
|
||||
cpu: [arm]
|
||||
os: [linux]
|
||||
|
||||
'@oxlint/binding-linux-arm-musleabihf@1.59.0':
|
||||
resolution: {integrity: sha512-TULQW8YBPGRWg5yZpFPL54HLOnJ3/HiX6VenDPi6YfxB/jlItwSMFh3/hCeSNbh+DAMaE1Py0j5MOaivHkI/9Q==}
|
||||
engines: {node: ^20.19.0 || >=22.12.0}
|
||||
cpu: [arm]
|
||||
os: [linux]
|
||||
|
||||
'@oxlint/binding-linux-arm64-gnu@1.59.0':
|
||||
resolution: {integrity: sha512-Gt54Y4eqSgYJ90xipm24xeyaPV854706o/kiT8oZvUt3VDY7qqxdqyGqchMaujd87ib+/MXvnl9WkK8Cc1BExg==}
|
||||
engines: {node: ^20.19.0 || >=22.12.0}
|
||||
cpu: [arm64]
|
||||
os: [linux]
|
||||
libc: [glibc]
|
||||
|
||||
'@oxlint/binding-linux-arm64-musl@1.59.0':
|
||||
resolution: {integrity: sha512-3CtsKp7NFB3OfqQzbuAecrY7GIZeiv7AD+xutU4tefVQzlfmTI7/ygWLrvkzsDEjTlMq41rYHxgsn6Yh8tybmA==}
|
||||
engines: {node: ^20.19.0 || >=22.12.0}
|
||||
cpu: [arm64]
|
||||
os: [linux]
|
||||
libc: [musl]
|
||||
|
||||
'@oxlint/binding-linux-ppc64-gnu@1.59.0':
|
||||
resolution: {integrity: sha512-K0diOpT3ncDmOfl9I1HuvpEsAuTxkts0VYwIv/w6Xiy9CdwyPBVX88Ga9l8VlGgMrwBMnSY4xIvVlVY/fkQk7Q==}
|
||||
engines: {node: ^20.19.0 || >=22.12.0}
|
||||
cpu: [ppc64]
|
||||
os: [linux]
|
||||
libc: [glibc]
|
||||
|
||||
'@oxlint/binding-linux-riscv64-gnu@1.59.0':
|
||||
resolution: {integrity: sha512-xAU7+QDU6kTJJ7mJLOGgo7oOjtAtkKyFZ0Yjdb5cEo3DiCCPFLvyr08rWiQh6evZ7RiUTf+o65NY/bqttzJiQQ==}
|
||||
engines: {node: ^20.19.0 || >=22.12.0}
|
||||
cpu: [riscv64]
|
||||
os: [linux]
|
||||
libc: [glibc]
|
||||
|
||||
'@oxlint/binding-linux-riscv64-musl@1.59.0':
|
||||
resolution: {integrity: sha512-KUmZmKlTTyauOnvUNVxK7G40sSSx0+w5l1UhaGsC6KPpOYHenx2oqJTnabmpLJicok7IC+3Y6fXAUOMyexaeJQ==}
|
||||
engines: {node: ^20.19.0 || >=22.12.0}
|
||||
cpu: [riscv64]
|
||||
os: [linux]
|
||||
libc: [musl]
|
||||
|
||||
'@oxlint/binding-linux-s390x-gnu@1.59.0':
|
||||
resolution: {integrity: sha512-4usRxC8gS0PGdkHnRmwJt/4zrQNZyk6vL0trCxwZSsAKM+OxhB8nKiR+mhjdBbl8lbMh2gc3bZpNN/ik8c4c2A==}
|
||||
engines: {node: ^20.19.0 || >=22.12.0}
|
||||
cpu: [s390x]
|
||||
os: [linux]
|
||||
libc: [glibc]
|
||||
|
||||
'@oxlint/binding-linux-x64-gnu@1.59.0':
|
||||
resolution: {integrity: sha512-s/rNE2gDmbwAOOP493xk2X7M8LZfI1LJFSSW1+yanz3vuQCFPiHkx4GY+O1HuLUDtkzGlhtMrIcxxzyYLv308w==}
|
||||
engines: {node: ^20.19.0 || >=22.12.0}
|
||||
cpu: [x64]
|
||||
os: [linux]
|
||||
libc: [glibc]
|
||||
|
||||
'@oxlint/binding-linux-x64-musl@1.59.0':
|
||||
resolution: {integrity: sha512-+yYj1udJa2UvvIUmEm0IcKgc0UlPMgz0nsSTvkPL2y6n0uU5LgIHSwVu4AHhrve6j9BpVSoRksnz8c9QcvITJA==}
|
||||
engines: {node: ^20.19.0 || >=22.12.0}
|
||||
cpu: [x64]
|
||||
os: [linux]
|
||||
libc: [musl]
|
||||
|
||||
'@oxlint/binding-openharmony-arm64@1.59.0':
|
||||
resolution: {integrity: sha512-bUplUb48LYsB3hHlQXP2ZMOenpieWoOyppLAnnAhuPag3MGPnt+7caxE3w/Vl9wpQsTA3gzLntQi9rxWrs7Xqg==}
|
||||
engines: {node: ^20.19.0 || >=22.12.0}
|
||||
cpu: [arm64]
|
||||
os: [openharmony]
|
||||
|
||||
'@oxlint/binding-win32-arm64-msvc@1.59.0':
|
||||
resolution: {integrity: sha512-/HLsLuz42rWl7h7ePdmMTpHm2HIDmPtcEMYgm5BBEHiEiuNOrzMaUpd2z7UnNni5LGN9obJy2YoAYBLXQwazrA==}
|
||||
engines: {node: ^20.19.0 || >=22.12.0}
|
||||
cpu: [arm64]
|
||||
os: [win32]
|
||||
|
||||
'@oxlint/binding-win32-ia32-msvc@1.59.0':
|
||||
resolution: {integrity: sha512-rUPy+JnanpPwV/aJCPnxAD1fW50+XPI0VkWr7f0vEbqcdsS8NpB24Rw6RsS7SdpFv8Dw+8ugCwao5nCFbqOUSg==}
|
||||
engines: {node: ^20.19.0 || >=22.12.0}
|
||||
cpu: [ia32]
|
||||
os: [win32]
|
||||
|
||||
'@oxlint/binding-win32-x64-msvc@1.59.0':
|
||||
resolution: {integrity: sha512-xkE7puteDS/vUyRngLXW0t8WgdWoS/tfxXjhP/P7SMqPDx+hs44SpssO3h3qmTqECYEuXBUPzcAw5257Ka+ofA==}
|
||||
engines: {node: ^20.19.0 || >=22.12.0}
|
||||
cpu: [x64]
|
||||
os: [win32]
|
||||
|
||||
'@pkgjs/parseargs@0.11.0':
|
||||
resolution: {integrity: sha512-+1VkjdD0QBLPodGrJUeqarH8VAIvQODIbwh9XpP5Syisf7YoQgsJKPNFoqqLQlu+VQ/tVSshMR6loPMn8U+dPg==}
|
||||
engines: {node: '>=14'}
|
||||
@@ -148,9 +448,59 @@ packages:
|
||||
'@rolldown/pluginutils@1.0.0-rc.12':
|
||||
resolution: {integrity: sha512-HHMwmarRKvoFsJorqYlFeFRzXZqCt2ETQlEDOb9aqssrnVBB1/+xgTGtuTrIk5vzLNX1MjMtTf7W9z3tsSbrxw==}
|
||||
|
||||
'@rolldown/pluginutils@1.0.0-rc.2':
|
||||
resolution: {integrity: sha512-izyXV/v+cHiRfozX62W9htOAvwMo4/bXKDrQ+vom1L1qRuexPock/7VZDAhnpHCLNejd3NJ6hiab+tO0D44Rgw==}
|
||||
|
||||
'@tanstack/virtual-core@3.17.9':
|
||||
resolution: {integrity: sha512-M8Bzy7CCMvUjRiuoHVH9mRjyUVczRs8v8RcUEphLFGc445ZP4KQ15Y1sLqhQqJi/HgGJrxfCHnEnIX0x9mVrBg==}
|
||||
|
||||
'@tanstack/vue-virtual@3.13.37':
|
||||
resolution: {integrity: sha512-1QNT8EXVKUx537/qvn/tFGs48eITBrrTWcyaMVjD4SCpij7E1LksbXZQLqkXBoJ9lfOVely/8Fgzqe/olQ+drw==}
|
||||
peerDependencies:
|
||||
vue: ^2.7.0 || ^3.0.0
|
||||
|
||||
'@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}
|
||||
peerDependencies:
|
||||
vite: ^5.0.0 || ^6.0.0 || ^7.0.0 || ^8.0.0
|
||||
vue: ^3.2.25
|
||||
|
||||
'@vue/compiler-core@3.5.32':
|
||||
resolution: {integrity: sha512-4x74Tbtqnda8s/NSD6e1Dr5p1c8HdMU5RWSjMSUzb8RTcUQqevDCxVAitcLBKT+ie3o0Dl9crc/S/opJM7qBGQ==}
|
||||
|
||||
'@vue/compiler-dom@3.5.32':
|
||||
resolution: {integrity: sha512-ybHAu70NtiEI1fvAUz3oXZqkUYEe5J98GjMDpTGl5iHb0T15wQYLR4wE3h9xfuTNA+Cm2f4czfe8B4s+CCH57Q==}
|
||||
|
||||
'@vue/compiler-sfc@3.5.32':
|
||||
resolution: {integrity: sha512-8UYUYo71cP/0YHMO814TRZlPuUUw3oifHuMR7Wp9SNoRSrxRQnhMLNlCeaODNn6kNTJsjFoQ/kqIj4qGvya4Xg==}
|
||||
|
||||
'@vue/compiler-ssr@3.5.32':
|
||||
resolution: {integrity: sha512-Gp4gTs22T3DgRotZ8aA/6m2jMR+GMztvBXUBEUOYOcST+giyGWJ4WvFd7QLHBkzTxkfOt8IELKNdpzITLbA2rw==}
|
||||
|
||||
'@vue/reactivity@3.5.32':
|
||||
resolution: {integrity: sha512-/ORasxSGvZ6MN5gc+uE364SxFdJ0+WqVG0CENXaGW58TOCdrAW76WWaplDtECeS1qphvtBZtR+3/o1g1zL4xPQ==}
|
||||
|
||||
'@vue/runtime-core@3.5.32':
|
||||
resolution: {integrity: sha512-pDrXCejn4UpFDFmMd27AcJEbHaLemaE5o4pbb7sLk79SRIhc6/t34BQA7SGNgYtbMnvbF/HHOftYBgFJtUoJUQ==}
|
||||
|
||||
'@vue/runtime-dom@3.5.32':
|
||||
resolution: {integrity: sha512-1CDVv7tv/IV13V8Nip1k/aaObVbWqRlVCVezTwx3K07p7Vxossp5JU1dcPNhJk3w347gonIUT9jQOGutyJrSVQ==}
|
||||
|
||||
'@vue/server-renderer@3.5.32':
|
||||
resolution: {integrity: sha512-IOjm2+JQwRFS7W28HNuJeXQle9KdZbODFY7hFGVtnnghF51ta20EWAZJHX+zLGtsHhaU6uC9BGPV52KVpYryMQ==}
|
||||
peerDependencies:
|
||||
vue: 3.5.32
|
||||
|
||||
'@vue/shared@3.5.32':
|
||||
resolution: {integrity: sha512-ksNyrmRQzWJJ8n3cRDuSF7zNNontuJg1YHnmWRJd2AMu8Ij2bqwiiri2lH5rHtYPZjj4STkNcgcmiQqlOjiYGg==}
|
||||
|
||||
abort-controller@3.0.0:
|
||||
resolution: {integrity: sha512-h8lQ8tacZYnR3vNQTgibj+tODHI5/+l06Au2Pcriv/Gmet0eaj4TwWH41sO9wnHDiQsEj19q0drzdWdeAHtweg==}
|
||||
engines: {node: '>=6.5'}
|
||||
@@ -179,6 +529,9 @@ packages:
|
||||
resolution: {integrity: sha512-ZcbTaIqJOfCc03QwD468Unz/5Ir8ATtvAHsK+FdXbDIbGfihqh9mrvdcYunQzqn4HrvWWaFyaxJhGZagaJJpPQ==}
|
||||
engines: {node: '>= 14'}
|
||||
|
||||
argparse@2.0.1:
|
||||
resolution: {integrity: sha512-8+9WqebbFzpX9OR+Wa6O29asIogeRMzcGtAINdpMHHyAg10f05aSFVBbcEqGf/PXw1EjAZ+q2/bEBg3DvurK3Q==}
|
||||
|
||||
async@3.2.6:
|
||||
resolution: {integrity: sha512-htCUDlxyyCLMgaM3xXg0C0LW2xqfuQ6p05pCEIsXuyQ+a1koYKTuBMzRNwmybfLgvJDMd0r1LTn4+E0Ti6C2AA==}
|
||||
|
||||
@@ -274,6 +627,9 @@ packages:
|
||||
resolution: {integrity: sha512-uV2QOWP2nWzsy2aMp8aRibhi9dlzF5Hgh5SHaB9OiTGEyDTiJJyx0uy51QXdyWbtAHNua4XJzUKca3OzKUd3vA==}
|
||||
engines: {node: '>= 8'}
|
||||
|
||||
csstype@3.2.3:
|
||||
resolution: {integrity: sha512-z1HGKcYy2xA8AGQfwrn0PAy+PB7X/GSj3UVJW9qKyn43xWa+gl5nXmU4qqLMRzWVLFC8KusUX8T/0kCiOYpAIQ==}
|
||||
|
||||
detect-libc@2.1.2:
|
||||
resolution: {integrity: sha512-Btj2BOOO83o3WyH59e8MgXsxEQVcarkUOpEYrubB0urwnN10yQ364rsiByU11nZlqWYZm05i/of7io4mzihBtQ==}
|
||||
engines: {node: '>=8'}
|
||||
@@ -287,6 +643,17 @@ packages:
|
||||
emoji-regex@9.2.2:
|
||||
resolution: {integrity: sha512-L18DaJsXSUk2+42pv8mLs5jJT2hqFkFE4j21wOmgbUqsZ2hL72NsUU785g9RXgo3s0ZNgVl42TiHp3ZtOv/Vyg==}
|
||||
|
||||
entities@4.5.0:
|
||||
resolution: {integrity: sha512-V0hjH4dGPh9Ao5p0MoRY6BVqtwCjhz6vI5LT8AJ55H+4g9/4vbHx1I54fS0XuclLhDHArPQCiMjDxjaL8fPxhw==}
|
||||
engines: {node: '>=0.12'}
|
||||
|
||||
entities@7.0.1:
|
||||
resolution: {integrity: sha512-TWrgLOFUQTH994YUyl1yT4uyavY5nNB5muff+RtWaqNVCAK408b5ZnnbNAUEWLTCpum9w6arT70i1XdQ4UeOPA==}
|
||||
engines: {node: '>=0.12'}
|
||||
|
||||
estree-walker@2.0.2:
|
||||
resolution: {integrity: sha512-Rfkk/Mp/DL7JVje3u18FxFujQlTNR2q6QfMSMB7AvCBx91NGj/ba3kCfza0f6dVDbw7YlRf/nDrn7pQrCCyQ/w==}
|
||||
|
||||
event-target-shim@5.0.1:
|
||||
resolution: {integrity: sha512-i/2XbnSz/uxRCU6+NdVJgKWDTM427+MqYbkQzD321DuCQJUqOuJKIA0IM2+W2xtYHdKOmZ4dR6fExsd4SXL+WQ==}
|
||||
engines: {node: '>=6'}
|
||||
@@ -349,6 +716,10 @@ packages:
|
||||
jackspeak@3.4.3:
|
||||
resolution: {integrity: sha512-OGlZQpz2yfahA/Rd1Y8Cd9SIEsqvXkLVoSw/cgwhnhFMDbsQFeZYoJJ7bIZBS9BcamUW96asq/npPWugM+RQBw==}
|
||||
|
||||
jiti@2.6.1:
|
||||
resolution: {integrity: sha512-ekilCSN1jwRvIbgeg/57YFh8qQDNbwDb9xT/qu2DAHbFFZUicIl4ygVaAvzveMhMVr3LnpSKTNnwt8PoOfmKhQ==}
|
||||
hasBin: true
|
||||
|
||||
kernelsu@3.0.2:
|
||||
resolution: {integrity: sha512-3MTGgIbl3TWCzqnJP6Fun9tHv6VULR3O188U3raeGRSMzK+G3pldL9ySwaZWhsHCtI2BTvlQuu/3p10s4a5c3w==}
|
||||
|
||||
@@ -430,14 +801,39 @@ packages:
|
||||
resolution: {integrity: sha512-NXYBzinNrblfraPGyrbPoD19C1h9lfI/1mzgWYvXUTe414Gz/X1FD2XBZSZM7rRTrMA8JL3OtAaGifrIKhQ5yQ==}
|
||||
engines: {node: '>= 12.0.0'}
|
||||
|
||||
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==}
|
||||
|
||||
lru-cache@10.4.3:
|
||||
resolution: {integrity: sha512-JNAzZcXrCt42VGLuYz0zfAzDfAvJWW6AfYlDBQyDV5DClI2m5sAmK+OIO7s59XfsRsWHp02jAJrRadPRGTt6SQ==}
|
||||
|
||||
lucide@1.7.0:
|
||||
resolution: {integrity: sha512-aYNogbuIxea3a8offpKjdMGf2FsUk9GECFh0B4iJgXlJOX41+7/ncvLVluKki8477SoybEdyGGf+qGYLBDiEsA==}
|
||||
lucide-vue-next@1.0.0:
|
||||
resolution: {integrity: sha512-V6SPvx1IHTj/UY+FrIYWV5faISsPSb8BnWSFDxAtezWKvWc9ZZ40PDrdu1/Qb5vg4lHWr1hs1BAMGVGm6V1Xdg==}
|
||||
deprecated: Package deprecated. Please use @lucide/vue instead.
|
||||
peerDependencies:
|
||||
vue: '>=3.0.1'
|
||||
|
||||
magic-string@0.30.21:
|
||||
resolution: {integrity: sha512-vd2F4YUyEXKGcLHoq+TEyCjxueSeHnFxyyjNp80yg0XV4vUhnDer/lvvlqM/arB5bXQN5K2/3oinyCRyx8T2CQ==}
|
||||
|
||||
markdown-it@14.1.1:
|
||||
resolution: {integrity: sha512-BuU2qnTti9YKgK5N+IeMubp14ZUKUUw7yeJbkjtosvHiP0AZ5c8IAgEMk79D0eC8F23r4Ac/q8cAIFdm2FtyoA==}
|
||||
hasBin: true
|
||||
|
||||
mdurl@2.0.0:
|
||||
resolution: {integrity: sha512-Lf+9+2r+Tdp5wXDXC4PcIBjTDtq4UKjCPMQhKIuzpJNW0b96kVqSwW0bT7FhRSfmAiFYgP+SCRvdrDozfh0U5w==}
|
||||
|
||||
minimatch@5.1.9:
|
||||
resolution: {integrity: sha512-7o1wEA2RyMP7Iu7GNba9vc0RWWGACJOCZBJX2GJWip0ikV+wcOsgVuY9uE8CPiyQhkGFSlhuSkZPavN7u1c2Fw==}
|
||||
@@ -460,6 +856,21 @@ packages:
|
||||
resolution: {integrity: sha512-6eZs5Ls3WtCisHWp9S2GUy8dqkpGi4BVSz3GaqiE6ezub0512ESztXUwUB6C6IKbQkY2Pnb/mD4WYojCRwcwLA==}
|
||||
engines: {node: '>=0.10.0'}
|
||||
|
||||
oxfmt@0.44.0:
|
||||
resolution: {integrity: sha512-lnncqvHewyRvaqdrnntVIrZV2tEddz8lbvPsQzG/zlkfvgZkwy0HP1p/2u1aCDToeg1jb9zBpbJdfkV73Itw+w==}
|
||||
engines: {node: ^20.19.0 || >=22.12.0}
|
||||
hasBin: true
|
||||
|
||||
oxlint@1.59.0:
|
||||
resolution: {integrity: sha512-0xBLeGGjP4vD9pygRo8iuOkOzEU1MqOnfiOl7KYezL/QvWL8NUg6n03zXc7ZVqltiOpUxBk2zgHI3PnRIEdAvw==}
|
||||
engines: {node: ^20.19.0 || >=22.12.0}
|
||||
hasBin: true
|
||||
peerDependencies:
|
||||
oxlint-tsgolint: '>=0.18.0'
|
||||
peerDependenciesMeta:
|
||||
oxlint-tsgolint:
|
||||
optional: true
|
||||
|
||||
package-json-from-dist@1.0.1:
|
||||
resolution: {integrity: sha512-UEZIS3/by4OC8vL3P2dTXRETpebLI2NiI5vIrjaD/5UtrkFX/tNbwjTSRAGC/+7CAo2pIcBaRgWmcBBHcsaCIw==}
|
||||
|
||||
@@ -478,6 +889,9 @@ packages:
|
||||
resolution: {integrity: sha512-QP88BAKvMam/3NxH6vj2o21R6MjxZUAd6nlwAS/pnGvN9IVLocLHxGYIzFhg6fUQ+5th6P4dv4eW9jX3DSIj7A==}
|
||||
engines: {node: '>=12'}
|
||||
|
||||
pinyin-match@1.2.10:
|
||||
resolution: {integrity: sha512-Xo1uMd9n56/xP2EAn7yfApnTmAGCLGqxFIm1fuOnSMty0xhqRF3+ZwVjp2yWFD/alv60RUWa/cZoQSeTSp1HxA==}
|
||||
|
||||
postcss@8.5.8:
|
||||
resolution: {integrity: sha512-OW/rX8O/jXnm82Ey1k44pObPtdblfiuWnrd8X7GJ7emImCOstunGbXUpp7HdBrFQX6rJzn3sPT397Wp5aCwCHg==}
|
||||
engines: {node: ^10 || ^12 || >=14}
|
||||
@@ -489,6 +903,10 @@ packages:
|
||||
resolution: {integrity: sha512-cdGef/drWFoydD1JsMzuFf8100nZl+GT+yacc2bEced5f9Rjk4z+WtFUTBu9PhOi9j/jfmBPu0mMEY4wIdAF8A==}
|
||||
engines: {node: '>= 0.6.0'}
|
||||
|
||||
punycode.js@2.3.1:
|
||||
resolution: {integrity: sha512-uxFIHU0YlHYhDQtV4R9J6a52SLx28BCjT+4ieh7IGbgwVJWO+km431c4yRlREUAsAmt/uMjQUyQHNEPf0M39CA==}
|
||||
engines: {node: '>=6'}
|
||||
|
||||
readable-stream@2.3.8:
|
||||
resolution: {integrity: sha512-8p0AUk4XODgIewSi0l8Epjs+EVnWiK7NoDIEGU0HhE7+ZyY8D1IMY7odu5lRrFXGg71L15KG8QrPmum45RTtdA==}
|
||||
|
||||
@@ -564,9 +982,16 @@ packages:
|
||||
resolution: {integrity: sha512-j2Zq4NyQYG5XMST4cbs02Ak8iJUdxRM0XI5QyxXuZOzKOINmWurp3smXu3y5wDcJrptwpSjgXHzIQxR0omXljQ==}
|
||||
engines: {node: '>=12.0.0'}
|
||||
|
||||
tinypool@2.1.0:
|
||||
resolution: {integrity: sha512-Pugqs6M0m7Lv1I7FtxN4aoyToKg1C4tu+/381vH35y8oENM/Ai7f7C4StcoK4/+BSw9ebcS8jRiVrORFKCALLw==}
|
||||
engines: {node: ^20.0.0 || >=22.0.0}
|
||||
|
||||
tslib@2.8.1:
|
||||
resolution: {integrity: sha512-oJFu94HQb+KVduSUQL7wnpmqnfmLsOA/nAh6b6EH0wCEoK0/mPeXU6c3wKDV83MkOuHPRHtSXKKU99IBazS/2w==}
|
||||
|
||||
uc.micro@2.1.0:
|
||||
resolution: {integrity: sha512-ARDJmphmdvUk6Glw7y9DQ2bFkKBHwQHLi2lsaH6PPmz/Ka9sFOBsBluozhDltWmnv9u/cF6Rt87znRTPV+yp/A==}
|
||||
|
||||
util-deprecate@1.0.2:
|
||||
resolution: {integrity: sha512-EPD5q1uXyFxJpCrLnCc1nHnq3gOa6DZBocAIiI2TaSCA7VCJ1UJDMagCzIkXNsUYfD1daK//LTEQ8xiIbrHtcw==}
|
||||
|
||||
@@ -613,6 +1038,14 @@ packages:
|
||||
yaml:
|
||||
optional: true
|
||||
|
||||
vue@3.5.32:
|
||||
resolution: {integrity: sha512-vM4z4Q9tTafVfMAK7IVzmxg34rSzTFMyIe0UUEijUCkn9+23lj0WRfA83dg7eQZIUlgOSGrkViIaCfqSAUXsMw==}
|
||||
peerDependencies:
|
||||
typescript: '*'
|
||||
peerDependenciesMeta:
|
||||
typescript:
|
||||
optional: true
|
||||
|
||||
which@2.0.2:
|
||||
resolution: {integrity: sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA==}
|
||||
engines: {node: '>= 8'}
|
||||
@@ -632,6 +1065,19 @@ packages:
|
||||
|
||||
snapshots:
|
||||
|
||||
'@babel/helper-string-parser@7.27.1': {}
|
||||
|
||||
'@babel/helper-validator-identifier@7.28.5': {}
|
||||
|
||||
'@babel/parser@7.29.2':
|
||||
dependencies:
|
||||
'@babel/types': 7.29.0
|
||||
|
||||
'@babel/types@7.29.0':
|
||||
dependencies:
|
||||
'@babel/helper-string-parser': 7.27.1
|
||||
'@babel/helper-validator-identifier': 7.28.5
|
||||
|
||||
'@emnapi/core@1.9.2':
|
||||
dependencies:
|
||||
'@emnapi/wasi-threads': 1.2.1
|
||||
@@ -657,6 +1103,24 @@ snapshots:
|
||||
wrap-ansi: 8.1.0
|
||||
wrap-ansi-cjs: wrap-ansi@7.0.0
|
||||
|
||||
'@jridgewell/sourcemap-codec@1.5.5': {}
|
||||
|
||||
'@lit-labs/ssr-dom-shim@1.6.0': {}
|
||||
|
||||
'@lit/context@1.1.6':
|
||||
dependencies:
|
||||
'@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:
|
||||
'@emnapi/core': 1.9.2
|
||||
@@ -666,6 +1130,120 @@ snapshots:
|
||||
|
||||
'@oxc-project/types@0.122.0': {}
|
||||
|
||||
'@oxfmt/binding-android-arm-eabi@0.44.0':
|
||||
optional: true
|
||||
|
||||
'@oxfmt/binding-android-arm64@0.44.0':
|
||||
optional: true
|
||||
|
||||
'@oxfmt/binding-darwin-arm64@0.44.0':
|
||||
optional: true
|
||||
|
||||
'@oxfmt/binding-darwin-x64@0.44.0':
|
||||
optional: true
|
||||
|
||||
'@oxfmt/binding-freebsd-x64@0.44.0':
|
||||
optional: true
|
||||
|
||||
'@oxfmt/binding-linux-arm-gnueabihf@0.44.0':
|
||||
optional: true
|
||||
|
||||
'@oxfmt/binding-linux-arm-musleabihf@0.44.0':
|
||||
optional: true
|
||||
|
||||
'@oxfmt/binding-linux-arm64-gnu@0.44.0':
|
||||
optional: true
|
||||
|
||||
'@oxfmt/binding-linux-arm64-musl@0.44.0':
|
||||
optional: true
|
||||
|
||||
'@oxfmt/binding-linux-ppc64-gnu@0.44.0':
|
||||
optional: true
|
||||
|
||||
'@oxfmt/binding-linux-riscv64-gnu@0.44.0':
|
||||
optional: true
|
||||
|
||||
'@oxfmt/binding-linux-riscv64-musl@0.44.0':
|
||||
optional: true
|
||||
|
||||
'@oxfmt/binding-linux-s390x-gnu@0.44.0':
|
||||
optional: true
|
||||
|
||||
'@oxfmt/binding-linux-x64-gnu@0.44.0':
|
||||
optional: true
|
||||
|
||||
'@oxfmt/binding-linux-x64-musl@0.44.0':
|
||||
optional: true
|
||||
|
||||
'@oxfmt/binding-openharmony-arm64@0.44.0':
|
||||
optional: true
|
||||
|
||||
'@oxfmt/binding-win32-arm64-msvc@0.44.0':
|
||||
optional: true
|
||||
|
||||
'@oxfmt/binding-win32-ia32-msvc@0.44.0':
|
||||
optional: true
|
||||
|
||||
'@oxfmt/binding-win32-x64-msvc@0.44.0':
|
||||
optional: true
|
||||
|
||||
'@oxlint/binding-android-arm-eabi@1.59.0':
|
||||
optional: true
|
||||
|
||||
'@oxlint/binding-android-arm64@1.59.0':
|
||||
optional: true
|
||||
|
||||
'@oxlint/binding-darwin-arm64@1.59.0':
|
||||
optional: true
|
||||
|
||||
'@oxlint/binding-darwin-x64@1.59.0':
|
||||
optional: true
|
||||
|
||||
'@oxlint/binding-freebsd-x64@1.59.0':
|
||||
optional: true
|
||||
|
||||
'@oxlint/binding-linux-arm-gnueabihf@1.59.0':
|
||||
optional: true
|
||||
|
||||
'@oxlint/binding-linux-arm-musleabihf@1.59.0':
|
||||
optional: true
|
||||
|
||||
'@oxlint/binding-linux-arm64-gnu@1.59.0':
|
||||
optional: true
|
||||
|
||||
'@oxlint/binding-linux-arm64-musl@1.59.0':
|
||||
optional: true
|
||||
|
||||
'@oxlint/binding-linux-ppc64-gnu@1.59.0':
|
||||
optional: true
|
||||
|
||||
'@oxlint/binding-linux-riscv64-gnu@1.59.0':
|
||||
optional: true
|
||||
|
||||
'@oxlint/binding-linux-riscv64-musl@1.59.0':
|
||||
optional: true
|
||||
|
||||
'@oxlint/binding-linux-s390x-gnu@1.59.0':
|
||||
optional: true
|
||||
|
||||
'@oxlint/binding-linux-x64-gnu@1.59.0':
|
||||
optional: true
|
||||
|
||||
'@oxlint/binding-linux-x64-musl@1.59.0':
|
||||
optional: true
|
||||
|
||||
'@oxlint/binding-openharmony-arm64@1.59.0':
|
||||
optional: true
|
||||
|
||||
'@oxlint/binding-win32-arm64-msvc@1.59.0':
|
||||
optional: true
|
||||
|
||||
'@oxlint/binding-win32-ia32-msvc@1.59.0':
|
||||
optional: true
|
||||
|
||||
'@oxlint/binding-win32-x64-msvc@1.59.0':
|
||||
optional: true
|
||||
|
||||
'@pkgjs/parseargs@0.11.0':
|
||||
optional: true
|
||||
|
||||
@@ -721,11 +1299,82 @@ snapshots:
|
||||
|
||||
'@rolldown/pluginutils@1.0.0-rc.12': {}
|
||||
|
||||
'@rolldown/pluginutils@1.0.0-rc.2': {}
|
||||
|
||||
'@tanstack/virtual-core@3.17.9': {}
|
||||
|
||||
'@tanstack/vue-virtual@3.13.37(vue@3.5.32)':
|
||||
dependencies:
|
||||
'@tanstack/virtual-core': 3.17.9
|
||||
vue: 3.5.32
|
||||
|
||||
'@tybys/wasm-util@0.10.1':
|
||||
dependencies:
|
||||
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
|
||||
vite: 8.0.3(@emnapi/core@1.9.2)(@emnapi/runtime@1.9.2)(jiti@2.6.1)
|
||||
vue: 3.5.32
|
||||
|
||||
'@vue/compiler-core@3.5.32':
|
||||
dependencies:
|
||||
'@babel/parser': 7.29.2
|
||||
'@vue/shared': 3.5.32
|
||||
entities: 7.0.1
|
||||
estree-walker: 2.0.2
|
||||
source-map-js: 1.2.1
|
||||
|
||||
'@vue/compiler-dom@3.5.32':
|
||||
dependencies:
|
||||
'@vue/compiler-core': 3.5.32
|
||||
'@vue/shared': 3.5.32
|
||||
|
||||
'@vue/compiler-sfc@3.5.32':
|
||||
dependencies:
|
||||
'@babel/parser': 7.29.2
|
||||
'@vue/compiler-core': 3.5.32
|
||||
'@vue/compiler-dom': 3.5.32
|
||||
'@vue/compiler-ssr': 3.5.32
|
||||
'@vue/shared': 3.5.32
|
||||
estree-walker: 2.0.2
|
||||
magic-string: 0.30.21
|
||||
postcss: 8.5.8
|
||||
source-map-js: 1.2.1
|
||||
|
||||
'@vue/compiler-ssr@3.5.32':
|
||||
dependencies:
|
||||
'@vue/compiler-dom': 3.5.32
|
||||
'@vue/shared': 3.5.32
|
||||
|
||||
'@vue/reactivity@3.5.32':
|
||||
dependencies:
|
||||
'@vue/shared': 3.5.32
|
||||
|
||||
'@vue/runtime-core@3.5.32':
|
||||
dependencies:
|
||||
'@vue/reactivity': 3.5.32
|
||||
'@vue/shared': 3.5.32
|
||||
|
||||
'@vue/runtime-dom@3.5.32':
|
||||
dependencies:
|
||||
'@vue/reactivity': 3.5.32
|
||||
'@vue/runtime-core': 3.5.32
|
||||
'@vue/shared': 3.5.32
|
||||
csstype: 3.2.3
|
||||
|
||||
'@vue/server-renderer@3.5.32(vue@3.5.32)':
|
||||
dependencies:
|
||||
'@vue/compiler-ssr': 3.5.32
|
||||
'@vue/shared': 3.5.32
|
||||
vue: 3.5.32
|
||||
|
||||
'@vue/shared@3.5.32': {}
|
||||
|
||||
abort-controller@3.0.0:
|
||||
dependencies:
|
||||
event-target-shim: 5.0.1
|
||||
@@ -764,6 +1413,8 @@ snapshots:
|
||||
- bare-buffer
|
||||
- react-native-b4a
|
||||
|
||||
argparse@2.0.1: {}
|
||||
|
||||
async@3.2.6: {}
|
||||
|
||||
b4a@1.8.0: {}
|
||||
@@ -844,6 +1495,8 @@ snapshots:
|
||||
shebang-command: 2.0.0
|
||||
which: 2.0.2
|
||||
|
||||
csstype@3.2.3: {}
|
||||
|
||||
detect-libc@2.1.2: {}
|
||||
|
||||
eastasianwidth@0.2.0: {}
|
||||
@@ -852,6 +1505,12 @@ snapshots:
|
||||
|
||||
emoji-regex@9.2.2: {}
|
||||
|
||||
entities@4.5.0: {}
|
||||
|
||||
entities@7.0.1: {}
|
||||
|
||||
estree-walker@2.0.2: {}
|
||||
|
||||
event-target-shim@5.0.1: {}
|
||||
|
||||
events-universal@1.0.1:
|
||||
@@ -905,6 +1564,9 @@ snapshots:
|
||||
optionalDependencies:
|
||||
'@pkgjs/parseargs': 0.11.0
|
||||
|
||||
jiti@2.6.1:
|
||||
optional: true
|
||||
|
||||
kernelsu@3.0.2: {}
|
||||
|
||||
lazystream@1.0.1:
|
||||
@@ -960,11 +1622,48 @@ snapshots:
|
||||
lightningcss-win32-arm64-msvc: 1.32.0
|
||||
lightningcss-win32-x64-msvc: 1.32.0
|
||||
|
||||
linkify-it@5.0.0:
|
||||
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: {}
|
||||
|
||||
lucide@1.7.0: {}
|
||||
lucide-vue-next@1.0.0(vue@3.5.32):
|
||||
dependencies:
|
||||
vue: 3.5.32
|
||||
|
||||
magic-string@0.30.21:
|
||||
dependencies:
|
||||
'@jridgewell/sourcemap-codec': 1.5.5
|
||||
|
||||
markdown-it@14.1.1:
|
||||
dependencies:
|
||||
argparse: 2.0.1
|
||||
entities: 4.5.0
|
||||
linkify-it: 5.0.0
|
||||
mdurl: 2.0.0
|
||||
punycode.js: 2.3.1
|
||||
uc.micro: 2.1.0
|
||||
|
||||
mdurl@2.0.0: {}
|
||||
|
||||
minimatch@5.1.9:
|
||||
dependencies:
|
||||
@@ -980,6 +1679,52 @@ snapshots:
|
||||
|
||||
normalize-path@3.0.0: {}
|
||||
|
||||
oxfmt@0.44.0:
|
||||
dependencies:
|
||||
tinypool: 2.1.0
|
||||
optionalDependencies:
|
||||
'@oxfmt/binding-android-arm-eabi': 0.44.0
|
||||
'@oxfmt/binding-android-arm64': 0.44.0
|
||||
'@oxfmt/binding-darwin-arm64': 0.44.0
|
||||
'@oxfmt/binding-darwin-x64': 0.44.0
|
||||
'@oxfmt/binding-freebsd-x64': 0.44.0
|
||||
'@oxfmt/binding-linux-arm-gnueabihf': 0.44.0
|
||||
'@oxfmt/binding-linux-arm-musleabihf': 0.44.0
|
||||
'@oxfmt/binding-linux-arm64-gnu': 0.44.0
|
||||
'@oxfmt/binding-linux-arm64-musl': 0.44.0
|
||||
'@oxfmt/binding-linux-ppc64-gnu': 0.44.0
|
||||
'@oxfmt/binding-linux-riscv64-gnu': 0.44.0
|
||||
'@oxfmt/binding-linux-riscv64-musl': 0.44.0
|
||||
'@oxfmt/binding-linux-s390x-gnu': 0.44.0
|
||||
'@oxfmt/binding-linux-x64-gnu': 0.44.0
|
||||
'@oxfmt/binding-linux-x64-musl': 0.44.0
|
||||
'@oxfmt/binding-openharmony-arm64': 0.44.0
|
||||
'@oxfmt/binding-win32-arm64-msvc': 0.44.0
|
||||
'@oxfmt/binding-win32-ia32-msvc': 0.44.0
|
||||
'@oxfmt/binding-win32-x64-msvc': 0.44.0
|
||||
|
||||
oxlint@1.59.0:
|
||||
optionalDependencies:
|
||||
'@oxlint/binding-android-arm-eabi': 1.59.0
|
||||
'@oxlint/binding-android-arm64': 1.59.0
|
||||
'@oxlint/binding-darwin-arm64': 1.59.0
|
||||
'@oxlint/binding-darwin-x64': 1.59.0
|
||||
'@oxlint/binding-freebsd-x64': 1.59.0
|
||||
'@oxlint/binding-linux-arm-gnueabihf': 1.59.0
|
||||
'@oxlint/binding-linux-arm-musleabihf': 1.59.0
|
||||
'@oxlint/binding-linux-arm64-gnu': 1.59.0
|
||||
'@oxlint/binding-linux-arm64-musl': 1.59.0
|
||||
'@oxlint/binding-linux-ppc64-gnu': 1.59.0
|
||||
'@oxlint/binding-linux-riscv64-gnu': 1.59.0
|
||||
'@oxlint/binding-linux-riscv64-musl': 1.59.0
|
||||
'@oxlint/binding-linux-s390x-gnu': 1.59.0
|
||||
'@oxlint/binding-linux-x64-gnu': 1.59.0
|
||||
'@oxlint/binding-linux-x64-musl': 1.59.0
|
||||
'@oxlint/binding-openharmony-arm64': 1.59.0
|
||||
'@oxlint/binding-win32-arm64-msvc': 1.59.0
|
||||
'@oxlint/binding-win32-ia32-msvc': 1.59.0
|
||||
'@oxlint/binding-win32-x64-msvc': 1.59.0
|
||||
|
||||
package-json-from-dist@1.0.1: {}
|
||||
|
||||
path-key@3.1.1: {}
|
||||
@@ -993,6 +1738,8 @@ snapshots:
|
||||
|
||||
picomatch@4.0.4: {}
|
||||
|
||||
pinyin-match@1.2.10: {}
|
||||
|
||||
postcss@8.5.8:
|
||||
dependencies:
|
||||
nanoid: 3.3.11
|
||||
@@ -1003,6 +1750,8 @@ snapshots:
|
||||
|
||||
process@0.11.10: {}
|
||||
|
||||
punycode.js@2.3.1: {}
|
||||
|
||||
readable-stream@2.3.8:
|
||||
dependencies:
|
||||
core-util-is: 1.0.3
|
||||
@@ -1129,12 +1878,15 @@ snapshots:
|
||||
fdir: 6.5.0(picomatch@4.0.4)
|
||||
picomatch: 4.0.4
|
||||
|
||||
tslib@2.8.1:
|
||||
optional: true
|
||||
tinypool@2.1.0: {}
|
||||
|
||||
tslib@2.8.1: {}
|
||||
|
||||
uc.micro@2.1.0: {}
|
||||
|
||||
util-deprecate@1.0.2: {}
|
||||
|
||||
vite@8.0.3(@emnapi/core@1.9.2)(@emnapi/runtime@1.9.2):
|
||||
vite@8.0.3(@emnapi/core@1.9.2)(@emnapi/runtime@1.9.2)(jiti@2.6.1):
|
||||
dependencies:
|
||||
lightningcss: 1.32.0
|
||||
picomatch: 4.0.4
|
||||
@@ -1143,10 +1895,19 @@ snapshots:
|
||||
tinyglobby: 0.2.15
|
||||
optionalDependencies:
|
||||
fsevents: 2.3.3
|
||||
jiti: 2.6.1
|
||||
transitivePeerDependencies:
|
||||
- '@emnapi/core'
|
||||
- '@emnapi/runtime'
|
||||
|
||||
vue@3.5.32:
|
||||
dependencies:
|
||||
'@vue/compiler-dom': 3.5.32
|
||||
'@vue/compiler-sfc': 3.5.32
|
||||
'@vue/runtime-dom': 3.5.32
|
||||
'@vue/server-renderer': 3.5.32(vue@3.5.32)
|
||||
'@vue/shared': 3.5.32
|
||||
|
||||
which@2.0.2:
|
||||
dependencies:
|
||||
isexe: 2.0.0
|
||||
|
||||
Binary file not shown.
Binary file not shown.
+4
-31
@@ -1,34 +1,7 @@
|
||||
#!/system/bin/sh
|
||||
# LuminPro 服务重启脚本
|
||||
#shellcheck shell=ash
|
||||
|
||||
# LuminPro 服务重启脚本(转发到 Go 实现)
|
||||
|
||||
MODDIR="${0%/*/*}"
|
||||
PID_DIR="$MODDIR/pid"
|
||||
pid_file="$PID_DIR/inotifyd.pid"
|
||||
flag_file="$PID_DIR/up.flag"
|
||||
now_bri_file="/sys/class/backlight/panel0-backlight/brightness"
|
||||
log_file="$MODDIR/service.log"
|
||||
|
||||
_log() {
|
||||
printf '[%s] [service.restart] %s\n' "$(date '+%d %H:%M:%S.%3N')" "$1" >>"$log_file"
|
||||
}
|
||||
|
||||
_log "正在手动重启服务..."
|
||||
|
||||
# 1. 杀死正在进行的 inotifyd
|
||||
if [ -f "$pid_file" ]; then
|
||||
kill -9 "$(cat "$pid_file")" 2>/dev/null
|
||||
_log "已杀死现有 inotifyd ($(cat "$pid_file"))"
|
||||
fi
|
||||
|
||||
# 2. 清理遗留文件
|
||||
rm -f "$pid_file"
|
||||
rm -f "$flag_file"
|
||||
_log "已清理 pid 和 flag 文件"
|
||||
|
||||
# 3. 重新启动 inotifyd
|
||||
inotifyd "$MODDIR/script/up.sh" "$now_bri_file:c" &
|
||||
inotifyd_pid="$!"
|
||||
echo "$inotifyd_pid" >"$pid_file"
|
||||
_log "inotifyd ($inotifyd_pid) 重新启动成功"
|
||||
|
||||
exit 0
|
||||
exec "$MODDIR/bin/luminpro" restart
|
||||
-178
@@ -1,178 +0,0 @@
|
||||
#!/system/bin/sh
|
||||
#shellcheck shell=ash
|
||||
# 亮度提升脚本
|
||||
|
||||
MODDIR="${0%/*/*}"
|
||||
CONFIG_DIR="$MODDIR/config"
|
||||
PID_DIR="$MODDIR/pid"
|
||||
flag_file="$PID_DIR/up.flag"
|
||||
stop_file="$PID_DIR/stop.flag"
|
||||
log_file="$MODDIR/service.log"
|
||||
|
||||
# 日志函数
|
||||
_log() {
|
||||
# 如果 stop.flag 存在并且不是正在清理日志,我们仍允许记录停止状态,但此处先检查基础
|
||||
case "$1" in
|
||||
"日志过大"*) ;;
|
||||
*) if [ -f "$stop_file" ]; then return; fi ;;
|
||||
esac
|
||||
|
||||
local max_size
|
||||
max_size="$(cat "$CONFIG_DIR/log_max_size.txt" 2>/dev/null)"
|
||||
[ -z "$max_size" ] && max_size="500" # 默认 500 KB
|
||||
|
||||
# 获取当前日志大小 (KB)
|
||||
if [ -f "$log_file" ]; then
|
||||
local cur_size
|
||||
cur_size=$(du -k "$log_file" | cut -f1)
|
||||
if [ "$cur_size" -ge "$max_size" ]; then
|
||||
echo "[$(date '+%d %H:%M:%S.%3N')] [service.up] 日志过大 ($cur_size KB), 自动重置" >"$log_file"
|
||||
fi
|
||||
fi
|
||||
|
||||
printf '[%s] [service.up] %s\n' "$(date '+%d %H:%M:%S.%3N')" "$1" >>"$log_file"
|
||||
}
|
||||
|
||||
_log "($$) 被 inotifyd 调用..."
|
||||
|
||||
if [ -f "$stop_file" ]; then
|
||||
_log "($$) 检测到 stop.flag, 停止本次调整 (服务已暂停)"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# 建立一个 flag, 避免重复执行; 如果已经有 flag, 则退出
|
||||
if [ -f "$flag_file" ]; then
|
||||
_log "($$) 重复执行, 这个进程退出, 将有其他进程接管"
|
||||
exit 1
|
||||
fi
|
||||
touch "$flag_file"
|
||||
|
||||
# 节点文件
|
||||
now_bri_file="/sys/class/backlight/panel0-backlight/brightness"
|
||||
|
||||
# 读取配置 (均为数值)
|
||||
ui_max_bri="$(cat "$CONFIG_DIR/ui_max_bri.txt")"
|
||||
max_bri="$(cat "$CONFIG_DIR/max_bri.txt")"
|
||||
sleep_time="$(cat "$CONFIG_DIR/sleep_time.txt" 2>/dev/null)"
|
||||
auto_bri_sleep="$(cat "$CONFIG_DIR/auto_bri_sleep.txt" 2>/dev/null)"
|
||||
|
||||
# 解析休眠时间 (格式: HHMM-HHMM, 例如 1900-0600)
|
||||
sleep_start="${sleep_time%-*}" # 1900
|
||||
sleep_end="${sleep_time#*-}" # 0600
|
||||
|
||||
# 判断当前是否处于休眠时段
|
||||
IS_SLEEP_TIME() {
|
||||
local now
|
||||
now="$(date '+%H%M')" # 当前时间, 例如 "2130"
|
||||
|
||||
# 未配置或格式无效则不休眠
|
||||
[ -z "$sleep_start" ] || [ -z "$sleep_end" ] && return 1
|
||||
# 起止相同表示不启用休眠
|
||||
[ "$sleep_start" = "$sleep_end" ] && return 1
|
||||
|
||||
if [ "$sleep_start" -gt "$sleep_end" ]; then
|
||||
# 跨午夜: 1900-0600 → 当前 >= 19:00 或 当前 < 06:00
|
||||
[ "$now" -ge "$sleep_start" ] || [ "$now" -lt "$sleep_end" ]
|
||||
else
|
||||
# 不跨午夜: 0100-0600 → 当前 >= 01:00 且 当前 < 06:00
|
||||
[ "$now" -ge "$sleep_start" ] && [ "$now" -lt "$sleep_end" ]
|
||||
fi
|
||||
}
|
||||
|
||||
# 目标亮度
|
||||
target_bri="$max_bri"
|
||||
steps_num="$(cat "$CONFIG_DIR/steps_num.txt" 2>/dev/null)"
|
||||
[ -z "$steps_num" ] && steps_num="50" # 步数 (默认 50)
|
||||
|
||||
# 循环调整
|
||||
update_all() {
|
||||
local step
|
||||
|
||||
# 在调整前的这一刻读取当前亮度作为起始值
|
||||
start_bri="$(cat "$now_bri_file")"
|
||||
bri_diff="$((target_bri - start_bri))"
|
||||
step_value="$((bri_diff / steps_num))"
|
||||
|
||||
# 如果步长为 0 (差值太小), 直接设置目标亮度
|
||||
if [ "$step_value" -eq 0 ]; then
|
||||
_log "($$) 步长为 0, 直接设置目标亮度: $target_bri"
|
||||
echo -n "$target_bri" >"$now_bri_file" && return 0 || return 1
|
||||
fi
|
||||
|
||||
_log "($$) 开始调整亮度: $start_bri -> $target_bri, 共 $steps_num 步, 每步 $step_value"
|
||||
for step in $(seq 1 "$steps_num"); do
|
||||
echo -n $((start_bri + step * step_value)) >"$now_bri_file"
|
||||
sleep 0.02
|
||||
done
|
||||
|
||||
# 最后一步写入目标亮度, 确保精确到位
|
||||
echo -n "$target_bri" >"$now_bri_file" && return 0 || return 1
|
||||
}
|
||||
|
||||
# 检测亮度是否符合条件
|
||||
CHECK_BRI() {
|
||||
local cycle_num
|
||||
local now_bri
|
||||
|
||||
# 循环 10 次 (检查 5s)
|
||||
# shellcheck disable=SC2034
|
||||
for cycle_num in $(seq 1 10); do
|
||||
now_bri="$(cat "$now_bri_file")"
|
||||
if [ "$now_bri" -ge "$ui_max_bri" ]; then
|
||||
if update_all; then
|
||||
_log "($$) 亮度调整完成!"
|
||||
_log "--------------------"
|
||||
return 0
|
||||
else
|
||||
_log "($$) 亮度调整失败!"
|
||||
_log "--------------------"
|
||||
return 1
|
||||
fi
|
||||
else
|
||||
sleep 0.5 # 不符合条件, 等待后再次检测
|
||||
fi
|
||||
done
|
||||
|
||||
_log "($$) 亮度 ($(cat "$now_bri_file")) 未达到条件, 本次调整取消"
|
||||
return 2
|
||||
}
|
||||
|
||||
# 判断是否开启了自动亮度且需要休眠
|
||||
IS_AUTO_BRI_SLEEP() {
|
||||
if [ "$auto_bri_sleep" = "1" ]; then
|
||||
local mode
|
||||
mode="$(settings get system screen_brightness_mode 2>/dev/null)"
|
||||
if [ "$mode" = "1" ]; then
|
||||
return 0 # 需要休眠
|
||||
fi
|
||||
fi
|
||||
return 1 # 不需要休眠
|
||||
}
|
||||
|
||||
MAIN() {
|
||||
# 休眠时段内不调整亮度
|
||||
if IS_SLEEP_TIME; then
|
||||
_log "($$) 当前处于休眠时段 ($sleep_start-$sleep_end), 跳过本次调整"
|
||||
_log "--------------------"
|
||||
sleep 1
|
||||
rm -f "$flag_file"
|
||||
return
|
||||
fi
|
||||
|
||||
if IS_AUTO_BRI_SLEEP; then
|
||||
_log "($$) 当前为自动亮度模式, 根据设置跳过本次调整"
|
||||
_log "--------------------"
|
||||
sleep 1
|
||||
rm -f "$flag_file"
|
||||
return
|
||||
fi
|
||||
|
||||
_log "($$) 亮度被调整, 将在 0.5s 后检测是否符合条件"
|
||||
sleep 0.5
|
||||
CHECK_BRI
|
||||
sleep 0.5 # 稍微延迟一会避免 inotifyd 刚启动就检测到亮度变化
|
||||
rm -f "$flag_file" # 删除 flag, 允许下一次调整
|
||||
}
|
||||
|
||||
MAIN
|
||||
exit 0
|
||||
+31
-52
@@ -1,69 +1,48 @@
|
||||
#!/system/bin/sh
|
||||
#shellcheck shell=ash
|
||||
|
||||
# LuminPro 模块启动入口:等待系统就绪后拉起 Go 守护进程
|
||||
|
||||
MODDIR="${0%/*}"
|
||||
CONFIG_DIR="$MODDIR/config"
|
||||
PID_DIR="$MODDIR/pid"
|
||||
|
||||
now_bri_file="/sys/class/backlight/panel0-backlight/brightness"
|
||||
|
||||
# 配置文件路径
|
||||
ui_max_bri_file="$CONFIG_DIR/ui_max_bri.txt"
|
||||
max_bri_file="$CONFIG_DIR/max_bri.txt"
|
||||
sleep_time_file="$CONFIG_DIR/sleep_time.txt"
|
||||
|
||||
pid_file="$PID_DIR/inotifyd.pid"
|
||||
BIN="$MODDIR/bin/luminpro"
|
||||
log_file="$MODDIR/service.log"
|
||||
|
||||
# inotifyd 用法:
|
||||
# inotifyd 程序 文件[:掩码] ...
|
||||
#
|
||||
# 当文件发生与 掩码(MASK) 匹配的文件系统事件时,运行 程序(PROG):
|
||||
# 程序 事件 文件 [目录文件]
|
||||
# 如果 程序(PROG) 为 "-",则事件将发送到标准输出 (stdout)。
|
||||
#
|
||||
# 以下是针对“此文件”的事件:
|
||||
# a 已访问 (accessed) c 已修改 (modified) e 元数据更改 (metadata change) w 已关闭 (可写)
|
||||
# r 已打开 (opened) D 已删除 (deleted) M 已移动 (moved) 0 已关闭 (不可写)
|
||||
# u 已卸载 (unmounted) o 溢出 (overflow) x 不可监控 (unwatchable)
|
||||
#
|
||||
# 以下是针对“此目录中”的文件事件:
|
||||
# m 移入 (moved in) y 移出 (moved out) n 已创建 (created) d 已删除 (deleted)
|
||||
# 当所有文件都发生 x 事件时,inotifyd 将退出(在等待程序运行结束后)。
|
||||
|
||||
# 监控当前亮度文件的日志
|
||||
# # inotifyd - /sys/class/backlight/panel0-backlight/brightness
|
||||
# c /sys/class/backlight/panel0-backlight/brightness # 已修改
|
||||
# r /sys/class/backlight/panel0-backlight/brightness # 已打开
|
||||
# a /sys/class/backlight/panel0-backlight/brightness # 已访问
|
||||
# 0 /sys/class/backlight/panel0-backlight/brightness # 已关闭(不可写)
|
||||
# -- 经过了 1 亮度值的调整 --
|
||||
# c /sys/class/backlight/panel0-backlight/brightness
|
||||
# r /sys/class/backlight/panel0-backlight/brightness
|
||||
# a /sys/class/backlight/panel0-backlight/brightness
|
||||
# 0 /sys/class/backlight/panel0-backlight/brightness
|
||||
# ...
|
||||
DEFAULT_NOW_BRI_FILE="/sys/class/backlight/panel0-backlight/brightness"
|
||||
|
||||
_log() {
|
||||
printf '[%s] [service] %s\n' "$(date '+%d %H:%M:%S.%3N')" "$1" >>"$log_file"
|
||||
local level="${2:-INFO}"
|
||||
local ll
|
||||
ll="$("$BIN" config get log_level 2>/dev/null)"
|
||||
[ -n "$ll" ] || ll="info"
|
||||
case "$ll" in
|
||||
off) return ;;
|
||||
error) case "$level" in ERROR) ;; *) return ;; esac ;;
|
||||
warn) case "$level" in ERROR | WARN) ;; *) return ;; esac ;;
|
||||
esac
|
||||
printf '[%s] [%s] [%s] %s\n' "$(date '+%m-%d %H:%M:%S')" "service" "$level" "$1" >>"$log_file"
|
||||
}
|
||||
|
||||
# 等待系统就绪
|
||||
sleep 30
|
||||
|
||||
_log "LuminPro 已启动"
|
||||
_log "- 前台最大亮度: $(cat "$ui_max_bri_file")"
|
||||
_log "- 峰值最大亮度: $(cat "$max_bri_file")"
|
||||
_log "- 休眠时间: $(cat "$sleep_time_file")"
|
||||
# 清理上次遗留的标记文件
|
||||
rm -f "$MODDIR/pid/"*.flag "$MODDIR/pid/"*.pause "$MODDIR/pid/"*.lock "$MODDIR/pid/oplock" "$MODDIR/pid/state.json" "$MODDIR/pid/.hdr_ratio_cache"
|
||||
|
||||
mkdir -p "$PID_DIR"
|
||||
[ -f "$pid_file" ] && rm -f "$pid_file"
|
||||
[ -f "$PID_DIR/up.flag" ] && rm -f "$PID_DIR/up.flag"
|
||||
chmod 755 "$MODDIR/script/up.sh"
|
||||
_log "LuminPro 服务启动" "INFO"
|
||||
|
||||
# 启动 inotifyd 监控
|
||||
inotifyd "$MODDIR/script/up.sh" "$now_bri_file:c" &
|
||||
inotifyd_pid="$!"
|
||||
echo "$inotifyd_pid" >"$pid_file"
|
||||
now_bri_file="$("$BIN" config get now_bri_file 2>/dev/null)"
|
||||
[ -n "$now_bri_file" ] || now_bri_file="$DEFAULT_NOW_BRI_FILE"
|
||||
_log "当前亮度节点: $now_bri_file" "INFO"
|
||||
|
||||
# 亮度节点不存在时不启动守护进程 (节点不可用的设备允许安装但功能保持关闭)
|
||||
if [ ! -f "$now_bri_file" ]; then
|
||||
_log "亮度节点不存在: $now_bri_file,模块功能未启用" "ERROR"
|
||||
_log "请配置正确的亮度节点路径后,在 Web UI 中重启模块以启用" "WARN"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
chmod 755 "$BIN"
|
||||
"$BIN" daemon >>"$log_file" 2>&1 &
|
||||
_log "守护进程已启动 (PID: $!)" "SUCCESS"
|
||||
|
||||
exit 0
|
||||
-379
@@ -1,379 +0,0 @@
|
||||
import { exec } from 'kernelsu';
|
||||
import { createIcons, Sun, Settings, Save, Activity, RefreshCw, FileText } from 'lucide';
|
||||
|
||||
const CONFIG_DIR = '/data/adb/modules/LuminPro/config';
|
||||
const BACKUP_DIR = '/data/adb/modules/LuminPro/config/.backup';
|
||||
const PID_FILE = '/data/adb/modules/LuminPro/pid/inotifyd.pid';
|
||||
const FLAG_FILE = '/data/adb/modules/LuminPro/pid/up.flag';
|
||||
const STOP_FLAG_FILE = '/data/adb/modules/LuminPro/pid/stop.flag';
|
||||
const LOG_FILE = '/data/adb/modules/LuminPro/service.log';
|
||||
const NOW_BRI_FILE = '/sys/class/backlight/panel0-backlight/brightness';
|
||||
const SYS_MAX_BRI_FILE = '/sys/class/backlight/panel0-backlight/max_brightness';
|
||||
|
||||
// ==========================
|
||||
// 工具函数
|
||||
// ==========================
|
||||
function showToast(msg) {
|
||||
const toast = document.getElementById('toast');
|
||||
toast.textContent = msg;
|
||||
toast.classList.add('show');
|
||||
setTimeout(() => toast.classList.remove('show'), 3000);
|
||||
}
|
||||
|
||||
// 封装的 exec,按需返回真实执行结果
|
||||
async function runCmd(cmd) {
|
||||
try {
|
||||
const res = await exec(cmd);
|
||||
return res;
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
return { errno: -1, stdout: '', stderr: String(e) };
|
||||
}
|
||||
}
|
||||
|
||||
// 写入文件
|
||||
async function writeFile(path, content) {
|
||||
const safeContent = String(content).replace(/'/g, "'\\''");
|
||||
return runCmd(`echo -n '${safeContent}' > "${path}"`);
|
||||
}
|
||||
|
||||
// ==========================
|
||||
// 业务逻辑
|
||||
// ==========================
|
||||
|
||||
// 1. 加载配置
|
||||
async function loadConfig() {
|
||||
const [uiRes, maxRes, sleepRes, autoRes, stepsRes, logSizeRes] = await Promise.all([
|
||||
runCmd(`cat "${CONFIG_DIR}/ui_max_bri.txt"`),
|
||||
runCmd(`cat "${CONFIG_DIR}/max_bri.txt"`),
|
||||
runCmd(`cat "${CONFIG_DIR}/sleep_time.txt"`),
|
||||
runCmd(`cat "${CONFIG_DIR}/auto_bri_sleep.txt"`),
|
||||
runCmd(`cat "${CONFIG_DIR}/steps_num.txt"`),
|
||||
runCmd(`cat "${CONFIG_DIR}/log_max_size.txt"`)
|
||||
]);
|
||||
|
||||
if (uiRes.errno === 0) document.getElementById('input-ui-max-bri').value = uiRes.stdout.trim();
|
||||
if (maxRes.errno === 0) document.getElementById('input-max-bri').value = maxRes.stdout.trim();
|
||||
|
||||
if (sleepRes.errno === 0) {
|
||||
const timeVal = sleepRes.stdout.trim();
|
||||
const modeSwitch = document.getElementById('input-sleep-mode');
|
||||
const expandArea = document.getElementById('sleep-time-expand');
|
||||
|
||||
if(timeVal && timeVal.includes('-')) {
|
||||
modeSwitch.checked = true;
|
||||
expandArea.classList.add('show');
|
||||
const [start, end] = timeVal.split('-');
|
||||
if(start.length === 4) {
|
||||
document.getElementById('input-sleep-start-h').value = start.slice(0, 2);
|
||||
document.getElementById('input-sleep-start-m').value = start.slice(2);
|
||||
}
|
||||
if(end.length === 4) {
|
||||
document.getElementById('input-sleep-end-h').value = end.slice(0, 2);
|
||||
document.getElementById('input-sleep-end-m').value = end.slice(2);
|
||||
}
|
||||
} else {
|
||||
modeSwitch.checked = false;
|
||||
expandArea.classList.remove('show');
|
||||
// 给个可感知的默认显示值
|
||||
document.getElementById('input-sleep-start-h').value = '19';
|
||||
document.getElementById('input-sleep-start-m').value = '00';
|
||||
document.getElementById('input-sleep-end-h').value = '06';
|
||||
document.getElementById('input-sleep-end-m').value = '00';
|
||||
}
|
||||
}
|
||||
|
||||
if (autoRes.errno === 0) document.getElementById('input-auto-bri-sleep').checked = autoRes.stdout.trim() === '1';
|
||||
if (stepsRes.errno === 0) {
|
||||
const v = stepsRes.stdout.trim();
|
||||
document.getElementById('input-steps-num').value = v ? v : '50';
|
||||
} else {
|
||||
document.getElementById('input-steps-num').value = '50';
|
||||
}
|
||||
if (logSizeRes.errno === 0) {
|
||||
const v = logSizeRes.stdout.trim();
|
||||
document.getElementById('input-log-max-size').value = v ? v : '500';
|
||||
} else {
|
||||
document.getElementById('input-log-max-size').value = '500';
|
||||
}
|
||||
}
|
||||
|
||||
// 2. 保存配置并重启服务
|
||||
async function saveConfig() {
|
||||
const uiMax = document.getElementById('input-ui-max-bri').value;
|
||||
const maxBri = document.getElementById('input-max-bri').value;
|
||||
|
||||
const pad = (v) => String(v).padStart(2, '0');
|
||||
const sleepMode = document.getElementById('input-sleep-mode').checked;
|
||||
let sleepTime = "";
|
||||
|
||||
if (sleepMode) {
|
||||
const sH = pad(document.getElementById('input-sleep-start-h').value);
|
||||
const sM = pad(document.getElementById('input-sleep-start-m').value);
|
||||
const eH = pad(document.getElementById('input-sleep-end-h').value);
|
||||
const eM = pad(document.getElementById('input-sleep-end-m').value);
|
||||
sleepTime = `${sH}${sM}-${eH}${eM}`;
|
||||
}
|
||||
|
||||
const autoBriSleep = document.getElementById('input-auto-bri-sleep').checked ? '1' : '0';
|
||||
const stepsNum = document.getElementById('input-steps-num').value || '50';
|
||||
const logMaxSize = document.getElementById('input-log-max-size').value || '500';
|
||||
|
||||
if (!uiMax || !maxBri) {
|
||||
showToast('亮度值不能为空');
|
||||
return;
|
||||
}
|
||||
|
||||
showToast('保存中...');
|
||||
|
||||
// 保存到文件 (若不存在则可能失败,前提是模块已经建立 config 目录)
|
||||
await writeFile(`${CONFIG_DIR}/ui_max_bri.txt`, uiMax);
|
||||
await writeFile(`${CONFIG_DIR}/max_bri.txt`, maxBri);
|
||||
await writeFile(`${CONFIG_DIR}/sleep_time.txt`, sleepTime);
|
||||
await writeFile(`${CONFIG_DIR}/auto_bri_sleep.txt`, autoBriSleep);
|
||||
await writeFile(`${CONFIG_DIR}/steps_num.txt`, stepsNum);
|
||||
await writeFile(`${CONFIG_DIR}/log_max_size.txt`, logMaxSize);
|
||||
|
||||
// 通过写亮度节点一个无变化的值,强制触发 inotifyd 执行 up.sh 以重新读取配置
|
||||
// 注意:需要先清除 flag 以防 up.sh 挂起
|
||||
await runCmd(`rm -f "${FLAG_FILE}"`);
|
||||
|
||||
// 或者最干脆的办法,直接杀掉 inotifyd,然后用模块本来的启动逻辑。
|
||||
// 但是 up.sh 本来就没有后台重启机制,它是通过 inotifyd 重启自己的。
|
||||
// 稳妥起见:
|
||||
const pidRes = await runCmd(`cat "${PID_FILE}"`);
|
||||
if (pidRes.errno === 0 && pidRes.stdout.trim()) {
|
||||
showToast('配置已保存 (可能需要在下次调整时生效)');
|
||||
} else {
|
||||
showToast('配置已保存 (服务未运行)');
|
||||
}
|
||||
}
|
||||
|
||||
// 2.5 恢复默认
|
||||
let isResetConfirming = false;
|
||||
let resetTimer = null;
|
||||
|
||||
function resetRestoreButton() {
|
||||
const btn = document.getElementById('btn-reset');
|
||||
btn.textContent = '恢复默认';
|
||||
btn.classList.remove('btn-danger');
|
||||
isResetConfirming = false;
|
||||
if(resetTimer) clearTimeout(resetTimer);
|
||||
}
|
||||
|
||||
async function handleReset() {
|
||||
const btn = document.getElementById('btn-reset');
|
||||
|
||||
if (!isResetConfirming) {
|
||||
// 进入确认状态
|
||||
isResetConfirming = true;
|
||||
btn.textContent = '确认';
|
||||
btn.classList.add('btn-danger');
|
||||
|
||||
// 5秒后自动重置回原来状态
|
||||
resetTimer = setTimeout(resetRestoreButton, 5000);
|
||||
return;
|
||||
}
|
||||
|
||||
// 执行恢复动作
|
||||
showToast('正在恢复默认配置...');
|
||||
resetRestoreButton();
|
||||
|
||||
// 读取备份 (或者回退到默认逻辑)
|
||||
const [uiRes, maxRes, sleepRes, autoRes, stepsRes, logSizeRes] = await Promise.all([
|
||||
runCmd(`cat "${BACKUP_DIR}/ui_max_bri.txt"`),
|
||||
runCmd(`cat "${BACKUP_DIR}/max_bri.txt"`),
|
||||
runCmd(`cat "${BACKUP_DIR}/sleep_time.txt"`),
|
||||
runCmd(`cat "${BACKUP_DIR}/auto_bri_sleep.txt"`),
|
||||
runCmd(`cat "${BACKUP_DIR}/steps_num.txt"`),
|
||||
runCmd(`cat "${BACKUP_DIR}/log_max_size.txt"`)
|
||||
]);
|
||||
|
||||
// 填入值
|
||||
if (uiRes.errno === 0) document.getElementById('input-ui-max-bri').value = uiRes.stdout.trim();
|
||||
if (maxRes.errno === 0) document.getElementById('input-max-bri').value = maxRes.stdout.trim();
|
||||
|
||||
if (sleepRes.errno === 0) {
|
||||
const tV = sleepRes.stdout.trim();
|
||||
const modeSwitch = document.getElementById('input-sleep-mode');
|
||||
const expandArea = document.getElementById('sleep-time-expand');
|
||||
|
||||
if(tV.includes('-')) {
|
||||
modeSwitch.checked = true;
|
||||
expandArea.classList.add('show');
|
||||
const [s, e] = tV.split('-');
|
||||
if(s.length === 4) {
|
||||
document.getElementById('input-sleep-start-h').value = s.slice(0, 2);
|
||||
document.getElementById('input-sleep-start-m').value = s.slice(2);
|
||||
}
|
||||
if(e.length === 4) {
|
||||
document.getElementById('input-sleep-end-h').value = e.slice(0, 2);
|
||||
document.getElementById('input-sleep-end-m').value = e.slice(2);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
document.getElementById('input-sleep-mode').checked = true;
|
||||
document.getElementById('sleep-time-expand').classList.add('show');
|
||||
document.getElementById('input-sleep-start-h').value = '19';
|
||||
document.getElementById('input-sleep-start-m').value = '00';
|
||||
document.getElementById('input-sleep-end-h').value = '06';
|
||||
document.getElementById('input-sleep-end-m').value = '00';
|
||||
}
|
||||
|
||||
document.getElementById('input-auto-bri-sleep').checked = (autoRes.errno === 0) ? (autoRes.stdout.trim() === '1') : true;
|
||||
document.getElementById('input-steps-num').value = (stepsRes.errno === 0) ? stepsRes.stdout.trim() : '50';
|
||||
document.getElementById('input-log-max-size').value = (logSizeRes.errno === 0) ? logSizeRes.stdout.trim() : '500';
|
||||
|
||||
// 直接触发保存
|
||||
await saveConfig();
|
||||
}
|
||||
|
||||
// 3. 刷新实时状态
|
||||
async function loadStatus() {
|
||||
const [curRes, sysRes, pidRes, stopRes] = await Promise.all([
|
||||
runCmd(`cat "${NOW_BRI_FILE}"`),
|
||||
runCmd(`cat "${SYS_MAX_BRI_FILE}"`),
|
||||
runCmd(`cat "${PID_FILE}"`),
|
||||
runCmd(`[ -f "${STOP_FLAG_FILE}" ] && echo "1" || echo "0"`)
|
||||
]);
|
||||
|
||||
const isPaused = stopRes.stdout.trim() === '1';
|
||||
const running = pidRes.errno === 0 && pidRes.stdout.trim();
|
||||
|
||||
const statusDot = document.querySelector('.header-status .status-dot');
|
||||
const statusText = document.querySelector('.header-status .status-text');
|
||||
const toggleBtn = document.getElementById('btn-toggle-service');
|
||||
|
||||
if (isPaused) {
|
||||
statusDot.style.backgroundColor = 'var(--md-sys-color-error)';
|
||||
statusText.textContent = '已暂停';
|
||||
toggleBtn.textContent = '启用';
|
||||
} else if (running) {
|
||||
statusDot.style.backgroundColor = '#4caf50';
|
||||
statusText.textContent = '运行中';
|
||||
toggleBtn.textContent = '暂停';
|
||||
} else {
|
||||
statusDot.style.backgroundColor = 'var(--md-sys-color-error)';
|
||||
statusText.textContent = '未运行';
|
||||
toggleBtn.textContent = '暂停';
|
||||
}
|
||||
|
||||
// 填入数值
|
||||
document.getElementById('status-current-bri').textContent = curRes.errno === 0 ? curRes.stdout.trim() : '—';
|
||||
document.getElementById('status-sys-max-bri').textContent = sysRes.errno === 0 ? sysRes.stdout.trim() : '—';
|
||||
document.getElementById('status-inotifyd-pid').textContent = running ? pidRes.stdout.trim() : '离线';
|
||||
|
||||
// 简易判断当前休眠状态 (只为了前端展示,不影响后端核心)
|
||||
const isEnabled = document.getElementById('input-sleep-mode').checked;
|
||||
const sH = document.getElementById('input-sleep-start-h').value;
|
||||
const sM = document.getElementById('input-sleep-start-m').value;
|
||||
const eH = document.getElementById('input-sleep-end-h').value;
|
||||
const eM = document.getElementById('input-sleep-end-m').value;
|
||||
let isSleep = false;
|
||||
|
||||
if(isEnabled && sH && sM && eH && eM) {
|
||||
const now = new Date();
|
||||
const nV = now.getHours() * 100 + now.getMinutes();
|
||||
const sNum = parseInt(sH, 10) * 100 + parseInt(sM, 10);
|
||||
const eNum = parseInt(eH, 10) * 100 + parseInt(eM, 10);
|
||||
if (sNum > eNum) {
|
||||
if(nV >= sNum || nV < eNum) isSleep = true;
|
||||
} else if (sNum < eNum) {
|
||||
if(nV >= sNum && nV < eNum) isSleep = true;
|
||||
}
|
||||
}
|
||||
document.getElementById('status-sleep').textContent = isSleep ? '休眠中' : '非休眠';
|
||||
}
|
||||
|
||||
// 6. 暂停/启用服务
|
||||
async function toggleService() {
|
||||
const res = await runCmd(`sh /data/adb/modules/LuminPro/action.sh`);
|
||||
if (res.errno === 0) {
|
||||
showToast(res.stdout.trim() || '状态已切换');
|
||||
} else {
|
||||
showToast('操作失败: ' + res.stderr);
|
||||
}
|
||||
await loadStatus();
|
||||
}
|
||||
async function restartService() {
|
||||
const btn = document.getElementById('btn-restart-service');
|
||||
|
||||
showToast('正在重启服务...');
|
||||
btn.disabled = true;
|
||||
|
||||
// 执行重启脚本
|
||||
const res = await runCmd(`sh /data/adb/modules/LuminPro/script/restart.sh`);
|
||||
|
||||
if (res.errno === 0) {
|
||||
showToast('服务已成功重启');
|
||||
} else {
|
||||
showToast('重启失败: ' + res.stderr);
|
||||
}
|
||||
|
||||
// 延迟刷新状态以确保 PID 文件已写入
|
||||
setTimeout(async () => {
|
||||
await loadStatus();
|
||||
btn.disabled = false;
|
||||
}, 1000);
|
||||
}
|
||||
async function loadLogs() {
|
||||
const logEl = document.getElementById('log-output');
|
||||
// 读取最后 50 行日志
|
||||
const res = await runCmd(`tail -n 50 "${LOG_FILE}"`);
|
||||
if (res.errno === 0) {
|
||||
const freshLog = res.stdout.trim() || '暂无日志';
|
||||
// 只有当日志内容变化时才更新 DOM, 减少闪烁
|
||||
if(logEl.textContent !== freshLog) {
|
||||
logEl.textContent = freshLog;
|
||||
logEl.scrollTop = logEl.scrollHeight;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 自动刷新循环
|
||||
async function startAutoRefresh() {
|
||||
await Promise.all([loadStatus(), loadLogs()]);
|
||||
setTimeout(startAutoRefresh, 500); // 0.5s 周期
|
||||
}
|
||||
|
||||
// ==========================
|
||||
// 初始化
|
||||
// ==========================
|
||||
async function init() {
|
||||
|
||||
// 初始化 Lucide 图标
|
||||
createIcons({
|
||||
icons: {
|
||||
Sun,
|
||||
Settings,
|
||||
Save,
|
||||
Activity,
|
||||
RefreshCw,
|
||||
FileText
|
||||
}
|
||||
});
|
||||
|
||||
// 绑定事件
|
||||
document.getElementById('btn-save').addEventListener('click', saveConfig);
|
||||
document.getElementById('btn-reset').addEventListener('click', handleReset);
|
||||
document.getElementById('btn-toggle-service').addEventListener('click', toggleService);
|
||||
document.getElementById('btn-restart-service').addEventListener('click', restartService);
|
||||
|
||||
// 定时休眠折叠逻辑
|
||||
document.getElementById('input-sleep-mode').addEventListener('change', (e) => {
|
||||
const expandArea = document.getElementById('sleep-time-expand');
|
||||
if (e.target.checked) {
|
||||
expandArea.classList.add('show');
|
||||
} else {
|
||||
expandArea.classList.remove('show');
|
||||
}
|
||||
});
|
||||
|
||||
// 初次加载配置
|
||||
await loadConfig();
|
||||
// 开启自动刷新状态和日志 (内置了已包含 loadStatus 和 loadLogs)
|
||||
startAutoRefresh();
|
||||
}
|
||||
|
||||
// DOM 加载完成后运行
|
||||
document.addEventListener('DOMContentLoaded', init);
|
||||
-476
@@ -1,476 +0,0 @@
|
||||
:root {
|
||||
--md-sys-color-background: #111318;
|
||||
--md-sys-color-on-background: #e2e2e9;
|
||||
--md-sys-color-surface: #1e1f25;
|
||||
--md-sys-color-surface-container: #212429;
|
||||
--md-sys-color-surface-container-high: #2b2930;
|
||||
--md-sys-color-on-surface: #e2e2e9;
|
||||
--md-sys-color-on-surface-variant: #c4c6d0;
|
||||
--md-sys-color-primary: #a8c7fa;
|
||||
--md-sys-color-on-primary: #062e6f;
|
||||
--md-sys-color-primary-container: #1b4b9b;
|
||||
--md-sys-color-on-primary-container: #d3e3fd;
|
||||
--md-sys-color-outline: #8e9099;
|
||||
--md-sys-color-outline-variant: #44474f;
|
||||
--md-sys-color-error: #ffb4ab;
|
||||
--md-sys-color-on-error: #690005;
|
||||
|
||||
--border-radius-m: 16px;
|
||||
--border-radius-s: 8px;
|
||||
--spacing-s: 8px;
|
||||
--spacing-m: 16px;
|
||||
--spacing-l: 24px;
|
||||
}
|
||||
|
||||
@font-face {
|
||||
font-family: 'Geist';
|
||||
src: url('/Geist-VariableFont_wght.ttf') format('truetype');
|
||||
font-weight: 100 900;
|
||||
font-style: normal;
|
||||
}
|
||||
|
||||
@font-face {
|
||||
font-family: 'Google Sans Code';
|
||||
src: url('/GoogleSansCode-VariableFont_wght.ttf') format('truetype');
|
||||
font-weight: 100 900;
|
||||
font-style: normal;
|
||||
}
|
||||
|
||||
* {
|
||||
box-sizing: border-box;
|
||||
-webkit-tap-highlight-color: transparent;
|
||||
}
|
||||
|
||||
body {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
/* 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;
|
||||
}
|
||||
|
||||
#app {
|
||||
padding: var(--spacing-m);
|
||||
max-width: 600px;
|
||||
margin: 0 auto;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: var(--spacing-m);
|
||||
}
|
||||
|
||||
/* Header */
|
||||
.app-header {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
padding: var(--spacing-m) 0;
|
||||
}
|
||||
|
||||
.header-content {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: var(--spacing-m);
|
||||
}
|
||||
|
||||
.header-icon {
|
||||
font-size: 2rem;
|
||||
background: var(--md-sys-color-surface-container-high);
|
||||
width: 48px;
|
||||
height: 48px;
|
||||
border-radius: 50%;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
.header-text h1 {
|
||||
margin: 0;
|
||||
font-size: 1.25rem;
|
||||
font-weight: 500;
|
||||
color: var(--md-sys-color-on-background);
|
||||
}
|
||||
|
||||
.header-subtitle {
|
||||
margin: 0;
|
||||
font-size: 0.875rem;
|
||||
color: var(--md-sys-color-on-surface-variant);
|
||||
}
|
||||
|
||||
.header-status {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 6px;
|
||||
background: var(--md-sys-color-surface-container);
|
||||
padding: 4px 12px;
|
||||
border-radius: 100px;
|
||||
font-size: 0.875rem;
|
||||
}
|
||||
|
||||
.status-dot {
|
||||
width: 8px;
|
||||
height: 8px;
|
||||
border-radius: 50%;
|
||||
background-color: var(--md-sys-color-error); /* 默认离线红色,在线动态改为绿色 #4caf50 */
|
||||
}
|
||||
|
||||
/* 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);
|
||||
}
|
||||
|
||||
.card-header {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: var(--spacing-s);
|
||||
margin-bottom: var(--spacing-l);
|
||||
}
|
||||
|
||||
.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-bottom: var(--spacing-l);
|
||||
padding: var(--spacing-m);
|
||||
background-color: var(--md-sys-color-surface-container);
|
||||
border-radius: var(--border-radius-s);
|
||||
}
|
||||
|
||||
.group-title {
|
||||
margin: 0 0 var(--spacing-m) 0;
|
||||
font-size: 0.875rem;
|
||||
font-weight: 600;
|
||||
color: var(--md-sys-color-primary);
|
||||
text-transform: uppercase;
|
||||
letter-spacing: 0.5px;
|
||||
}
|
||||
|
||||
.config-item {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.config-item + .config-item {
|
||||
margin-top: var(--spacing-m);
|
||||
}
|
||||
|
||||
.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 {
|
||||
background-color: var(--md-sys-color-surface-container-high);
|
||||
color: var(--md-sys-color-on-surface);
|
||||
border: 1px solid var(--md-sys-color-outline);
|
||||
border-radius: var(--border-radius-s);
|
||||
padding: 8px 12px;
|
||||
font-size: 1rem;
|
||||
width: 100px;
|
||||
text-align: right;
|
||||
font-family: inherit;
|
||||
outline: none;
|
||||
transition: border-color 0.2s, box-shadow 0.2s;
|
||||
}
|
||||
|
||||
.config-input:focus {
|
||||
border-color: var(--md-sys-color-primary);
|
||||
box-shadow: 0 0 0 2px rgba(168, 199, 250, 0.3);
|
||||
}
|
||||
|
||||
.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: 'Google Sans Code', monospace;
|
||||
outline: none;
|
||||
-moz-appearance: textfield;
|
||||
}
|
||||
|
||||
.time-input::-webkit-outer-spin-button,
|
||||
.time-input::-webkit-inner-spin-button {
|
||||
-webkit-appearance: none;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.time-sep {
|
||||
color: var(--md-sys-color-on-surface-variant);
|
||||
font-size: 0.875rem;
|
||||
}
|
||||
|
||||
/* Switch Styles */
|
||||
.switch {
|
||||
position: relative;
|
||||
display: inline-block;
|
||||
width: 52px;
|
||||
height: 32px;
|
||||
}
|
||||
|
||||
.switch input {
|
||||
opacity: 0;
|
||||
width: 0;
|
||||
height: 0;
|
||||
}
|
||||
|
||||
.slider {
|
||||
position: absolute;
|
||||
cursor: pointer;
|
||||
top: 0;
|
||||
left: 0;
|
||||
right: 0;
|
||||
bottom: 0;
|
||||
background-color: var(--md-sys-color-surface-container-high);
|
||||
transition: .4s;
|
||||
border-radius: 34px;
|
||||
border: 2px solid var(--md-sys-color-outline);
|
||||
}
|
||||
|
||||
.slider:before {
|
||||
position: absolute;
|
||||
content: "";
|
||||
height: 24px;
|
||||
width: 24px;
|
||||
left: 2px;
|
||||
bottom: 2px;
|
||||
background-color: var(--md-sys-color-outline);
|
||||
transition: .4s;
|
||||
border-radius: 50%;
|
||||
}
|
||||
|
||||
input:checked + .slider {
|
||||
background-color: var(--md-sys-color-primary-container);
|
||||
border-color: var(--md-sys-color-primary);
|
||||
}
|
||||
|
||||
input:checked + .slider:before {
|
||||
transform: translateX(20px);
|
||||
background-color: var(--md-sys-color-primary);
|
||||
}
|
||||
|
||||
/* Status Grid */
|
||||
.status-grid {
|
||||
display: grid;
|
||||
grid-template-columns: 1fr 1fr;
|
||||
gap: var(--spacing-m);
|
||||
}
|
||||
|
||||
.status-item {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
background-color: var(--md-sys-color-surface-container);
|
||||
padding: var(--spacing-m);
|
||||
border-radius: var(--border-radius-s);
|
||||
}
|
||||
|
||||
.status-label {
|
||||
font-size: 0.75rem;
|
||||
color: var(--md-sys-color-on-surface-variant);
|
||||
margin-bottom: 4px;
|
||||
}
|
||||
|
||||
.status-value {
|
||||
font-size: 1.125rem;
|
||||
font-weight: 500;
|
||||
color: var(--md-sys-color-primary);
|
||||
word-break: break-all;
|
||||
}
|
||||
|
||||
/* Actions */
|
||||
.card-actions {
|
||||
display: flex;
|
||||
justify-content: flex-end;
|
||||
gap: 12px;
|
||||
margin-top: var(--spacing-l);
|
||||
padding-top: var(--spacing-m);
|
||||
border-top: 1px solid var(--md-sys-color-outline-variant);
|
||||
}
|
||||
|
||||
/* 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:active {
|
||||
background-color: var(--md-sys-color-surface-container-high);
|
||||
}
|
||||
|
||||
.animate-spin {
|
||||
animation: spin 1s linear infinite;
|
||||
}
|
||||
|
||||
@keyframes spin {
|
||||
from { transform: rotate(0deg); }
|
||||
to { transform: rotate(360deg); }
|
||||
}
|
||||
|
||||
/* Logs */
|
||||
.log-output {
|
||||
font-family: 'Google Sans Code', 'Consolas', 'Courier New', monospace;
|
||||
font-size: 0.75rem;
|
||||
padding: var(--spacing-s);
|
||||
border-radius: var(--border-radius-s);
|
||||
height: 200px;
|
||||
overflow-y: auto;
|
||||
margin: 0;
|
||||
white-space: pre-wrap;
|
||||
word-wrap: break-word;
|
||||
}
|
||||
|
||||
/* Simple Toast */
|
||||
.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);
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"versionCode": 2050054,
|
||||
"version": "V2.5.0-beta.4",
|
||||
"zipUrl": "https://github.com/YuleBest/LuminPro/releases/download/v2.5.0-beta.4/LuminPro_V2.5.0-beta.4.zip",
|
||||
"changelog": "https://raw.githubusercontent.com/YuleBest/LuminPro/beta/changelog.md"
|
||||
}
|
||||
+5
-5
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"versionCode": 2202,
|
||||
"version": "V2.2",
|
||||
"zipUrl": "https://share.yule.ink/magisk/mod/luminpro/module/LuminPro_V2.2-2202.zip",
|
||||
"changelog": "https://share.yule.ink/magisk/mod/luminpro/changelog.md"
|
||||
}
|
||||
"versionCode": 2401,
|
||||
"version": "V2.4-2401",
|
||||
"zipUrl": "https://github.com/YuleBest/LuminPro/releases/download/v2.4-2401/LuminPro_V2.4-2401-f2c489e.zip",
|
||||
"changelog": "https://raw.githubusercontent.com/YuleBest/LuminPro/main/changelog.md"
|
||||
}
|
||||
@@ -1,8 +0,0 @@
|
||||
import { defineConfig } from 'vite';
|
||||
|
||||
export default defineConfig({
|
||||
build: {
|
||||
outDir: 'webroot',
|
||||
emptyOutDir: true,
|
||||
},
|
||||
});
|
||||
Binary file not shown.
Binary file not shown.
@@ -1 +0,0 @@
|
||||
:root{--md-sys-color-background:#111318;--md-sys-color-on-background:#e2e2e9;--md-sys-color-surface:#1e1f25;--md-sys-color-surface-container:#212429;--md-sys-color-surface-container-high:#2b2930;--md-sys-color-on-surface:#e2e2e9;--md-sys-color-on-surface-variant:#c4c6d0;--md-sys-color-primary:#a8c7fa;--md-sys-color-on-primary:#062e6f;--md-sys-color-primary-container:#1b4b9b;--md-sys-color-on-primary-container:#d3e3fd;--md-sys-color-outline:#8e9099;--md-sys-color-outline-variant:#44474f;--md-sys-color-error:#ffb4ab;--md-sys-color-on-error:#690005;--border-radius-m:16px;--border-radius-s:8px;--spacing-s:8px;--spacing-m:16px;--spacing-l:24px}@font-face{font-family:Geist;src:url(/Geist-VariableFont_wght.ttf)format("truetype");font-weight:100 900;font-style:normal}@font-face{font-family:Google Sans Code;src:url(/GoogleSansCode-VariableFont_wght.ttf)format("truetype");font-weight:100 900;font-style:normal}*{box-sizing:border-box;-webkit-tap-highlight-color:transparent}body{padding:0;padding-top:var(--safe-area-inset-top,0);padding-bottom:var(--safe-area-inset-bottom,0);background-color:var(--md-sys-color-background);color:var(--md-sys-color-on-background);margin:0;font-family:Geist,system-ui,-apple-system,sans-serif;line-height:1.5}#app{padding:var(--spacing-m);gap:var(--spacing-m);flex-direction:column;max-width:600px;margin:0 auto;display:flex}.app-header{padding:var(--spacing-m) 0;justify-content:space-between;align-items:center;display:flex}.header-content{align-items:center;gap:var(--spacing-m);display:flex}.header-icon{background:var(--md-sys-color-surface-container-high);border-radius:50%;justify-content:center;align-items:center;width:48px;height:48px;font-size:2rem;display:flex}.header-text h1{color:var(--md-sys-color-on-background);margin:0;font-size:1.25rem;font-weight:500}.header-subtitle{color:var(--md-sys-color-on-surface-variant);margin:0;font-size:.875rem}.header-status{background:var(--md-sys-color-surface-container);border-radius:100px;align-items:center;gap:6px;padding:4px 12px;font-size:.875rem;display:flex}.status-dot{background-color:var(--md-sys-color-error);border-radius:50%;width:8px;height:8px}.card{background-color:var(--md-sys-color-surface);border-radius:var(--border-radius-m);padding:var(--spacing-l);box-shadow:0 1px 3px #0000004d,0 4px 8px 3px #00000026}.card-header{align-items:center;gap:var(--spacing-s);margin-bottom:var(--spacing-l);display:flex}.card-header h2{color:var(--md-sys-color-on-surface);flex-grow:1;margin:0;font-size:1.125rem;font-weight:500}.config-group{margin-bottom:var(--spacing-l);padding:var(--spacing-m);background-color:var(--md-sys-color-surface-container);border-radius:var(--border-radius-s)}.group-title{margin:0 0 var(--spacing-m) 0;color:var(--md-sys-color-primary);text-transform:uppercase;letter-spacing:.5px;font-size:.875rem;font-weight:600}.config-item{justify-content:space-between;align-items:center;display:flex}.config-item+.config-item{margin-top:var(--spacing-m)}.config-label{flex-direction:column;display:flex}.config-name{color:var(--md-sys-color-on-surface);font-size:1rem}.config-desc{color:var(--md-sys-color-on-surface-variant);font-size:.875rem}.config-input{background-color:var(--md-sys-color-surface-container-high);color:var(--md-sys-color-on-surface);border:1px solid var(--md-sys-color-outline);border-radius:var(--border-radius-s);text-align:right;outline:none;width:100px;padding:8px 12px;font-family:inherit;font-size:1rem;transition:border-color .2s,box-shadow .2s}.config-input:focus{border-color:var(--md-sys-color-primary);box-shadow:0 0 0 2px #a8c7fa4d}.config-input-wide{width:140px}.config-item-expand{margin-top:var(--spacing-s);opacity:0;justify-content:flex-end;max-height:0;transition:all .3s;display:flex;overflow:hidden}.config-item-expand.show{opacity:1;max-height:100px;margin-bottom:var(--spacing-m)}.custom-time-picker{align-items:center;gap:8px;display:flex}.time-unit{background-color:var(--md-sys-color-surface-container-high);border-radius:var(--border-radius-s);border:1px solid var(--md-sys-color-outline);align-items:center;gap:2px;padding:2px 6px;display:flex}.time-input{width:32px;color:var(--md-sys-color-on-surface);text-align:center;-moz-appearance:textfield;background-color:#0000;border:none;outline:none;font-family:Google Sans Code,monospace;font-size:.875rem}.time-input::-webkit-outer-spin-button{-webkit-appearance:none;margin:0}.time-input::-webkit-inner-spin-button{-webkit-appearance:none;margin:0}.time-sep{color:var(--md-sys-color-on-surface-variant);font-size:.875rem}.switch{width:52px;height:32px;display:inline-block;position:relative}.switch input{opacity:0;width:0;height:0}.slider{cursor:pointer;background-color:var(--md-sys-color-surface-container-high);border:2px solid var(--md-sys-color-outline);border-radius:34px;transition:all .4s;position:absolute;inset:0}.slider:before{content:"";background-color:var(--md-sys-color-outline);border-radius:50%;width:24px;height:24px;transition:all .4s;position:absolute;bottom:2pxLine truncated
|
||||
@@ -1,4 +0,0 @@
|
||||
(function(){let e=document.createElement(`link`).relList;if(e&&e.supports&&e.supports(`modulepreload`))return;for(let e of document.querySelectorAll(`link[rel="modulepreload"]`))n(e);new MutationObserver(e=>{for(let t of e)if(t.type===`childList`)for(let e of t.addedNodes)e.tagName===`LINK`&&e.rel===`modulepreload`&&n(e)}).observe(document,{childList:!0,subtree:!0});function t(e){let t={};return e.integrity&&(t.integrity=e.integrity),e.referrerPolicy&&(t.referrerPolicy=e.referrerPolicy),e.crossOrigin===`use-credentials`?t.credentials=`include`:e.crossOrigin===`anonymous`?t.credentials=`omit`:t.credentials=`same-origin`,t}function n(e){if(e.ep)return;e.ep=!0;let n=t(e);fetch(e.href,n)}})();var e=0;function t(t){return`${t}_callback_${Date.now()}_${e++}`}function n(e,n){return n===void 0&&(n={}),new Promise((r,i)=>{let a=t(`exec`);window[a]=(e,t,n)=>{r({errno:e,stdout:t,stderr:n}),o(a)};function o(e){delete window[e]}try{ksu.exec(e,JSON.stringify(n),a)}catch(e){i(e),o(a)}})}function r(){this.listeners={}}r.prototype.on=function(e,t){this.listeners[e]||(this.listeners[e]=[]),this.listeners[e].push(t)},r.prototype.emit=function(e,...t){this.listeners[e]&&this.listeners[e].forEach(e=>e(...t))};function i(){this.listeners={},this.stdin=new r,this.stdout=new r,this.stderr=new r}i.prototype.on=function(e,t){this.listeners[e]||(this.listeners[e]=[]),this.listeners[e].push(t)},i.prototype.emit=function(e,...t){this.listeners[e]&&this.listeners[e].forEach(e=>e(...t))};var a={xmlns:`http://www.w3.org/2000/svg`,width:24,height:24,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,"stroke-width":2,"stroke-linecap":`round`,"stroke-linejoin":`round`},o=([e,t,n])=>{let r=document.createElementNS(`http://www.w3.org/2000/svg`,e);return Object.keys(t).forEach(e=>{r.setAttribute(e,String(t[e]))}),n?.length&&n.forEach(e=>{let t=o(e);r.appendChild(t)}),r},s=(e,t={})=>o([`svg`,{...a,...t},e]),c=e=>{for(let t in e)if(t.startsWith(`aria-`)||t===`role`||t===`title`)return!0;return!1},l=(...e)=>e.filter((e,t,n)=>!!e&&e.trim()!==``&&n.indexOf(e)===t).join(` `).trim(),u=e=>e.replace(/^([A-Z])|[\s-_]+(\w)/g,(e,t,n)=>n?n.toUpperCase():t.toLowerCase()),d=e=>{let t=u(e);return t.charAt(0).toUpperCase()+t.slice(1)},f=e=>Array.from(e.attributes).reduce((e,t)=>(e[t.name]=t.value,e),{}),p=e=>typeof e==`string`?e:!e||!e.class?``:e.class&&typeof e.class==`string`?e.class.split(` `):e.class&&Array.isArray(e.class)?e.class:``,m=(e,{nameAttr:t,icons:n,attrs:r})=>{let i=e.getAttribute(t);if(i==null)return;let o=n[d(i)];if(!o)return console.warn(`${e.outerHTML} icon name was not found in the provided icons object.`);let u=f(e),m=c(u)?{}:{"aria-hidden":`true`},h={...a,"data-lucide":i,...m,...r,...u},g=p(u),_=p(r),v=l(`lucide`,`lucide-${i}`,...g,..._);v&&Object.assign(h,{class:v});let y=s(o,h);return e.parentNode?.replaceChild(y,e)},h=[[`path`,{d:`M22 12h-2.48a2 2 0 0 0-1.93 1.46l-2.35 8.36a.25.25 0 0 1-.48 0L9.24 2.18a.25.25 0 0 0-.48 0l-2.35 8.36A2 2 0 0 1 4.49 12H2`}]],g=[[`path`,{d:`M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`}],[`path`,{d:`M10 9H8`}],[`path`,{d:`M16 13H8`}],[`path`,{d:`M16 17H8`}]],_=[[`path`,{d:`M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8`}],[`path`,{d:`M21 3v5h-5`}],[`path`,{d:`M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16`}],[`path`,{d:`M8 16H3v5`}]],v=[[`path`,{d:`M15.2 3a2 2 0 0 1 1.4.6l3.8 3.8a2 2 0 0 1 .6 1.4V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2z`}],[`path`,{d:`M17 21v-7a1 1 0 0 0-1-1H8a1 1 0 0 0-1 1v7`}],[`path`,{d:`M7 3v4a1 1 0 0 0 1 1h7`}]],y=[[`path`,{d:`M9.671 4.136a2.34 2.34 0 0 1 4.659 0 2.34 2.34 0 0 0 3.319 1.915 2.34 2.34 0 0 1 2.33 4.033 2.34 2.34 0 0 0 0 3.831 2.34 2.34 0 0 1-2.33 4.033 2.34 2.34 0 0 0-3.319 1.915 2.34 2.34 0 0 1-4.659 0 2.34 2.34 0 0 0-3.32-1.915 2.34 2.34 0 0 1-2.33-4.033 2.34 2.34 0 0 0 0-3.831A2.34 2.34 0 0 1 6.35 6.051a2.34 2.34 0 0 0 3.319-1.915`}],[`circle`,{cx:`12`,cy:`12`,r:`3`}]],b=[[`circle`,{cx:`12`,cy:`12`,r:`4`}],[`path`,{d:`M12 2v2`}],[`path`,{d:`M12 20v2`}],[`path`,{d:`m4.93 4.93 1.41 1.41`}],[`path`,{d:`m17.66 17.66 1.41 1.41`}],[`path`,{d:`M2 12h2`}],[`path`,{d:`M20 12h2`}],[`path`,{d:`m6.34 17.66-1.41 1.41`}],[`path`,{d:`m19.07 4.93-1.41 1.41`}]],x=({icons:e={},nameAttr:t=`data-lucide`,attrs:n={},root:r=document,inTemplates:i}={})=>{if(!Object.values(e).length)throw Error(`Please provide an icons object.
|
||||
If you want to use all the icons you can import it like:
|
||||
\`import { createIcons, icons } from 'lucide';
|
||||
lucide.createIcons({icons});\``);if(r===void 0)throw Error("`createIcons()` only works in a browser environment.");if(Array.from(r.querySelectorAll(`[${t}]`)).forEach(r=>m(r,{nameAttr:t,icons:e,attrs:n})),i&&Array.from(r.querySelectorAll(`template`)).forEach(r=>x({icons:e,nameAttr:t,attrs:n,root:r.content,inTemplates:i})),t===`data-lucide`){let t=r.querySelectorAll(`[icon-name]`);t.length>0&&(console.warn(`[Lucide] Some icons were found with the now deprecated icon-name attribute. These will still be replaced for backwards compatibility, but will no longer be supported in v1.0 and you should switch to data-lucide`),Array.from(t).forEach(t=>m(t,{nameAttr:`icon-name`,icons:e,attrs:n})))}},S=`/data/adb/modules/LuminPro/config`,C=`/data/adb/modules/LuminPro/config/.backup`,w=`/data/adb/modules/LuminPro/pid/inotifyd.pid`,T=`/data/adb/modules/LuminPro/pid/up.flag`,E=`/data/adb/modules/LuminPro/pid/stop.flag`,D=`/data/adb/modules/LuminPro/service.log`,O=`/sys/class/backlight/panel0-backlight/brightness`,k=`/sys/class/backlight/panel0-backlight/max_brightness`;function A(e){let t=document.getElementById(`toast`);t.textContent=e,t.classList.add(`show`),setTimeout(()=>t.classList.remove(`show`),3e3)}async function j(e){try{return await n(e)}catch(e){return console.error(e),{errno:-1,stdout:``,stderr:String(e)}}}async function M(e,t){return j(`echo -n '${String(t).replace(/'/g,`'\\''`)}' > "${e}"`)}async function N(){let[e,t,n,r,i,a]=await Promise.all([j(`cat "${S}/ui_max_bri.txt"`),j(`cat "${S}/max_bri.txt"`),j(`cat "${S}/sleep_time.txt"`),j(`cat "${S}/auto_bri_sleep.txt"`),j(`cat "${S}/steps_num.txt"`),j(`cat "${S}/log_max_size.txt"`)]);if(e.errno===0&&(document.getElementById(`input-ui-max-bri`).value=e.stdout.trim()),t.errno===0&&(document.getElementById(`input-max-bri`).value=t.stdout.trim()),n.errno===0){let e=n.stdout.trim(),t=document.getElementById(`input-sleep-mode`),r=document.getElementById(`sleep-time-expand`);if(e&&e.includes(`-`)){t.checked=!0,r.classList.add(`show`);let[n,i]=e.split(`-`);n.length===4&&(document.getElementById(`input-sleep-start-h`).value=n.slice(0,2),document.getElementById(`input-sleep-start-m`).value=n.slice(2)),i.length===4&&(document.getElementById(`input-sleep-end-h`).value=i.slice(0,2),document.getElementById(`input-sleep-end-m`).value=i.slice(2))}else t.checked=!1,r.classList.remove(`show`),document.getElementById(`input-sleep-start-h`).value=`19`,document.getElementById(`input-sleep-start-m`).value=`00`,document.getElementById(`input-sleep-end-h`).value=`06`,document.getElementById(`input-sleep-end-m`).value=`00`}if(r.errno===0&&(document.getElementById(`input-auto-bri-sleep`).checked=r.stdout.trim()===`1`),i.errno===0){let e=i.stdout.trim();document.getElementById(`input-steps-num`).value=e||`50`}else document.getElementById(`input-steps-num`).value=`50`;if(a.errno===0){let e=a.stdout.trim();document.getElementById(`input-log-max-size`).value=e||`500`}else document.getElementById(`input-log-max-size`).value=`500`}async function P(){let e=document.getElementById(`input-ui-max-bri`).value,t=document.getElementById(`input-max-bri`).value,n=e=>String(e).padStart(2,`0`),r=document.getElementById(`input-sleep-mode`).checked,i=``;r&&(i=`${n(document.getElementById(`input-sleep-start-h`).value)}${n(document.getElementById(`input-sleep-start-m`).value)}-${n(document.getElementById(`input-sleep-end-h`).value)}${n(document.getElementById(`input-sleep-end-m`).value)}`);let a=document.getElementById(`input-auto-bri-sleep`).checked?`1`:`0`,o=document.getElementById(`input-steps-num`).value||`50`,s=document.getElementById(`input-log-max-size`).value||`500`;if(!e||!t){A(`亮度值不能为空`);return}A(`保存中...`),await M(`${S}/ui_max_bri.txt`,e),await M(`${S}/max_bri.txt`,t),await M(`${S}/sleep_time.txt`,i),await M(`${S}/auto_bri_sleep.txt`,a),await M(`${S}/steps_num.txt`,o),await M(`${S}/log_max_size.txt`,s),await j(`rm -f "${T}"`);let c=await j(`cat "${w}"`);c.errno===0&&c.stdout.trim()?A(`配置已保存 (可能需要在下次调整时生效)`):A(`配置已保存 (服务未运行)`)}var F=!1,I=null;function L(){let e=document.getElementById(`btn-reset`);e.textContent=`恢复默认`,e.classList.remove(`btn-danger`),F=!1,I&&clearTimeout(I)}async function R(){let e=document.getElementById(`btn-reset`);if(!F){F=!0,e.textContent=`确认`,e.classList.add(`btn-danger`),I=setTimeout(L,5e3);return}A(`正在恢复默认配置...`),L();let[t,n,r,i,a,o]=await Promise.all([j(`cat "${C}/ui_max_bri.txt"`),j(`cat "${C}/max_bri.txt"`),j(`cat "${C}/sleep_time.txt"`),j(`cat "${C}/auto_bri_sleep.txt"`),j(`cat "${C}/steps_num.txt"`),j(`cat "${C}/log_max_size.txt"`)]);if(t.errno===0&&(document.getElementById(`input-ui-max-bri`).value=t.stdout.trim()),n.errno===0&&(document.getElementById(`input-max-bri`).value=n.stdout.trim()),r.errno===0){let e=r.stdout.trim(),t=document.getElementById(`input-sleep-mode`),n=document.getElementById(`sleep-time-expand`);if(e.includes(`-`)){t.checked=!0,n.classList.add(`sh
Line truncated
|
||||
@@ -1,183 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="zh-CN">
|
||||
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no" />
|
||||
<title>LuminPro</title>
|
||||
<link rel="stylesheet" type="text/css" href="/internal/insets.css" />
|
||||
<script type="module" crossorigin src="/assets/index-GvCaVVmw.js"></script>
|
||||
<link rel="stylesheet" crossorigin href="/assets/index-DpSbbGTK.css">
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div id="app">
|
||||
<!-- 顶部头 -->
|
||||
<header class="app-header">
|
||||
<div class="header-content">
|
||||
<div class="header-icon"><i data-lucide="sun"></i></div>
|
||||
<div class="header-text">
|
||||
<h1>LuminPro</h1>
|
||||
<p class="header-subtitle" id="module-version">日用屏幕亮度强化</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="header-status" id="module-status">
|
||||
<span class="status-dot"></span>
|
||||
<span class="status-text">运行中</span>
|
||||
</div>
|
||||
</header>
|
||||
|
||||
<!-- 配置卡片 -->
|
||||
<section class="card" id="config-section">
|
||||
<div class="card-header">
|
||||
<span class="card-icon"><i data-lucide="settings"></i></span>
|
||||
<h2>亮度配置</h2>
|
||||
</div>
|
||||
|
||||
<!-- 分类: 亮度调节 -->
|
||||
<div class="config-group">
|
||||
<h3 class="group-title">亮度调节</h3>
|
||||
<div class="config-item">
|
||||
<div class="config-label">
|
||||
<span class="config-name">前台最大亮度</span>
|
||||
<span class="config-desc">触发亮度提升的阈值</span>
|
||||
</div>
|
||||
<div class="config-value">
|
||||
<input type="number" id="input-ui-max-bri" class="config-input" min="0" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="config-item">
|
||||
<div class="config-label">
|
||||
<span class="config-name">峰值最大亮度</span>
|
||||
<span class="config-desc">亮度提升的目标值</span>
|
||||
</div>
|
||||
<div class="config-value">
|
||||
<input type="number" id="input-max-bri" class="config-input" min="0" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="config-item">
|
||||
<div class="config-label">
|
||||
<span class="config-name">亮度提升步数</span>
|
||||
<span class="config-desc">约 0.02 秒 / 步</span>
|
||||
</div>
|
||||
<div class="config-value">
|
||||
<input type="number" id="input-steps-num" class="config-input" min="1" max="500" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 分类: 执行策略 -->
|
||||
<div class="config-group">
|
||||
<h3 class="group-title">执行策略</h3>
|
||||
<div class="config-item">
|
||||
<div class="config-label">
|
||||
<span class="config-name">自动亮度时休眠</span>
|
||||
<span class="config-desc">开启自动亮度时不提升</span>
|
||||
</div>
|
||||
<div class="config-value">
|
||||
<label class="switch">
|
||||
<input type="checkbox" id="input-auto-bri-sleep">
|
||||
<span class="slider"></span>
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
<div class="config-item">
|
||||
<div class="config-label">
|
||||
<span class="config-name">定时休眠</span>
|
||||
<span class="config-desc">设定时段内不提升亮度</span>
|
||||
</div>
|
||||
<div class="config-value">
|
||||
<label class="switch">
|
||||
<input type="checkbox" id="input-sleep-mode">
|
||||
<span class="slider"></span>
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
<div class="config-item-expand" id="sleep-time-expand">
|
||||
<div class="custom-time-picker">
|
||||
<div class="time-unit">
|
||||
<input type="number" id="input-sleep-start-h" class="time-input" min="0" max="23" placeholder="00" />
|
||||
<span>:</span>
|
||||
<input type="number" id="input-sleep-start-m" class="time-input" min="0" max="59" placeholder="00" />
|
||||
</div>
|
||||
<span class="time-sep">至</span>
|
||||
<div class="time-unit">
|
||||
<input type="number" id="input-sleep-end-h" class="time-input" min="0" max="23" placeholder="00" />
|
||||
<span>:</span>
|
||||
<input type="number" id="input-sleep-end-m" class="time-input" min="0" max="59" placeholder="00" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 分类: 系统管理 -->
|
||||
<div class="config-group">
|
||||
<h3 class="group-title">系统管理</h3>
|
||||
<div class="config-item">
|
||||
<div class="config-label">
|
||||
<span class="config-name">日志大小限制</span>
|
||||
<span class="config-desc">单位: KB</span>
|
||||
</div>
|
||||
<div class="config-value">
|
||||
<input type="number" id="input-log-max-size" class="config-input" min="1" max="10240" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="card-actions">
|
||||
<button class="btn btn-outline" id="btn-reset">
|
||||
恢复默认
|
||||
</button>
|
||||
<button class="btn btn-primary" id="btn-save">
|
||||
<span class="btn-icon"><i data-lucide="save"></i></span> 保存配置
|
||||
</button>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<!-- 实时状态 -->
|
||||
<section class="card" id="status-section">
|
||||
<div class="card-header">
|
||||
<span class="card-icon"><i data-lucide="activity"></i></span>
|
||||
<h2>实时状态</h2>
|
||||
<div class="header-actions">
|
||||
<button class="btn-text-s" id="btn-toggle-service">暂停</button>
|
||||
<button class="btn-text-s" id="btn-restart-service">重启</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="status-grid">
|
||||
<div class="status-item">
|
||||
<span class="status-label">当前亮度</span>
|
||||
<span class="status-value" id="status-current-bri">—</span>
|
||||
</div>
|
||||
<div class="status-item">
|
||||
<span class="status-label">系统最大亮度</span>
|
||||
<span class="status-value" id="status-sys-max-bri">—</span>
|
||||
</div>
|
||||
<div class="status-item">
|
||||
<span class="status-label">inotifyd PID</span>
|
||||
<span class="status-value" id="status-inotifyd-pid">—</span>
|
||||
</div>
|
||||
<div class="status-item">
|
||||
<span class="status-label">休眠状态</span>
|
||||
<span class="status-value" id="status-sleep">—</span>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<!-- 日志 -->
|
||||
<section class="card" id="log-section">
|
||||
<div class="card-header">
|
||||
<span class="card-icon"><i data-lucide="file-text"></i></span>
|
||||
<h2>运行日志</h2>
|
||||
</div>
|
||||
<pre class="log-output" id="log-output">加载中...</pre>
|
||||
</section>
|
||||
|
||||
<!-- Toast -->
|
||||
<div class="toast" id="toast"></div>
|
||||
</div>
|
||||
|
||||
</body>
|
||||
|
||||
</html>
|
||||
@@ -0,0 +1,14 @@
|
||||
<!doctype html>
|
||||
<html lang="zh-CN">
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<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>
|
||||
|
||||
<body>
|
||||
<div id="app"></div>
|
||||
<script type="module" src="/src/main.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,153 @@
|
||||
<script setup>
|
||||
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 { 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'
|
||||
import LogView from './views/LogView.vue'
|
||||
import AboutView from './views/AboutView.vue'
|
||||
|
||||
const NAV_ORDER = ['status', 'config', 'apps', 'log', 'about']
|
||||
const currentView = ref('status')
|
||||
const scrolled = ref(false)
|
||||
const version = ref(moduleVersion())
|
||||
|
||||
const snackbar = useSnackbar()
|
||||
const status = useStatus()
|
||||
const config = useConfig()
|
||||
const log = useLog()
|
||||
const apps = useApps()
|
||||
const prefs = useWebUIPrefs()
|
||||
|
||||
provide('snackbar', snackbar.show)
|
||||
provide('status', status)
|
||||
provide('config', config)
|
||||
provide('log', log)
|
||||
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 DISPLAY_EVERY = 5
|
||||
let timer = null
|
||||
let stopped = false
|
||||
let ticks = 0
|
||||
|
||||
function schedule(ms) {
|
||||
timer = setTimeout(tick, ms)
|
||||
}
|
||||
|
||||
async function tick() {
|
||||
timer = null
|
||||
if (stopped) return
|
||||
|
||||
await status.refreshOplock()
|
||||
if (status.oplock.value.locked) {
|
||||
schedule(LOCK_POLL_INTERVAL)
|
||||
return
|
||||
}
|
||||
|
||||
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 startRefresh() {
|
||||
stopRefresh()
|
||||
stopped = false
|
||||
schedule(Math.max(200, prefs.refreshInterval.value))
|
||||
}
|
||||
|
||||
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()
|
||||
})
|
||||
|
||||
onMounted(async () => {
|
||||
prefs.applyZoom()
|
||||
prefs.applyTheme(prefs.themeMode.value)
|
||||
await Promise.all([status.load({ display: true }), config.load(), log.load()])
|
||||
startRefresh()
|
||||
})
|
||||
|
||||
onUnmounted(stopRefresh)
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<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)"
|
||||
/>
|
||||
|
||||
<OpLockBanner
|
||||
:locked="locked"
|
||||
:label="status.oplock.value.label || '正在执行后台操作'"
|
||||
:seconds="status.oplock.value.seconds || 0"
|
||||
/>
|
||||
|
||||
<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>
|
||||
|
||||
<AppBottomNav :model-value="currentView" @update:model-value="onViewChange" />
|
||||
|
||||
<SnackbarHost :messages="snackbar.messages.value" />
|
||||
</template>
|
||||
@@ -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 : ''
|
||||
}
|
||||
@@ -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>
|
||||
@@ -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>
|
||||
@@ -0,0 +1,245 @@
|
||||
import { ref, reactive, computed } from 'vue'
|
||||
import { listPackages, getPackagesInfo } from 'kernelsu'
|
||||
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)
|
||||
const loadError = ref('')
|
||||
const searchKeyword = ref('')
|
||||
const showingSystemApps = ref(true)
|
||||
const savedBlacklist = ref(new Set())
|
||||
const activityEntries = ref(new Set())
|
||||
|
||||
/** 条目结构: { packageName, appLabel, isSystem, uid, checked, expanded } */
|
||||
|
||||
async function load() {
|
||||
isLoading.value = true
|
||||
loadError.value = ''
|
||||
ensurePinyin() // 后台加载拼音库,不阻塞列表
|
||||
try {
|
||||
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('/')))
|
||||
activityEntries.value = 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 pkgs')
|
||||
} catch {
|
||||
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.value) infoList = infoList.filter((a) => !a.isSystem)
|
||||
|
||||
infoList.sort((a, b) => {
|
||||
if (a.isSystem !== b.isSystem) return a.isSystem ? 1 : -1
|
||||
return (a.appLabel || '').localeCompare(b.appLabel || '')
|
||||
})
|
||||
|
||||
const seenUids = new Set()
|
||||
infoList = infoList.filter((a) => {
|
||||
if (a.uid == null) return true
|
||||
if (seenUids.has(a.uid)) return false
|
||||
seenUids.add(a.uid)
|
||||
return true
|
||||
})
|
||||
|
||||
apps.value = infoList.map((a) =>
|
||||
reactive({
|
||||
packageName: a.packageName,
|
||||
appLabel: a.appLabel || 'Unknown',
|
||||
isSystem: a.isSystem,
|
||||
uid: a.uid,
|
||||
checked: savedPkgSet.has(a.packageName),
|
||||
expanded: false,
|
||||
}),
|
||||
)
|
||||
reorder()
|
||||
} catch (e) {
|
||||
loadError.value = e.message || String(e)
|
||||
} finally {
|
||||
isLoading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
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
|
||||
return stateB - stateA
|
||||
})
|
||||
}
|
||||
|
||||
function hasActivity(pkg) {
|
||||
for (const entry of activityEntries.value) {
|
||||
if (entry.startsWith(pkg + '/')) return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
function getActivities(pkg) {
|
||||
return [...activityEntries.value].filter((e) => e.startsWith(pkg + '/'))
|
||||
}
|
||||
|
||||
function addActivity(entry) {
|
||||
activityEntries.value.add(entry)
|
||||
reorder()
|
||||
}
|
||||
|
||||
function removeActivity(entry) {
|
||||
activityEntries.value.delete(entry)
|
||||
reorder()
|
||||
}
|
||||
|
||||
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 toggleSystemApps() {
|
||||
showingSystemApps.value = !showingSystemApps.value
|
||||
load()
|
||||
}
|
||||
|
||||
function selectAll() {
|
||||
for (const app of apps.value) app.checked = true
|
||||
reorder()
|
||||
}
|
||||
|
||||
function selectNone() {
|
||||
for (const app of apps.value) app.checked = false
|
||||
reorder()
|
||||
}
|
||||
|
||||
function invertSelection() {
|
||||
for (const app of apps.value) app.checked = !app.checked
|
||||
reorder()
|
||||
}
|
||||
|
||||
const smartKeywords = [
|
||||
'抖音',
|
||||
'tiktok',
|
||||
'爱奇艺',
|
||||
'优酷',
|
||||
'腾讯视频',
|
||||
'哔哩',
|
||||
'bilibili',
|
||||
'youku',
|
||||
'iqiyi',
|
||||
'芒果',
|
||||
'西瓜',
|
||||
'快手',
|
||||
'kuaishou',
|
||||
'小红书',
|
||||
'netflix',
|
||||
'youtube',
|
||||
'hulu',
|
||||
'disney',
|
||||
'prime',
|
||||
'相册',
|
||||
'gallery',
|
||||
'photos',
|
||||
'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)') {
|
||||
if (!app.checked) count++
|
||||
app.checked = true
|
||||
break
|
||||
}
|
||||
} else if (name.includes(keyword) || pkg.includes(keyword)) {
|
||||
if (!app.checked) count++
|
||||
app.checked = true
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
reorder()
|
||||
snackbar?.(count > 0 ? `已智能勾选 ${count} 个应用` : '没有匹配到可勾选的应用')
|
||||
}
|
||||
|
||||
/** 过滤后的列表(供虚拟滚动使用) */
|
||||
function getFilteredApps() {
|
||||
const keyword = searchKeyword.value.trim().toLowerCase()
|
||||
if (!keyword) return apps.value
|
||||
return apps.value.filter((a) => {
|
||||
const pkg = a.packageName.toLowerCase()
|
||||
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,
|
||||
loadError,
|
||||
searchKeyword,
|
||||
showingSystemApps,
|
||||
savedBlacklist,
|
||||
activityEntries,
|
||||
unsavedCount,
|
||||
load,
|
||||
save,
|
||||
hasActivity,
|
||||
getActivities,
|
||||
addActivity,
|
||||
removeActivity,
|
||||
reorder,
|
||||
toggleSystemApps,
|
||||
selectAll,
|
||||
selectNone,
|
||||
invertSelection,
|
||||
smartSelect,
|
||||
getFilteredApps,
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,187 @@
|
||||
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 saved = ref({})
|
||||
const loading = ref(false)
|
||||
const error = ref('')
|
||||
|
||||
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() {
|
||||
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
|
||||
}
|
||||
try {
|
||||
await patchConfig(patch)
|
||||
await load()
|
||||
snackbar?.(message)
|
||||
} catch (e) {
|
||||
snackbar?.(`保存失败: ${e.message}`)
|
||||
}
|
||||
}
|
||||
|
||||
const saveMain = (snackbar) => save(diffMain.value, snackbar, '配置已保存')
|
||||
const saveAdvanced = (snackbar) => save(diffAdvanced.value, snackbar, '高级设置已保存,需重启模块生效')
|
||||
|
||||
/** 从安装时备份恢复默认值(只改表单,需再点保存) */
|
||||
async function restoreBackup(snackbar) {
|
||||
const raw = await readModuleFile('config/.backup/config.json')
|
||||
if (!raw.trim()) {
|
||||
snackbar?.('备份文件不存在,无法恢复')
|
||||
return
|
||||
}
|
||||
let backup
|
||||
try {
|
||||
backup = JSON.parse(raw)
|
||||
} catch {
|
||||
snackbar?.('备份文件损坏')
|
||||
return
|
||||
}
|
||||
hydrate({ ...saved.value, ...backup })
|
||||
snackbar?.('已载入安装时的配置,点击保存生效')
|
||||
}
|
||||
|
||||
// ── 定时休眠:字符串 <-> 开关 + 四个时间输入 ──────────────────────
|
||||
const sleepEnabled = computed({
|
||||
get: () => !!form.sleep_time,
|
||||
set: (on) => {
|
||||
form.sleep_time = on ? form.sleep_time || '2300-0700' : ''
|
||||
},
|
||||
})
|
||||
|
||||
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 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 {
|
||||
saved,
|
||||
form,
|
||||
loading,
|
||||
error,
|
||||
dirtyMain,
|
||||
dirtyAdvanced,
|
||||
autoBriSleep,
|
||||
displayHdrSleep,
|
||||
compatibilityMode,
|
||||
debugMode,
|
||||
load,
|
||||
saveMain,
|
||||
saveAdvanced,
|
||||
restoreBackup,
|
||||
sleepEnabled,
|
||||
sleepParts,
|
||||
setSleepPart,
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,68 @@
|
||||
import { ref, computed } from 'vue'
|
||||
import { fetchLog, clearLog, exportLog } from '../api/luminpro.js'
|
||||
|
||||
const LEVELS = ['', 'INFO', 'WARN', 'ERROR', 'SUCCESS']
|
||||
|
||||
/** 日志:数据来自 Go 侧 `luminpro log tail`,等级过滤在前端进行 */
|
||||
export function useLog() {
|
||||
const entries = ref([])
|
||||
const level = ref('')
|
||||
const error = ref('')
|
||||
const loading = ref(false)
|
||||
|
||||
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() {
|
||||
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(snackbar) {
|
||||
try {
|
||||
await clearLog()
|
||||
entries.value = []
|
||||
snackbar?.('日志已清空')
|
||||
} catch (e) {
|
||||
snackbar?.(`清空失败: ${e.message}`)
|
||||
}
|
||||
}
|
||||
|
||||
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(text)
|
||||
snackbar?.('日志已复制到剪贴板')
|
||||
} catch {
|
||||
snackbar?.('复制失败,请手动选择文本')
|
||||
}
|
||||
}
|
||||
|
||||
return { entries, filtered, level, levels, error, loading, asText, load, clear, exportTo, copy }
|
||||
}
|
||||
@@ -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,
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,108 @@
|
||||
import { ref, computed } from 'vue'
|
||||
import {
|
||||
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 status = ref(null)
|
||||
const oplock = ref({ locked: false })
|
||||
const error = ref('')
|
||||
|
||||
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 hdrText = computed(() => {
|
||||
const d = display.value
|
||||
if (!d || !d.hdrKnown) return '—'
|
||||
return `${d.hdrRatio.toFixed(2)}${d.hdrStale ? '*' : ''}`
|
||||
})
|
||||
|
||||
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
|
||||
}
|
||||
}
|
||||
|
||||
async function refreshOplock() {
|
||||
try {
|
||||
oplock.value = await fetchOplock()
|
||||
} catch {
|
||||
/* 忽略:下次轮询会重试 */
|
||||
}
|
||||
}
|
||||
|
||||
async function setBrightness(value) {
|
||||
await apiSetBrightness(value)
|
||||
await load({ display: false })
|
||||
}
|
||||
|
||||
async function toggleService(snackbar) {
|
||||
const res = await apiToggleService()
|
||||
snackbar?.(res.ok ? res.stdout.trim() || '状态已切换' : '操作失败: ' + res.stderr)
|
||||
await load({ display: false })
|
||||
}
|
||||
|
||||
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 {
|
||||
status,
|
||||
oplock,
|
||||
error,
|
||||
moduleInfo,
|
||||
daemon,
|
||||
brightness,
|
||||
display,
|
||||
sleep,
|
||||
cfg,
|
||||
isRunning,
|
||||
isPaused,
|
||||
statusText,
|
||||
statusClass,
|
||||
sleepText,
|
||||
hdrText,
|
||||
load,
|
||||
refreshOplock,
|
||||
setBrightness,
|
||||
toggleService,
|
||||
boost,
|
||||
restart,
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
import { createApp } from 'vue'
|
||||
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'
|
||||
@@ -0,0 +1,268 @@
|
||||
/* ==========================================================================
|
||||
应用外壳:顶栏 / 页面滑动轨 / 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-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);
|
||||
}
|
||||
@@ -0,0 +1,331 @@
|
||||
<script setup>
|
||||
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 status = inject('status')
|
||||
const snackbar = inject('snackbar')
|
||||
|
||||
/** 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 })
|
||||
|
||||
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
|
||||
})
|
||||
|
||||
renderMarkdown = (text) => md.render(text)
|
||||
return renderMarkdown
|
||||
}
|
||||
|
||||
/** 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>
|
||||
<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-meta">
|
||||
<div class="about-meta__item">
|
||||
<span class="ts-body-sm supporting">版本</span>
|
||||
<span class="ts-body mono">{{ version }}</span>
|
||||
</div>
|
||||
<div class="about-meta__item">
|
||||
<span class="ts-body-sm supporting">作者</span>
|
||||
<span class="ts-body">酷安 @于乐yule</span>
|
||||
</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>
|
||||
@@ -0,0 +1,593 @@
|
||||
<script setup>
|
||||
import { inject, ref, computed, onUnmounted, nextTick } from 'vue'
|
||||
import { useVirtualizer } from '@tanstack/vue-virtual'
|
||||
import {
|
||||
Search,
|
||||
Save,
|
||||
X,
|
||||
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 appsApi = inject('apps')
|
||||
const status = inject('status')
|
||||
const snackbar = inject('snackbar')
|
||||
|
||||
const locked = computed(() => status.oplock.value.locked)
|
||||
|
||||
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)
|
||||
|
||||
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: () => 64,
|
||||
overscan: 6,
|
||||
})),
|
||||
)
|
||||
const virtualRows = computed(() =>
|
||||
rowVirtualizer.value.getVirtualItems().map((row) => ({
|
||||
...row,
|
||||
app: filteredApps.value[row.index],
|
||||
})),
|
||||
)
|
||||
const totalListHeight = computed(() => rowVirtualizer.value.getTotalSize())
|
||||
|
||||
function measureElement(el) {
|
||||
if (el) rowVirtualizer.value.measureElement(el)
|
||||
}
|
||||
|
||||
// ── 按活动屏蔽 ─────────────────────────────────────────────────────
|
||||
const activityInput = ref('')
|
||||
|
||||
function addActivityEntry() {
|
||||
const value = activityInput.value.trim()
|
||||
const parts = value.split('/')
|
||||
if (parts.length !== 2 || !parts[0] || !parts[1]) {
|
||||
snackbar('格式错误,请输入 包名/完整活动类名')
|
||||
return
|
||||
}
|
||||
appsApi.addActivity(value)
|
||||
activityInput.value = ''
|
||||
snackbar(`已添加: ${value}`)
|
||||
}
|
||||
|
||||
// ── 活动抓取(扫描当前前台 Activity)────────────────────────────────
|
||||
const pickerOpen = ref(false)
|
||||
const pickerStep = ref(1)
|
||||
const pickerStatus = ref('等待中...')
|
||||
const pickerPolling = ref(false)
|
||||
const pickerResult = ref('')
|
||||
const pickerDialog = ref(null)
|
||||
let pollingTimer = null
|
||||
|
||||
async function openPicker() {
|
||||
pickerStep.value = 1
|
||||
pickerStatus.value = '等待中...'
|
||||
pickerResult.value = ''
|
||||
pickerPolling.value = false
|
||||
pickerOpen.value = true
|
||||
await nextTick()
|
||||
pickerDialog.value?.show()
|
||||
}
|
||||
|
||||
function closePicker() {
|
||||
stopPolling()
|
||||
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
|
||||
pickerStatus.value = '检测中,请切换到目标界面...'
|
||||
stopPolling()
|
||||
pollingTimer = setInterval(async () => {
|
||||
try {
|
||||
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 {
|
||||
/* 忽略单次失败,继续轮询 */
|
||||
}
|
||||
}, 600)
|
||||
}
|
||||
|
||||
function confirmPicker() {
|
||||
if (!pickerResult.value) return
|
||||
appsApi.addActivity(pickerResult.value)
|
||||
snackbar(`已添加: ${pickerResult.value}`)
|
||||
closePicker()
|
||||
}
|
||||
|
||||
onUnmounted(stopPolling)
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<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>
|
||||
<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 class="search-row">
|
||||
<md-outlined-text-field
|
||||
:value="appsApi.searchKeyword.value"
|
||||
label="应用名称或包名"
|
||||
autocomplete="off"
|
||||
spellcheck="false"
|
||||
@input="appsApi.searchKeyword.value = $event.target.value"
|
||||
>
|
||||
<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>
|
||||
|
||||
<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>
|
||||
</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>
|
||||
@@ -0,0 +1,387 @@
|
||||
<script setup>
|
||||
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 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 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 全部事件`
|
||||
|
||||
async function openHelp() {
|
||||
helpOpen.value = true
|
||||
await nextTick()
|
||||
helpDialog.value?.show()
|
||||
}
|
||||
|
||||
// ── 定时休眠: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>
|
||||
<!-- ── 亮度配置 ─────────────────────────────────────────────── -->
|
||||
<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="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>
|
||||
|
||||
<!-- ── 高级设置 ─────────────────────────────────────────────── -->
|
||||
<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>
|
||||
<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>
|
||||
<AppTextField
|
||||
v-model="form.now_bri_file"
|
||||
label="当前亮度节点"
|
||||
supporting-text="改后需重启模块"
|
||||
/>
|
||||
<AppTextField
|
||||
v-model="form.max_bri_file"
|
||||
label="最大亮度节点"
|
||||
supporting-text="改后需重启模块"
|
||||
/>
|
||||
|
||||
<md-divider></md-divider>
|
||||
|
||||
<div class="group-title ts-title-sm supporting">
|
||||
<Settings2 :size="16" aria-hidden="true" /> 系统管理
|
||||
</div>
|
||||
<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"
|
||||
>
|
||||
<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>
|
||||
|
||||
<div class="actions">
|
||||
<md-filled-button
|
||||
:disabled="locked || !config.dirtyAdvanced.value"
|
||||
@click="config.saveAdvanced(snackbar)"
|
||||
>
|
||||
<Save :size="16" /> 保存设置
|
||||
</md-filled-button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<!-- ── 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="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="actions">
|
||||
<md-filled-button :disabled="!webuiDirty" @click="saveWebUI">
|
||||
<Save :size="16" /> 保存配置
|
||||
</md-filled-button>
|
||||
</div>
|
||||
</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="helpOpen = false">知道了</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>
|
||||
@@ -0,0 +1,125 @@
|
||||
<script setup>
|
||||
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 log = inject('log')
|
||||
const snackbar = inject('snackbar')
|
||||
|
||||
const clearOpen = ref(false)
|
||||
|
||||
const menuItems = [
|
||||
{ key: 'copy', label: '复制当前日志' },
|
||||
{ key: 'export', label: '导出到 /sdcard' },
|
||||
{ key: 'clear', label: '清空日志' },
|
||||
]
|
||||
|
||||
const filterItems = computed(() => [
|
||||
{ key: '', label: '全部' },
|
||||
{ key: 'INFO', label: 'INFO' },
|
||||
{ key: 'WARN', label: 'WARN' },
|
||||
{ key: 'ERROR', label: 'ERROR' },
|
||||
{ key: 'SUCCESS', label: 'SUCCESS' },
|
||||
])
|
||||
|
||||
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="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>
|
||||
|
||||
<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>
|
||||
|
||||
<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>
|
||||
@@ -0,0 +1,176 @@
|
||||
<script setup>
|
||||
import { inject, computed, ref } from 'vue'
|
||||
import { SunMedium, Smartphone, Activity, Clock, Moon, Layers, Gauge, RefreshCw } from 'lucide-vue-next'
|
||||
import ConfirmDialog from '../components/ConfirmDialog.vue'
|
||||
|
||||
const status = inject('status')
|
||||
const snackbar = inject('snackbar')
|
||||
|
||||
const sliderEl = ref(null)
|
||||
const confirmLowOpen = ref(false)
|
||||
const pendingValue = ref(0)
|
||||
|
||||
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 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 refresh() {
|
||||
await status.load({ display: true })
|
||||
snackbar('已刷新')
|
||||
}
|
||||
|
||||
let lastApplied = null
|
||||
|
||||
/** 拖动中节流:距上次应用超过 3% 才写一次节点,避免每个像素都 exec */
|
||||
const DRAG_APPLY_STEP_PERCENT = 3
|
||||
|
||||
async function applyBrightness(value, { silent = false } = {}) {
|
||||
try {
|
||||
await status.setBrightness(value)
|
||||
lastApplied = value
|
||||
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 (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)
|
||||
const pct = Math.round((value / maxBrightness.value) * 100)
|
||||
if (pct < 5) {
|
||||
pendingValue.value = value
|
||||
confirmLowOpen.value = true
|
||||
return
|
||||
}
|
||||
await applyBrightness(value)
|
||||
lastApplied = value
|
||||
}
|
||||
|
||||
function cancelLow() {
|
||||
confirmLowOpen.value = false
|
||||
if (sliderEl.value) sliderEl.value.value = currentBrightness.value
|
||||
}
|
||||
|
||||
async function confirmLow() {
|
||||
confirmLowOpen.value = false
|
||||
await applyBrightness(pendingValue.value)
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<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 items" :key="item.label" class="status-item">
|
||||
<span class="status-item__label">
|
||||
<component :is="item.icon" :size="14" aria-hidden="true" />
|
||||
{{ item.label }}
|
||||
</span>
|
||||
<span class="status-item__value tabular">{{ item.value }}</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="继续可能让屏幕接近黑屏,确定要设置吗?"
|
||||
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>
|
||||
@@ -0,0 +1,26 @@
|
||||
import { defineConfig } from 'vite'
|
||||
import vue from '@vitejs/plugin-vue'
|
||||
import { fileURLToPath, URL } from 'node:url'
|
||||
|
||||
export default defineConfig({
|
||||
plugins: [
|
||||
vue({
|
||||
template: {
|
||||
compilerOptions: {
|
||||
// @material/web 提供的是自定义元素(md-*),交由浏览器处理而非 Vue 组件
|
||||
isCustomElement: (tag) => tag.startsWith('md-'),
|
||||
},
|
||||
},
|
||||
}),
|
||||
],
|
||||
resolve: {
|
||||
alias: {
|
||||
'@': fileURLToPath(new URL('./src', import.meta.url)),
|
||||
},
|
||||
},
|
||||
build: {
|
||||
outDir: '../webroot',
|
||||
emptyOutDir: true,
|
||||
minify: 'oxc',
|
||||
},
|
||||
})
|
||||
Reference in new issue
Block a user