mirror of
https://github.com/YuleBest/LuminPro.git
synced 2026-12-04 00:54:42 +08:00
feat: 新增操作锁,后台写亮度期间 WebUI 暂停刷新并禁用写操作
- 脚本侧: up.sh 渐变期、boost.sh 全程、restart.sh 全程写入 pid/oplock (含 PID) 并 trap 清理;restart.sh 末尾等待新监听就绪以覆盖守护进程重建窗口 - WebUI: 新增 useOplock 轮询锁状态,锁定时暂停数据刷新 (300ms 探测释放), 释放瞬间强制全量刷新;顶部固定横幅提示 - 锁定期间禁用: 配置保存/恢复默认/高级保存、黑名单保存、亮度滑条、重启模块 - 遗留锁自愈: 锁内 PID 不存在则就地清理,避免 SIGKILL 后永久锁定 - service.sh 开机清理 oplock;DEVELOPMENT.md 补充锁协议说明
This commit is contained in:
1 parent
f9dd4c40d6
commit
ec5ae07ce0
15 files changed
+223
-24
No files matched your search
@@ -15,3 +15,6 @@ rust/target/
|
|||||||
# 本地脚本
|
# 本地脚本
|
||||||
deploy.js
|
deploy.js
|
||||||
.dist-tmp
|
.dist-tmp
|
||||||
|
|
||||||
|
# 编辑器 / 会话临时文件
|
||||||
|
.zcode/
|
||||||
@@ -105,9 +105,23 @@ node build-module.js
|
|||||||
|
|
||||||
- **service.sh**: 模块启动入口,负责拉起守护进程。
|
- **service.sh**: 模块启动入口,负责拉起守护进程。
|
||||||
- **script/daemon.sh**: 持续监控 `lumipro` 进程,并处理亮度提升逻辑。
|
- **script/daemon.sh**: 持续监控 `lumipro` 进程,并处理亮度提升逻辑。
|
||||||
|
- **script/up.sh**: 亮度提升核心逻辑(阈值判断、黑名单、HDR、渐变写入)。
|
||||||
|
- **script/restart.sh**: 重启守护进程与监听。
|
||||||
|
- **boost.sh**: 一键提升至峰值亮度 / 恢复原亮度。
|
||||||
- **customize.sh**: 刷入时的安装逻辑,处理初次校准与文件权限。
|
- **customize.sh**: 刷入时的安装逻辑,处理初次校准与文件权限。
|
||||||
- **action.sh**: 快捷操作逻辑(音量键或管理器按钮触发)。
|
- **action.sh**: 快捷操作逻辑(音量键或管理器按钮触发)。
|
||||||
|
|
||||||
|
### 操作锁 (oplock)
|
||||||
|
|
||||||
|
`pid/oplock` 是脚本与 WebUI 之间的约定文件:任何会写亮度节点或重建监听的操作
|
||||||
|
(`up.sh` 渐变期间、`boost.sh` 全程、`restart.sh` 全程)都会把自己的 PID 写入该文件,
|
||||||
|
结束时删除。WebUI 轮询此文件,发现持锁时暂停状态刷新并禁用写操作入口(配置保存、
|
||||||
|
黑名单保存、亮度滑条、重启模块),顶部显示提示横幅。
|
||||||
|
|
||||||
|
- 查询约定:文件存在且其中的 PID 在 `/proc` 中存活 → 锁定中;否则视为遗留锁,由查询方
|
||||||
|
就地清理(避免脚本被 SIGKILL 后 WebUI 永久卡在锁定态)。
|
||||||
|
- `service.sh` 开机时清理该文件;WebUI 侧的实现见 `webui/src/composables/useOplock.js`。
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
## 8. 调试技巧
|
## 8. 调试技巧
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ CONFIG_FILE="$MODDIR/config/config.json"
|
|||||||
JQ="$MODDIR/bin/jq"
|
JQ="$MODDIR/bin/jq"
|
||||||
PID_DIR="$MODDIR/pid"
|
PID_DIR="$MODDIR/pid"
|
||||||
BOOST_FLAG="$PID_DIR/boost.flag"
|
BOOST_FLAG="$PID_DIR/boost.flag"
|
||||||
|
OPLOCK_FILE="$PID_DIR/oplock"
|
||||||
|
|
||||||
DEFAULT_NOW_BRI_FILE="/sys/class/backlight/panel0-backlight/brightness"
|
DEFAULT_NOW_BRI_FILE="/sys/class/backlight/panel0-backlight/brightness"
|
||||||
|
|
||||||
@@ -27,6 +28,12 @@ if [ ! -f "$now_bri_file" ]; then
|
|||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
mkdir -p "$PID_DIR"
|
||||||
|
# 持操作锁:WebUI 据此暂停刷新并禁用写操作
|
||||||
|
echo $$ >"$OPLOCK_FILE"
|
||||||
|
# shellcheck disable=SC2064
|
||||||
|
trap "rm -f '$OPLOCK_FILE'" EXIT HUP INT TERM
|
||||||
|
|
||||||
if [ -f "$BOOST_FLAG" ]; then
|
if [ -f "$BOOST_FLAG" ]; then
|
||||||
restore_bri="$(cat "$BOOST_FLAG" 2>/dev/null | tr -d ' \n')"
|
restore_bri="$(cat "$BOOST_FLAG" 2>/dev/null | tr -d ' \n')"
|
||||||
[ -n "$restore_bri" ] && echo -n "$restore_bri" >"$now_bri_file" 2>/dev/null
|
[ -n "$restore_bri" ] && echo -n "$restore_bri" >"$now_bri_file" 2>/dev/null
|
||||||
@@ -37,7 +44,6 @@ else
|
|||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
now_bri="$(cat "$now_bri_file" 2>/dev/null | tr -d ' \n')"
|
now_bri="$(cat "$now_bri_file" 2>/dev/null | tr -d ' \n')"
|
||||||
mkdir -p "$PID_DIR"
|
|
||||||
echo -n "$now_bri" >"$BOOST_FLAG"
|
echo -n "$now_bri" >"$BOOST_FLAG"
|
||||||
echo -n "$max_bri" >"$now_bri_file" 2>/dev/null
|
echo -n "$max_bri" >"$now_bri_file" 2>/dev/null
|
||||||
fi
|
fi
|
||||||
|
|||||||
@@ -28,6 +28,13 @@ _log() {
|
|||||||
_log "收到手动重启请求"
|
_log "收到手动重启请求"
|
||||||
|
|
||||||
pause_file="$PID_DIR/daemon.pause"
|
pause_file="$PID_DIR/daemon.pause"
|
||||||
|
oplock_file="$PID_DIR/oplock"
|
||||||
|
|
||||||
|
# 持操作锁:覆盖守护进程重建窗口,WebUI 据此暂停刷新并禁用写操作
|
||||||
|
mkdir -p "$PID_DIR"
|
||||||
|
echo $$ >"$oplock_file"
|
||||||
|
# shellcheck disable=SC2064
|
||||||
|
trap "rm -f '$oplock_file'" EXIT HUP INT TERM
|
||||||
|
|
||||||
# 1. 通知守护进程挂起,终止 lumipro 实例
|
# 1. 通知守护进程挂起,终止 lumipro 实例
|
||||||
_log "通知守护进程挂起,清理 lumipro 实例"
|
_log "通知守护进程挂起,清理 lumipro 实例"
|
||||||
@@ -58,4 +65,18 @@ else
|
|||||||
_log "守护进程已恢复,等待自动拉起监听"
|
_log "守护进程已恢复,等待自动拉起监听"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# 5. 等待新监听就绪,让操作锁覆盖守护进程重建窗口
|
||||||
|
wait_i=0
|
||||||
|
while [ "$wait_i" -lt 15 ]; do
|
||||||
|
if [ -f "$pid_file" ]; then
|
||||||
|
new_pid="$(cat "$pid_file" 2>/dev/null)"
|
||||||
|
if [ "$new_pid" = "polling" ] || { [ -n "$new_pid" ] && [ -d "/proc/$new_pid" ]; }; then
|
||||||
|
_log "新监听已就绪 (PID: $new_pid)"
|
||||||
|
break
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
sleep 0.2
|
||||||
|
wait_i=$((wait_i + 1))
|
||||||
|
done
|
||||||
|
|
||||||
exit 0
|
exit 0
|
||||||
+17
-9
@@ -57,6 +57,8 @@ fi
|
|||||||
|
|
||||||
# 防止 up.sh 自身读写亮度节点时触发 inotify 事件导致递归调用
|
# 防止 up.sh 自身读写亮度节点时触发 inotify 事件导致递归调用
|
||||||
lock_file="$PID_DIR/up.lock"
|
lock_file="$PID_DIR/up.lock"
|
||||||
|
# 操作锁:仅在真正写亮度节点期间持有,供 WebUI 暂停刷新并禁用写操作
|
||||||
|
oplock_file="$PID_DIR/oplock"
|
||||||
if [ -f "$lock_file" ]; then
|
if [ -f "$lock_file" ]; then
|
||||||
old_pid=$(cat "$lock_file" 2>/dev/null)
|
old_pid=$(cat "$lock_file" 2>/dev/null)
|
||||||
if [ -n "$old_pid" ] && [ -d "/proc/$old_pid" ]; then
|
if [ -n "$old_pid" ] && [ -d "/proc/$old_pid" ]; then
|
||||||
@@ -68,7 +70,7 @@ if [ -f "$lock_file" ]; then
|
|||||||
fi
|
fi
|
||||||
echo $$ >"$lock_file"
|
echo $$ >"$lock_file"
|
||||||
# shellcheck disable=SC2064
|
# shellcheck disable=SC2064
|
||||||
trap "rm -f '$lock_file'" EXIT HUP INT TERM
|
trap "rm -f '$lock_file' '$oplock_file'" EXIT HUP INT TERM
|
||||||
|
|
||||||
# 读取配置
|
# 读取配置
|
||||||
ui_max_bri="$(get_cfg ui_max_bri 0)"
|
ui_max_bri="$(get_cfg ui_max_bri 0)"
|
||||||
@@ -99,22 +101,28 @@ IS_SLEEP_TIME() {
|
|||||||
target_bri="$max_bri"
|
target_bri="$max_bri"
|
||||||
|
|
||||||
update_all() {
|
update_all() {
|
||||||
local step
|
local step rc=0
|
||||||
|
# 持操作锁:仅在写亮度节点期间,WebUI 据此暂停刷新并禁用写操作
|
||||||
|
echo $$ >"$oplock_file"
|
||||||
|
|
||||||
start_bri="$(cat "$now_bri_file")"
|
start_bri="$(cat "$now_bri_file")"
|
||||||
bri_diff="$((target_bri - start_bri))"
|
bri_diff="$((target_bri - start_bri))"
|
||||||
step_value="$((bri_diff / steps_num))"
|
step_value="$((bri_diff / steps_num))"
|
||||||
|
|
||||||
if [ "$step_value" -eq 0 ]; then
|
if [ "$step_value" -eq 0 ]; then
|
||||||
_log "差値过小,直接设定亮度: $target_bri" "INFO"
|
_log "差値过小,直接设定亮度: $target_bri" "INFO"
|
||||||
echo -n "$target_bri" >"$now_bri_file" && return 0 || return 1
|
echo -n "$target_bri" >"$now_bri_file" || rc=1
|
||||||
|
else
|
||||||
|
_log "开始渐变调整: $start_bri → $target_bri ($steps_num 步)" "INFO"
|
||||||
|
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" || rc=1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
_log "开始渐变调整: $start_bri → $target_bri ($steps_num 步)" "INFO"
|
rm -f "$oplock_file"
|
||||||
for step in $(seq 1 "$steps_num"); do
|
return "$rc"
|
||||||
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() {
|
CHECK_BRI() {
|
||||||
|
|||||||
+1
-1
@@ -35,7 +35,7 @@ _log() {
|
|||||||
sleep 30
|
sleep 30
|
||||||
|
|
||||||
# 清理上次遗留的标记文件
|
# 清理上次遗留的标记文件
|
||||||
rm -f "$MODDIR/pid/"*.flag "$MODDIR/pid/"*.pause "$MODDIR/pid/"*.lock "$MODDIR/pid/.hdr_ratio_cache"
|
rm -f "$MODDIR/pid/"*.flag "$MODDIR/pid/"*.pause "$MODDIR/pid/"*.lock "$MODDIR/pid/oplock" "$MODDIR/pid/.hdr_ratio_cache"
|
||||||
|
|
||||||
_log "LuminPro 服务启动" "INFO"
|
_log "LuminPro 服务启动" "INFO"
|
||||||
_log "前台最大亮度: $(get_cfg ui_max_bri 0)" "INFO"
|
_log "前台最大亮度: $(get_cfg ui_max_bri 0)" "INFO"
|
||||||
|
|||||||
+56
-9
@@ -5,6 +5,7 @@ import { runCmd, showToast } from './utils.js'
|
|||||||
import { useStatus } from './composables/useStatus.js'
|
import { useStatus } from './composables/useStatus.js'
|
||||||
import { useConfig } from './composables/useConfig.js'
|
import { useConfig } from './composables/useConfig.js'
|
||||||
import { useLog } from './composables/useLog.js'
|
import { useLog } from './composables/useLog.js'
|
||||||
|
import { useOplock } from './composables/useOplock.js'
|
||||||
import BottomNav from './components/BottomNav.vue'
|
import BottomNav from './components/BottomNav.vue'
|
||||||
import StatusView from './views/StatusView.vue'
|
import StatusView from './views/StatusView.vue'
|
||||||
import ConfigView from './views/ConfigView.vue'
|
import ConfigView from './views/ConfigView.vue'
|
||||||
@@ -25,33 +26,66 @@ const moduleVersion = ref('')
|
|||||||
const status = useStatus()
|
const status = useStatus()
|
||||||
const config = useConfig()
|
const config = useConfig()
|
||||||
const log = useLog()
|
const log = useLog()
|
||||||
|
const oplock = useOplock()
|
||||||
|
|
||||||
// 供子组件使用
|
// 供子组件使用
|
||||||
provide('showToast', showToast)
|
provide('showToast', showToast)
|
||||||
provide('status', status)
|
provide('status', status)
|
||||||
provide('config', config)
|
provide('config', config)
|
||||||
provide('log', log)
|
provide('log', log)
|
||||||
|
provide('oplock', oplock)
|
||||||
|
|
||||||
|
// 操作锁探测间隔:锁定期间用短间隔以便尽快感知结束;自动刷新关闭时用较轻的空闲间隔
|
||||||
|
const LOCK_POLL_INTERVAL = 300
|
||||||
|
const LOCK_IDLE_INTERVAL = 2000
|
||||||
let refreshTimer = null
|
let refreshTimer = null
|
||||||
|
let refreshStopped = false
|
||||||
|
let _prevLocked = false
|
||||||
|
|
||||||
function startRefresh() {
|
function startRefresh() {
|
||||||
stopRefresh()
|
stopRefresh()
|
||||||
if (!config.autoRefresh.value) return
|
refreshStopped = false
|
||||||
const interval = config.statusRefreshInterval.value
|
refreshTimer = setTimeout(tick, config.statusRefreshInterval.value)
|
||||||
refreshTimer = setInterval(async () => {
|
|
||||||
try {
|
|
||||||
await Promise.all([status.load(), log.load()])
|
|
||||||
} catch {}
|
|
||||||
}, interval)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function stopRefresh() {
|
function stopRefresh() {
|
||||||
|
refreshStopped = true
|
||||||
if (refreshTimer) {
|
if (refreshTimer) {
|
||||||
clearInterval(refreshTimer)
|
clearTimeout(refreshTimer)
|
||||||
refreshTimer = null
|
refreshTimer = null
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function tick() {
|
||||||
|
refreshTimer = null
|
||||||
|
if (refreshStopped) return
|
||||||
|
|
||||||
|
let locked = false
|
||||||
|
try {
|
||||||
|
locked = await oplock.refresh()
|
||||||
|
} catch {}
|
||||||
|
|
||||||
|
if (locked) {
|
||||||
|
// 锁定期间不刷新数据,仅以更短间隔探测锁释放
|
||||||
|
_prevLocked = true
|
||||||
|
refreshTimer = setTimeout(tick, LOCK_POLL_INTERVAL)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// 锁刚释放时强制全量刷新,否则亮度值会停留在操作前的旧值
|
||||||
|
try {
|
||||||
|
if (config.autoRefresh.value) {
|
||||||
|
await Promise.all([status.load(_prevLocked), log.load()])
|
||||||
|
} else if (_prevLocked) {
|
||||||
|
await status.load(true)
|
||||||
|
}
|
||||||
|
} catch {}
|
||||||
|
_prevLocked = false
|
||||||
|
|
||||||
|
const next = config.autoRefresh.value ? config.statusRefreshInterval.value : LOCK_IDLE_INTERVAL
|
||||||
|
refreshTimer = setTimeout(tick, next)
|
||||||
|
}
|
||||||
|
|
||||||
function restartRefresh(enabled, interval) {
|
function restartRefresh(enabled, interval) {
|
||||||
config.autoRefresh.value = enabled
|
config.autoRefresh.value = enabled
|
||||||
config.statusRefreshInterval.value = interval
|
config.statusRefreshInterval.value = interval
|
||||||
@@ -133,7 +167,19 @@ function handleViewChange(view) {
|
|||||||
<!-- 顶部状态栏渐变模糊 -->
|
<!-- 顶部状态栏渐变模糊 -->
|
||||||
<div class="top-blur"></div>
|
<div class="top-blur"></div>
|
||||||
|
|
||||||
<div id="app" :class="{ 'header-hidden': headerHidden }">
|
<div
|
||||||
|
id="app"
|
||||||
|
:class="{ 'header-hidden': headerHidden }"
|
||||||
|
:style="oplock.isLocked.value ? { '--oplock-offset': '32px' } : {}"
|
||||||
|
>
|
||||||
|
<!-- 操作锁横幅 -->
|
||||||
|
<Transition name="oplock-fade">
|
||||||
|
<div v-if="oplock.isLocked.value" class="oplock-banner" role="status">
|
||||||
|
<span class="oplock-spinner"></span>
|
||||||
|
<span>正在执行后台操作,已暂停刷新</span>
|
||||||
|
</div>
|
||||||
|
</Transition>
|
||||||
|
|
||||||
<!-- 顶部头 -->
|
<!-- 顶部头 -->
|
||||||
<header class="app-header" ref="headerEl">
|
<header class="app-header" ref="headerEl">
|
||||||
<div class="header-content">
|
<div class="header-content">
|
||||||
@@ -159,6 +205,7 @@ function handleViewChange(view) {
|
|||||||
<button
|
<button
|
||||||
class="btn-status-action"
|
class="btn-status-action"
|
||||||
id="btn-restart-service"
|
id="btn-restart-service"
|
||||||
|
:disabled="oplock.isLocked.value"
|
||||||
@click="status.restartService(showToast)"
|
@click="status.restartService(showToast)"
|
||||||
>
|
>
|
||||||
重启模块
|
重启模块
|
||||||
|
|||||||
@@ -460,6 +460,15 @@ input:checked + .slider:before {
|
|||||||
height: 28px;
|
height: 28px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.brightness-slider:disabled {
|
||||||
|
opacity: 0.5;
|
||||||
|
cursor: not-allowed;
|
||||||
|
}
|
||||||
|
|
||||||
|
.brightness-slider:disabled:hover {
|
||||||
|
height: 24px;
|
||||||
|
}
|
||||||
|
|
||||||
.brightness-slider::-webkit-slider-thumb {
|
.brightness-slider::-webkit-slider-thumb {
|
||||||
-webkit-appearance: none;
|
-webkit-appearance: none;
|
||||||
appearance: none;
|
appearance: none;
|
||||||
|
|||||||
@@ -0,0 +1,23 @@
|
|||||||
|
import { ref } from 'vue'
|
||||||
|
import { runCmd, OPLOCK_FILE } from '../utils.js'
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 操作锁:后台脚本 (up.sh 渐变 / boost.sh 峰值 / restart.sh 重启) 写亮度节点期间
|
||||||
|
* 会创建 oplock 并写入自身 PID。WebUI 据此暂停刷新、禁用写操作。
|
||||||
|
* 锁文件中的 PID 不存在时视为遗留锁,就地清理并放行。
|
||||||
|
*/
|
||||||
|
export function useOplock() {
|
||||||
|
const isLocked = ref(false)
|
||||||
|
|
||||||
|
async function refresh() {
|
||||||
|
const res = await runCmd(
|
||||||
|
`F="${OPLOCK_FILE}"; if [ -f "$F" ]; then P="$(cat "$F" 2>/dev/null)"; ` +
|
||||||
|
`if [ -n "$P" ] && [ -d "/proc/$P" ]; then echo locked; ` +
|
||||||
|
`else rm -f "$F"; echo free; fi; else echo free; fi`,
|
||||||
|
)
|
||||||
|
isLocked.value = res.errno === 0 && res.stdout.trim() === 'locked'
|
||||||
|
return isLocked.value
|
||||||
|
}
|
||||||
|
|
||||||
|
return { isLocked, refresh }
|
||||||
|
}
|
||||||
+56
-1
@@ -1,7 +1,7 @@
|
|||||||
/* Header */
|
/* Header */
|
||||||
.app-header {
|
.app-header {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
top: 0;
|
top: var(--oplock-offset, 0);
|
||||||
left: 0;
|
left: 0;
|
||||||
right: 0;
|
right: 0;
|
||||||
z-index: 10;
|
z-index: 10;
|
||||||
@@ -111,6 +111,61 @@
|
|||||||
opacity: 1;
|
opacity: 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.btn-status-action:disabled {
|
||||||
|
opacity: 0.4;
|
||||||
|
cursor: not-allowed;
|
||||||
|
pointer-events: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* 操作锁横幅 */
|
||||||
|
.oplock-banner {
|
||||||
|
position: fixed;
|
||||||
|
top: 0;
|
||||||
|
left: 0;
|
||||||
|
right: 0;
|
||||||
|
z-index: 20;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
gap: 8px;
|
||||||
|
padding: 8px 16px;
|
||||||
|
font-size: 0.8125rem;
|
||||||
|
font-weight: 500;
|
||||||
|
color: var(--md-sys-color-on-surface);
|
||||||
|
background: var(--md-sys-color-surface-container-high);
|
||||||
|
border-bottom: 1px solid var(--md-sys-color-outline-variant);
|
||||||
|
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.12);
|
||||||
|
}
|
||||||
|
|
||||||
|
.oplock-spinner {
|
||||||
|
width: 14px;
|
||||||
|
height: 14px;
|
||||||
|
flex-shrink: 0;
|
||||||
|
border: 2px solid var(--md-sys-color-primary);
|
||||||
|
border-top-color: transparent;
|
||||||
|
border-radius: 50%;
|
||||||
|
animation: oplock-spin 0.8s linear infinite;
|
||||||
|
}
|
||||||
|
|
||||||
|
@keyframes oplock-spin {
|
||||||
|
to {
|
||||||
|
transform: rotate(360deg);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.oplock-fade-enter-active,
|
||||||
|
.oplock-fade-leave-active {
|
||||||
|
transition:
|
||||||
|
opacity 0.2s,
|
||||||
|
transform 0.2s;
|
||||||
|
}
|
||||||
|
|
||||||
|
.oplock-fade-enter-from,
|
||||||
|
.oplock-fade-leave-to {
|
||||||
|
opacity: 0;
|
||||||
|
transform: translateY(-100%);
|
||||||
|
}
|
||||||
|
|
||||||
.status-dot {
|
.status-dot {
|
||||||
width: 10px;
|
width: 10px;
|
||||||
height: 10px;
|
height: 10px;
|
||||||
|
|||||||
+1
-1
@@ -117,7 +117,7 @@ body::-webkit-scrollbar {
|
|||||||
overflow-y: auto;
|
overflow-y: auto;
|
||||||
overflow-x: hidden;
|
overflow-x: hidden;
|
||||||
padding: 12px;
|
padding: 12px;
|
||||||
padding-top: var(--header-height, 120px);
|
padding-top: calc(var(--header-height, 120px) + var(--oplock-offset, 0px));
|
||||||
padding-bottom: calc(16px + 80px + var(--safe-area-inset-bottom, 0px));
|
padding-bottom: calc(16px + 80px + var(--safe-area-inset-bottom, 0px));
|
||||||
scrollbar-width: none;
|
scrollbar-width: none;
|
||||||
-ms-overflow-style: none;
|
-ms-overflow-style: none;
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ export const BACKUP_CONFIG_FILE = `${MODULE_DIR}/config/.backup/config.json`
|
|||||||
export const PID_FILE = `${MODULE_DIR}/pid/inotifyd.pid`
|
export const PID_FILE = `${MODULE_DIR}/pid/inotifyd.pid`
|
||||||
export const FLAG_FILE = `${MODULE_DIR}/pid/up.flag`
|
export const FLAG_FILE = `${MODULE_DIR}/pid/up.flag`
|
||||||
export const STOP_FLAG_FILE = `${MODULE_DIR}/pid/stop.flag`
|
export const STOP_FLAG_FILE = `${MODULE_DIR}/pid/stop.flag`
|
||||||
|
export const OPLOCK_FILE = `${MODULE_DIR}/pid/oplock`
|
||||||
export const LOG_FILE = `${MODULE_DIR}/service.log`
|
export const LOG_FILE = `${MODULE_DIR}/service.log`
|
||||||
export const DEFAULT_NOW_BRI_FILE = '/sys/class/backlight/panel0-backlight/brightness'
|
export const DEFAULT_NOW_BRI_FILE = '/sys/class/backlight/panel0-backlight/brightness'
|
||||||
export const DEFAULT_SYS_MAX_BRI_FILE = '/sys/class/backlight/panel0-backlight/max_brightness'
|
export const DEFAULT_SYS_MAX_BRI_FILE = '/sys/class/backlight/panel0-backlight/max_brightness'
|
||||||
@@ -53,6 +54,7 @@ export async function runCmd(cmd) {
|
|||||||
return { errno: 0, stdout: '12345', stderr: '' }
|
return { errno: 0, stdout: '12345', stderr: '' }
|
||||||
if (cmd.includes('[ -f') && cmd.includes('stop.flag'))
|
if (cmd.includes('[ -f') && cmd.includes('stop.flag'))
|
||||||
return { errno: 0, stdout: '0', stderr: '' }
|
return { errno: 0, stdout: '0', stderr: '' }
|
||||||
|
if (cmd.includes('oplock')) return { errno: 0, stdout: 'free', stderr: '' }
|
||||||
if (cmd.includes('cat') && (cmd.includes('brightness') || cmd.includes('now_bri')))
|
if (cmd.includes('cat') && (cmd.includes('brightness') || cmd.includes('now_bri')))
|
||||||
return { errno: 0, stdout: '1200', stderr: '' }
|
return { errno: 0, stdout: '1200', stderr: '' }
|
||||||
if (cmd.includes('cat') && (cmd.includes('max_brightness') || cmd.includes('max_bri')))
|
if (cmd.includes('cat') && (cmd.includes('max_brightness') || cmd.includes('max_bri')))
|
||||||
|
|||||||
@@ -26,6 +26,7 @@ import {
|
|||||||
} from 'lucide-vue-next'
|
} from 'lucide-vue-next'
|
||||||
|
|
||||||
const showToast = inject('showToast')
|
const showToast = inject('showToast')
|
||||||
|
const oplock = inject('oplock')
|
||||||
const appsMenuOpen = ref(false)
|
const appsMenuOpen = ref(false)
|
||||||
|
|
||||||
const {
|
const {
|
||||||
@@ -312,6 +313,7 @@ function retryPicker() {
|
|||||||
white-space: nowrap;
|
white-space: nowrap;
|
||||||
flex-shrink: 0;
|
flex-shrink: 0;
|
||||||
"
|
"
|
||||||
|
:disabled="oplock.isLocked.value"
|
||||||
@click="save(showToast)"
|
@click="save(showToast)"
|
||||||
>保存</Button
|
>保存</Button
|
||||||
>
|
>
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ import { runCmd } from '../utils.js'
|
|||||||
const config = inject('config')
|
const config = inject('config')
|
||||||
const showToast = inject('showToast')
|
const showToast = inject('showToast')
|
||||||
const restartRefresh = inject('restartRefresh')
|
const restartRefresh = inject('restartRefresh')
|
||||||
|
const oplock = inject('oplock')
|
||||||
|
|
||||||
const advancedOpen = ref(false)
|
const advancedOpen = ref(false)
|
||||||
const webuiOpen = ref(false)
|
const webuiOpen = ref(false)
|
||||||
@@ -241,12 +242,15 @@ function handleSaveWebUI() {
|
|||||||
<div class="card-actions">
|
<div class="card-actions">
|
||||||
<Button
|
<Button
|
||||||
variant="outline"
|
variant="outline"
|
||||||
|
:disabled="oplock.isLocked.value"
|
||||||
@click="handleReset"
|
@click="handleReset"
|
||||||
:class="resetConfirming ? 'border-destructive text-destructive' : ''"
|
:class="resetConfirming ? 'border-destructive text-destructive' : ''"
|
||||||
>
|
>
|
||||||
{{ resetConfirming ? '确认恢复?' : '恢复默认' }}
|
{{ resetConfirming ? '确认恢复?' : '恢复默认' }}
|
||||||
</Button>
|
</Button>
|
||||||
<Button @click="config.save(showToast)"> <Save :size="15" /> 保存配置 </Button>
|
<Button :disabled="oplock.isLocked.value" @click="config.save(showToast)">
|
||||||
|
<Save :size="15" /> 保存配置
|
||||||
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
@@ -343,7 +347,10 @@ function handleSaveWebUI() {
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="card-actions">
|
<div class="card-actions">
|
||||||
<Button @click="config.saveAdvanced(showToast, () => {})">
|
<Button
|
||||||
|
:disabled="oplock.isLocked.value"
|
||||||
|
@click="config.saveAdvanced(showToast, () => {})"
|
||||||
|
>
|
||||||
<Save :size="15" /> 保存设置
|
<Save :size="15" /> 保存设置
|
||||||
</Button>
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -17,6 +17,7 @@ import {
|
|||||||
const status = inject('status')
|
const status = inject('status')
|
||||||
const showToast = inject('showToast')
|
const showToast = inject('showToast')
|
||||||
const config = inject('config')
|
const config = inject('config')
|
||||||
|
const oplock = inject('oplock')
|
||||||
|
|
||||||
const confirmedLowBri = ref(false)
|
const confirmedLowBri = ref(false)
|
||||||
|
|
||||||
@@ -105,6 +106,7 @@ const statusItems = computed(() => [
|
|||||||
:max="status.sysMaxBri.value || 255"
|
:max="status.sysMaxBri.value || 255"
|
||||||
:value="status.currentBri.value || 0"
|
:value="status.currentBri.value || 0"
|
||||||
:style="sliderStyle"
|
:style="sliderStyle"
|
||||||
|
:disabled="oplock.isLocked.value"
|
||||||
@change="onSliderChange"
|
@change="onSliderChange"
|
||||||
/>
|
/>
|
||||||
<span class="brightness-label">100%</span>
|
<span class="brightness-label">100%</span>
|
||||||
|
|||||||
Reference in new issue
Block a user