style(webui): 整体外观优化

This commit is contained in:
YuleBest committed 2026-04-10 08:59:33 +08:00
1 parent 66ff3a6429
commit 19ba371b99
5 files changed
+134 -75

No files matched your search

+11 -16
View File
@@ -16,7 +16,6 @@ const NAV_ORDER = ['status', 'config', 'apps', 'log', 'about']
const currentView = ref('status')
const headerEl = ref(null)
const headerHidden = ref(false)
const lastScrollTops = {}
const trackStyle = computed(() => {
const idx = NAV_ORDER.indexOf(currentView.value)
@@ -104,32 +103,28 @@ onUnmounted(() => {
})
function onPageScroll(e) {
// 只响应 .page-slide 的滚动,忽略内部子滚动容器(如应用列表)
if (!e.target.classList.contains('page-slide')) return
const topBlur = document.querySelector('.top-blur')
const { scrollTop, scrollHeight, clientHeight } = e.target
const { scrollTop } = e.target
if (topBlur) topBlur.classList.toggle('scrolled', scrollTop > 10)
// 根据滚动方向自动隐藏/显示 header
// nearBottom: 接近底部时不触发隐藏,防止弹性滚动引发抖动
const nearBottom = scrollTop + clientHeight >= scrollHeight - 30
const idx = NAV_ORDER.indexOf(currentView.value)
const last = lastScrollTops[idx] ?? 0
if (scrollTop > last + 6 && !nearBottom) {
headerHidden.value = true
} else if (scrollTop < last - 4) {
headerHidden.value = false
}
lastScrollTops[idx] = scrollTop
headerHidden.value = scrollTop > 0
}
function handleViewChange(view) {
currentView.value = view
headerHidden.value = false // 切换页面时恢复显示 header
// 切换页面时同步更新 top-blur 状态
const idx = NAV_ORDER.indexOf(view)
const slides = document.querySelectorAll('.page-slide')
const slide = slides[idx]
// 切换页面时回顶
if (slide) slide.scrollTop = 0
// 切换后 top-blur 跟随新页面状态(已回顶故一定为 false)
const topBlur = document.querySelector('.top-blur')
if (topBlur) topBlur.classList.toggle('scrolled', slide ? slide.scrollTop > 10 : false)
if (topBlur) topBlur.classList.remove('scrolled')
}
</script>
+40 -9
View File
@@ -92,18 +92,18 @@
/* Config Items */
.config-group {
margin-top: var(--spacing-l);
margin-bottom: var(--spacing-l);
padding: var(--spacing-m);
margin-top: 12px;
margin-bottom: 0;
padding: 12px;
background-color: var(--md-sys-color-surface-container);
border-radius: var(--border-radius-m);
border: 1px solid rgba(var(--md-sys-color-on-surface-rgb, 0, 0, 0), 0.05);
}
.group-title {
margin: 0 0 var(--spacing-m) 0;
margin: 0 0 10px 0;
color: var(--md-sys-color-primary);
font-size: 0.9rem;
font-size: 0.875rem;
font-weight: 600;
display: flex;
align-items: center;
@@ -135,9 +135,9 @@
}
.config-item + .config-item {
margin-top: var(--spacing-m);
margin-top: 10px;
border-top: 1px solid rgba(var(--md-sys-color-outline-variant-rgb, 142, 144, 153), 0.1);
padding-top: var(--spacing-m);
padding-top: 10px;
}
.config-label {
@@ -175,6 +175,25 @@
background-color: var(--md-sys-color-surface);
}
.config-select {
padding: 8px 12px;
background-color: var(--md-sys-color-surface-container-high);
border: 1px solid var(--md-sys-color-outline-variant);
border-radius: var(--border-radius-s);
color: var(--md-sys-color-on-surface);
font-size: 1rem;
font-family: inherit;
outline: none;
cursor: pointer;
transition: all 0.2s ease;
}
.config-select:focus {
border-color: var(--md-sys-color-primary);
box-shadow: 0 0 0 2px rgba(var(--md-sys-color-primary-rgb), 0.2);
background-color: var(--md-sys-color-surface);
}
#advanced-section .config-input {
width: 100%;
text-align: left;
@@ -317,6 +336,7 @@ input:checked + .slider:before {
display: grid;
grid-template-columns: 1fr 1fr;
gap: var(--spacing-m);
margin-top: var(--spacing-m);
}
.status-item {
@@ -497,12 +517,23 @@ input:checked + .slider:before {
}
/* Actions */
.unsaved-dot {
display: inline-block;
width: 7px;
height: 7px;
border-radius: 50%;
background: var(--md-sys-color-error);
margin-left: 6px;
vertical-align: middle;
flex-shrink: 0;
}
.card-actions {
display: flex;
justify-content: flex-end;
gap: 12px;
margin-top: var(--spacing-l);
padding-top: var(--spacing-m);
margin-top: 16px;
padding-top: 12px;
border-top: 1px solid var(--md-sys-color-outline-variant);
}
+43 -2
View File
@@ -1,4 +1,4 @@
import { ref } from 'vue'
import { ref, watch } from 'vue'
import {
runCmd,
readConfig,
@@ -34,6 +34,11 @@ export function useConfig() {
const debugMode = ref(false)
const logLevel = ref('info')
// 脸污标记
const dirty = ref(false)
const dirtyAdvanced = ref(false)
let _silent = false
// Web UI 配置 (localStorage 持久化)
const autoRefresh = ref(localStorage.getItem('autoRefresh') !== 'false')
const statusRefreshInterval = ref(
@@ -44,9 +49,38 @@ export function useConfig() {
)
const themeMode = ref(localStorage.getItem('themeMode') || 'system')
// 监听主配置字段
watch(
[
uiMaxBri,
maxBri,
stepsNum,
logMaxSize,
autoBriSleep,
displayHdrSleep,
sleepMode,
sleepStartH,
sleepStartM,
sleepEndH,
sleepEndM,
logLevel,
],
() => {
if (!_silent) dirty.value = true
},
)
// 监听高级设置字段
watch([nowBriFile, sysMaxBriFile, inotifyEvents, debugMode], () => {
if (!_silent) dirtyAdvanced.value = true
})
async function load() {
_silent = true
const cfg = await readConfig()
if (!cfg || Object.keys(cfg).length === 0) return
if (!cfg || Object.keys(cfg).length === 0) {
_silent = false
return
}
uiMaxBri.value = cfg.ui_max_bri != null ? String(cfg.ui_max_bri) : ''
maxBri.value = cfg.max_bri != null ? String(cfg.max_bri) : ''
@@ -75,6 +109,9 @@ export function useConfig() {
} else {
sleepMode.value = false
}
dirty.value = false
dirtyAdvanced.value = false
_silent = false
}
function getSleepTimeStr() {
@@ -109,6 +146,7 @@ export function useConfig() {
? '配置已保存 (下次调整时生效)'
: '配置已保存 (服务未运行)',
)
dirty.value = false
}
async function saveAdvanced(toast, onPathsChanged) {
@@ -121,6 +159,7 @@ export function useConfig() {
})
onPathsChanged?.()
toast('高级设置已保存,需重启服务生效')
dirtyAdvanced.value = false
}
async function resetToDefaults(toast) {
@@ -215,6 +254,8 @@ export function useConfig() {
inotifyEvents,
debugMode,
logLevel,
dirty,
dirtyAdvanced,
autoRefresh,
statusRefreshInterval,
uiZoom,
+3 -1
View File
@@ -49,6 +49,7 @@
html {
scrollbar-width: none; /* Firefox */
-ms-overflow-style: none; /* IE/Edge */
background-color: var(--md-sys-color-background);
}
html::-webkit-scrollbar {
@@ -58,6 +59,7 @@ html::-webkit-scrollbar {
body {
margin: 0;
padding: 0;
zoom: 0.95;
/* insets 会在这里被 internal/insets.css 处理,我们预留顶底内边距 */
padding-top: var(--safe-area-inset-top, 0);
padding-bottom: var(--safe-area-inset-bottom, 0);
@@ -84,7 +86,7 @@ body::-webkit-scrollbar {
margin: 0 auto;
display: flex;
flex-direction: column;
height: 100dvh;
height: calc(100dvh / 0.95);
overflow: hidden;
}
+37 -47
View File
@@ -82,7 +82,11 @@ function handleSaveWebUI() {
<div style="display: contents">
<!-- === 亮度配置 === -->
<section class="card" id="config-section" data-nav-group="config">
<div class="card-header"><h2>亮度配置</h2></div>
<div class="card-header">
<h2>
亮度配置<span v-if="config.dirty.value" class="unsaved-dot" title="有未保存的更改"></span>
</h2>
</div>
<div class="config-group">
<h3 class="group-title"><Settings2 :size="16" /> 亮度调节</h3>
@@ -134,7 +138,7 @@ function handleSaveWebUI() {
<span class="config-name">显示 HDR 内容时休眠</span>
<span class="config-desc">HDR/SDR 比率 &gt; 1 时不提升</span>
<span class="config-desc" style="color: var(--color-warning)"
>建议配合去温控使用。出现闪屏时可改用黑名单功能</span
>出现闪屏建议改用黑名单</span
>
</div>
<Switch v-model="config.displayHdrSleep.value" />
@@ -212,24 +216,14 @@ function handleSaveWebUI() {
<div class="config-item">
<div class="config-label">
<span class="config-name">日志等级</span>
<span class="config-desc">低于该等级的日志不写入文件</span>
</div>
<div class="theme-seg">
<button
v-for="opt in [
{ v: 'off', l: '关闭' },
{ v: 'error', l: '错误' },
{ v: 'warn', l: '警告' },
{ v: 'info', l: '全部' },
]"
:key="opt.v"
class="theme-seg-btn"
:class="{ active: config.logLevel.value === opt.v }"
@click="config.logLevel.value = opt.v"
>
{{ opt.l }}
</button>
<span class="config-desc">低于此级别不写入日志</span>
</div>
<select v-model="config.logLevel.value" class="config-select">
<option value="off">关闭</option>
<option value="error">仅错误</option>
<option value="warn">警告+</option>
<option value="info">全部</option>
</select>
</div>
</div>
@@ -248,7 +242,13 @@ function handleSaveWebUI() {
<!-- === 高级设置 === -->
<section class="card" id="advanced-section" data-nav-group="config">
<div class="card-header card-header-toggle" @click="advancedOpen = !advancedOpen">
<h2>高级设置</h2>
<h2>
高级设置<span
v-if="config.dirtyAdvanced.value"
class="unsaved-dot"
title="有未保存的更改"
></span>
</h2>
<ChevronDown :size="18" class="collapse-chevron" :class="{ open: advancedOpen }" />
</div>
<div class="collapsible-body" :class="{ open: advancedOpen }">
@@ -259,9 +259,9 @@ function handleSaveWebUI() {
<div class="config-item">
<div class="config-label">
<span class="config-name">调试模式</span>
<span class="config-desc">将每个 inotify 事件及防抖触发信息写入日志</span>
<span class="config-desc">记录详细 inotify 事件到日志</span>
<span class="config-desc" style="color: var(--color-warning)"
>开启后需重启服务,日志量增大。诊断完成后请关闭</span
>需重启生效,用完请关闭</span
>
</div>
<Switch v-model="config.debugMode.value" />
@@ -270,10 +270,7 @@ function handleSaveWebUI() {
<div class="config-item">
<div class="config-label">
<span class="config-name">lumipro 监听事件</span>
<span class="config-desc">默认 c(sysfs MODIFY)。修改需重启服务</span>
<span class="config-desc" style="color: var(--color-warning)"
>修改为 c 以外时建议关闭自动刷新</span
>
<span class="config-desc">默认 c,改后需重启</span>
<button
class="btn-text-s"
style="margin-top: 6px; padding: 2px 6px"
@@ -293,7 +290,7 @@ function handleSaveWebUI() {
<div class="config-item" id="advanced-section">
<div class="config-label">
<span class="config-name">当前亮度节点</span>
<span class="config-desc">修改需重启服务</span>
<span class="config-desc">改后需重启</span>
</div>
<Textarea v-model="config.nowBriFile.value" class="config-textarea" />
</div>
@@ -301,7 +298,7 @@ function handleSaveWebUI() {
<div class="config-item">
<div class="config-label">
<span class="config-name">最大亮度节点</span>
<span class="config-desc">修改需重启服务</span>
<span class="config-desc">改后需重启</span>
</div>
<Textarea v-model="config.sysMaxBriFile.value" class="config-textarea" />
</div>
@@ -330,7 +327,7 @@ function handleSaveWebUI() {
<div class="config-item">
<div class="config-label">
<span class="config-name">自动刷新</span>
<span class="config-desc">定时刷新状态和日志。监听非 c 事件时建议关闭</span>
<span class="config-desc">定时拉取状态和日志</span>
</div>
<Switch v-model="config.autoRefresh.value" />
</div>
@@ -338,7 +335,7 @@ function handleSaveWebUI() {
<div class="config-item" v-show="config.autoRefresh.value">
<div class="config-label">
<span class="config-name">状态/日志刷新间隔</span>
<span class="config-desc">单位: 毫秒 (最小100ms)</span>
<span class="config-desc">ms,最小 100</span>
</div>
<Input
v-model="config.statusRefreshInterval.value"
@@ -351,29 +348,22 @@ function handleSaveWebUI() {
<div class="config-item">
<div class="config-label">
<span class="config-name">外观主题</span>
<span class="config-desc">深色 / 浅色 / 跟随系统</span>
</div>
<div class="theme-seg">
<button
v-for="opt in [
{ v: 'system', l: '系统' },
{ v: 'light', l: '浅色' },
{ v: 'dark', l: '深色' },
]"
:key="opt.v"
class="theme-seg-btn"
:class="{ active: config.themeMode.value === opt.v }"
@click="setTheme(opt.v)"
>
{{ opt.l }}
</button>
</div>
<select
class="config-select"
:value="config.themeMode.value"
@change="setTheme($event.target.value)"
>
<option value="system">跟随系统</option>
<option value="light">浅色</option>
<option value="dark">深色</option>
</select>
</div>
<div class="config-item">
<div class="config-label">
<span class="config-name">界面缩放</span>
<span class="config-desc">50% - 150%(立即生效)</span>
<span class="config-desc">50%–150%,立即生效</span>
</div>
<Input
v-model="config.uiZoom.value"