21 Commits
20 changed files with 444 additions and 71 deletions

No files matched your search

+80
View File
@@ -0,0 +1,80 @@
name: Bug 反馈
description: 提交一个 Bug,帮助我们定位和修复问题。
title: '[Bug]: '
labels: ['bug']
body:
- type: markdown
attributes:
value: |
感谢你提交 Bug!请尽量填写完整,带 * 的为必填项。
提交前请先搜索是否已有类似 Issue。
- type: textarea
id: what-happened
attributes:
label: 遇到了什么?
description: 请描述实际发生了什么,以及你期望发生什么。
placeholder: 例如:点击保存按钮后页面崩溃,期望正常保存并提示成功。
validations:
required: true
- type: textarea
id: steps-to-reproduce
attributes:
label: 操作步骤
description: 请按顺序列出可复现问题的步骤。
placeholder: |
1. 打开...
2. 点击...
3. 看到...
validations:
required: true
- type: dropdown
id: version-channel
attributes:
label: 版本渠道
description: 你使用的是哪个版本渠道?
options:
- Release
- Beta
- Dev
validations:
required: true
- type: input
id: version-number
attributes:
label: 版本号
description: 请填写完整版本号,例如 1.2.3 或 1.2.3-beta.1
placeholder: 例如 1.2.3
validations:
required: true
- type: textarea
id: screenshots
attributes:
label: 截图(可选)
description: 可以直接拖拽图片到此处上传,或粘贴图片链接。
placeholder: 拖拽截图到这里...
validations:
required: false
- type: textarea
id: logs
attributes:
label: 日志(可选)
description: 请粘贴相关日志、错误堆栈或控制台输出。注意删除敏感信息。
render: shell
placeholder: 粘贴日志...
validations:
required: false
- type: textarea
id: additional-info
attributes:
label: 更多信息(可选)
description: 其他有助于定位问题的信息,例如系统环境等。
placeholder: 其他信息...
validations:
required: false
@@ -0,0 +1,69 @@
name: 改进建议
description: 提交一个功能建议或改进想法。
title: '[建议]: '
labels: ['enhancement']
body:
- type: markdown
attributes:
value: |
感谢你的建议!请尽量描述清楚你的使用场景和期望效果。
提交前请先搜索是否已有类似 Issue。
- type: dropdown
id: suggestion-type
attributes:
label: 建议类型
description: 这个建议主要属于哪一类?
options:
- 新功能
- 体验优化
- 性能改进
- 文档改进
- 其他
validations:
required: true
- type: textarea
id: problem
attributes:
label: 当前问题 / 使用场景
description: 描述你遇到了什么不便,或这个建议能解决什么问题。
placeholder: 例如:目前导出数据需要手动逐个复制,效率很低。
validations:
required: true
- type: textarea
id: proposal
attributes:
label: 期望的改进
description: 描述你希望增加或改变什么,越具体越好。
placeholder: 例如:希望支持一键导出全部数据为 CSV。
validations:
required: true
- type: textarea
id: alternatives
attributes:
label: 替代方案(可选)
description: 你考虑过的其他实现方式,或目前的临时解决办法。
placeholder: 例如:目前只能通过脚本调用 API 实现。
validations:
required: false
- type: textarea
id: screenshots
attributes:
label: 截图 / 示例(可选)
description: 可以拖拽图片到此处上传,或粘贴参考链接、示例代码。
placeholder: 拖拽截图到这里,或粘贴示例链接...
validations:
required: false
- type: textarea
id: additional-info
attributes:
label: 更多信息(可选)
description: 其他补充信息,例如优先级、影响范围、相关 Issue 等。
placeholder: 其他信息...
validations:
required: false
+2 -2
View File
@@ -1,5 +1,5 @@
=======================================
LuminPro V2.3 — 日用屏幕亮度强化
=======================================
LuminPro — 日用屏幕亮度强化
作者: 酷安@Yule
=======================================
Executable
BIN
View File
Binary file not shown.
+13 -13
View File
@@ -1,24 +1,24 @@
# 更新日志
## V2.5.0-beta.2
## V2.5.0
- 重构: 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)
- 重构: **核心逻辑全量迁移至 Go**,单一常驻守护进程负责监听、判定与渐变写入,移除 Rust 监听器与 jq 依赖,模块体积减少约 1.8MB
- 新增: **Go JSON API** —— 状态、操作锁、亮度、配置、日志改为一次调用取回结构化数据,刷新更快、更省资源
- 新增: **操作锁** —— 后台写亮度期间 WebUI 自动暂停刷新、禁用写操作入口并显示顶部提示
- 新增: HDR 休眠双阈值迟滞机制,进入/退出阈值可在 WebUI 自定义(默认 1.15 / 1.05)
- 新增: **HDR 休眠双阈值迟滞**,进入/退出阈值可在 WebUI 自定义(默认 1.15 / 1.05),避免在阈值附近抖动
- 新增: 版本通道(正式 / 预览),两类用户互不干扰,预览版可平滑升级到正式版
- 重构: **WebUI 全量重写为 Material Design 3**(基于 @material/web),补全颜色/字阶/形状/动效令牌,支持涟漪与状态层反馈
- 新增: 黑名单列表虚拟滚动,500+ 应用时滑动依然流畅
- 新增: 版本通道(正式 / 预览),预览版与正式版互不干扰
- 新增: 底部导航栏适配手势导航条(色块填充),顶栏适配状态栏安全区
- 优化: 顶栏瘦身并采用 M3 固定样式;「重启模块」移入更多菜单并与刷新区分
- 优化: 亮度滑条改为拖动中实时应用(按 3% 节流)、松手应用最终值
- 优化: 提示改为 M3 snackbar,确认/输入改用 M3 对话框,菜单改用 M3 菜单
- 优化: 状态页移除「自动亮度调节」开关;「智能选择」提为一级按钮
- 优化: 配置页改用「已保存 / 未保存」徽标,「系统管理」并入高级设置
- 修复: 低亮度保护失效——现在拖动中即拦在 5% 安全下限,确认后才放开
- 修复: 设备默认亮度节点不可用时改为允许安装但功能保持关闭
- 修复: 亮度设置与配置写入统一由 Go 侧校验并原子保存,不再拼接 shell 字符串
- 修复: 文档预览支持 HTML 与 GitHub 提示块;活动抓取忽略桌面与系统界面
## V2.4-2401
+7 -3
View File
@@ -211,6 +211,10 @@ func TestReadModuleInfo(t *testing.T) {
}
}
// 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)
@@ -247,9 +251,9 @@ func TestBuildStatus(t *testing.T) {
}
if err := WriteState(paths.StateFile, DaemonState{
PID: os.Getpid(),
StartedAt: time.Now().Add(-90 * time.Second).Unix(),
StartedAt: fixedNow.Add(-90 * time.Second).Unix(),
Mode: "event",
Ratio: &RatioInfo{Value: 1.08, At: time.Now().Unix()},
Ratio: &RatioInfo{Value: 1.08, At: fixedNow.Unix()},
HdrSleep: true,
}); err != nil {
t.Fatal(err)
@@ -265,7 +269,7 @@ func TestBuildStatus(t *testing.T) {
status := BuildStatus(paths, cfg, StatusDeps{
AutoBrightness: system.AutoBrightness{Runner: runner},
HDR: system.HdrRatio{Runner: runner},
Now: func() time.Time { return time.Date(2026, 9, 10, 12, 0, 0, 0, time.Local) },
Now: func() time.Time { return fixedNow },
}, StatusOptions{IncludeDisplay: true})
if status.Module.Version != "" && status.Module.Channel != "stable" {
+19 -7
View File
@@ -155,13 +155,22 @@ func (w *Watcher) Add(path, letters string) error {
return nil
}
// Close 释放资源。
// Close 释放资源。重复调用安全。
func (w *Watcher) Close() error {
w.mu.Lock()
defer w.mu.Unlock()
_ = unix.Close(w.wakeR)
_ = unix.Close(w.wakeW)
w.wakeR, w.wakeW = -1, -1
// 先唤醒 Run:直接关闭 fd 会让阻塞中的 poll 拿不到退出信号
if w.wakeW >= 0 {
_, _ = unix.Write(w.wakeW, []byte{1})
}
if w.wakeR >= 0 {
_ = unix.Close(w.wakeR)
w.wakeR = -1
}
if w.wakeW >= 0 {
_ = unix.Close(w.wakeW)
w.wakeW = -1
}
if w.fd >= 0 {
err := unix.Close(w.fd)
w.fd = -1
@@ -170,10 +179,13 @@ func (w *Watcher) Close() error {
return nil
}
// wake 唤醒正在 poll 的 Run。
// wake 唤醒正在 poll 的 Run。并发/重复调用安全。
func (w *Watcher) wake() {
if w.wakeW >= 0 {
_, _ = unix.Write(w.wakeW, []byte{1})
w.mu.Lock()
fd := w.wakeW
w.mu.Unlock()
if fd >= 0 {
_, _ = unix.Write(fd, []byte{1})
}
}
+9 -11
View File
@@ -80,6 +80,8 @@ func startRunner(t *testing.T, w *Watcher, debounce time.Duration, handler func(
_ = w.NewRunner(debounce, nil).Run(handler, stop)
}()
t.Cleanup(func() {
// 必须先让 Run 退出,再关闭 watcher:反过来会先关掉唤醒管道,
// Stop 的唤醒丢失,Run 会卡在 poll 里直到超时(CI 上偶发)
close(stop)
w.Stop()
select {
@@ -87,6 +89,7 @@ func startRunner(t *testing.T, w *Watcher, debounce time.Duration, handler func(
case <-time.After(2 * time.Second):
t.Error("Run 未能退出")
}
w.Close()
})
return stop
}
@@ -113,7 +116,6 @@ func TestWatchModifyDeliversEvent(t *testing.T) {
if err != nil {
t.Skipf("当前环境不支持 inotify: %v", err)
}
defer w.Close()
if err := w.Add(path, "c"); err != nil {
t.Fatal(err)
}
@@ -144,7 +146,6 @@ func TestCloseWriteLetter(t *testing.T) {
if err != nil {
t.Skipf("当前环境不支持 inotify: %v", err)
}
defer w.Close()
if err := w.Add(path, "w"); err != nil {
t.Fatal(err)
}
@@ -181,7 +182,6 @@ func TestCloseNoWriteLetter(t *testing.T) {
if err != nil {
t.Skipf("当前环境不支持 inotify: %v", err)
}
defer w.Close()
if err := w.Add(path, "0"); err != nil {
t.Fatal(err)
}
@@ -216,25 +216,26 @@ func TestDebounceCoalescesBurst(t *testing.T) {
if err != nil {
t.Skipf("当前环境不支持 inotify: %v", err)
}
defer w.Close()
if err := w.Add(path, "c"); err != nil {
t.Fatal(err)
}
c := &collector{}
startRunner(t, w, 200*time.Millisecond, c.add)
// 防抖窗口取大一些:CI 上单次写文件可能耗时数十毫秒,
// 窗口过短会让连写跨越窗口边界,产生第 2 次触发(测试因此偶发失败)
const debounceWindow = 800 * time.Millisecond
startRunner(t, w, debounceWindow, c.add)
for i := 0; i < 5; i++ {
if err := os.WriteFile(path, []byte("x"), 0o644); err != nil {
t.Fatal(err)
}
time.Sleep(10 * time.Millisecond)
}
if !waitFor(t, 2*time.Second, func() bool { return len(c.snapshot()) > 0 }) {
if !waitFor(t, 3*time.Second, func() bool { return len(c.snapshot()) > 0 }) {
t.Fatal("未收到事件")
}
time.Sleep(300 * time.Millisecond) // 等超过一个防抖窗口
time.Sleep(debounceWindow + 400*time.Millisecond) // 等超过一个防抖窗口
if got := len(c.snapshot()); got != 1 {
t.Fatalf("防抖后应只触发 1 次, 实际 %d 次", got)
}
@@ -251,7 +252,6 @@ func TestDrainPreventsRecursion(t *testing.T) {
if err != nil {
t.Skipf("当前环境不支持 inotify: %v", err)
}
defer w.Close()
if err := w.Add(path, "c"); err != nil {
t.Fatal(err)
}
@@ -287,7 +287,6 @@ func TestStopExitsBlockingRun(t *testing.T) {
if err != nil {
t.Skipf("当前环境不支持 inotify: %v", err)
}
defer w.Close()
if err := w.Add(path, "c"); err != nil {
t.Fatal(err)
}
@@ -317,7 +316,6 @@ func TestAddMissingPathFails(t *testing.T) {
if err != nil {
t.Skipf("当前环境不支持 inotify: %v", err)
}
defer w.Close()
if err := w.Add(filepath.Join(t.TempDir(), "不存在"), "c"); err == nil {
t.Fatal("监听不存在的路径应报错")
}
+2 -2
View File
@@ -1,7 +1,7 @@
id=LuminPro
name=LuminPro丨日用屏幕亮度强化
version=V2.5.0-beta.2
versionCode=2050052
version=V2.5.0
versionCode=2050090
author=酷安@Yule
description=本模块旨在让你的 Android 设备随时可以使用高亮度显示屏幕内容。无论设备当前亮度如何,只要满足设定的前台触发亮度条件,模块便会自动且平滑地提升屏幕亮度至硬件支持的峰值状态,确保你在强光室外也能获得清晰的显示效果
updateJson=https://raw.githubusercontent.com/YuleBest/LuminPro/main/update.json
+3 -3
View File
@@ -1,6 +1,6 @@
{
"versionCode": 2050052,
"version": "V2.5.0-beta.2",
"zipUrl": "https://github.com/YuleBest/LuminPro/releases/download/v2.5.0-beta.2/LuminPro_V2.5.0-beta.2.zip",
"versionCode": 2050056,
"version": "V2.5.0-beta.6",
"zipUrl": "https://github.com/YuleBest/LuminPro/releases/download/v2.5.0-beta.6/LuminPro_V2.5.0-beta.6.zip",
"changelog": "https://raw.githubusercontent.com/YuleBest/LuminPro/beta/changelog.md"
}
+3 -3
View File
@@ -1,6 +1,6 @@
{
"versionCode": 2401,
"version": "V2.4-2401",
"zipUrl": "https://github.com/YuleBest/LuminPro/releases/download/v2.4-2401/LuminPro_V2.4-2401-f2c489e.zip",
"versionCode": 2050090,
"version": "V2.5.0",
"zipUrl": "https://github.com/YuleBest/LuminPro/releases/download/v2.5.0/LuminPro_V2.5.0.zip",
"changelog": "https://raw.githubusercontent.com/YuleBest/LuminPro/main/changelog.md"
}
+1 -1
View File
@@ -2,7 +2,7 @@
<html lang="zh-CN">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no, viewport-fit=cover" />
<title>LuminPro</title>
<link rel="stylesheet" type="text/css" href="/internal/insets.css" />
</head>
+19
View File
@@ -41,6 +41,25 @@ 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 {
+14 -12
View File
@@ -16,16 +16,18 @@ const tabs = [
</script>
<template>
<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 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>
+2
View File
@@ -1,4 +1,5 @@
import { createApp } from 'vue'
import { applyEdgeToEdge } from './api/ksu.js'
import './mwc.js'
import './theme/tokens.css'
@@ -8,4 +9,5 @@ import './theme/app.css'
import App from './App.vue'
applyEdgeToEdge()
createApp(App).mount('#app')
+12 -3
View File
@@ -138,11 +138,20 @@
}
/* ── M3 导航栏 ────────────────────────────────────────────────────── */
md-navigation-bar {
/* 底栏容器:色块填充法——容器背景延伸至屏幕最底部,手势导航条区域
与导航栏同色;内边距把导航内容抬到手势条之上。
安全区变量在不同 KernelSU 版本命名不同,最后兜底 env()。 */
.bottom-nav {
flex: 0 0 auto;
/* 背景延伸到屏幕底部,内容抬到手势条之上 */
padding-bottom: var(--safe-area-inset-bottom, var(--window-inset-bottom, 0px));
background-color: var(--md-sys-color-surface-container);
padding-bottom: var(--safe-area-inset-bottom, var(--window-inset-bottom, env(safe-area-inset-bottom, 0px)));
}
md-navigation-bar {
--md-navigation-bar-container-color: var(--md-sys-color-surface-container);
/* 去掉容器阴影:手势条区域用同色填充,阴影会在底部露出一条边 */
--md-navigation-bar-container-elevation: 0;
box-shadow: none;
--md-navigation-bar-active-indicator-color: var(--md-sys-color-secondary-container);
--md-navigation-bar-active-icon-color: var(--md-sys-color-on-secondary-container);
--md-navigation-bar-active-label-text-color: var(--md-sys-color-on-surface);
+99 -1
View File
@@ -12,11 +12,58 @@ let renderMarkdown = null
async function ensureMarkdown() {
if (renderMarkdown) return renderMarkdown
const { default: MarkdownIt } = await import('markdown-it')
const md = new MarkdownIt({ html: false, linkify: true, breaks: true })
// 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 },
@@ -144,6 +191,57 @@ async function openLink(url) {
</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;
+22 -1
View File
@@ -156,6 +156,26 @@ function stopPolling() {
}
}
/**
* 需要忽略的前台活动: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 = '检测中,请切换到目标界面...'
@@ -164,7 +184,8 @@ function startPolling() {
try {
const res = await fetchFocus()
const activity = (res.focus || '').trim()
if (!activity || activity.toLowerCase().includes('webui')) return
// 空值、WebUI 自身、桌面等系统界面都继续等待
if (!activity || isIgnoredActivity(activity)) return
stopPolling()
pickerPolling.value = false
pickerResult.value = activity
+6 -1
View File
@@ -41,6 +41,11 @@ async function openHelp() {
helpDialog.value?.show()
}
function closeHelp() {
helpDialog.value?.close()
helpOpen.value = false
}
// ── 定时休眠:HHMM 起止时间 ────────────────────────────────────────
const sleepStart = computed(() => config.sleepParts.value[0] + config.sleepParts.value[1])
const sleepEnd = computed(() => config.sleepParts.value[2] + config.sleepParts.value[3])
@@ -316,7 +321,7 @@ async function confirmReset() {
<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>
<md-filled-button @click="closeHelp">知道了</md-filled-button>
</div>
</md-dialog>
</template>
+62 -8
View File
@@ -44,33 +44,86 @@ async function refresh() {
snackbar('已刷新')
}
async function applyBrightness(value) {
let lastApplied = null
/** 拖动中节流:距上次应用超过 3% 才写一次节点,避免每个像素都 exec */
const DRAG_APPLY_STEP_PERCENT = 3
/** 低亮度保护:低于该比例视为伪黑屏风险,需用户确认后才允许 */
const MIN_PERCENT = 5
/** 用户确认过本次会话的低亮度设置(确认后不再重复拦截) */
const lowConfirmed = ref(false)
/** 5% 对应的亮度值,向上取整 */
const lowFloor = computed(() => Math.ceil(((maxBrightness.value || 255) * MIN_PERCENT) / 100))
/** 把滑条与已应用值拉回安全下限 */
function snapToFloor() {
if (sliderEl.value) sliderEl.value.value = lowFloor.value
return lowFloor.value
}
async function applyBrightness(value, { silent = false } = {}) {
try {
await status.setBrightness(value)
snackbar(`亮度已设为 ${value}`)
lastApplied = value
// 回到安全区以上后重置确认状态:下次再往下滑会重新提醒
// 注意用严格大于:确认后应用的就是下限值本身,等于时不应重置
if (value > lowFloor.value) lowConfirmed.value = false
if (!silent) snackbar(`亮度已设为 ${value}`)
} catch (e) {
snackbar(`设置失败: ${e.message}`)
if (!silent) snackbar(`设置失败: ${e.message}`)
}
}
/** 拖动过程中(input 事件):先做低亮度拦截,再按比例节流应用 */
async function onSliderInput(event) {
const value = Number(event.target.value)
const max = maxBrightness.value || 255
// 低亮度保护:未确认前直接拦在安全下限,避免滑到伪黑屏
if (!lowConfirmed.value && value < lowFloor.value) {
const floored = snapToFloor()
if (!confirmLowOpen.value) {
pendingValue.value = floored
confirmLowOpen.value = true
}
return
}
if (lastApplied === null) {
lastApplied = currentBrightness.value
}
const step = (max * DRAG_APPLY_STEP_PERCENT) / 100
if (Math.abs(value - lastApplied) < step) return
await applyBrightness(value, { silent: true })
}
async function onSliderChange(event) {
const value = Number(event.target.value)
const pct = Math.round((value / maxBrightness.value) * 100)
if (pct < 5) {
pendingValue.value = value
// 未确认低亮度时,松手也不允许落在安全下限之下
if (!lowConfirmed.value && value < lowFloor.value) {
pendingValue.value = lowFloor.value
snapToFloor()
confirmLowOpen.value = true
return
}
await applyBrightness(value)
lastApplied = value
}
/** 取消:保持在安全下限,不写节点 */
function cancelLow() {
confirmLowOpen.value = false
if (sliderEl.value) sliderEl.value.value = currentBrightness.value
if (sliderEl.value) sliderEl.value.value = lowFloor.value
}
/** 确认:本次会话放开低亮度限制,并应用目标值 */
async function confirmLow() {
confirmLowOpen.value = false
lowConfirmed.value = true
await applyBrightness(pendingValue.value)
}
</script>
@@ -118,6 +171,7 @@ async function confirmLow() {
:max="maxBrightness"
:value="currentBrightness"
labeled
@input="onSliderInput"
@change="onSliderChange"
></md-slider>
</div>
@@ -130,7 +184,7 @@ async function confirmLow() {
<ConfirmDialog
:open="confirmLowOpen"
headline="亮度低于 5%"
description="继续可能让屏幕接近黑屏,确定要设置吗?"
:description="`低于 ${MIN_PERCENT}% 可能让屏幕看起来像黑屏。\n确认后将临时放开该限制。`"
confirm-text="仍然设置"
danger
@confirm="confirmLow"