style: 代码格式调整

This commit is contained in:
YuleBest committed 2026-04-10 01:59:23 +08:00
1 parent 21b4ad314a
commit 0882c89150
38 files changed
+2708 -1692

No files matched your search

+11 -13
View File
@@ -1,16 +1,14 @@
<!DOCTYPE html>
<!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" />
</head>
<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" />
</head>
<body>
<div id="app"></div>
<script type="module" src="/src/main.js"></script>
</body>
<body>
<div id="app"></div>
<script type="module" src="/src/main.js"></script>
</body>
</html>
+66 -59
View File
@@ -1,98 +1,101 @@
<script setup>
import { ref, provide, onMounted, onUnmounted, watch } from 'vue';
import { moduleInfo } from 'kernelsu';
import { runCmd, showToast } from './utils.js';
import { useStatus } from './composables/useStatus.js';
import { useConfig } from './composables/useConfig.js';
import { useLog } from './composables/useLog.js';
import BottomNav from './components/BottomNav.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';
import { ref, provide, onMounted, onUnmounted, watch } from 'vue'
import { moduleInfo } from 'kernelsu'
import { runCmd, showToast } from './utils.js'
import { useStatus } from './composables/useStatus.js'
import { useConfig } from './composables/useConfig.js'
import { useLog } from './composables/useLog.js'
import BottomNav from './components/BottomNav.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 currentView = ref('status');
const moduleVersion = ref('');
const status = useStatus();
const config = useConfig();
const log = useLog();
const currentView = ref('status')
const moduleVersion = ref('')
const status = useStatus()
const config = useConfig()
const log = useLog()
// 供子组件使用
provide('showToast', showToast);
provide('status', status);
provide('config', config);
provide('log', log);
provide('showToast', showToast)
provide('status', status)
provide('config', config)
provide('log', log)
let refreshTimer = null;
let refreshTimer = null
function startRefresh() {
stopRefresh();
if (!config.autoRefresh.value) return;
const interval = config.statusRefreshInterval.value;
stopRefresh()
if (!config.autoRefresh.value) return
const interval = config.statusRefreshInterval.value
refreshTimer = setInterval(async () => {
try {
await Promise.all([status.load(), log.load()]);
await Promise.all([status.load(), log.load()])
} catch {}
}, interval);
}, interval)
}
function stopRefresh() {
if (refreshTimer) { clearInterval(refreshTimer); refreshTimer = null; }
if (refreshTimer) {
clearInterval(refreshTimer)
refreshTimer = null
}
}
function restartRefresh(enabled, interval) {
config.autoRefresh.value = enabled;
config.statusRefreshInterval.value = interval;
startRefresh();
config.autoRefresh.value = enabled
config.statusRefreshInterval.value = interval
startRefresh()
}
provide('restartRefresh', restartRefresh);
provide('restartRefresh', restartRefresh)
// 跟随系统色彩偏好变化
let _mq = null;
let _mq = null
function _onSystemTheme() {
if (config.themeMode.value === 'system') config.applyTheme('system');
if (config.themeMode.value === 'system') config.applyTheme('system')
}
onMounted(async () => {
// 应用 UI 缩放 + 主题
config.applyZoom();
config.applyTheme(config.themeMode.value);
_mq = window.matchMedia('(prefers-color-scheme: light)');
_mq.addEventListener('change', _onSystemTheme);
config.applyZoom()
config.applyTheme(config.themeMode.value)
_mq = window.matchMedia('(prefers-color-scheme: light)')
_mq.addEventListener('change', _onSystemTheme)
// 读取模块版本
try {
const info = JSON.parse(moduleInfo());
moduleVersion.value = info.version || '';
const info = JSON.parse(moduleInfo())
moduleVersion.value = info.version || ''
} catch {
moduleVersion.value = '[debug]';
moduleVersion.value = '[debug]'
}
// 页面滚动监听
window.addEventListener('scroll', onScroll, { passive: true });
window.addEventListener('scroll', onScroll, { passive: true })
// 初始加载
try {
await Promise.all([status.load(true), config.load(), log.load()]);
await Promise.all([status.load(true), config.load(), log.load()])
} catch {}
startRefresh();
});
startRefresh()
})
onUnmounted(() => {
stopRefresh();
window.removeEventListener('scroll', onScroll);
_mq?.removeEventListener('change', _onSystemTheme);
});
stopRefresh()
window.removeEventListener('scroll', onScroll)
_mq?.removeEventListener('change', _onSystemTheme)
})
function onScroll() {
const topBlur = document.querySelector('.top-blur');
if (topBlur) topBlur.classList.toggle('scrolled', window.scrollY > 10);
const topBlur = document.querySelector('.top-blur')
if (topBlur) topBlur.classList.toggle('scrolled', window.scrollY > 10)
}
function handleViewChange(view) {
currentView.value = view;
currentView.value = view
}
</script>
@@ -112,19 +115,23 @@ function handleViewChange(view) {
</div>
</div>
<div class="header-status-container">
<div
class="header-status"
id="module-status"
:class="status.statusClass.value"
>
<div class="header-status" id="module-status" :class="status.statusClass.value">
<span class="status-dot"></span>
<span class="status-text">{{ status.statusText.value }}</span>
</div>
<div class="header-status-actions">
<button class="btn-status-action" id="btn-toggle-service" @click="status.toggleService(showToast)">
<button
class="btn-status-action"
id="btn-toggle-service"
@click="status.toggleService(showToast)"
>
{{ status.isPaused.value ? '启用' : '暂停' }}
</button>
<button class="btn-status-action" id="btn-restart-service" @click="status.restartService(showToast)">
<button
class="btn-status-action"
id="btn-restart-service"
@click="status.restartService(showToast)"
>
重启
</button>
</div>
+11 -9
View File
@@ -12,7 +12,11 @@
width: 72px;
height: 72px;
border-radius: 20px;
background: linear-gradient(135deg, var(--md-sys-color-primary-container), var(--md-sys-color-secondary-container));
background: linear-gradient(
135deg,
var(--md-sys-color-primary-container),
var(--md-sys-color-secondary-container)
);
display: flex;
align-items: center;
justify-content: center;
@@ -73,7 +77,7 @@
width: 100%;
}
.about-list-item + .about-list-item {
border-top: 1px solid rgba(var(--md-sys-color-on-surface-rgb, 0,0,0), 0.06);
border-top: 1px solid rgba(var(--md-sys-color-on-surface-rgb, 0, 0, 0), 0.06);
}
.about-list-item:active {
background-color: var(--md-sys-color-surface-container-high);
@@ -103,7 +107,7 @@
.doc-sheet-backdrop {
position: fixed;
inset: 0;
background: rgba(0,0,0,0.5);
background: rgba(0, 0, 0, 0.5);
backdrop-filter: blur(4px);
z-index: 1999;
opacity: 0;
@@ -127,7 +131,7 @@
flex-direction: column;
transform: translateY(100%);
transition: transform 0.35s cubic-bezier(0.19, 1, 0.22, 1);
box-shadow: 0 -8px 32px rgba(0,0,0,0.3);
box-shadow: 0 -8px 32px rgba(0, 0, 0, 0.3);
overflow: hidden;
}
.doc-sheet.show {
@@ -137,7 +141,7 @@
display: flex;
align-items: center;
padding: 16px 16px 12px;
border-bottom: 1px solid rgba(var(--md-sys-color-on-surface-rgb, 0,0,0), 0.07);
border-bottom: 1px solid rgba(var(--md-sys-color-on-surface-rgb, 0, 0, 0), 0.07);
gap: 12px;
flex-shrink: 0;
}
@@ -183,7 +187,8 @@
color: var(--md-sys-color-on-surface);
word-break: break-word;
}
.doc-sheet-content h1, .doc-sheet-content h2 {
.doc-sheet-content h1,
.doc-sheet-content h2 {
color: var(--md-sys-color-primary);
margin-top: 1.4em;
}
@@ -232,7 +237,6 @@
font-weight: 600;
}
/* ==========================================
Theme Segmented Button
========================================== */
@@ -262,5 +266,3 @@
color: var(--md-sys-color-on-primary-container);
font-weight: 600;
}
+28 -8
View File
@@ -14,7 +14,9 @@
border-radius: var(--border-radius-m);
padding: 8px 12px;
margin-bottom: var(--spacing-m);
transition: border-color 0.2s, box-shadow 0.2s;
transition:
border-color 0.2s,
box-shadow 0.2s;
}
.app-search-container:focus-within {
@@ -188,7 +190,11 @@
width: 40px;
height: 40px;
border-radius: 8px;
background: linear-gradient(135deg, var(--md-sys-color-primary-container), rgba(168, 199, 250, 0.5));
background: linear-gradient(
135deg,
var(--md-sys-color-primary-container),
rgba(168, 199, 250, 0.5)
);
color: var(--md-sys-color-on-primary-container);
display: flex;
align-items: center;
@@ -239,7 +245,9 @@
border-radius: var(--border-radius-s);
color: var(--md-sys-color-on-surface-variant);
cursor: pointer;
transition: transform 0.2s, background-color 0.2s;
transition:
transform 0.2s,
background-color 0.2s;
padding: 0;
}
@@ -337,7 +345,9 @@
font-weight: 500;
padding: 3px 8px;
cursor: pointer;
transition: background-color 0.2s, border-color 0.2s;
transition:
background-color 0.2s,
border-color 0.2s;
white-space: nowrap;
font-family: inherit;
}
@@ -363,7 +373,9 @@
font-size: 0.8125rem;
color: var(--md-sys-color-on-surface);
outline: none;
transition: border-color 0.2s, box-shadow 0.2s;
transition:
border-color 0.2s,
box-shadow 0.2s;
}
.activity-block-input:focus {
@@ -437,7 +449,10 @@
height: 6px;
border-radius: 50%;
background-color: var(--md-sys-color-outline-variant);
transition: background-color 0.3s, transform 0.3s, width 0.3s;
transition:
background-color 0.3s,
transform 0.3s,
width 0.3s;
}
.picker-step-dot.active {
@@ -504,8 +519,13 @@
}
@keyframes picker-pulse {
0%, 100% { opacity: 1; }
50% { opacity: 0.35; }
0%,
100% {
opacity: 1;
}
50% {
opacity: 0.35;
}
}
.picker-result-box {
+472 -404
View File
File diff suppressed because it is too large. Load diff
+39 -19
View File
@@ -3,7 +3,9 @@
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);
box-shadow:
0 1px 3px 0 rgba(0, 0, 0, 0.3),
0 4px 8px 3px rgba(0, 0, 0, 0.15);
display: flex;
flex-direction: column;
}
@@ -54,7 +56,7 @@
padding: var(--spacing-m);
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);
border: 1px solid rgba(var(--md-sys-color-on-surface-rgb, 0, 0, 0), 0.05);
}
.group-title {
@@ -67,7 +69,8 @@
gap: 8px;
}
.group-title i, .group-title svg {
.group-title i,
.group-title svg {
width: 16px;
height: 16px;
}
@@ -241,20 +244,20 @@
right: 0;
bottom: 0;
background-color: var(--md-sys-color-surface-container-high);
transition: .4s;
transition: 0.4s;
border-radius: 34px;
border: 2px solid var(--md-sys-color-outline);
}
.slider:before {
position: absolute;
content: "";
content: '';
height: 24px;
width: 24px;
left: 2px;
bottom: 2px;
background-color: var(--md-sys-color-outline);
transition: .4s;
transition: 0.4s;
border-radius: 50%;
}
@@ -282,7 +285,7 @@ input:checked + .slider:before {
display: flex;
flex-direction: column;
gap: 8px;
border: 1px solid rgba(var(--md-sys-color-on-surface-rgb, 0,0,0), 0.04);
border: 1px solid rgba(var(--md-sys-color-on-surface-rgb, 0, 0, 0), 0.04);
transition: transform 0.2s ease;
}
@@ -319,7 +322,11 @@ input:checked + .slider:before {
.brightness-section {
margin-top: var(--spacing-l);
padding: var(--spacing-m);
background: linear-gradient(135deg, var(--md-sys-color-surface-container-high) 0%, var(--md-sys-color-surface-container) 100%);
background: linear-gradient(
135deg,
var(--md-sys-color-surface-container-high) 0%,
var(--md-sys-color-surface-container) 100%
);
border-radius: var(--border-radius-m);
border: 1px solid var(--md-sys-color-outline-variant);
}
@@ -370,14 +377,16 @@ input:checked + .slider:before {
height: 24px;
border-radius: 12px;
/* 背景将由 JS 通过 linear-gradient 动态更新实现进度条效果 */
background: var(--md-sys-color-surface-container-high);
background: var(--md-sys-color-surface-container-high);
outline: none;
-webkit-appearance: none;
appearance: none;
cursor: grab;
transition: height 0.2s, box-shadow 0.2s;
transition:
height 0.2s,
box-shadow 0.2s;
border: 1px solid rgba(255, 255, 255, 0.03);
box-shadow: inset 0 1px 2px rgba(0,0,0,0.2);
box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.2);
overflow: hidden; /* 确保进度条颜色不溢出圆角 */
}
@@ -406,12 +415,16 @@ input:checked + .slider:before {
background: var(--md-sys-color-primary);
cursor: grab;
border: 2px solid var(--md-sys-color-surface);
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4), inset 0 1px 2px rgba(255, 255, 255, 0.3);
box-shadow:
0 2px 8px rgba(0, 0, 0, 0.4),
inset 0 1px 2px rgba(255, 255, 255, 0.3);
transition: all 0.2s;
}
.brightness-slider::-moz-range-thumb:hover {
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5), inset 0 1px 2px rgba(255, 255, 255, 0.3);
box-shadow:
0 4px 12px rgba(0, 0, 0, 0.5),
inset 0 1px 2px rgba(255, 255, 255, 0.3);
transform: scale(1.1);
}
@@ -464,7 +477,9 @@ input:checked + .slider:before {
font-weight: 500;
font-family: inherit;
cursor: pointer;
transition: background-color 0.2s, opacity 0.2s;
transition:
background-color 0.2s,
opacity 0.2s;
}
.btn:active {
@@ -482,7 +497,8 @@ input:checked + .slider:before {
color: var(--md-sys-color-primary);
}
.btn-outline-s, .btn-text-s {
.btn-outline-s,
.btn-text-s {
background-color: transparent;
border: 1px solid var(--md-sys-color-outline-variant);
color: var(--md-sys-color-primary);
@@ -548,7 +564,8 @@ input:checked + .slider:before {
transform: scale(0.9);
}
.btn-icon-only-s i, .btn-icon-only-s svg {
.btn-icon-only-s i,
.btn-icon-only-s svg {
width: 16px;
height: 16px;
}
@@ -557,8 +574,11 @@ input:checked + .slider:before {
animation: spin 1s linear infinite;
}
@keyframes spin {
from { transform: rotate(0deg); }
to { transform: rotate(360deg); }
from {
transform: rotate(0deg);
}
to {
transform: rotate(360deg);
}
}
+78 -67
View File
@@ -1,111 +1,122 @@
<script setup>
import { ref, onMounted, onUnmounted, watch } from 'vue';
import { ref, onMounted, onUnmounted, watch } from 'vue'
import {
Activity as IconActivity,
Settings as IconSettings,
AppWindow as IconApps,
ScrollText as IconLog,
Info as IconInfo,
} from 'lucide-vue-next';
} from 'lucide-vue-next'
const props = defineProps({ modelValue: { type: String, default: 'status' } });
const emit = defineEmits(['update:modelValue']);
const props = defineProps({ modelValue: { type: String, default: 'status' } })
const emit = defineEmits(['update:modelValue'])
const navItems = [
{ key: 'status', label: '状态', icon: IconActivity },
{ key: 'config', label: '配置', icon: IconSettings },
{ key: 'apps', label: '黑名单', icon: IconApps },
{ key: 'log', label: '日志', icon: IconLog },
{ key: 'about', label: '关于', icon: IconInfo },
];
{ key: 'apps', label: '黑名单', icon: IconApps },
{ key: 'log', label: '日志', icon: IconLog },
{ key: 'about', label: '关于', icon: IconInfo },
]
const navbarEl = ref(null);
const sliderEl = ref(null);
const btnRefs = ref([]);
const navbarEl = ref(null)
const sliderEl = ref(null)
const btnRefs = ref([])
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.width = btn.offsetWidth + 'px';
sliderEl.value.style.transform = `translateX(${btn.offsetLeft}px)`;
if (!animate) requestAnimationFrame(() => { if (sliderEl.value) sliderEl.value.style.transition = ''; });
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.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) {
emit('update:modelValue', key);
emit('update:modelValue', key)
}
watch(() => props.modelValue, v => updateSlider(v));
watch(
() => props.modelValue,
(v) => updateSlider(v),
)
// ---- 拖拽逻辑 ----
let isDragging = false;
let isActuallyDragging = false;
let startX = 0;
let startSliderX = 0;
let isDragging = false
let isActuallyDragging = false
let startX = 0
let startSliderX = 0
function onPointerDown(e) {
isDragging = true;
isActuallyDragging = false;
startX = e.clientX;
const idx = navItems.findIndex(n => n.key === props.modelValue);
startSliderX = idx >= 0 && btnRefs.value[idx] ? btnRefs.value[idx].offsetLeft : 0;
isDragging = true
isActuallyDragging = false
startX = e.clientX
const idx = navItems.findIndex((n) => n.key === props.modelValue)
startSliderX = idx >= 0 && btnRefs.value[idx] ? btnRefs.value[idx].offsetLeft : 0
}
function onPointerMove(e) {
if (!isDragging) return;
const dx = e.clientX - startX;
if (!isDragging) return
const dx = e.clientX - startX
if (!isActuallyDragging && Math.abs(dx) > 10) {
isActuallyDragging = true;
navbarEl.value?.setPointerCapture(e.pointerId);
isActuallyDragging = true
navbarEl.value?.setPointerCapture(e.pointerId)
}
if (!isActuallyDragging || !sliderEl.value) return;
const first = btnRefs.value[0];
const last = btnRefs.value[btnRefs.value.length - 1];
const minX = first ? first.offsetLeft : 0;
const maxX = last ? last.offsetLeft : 0;
let tx = startSliderX + dx;
if (tx < minX) tx = minX + (tx - minX) * 0.3;
if (tx > maxX) tx = maxX + (tx - maxX) * 0.3;
sliderEl.value.style.transition = 'none';
sliderEl.value.style.transform = `translateX(${tx}px)`;
if (!isActuallyDragging || !sliderEl.value) return
const first = btnRefs.value[0]
const last = btnRefs.value[btnRefs.value.length - 1]
const minX = first ? first.offsetLeft : 0
const maxX = last ? last.offsetLeft : 0
let tx = startSliderX + dx
if (tx < minX) tx = minX + (tx - minX) * 0.3
if (tx > maxX) tx = maxX + (tx - maxX) * 0.3
sliderEl.value.style.transition = 'none'
sliderEl.value.style.transform = `translateX(${tx}px)`
}
function onPointerUp(e) {
if (!isDragging) return;
const wasDragging = isActuallyDragging;
isDragging = false;
isActuallyDragging = false;
navbarEl.value?.releasePointerCapture(e.pointerId);
if (!isDragging) return
const wasDragging = isActuallyDragging
isDragging = false
isActuallyDragging = false
navbarEl.value?.releasePointerCapture(e.pointerId)
if (wasDragging && sliderEl.value) {
const sliderRect = sliderEl.value.getBoundingClientRect();
const navRect = navbarEl.value?.getBoundingClientRect();
const currentX = navRect ? sliderRect.left - navRect.left : 0;
let closest = navItems[0].key;
let minDist = Infinity;
const sliderRect = sliderEl.value.getBoundingClientRect()
const navRect = navbarEl.value?.getBoundingClientRect()
const currentX = navRect ? sliderRect.left - navRect.left : 0
let closest = navItems[0].key
let minDist = Infinity
btnRefs.value.forEach((btn, i) => {
if (!btn) return;
const dist = Math.abs(btn.offsetLeft - currentX);
if (dist < minDist) { minDist = dist; closest = navItems[i].key; }
});
select(closest);
if (!btn) return
const dist = Math.abs(btn.offsetLeft - currentX)
if (dist < minDist) {
minDist = dist
closest = navItems[i].key
}
})
select(closest)
} else {
updateSlider(props.modelValue);
updateSlider(props.modelValue)
}
}
function onResize() { updateSlider(props.modelValue, false); }
function onResize() {
updateSlider(props.modelValue, false)
}
onMounted(() => {
updateSlider(props.modelValue, false);
window.addEventListener('resize', onResize);
});
updateSlider(props.modelValue, false)
window.addEventListener('resize', onResize)
})
onUnmounted(() => {
window.removeEventListener('resize', onResize);
});
window.removeEventListener('resize', onResize)
})
</script>
<template>
@@ -121,7 +132,7 @@ onUnmounted(() => {
<button
v-for="(item, i) in navItems"
:key="item.key"
:ref="el => btnRefs[i] = el"
:ref="(el) => (btnRefs[i] = el)"
class="navbar-btn"
:class="{ active: modelValue === item.key }"
:data-section="item.key"
+5 -5
View File
@@ -1,6 +1,6 @@
<script setup>
import { cn } from '@/lib/utils';
import { cva } from 'class-variance-authority';
import { cn } from '@/lib/utils'
import { cva } from 'class-variance-authority'
const badgeVariants = cva(
'inline-flex items-center rounded-full px-2 py-0.5 text-xs font-medium transition-colors',
@@ -16,13 +16,13 @@ const badgeVariants = cva(
},
},
defaultVariants: { variant: 'default' },
}
);
},
)
const props = defineProps({
variant: { type: String, default: 'default' },
class: { type: String, default: '' },
});
})
</script>
<template>
+9 -7
View File
@@ -1,6 +1,6 @@
<script setup>
import { cn } from '@/lib/utils';
import { cva } from 'class-variance-authority';
import { cn } from '@/lib/utils'
import { cva } from 'class-variance-authority'
const buttonVariants = cva(
'inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0',
@@ -8,8 +8,10 @@ const buttonVariants = cva(
variants: {
variant: {
default: 'bg-primary text-primary-foreground hover:bg-primary/90 active:bg-primary/80',
destructive: 'bg-destructive/20 text-destructive border border-destructive/40 hover:bg-destructive/30',
outline: 'border border-border bg-transparent hover:bg-secondary hover:text-secondary-foreground',
destructive:
'bg-destructive/20 text-destructive border border-destructive/40 hover:bg-destructive/30',
outline:
'border border-border bg-transparent hover:bg-secondary hover:text-secondary-foreground',
secondary: 'bg-secondary text-secondary-foreground hover:bg-secondary/80',
ghost: 'hover:bg-secondary hover:text-secondary-foreground',
link: 'text-primary underline-offset-4 hover:underline',
@@ -26,8 +28,8 @@ const buttonVariants = cva(
variant: 'default',
size: 'default',
},
}
);
},
)
const props = defineProps({
variant: { type: String, default: 'default' },
@@ -36,7 +38,7 @@ const props = defineProps({
disabled: { type: Boolean, default: false },
type: { type: String, default: 'button' },
as: { type: String, default: 'button' },
});
})
</script>
<template>
+7 -3
View File
@@ -1,13 +1,17 @@
<script setup>
import { cn } from '@/lib/utils';
import { cn } from '@/lib/utils'
const props = defineProps({
class: { type: String, default: '' },
});
})
</script>
<template>
<div :class="cn('rounded-xl border border-border/40 bg-card text-card-foreground shadow-md', props.class)">
<div
:class="
cn('rounded-xl border border-border/40 bg-card text-card-foreground shadow-md', props.class)
"
>
<slot />
</div>
</template>
+9 -7
View File
@@ -1,5 +1,5 @@
<script setup>
import { cn } from '@/lib/utils';
import { cn } from '@/lib/utils'
const props = defineProps({
class: { type: String, default: '' },
@@ -11,9 +11,9 @@ const props = defineProps({
max: { type: [String, Number], default: undefined },
autocomplete: { type: String, default: 'off' },
spellcheck: { type: Boolean, default: false },
});
})
const emit = defineEmits(['update:modelValue']);
const emit = defineEmits(['update:modelValue'])
</script>
<template>
@@ -27,10 +27,12 @@ const emit = defineEmits(['update:modelValue']);
:max="max"
:autocomplete="autocomplete"
:spellcheck="spellcheck"
:class="cn(
'flex h-9 w-full rounded-md border border-input bg-muted px-3 py-1 text-sm text-foreground shadow-sm transition-colors placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:border-primary disabled:cursor-not-allowed disabled:opacity-50',
props.class
)"
:class="
cn(
'flex h-9 w-full rounded-md border border-input bg-muted px-3 py-1 text-sm text-foreground shadow-sm transition-colors placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:border-primary disabled:cursor-not-allowed disabled:opacity-50',
props.class,
)
"
@input="emit('update:modelValue', $event.target.value)"
/>
</template>
+11 -3
View File
@@ -1,14 +1,22 @@
<script setup>
import { cn } from '@/lib/utils';
import { cn } from '@/lib/utils'
const props = defineProps({
class: { type: String, default: '' },
for: { type: String, default: undefined },
});
})
</script>
<template>
<label :for="props.for" :class="cn('text-sm font-medium leading-none text-foreground peer-disabled:cursor-not-allowed peer-disabled:opacity-70', props.class)">
<label
:for="props.for"
:class="
cn(
'text-sm font-medium leading-none text-foreground peer-disabled:cursor-not-allowed peer-disabled:opacity-70',
props.class,
)
"
>
<slot />
</label>
</template>
+9 -7
View File
@@ -1,19 +1,21 @@
<script setup>
import { cn } from '@/lib/utils';
import { cn } from '@/lib/utils'
const props = defineProps({
class: { type: String, default: '' },
vertical: { type: Boolean, default: false },
});
})
</script>
<template>
<div
:role="'separator'"
:class="cn(
vertical ? 'inline-flex h-full w-px' : 'flex h-px w-full',
'bg-border shrink-0',
props.class
)"
:class="
cn(
vertical ? 'inline-flex h-full w-px' : 'flex h-px w-full',
'bg-border shrink-0',
props.class,
)
"
/>
</template>
+20 -16
View File
@@ -1,14 +1,14 @@
<script setup>
import { cn } from '@/lib/utils';
import { cn } from '@/lib/utils'
const props = defineProps({
class: { type: String, default: '' },
modelValue: { type: Boolean, default: false },
disabled: { type: Boolean, default: false },
id: { type: String, default: undefined },
});
})
const emit = defineEmits(['update:modelValue']);
const emit = defineEmits(['update:modelValue'])
</script>
<template>
@@ -18,22 +18,26 @@ const emit = defineEmits(['update:modelValue']);
:aria-checked="modelValue"
:disabled="disabled"
:id="id"
:class="cn(
'relative inline-flex h-6 w-11 shrink-0 cursor-pointer items-center rounded-full transition-colors duration-200 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50',
modelValue
? 'bg-primary border-2 border-transparent'
: 'bg-transparent border-2 border-muted-foreground/40',
props.class
)"
:class="
cn(
'relative inline-flex h-6 w-11 shrink-0 cursor-pointer items-center rounded-full transition-colors duration-200 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50',
modelValue
? 'bg-primary border-2 border-transparent'
: 'bg-transparent border-2 border-muted-foreground/40',
props.class,
)
"
@click="emit('update:modelValue', !modelValue)"
>
<span
:class="cn(
'pointer-events-none block rounded-full shadow-sm ring-0 transition-all duration-200',
modelValue
? 'h-5 w-5 translate-x-5 bg-white'
: 'h-4 w-4 translate-x-0.5 bg-muted-foreground/60'
)"
:class="
cn(
'pointer-events-none block rounded-full shadow-sm ring-0 transition-all duration-200',
modelValue
? 'h-5 w-5 translate-x-5 bg-white'
: 'h-4 w-4 translate-x-0.5 bg-muted-foreground/60',
)
"
/>
</button>
</template>
+9 -7
View File
@@ -1,5 +1,5 @@
<script setup>
import { cn } from '@/lib/utils';
import { cn } from '@/lib/utils'
const props = defineProps({
class: { type: String, default: '' },
@@ -7,9 +7,9 @@ const props = defineProps({
placeholder: { type: String, default: '' },
disabled: { type: Boolean, default: false },
rows: { type: Number, default: 2 },
});
})
const emit = defineEmits(['update:modelValue']);
const emit = defineEmits(['update:modelValue'])
</script>
<template>
@@ -19,10 +19,12 @@ const emit = defineEmits(['update:modelValue']);
:placeholder="placeholder"
:disabled="disabled"
:rows="rows"
:class="cn(
'flex min-h-15 w-full rounded-md border border-input bg-muted px-3 py-2 text-sm font-mono text-foreground shadow-sm transition-colors placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:border-primary disabled:cursor-not-allowed disabled:opacity-50 resize-vertical',
props.class
)"
:class="
cn(
'flex min-h-15 w-full rounded-md border border-input bg-muted px-3 py-2 text-sm font-mono text-foreground shadow-sm transition-colors placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:border-primary disabled:cursor-not-allowed disabled:opacity-50 resize-vertical',
props.class,
)
"
@input="emit('update:modelValue', $event.target.value)"
/>
</template>
+153 -92
View File
@@ -1,159 +1,220 @@
import { ref, reactive } from 'vue';
import { listPackages, getPackagesInfo } from 'kernelsu';
import PinyinMatch from 'pinyin-match';
import { runCmd, readConfig, updateConfig } from '../utils.js';
import { ref, reactive } from 'vue'
import { listPackages, getPackagesInfo } from 'kernelsu'
import PinyinMatch from 'pinyin-match'
import { runCmd, readConfig, updateConfig } from '../utils.js'
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());
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())
/** 每个 app 条目结构: { packageName, appLabel, isSystem, uid, checked, hasActivities } */
async function load() {
isLoading.value = true;
loadError.value = '';
isLoading.value = true
loadError.value = ''
try {
const cfg = await readConfig();
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('/')));
const cfg = await readConfig()
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 = [];
let infoList = []
try {
const pkgs = await listPackages();
if (pkgs && pkgs.length > 0) infoList = await getPackagesInfo(pkgs);
else throw new Error('no pkgs');
const pkgs = await listPackages()
if (pkgs && pkgs.length > 0) infoList = await getPackagesInfo(pkgs)
else throw new Error('no pkgs')
} catch {
console.log('[DEBUG] 使用模拟数据');
console.log('[DEBUG] 使用模拟数据')
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);
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 || '');
});
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;
});
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,
}));
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();
_reorder()
} catch (e) {
loadError.value = e.message || String(e);
loadError.value = e.message || String(e)
} finally {
isLoading.value = false;
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;
});
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) {
return [...activityEntries.value].some(e => e.startsWith(pkg + '/'));
return [...activityEntries.value].some((e) => e.startsWith(pkg + '/'))
}
function getActivities(pkg) {
return [...activityEntries.value].filter(e => e.startsWith(pkg + '/'));
return [...activityEntries.value].filter((e) => e.startsWith(pkg + '/'))
}
function addActivity(entry) {
activityEntries.value.add(entry);
_reorder();
activityEntries.value.add(entry)
_reorder()
}
function removeActivity(entry) {
activityEntries.value.delete(entry);
_reorder();
activityEntries.value.delete(entry)
_reorder()
}
async function save(toast) {
toast('保存中...');
const selectedPkgs = apps.value.filter(a => a.checked).map(a => a.packageName);
const allEntries = [...selectedPkgs, ...activityEntries.value];
const res = await updateConfig({ blacklist_apps: allEntries });
toast('保存中...')
const selectedPkgs = apps.value.filter((a) => a.checked).map((a) => a.packageName)
const allEntries = [...selectedPkgs, ...activityEntries.value]
const res = await updateConfig({ blacklist_apps: allEntries })
if (res.errno === 0) {
savedBlacklist.value = new Set(allEntries);
toast('黑名单保存成功');
savedBlacklist.value = new Set(allEntries)
toast('黑名单保存成功')
} else {
toast('保存失败: ' + res.stderr);
toast('保存失败: ' + res.stderr)
}
}
function onCheckboxChange() { _reorder(); }
function toggleSystemApps() {
showingSystemApps.value = !showingSystemApps.value;
load();
function onCheckboxChange() {
_reorder()
}
function selectAll() { apps.value.forEach(a => { a.checked = true; }); _reorder(); }
function selectNone() { apps.value.forEach(a => { a.checked = false; }); _reorder(); }
function invertSelection() { apps.value.forEach(a => { a.checked = !a.checked; }); _reorder(); }
function toggleSystemApps() {
showingSystemApps.value = !showingSystemApps.value
load()
}
const smartKeywords = ['抖音', 'tiktok', '爱奇艺', '优酷', '腾讯视频', '哔哩', 'bilibili',
'youku', 'iqiyi', '芒果', '西瓜', '快手', 'kuaishou', '小红书',
'netflix', 'youtube', 'hulu', 'disney', 'prime', '相册', 'gallery', 'photos', 'x'];
function selectAll() {
apps.value.forEach((a) => {
a.checked = true
})
_reorder()
}
function selectNone() {
apps.value.forEach((a) => {
a.checked = false
})
_reorder()
}
function invertSelection() {
apps.value.forEach((a) => {
a.checked = !a.checked
})
_reorder()
}
const smartKeywords = [
'抖音',
'tiktok',
'爱奇艺',
'优酷',
'腾讯视频',
'哔哩',
'bilibili',
'youku',
'iqiyi',
'芒果',
'西瓜',
'快手',
'kuaishou',
'小红书',
'netflix',
'youtube',
'hulu',
'disney',
'prime',
'相册',
'gallery',
'photos',
'x',
]
function smartSelect() {
apps.value.forEach(a => {
const name = (a.appLabel || '').toLowerCase();
const pkg = (a.packageName || '').toLowerCase();
apps.value.forEach((a) => {
const name = (a.appLabel || '').toLowerCase()
const pkg = (a.packageName || '').toLowerCase()
for (const kw of smartKeywords) {
if (kw === 'x') {
if (name === 'x' || name === 'x (twitter)') { a.checked = true; break; }
} else if (name.includes(kw) || pkg.includes(kw)) { a.checked = true; break; }
if (name === 'x' || name === 'x (twitter)') {
a.checked = true
break
}
} else if (name.includes(kw) || pkg.includes(kw)) {
a.checked = true
break
}
}
});
_reorder();
})
_reorder()
}
// 过滤后的列表
function getFilteredApps() {
const kw = searchKeyword.value.trim().toLowerCase();
if (!kw) return apps.value;
return apps.value.filter(a => {
const pkg = a.packageName.toLowerCase();
return pkg.includes(kw) || PinyinMatch.match(a.appLabel, kw);
});
const kw = searchKeyword.value.trim().toLowerCase()
if (!kw) return apps.value
return apps.value.filter((a) => {
const pkg = a.packageName.toLowerCase()
return pkg.includes(kw) || PinyinMatch.match(a.appLabel, kw)
})
}
return {
apps, isLoading, loadError, searchKeyword, showingSystemApps,
savedBlacklist, activityEntries,
load, save,
hasActivity, getActivities, addActivity, removeActivity,
apps,
isLoading,
loadError,
searchKeyword,
showingSystemApps,
savedBlacklist,
activityEntries,
load,
save,
hasActivity,
getActivities,
addActivity,
removeActivity,
onCheckboxChange,
toggleSystemApps, selectAll, selectNone, invertSelection, smartSelect,
toggleSystemApps,
selectAll,
selectNone,
invertSelection,
smartSelect,
getFilteredApps,
};
}
}
+166 -117
View File
@@ -1,174 +1,223 @@
import { ref } from 'vue';
import { ref } from 'vue'
import {
runCmd, readConfig, writeConfig, updateConfig,
CONFIG_FILE, BACKUP_CONFIG_FILE, PID_FILE, FLAG_FILE,
DEFAULT_NOW_BRI_FILE, DEFAULT_SYS_MAX_BRI_FILE,
} from '../utils.js';
runCmd,
readConfig,
writeConfig,
updateConfig,
CONFIG_FILE,
BACKUP_CONFIG_FILE,
PID_FILE,
FLAG_FILE,
DEFAULT_NOW_BRI_FILE,
DEFAULT_SYS_MAX_BRI_FILE,
} from '../utils.js'
export function useConfig() {
// 亮度配置
const uiMaxBri = ref('');
const maxBri = ref('');
const stepsNum = ref('50');
const logMaxSize = ref('500');
const uiMaxBri = ref('')
const maxBri = ref('')
const stepsNum = ref('50')
const logMaxSize = ref('500')
// 执行策略
const autoBriSleep = ref(false);
const displayHdrSleep = ref(false);
const sleepMode = ref(false);
const sleepStartH = ref('19');
const sleepStartM = ref('00');
const sleepEndH = ref('06');
const sleepEndM = ref('00');
const autoBriSleep = ref(false)
const displayHdrSleep = ref(false)
const sleepMode = ref(false)
const sleepStartH = ref('19')
const sleepStartM = ref('00')
const sleepEndH = ref('06')
const sleepEndM = ref('00')
// 高级设置
const nowBriFile = ref(DEFAULT_NOW_BRI_FILE);
const sysMaxBriFile = ref(DEFAULT_SYS_MAX_BRI_FILE);
const inotifyEvents = ref('c');
const nowBriFile = ref(DEFAULT_NOW_BRI_FILE)
const sysMaxBriFile = ref(DEFAULT_SYS_MAX_BRI_FILE)
const inotifyEvents = ref('c')
// Web UI 配置 (localStorage 持久化)
const autoRefresh = ref(localStorage.getItem('autoRefresh') !== 'false');
const autoRefresh = ref(localStorage.getItem('autoRefresh') !== 'false')
const statusRefreshInterval = ref(
Math.max(100, parseInt(localStorage.getItem('statusLogRefreshInterval') || '1000', 10))
);
Math.max(100, parseInt(localStorage.getItem('statusLogRefreshInterval') || '1000', 10)),
)
const uiZoom = ref(
Math.min(150, Math.max(50, parseInt(localStorage.getItem('uiZoom') || '100', 10)))
);
const themeMode = ref(localStorage.getItem('themeMode') || 'system');
Math.min(150, Math.max(50, parseInt(localStorage.getItem('uiZoom') || '100', 10))),
)
const themeMode = ref(localStorage.getItem('themeMode') || 'system')
async function load() {
const cfg = await readConfig();
if (!cfg || Object.keys(cfg).length === 0) return;
const cfg = await readConfig()
if (!cfg || Object.keys(cfg).length === 0) return
uiMaxBri.value = cfg.ui_max_bri != null ? String(cfg.ui_max_bri) : '';
maxBri.value = cfg.max_bri != null ? String(cfg.max_bri) : '';
stepsNum.value = cfg.steps_num != null ? String(cfg.steps_num) : '50';
logMaxSize.value = cfg.log_max_size != null ? String(cfg.log_max_size) : '500';
autoBriSleep.value = cfg.auto_bri_sleep === 1;
displayHdrSleep.value = cfg.display_hdr_sleep === 1;
nowBriFile.value = cfg.now_bri_file || DEFAULT_NOW_BRI_FILE;
sysMaxBriFile.value = cfg.max_bri_file || DEFAULT_SYS_MAX_BRI_FILE;
inotifyEvents.value = cfg.inotify_events || 'c';
uiMaxBri.value = cfg.ui_max_bri != null ? String(cfg.ui_max_bri) : ''
maxBri.value = cfg.max_bri != null ? String(cfg.max_bri) : ''
stepsNum.value = cfg.steps_num != null ? String(cfg.steps_num) : '50'
logMaxSize.value = cfg.log_max_size != null ? String(cfg.log_max_size) : '500'
autoBriSleep.value = cfg.auto_bri_sleep === 1
displayHdrSleep.value = cfg.display_hdr_sleep === 1
nowBriFile.value = cfg.now_bri_file || DEFAULT_NOW_BRI_FILE
sysMaxBriFile.value = cfg.max_bri_file || DEFAULT_SYS_MAX_BRI_FILE
inotifyEvents.value = cfg.inotify_events || 'c'
const st = cfg.sleep_time || '';
const st = cfg.sleep_time || ''
if (st && st.includes('-')) {
sleepMode.value = true;
const [s, e] = st.split('-');
if (s.length === 4) { sleepStartH.value = s.slice(0, 2); sleepStartM.value = s.slice(2); }
if (e.length === 4) { sleepEndH.value = e.slice(0, 2); sleepEndM.value = e.slice(2); }
sleepMode.value = true
const [s, e] = st.split('-')
if (s.length === 4) {
sleepStartH.value = s.slice(0, 2)
sleepStartM.value = s.slice(2)
}
if (e.length === 4) {
sleepEndH.value = e.slice(0, 2)
sleepEndM.value = e.slice(2)
}
} else {
sleepMode.value = false;
sleepMode.value = false
}
}
function getSleepTimeStr() {
if (!sleepMode.value) return '';
const pad = v => String(v).padStart(2, '0');
return `${pad(sleepStartH.value)}${pad(sleepStartM.value)}-${pad(sleepEndH.value)}${pad(sleepEndM.value)}`;
if (!sleepMode.value) return ''
const pad = (v) => String(v).padStart(2, '0')
return `${pad(sleepStartH.value)}${pad(sleepStartM.value)}-${pad(sleepEndH.value)}${pad(sleepEndM.value)}`
}
async function save(toast) {
if (!uiMaxBri.value || !maxBri.value) { toast('亮度値不能为空'); return; }
toast('保存中...');
if (!uiMaxBri.value || !maxBri.value) {
toast('亮度値不能为空')
return
}
toast('保存中...')
// 读取当前配置(保留 blacklist_apps 等其他字段)
const current = await readConfig();
const current = await readConfig()
await writeConfig({
...current,
ui_max_bri: parseInt(uiMaxBri.value) || 0,
max_bri: parseInt(maxBri.value) || 0,
steps_num: parseInt(stepsNum.value) || 50,
log_max_size: parseInt(logMaxSize.value) || 500,
auto_bri_sleep: autoBriSleep.value ? 1 : 0,
ui_max_bri: parseInt(uiMaxBri.value) || 0,
max_bri: parseInt(maxBri.value) || 0,
steps_num: parseInt(stepsNum.value) || 50,
log_max_size: parseInt(logMaxSize.value) || 500,
auto_bri_sleep: autoBriSleep.value ? 1 : 0,
display_hdr_sleep: displayHdrSleep.value ? 1 : 0,
sleep_time: getSleepTimeStr(),
});
await runCmd(`rm -f "${FLAG_FILE}"`);
const pidRes = await runCmd(`cat "${PID_FILE}"`);
toast(pidRes.errno === 0 && pidRes.stdout.trim() ? '配置已保存 (下次调整时生效)' : '配置已保存 (服务未运行)');
sleep_time: getSleepTimeStr(),
})
await runCmd(`rm -f "${FLAG_FILE}"`)
const pidRes = await runCmd(`cat "${PID_FILE}"`)
toast(
pidRes.errno === 0 && pidRes.stdout.trim()
? '配置已保存 (下次调整时生效)'
: '配置已保存 (服务未运行)',
)
}
async function saveAdvanced(toast, onPathsChanged) {
toast('保存中...');
toast('保存中...')
await updateConfig({
now_bri_file: nowBriFile.value || DEFAULT_NOW_BRI_FILE,
max_bri_file: sysMaxBriFile.value || DEFAULT_SYS_MAX_BRI_FILE,
now_bri_file: nowBriFile.value || DEFAULT_NOW_BRI_FILE,
max_bri_file: sysMaxBriFile.value || DEFAULT_SYS_MAX_BRI_FILE,
inotify_events: inotifyEvents.value || 'c',
});
onPathsChanged?.();
toast('高级设置已保存,需重启服务生效');
})
onPathsChanged?.()
toast('高级设置已保存,需重启服务生效')
}
async function resetToDefaults(toast) {
toast('正在恢复默认配置...');
const backupRes = await runCmd(`cat "${BACKUP_CONFIG_FILE}"`);
toast('正在恢复默认配置...')
const backupRes = await runCmd(`cat "${BACKUP_CONFIG_FILE}"`)
if (backupRes.errno !== 0 || !backupRes.stdout.trim()) {
toast('备份文件不存在,无法恢复');
return;
toast('备份文件不存在,无法恢复')
return
}
let backup
try {
backup = JSON.parse(backupRes.stdout)
} catch {
toast('备份文件损坏')
return
}
let backup;
try { backup = JSON.parse(backupRes.stdout); } catch { toast('备份文件损坏'); return; }
uiMaxBri.value = backup.ui_max_bri != null ? String(backup.ui_max_bri) : '';
maxBri.value = backup.max_bri != null ? String(backup.max_bri) : '';
autoBriSleep.value = backup.auto_bri_sleep === 1;
displayHdrSleep.value = backup.display_hdr_sleep === 1;
stepsNum.value = backup.steps_num != null ? String(backup.steps_num) : '50';
logMaxSize.value = backup.log_max_size != null ? String(backup.log_max_size) : '500';
nowBriFile.value = backup.now_bri_file || DEFAULT_NOW_BRI_FILE;
sysMaxBriFile.value = backup.max_bri_file || DEFAULT_SYS_MAX_BRI_FILE;
inotifyEvents.value = backup.inotify_events || 'c';
uiMaxBri.value = backup.ui_max_bri != null ? String(backup.ui_max_bri) : ''
maxBri.value = backup.max_bri != null ? String(backup.max_bri) : ''
autoBriSleep.value = backup.auto_bri_sleep === 1
displayHdrSleep.value = backup.display_hdr_sleep === 1
stepsNum.value = backup.steps_num != null ? String(backup.steps_num) : '50'
logMaxSize.value = backup.log_max_size != null ? String(backup.log_max_size) : '500'
nowBriFile.value = backup.now_bri_file || DEFAULT_NOW_BRI_FILE
sysMaxBriFile.value = backup.max_bri_file || DEFAULT_SYS_MAX_BRI_FILE
inotifyEvents.value = backup.inotify_events || 'c'
const st = backup.sleep_time || '';
const st = backup.sleep_time || ''
if (st && st.includes('-')) {
sleepMode.value = true;
const [s, e] = st.split('-');
if (s.length === 4) { sleepStartH.value = s.slice(0, 2); sleepStartM.value = s.slice(2); }
if (e.length === 4) { sleepEndH.value = e.slice(0, 2); sleepEndM.value = e.slice(2); }
sleepMode.value = true
const [s, e] = st.split('-')
if (s.length === 4) {
sleepStartH.value = s.slice(0, 2)
sleepStartM.value = s.slice(2)
}
if (e.length === 4) {
sleepEndH.value = e.slice(0, 2)
sleepEndM.value = e.slice(2)
}
} else {
sleepMode.value = true;
sleepStartH.value = '19'; sleepStartM.value = '00';
sleepEndH.value = '06'; sleepEndM.value = '00';
sleepMode.value = true
sleepStartH.value = '19'
sleepStartM.value = '00'
sleepEndH.value = '06'
sleepEndM.value = '00'
}
await save(toast);
await save(toast)
}
function saveWebUIConfig(toast, newAutoRefresh, newInterval, newZoom, newTheme, onRestart) {
const interval = Math.max(100, parseInt(newInterval, 10) || 1000);
const zoom = Math.min(150, Math.max(50, parseInt(newZoom, 10) || 100));
localStorage.setItem('autoRefresh', newAutoRefresh);
localStorage.setItem('statusLogRefreshInterval', interval);
localStorage.setItem('uiZoom', zoom);
localStorage.setItem('themeMode', newTheme);
autoRefresh.value = newAutoRefresh;
statusRefreshInterval.value = interval;
uiZoom.value = zoom;
themeMode.value = newTheme;
document.documentElement.style.zoom = zoom / 100;
applyTheme(newTheme);
onRestart?.(newAutoRefresh, interval);
toast('Web UI 配置已保存');
const interval = Math.max(100, parseInt(newInterval, 10) || 1000)
const zoom = Math.min(150, Math.max(50, parseInt(newZoom, 10) || 100))
localStorage.setItem('autoRefresh', newAutoRefresh)
localStorage.setItem('statusLogRefreshInterval', interval)
localStorage.setItem('uiZoom', zoom)
localStorage.setItem('themeMode', newTheme)
autoRefresh.value = newAutoRefresh
statusRefreshInterval.value = interval
uiZoom.value = zoom
themeMode.value = newTheme
document.documentElement.style.zoom = zoom / 100
applyTheme(newTheme)
onRestart?.(newAutoRefresh, interval)
toast('Web UI 配置已保存')
}
function applyZoom() {
document.documentElement.style.zoom = uiZoom.value / 100;
document.documentElement.style.zoom = uiZoom.value / 100
}
function applyTheme(mode) {
const html = document.documentElement;
html.classList.remove('light', 'dark');
if (mode === 'light') html.classList.add('light');
else if (mode === 'dark') html.classList.add('dark');
const html = document.documentElement
html.classList.remove('light', 'dark')
if (mode === 'light') html.classList.add('light')
else if (mode === 'dark') html.classList.add('dark')
}
return {
uiMaxBri, maxBri, stepsNum, logMaxSize,
autoBriSleep, displayHdrSleep,
sleepMode, sleepStartH, sleepStartM, sleepEndH, sleepEndM,
nowBriFile, sysMaxBriFile, inotifyEvents,
autoRefresh, statusRefreshInterval, uiZoom, themeMode,
load, save, saveAdvanced, resetToDefaults,
saveWebUIConfig, applyZoom, applyTheme,
};
uiMaxBri,
maxBri,
stepsNum,
logMaxSize,
autoBriSleep,
displayHdrSleep,
sleepMode,
sleepStartH,
sleepStartM,
sleepEndH,
sleepEndM,
nowBriFile,
sysMaxBriFile,
inotifyEvents,
autoRefresh,
statusRefreshInterval,
uiZoom,
themeMode,
load,
save,
saveAdvanced,
resetToDefaults,
saveWebUIConfig,
applyZoom,
applyTheme,
}
}
+39 -30
View File
@@ -1,49 +1,58 @@
import { ref, computed } from 'vue';
import { runCmd, LOG_FILE } from '../utils.js';
import { ref, computed } from 'vue'
import { runCmd, LOG_FILE } from '../utils.js'
export function useLog() {
const fullLog = ref('');
const filterLevel = ref('');
const isLoading = ref(false);
const fullLog = ref('')
const filterLevel = ref('')
const isLoading = ref(false)
const filteredLog = computed(() => {
if (!fullLog.value) return '暂无日志';
if (!filterLevel.value) return fullLog.value;
const lines = fullLog.value.split('\n').filter(l => l.includes(`[${filterLevel.value}]`));
return lines.length > 0 ? lines.join('\n') : `暂无 [${filterLevel.value}] 等级的日志`;
});
if (!fullLog.value) return '暂无日志'
if (!filterLevel.value) return fullLog.value
const lines = fullLog.value.split('\n').filter((l) => l.includes(`[${filterLevel.value}]`))
return lines.length > 0 ? lines.join('\n') : `暂无 [${filterLevel.value}] 等级的日志`
})
async function load() {
const res = await runCmd(`tail -n 100 "${LOG_FILE}"`);
fullLog.value = res.errno === 0 ? (res.stdout.trim() || '暂无日志') : '无法读取日志 (可能模块尚未产生日志文件)';
const res = await runCmd(`tail -n 100 "${LOG_FILE}"`)
fullLog.value =
res.errno === 0 ? res.stdout.trim() || '暂无日志' : '无法读取日志 (可能模块尚未产生日志文件)'
}
async function clear(toast) {
toast('正在清空日志...');
const res = await runCmd(`> "${LOG_FILE}"`);
if (res.errno === 0) { fullLog.value = ''; toast('日志已清空'); }
else toast('清空失败: ' + (res.stderr || '未知错误'));
toast('正在清空日志...')
const res = await runCmd(`> "${LOG_FILE}"`)
if (res.errno === 0) {
fullLog.value = ''
toast('日志已清空')
} else toast('清空失败: ' + (res.stderr || '未知错误'))
}
async function copy(toast) {
const res = await runCmd(`tail -n 50 "${LOG_FILE}"`);
if (res.errno !== 0 || !res.stdout.trim()) { toast('暂无日志内容'); return; }
try {
await navigator.clipboard.writeText(res.stdout.trim());
} catch {
const ta = document.createElement('textarea');
ta.value = res.stdout.trim();
ta.style.cssText = 'position:fixed;opacity:0;pointer-events:none';
document.body.appendChild(ta); ta.select(); document.execCommand('copy'); document.body.removeChild(ta);
const res = await runCmd(`tail -n 50 "${LOG_FILE}"`)
if (res.errno !== 0 || !res.stdout.trim()) {
toast('暂无日志内容')
return
}
toast('已复制最新 50 条日志');
try {
await navigator.clipboard.writeText(res.stdout.trim())
} catch {
const ta = document.createElement('textarea')
ta.value = res.stdout.trim()
ta.style.cssText = 'position:fixed;opacity:0;pointer-events:none'
document.body.appendChild(ta)
ta.select()
document.execCommand('copy')
document.body.removeChild(ta)
}
toast('已复制最新 50 条日志')
}
async function exportLog(toast) {
toast('正在导出...');
const res = await runCmd(`cp "${LOG_FILE}" "/sdcard/LuminPro_$(date '+%Y%m%d_%H%M%S').log"`);
toast(res.errno === 0 ? '日志已导出到 /sdcard' : '导出失败: ' + (res.stderr || '未知错误'));
toast('正在导出...')
const res = await runCmd(`cp "${LOG_FILE}" "/sdcard/LuminPro_$(date '+%Y%m%d_%H%M%S').log"`)
toast(res.errno === 0 ? '日志已导出到 /sdcard' : '导出失败: ' + (res.stderr || '未知错误'))
}
return { fullLog, filterLevel, filteredLog, isLoading, load, clear, copy, exportLog };
return { fullLog, filterLevel, filteredLog, isLoading, load, clear, copy, exportLog }
}
+104 -87
View File
@@ -1,152 +1,169 @@
import { ref, computed } from 'vue';
import { ref, computed } from 'vue'
import {
runCmd, readConfig,
PID_FILE, STOP_FLAG_FILE,
DEFAULT_NOW_BRI_FILE, DEFAULT_SYS_MAX_BRI_FILE,
} from '../utils.js';
runCmd,
readConfig,
PID_FILE,
STOP_FLAG_FILE,
DEFAULT_NOW_BRI_FILE,
DEFAULT_SYS_MAX_BRI_FILE,
} from '../utils.js'
export function useStatus() {
// 亮度
const currentBri = ref(null);
const sysMaxBri = ref(null);
const currentBri = ref(null)
const sysMaxBri = ref(null)
// 服务状态
const inotifydPid = ref('—');
const inotifydState = ref('—');
const isRunning = ref(false);
const isPaused = ref(false);
const inotifydPid = ref('—')
const inotifydState = ref('—')
const isRunning = ref(false)
const isPaused = ref(false)
const statusClass = computed(() => {
if (isPaused.value) return 'status-paused';
if (isRunning.value) return 'status-running';
return 'status-loading';
});
if (isPaused.value) return 'status-paused'
if (isRunning.value) return 'status-running'
return 'status-loading'
})
const statusText = computed(() => {
if (isPaused.value) return '已暂停';
if (isRunning.value) return '运行中';
return '未运行';
});
if (isPaused.value) return '已暂停'
if (isRunning.value) return '运行中'
return '未运行'
})
// HDR / 睡眠状态
const hdrRatio = ref('—');
const sleepStatus = ref('—');
const hdrRatio = ref('—')
const sleepStatus = ref('—')
// 自动亮度
const autoBriMode = ref(false);
const autoBriMode = ref(false)
// 缓存配置字段(避免每次刷新都 readConfig)
let _nowBriFile = null;
let _sysMaxBriFile = null;
let _sleepTime = null;
let _nowBriFile = null
let _sysMaxBriFile = null
let _sleepTime = null
async function _ensurePaths() {
if (_nowBriFile && _sysMaxBriFile) return;
const cfg = await readConfig();
_nowBriFile = cfg.now_bri_file || DEFAULT_NOW_BRI_FILE;
_sysMaxBriFile = cfg.max_bri_file || DEFAULT_SYS_MAX_BRI_FILE;
_sleepTime = cfg.sleep_time || '';
if (_nowBriFile && _sysMaxBriFile) return
const cfg = await readConfig()
_nowBriFile = cfg.now_bri_file || DEFAULT_NOW_BRI_FILE
_sysMaxBriFile = cfg.max_bri_file || DEFAULT_SYS_MAX_BRI_FILE
_sleepTime = cfg.sleep_time || ''
}
function invalidatePaths() {
_nowBriFile = null;
_sysMaxBriFile = null;
_sleepTime = null;
_nowBriFile = null
_sysMaxBriFile = null
_sleepTime = null
}
async function load(forceFull = false) {
await _ensurePaths();
await _ensurePaths()
const needBri = forceFull || currentBri.value === null || sysMaxBri.value === null;
const needBri = forceFull || currentBri.value === null || sysMaxBri.value === null
// 所有 Shell 命令一次并发,消除多轮顺序等待
// PID + 进程状态合并为一条命令以减少 exec 次数
const [pidStateRes, stopRes, autoBriRes, hdrRes, cBriRes, sBriRes] = await Promise.all([
runCmd(`PID=$(cat "${PID_FILE}" 2>/dev/null || true); printf '%s\\n' "$PID"; [ -n "$PID" ] && grep '^State:' "/proc/$PID/status" 2>/dev/null | awk '{print $2}' || true`),
runCmd(
`PID=$(cat "${PID_FILE}" 2>/dev/null || true); printf '%s\\n' "$PID"; [ -n "$PID" ] && grep '^State:' "/proc/$PID/status" 2>/dev/null | awk '{print $2}' || true`,
),
runCmd(`[ -f "${STOP_FLAG_FILE}" ] && echo "1" || echo "0"`),
runCmd(`settings get system screen_brightness_mode`),
runCmd(`dumpsys display 2>/dev/null | sed -n 's/.*hdrSdrRatio \\([0-9.]*\\).*/\\1/p' | head -n 1`),
needBri ? runCmd(`cat "${_nowBriFile}"`) : Promise.resolve({ errno: -1, stdout: '' }),
runCmd(
`dumpsys display 2>/dev/null | sed -n 's/.*hdrSdrRatio \\([0-9.]*\\).*/\\1/p' | head -n 1`,
),
needBri ? runCmd(`cat "${_nowBriFile}"`) : Promise.resolve({ errno: -1, stdout: '' }),
needBri ? runCmd(`cat "${_sysMaxBriFile}"`) : Promise.resolve({ errno: -1, stdout: '' }),
]);
])
if (needBri) {
currentBri.value = cBriRes.errno === 0 ? cBriRes.stdout.trim() : '0';
sysMaxBri.value = sBriRes.errno === 0 ? sBriRes.stdout.trim() : '255';
currentBri.value = cBriRes.errno === 0 ? cBriRes.stdout.trim() : '0'
sysMaxBri.value = sBriRes.errno === 0 ? sBriRes.stdout.trim() : '255'
}
const psLines = (pidStateRes.errno === 0 ? pidStateRes.stdout : '').split('\n');
const pidStr = psLines[0]?.trim() || '';
const stateChar = psLines[1]?.trim() || '';
const psLines = (pidStateRes.errno === 0 ? pidStateRes.stdout : '').split('\n')
const pidStr = psLines[0]?.trim() || ''
const stateChar = psLines[1]?.trim() || ''
isPaused.value = stopRes.errno === 0 && stopRes.stdout.trim() === '1';
isRunning.value = !isPaused.value && !!pidStr;
inotifydPid.value = pidStr || '离线';
inotifydState.value = isRunning.value ? (stateChar || '已退出') : '离线';
isPaused.value = stopRes.errno === 0 && stopRes.stdout.trim() === '1'
isRunning.value = !isPaused.value && !!pidStr
inotifydPid.value = pidStr || '离线'
inotifydState.value = isRunning.value ? stateChar || '已退出' : '离线'
autoBriMode.value = autoBriRes.errno === 0 && parseInt(autoBriRes.stdout.trim(), 10) === 1;
autoBriMode.value = autoBriRes.errno === 0 && parseInt(autoBriRes.stdout.trim(), 10) === 1
const hdrRaw = hdrRes.errno === 0 ? hdrRes.stdout.trim() : '';
hdrRatio.value = (hdrRaw && /^\d+(\.\d+)?$/.test(hdrRaw)) ? parseFloat(hdrRaw).toFixed(2) : '-';
const hdrRaw = hdrRes.errno === 0 ? hdrRes.stdout.trim() : ''
hdrRatio.value = hdrRaw && /^\d+(\.\d+)?$/.test(hdrRaw) ? parseFloat(hdrRaw).toFixed(2) : '-'
sleepStatus.value = _calcSleep(_sleepTime);
sleepStatus.value = _calcSleep(_sleepTime)
}
function _calcSleep(sleepTime) {
if (!sleepTime || !sleepTime.includes('-')) return '非休眠';
const [s, e] = sleepTime.split('-');
if (s.length !== 4 || e.length !== 4) return '非休眠';
const now = new Date();
const nV = now.getHours() * 100 + now.getMinutes();
const sNum = parseInt(s.slice(0, 2), 10) * 100 + parseInt(s.slice(2), 10);
const eNum = parseInt(e.slice(0, 2), 10) * 100 + parseInt(e.slice(2), 10);
if (!sleepTime || !sleepTime.includes('-')) return '非休眠'
const [s, e] = sleepTime.split('-')
if (s.length !== 4 || e.length !== 4) return '非休眠'
const now = new Date()
const nV = now.getHours() * 100 + now.getMinutes()
const sNum = parseInt(s.slice(0, 2), 10) * 100 + parseInt(s.slice(2), 10)
const eNum = parseInt(e.slice(0, 2), 10) * 100 + parseInt(e.slice(2), 10)
if (sNum > eNum) {
return (nV >= sNum || nV < eNum) ? '休眠中' : '非休眠';
return nV >= sNum || nV < eNum ? '休眠中' : '非休眠'
}
return (nV >= sNum && nV < eNum) ? '休眠中' : '非休眠';
return nV >= sNum && nV < eNum ? '休眠中' : '非休眠'
}
async function toggleService(toast) {
const res = await runCmd(`sh /data/adb/modules/LuminPro/action.sh`);
toast(res.errno === 0 ? (res.stdout.trim() || '状态已切换') : ('操作失败: ' + res.stderr));
await load(true);
const res = await runCmd(`sh /data/adb/modules/LuminPro/action.sh`)
toast(res.errno === 0 ? res.stdout.trim() || '状态已切换' : '操作失败: ' + res.stderr)
await load(true)
}
async function restartService(toast) {
toast('正在重启服务...');
const res = await runCmd(`sh /data/adb/modules/LuminPro/script/restart.sh`);
setTimeout(async () => { await load(true); }, 1000);
toast(res.errno === 0 ? '服务已成功重启' : ('重启失败: ' + res.stderr));
toast('正在重启服务...')
const res = await runCmd(`sh /data/adb/modules/LuminPro/script/restart.sh`)
setTimeout(async () => {
await load(true)
}, 1000)
toast(res.errno === 0 ? '服务已成功重启' : '重启失败: ' + res.stderr)
}
async function setBrightness(newBri, toast) {
currentBri.value = String(newBri);
const cmd = `echo -n '${newBri}' > '${_nowBriFile}' 2>/dev/null && echo 'OK'`;
const res = await runCmd(cmd);
currentBri.value = String(newBri)
const cmd = `echo -n '${newBri}' > '${_nowBriFile}' 2>/dev/null && echo 'OK'`
const res = await runCmd(cmd)
if (!(res.errno === 0 && res.stdout.includes('OK'))) {
toast('亮度设置失败,已恢复');
await load(true);
toast('亮度设置失败,已恢复')
await load(true)
}
}
async function setAutoBrightness(enabled, toast) {
const mode = enabled ? 1 : 0;
const res = await runCmd(`settings put system screen_brightness_mode ${mode}`);
const mode = enabled ? 1 : 0
const res = await runCmd(`settings put system screen_brightness_mode ${mode}`)
if (res.errno === 0) {
autoBriMode.value = enabled;
toast(enabled ? '自动亮度已启用' : '手动亮度已启用');
autoBriMode.value = enabled
toast(enabled ? '自动亮度已启用' : '手动亮度已启用')
} else {
toast('设置失败: ' + (res.stderr || '未知错误'));
toast('设置失败: ' + (res.stderr || '未知错误'))
}
}
return {
currentBri, sysMaxBri,
inotifydPid, inotifydState,
isRunning, isPaused,
statusClass, statusText,
hdrRatio, sleepStatus,
currentBri,
sysMaxBri,
inotifydPid,
inotifydState,
isRunning,
isPaused,
statusClass,
statusText,
hdrRatio,
sleepStatus,
autoBriMode,
load, invalidatePaths,
toggleService, restartService,
setBrightness, setAutoBrightness,
};
load,
invalidatePaths,
toggleService,
restartService,
setBrightness,
setAutoBrightness,
}
}
+9 -4
View File
@@ -15,7 +15,11 @@
.header-icon {
font-size: 2.5rem;
background: linear-gradient(135deg, var(--md-sys-color-primary-container), var(--md-sys-color-secondary-container));
background: linear-gradient(
135deg,
var(--md-sys-color-primary-container),
var(--md-sys-color-secondary-container)
);
width: 56px;
height: 56px;
border-radius: 12px;
@@ -110,7 +114,8 @@
}
@keyframes status-pulse {
0%, 100% {
0%,
100% {
box-shadow: 0 0 8px rgba(244, 67, 54, 0.5);
}
50% {
@@ -119,7 +124,8 @@
}
@keyframes status-pulse-green {
0%, 100% {
0%,
100% {
box-shadow: 0 0 8px rgba(76, 175, 80, 0.6);
}
50% {
@@ -137,4 +143,3 @@
.header-status.status-loading .status-dot {
animation: status-pulse 2s infinite;
}
+4 -3
View File
@@ -1,5 +1,5 @@
@import "tailwindcss";
@import "tw-animate-css";
@import 'tailwindcss';
@import 'tw-animate-css';
@custom-variant dark (&:is(.dark *));
@@ -33,7 +33,8 @@
/* ===============================
Shadcn 主题 Token (暗色, MD3 调色板)
=============================== */
:root, :root.dark {
:root,
:root.dark {
--radius: 0.75rem;
/* Shadcn tokens */
+3 -3
View File
@@ -1,6 +1,6 @@
import { clsx } from 'clsx';
import { twMerge } from 'tailwind-merge';
import { clsx } from 'clsx'
import { twMerge } from 'tailwind-merge'
export function cn(...inputs) {
return twMerge(clsx(inputs));
return twMerge(clsx(inputs))
}
+23 -15
View File
@@ -60,8 +60,9 @@
z-index: 998;
pointer-events: none;
/* 基础暗色背景,增强状态栏文字可读性 */
background: linear-gradient(to bottom,
rgba(var(--md-sys-color-background-rgb, 17, 19, 24), 0.85) 0%,
background: linear-gradient(
to bottom,
rgba(var(--md-sys-color-background-rgb, 17, 19, 24), 0.85) 0%,
rgba(var(--md-sys-color-background-rgb, 17, 19, 24), 0.4) 40%,
rgba(var(--md-sys-color-background-rgb, 17, 19, 24), 0) 100%
);
@@ -69,17 +70,19 @@
-webkit-backdrop-filter: blur(16px);
backdrop-filter: blur(16px);
/* 梯度蒙版:越往上越模糊的核心逻辑 */
-webkit-mask-image: linear-gradient(to bottom,
rgba(0,0,0,1) 0%,
rgba(0,0,0,1) 30%,
rgba(0,0,0,0.7) 60%,
rgba(0,0,0,0) 100%
-webkit-mask-image: linear-gradient(
to bottom,
rgba(0, 0, 0, 1) 0%,
rgba(0, 0, 0, 1) 30%,
rgba(0, 0, 0, 0.7) 60%,
rgba(0, 0, 0, 0) 100%
);
mask-image: linear-gradient(to bottom,
rgba(0,0,0,1) 0%,
rgba(0,0,0,1) 30%,
rgba(0,0,0,0.7) 60%,
rgba(0,0,0,0) 100%
mask-image: linear-gradient(
to bottom,
rgba(0, 0, 0, 1) 0%,
rgba(0, 0, 0, 1) 30%,
rgba(0, 0, 0, 0.7) 60%,
rgba(0, 0, 0, 0) 100%
);
transform: translateZ(0); /* 开启 GPU 加速 */
opacity: 0;
@@ -129,7 +132,9 @@
padding: 8px 16px;
border-radius: 28px;
border: 1px solid rgba(255, 255, 255, 0.08);
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15), 0 8px 32px rgba(0, 0, 0, 0.3);
box-shadow:
0 4px 12px rgba(0, 0, 0, 0.15),
0 8px 32px rgba(0, 0, 0, 0.3);
z-index: 999;
width: fit-content;
max-width: calc(100% - 32px);
@@ -147,7 +152,9 @@
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;
transition:
transform 0.3s cubic-bezier(0.25, 1, 0.5, 1),
width 0.3s ease;
pointer-events: none;
z-index: 0;
}
@@ -173,7 +180,8 @@
z-index: 1;
}
.navbar-btn i, .navbar-btn svg {
.navbar-btn i,
.navbar-btn svg {
width: 20px;
height: 20px;
display: flex;
+10 -10
View File
@@ -1,11 +1,11 @@
import { createApp } from 'vue';
import App from './App.vue';
import './index.css';
import './style.css';
import './header.css';
import './components.css';
import './about.css';
import './apps.css';
import './log.css';
import { createApp } from 'vue'
import App from './App.vue'
import './index.css'
import './style.css'
import './header.css'
import './components.css'
import './about.css'
import './apps.css'
import './log.css'
createApp(App).mount('#app');
createApp(App).mount('#app')
+7 -3
View File
@@ -1,4 +1,5 @@
:root, :root.dark {
:root,
:root.dark {
--md-sys-color-background: #111318;
--md-sys-color-background-rgb: 17, 19, 24;
--md-sys-color-on-background: #e2e2e9;
@@ -62,7 +63,11 @@ body {
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;
font-family:
'Geist',
system-ui,
-apple-system,
sans-serif;
line-height: 1.5;
scrollbar-width: none; /* Firefox */
-ms-overflow-style: none; /* IE/Edge */
@@ -81,4 +86,3 @@ body::-webkit-scrollbar {
flex-direction: column;
gap: var(--spacing-m);
}
+73 -44
View File
@@ -1,83 +1,112 @@
import { exec } from 'kernelsu';
import { exec } from 'kernelsu'
export const MODULE_DIR = '/data/adb/modules/LuminPro';
export const CONFIG_DIR = `${MODULE_DIR}/config`;
export const CONFIG_FILE = `${MODULE_DIR}/config/config.json`;
export const BACKUP_CONFIG_FILE = `${MODULE_DIR}/config/.backup/config.json`;
export const PID_FILE = `${MODULE_DIR}/pid/inotifyd.pid`;
export const FLAG_FILE = `${MODULE_DIR}/pid/up.flag`;
export const STOP_FLAG_FILE = `${MODULE_DIR}/pid/stop.flag`;
export const LOG_FILE = `${MODULE_DIR}/service.log`;
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 MODULE_DIR = '/data/adb/modules/LuminPro'
export const CONFIG_DIR = `${MODULE_DIR}/config`
export const CONFIG_FILE = `${MODULE_DIR}/config/config.json`
export const BACKUP_CONFIG_FILE = `${MODULE_DIR}/config/.backup/config.json`
export const PID_FILE = `${MODULE_DIR}/pid/inotifyd.pid`
export const FLAG_FILE = `${MODULE_DIR}/pid/up.flag`
export const STOP_FLAG_FILE = `${MODULE_DIR}/pid/stop.flag`
export const LOG_FILE = `${MODULE_DIR}/service.log`
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 function showToast(msg) {
const toast = document.getElementById('toast');
toast.textContent = msg;
toast.classList.add('show');
setTimeout(() => toast.classList.remove('show'), 3000);
const toast = document.getElementById('toast')
toast.textContent = msg
toast.classList.add('show')
setTimeout(() => toast.classList.remove('show'), 3000)
}
export async function runCmd(cmd) {
try {
const res = await exec(cmd);
return res;
const res = await exec(cmd)
return res
} catch (e) {
console.warn(`[DEBUG] 执行命令失败 (可能是非 KSU 环境): ${cmd}`);
console.warn(`[DEBUG] 执行命令失败 (可能是非 KSU 环境): ${cmd}`)
// JSON 配置模拟
if (cmd.includes('cat') && cmd.includes('config.json')) {
return { errno: 0, stdout: JSON.stringify({
ui_max_bri: 4095, max_bri: 3500, steps_num: 100, log_max_size: 1024,
auto_bri_sleep: 1, display_hdr_sleep: 0, sleep_time: '1900-0600',
inotify_events: 'c',
now_bri_file: '/sys/mock/brightness',
max_bri_file: '/sys/mock/max_brightness',
blacklist_apps: ['com.example.app'],
}), stderr: '' };
return {
errno: 0,
stdout: JSON.stringify({
ui_max_bri: 4095,
max_bri: 3500,
steps_num: 100,
log_max_size: 1024,
auto_bri_sleep: 1,
display_hdr_sleep: 0,
sleep_time: '1900-0600',
inotify_events: 'c',
now_bri_file: '/sys/mock/brightness',
max_bri_file: '/sys/mock/max_brightness',
blacklist_apps: ['com.example.app'],
}),
stderr: '',
}
}
// 状态模拟
if (cmd.includes('cat') && cmd.includes('inotifyd.pid')) return { errno: 0, stdout: '12345', stderr: '' };
if (cmd.includes('settings get system screen_brightness_mode')) return { errno: 0, stdout: '1', stderr: '' };
if (cmd.includes('[ -f') && cmd.includes('stop.flag')) return { errno: 0, stdout: '0', stderr: '' };
if (cmd.includes('cat') && (cmd.includes('brightness') || cmd.includes('now_bri'))) return { errno: 0, stdout: '1200', stderr: '' };
if (cmd.includes('cat') && (cmd.includes('max_brightness') || cmd.includes('max_bri'))) return { errno: 0, stdout: '4095', stderr: '' };
if (cmd.includes('cat') && cmd.includes('inotifyd.pid'))
return { errno: 0, stdout: '12345', stderr: '' }
if (cmd.includes('settings get system screen_brightness_mode'))
return { errno: 0, stdout: '1', stderr: '' }
if (cmd.includes('[ -f') && cmd.includes('stop.flag'))
return { errno: 0, stdout: '0', stderr: '' }
if (cmd.includes('cat') && (cmd.includes('brightness') || cmd.includes('now_bri')))
return { errno: 0, stdout: '1200', stderr: '' }
if (cmd.includes('cat') && (cmd.includes('max_brightness') || cmd.includes('max_bri')))
return { errno: 0, stdout: '4095', stderr: '' }
// 日志模拟
if (cmd.includes('tail') && cmd.includes('service.log')) {
return { errno: 0, stdout: '[04-07 15:40:01] [service] [INFO ] LuminPro 服务启动\n[04-07 15:41:05] [up] [INFO ] 触发提升: 当前亮度 1200 ≥ 阈値 1000\n[04-07 15:42:10] [up] [SUCCESS ] 亮度提升完成 (3500)', stderr: '' };
return {
errno: 0,
stdout:
'[04-07 15:40:01] [service] [INFO ] LuminPro 服务启动\n[04-07 15:41:05] [up] [INFO ] 触发提升: 当前亮度 1200 ≥ 阈値 1000\n[04-07 15:42:10] [up] [SUCCESS ] 亮度提升完成 (3500)',
stderr: '',
}
}
// 文档模拟
if (cmd.includes('cat') && cmd.includes('.md')) return { errno: 0, stdout: '# 调试模式\n\n当前处于 **Web 调试模式**,显示的是模拟测试数据。', stderr: '' };
if (cmd.includes('cat') && cmd.includes('.txt')) return { errno: 0, stdout: '这是 NOTE.txt 的模拟内容。', stderr: '' };
if (cmd.includes('cat') && cmd.includes('.md'))
return {
errno: 0,
stdout: '# 调试模式\n\n当前处于 **Web 调试模式**,显示的是模拟测试数据。',
stderr: '',
}
if (cmd.includes('cat') && cmd.includes('.txt'))
return { errno: 0, stdout: '这是 NOTE.txt 的模拟内容。', stderr: '' }
return { errno: -1, stdout: '', stderr: String(e) };
return { errno: -1, stdout: '', stderr: String(e) }
}
}
// 读取完整 JSON 配置
export async function readConfig() {
const res = await runCmd(`cat "${CONFIG_FILE}"`);
if (res.errno !== 0 || !res.stdout.trim()) return {};
try { return JSON.parse(res.stdout); } catch { return {}; }
const res = await runCmd(`cat "${CONFIG_FILE}"`)
if (res.errno !== 0 || !res.stdout.trim()) return {}
try {
return JSON.parse(res.stdout)
} catch {
return {}
}
}
// 写入完整 JSON 配置
export async function writeConfig(obj) {
const content = JSON.stringify(obj).replace(/'/g, "'\\''" );
return runCmd(`printf '%s' '${content}' > "${CONFIG_FILE}"`);
const content = JSON.stringify(obj).replace(/'/g, "'\\''")
return runCmd(`printf '%s' '${content}' > "${CONFIG_FILE}"`)
}
// 合并更新 JSON 配置(保留其他字段)
export async function updateConfig(updates) {
const current = await readConfig();
return writeConfig({ ...current, ...updates });
const current = await readConfig()
return writeConfig({ ...current, ...updates })
}
// 将文件内容写入指定路径
export async function writeFile(path, content) {
const safeContent = String(content).replace(/'/g, "'\\''" );
return runCmd(`printf '%s' '${safeContent}' > "${path}"`);
const safeContent = String(content).replace(/'/g, "'\\''")
return runCmd(`printf '%s' '${safeContent}' > "${path}"`)
}
+88 -76
View File
@@ -1,103 +1,115 @@
<script setup>
import { ref } from "vue";
import Button from "@/components/ui/Button.vue";
import { BookOpen, ScrollText, StickyNote, X, Github } from "lucide-vue-next";
import { runCmd } from "../utils.js";
import { ref } from 'vue'
import Button from '@/components/ui/Button.vue'
import { BookOpen, ScrollText, StickyNote, X, Github } from 'lucide-vue-next'
import { runCmd } from '../utils.js'
const MODULE_DIR = '/data/adb/modules/LuminPro';
const MODULE_DIR = '/data/adb/modules/LuminPro'
const sheetOpen = ref(false);
const sheetTitle = ref("");
const sheetContent = ref("");
const sheetLoading = ref(false);
const sheetOpen = ref(false)
const sheetTitle = ref('')
const sheetContent = ref('')
const sheetLoading = ref(false)
const moduleDocs = [
{ title: "README", file: `${MODULE_DIR}/README.md`, icon: BookOpen, md: true },
{ title: "README (EN)", file: `${MODULE_DIR}/README_en.md`, icon: BookOpen, md: true },
{ title: "更新日志", file: `${MODULE_DIR}/changelog.md`, icon: ScrollText, md: true },
{ title: "NOTE", file: `${MODULE_DIR}/NOTE.txt`, icon: StickyNote, md: false },
];
{ title: 'README', file: `${MODULE_DIR}/README.md`, icon: BookOpen, md: true },
{ title: 'README (EN)', file: `${MODULE_DIR}/README_en.md`, icon: BookOpen, md: true },
{ title: '更新日志', file: `${MODULE_DIR}/changelog.md`, icon: ScrollText, md: true },
{ title: 'NOTE', file: `${MODULE_DIR}/NOTE.txt`, icon: StickyNote, md: false },
]
function mdToHtml(text) {
return text
.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;")
.replace(/^### (.+)$/gm, "<h3>$1</h3>")
.replace(/^## (.+)$/gm, "<h2>$1</h2>")
.replace(/^# (.+)$/gm, "<h1>$1</h1>")
.replace(/\*\*(.+?)\*\*/g, "<strong>$1</strong>")
.replace(/`([^`]+)`/g, "<code>$1</code>")
.replace(/\n/g, "<br>");
.replace(/&/g, '&amp;')
.replace(/</g, '&lt;')
.replace(/>/g, '&gt;')
.replace(/^### (.+)$/gm, '<h3>$1</h3>')
.replace(/^## (.+)$/gm, '<h2>$1</h2>')
.replace(/^# (.+)$/gm, '<h1>$1</h1>')
.replace(/\*\*(.+?)\*\*/g, '<strong>$1</strong>')
.replace(/`([^`]+)`/g, '<code>$1</code>')
.replace(/\n/g, '<br>')
}
async function openModuleDoc(doc) {
sheetTitle.value = doc.title;
sheetContent.value = "";
sheetLoading.value = true;
sheetOpen.value = true;
sheetTitle.value = doc.title
sheetContent.value = ''
sheetLoading.value = true
sheetOpen.value = true
try {
const res = await runCmd(`cat "${doc.file}" 2>/dev/null`);
if (res.errno !== 0 || !res.stdout.trim()) throw new Error('文件不存在或为空');
sheetContent.value = doc.md ? mdToHtml(res.stdout) : res.stdout.replace(/&/g,'&amp;').replace(/</g,'&lt;').replace(/>/g,'&gt;').replace(/\n/g,'<br>');
const res = await runCmd(`cat "${doc.file}" 2>/dev/null`)
if (res.errno !== 0 || !res.stdout.trim()) throw new Error('文件不存在或为空')
sheetContent.value = doc.md
? mdToHtml(res.stdout)
: res.stdout
.replace(/&/g, '&amp;')
.replace(/</g, '&lt;')
.replace(/>/g, '&gt;')
.replace(/\n/g, '<br>')
} catch (e) {
sheetContent.value = `加载失败: ${e.message}`;
sheetContent.value = `加载失败: ${e.message}`
} finally {
sheetLoading.value = false;
sheetLoading.value = false
}
}
function closeSheet() {
sheetOpen.value = false;
sheetOpen.value = false
}
</script>
<template>
<div style="display:contents">
<section class="card" id="about-section">
<!-- 模块文档 -->
<div class="about-section-title">模块文档</div>
<div class="about-list">
<button
v-for="doc in moduleDocs"
:key="doc.file"
class="about-list-item"
@click="openModuleDoc(doc)"
>
<component :is="doc.icon" :size="18" class="about-list-icon" />
<span>{{ doc.title }}</span>
</button>
</div>
<!-- 链接列表 -->
<div class="about-section-title">链接</div>
<div class="about-list">
<button
class="about-list-item"
@click="runCmd('am start -a android.intent.action.VIEW -d \'https://github.com/YuleBest/LuminPro\'')"
>
<Github :size="18" class="about-list-icon" />
<span>GitHub 项目主页</span>
</button>
</div>
<p class="about-footer">Made with ❤ by Yule</p>
</section>
<!-- 文档底部弹出抽屉 -->
<Teleport to="body">
<div class="doc-sheet-backdrop" :class="{ show: sheetOpen }" @click="closeSheet"></div>
<div class="doc-sheet" :class="{ show: sheetOpen }">
<div class="doc-sheet-header">
<span class="doc-sheet-title">{{ sheetTitle }}</span>
<button class="doc-sheet-close" @click="closeSheet">
<X :size="20" />
<div style="display: contents">
<section class="card" id="about-section">
<!-- 模块文档 -->
<div class="about-section-title">模块文档</div>
<div class="about-list">
<button
v-for="doc in moduleDocs"
:key="doc.file"
class="about-list-item"
@click="openModuleDoc(doc)"
>
<component :is="doc.icon" :size="18" class="about-list-icon" />
<span>{{ doc.title }}</span>
</button>
</div>
<div class="doc-sheet-body">
<div v-if="sheetLoading" class="doc-sheet-loading">加载中...</div>
<!-- eslint-disable-next-line vue/no-v-html -->
<div v-else class="doc-sheet-content" v-html="sheetContent"></div>
<!-- 链接列表 -->
<div class="about-section-title">链接</div>
<div class="about-list">
<button
class="about-list-item"
@click="
runCmd(
'am start -a android.intent.action.VIEW -d \'https://github.com/YuleBest/LuminPro\'',
)
"
>
<Github :size="18" class="about-list-icon" />
<span>GitHub 项目主页</span>
</button>
</div>
</div>
</Teleport>
<p class="about-footer">Made with ❤ by Yule</p>
</section>
<!-- 文档底部弹出抽屉 -->
<Teleport to="body">
<div class="doc-sheet-backdrop" :class="{ show: sheetOpen }" @click="closeSheet"></div>
<div class="doc-sheet" :class="{ show: sheetOpen }">
<div class="doc-sheet-header">
<span class="doc-sheet-title">{{ sheetTitle }}</span>
<button class="doc-sheet-close" @click="closeSheet">
<X :size="20" />
</button>
</div>
<div class="doc-sheet-body">
<div v-if="sheetLoading" class="doc-sheet-loading">加载中...</div>
<!-- eslint-disable-next-line vue/no-v-html -->
<div v-else class="doc-sheet-content" v-html="sheetContent"></div>
</div>
</div>
</Teleport>
</div>
</template>
+379 -294
View File
@@ -1,361 +1,446 @@
<script setup>
import { inject, ref, computed, onMounted, reactive } from "vue";
import { getPackagesInfo } from "kernelsu";
import { useApps } from "@/composables/useApps.js";
import { runCmd } from "../utils.js";
import Button from "@/components/ui/Button.vue";
import { inject, ref, computed, onMounted, reactive } from 'vue'
import { getPackagesInfo } from 'kernelsu'
import { useApps } from '@/composables/useApps.js'
import { runCmd } from '../utils.js'
import Button from '@/components/ui/Button.vue'
import {
RefreshCw, Eye, EyeOff, Sparkles, Plus, CheckCheck, Square,
CheckSquare, Search, X, Check, ChevronDown, ScanSearch,
ChevronLeft, Monitor, Clock, CircleCheck,
} from "lucide-vue-next";
RefreshCw,
Eye,
EyeOff,
Sparkles,
Plus,
CheckCheck,
Square,
CheckSquare,
Search,
X,
Check,
ChevronDown,
ScanSearch,
ChevronLeft,
Monitor,
Clock,
CircleCheck,
} from 'lucide-vue-next'
const showToast = inject("showToast");
const appsMenuOpen = ref(false);
const showToast = inject('showToast')
const appsMenuOpen = ref(false)
const {
apps, isLoading, loadError, searchKeyword, showingSystemApps,
savedBlacklist, activityEntries,
load, save,
hasActivity, getActivities, addActivity, removeActivity,
apps,
isLoading,
loadError,
searchKeyword,
showingSystemApps,
savedBlacklist,
activityEntries,
load,
save,
hasActivity,
getActivities,
addActivity,
removeActivity,
onCheckboxChange,
toggleSystemApps, selectAll, selectNone, invertSelection, smartSelect,
toggleSystemApps,
selectAll,
selectNone,
invertSelection,
smartSelect,
getFilteredApps,
} = useApps();
} = useApps()
const filteredApps = computed(() => getFilteredApps());
const appCount = computed(() => filteredApps.value.length);
const filteredApps = computed(() => getFilteredApps())
const appCount = computed(() => filteredApps.value.length)
onMounted(() => load());
onMounted(() => load())
// 关闭下拉菜单 (点击外部)
function handleBodyClick() { appsMenuOpen.value = false; }
function handleBodyClick() {
appsMenuOpen.value = false
}
// 按活动屏蔽
const activityInput = ref("");
const activityInput = ref('')
function doAddActivity() {
const val = activityInput.value.trim();
if (!val) return;
const parts = val.split("/");
const val = activityInput.value.trim()
if (!val) return
const parts = val.split('/')
if (parts.length !== 2 || !parts[0] || !parts[1]) {
showToast("格式错误,请输入 包名/完整活动类名");
return;
showToast('格式错误,请输入 包名/完整活动类名')
return
}
addActivity(val);
activityInput.value = "";
showToast(`已添加: ${val}`);
addActivity(val)
activityInput.value = ''
showToast(`已添加: ${val}`)
}
// 手动添加包名
async function handleManualAdd() {
appsMenuOpen.value = false;
const pkg = prompt("请输入完整应用包名(例如: com.example.app):");
if (!pkg?.trim()) return;
const realPkg = pkg.trim();
const existing = apps.value.find((a) => a.packageName === realPkg);
appsMenuOpen.value = false
const pkg = prompt('请输入完整应用包名(例如: com.example.app):')
if (!pkg?.trim()) return
const realPkg = pkg.trim()
const existing = apps.value.find((a) => a.packageName === realPkg)
if (existing) {
existing.checked = true;
onCheckboxChange();
showToast("已为你自动勾选并置顶");
return;
existing.checked = true
onCheckboxChange()
showToast('已为你自动勾选并置顶')
return
}
showToast("正在获取应用信息...");
showToast('正在获取应用信息...')
let appData = {
packageName: realPkg,
appLabel: "未知 (手动添加)",
appLabel: '未知 (手动添加)',
isSystem: false,
uid: "自定义",
};
uid: '自定义',
}
try {
const info = await getPackagesInfo([realPkg]);
if (info?.length > 0) appData = info[0];
const info = await getPackagesInfo([realPkg])
if (info?.length > 0) appData = info[0]
} catch {}
apps.value.unshift(reactive({ ...appData, checked: true, expanded: false }));
onCheckboxChange();
showToast("已添加到列表顶部");
apps.value.unshift(reactive({ ...appData, checked: true, expanded: false }))
onCheckboxChange()
showToast('已添加到列表顶部')
}
// Activity Picker
const pickerVisible = ref(false);
const pickerStep = ref(1);
const pickerStatusText = ref("等待中...");
const pickerPolling = ref(false);
const pickerResult = ref("");
let pollingTimer = null;
const pickerVisible = ref(false)
const pickerStep = ref(1)
const pickerStatusText = ref('等待中...')
const pickerPolling = ref(false)
const pickerResult = ref('')
let pollingTimer = null
function openPicker() {
stopPolling();
pickerStep.value = 1;
pickerStatusText.value = "等待中...";
pickerResult.value = "";
pickerPolling.value = false;
pickerVisible.value = true;
stopPolling()
pickerStep.value = 1
pickerStatusText.value = '等待中...'
pickerResult.value = ''
pickerPolling.value = false
pickerVisible.value = true
}
function closePicker() {
stopPolling();
pickerVisible.value = false;
stopPolling()
pickerVisible.value = false
}
function stopPolling() {
if (pollingTimer) {
clearInterval(pollingTimer);
pollingTimer = null;
clearInterval(pollingTimer)
pollingTimer = null
}
}
function startPolling() {
pickerPolling.value = true;
pickerStatusText.value = "检测中,请切换到目标界面...";
stopPolling();
pickerPolling.value = true
pickerStatusText.value = '检测中,请切换到目标界面...'
stopPolling()
pollingTimer = setInterval(async () => {
try {
const res = await runCmd(
`dumpsys window 2>/dev/null | grep mCurrentFocus | sed 's/.*u[0-9][0-9]* //' | sed 's/}.*//'`
);
if (res.errno !== 0) return;
const activity = res.stdout.trim();
if (!activity || activity.toLowerCase().includes("webui")) return;
stopPolling();
pickerPolling.value = false;
pickerResult.value = activity;
pickerStep.value = 3;
`dumpsys window 2>/dev/null | grep mCurrentFocus | sed 's/.*u[0-9][0-9]* //' | sed 's/}.*//'`,
)
if (res.errno !== 0) return
const activity = res.stdout.trim()
if (!activity || activity.toLowerCase().includes('webui')) return
stopPolling()
pickerPolling.value = false
pickerResult.value = activity
pickerStep.value = 3
} catch {}
}, 600);
}, 600)
}
function confirmPicker() {
if (!pickerResult.value) return;
addActivity(pickerResult.value);
showToast(`已添加: ${pickerResult.value}`);
closePicker();
if (!pickerResult.value) return
addActivity(pickerResult.value)
showToast(`已添加: ${pickerResult.value}`)
closePicker()
}
</script>
<template>
<div style="display:contents">
<section class="card" id="apps-section">
<div class="card-header" style="margin-bottom: 8px">
<h2>黑名单</h2>
<div class="header-actions dropdown-container">
<Button variant="ghost" size="icon" @click="load">
<RefreshCw :size="18" />
</Button>
<Button variant="ghost" size="icon" @click="appsMenuOpen = !appsMenuOpen">
<span class="sr-only">更多</span>
<svg xmlns="http://www.w3.org/2000/svg" width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
<circle cx="12" cy="12" r="1" /><circle cx="12" cy="5" r="1" /><circle cx="12" cy="19" r="1" />
</svg>
</Button>
<div class="dropdown-menu" :class="{ show: appsMenuOpen }" @click.stop>
<div class="dropdown-item" @click="toggleSystemApps(); appsMenuOpen = false">
<component :is="showingSystemApps ? EyeOff : Eye" :size="18" />
<span>{{ showingSystemApps ? "隐藏系统应用" : "显示系统应用" }}</span>
</div>
<div class="dropdown-item" @click="smartSelect(); appsMenuOpen = false">
<Sparkles :size="18" /><span>智能选择</span>
</div>
<div class="dropdown-item" @click="handleManualAdd">
<Plus :size="18" /><span>手动添加包名</span>
</div>
<div class="dropdown-item" @click="selectAll(); appsMenuOpen = false">
<CheckCheck :size="18" /><span>全选</span>
</div>
<div class="dropdown-item" @click="selectNone(); appsMenuOpen = false">
<Square :size="18" /><span>全不选</span>
</div>
<div class="dropdown-item" @click="invertSelection(); appsMenuOpen = false">
<CheckSquare :size="18" /><span>反选</span>
<div style="display: contents">
<section class="card" id="apps-section">
<div class="card-header" style="margin-bottom: 8px">
<h2>黑名单</h2>
<div class="header-actions dropdown-container">
<Button variant="ghost" size="icon" @click="load">
<RefreshCw :size="18" />
</Button>
<Button variant="ghost" size="icon" @click="appsMenuOpen = !appsMenuOpen">
<span class="sr-only">更多</span>
<svg
xmlns="http://www.w3.org/2000/svg"
width="18"
height="18"
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
stroke-width="2"
stroke-linecap="round"
stroke-linejoin="round"
>
<circle cx="12" cy="12" r="1" />
<circle cx="12" cy="5" r="1" />
<circle cx="12" cy="19" r="1" />
</svg>
</Button>
<div class="dropdown-menu" :class="{ show: appsMenuOpen }" @click.stop>
<div
class="dropdown-item"
@click="
toggleSystemApps()
appsMenuOpen = false
"
>
<component :is="showingSystemApps ? EyeOff : Eye" :size="18" />
<span>{{ showingSystemApps ? '隐藏系统应用' : '显示系统应用' }}</span>
</div>
<div
class="dropdown-item"
@click="
smartSelect()
appsMenuOpen = false
"
>
<Sparkles :size="18" /><span>智能选择</span>
</div>
<div class="dropdown-item" @click="handleManualAdd">
<Plus :size="18" /><span>手动添加包名</span>
</div>
<div
class="dropdown-item"
@click="
selectAll()
appsMenuOpen = false
"
>
<CheckCheck :size="18" /><span>全选</span>
</div>
<div
class="dropdown-item"
@click="
selectNone()
appsMenuOpen = false
"
>
<Square :size="18" /><span>全不选</span>
</div>
<div
class="dropdown-item"
@click="
invertSelection()
appsMenuOpen = false
"
>
<CheckSquare :size="18" /><span>反选</span>
</div>
</div>
</div>
</div>
</div>
<p class="app-list-hint">
被选中的应用将不生效本模块<br />推荐选择视频类、相册等需展示 HDR 内容的应用
</p>
<p class="app-list-hint">
被选中的应用将不生效本模块<br />推荐选择视频类、相册等需展示 HDR 内容的应用
</p>
<!-- 按活动屏蔽 -->
<div class="activity-block-card">
<div class="activity-block-header">
<span class="activity-block-label">按活动屏蔽</span>
<button class="btn-picker-trigger" @click="openPicker">
<ScanSearch :size="12" /> 扫描获取
</button>
</div>
<div class="activity-block-row">
<input
v-model="activityInput"
type="text"
class="activity-block-input"
placeholder="com.pkg/com.pkg.ActivityClass"
autocomplete="off"
spellcheck="false"
@keydown.enter="doAddActivity"
/>
<Button
style="padding: 0 14px; border-radius: var(--border-radius-s); font-size: 0.8125rem; white-space: nowrap; flex-shrink: 0"
@click="doAddActivity"
>确认</Button
>
</div>
</div>
<!-- 搜索栏 + 保存 -->
<div style="display: flex; gap: 8px; align-items: stretch; margin-bottom: var(--spacing-m)">
<div class="app-search-container" style="flex: 1; margin-bottom: 0">
<Search :size="18" class="search-icon" />
<input
v-model="searchKeyword"
type="text"
class="app-search-input"
placeholder="应用名称或包名"
autocomplete="off"
spellcheck="false"
/>
<span class="count-badge">{{ appCount }}</span>
</div>
<Button
style="padding: 0 16px; border-radius: var(--border-radius-s); font-size: 0.8125rem; white-space: nowrap; flex-shrink: 0"
@click="save(showToast)"
>保存</Button
>
</div>
<!-- 应用列表 -->
<div class="app-list-container" id="app-list-container">
<div
v-if="isLoading"
style="text-align: center; padding: 20px; color: var(--md-sys-color-on-surface-variant)"
>
加载中...
</div>
<div
v-else-if="loadError"
style="text-align: center; padding: 20px; color: var(--md-sys-color-error)"
>
加载失败: {{ loadError }}
</div>
<div v-else v-for="app in filteredApps" :key="app.packageName" class="app-list-item">
<div class="app-item-main-row">
<label class="app-checkbox-label">
<input
type="checkbox"
class="app-checkbox"
:class="{ unsaved: app.checked && !savedBlacklist?.has(app.packageName) }"
:data-pkg="app.packageName"
v-model="app.checked"
@change="onCheckboxChange"
/>
<span
class="app-checkbox-custom"
:class="{ partial: !app.checked && hasActivity(app.packageName) }"
></span>
</label>
<div class="app-info">
<span class="app-name">
{{ app.appLabel }}
<span class="app-uid">{{ app.uid }}</span>
</span>
<span class="app-pkg">
{{ app.packageName }}
<span v-if="app.isSystem" class="app-badge">系统</span>
</span>
</div>
<button
v-if="hasActivity(app.packageName)"
class="app-activities-chevron"
:class="{ expanded: app.expanded }"
@click.stop="app.expanded = !app.expanded"
>
<ChevronDown :size="16" />
<!-- 按活动屏蔽 -->
<div class="activity-block-card">
<div class="activity-block-header">
<span class="activity-block-label">按活动屏蔽</span>
<button class="btn-picker-trigger" @click="openPicker">
<ScanSearch :size="12" /> 扫描获取
</button>
</div>
<!-- 活动列表 -->
<div
v-if="hasActivity(app.packageName)"
class="app-activities-list"
:class="{ show: app.expanded }"
>
<div
v-for="entry in getActivities(app.packageName)"
:key="entry"
class="activity-entry-item"
<div class="activity-block-row">
<input
v-model="activityInput"
type="text"
class="activity-block-input"
placeholder="com.pkg/com.pkg.ActivityClass"
autocomplete="off"
spellcheck="false"
@keydown.enter="doAddActivity"
/>
<Button
style="
padding: 0 14px;
border-radius: var(--border-radius-s);
font-size: 0.8125rem;
white-space: nowrap;
flex-shrink: 0;
"
@click="doAddActivity"
>确认</Button
>
<span class="activity-entry-path">{{
entry.slice(app.packageName.length + 1)
}}</span>
<button class="activity-entry-delete" @click="removeActivity(entry)">
<X :size="14" />
</div>
</div>
<!-- 搜索栏 + 保存 -->
<div style="display: flex; gap: 8px; align-items: stretch; margin-bottom: var(--spacing-m)">
<div class="app-search-container" style="flex: 1; margin-bottom: 0">
<Search :size="18" class="search-icon" />
<input
v-model="searchKeyword"
type="text"
class="app-search-input"
placeholder="应用名称或包名"
autocomplete="off"
spellcheck="false"
/>
<span class="count-badge">{{ appCount }}</span>
</div>
<Button
style="
padding: 0 16px;
border-radius: var(--border-radius-s);
font-size: 0.8125rem;
white-space: nowrap;
flex-shrink: 0;
"
@click="save(showToast)"
>保存</Button
>
</div>
<!-- 应用列表 -->
<div class="app-list-container" id="app-list-container">
<div
v-if="isLoading"
style="text-align: center; padding: 20px; color: var(--md-sys-color-on-surface-variant)"
>
加载中...
</div>
<div
v-else-if="loadError"
style="text-align: center; padding: 20px; color: var(--md-sys-color-error)"
>
加载失败: {{ loadError }}
</div>
<div v-else v-for="app in filteredApps" :key="app.packageName" class="app-list-item">
<div class="app-item-main-row">
<label class="app-checkbox-label">
<input
type="checkbox"
class="app-checkbox"
:class="{ unsaved: app.checked && !savedBlacklist?.has(app.packageName) }"
:data-pkg="app.packageName"
v-model="app.checked"
@change="onCheckboxChange"
/>
<span
class="app-checkbox-custom"
:class="{ partial: !app.checked && hasActivity(app.packageName) }"
></span>
</label>
<div class="app-info">
<span class="app-name">
{{ app.appLabel }}
<span class="app-uid">{{ app.uid }}</span>
</span>
<span class="app-pkg">
{{ app.packageName }}
<span v-if="app.isSystem" class="app-badge">系统</span>
</span>
</div>
<button
v-if="hasActivity(app.packageName)"
class="app-activities-chevron"
:class="{ expanded: app.expanded }"
@click.stop="app.expanded = !app.expanded"
>
<ChevronDown :size="16" />
</button>
</div>
</div>
</div>
</div>
</section>
<!-- Activity Picker 覆盖层 -->
<Teleport to="body">
<div
class="activity-picker-overlay"
:class="{ show: pickerVisible }"
id="activity-picker-overlay"
>
<div class="activity-picker-header">
<button class="picker-back-btn" @click="closePicker">
<ChevronLeft :size="20" />
</button>
<span class="picker-title">获取活动名</span>
</div>
<div class="picker-steps-indicator">
<div
v-for="n in 3"
:key="n"
class="picker-step-dot"
:class="{ active: pickerStep === n }"
></div>
</div>
<div class="activity-picker-body">
<!-- 步骤 1 -->
<div class="picker-step" v-show="pickerStep === 1">
<div class="picker-step-icon"><Monitor :size="52" stroke-width="1.5" /></div>
<h3 class="picker-step-title">将 Web UI 挂小窗</h3>
<p class="picker-step-desc">
在开始获取前,请先将当前 Web UI 调整为<strong>小窗模式</strong>。<br /><br />
这样在后续步骤中,你可以同时操作目标应用并看到 Web UI 的反馈。
</p>
<Button class="picker-action-btn" @click="pickerStep = 2">已挂小窗,下一步</Button>
</div>
<!-- 步骤 2 -->
<div class="picker-step" v-show="pickerStep === 2">
<div class="picker-step-icon"><Clock :size="52" stroke-width="1.5" /></div>
<h3 class="picker-step-title">切换到目标界面</h3>
<p class="picker-step-desc">
切换到需要屏蔽的应用界面,并点击 「开始获取」<br /><br />
检测到非 Web UI 界面后将<strong>自动停止</strong>。<br /><br />
<span class="picker-status-text" :class="{ polling: pickerPolling }">{{
pickerStatusText
}}</span>
</p>
<Button class="picker-action-btn" :disabled="pickerPolling" @click="startPolling"
>开始获取</Button
<!-- 活动列表 -->
<div
v-if="hasActivity(app.packageName)"
class="app-activities-list"
:class="{ show: app.expanded }"
>
</div>
<!-- 步骤 3 -->
<div class="picker-step" v-show="pickerStep === 3">
<div class="picker-step-icon">
<CircleCheck :size="52" stroke-width="1.5" />
</div>
<h3 class="picker-step-title">检测到活动</h3>
<p class="picker-step-desc">以下活动将被添加到按活动屏蔽列表:</p>
<div class="picker-result-box">{{ pickerResult }}</div>
<div class="picker-result-actions">
<Button
variant="secondary"
@click="pickerStep = 2; pickerPolling = false; stopPolling()"
>重试</Button
<div
v-for="entry in getActivities(app.packageName)"
:key="entry"
class="activity-entry-item"
>
<Button @click="confirmPicker"><Check :size="15" /> 确认添加</Button>
<span class="activity-entry-path">{{ entry.slice(app.packageName.length + 1) }}</span>
<button class="activity-entry-delete" @click="removeActivity(entry)">
<X :size="14" />
</button>
</div>
</div>
</div>
</div>
</div>
</Teleport>
</section>
<!-- Activity Picker 覆盖层 -->
<Teleport to="body">
<div
class="activity-picker-overlay"
:class="{ show: pickerVisible }"
id="activity-picker-overlay"
>
<div class="activity-picker-header">
<button class="picker-back-btn" @click="closePicker">
<ChevronLeft :size="20" />
</button>
<span class="picker-title">获取活动名</span>
</div>
<div class="picker-steps-indicator">
<div
v-for="n in 3"
:key="n"
class="picker-step-dot"
:class="{ active: pickerStep === n }"
></div>
</div>
<div class="activity-picker-body">
<!-- 步骤 1 -->
<div class="picker-step" v-show="pickerStep === 1">
<div class="picker-step-icon"><Monitor :size="52" stroke-width="1.5" /></div>
<h3 class="picker-step-title">将 Web UI 挂小窗</h3>
<p class="picker-step-desc">
在开始获取前,请先将当前 Web UI 调整为<strong>小窗模式</strong>。<br /><br />
这样在后续步骤中,你可以同时操作目标应用并看到 Web UI 的反馈。
</p>
<Button class="picker-action-btn" @click="pickerStep = 2">已挂小窗,下一步</Button>
</div>
<!-- 步骤 2 -->
<div class="picker-step" v-show="pickerStep === 2">
<div class="picker-step-icon"><Clock :size="52" stroke-width="1.5" /></div>
<h3 class="picker-step-title">切换到目标界面</h3>
<p class="picker-step-desc">
切换到需要屏蔽的应用界面,并点击 「开始获取」<br /><br />
检测到非 Web UI 界面后将<strong>自动停止</strong>。<br /><br />
<span class="picker-status-text" :class="{ polling: pickerPolling }">{{
pickerStatusText
}}</span>
</p>
<Button class="picker-action-btn" :disabled="pickerPolling" @click="startPolling"
>开始获取</Button
>
</div>
<!-- 步骤 3 -->
<div class="picker-step" v-show="pickerStep === 3">
<div class="picker-step-icon">
<CircleCheck :size="52" stroke-width="1.5" />
</div>
<h3 class="picker-step-title">检测到活动</h3>
<p class="picker-step-desc">以下活动将被添加到按活动屏蔽列表:</p>
<div class="picker-result-box">{{ pickerResult }}</div>
<div class="picker-result-actions">
<Button
variant="secondary"
@click="
pickerStep = 2
pickerPolling = false
stopPolling()
"
>重试</Button
>
<Button @click="confirmPicker"><Check :size="15" /> 确认添加</Button>
</div>
</div>
</div>
</div>
</Teleport>
</div>
</template>
+291 -208
View File
@@ -1,36 +1,46 @@
<script setup>
import { inject, ref } from 'vue';
import Button from '@/components/ui/Button.vue';
import Input from '@/components/ui/Input.vue';
import Textarea from '@/components/ui/Textarea.vue';
import Switch from '@/components/ui/Switch.vue';
import Label from '@/components/ui/Label.vue';
import { Save, Settings2, ShieldCheck, FileText, Settings, Monitor, HelpCircle } from 'lucide-vue-next';
import { runCmd } from '../utils.js';
import { inject, ref } from 'vue'
import Button from '@/components/ui/Button.vue'
import Input from '@/components/ui/Input.vue'
import Textarea from '@/components/ui/Textarea.vue'
import Switch from '@/components/ui/Switch.vue'
import Label from '@/components/ui/Label.vue'
import {
Save,
Settings2,
ShieldCheck,
FileText,
Settings,
Monitor,
HelpCircle,
} from 'lucide-vue-next'
import { runCmd } from '../utils.js'
const config = inject('config');
const showToast = inject('showToast');
const restartRefresh = inject('restartRefresh');
const config = inject('config')
const showToast = inject('showToast')
const restartRefresh = inject('restartRefresh')
// 恢复默认二次确认
const resetConfirming = ref(false);
let resetTimer = null;
const resetConfirming = ref(false)
let resetTimer = null
function handleReset() {
if (!resetConfirming.value) {
resetConfirming.value = true;
resetTimer = setTimeout(() => { resetConfirming.value = false; }, 5000);
return;
resetConfirming.value = true
resetTimer = setTimeout(() => {
resetConfirming.value = false
}, 5000)
return
}
clearTimeout(resetTimer);
resetConfirming.value = false;
config.resetToDefaults(showToast);
clearTimeout(resetTimer)
resetConfirming.value = false
config.resetToDefaults(showToast)
}
async function viewInotifyHelp() {
showToast('获取中...');
const res = await runCmd('inotifyd --help');
const out = (res.stderr || '') + (res.stdout || '');
alert(out.trim() || '无法获取帮助信息');
showToast('获取中...')
const res = await runCmd('inotifyd --help')
const out = (res.stderr || '') + (res.stdout || '')
alert(out.trim() || '无法获取帮助信息')
}
function handleSaveWebUI() {
@@ -41,206 +51,279 @@ function handleSaveWebUI() {
config.uiZoom.value,
config.themeMode.value,
restartRefresh,
);
)
}
</script>
<template>
<div style="display:contents">
<!-- === 亮度配置 === -->
<section class="card" id="config-section" data-nav-group="config">
<div class="card-header"><h2>亮度配置</h2></div>
<div style="display: contents">
<!-- === 亮度配置 === -->
<section class="card" id="config-section" data-nav-group="config">
<div class="card-header"><h2>亮度配置</h2></div>
<div class="config-group">
<h3 class="group-title"><Settings2 :size="16" /> 亮度调节</h3>
<div class="config-group">
<h3 class="group-title"><Settings2 :size="16" /> 亮度调节</h3>
<div class="config-item">
<div class="config-label">
<span class="config-name">前台最大亮度</span>
<span class="config-desc">触发亮度提升的阈值</span>
</div>
<Input v-model="config.uiMaxBri.value" type="number" min="0" class="config-input" />
</div>
<div class="config-item">
<div class="config-label">
<span class="config-name">峰值最大亮度</span>
<span class="config-desc">亮度提升的目标值</span>
</div>
<Input v-model="config.maxBri.value" type="number" min="0" class="config-input" />
</div>
<div class="config-item">
<div class="config-label">
<span class="config-name">亮度提升步数</span>
<span class="config-desc">约 0.02 秒 / 步</span>
</div>
<Input v-model="config.stepsNum.value" type="number" min="1" max="500" class="config-input" />
</div>
</div>
<div class="config-group">
<h3 class="group-title"><ShieldCheck :size="16" /> 执行策略</h3>
<div class="config-item">
<div class="config-label">
<span class="config-name">自动亮度时休眠</span>
<span class="config-desc">开启自动亮度时不提升</span>
</div>
<Switch v-model="config.autoBriSleep.value" />
</div>
<div class="config-item">
<div class="config-label">
<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>
</div>
<Switch v-model="config.displayHdrSleep.value" />
</div>
<div class="config-item">
<div class="config-label">
<span class="config-name">定时休眠</span>
<span class="config-desc">设定时段内不提升亮度</span>
</div>
<Switch v-model="config.sleepMode.value" />
</div>
<div class="config-item-expand" :class="{ show: config.sleepMode.value }">
<div class="custom-time-picker">
<div class="time-unit">
<input type="number" v-model="config.sleepStartH.value" class="time-input" min="0" max="23" placeholder="00" />
<span>:</span>
<input type="number" v-model="config.sleepStartM.value" class="time-input" min="0" max="59" placeholder="00" />
<div class="config-item">
<div class="config-label">
<span class="config-name">前台最大亮度</span>
<span class="config-desc">触发亮度提升的阈值</span>
</div>
<span class="time-sep">至</span>
<div class="time-unit">
<input type="number" v-model="config.sleepEndH.value" class="time-input" min="0" max="23" placeholder="00" />
<span>:</span>
<input type="number" v-model="config.sleepEndM.value" class="time-input" min="0" max="59" placeholder="00" />
<Input v-model="config.uiMaxBri.value" type="number" min="0" class="config-input" />
</div>
<div class="config-item">
<div class="config-label">
<span class="config-name">峰值最大亮度</span>
<span class="config-desc">亮度提升的目标值</span>
</div>
<Input v-model="config.maxBri.value" type="number" min="0" class="config-input" />
</div>
<div class="config-item">
<div class="config-label">
<span class="config-name">亮度提升步数</span>
<span class="config-desc">约 0.02 秒 / 步</span>
</div>
<Input
v-model="config.stepsNum.value"
type="number"
min="1"
max="500"
class="config-input"
/>
</div>
</div>
<div class="config-group">
<h3 class="group-title"><ShieldCheck :size="16" /> 执行策略</h3>
<div class="config-item">
<div class="config-label">
<span class="config-name">自动亮度时休眠</span>
<span class="config-desc">开启自动亮度时不提升</span>
</div>
<Switch v-model="config.autoBriSleep.value" />
</div>
<div class="config-item">
<div class="config-label">
<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
>
</div>
<Switch v-model="config.displayHdrSleep.value" />
</div>
<div class="config-item">
<div class="config-label">
<span class="config-name">定时休眠</span>
<span class="config-desc">设定时段内不提升亮度</span>
</div>
<Switch v-model="config.sleepMode.value" />
</div>
<div class="config-item-expand" :class="{ show: config.sleepMode.value }">
<div class="custom-time-picker">
<div class="time-unit">
<input
type="number"
v-model="config.sleepStartH.value"
class="time-input"
min="0"
max="23"
placeholder="00"
/>
<span>:</span>
<input
type="number"
v-model="config.sleepStartM.value"
class="time-input"
min="0"
max="59"
placeholder="00"
/>
</div>
<span class="time-sep">至</span>
<div class="time-unit">
<input
type="number"
v-model="config.sleepEndH.value"
class="time-input"
min="0"
max="23"
placeholder="00"
/>
<span>:</span>
<input
type="number"
v-model="config.sleepEndM.value"
class="time-input"
min="0"
max="59"
placeholder="00"
/>
</div>
</div>
</div>
</div>
</div>
<div class="config-group">
<h3 class="group-title"><FileText :size="16" /> 系统管理</h3>
<div class="config-item">
<div class="config-label">
<span class="config-name">日志大小限制</span>
<span class="config-desc">单位: KB</span>
</div>
<Input v-model="config.logMaxSize.value" type="number" min="1" max="10240" class="config-input" />
</div>
</div>
<div class="card-actions">
<Button variant="outline" @click="handleReset" :class="resetConfirming ? 'border-destructive text-destructive' : ''">
{{ resetConfirming ? '确认恢复?' : '恢复默认' }}
</Button>
<Button @click="config.save(showToast)">
<Save :size="15" /> 保存配置
</Button>
</div>
</section>
<!-- === 高级设置 === -->
<section class="card" id="advanced-section" data-nav-group="config">
<div class="card-header"><h2>高级设置</h2></div>
<div class="config-group">
<h3 class="group-title"><Settings :size="16" /> 运行环境</h3>
<div class="config-item">
<div class="config-label">
<span class="config-name">inotifyd 监听事件</span>
<span class="config-desc">默认 c。修改需重启服务</span>
<span class="config-desc" style="color:var(--color-warning)">修改为 c 以外时建议关闭自动刷新</span>
<button class="btn-text-s" style="margin-top:6px;padding:2px 6px" @click="viewInotifyHelp">
查看支持事件
</button>
</div>
<Input v-model="config.inotifyEvents.value" type="text" placeholder="c" class="config-input" />
</div>
<div class="config-item" id="advanced-section">
<div class="config-label">
<span class="config-name">当前亮度节点</span>
<span class="config-desc">修改需重启服务</span>
</div>
<Textarea v-model="config.nowBriFile.value" class="config-textarea" />
</div>
<div class="config-item">
<div class="config-label">
<span class="config-name">最大亮度节点</span>
<span class="config-desc">修改需重启服务</span>
</div>
<Textarea v-model="config.sysMaxBriFile.value" class="config-textarea" />
</div>
</div>
<div class="card-actions">
<Button @click="config.saveAdvanced(showToast, () => {})">
<Save :size="15" /> 保存设置
</Button>
</div>
</section>
<!-- === Web UI 配置 === -->
<section class="card" id="webui-config-section" data-nav-group="config">
<div class="card-header"><h2>Web UI 配置</h2></div>
<div class="config-group">
<h3 class="group-title"><Monitor :size="16" /> 界面设置</h3>
<div class="config-item">
<div class="config-label">
<span class="config-name">自动刷新</span>
<span class="config-desc">定时刷新状态和日志。监听非 c 事件时建议关闭</span>
</div>
<Switch v-model="config.autoRefresh.value" />
</div>
<div class="config-item" v-show="config.autoRefresh.value">
<div class="config-label">
<span class="config-name">状态/日志刷新间隔</span>
<span class="config-desc">单位: 毫秒 (最小100ms)</span>
</div>
<Input v-model="config.statusRefreshInterval.value" type="number" min="100" class="config-input" />
</div>
<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="config.themeMode.value = opt.v; config.applyTheme(opt.v)"
>{{ opt.l }}</button>
<div class="config-group">
<h3 class="group-title"><FileText :size="16" /> 系统管理</h3>
<div class="config-item">
<div class="config-label">
<span class="config-name">日志大小限制</span>
<span class="config-desc">单位: KB</span>
</div>
<Input
v-model="config.logMaxSize.value"
type="number"
min="1"
max="10240"
class="config-input"
/>
</div>
</div>
<div class="config-item">
<div class="config-label">
<span class="config-name">界面缩放</span>
<span class="config-desc">50% - 150%(立即生效)</span>
</div>
<Input v-model="config.uiZoom.value" type="number" min="50" max="150" class="config-input" />
<div class="card-actions">
<Button
variant="outline"
@click="handleReset"
:class="resetConfirming ? 'border-destructive text-destructive' : ''"
>
{{ resetConfirming ? '确认恢复?' : '恢复默认' }}
</Button>
<Button @click="config.save(showToast)"> <Save :size="15" /> 保存配置 </Button>
</div>
</div>
</section>
<div class="card-actions">
<Button @click="handleSaveWebUI">
<Save :size="15" /> 保存配置
</Button>
</div>
</section>
<!-- === 高级设置 === -->
<section class="card" id="advanced-section" data-nav-group="config">
<div class="card-header"><h2>高级设置</h2></div>
<div class="config-group">
<h3 class="group-title"><Settings :size="16" /> 运行环境</h3>
<div class="config-item">
<div class="config-label">
<span class="config-name">inotifyd 监听事件</span>
<span class="config-desc">默认 c。修改需重启服务</span>
<span class="config-desc" style="color: var(--color-warning)"
>修改为 c 以外时建议关闭自动刷新</span
>
<button
class="btn-text-s"
style="margin-top: 6px; padding: 2px 6px"
@click="viewInotifyHelp"
>
查看支持事件
</button>
</div>
<Input
v-model="config.inotifyEvents.value"
type="text"
placeholder="c"
class="config-input"
/>
</div>
<div class="config-item" id="advanced-section">
<div class="config-label">
<span class="config-name">当前亮度节点</span>
<span class="config-desc">修改需重启服务</span>
</div>
<Textarea v-model="config.nowBriFile.value" class="config-textarea" />
</div>
<div class="config-item">
<div class="config-label">
<span class="config-name">最大亮度节点</span>
<span class="config-desc">修改需重启服务</span>
</div>
<Textarea v-model="config.sysMaxBriFile.value" class="config-textarea" />
</div>
</div>
<div class="card-actions">
<Button @click="config.saveAdvanced(showToast, () => {})">
<Save :size="15" /> 保存设置
</Button>
</div>
</section>
<!-- === Web UI 配置 === -->
<section class="card" id="webui-config-section" data-nav-group="config">
<div class="card-header"><h2>Web UI 配置</h2></div>
<div class="config-group">
<h3 class="group-title"><Monitor :size="16" /> 界面设置</h3>
<div class="config-item">
<div class="config-label">
<span class="config-name">自动刷新</span>
<span class="config-desc">定时刷新状态和日志。监听非 c 事件时建议关闭</span>
</div>
<Switch v-model="config.autoRefresh.value" />
</div>
<div class="config-item" v-show="config.autoRefresh.value">
<div class="config-label">
<span class="config-name">状态/日志刷新间隔</span>
<span class="config-desc">单位: 毫秒 (最小100ms)</span>
</div>
<Input
v-model="config.statusRefreshInterval.value"
type="number"
min="100"
class="config-input"
/>
</div>
<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="
config.themeMode.value = opt.v
config.applyTheme(opt.v)
"
>
{{ opt.l }}
</button>
</div>
</div>
<div class="config-item">
<div class="config-label">
<span class="config-name">界面缩放</span>
<span class="config-desc">50% - 150%(立即生效)</span>
</div>
<Input
v-model="config.uiZoom.value"
type="number"
min="50"
max="150"
class="config-input"
/>
</div>
</div>
<div class="card-actions">
<Button @click="handleSaveWebUI"> <Save :size="15" /> 保存配置 </Button>
</div>
</section>
</div>
</template>
+61 -27
View File
@@ -1,41 +1,43 @@
<script setup>
import { inject, ref, onMounted } from 'vue';
import Button from '@/components/ui/Button.vue';
import { RefreshCw, Copy, Download, Trash2 } from 'lucide-vue-next';
import { inject, ref, onMounted } from 'vue'
import Button from '@/components/ui/Button.vue'
import { RefreshCw, Copy, Download, Trash2 } from 'lucide-vue-next'
const showToast = inject('showToast');
const log = inject('log');
const showToast = inject('showToast')
const log = inject('log')
const logMenuOpen = ref(false);
const clearConfirming = ref(false);
const logMenuOpen = ref(false)
const clearConfirming = ref(false)
let clearConfirmTimer = null;
let clearConfirmTimer = null
function handleClear() {
if (!clearConfirming.value) {
clearConfirming.value = true;
clearConfirmTimer = setTimeout(() => { clearConfirming.value = false; }, 3000);
return;
clearConfirming.value = true
clearConfirmTimer = setTimeout(() => {
clearConfirming.value = false
}, 3000)
return
}
clearTimeout(clearConfirmTimer);
clearConfirming.value = false;
logMenuOpen.value = false;
log.clear(showToast);
clearTimeout(clearConfirmTimer)
clearConfirming.value = false
logMenuOpen.value = false
log.clear(showToast)
}
// filter options
const filterOptions = [
{ key: '', label: '全部' },
{ key: 'INFO', label: 'INFO' },
{ key: 'WARN', label: 'WARN' },
{ key: '', label: '全部' },
{ key: 'INFO', label: 'INFO' },
{ key: 'WARN', label: 'WARN' },
{ key: 'ERROR', label: 'ERROR' },
];
]
onMounted(() => log.load());
onMounted(() => log.load())
</script>
<template>
<section class="card" id="log-section">
<div class="card-header" style="margin-bottom:8px">
<div class="card-header" style="margin-bottom: 8px">
<h2>运行日志</h2>
<div class="header-actions dropdown-container">
<Button variant="ghost" size="icon" @click="log.load">
@@ -43,16 +45,46 @@ onMounted(() => log.load());
</Button>
<Button variant="ghost" size="icon" @click="logMenuOpen = !logMenuOpen">
<span class="sr-only">更多操作</span>
<svg xmlns="http://www.w3.org/2000/svg" width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="12" cy="12" r="1"/><circle cx="12" cy="5" r="1"/><circle cx="12" cy="19" r="1"/></svg>
<svg
xmlns="http://www.w3.org/2000/svg"
width="18"
height="18"
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
stroke-width="2"
stroke-linecap="round"
stroke-linejoin="round"
>
<circle cx="12" cy="12" r="1" />
<circle cx="12" cy="5" r="1" />
<circle cx="12" cy="19" r="1" />
</svg>
</Button>
<div class="dropdown-menu" :class="{ show: logMenuOpen }" @click.stop>
<div class="dropdown-item" @click="log.copy(showToast); logMenuOpen=false">
<div
class="dropdown-item"
@click="
log.copy(showToast)
logMenuOpen = false
"
>
<Copy :size="18" /><span>复制日志</span>
</div>
<div class="dropdown-item" @click="log.exportLog(showToast); logMenuOpen=false">
<div
class="dropdown-item"
@click="
log.exportLog(showToast)
logMenuOpen = false
"
>
<Download :size="18" /><span>导出日志文件</span>
</div>
<div class="dropdown-item" :class="{ 'dropdown-item-danger': clearConfirming }" @click="handleClear">
<div
class="dropdown-item"
:class="{ 'dropdown-item-danger': clearConfirming }"
@click="handleClear"
>
<Trash2 :size="18" />
<span>{{ clearConfirming ? '再次点击确认清除' : '清除日志' }}</span>
</div>
@@ -61,7 +93,7 @@ onMounted(() => log.load());
</div>
<!-- 过滤器 -->
<div class="log-filter-container" style="margin-bottom:var(--spacing-s)">
<div class="log-filter-container" style="margin-bottom: var(--spacing-s)">
<div class="log-filter-tabs">
<button
v-for="opt in filterOptions"
@@ -69,7 +101,9 @@ onMounted(() => log.load());
class="log-filter-tab"
:class="{ active: log.filterLevel.value === opt.key }"
@click="log.filterLevel.value = opt.key"
>{{ opt.label }}</button>
>
{{ opt.label }}
</button>
</div>
</div>
+47 -36
View File
@@ -1,53 +1,64 @@
<script setup>
import { inject, computed, ref } from 'vue';
import Button from '@/components/ui/Button.vue';
import Switch from '@/components/ui/Switch.vue';
import Badge from '@/components/ui/Badge.vue';
import { inject, computed, ref } from 'vue'
import Button from '@/components/ui/Button.vue'
import Switch from '@/components/ui/Switch.vue'
import Badge from '@/components/ui/Badge.vue'
import {
RefreshCw, Play, RotateCcw,
SunMedium, Smartphone, Activity, Clock, Moon, Layers,
} from 'lucide-vue-next';
RefreshCw,
Play,
RotateCcw,
SunMedium,
Smartphone,
Activity,
Clock,
Moon,
Layers,
} from 'lucide-vue-next'
const status = inject('status');
const showToast = inject('showToast');
const config = inject('config');
const status = inject('status')
const showToast = inject('showToast')
const config = inject('config')
const confirmedLowBri = ref(false);
const confirmedLowBri = ref(false)
// --------- 亮度滑条渐变 ----------
const sliderStyle = computed(() => {
const sysMax = parseInt(status.sysMaxBri.value) || 255;
const curr = parseInt(status.currentBri.value) || 0;
const uiMax = parseInt(config.uiMaxBri.value) || sysMax;
const c = (curr / sysMax) * 100;
const u = (uiMax / sysMax) * 100;
const pri = '#a8c7fa';
const bst = '#fb8c00';
const trk = 'var(--md-sys-color-surface-container-high)';
const btrk = 'rgba(251,140,0,0.15)';
const sysMax = parseInt(status.sysMaxBri.value) || 255
const curr = parseInt(status.currentBri.value) || 0
const uiMax = parseInt(config.uiMaxBri.value) || sysMax
const c = (curr / sysMax) * 100
const u = (uiMax / sysMax) * 100
const pri = '#a8c7fa'
const bst = '#fb8c00'
const trk = 'var(--md-sys-color-surface-container-high)'
const btrk = 'rgba(251,140,0,0.15)'
if (c <= u) {
return `background: linear-gradient(to right, ${pri} 0%, ${pri} ${c}%, ${trk} ${c}%, ${trk} ${u}%, ${btrk} ${u}%, ${btrk} 100%)`;
return `background: linear-gradient(to right, ${pri} 0%, ${pri} ${c}%, ${trk} ${c}%, ${trk} ${u}%, ${btrk} ${u}%, ${btrk} 100%)`
}
return `background: linear-gradient(to right, ${pri} 0%, ${pri} ${u}%, ${bst} ${u}%, ${bst} ${c}%, ${btrk} ${c}%, ${btrk} 100%)`;
});
return `background: linear-gradient(to right, ${pri} 0%, ${pri} ${u}%, ${bst} ${u}%, ${bst} ${c}%, ${btrk} ${c}%, ${btrk} 100%)`
})
const brightnessPercent = computed(() => {
const sysMax = parseInt(status.sysMaxBri.value) || 255;
const curr = parseInt(status.currentBri.value) || 0;
return Math.round((curr / sysMax) * 100) + '%';
});
const sysMax = parseInt(status.sysMaxBri.value) || 255
const curr = parseInt(status.currentBri.value) || 0
return Math.round((curr / sysMax) * 100) + '%'
})
async function onSliderChange(e) {
const newBri = parseInt(e.target.value, 10);
const sysMax = parseInt(status.sysMaxBri.value) || 255;
const pct = Math.round((newBri / sysMax) * 100);
const newBri = parseInt(e.target.value, 10)
const sysMax = parseInt(status.sysMaxBri.value) || 255
const pct = Math.round((newBri / sysMax) * 100)
if (pct < 5 && !confirmedLowBri.value) {
const ok = confirm('⚠️ 警告:亮度低于 5% 可能导致屏幕近似黑屏。\n\n确定要继续吗?');
if (!ok) { const safe = Math.ceil(sysMax * 0.05); e.target.value = safe; return; }
confirmedLowBri.value = true;
const ok = confirm('⚠️ 警告:亮度低于 5% 可能导致屏幕近似黑屏。\n\n确定要继续吗?')
if (!ok) {
const safe = Math.ceil(sysMax * 0.05)
e.target.value = safe
return
}
confirmedLowBri.value = true
}
if (pct >= 5) confirmedLowBri.value = false;
await status.setBrightness(newBri, showToast);
if (pct >= 5) confirmedLowBri.value = false
await status.setBrightness(newBri, showToast)
}
const statusItems = computed(() => [
@@ -57,7 +68,7 @@ const statusItems = computed(() => [
{ label: 'inotifyd 状态', value: status.inotifydState.value, icon: Clock },
{ label: '休眠状态', value: status.sleepStatus.value, icon: Moon },
{ label: 'HDR/SDR 比率', value: status.hdrRatio.value, icon: Layers },
]);
])
</script>
<template>
+5 -5
View File
@@ -1,7 +1,7 @@
import { defineConfig } from 'vite';
import vue from '@vitejs/plugin-vue';
import tailwindcss from '@tailwindcss/vite';
import { fileURLToPath, URL } from 'node:url';
import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import tailwindcss from '@tailwindcss/vite'
import { fileURLToPath, URL } from 'node:url'
export default defineConfig({
plugins: [vue(), tailwindcss()],
@@ -14,4 +14,4 @@ export default defineConfig({
outDir: '../webroot',
emptyOutDir: true,
},
});
})