mirror of
https://github.com/YuleBest/LuminPro.git
synced 2026-12-04 00:54:42 +08:00
style(webui): Web UI 动画优化
This commit is contained in:
1 parent
c14fcc446b
commit
d81c494ba2
7 files changed
+70
-25
No files matched your search
+26
-12
@@ -1,5 +1,5 @@
|
||||
<script setup>
|
||||
import { ref, provide, onMounted, onUnmounted, watch } from 'vue'
|
||||
import { ref, computed, provide, onMounted, onUnmounted, watch } from 'vue'
|
||||
import { moduleInfo } from 'kernelsu'
|
||||
import { runCmd, showToast } from './utils.js'
|
||||
import { useStatus } from './composables/useStatus.js'
|
||||
@@ -12,7 +12,13 @@ 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 trackStyle = computed(() => {
|
||||
const idx = NAV_ORDER.indexOf(currentView.value)
|
||||
return { transform: `translateX(${-idx * 100}%)` }
|
||||
})
|
||||
const moduleVersion = ref('')
|
||||
const status = useStatus()
|
||||
const config = useConfig()
|
||||
@@ -72,8 +78,7 @@ onMounted(async () => {
|
||||
moduleVersion.value = '[debug]'
|
||||
}
|
||||
|
||||
// 页面滚动监听
|
||||
window.addEventListener('scroll', onScroll, { passive: true })
|
||||
window.removeEventListener('scroll', onPageScroll)
|
||||
|
||||
// 初始加载
|
||||
try {
|
||||
@@ -85,17 +90,22 @@ onMounted(async () => {
|
||||
|
||||
onUnmounted(() => {
|
||||
stopRefresh()
|
||||
window.removeEventListener('scroll', onScroll)
|
||||
_mq?.removeEventListener('change', _onSystemTheme)
|
||||
})
|
||||
|
||||
function onScroll() {
|
||||
function onPageScroll(e) {
|
||||
const topBlur = document.querySelector('.top-blur')
|
||||
if (topBlur) topBlur.classList.toggle('scrolled', window.scrollY > 10)
|
||||
if (topBlur) topBlur.classList.toggle('scrolled', e.target.scrollTop > 10)
|
||||
}
|
||||
|
||||
function handleViewChange(view) {
|
||||
currentView.value = view
|
||||
// 切换页面时同步更新 top-blur 状态
|
||||
const idx = NAV_ORDER.indexOf(view)
|
||||
const slides = document.querySelectorAll('.page-slide')
|
||||
const slide = slides[idx]
|
||||
const topBlur = document.querySelector('.top-blur')
|
||||
if (topBlur) topBlur.classList.toggle('scrolled', slide ? slide.scrollTop > 10 : false)
|
||||
}
|
||||
</script>
|
||||
|
||||
@@ -138,12 +148,16 @@ function handleViewChange(view) {
|
||||
</div>
|
||||
</header>
|
||||
|
||||
<!-- 各视图(v-show 保持 DOM 以维持状态) -->
|
||||
<StatusView v-show="currentView === 'status'" />
|
||||
<ConfigView v-show="currentView === 'config'" />
|
||||
<AppsView v-show="currentView === 'apps'" />
|
||||
<LogView v-show="currentView === 'log'" />
|
||||
<AboutView v-show="currentView === 'about'" />
|
||||
<!-- 左右滑动页面区 -->
|
||||
<div class="page-viewport" @scroll.capture.passive="onPageScroll">
|
||||
<div class="page-track" :style="trackStyle">
|
||||
<div class="page-slide"><StatusView /></div>
|
||||
<div class="page-slide"><ConfigView /></div>
|
||||
<div class="page-slide"><AppsView /></div>
|
||||
<div class="page-slide"><LogView /></div>
|
||||
<div class="page-slide"><AboutView /></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 底栏导航 -->
|
||||
|
||||
@@ -383,6 +383,7 @@ input:checked + .slider:before {
|
||||
appearance: none;
|
||||
cursor: grab;
|
||||
transition:
|
||||
background 0.35s ease,
|
||||
height 0.2s,
|
||||
box-shadow 0.2s;
|
||||
border: 1px solid rgba(255, 255, 255, 0.03);
|
||||
|
||||
@@ -23,18 +23,16 @@ const navbarEl = ref(null)
|
||||
const sliderEl = ref(null)
|
||||
const btnRefs = ref([])
|
||||
|
||||
const TRANSITION_ON = 'transform 0.3s cubic-bezier(0.25, 1, 0.5, 1), width 0.3s ease'
|
||||
|
||||
function updateSlider(key, animate = true) {
|
||||
const idx = navItems.findIndex((n) => n.key === key)
|
||||
if (idx < 0) return
|
||||
const btn = btnRefs.value[idx]
|
||||
if (!btn || !sliderEl.value) return
|
||||
if (!animate) sliderEl.value.style.transition = 'none'
|
||||
sliderEl.value.style.transition = animate ? TRANSITION_ON : 'none'
|
||||
sliderEl.value.style.width = btn.offsetWidth + 'px'
|
||||
sliderEl.value.style.transform = `translateX(${btn.offsetLeft}px)`
|
||||
if (!animate)
|
||||
requestAnimationFrame(() => {
|
||||
if (sliderEl.value) sliderEl.value.style.transition = ''
|
||||
})
|
||||
}
|
||||
|
||||
function select(key) {
|
||||
|
||||
+1
-3
@@ -152,9 +152,7 @@
|
||||
height: auto;
|
||||
background: var(--md-sys-color-primary-container);
|
||||
border-radius: 20px;
|
||||
transition:
|
||||
transform 0.3s cubic-bezier(0.25, 1, 0.5, 1),
|
||||
width 0.3s ease;
|
||||
will-change: transform, width;
|
||||
pointer-events: none;
|
||||
z-index: 0;
|
||||
}
|
||||
|
||||
+36
-2
@@ -78,11 +78,45 @@ body::-webkit-scrollbar {
|
||||
}
|
||||
|
||||
#app {
|
||||
padding: 12px;
|
||||
padding-bottom: calc(12px + 80px);
|
||||
padding: 0;
|
||||
max-width: 600px;
|
||||
margin: 0 auto;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
height: 100dvh;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
/* 滑动页面轨道 */
|
||||
.page-viewport {
|
||||
flex: 1;
|
||||
min-height: 0;
|
||||
overflow: hidden;
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.page-track {
|
||||
display: flex;
|
||||
height: 100%;
|
||||
transition: transform 0.38s cubic-bezier(0.25, 1, 0.5, 1);
|
||||
will-change: transform;
|
||||
}
|
||||
|
||||
.page-slide {
|
||||
width: 100%;
|
||||
flex-shrink: 0;
|
||||
height: 100%;
|
||||
overflow-y: auto;
|
||||
overflow-x: hidden;
|
||||
padding: 12px;
|
||||
padding-bottom: calc(16px + 80px + var(--safe-area-inset-bottom, 0px));
|
||||
scrollbar-width: none;
|
||||
-ms-overflow-style: none;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: var(--spacing-m);
|
||||
}
|
||||
|
||||
.page-slide::-webkit-scrollbar {
|
||||
display: none;
|
||||
}
|
||||
@@ -42,7 +42,7 @@ function setTheme(v) {
|
||||
}
|
||||
|
||||
async function viewInotifyHelp() {
|
||||
const msg = `支持的事件字母 (toybox inotifyd 兼容):
|
||||
const msg = `支持的事件字母 (toybox/busybox inotifyd 兼容):
|
||||
a = accessed 读取
|
||||
c = modified 内容修改 (亮度节点推荐用此)
|
||||
e = metadata change 属性变更
|
||||
|
||||
@@ -64,8 +64,8 @@ async function onSliderChange(e) {
|
||||
const statusItems = computed(() => [
|
||||
{ label: '当前亮度', value: status.currentBri.value || '—', icon: SunMedium },
|
||||
{ label: '系统最大亮度', value: status.sysMaxBri.value || '—', icon: Smartphone },
|
||||
{ label: 'inotifyd PID', value: status.inotifydPid.value, icon: Activity },
|
||||
{ label: 'inotifyd 状态', value: status.inotifydState.value, icon: Clock },
|
||||
{ label: 'lumipro PID', value: status.inotifydPid.value, icon: Activity },
|
||||
{ label: 'lumipro 状态', value: status.inotifydState.value, icon: Clock },
|
||||
{ label: '休眠状态', value: status.sleepStatus.value, icon: Moon },
|
||||
{ label: 'HDR/SDR 比率', value: status.hdrRatio.value, icon: Layers },
|
||||
])
|
||||
|
||||
Reference in new issue
Block a user