-
-
-
-
- 正在执行后台操作,已暂停刷新
-
-
+
-
-
-
-
-
+
+
+
+
+
diff --git a/webui/src/about.css b/webui/src/about.css
deleted file mode 100644
index bae008a..0000000
--- a/webui/src/about.css
+++ /dev/null
@@ -1,330 +0,0 @@
-/* ==========================================
- About View Styles
- ========================================== */
-.about-hero {
- display: flex;
- flex-direction: column;
- align-items: center;
- padding: var(--spacing-l) 0 var(--spacing-m);
- gap: 8px;
-}
-.about-logo {
- width: 72px;
- height: 72px;
- border-radius: 20px;
- background: linear-gradient(
- 135deg,
- var(--md-sys-color-primary-container),
- var(--md-sys-color-secondary-container)
- );
- display: flex;
- align-items: center;
- justify-content: center;
- color: var(--md-sys-color-primary);
- margin-bottom: 4px;
-}
-.about-name {
- margin: 0;
- font-size: 1.5rem;
- font-weight: 700;
- color: var(--md-sys-color-on-surface);
-}
-.about-desc {
- margin: 0;
- font-size: 0.875rem;
- color: var(--md-sys-color-on-surface-variant);
-}
-.about-version-badge {
- display: inline-block;
- padding: 2px 10px;
- background-color: var(--md-sys-color-primary-container);
- color: var(--md-sys-color-on-primary-container);
- border-radius: 100px;
- font-size: 0.75rem;
- font-weight: 600;
- letter-spacing: 0.3px;
-}
-.about-section-title {
- font-size: 0.75rem;
- font-weight: 600;
- color: var(--md-sys-color-primary);
- text-transform: uppercase;
- letter-spacing: 1px;
- margin: var(--spacing-l) 0 var(--spacing-s);
-}
-.about-list {
- display: flex;
- flex-direction: column;
- gap: 2px;
- background-color: var(--md-sys-color-surface-container);
- border-radius: var(--border-radius-m);
- overflow: hidden;
-}
-.about-list-item {
- display: flex;
- align-items: center;
- gap: 12px;
- padding: 14px 16px;
- background: transparent;
- border: none;
- color: var(--md-sys-color-on-surface);
- font-size: 0.9375rem;
- font-family: inherit;
- cursor: pointer;
- text-decoration: none;
- transition: background-color 0.15s;
- text-align: left;
- 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);
-}
-.about-list-item:active {
- background-color: var(--md-sys-color-surface-container-high);
-}
-.about-list-icon {
- color: var(--md-sys-color-primary);
- flex-shrink: 0;
-}
-.about-list-chevron {
- margin-left: auto;
- color: var(--md-sys-color-on-surface-variant);
- opacity: 0.5;
- flex-shrink: 0;
-}
-.about-footer {
- text-align: center;
- color: var(--md-sys-color-on-surface-variant);
- font-size: 0.8125rem;
- margin-top: var(--spacing-l);
- padding-top: var(--spacing-m);
- border-top: 1px solid rgba(var(--md-sys-color-outline-variant-rgb, 142, 144, 153), 0.15);
-}
-
-/* ==========================================
- Doc Sheet (Bottom drawer)
- ========================================== */
-.doc-sheet-backdrop {
- position: fixed;
- inset: 0;
- background: rgba(0, 0, 0, 0.5);
- backdrop-filter: blur(4px);
- z-index: 1999;
- opacity: 0;
- pointer-events: none;
- transition: opacity 0.3s ease;
-}
-.doc-sheet-backdrop.show {
- opacity: 1;
- pointer-events: auto;
-}
-.doc-sheet {
- position: fixed;
- left: 0;
- right: 0;
- bottom: 0;
- max-height: 90vh;
- background-color: var(--md-sys-color-surface-container-high);
- border-radius: 28px 28px 0 0;
- z-index: 2000;
- display: flex;
- 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);
- overflow: hidden;
-}
-.doc-sheet.show {
- transform: translateY(0);
-}
-.doc-sheet-header {
- 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);
- gap: 12px;
- flex-shrink: 0;
-}
-.doc-sheet-title {
- font-size: 1.0625rem;
- font-weight: 600;
- color: var(--md-sys-color-on-surface);
- flex: 1;
-}
-.doc-sheet-close {
- display: flex;
- align-items: center;
- justify-content: center;
- width: 32px;
- height: 32px;
- border-radius: 50%;
- border: none;
- background: transparent;
- color: var(--md-sys-color-on-surface-variant);
- cursor: pointer;
- transition: background-color 0.15s;
-}
-.doc-sheet-close:active {
- background-color: var(--md-sys-color-surface-container);
-}
-.doc-sheet-body {
- flex: 1;
- overflow-y: auto;
- padding: 20px 20px 48px;
- scrollbar-width: none;
-}
-.doc-sheet-body::-webkit-scrollbar {
- display: none;
-}
-.doc-sheet-loading {
- text-align: center;
- padding: 48px 20px;
- color: var(--md-sys-color-on-surface-variant);
-}
-.doc-sheet-content {
- font-size: 0.9rem;
- line-height: 1.75;
- color: var(--md-sys-color-on-surface);
- word-break: break-word;
-}
-.doc-sheet-content h1,
-.doc-sheet-content h2 {
- color: var(--md-sys-color-primary);
- margin-top: 1.4em;
- margin-bottom: 0.4em;
-}
-.doc-sheet-content h3,
-.doc-sheet-content h4 {
- color: var(--md-sys-color-on-primary-container);
- margin-top: 1.2em;
- margin-bottom: 0.3em;
-}
-.doc-sheet-content p {
- margin: 0.6em 0;
-}
-.doc-sheet-content a {
- color: var(--md-sys-color-primary);
- text-decoration: underline;
- word-break: break-all;
-}
-.doc-sheet-content ul,
-.doc-sheet-content ol {
- padding-left: 1.4em;
- margin: 0.5em 0;
-}
-.doc-sheet-content li {
- margin: 0.25em 0;
-}
-.doc-sheet-content code {
- background-color: var(--md-sys-color-surface-container);
- padding: 2px 6px;
- border-radius: 4px;
- font-family: 'Geist Mono', monospace;
- font-size: 0.85em;
-}
-.doc-sheet-content pre {
- background-color: var(--md-sys-color-surface-container);
- border-radius: 8px;
- padding: 12px 14px;
- overflow-x: auto;
- margin: 0.75em 0;
-}
-.doc-sheet-content pre code {
- background: none;
- padding: 0;
- border-radius: 0;
- font-size: 0.82em;
- line-height: 1.6;
-}
-.doc-sheet-content blockquote {
- border-left: 3px solid var(--md-sys-color-primary-container);
- margin: 0.75em 0;
- padding: 0.2em 0.75em;
- color: var(--md-sys-color-on-surface-variant);
- background-color: rgba(var(--md-sys-color-primary-rgb), 0.06);
- border-radius: 0 4px 4px 0;
-}
-.doc-sheet-content hr {
- border: none;
- border-top: 1px solid var(--md-sys-color-outline-variant);
- margin: 1.2em 0;
-}
-.doc-sheet-content table {
- border-collapse: collapse;
- width: 100%;
- margin: 0.75em 0;
- font-size: 0.85em;
-}
-.doc-sheet-content th,
-.doc-sheet-content td {
- border: 1px solid var(--md-sys-color-outline-variant);
- padding: 6px 10px;
- text-align: left;
-}
-.doc-sheet-content th {
- background-color: var(--md-sys-color-surface-container);
- font-weight: 600;
-}
-
-/* ==========================================
- Log Filter Tabs
- ========================================== */
-.log-filter-container {
- display: flex;
- align-items: center;
- gap: var(--spacing-s);
-}
-.log-filter-tabs {
- display: flex;
- gap: 4px;
- background-color: var(--md-sys-color-surface-container);
- padding: 4px;
- border-radius: var(--border-radius-s);
-}
-.log-filter-tab {
- padding: 4px 12px;
- border-radius: calc(var(--border-radius-s) - 2px);
- border: none;
- background: transparent;
- color: var(--md-sys-color-on-surface-variant);
- font-size: 0.8125rem;
- font-weight: 500;
- font-family: inherit;
- cursor: pointer;
- transition: all 0.2s;
-}
-.log-filter-tab.active {
- background-color: var(--md-sys-color-surface-container-high);
- color: var(--md-sys-color-primary);
- font-weight: 600;
-}
-
-/* ==========================================
- Theme Segmented Button
- ========================================== */
-.theme-seg {
- display: flex;
- gap: 2px;
- background-color: var(--md-sys-color-surface-container);
- padding: 3px;
- border-radius: var(--border-radius-s);
- flex-shrink: 0;
-}
-.theme-seg-btn {
- padding: 4px 12px;
- border-radius: calc(var(--border-radius-s) - 2px);
- border: none;
- background: transparent;
- color: var(--md-sys-color-on-surface-variant);
- font-size: 0.8125rem;
- font-weight: 500;
- font-family: inherit;
- cursor: pointer;
- transition: all 0.18s ease;
- white-space: nowrap;
-}
-.theme-seg-btn.active {
- background-color: var(--md-sys-color-primary-container);
- color: var(--md-sys-color-on-primary-container);
- font-weight: 600;
-}
diff --git a/webui/src/api/devMock.js b/webui/src/api/devMock.js
new file mode 100644
index 0000000..8b9c504
--- /dev/null
+++ b/webui/src/api/devMock.js
@@ -0,0 +1,80 @@
+/**
+ * 开发环境(浏览器直开、无 KernelSU bridge)下返回模拟数据,
+ * 便于在电脑上调试界面。真机永远不会走到这里。
+ */
+
+const mockStatus = (display) => ({
+ module: { id: 'LuminPro', name: 'LuminPro', version: 'V2.5.0-beta.2', versionCode: 2050052, channel: 'beta' },
+ daemon: { pid: 12345, running: true, state: 'S', mode: 'event', paused: false, uptimeSec: 3620 },
+ brightness: { current: 1200, max: 4095, percent: 29, node: '/sys/mock/brightness', maxNode: '/sys/mock/max_brightness' },
+ display: display
+ ? { hdrRatio: 1.02, hdrKnown: true, hdrStale: false, hdrSleep: false, autoBrightness: false }
+ : undefined,
+ sleep: { window: '2300-0700', active: false },
+ oplock: { locked: false, seconds: 0 },
+ config: {
+ uiMaxBri: 1000,
+ maxBri: 3500,
+ stepsNum: 50,
+ sleepTime: '2300-0700',
+ autoBriSleep: 1,
+ displayHdrSleep: 0,
+ hdrEnterRatio: 1.15,
+ hdrExitRatio: 1.05,
+ compatibilityMode: 0,
+ logLevel: 'info',
+ logMaxSize: 512,
+ debugMode: 0,
+ nowBriFile: '/sys/class/backlight/panel0-backlight/brightness',
+ maxBriFile: '/sys/class/backlight/panel0-backlight/max_brightness',
+ blacklistCount: 3,
+ },
+ log: { path: '/data/adb/modules/LuminPro/service.log', sizeKB: 12 },
+})
+
+const mockConfig = () => ({
+ ui_max_bri: 1000,
+ max_bri: 3500,
+ steps_num: 50,
+ log_max_size: 512,
+ auto_bri_sleep: 1,
+ display_hdr_sleep: 0,
+ hdr_enter_ratio: 1.15,
+ hdr_exit_ratio: 1.05,
+ compatibility_mode: 0,
+ sleep_time: '2300-0700',
+ inotify_events: 'c',
+ now_bri_file: '/sys/mock/brightness',
+ max_bri_file: '/sys/mock/max_brightness',
+ log_level: 'info',
+ debug_mode: 0,
+ blacklist_apps: ['com.example.video'],
+})
+
+const mockLogEntries = [
+ { time: '09-10 12:00:01', tag: 'luminpro', level: 'INFO', message: '守护进程已启动' },
+ { time: '09-10 12:00:03', tag: 'luminpro', level: 'INFO', message: '正在监听: /sys/mock/brightness, 事件: c' },
+ { time: '09-10 12:01:12', tag: 'luminpro', level: 'INFO', message: '触发提升: 当前亮度 1200 ≥ 阈值 1000,目标 3500' },
+ { time: '09-10 12:01:12', tag: 'luminpro', level: 'WARN', message: 'HDR 比率读取为空,使用缓存值: 1.02' },
+ { time: '09-10 12:01:13', tag: 'luminpro', level: 'SUCCESS', message: '亮度提升完成 (3500)' },
+]
+
+const ok = (obj) => ({ ok: true, errno: 0, stdout: JSON.stringify(obj), stderr: '' })
+
+/** 依据命令内容返回模拟响应;无法识别时返回 null */
+export function devMock(command) {
+ if (command.includes(' config read')) return ok(mockConfig())
+ if (command.includes(' config patch') || command.includes(' config set')) return ok({ ok: true })
+ if (command.includes(' status')) return ok(mockStatus(!command.includes('--no-display')))
+ if (command.includes(' oplock')) return ok({ locked: false, seconds: 0 })
+ if (command.includes(' focus')) return ok({ focus: 'com.example.video/.MainActivity' })
+ if (command.includes(' brightness set')) return ok({ ok: true, value: 2000 })
+ if (command.includes(' log tail')) {
+ return ok({ entries: mockLogEntries, sizeKB: 12, total: mockLogEntries.length })
+ }
+ if (command.includes(' log clear') || command.includes(' log export')) return ok({ ok: true })
+ if (command.includes('boost') || command.includes('restart') || command.includes('action.sh')) {
+ return { ok: true, errno: 0, stdout: 'LuminPro: 服务已启用', stderr: '' }
+ }
+ return null
+}
diff --git a/webui/src/api/ksu.js b/webui/src/api/ksu.js
new file mode 100644
index 0000000..8f4500c
--- /dev/null
+++ b/webui/src/api/ksu.js
@@ -0,0 +1,51 @@
+import { exec, moduleInfo } from 'kernelsu'
+import { devMock } from './devMock.js'
+
+export const MODULE_DIR = '/data/adb/modules/LuminPro'
+export const BIN = `${MODULE_DIR}/bin/luminpro`
+
+/** 是否为 KernelSU 环境(exec 可用) */
+let available = true
+
+export function isKsuAvailable() {
+ return available
+}
+
+/**
+ * 执行 shell 命令。所有命令都是固定字符串或经 shellQuote 处理过的参数,
+ * 不把未校验的用户输入直接拼进命令。
+ */
+export async function runCmd(command) {
+ try {
+ const res = await exec(command)
+ available = true
+ return {
+ ok: res.errno === 0,
+ errno: res.errno,
+ stdout: res.stdout ?? '',
+ stderr: res.stderr ?? '',
+ }
+ } catch (err) {
+ available = false
+ // 仅开发环境回退到模拟数据,真机上失败就是失败
+ if (import.meta.env.DEV) {
+ const mocked = devMock(command)
+ if (mocked) return mocked
+ }
+ return { ok: false, errno: -1, stdout: '', stderr: String(err) }
+ }
+}
+
+/** 把任意字符串安全地包成 shell 单引号参数 */
+export function shellQuote(value) {
+ return `'${String(value).replace(/'/g, "'\\''")}'`
+}
+
+/** 读取模块版本(module.prop 的 version) */
+export function moduleVersion() {
+ try {
+ return JSON.parse(moduleInfo()).version || ''
+ } catch {
+ return import.meta.env.DEV ? 'V2.5.0-dev.0' : ''
+ }
+}
diff --git a/webui/src/api/luminpro.js b/webui/src/api/luminpro.js
new file mode 100644
index 0000000..c945bda
--- /dev/null
+++ b/webui/src/api/luminpro.js
@@ -0,0 +1,85 @@
+/**
+ * Go 侧 JSON API 客户端。所有读写都经由 `luminpro` 子命令:
+ * 一次调用拿回结构化数据,避免前端拼多条 shell 命令与字符串转义。
+ */
+import { BIN, MODULE_DIR, runCmd, shellQuote } from './ksu.js'
+
+/** 调用返回 JSON 的子命令 */
+async function callJSON(subcommand, args = []) {
+ const command = [BIN, subcommand, ...args.map(shellQuote)].join(' ')
+ const res = await runCmd(command)
+ if (!res.ok) {
+ throw new Error(res.stderr.trim() || `命令执行失败: luminpro ${subcommand}`)
+ }
+ try {
+ return JSON.parse(res.stdout)
+ } catch {
+ throw new Error(`输出不是合法 JSON: luminpro ${subcommand}`)
+ }
+}
+
+/** 聚合状态;display=false 时跳过 dumpsys/settings 读取 */
+export function fetchStatus({ display = true } = {}) {
+ return callJSON('status', display ? [] : ['--no-display'])
+}
+
+/** 操作锁状态(轻量,供高频轮询) */
+export function fetchOplock() {
+ return callJSON('oplock')
+}
+
+/** 当前前台 Activity(活动抓取向导用) */
+export function fetchFocus() {
+ return callJSON('focus')
+}
+
+/** 设置亮度 */
+export function setBrightness(value) {
+ return callJSON('brightness', ['set', String(value)])
+}
+
+/** 读取完整配置 */
+export function fetchConfig() {
+ return callJSON('config', ['read'])
+}
+
+/** 浅合并写入配置(只传变化字段) */
+export function patchConfig(patch) {
+ return callJSON('config', ['patch', JSON.stringify(patch)])
+}
+
+/** 读取日志 */
+export function fetchLog(lines = 200) {
+ return callJSON('log', ['tail', '-n', String(lines)])
+}
+
+/** 清空日志 */
+export function clearLog() {
+ return callJSON('log', ['clear'])
+}
+
+/** 导出日志到 /sdcard */
+export function exportLog(dir = '/sdcard') {
+ return callJSON('log', ['export', dir])
+}
+
+/** 一键提升 / 恢复 */
+export function boost() {
+ return runCmd(`${BIN} boost`)
+}
+
+/** 重启模块 */
+export function restart() {
+ return runCmd(`${BIN} restart`)
+}
+
+/** 启停切换(沿用 action.sh,管理器「操作」按钮与之共用同一实现) */
+export function toggleService() {
+ return runCmd(`sh ${MODULE_DIR}/action.sh`)
+}
+
+/** 模块文档内容(关于页) */
+export async function readModuleFile(name) {
+ const res = await runCmd(`cat ${shellQuote(`${MODULE_DIR}/${name}`)} 2>/dev/null`)
+ return res.ok ? res.stdout : ''
+}
diff --git a/webui/src/apps.css b/webui/src/apps.css
deleted file mode 100644
index be2b7e3..0000000
--- a/webui/src/apps.css
+++ /dev/null
@@ -1,562 +0,0 @@
-.app-list-hint {
- font-size: 0.8125rem;
- color: var(--md-sys-color-on-surface-variant);
- margin-top: 0;
- margin-bottom: var(--spacing-m);
-}
-
-/* App Search */
-.app-search-container {
- display: flex;
- align-items: center;
- background-color: var(--md-sys-color-surface-container-high);
- border: 1px solid var(--md-sys-color-outline-variant);
- border-radius: var(--border-radius-m);
- padding: 8px 12px;
- margin-bottom: var(--spacing-m);
- transition:
- border-color 0.2s,
- box-shadow 0.2s;
-}
-
-.app-search-container:focus-within {
- border-color: var(--md-sys-color-primary);
- box-shadow: 0 0 0 2px rgba(168, 199, 250, 0.3);
-}
-
-.search-icon {
- width: 18px;
- height: 18px;
- color: var(--md-sys-color-on-surface-variant);
- margin-right: 8px;
-}
-
-.app-search-input {
- flex: 1;
- width: 100%;
- min-width: 0;
- background: transparent;
- border: none;
- color: var(--md-sys-color-on-surface);
- font-size: 0.875rem;
- outline: none;
- font-family: inherit;
-}
-
-.app-search-input::placeholder {
- color: var(--md-sys-color-on-surface-variant);
-}
-
-.count-badge {
- background-color: var(--md-sys-color-primary-container);
- color: var(--md-sys-color-on-primary-container);
- font-size: 0.75rem;
- font-weight: 600;
- padding: 2px 8px;
- border-radius: 20px;
- margin-left: 8px;
- white-space: nowrap;
- opacity: 0.85;
-}
-
-/* App List */
-.app-list-container {
- max-height: 60vh;
- overflow-y: auto;
- border-radius: var(--border-radius-m);
- padding: 0;
-}
-
-.app-list-container::-webkit-scrollbar {
- display: none;
-}
-
-/* 虚拟滚动:spacer 撑起总高度,行绝对定位;
- 行间距由 item 的 padding-bottom 提供,保证测量行高包含间距 */
-.app-virtual-spacer {
- position: relative;
- width: 100%;
-}
-
-.app-virtual-item {
- position: absolute;
- top: 0;
- left: 0;
- width: 100%;
- padding-bottom: var(--spacing-s);
-}
-
-.app-list-item {
- display: flex;
- flex-direction: column;
- background-color: var(--md-sys-color-surface-container-high);
- border-radius: var(--border-radius-s);
- transition: background-color 0.2s;
- overflow: hidden;
- flex-shrink: 0;
-}
-
-.app-item-main-row {
- display: flex;
- align-items: center;
- gap: var(--spacing-m);
- padding: var(--spacing-s) var(--spacing-m);
-}
-
-.app-item-main-row:active {
- background-color: var(--md-sys-color-surface-container);
-}
-
-.app-checkbox-label {
- display: flex;
- align-items: center;
- cursor: pointer;
- position: relative;
-}
-
-.app-checkbox {
- opacity: 0;
- position: absolute;
- width: 0;
- height: 0;
-}
-
-.app-checkbox-custom {
- width: 20px;
- height: 20px;
- border: 2px solid var(--md-sys-color-outline);
- border-radius: 4px;
- display: flex;
- align-items: center;
- justify-content: center;
- transition: all 0.2s;
-}
-
-.app-checkbox:checked + .app-checkbox-custom {
- background-color: var(--md-sys-color-primary);
- border-color: var(--md-sys-color-primary);
-}
-
-.app-checkbox.unsaved:checked + .app-checkbox-custom {
- background-color: #4caf50;
- border-color: #4caf50;
-}
-
-.app-checkbox:checked + .app-checkbox-custom::after {
- content: '';
- width: 5px;
- height: 10px;
- border: solid var(--md-sys-color-on-primary);
- border-width: 0 2px 2px 0;
- transform: rotate(45deg);
- margin-bottom: 2px;
-}
-
-.app-info {
- display: flex;
- flex-direction: column;
- flex: 1;
- overflow: hidden;
-}
-
-.app-name {
- font-size: 1rem;
- font-weight: 500;
- color: var(--md-sys-color-on-surface);
- white-space: nowrap;
- overflow: hidden;
- text-overflow: ellipsis;
-}
-
-.app-pkg {
- font-size: 0.8125rem;
- color: var(--md-sys-color-on-surface-variant);
- font-family: 'Geist Mono', monospace;
- display: flex;
- flex-wrap: wrap;
- align-items: center;
- gap: 6px;
- word-break: break-all;
- line-height: 1.4;
-}
-
-.app-badge {
- background-color: var(--md-sys-color-primary-container);
- color: var(--md-sys-color-on-primary-container);
- padding: 0 4px;
- border-radius: 4px;
- font-size: 0.65rem;
- font-weight: bold;
-}
-
-.app-icon {
- width: 40px;
- height: 40px;
- border-radius: 8px;
- object-fit: cover;
- flex-shrink: 0;
- box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
-}
-
-.app-icon-fallback {
- width: 40px;
- height: 40px;
- border-radius: 8px;
- 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;
- justify-content: center;
- font-size: 1.25rem;
- font-weight: bold;
- flex-shrink: 0;
- box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
-}
-
-.app-uid {
- font-size: 0.65rem;
- color: var(--md-sys-color-on-surface-variant);
- background-color: var(--md-sys-color-surface-container-high);
- border: 1px solid var(--md-sys-color-outline-variant);
- padding: 0 4px;
- border-radius: 4px;
- font-family: 'Geist Mono', monospace;
- margin-left: 6px;
- vertical-align: middle;
-}
-
-/* 部分选中状态(有活动条目但包未完全选中)*/
-.app-checkbox-custom.partial {
- background-color: var(--md-sys-color-primary-container);
- border-color: var(--md-sys-color-primary);
-}
-
-.app-checkbox-custom.partial::after {
- content: '';
- display: block;
- width: 8px;
- height: 8px;
- background-color: var(--md-sys-color-primary);
- border-radius: 1px;
-}
-
-/* 活动列表展开箭头 */
-.app-activities-chevron {
- flex-shrink: 0;
- display: flex;
- align-items: center;
- justify-content: center;
- width: 28px;
- height: 28px;
- background: none;
- border: none;
- border-radius: var(--border-radius-s);
- color: var(--md-sys-color-on-surface-variant);
- cursor: pointer;
- transition:
- transform 0.2s,
- background-color 0.2s;
- padding: 0;
-}
-
-.app-activities-chevron:hover {
- background-color: var(--md-sys-color-surface-container);
-}
-
-.app-activities-chevron.expanded {
- transform: rotate(180deg);
-}
-
-/* 活动列表容器 */
-.app-activities-list {
- display: none;
- flex-direction: column;
- padding: 0 var(--spacing-m) var(--spacing-s);
- border-top: 1px solid var(--md-sys-color-outline-variant);
- gap: 2px;
-}
-
-.app-activities-list.show {
- display: flex;
-}
-
-/* 单条活动条目 */
-.activity-entry-item {
- display: flex;
- align-items: center;
- gap: 8px;
- padding: 5px 4px;
- border-radius: var(--border-radius-s);
-}
-
-.activity-entry-path {
- flex: 1;
- font-family: 'Geist Mono', 'Roboto Mono', monospace;
- font-size: 0.75rem;
- color: var(--md-sys-color-on-surface-variant);
- word-break: break-all;
- line-height: 1.4;
-}
-
-.activity-entry-delete {
- flex-shrink: 0;
- display: flex;
- align-items: center;
- justify-content: center;
- width: 24px;
- height: 24px;
- background: none;
- border: none;
- border-radius: 50%;
- color: var(--md-sys-color-error);
- cursor: pointer;
- padding: 0;
- transition: background-color 0.2s;
-}
-
-.activity-entry-delete:hover {
- background-color: var(--md-sys-color-error-container);
-}
-
-/* 按活动屏蔽输入卡片 */
-.activity-block-card {
- background-color: var(--md-sys-color-surface-container-high);
- border-radius: var(--border-radius-m);
- padding: var(--spacing-s) var(--spacing-m);
- margin-bottom: var(--spacing-m);
- display: flex;
- flex-direction: column;
- gap: 8px;
-}
-
-.activity-block-header {
- display: flex;
- align-items: center;
- justify-content: space-between;
-}
-
-.activity-block-label {
- font-size: 0.8125rem;
- font-weight: 500;
- color: var(--md-sys-color-on-surface);
-}
-
-.btn-picker-trigger {
- display: flex;
- align-items: center;
- gap: 4px;
- background: none;
- border: 1px solid var(--md-sys-color-outline-variant);
- border-radius: var(--border-radius-s);
- color: var(--md-sys-color-primary);
- font-size: 0.75rem;
- font-weight: 500;
- padding: 3px 8px;
- cursor: pointer;
- transition:
- background-color 0.2s,
- border-color 0.2s;
- white-space: nowrap;
- font-family: inherit;
-}
-
-.btn-picker-trigger:hover {
- background-color: var(--md-sys-color-primary-container);
- border-color: var(--md-sys-color-primary);
-}
-
-.activity-block-row {
- display: flex;
- gap: 8px;
- align-items: stretch;
-}
-
-.activity-block-input {
- flex: 1;
- background: var(--md-sys-color-surface-container);
- border: 1px solid var(--md-sys-color-outline-variant);
- border-radius: var(--border-radius-s);
- padding: 7px 10px;
- font-family: 'Geist Mono', 'Roboto Mono', monospace;
- font-size: 0.8125rem;
- color: var(--md-sys-color-on-surface);
- outline: none;
- transition:
- border-color 0.2s,
- box-shadow 0.2s;
-}
-
-.activity-block-input:focus {
- border-color: var(--md-sys-color-primary);
- box-shadow: 0 0 0 2px rgba(168, 199, 250, 0.3);
-}
-
-/* ========================
- 获取活动名向导覆盖层
- ======================== */
-.activity-picker-overlay {
- position: fixed;
- inset: 0;
- background: var(--md-sys-color-background);
- z-index: 950;
- display: flex;
- flex-direction: column;
- transform: translateX(100%);
- transition: transform 0.35s cubic-bezier(0.25, 1, 0.5, 1);
-}
-
-.activity-picker-overlay.show {
- transform: translateX(0);
-}
-
-.activity-picker-header {
- display: flex;
- align-items: center;
- gap: 12px;
- padding: calc(var(--safe-area-inset-top, 0px) + 16px) 16px 12px;
- border-bottom: 1px solid var(--md-sys-color-outline-variant);
- flex-shrink: 0;
-}
-
-.picker-back-btn {
- display: flex;
- align-items: center;
- justify-content: center;
- width: 36px;
- height: 36px;
- background: none;
- border: none;
- border-radius: 50%;
- color: var(--md-sys-color-on-surface);
- cursor: pointer;
- transition: background-color 0.2s;
- flex-shrink: 0;
-}
-
-.picker-back-btn:hover {
- background-color: var(--md-sys-color-surface-container);
-}
-
-.picker-title {
- font-size: 1.0625rem;
- font-weight: 600;
- color: var(--md-sys-color-on-surface);
-}
-
-.picker-steps-indicator {
- display: flex;
- justify-content: center;
- align-items: center;
- gap: 8px;
- padding: 16px 0 0;
- flex-shrink: 0;
-}
-
-.picker-step-dot {
- width: 6px;
- height: 6px;
- border-radius: 50%;
- background-color: var(--md-sys-color-outline-variant);
- transition:
- background-color 0.3s,
- transform 0.3s,
- width 0.3s;
-}
-
-.picker-step-dot.active {
- background-color: var(--md-sys-color-primary);
- transform: scale(1.2);
- width: 18px;
- border-radius: 4px;
-}
-
-.activity-picker-body {
- flex: 1;
- overflow-y: auto;
- display: flex;
- flex-direction: column;
-}
-
-.picker-step {
- flex: 1;
- display: flex;
- flex-direction: column;
- align-items: center;
- justify-content: center;
- padding: 32px 32px calc(var(--safe-area-inset-bottom, 0px) + 48px);
- text-align: center;
- gap: 14px;
-}
-
-.picker-step-icon {
- color: var(--md-sys-color-primary);
- opacity: 0.9;
- margin-bottom: 4px;
-}
-
-.picker-step-title {
- font-size: 1.25rem;
- font-weight: 600;
- color: var(--md-sys-color-on-background);
- margin: 0;
-}
-
-.picker-step-desc {
- font-size: 0.9375rem;
- color: var(--md-sys-color-on-surface-variant);
- line-height: 1.65;
- max-width: 300px;
- margin: 0;
-}
-
-.picker-action-btn {
- margin-top: 12px;
- padding: 12px 32px;
- border-radius: 24px;
- font-size: 0.9375rem;
-}
-
-.picker-status-text {
- display: inline-block;
- font-weight: 500;
- color: var(--md-sys-color-primary);
-}
-
-.picker-status-text.polling {
- animation: picker-pulse 1.2s ease-in-out infinite;
-}
-
-@keyframes picker-pulse {
- 0%,
- 100% {
- opacity: 1;
- }
- 50% {
- opacity: 0.35;
- }
-}
-
-.picker-result-box {
- background: var(--md-sys-color-surface-container-high);
- border: 1.5px solid var(--md-sys-color-primary);
- border-radius: var(--border-radius-m);
- padding: 14px 18px;
- font-family: 'Geist Mono', 'Roboto Mono', monospace;
- font-size: 0.875rem;
- color: var(--md-sys-color-on-surface);
- word-break: break-all;
- line-height: 1.55;
- max-width: 320px;
- width: 100%;
- text-align: left;
-}
-
-.picker-result-actions {
- display: flex;
- gap: 12px;
- margin-top: 4px;
-}
diff --git a/webui/src/apps.js b/webui/src/apps.js
deleted file mode 100644
index 5903129..0000000
--- a/webui/src/apps.js
+++ /dev/null
@@ -1,734 +0,0 @@
-// oxlint-disable no-unused-expressions
-import { listPackages, getPackagesInfo } from 'kernelsu'
-import { createIcons, Eye, EyeOff } from 'lucide'
-import PinyinMatch from 'pinyin-match'
-import { showToast, runCmd, readConfig, updateConfig } from './utils.js'
-
-let showingSystemApps = true
-let savedBlacklist = new Set()
-let activityEntries = new Set() // 活动级黑名单条目(格式:pkg/ActivityClass)
-
-export function updateUnsavedStyling() {
- const items = document.querySelectorAll('.app-list-item')
- items.forEach((item) => {
- const cb = item.querySelector('.app-checkbox')
- const custom = item.querySelector('.app-checkbox-custom')
- if (!cb || !custom) return
- const pkg = cb.dataset.pkg
- const hasActivities = pkg && [...activityEntries].some((e) => e.startsWith(pkg + '/'))
- // 部分选中:有活动条目但包名未完全选中
- if (!cb.checked && hasActivities) {
- custom.classList.add('partial')
- } else {
- custom.classList.remove('partial')
- }
- // 未保存高亮
- if (cb.checked && !savedBlacklist.has(pkg)) {
- cb.classList.add('unsaved')
- } else {
- cb.classList.remove('unsaved')
- }
- // 箭头可见性
- const chevron = item.querySelector('.app-activities-chevron')
- if (chevron) {
- chevron.style.display = hasActivities ? '' : 'none'
- if (!hasActivities) {
- const actList = item.querySelector('.app-activities-list')
- if (actList) {
- actList.classList.remove('show')
- chevron.classList.remove('expanded')
- }
- }
- }
- })
-}
-
-export function reorderDOMApps() {
- const container = document.getElementById('app-list-container')
- if (!container) return
- const items = Array.from(container.children)
- const getState = (item) => {
- const cb = item.querySelector('.app-checkbox')
- if (cb?.checked) return 2 // 完全选中
- const pkg = cb?.dataset.pkg
- if (pkg && [...activityEntries].some((e) => e.startsWith(pkg + '/'))) return 1 // 部分选中
- return 0
- }
- items.sort((a, b) => getState(b) - getState(a))
- items.forEach((item) => container.appendChild(item))
-}
-
-export function renderActivityList(pkg, container) {
- const entries = [...activityEntries].filter((e) => e.startsWith(pkg + '/'))
- container.innerHTML = ''
- entries.forEach((entry) => {
- const entryDiv = document.createElement('div')
- entryDiv.className = 'activity-entry-item'
- const actPath = document.createElement('span')
- actPath.className = 'activity-entry-path'
- actPath.textContent = entry.slice(pkg.length + 1)
- const delBtn = document.createElement('button')
- delBtn.className = 'activity-entry-delete'
- delBtn.innerHTML =
- '
'
- delBtn.addEventListener('click', (e) => {
- e.stopPropagation()
- activityEntries.delete(entry)
- renderActivityList(pkg, container)
- const actItem = container.closest('.app-list-item')
- if (actItem) {
- const chevron = actItem.querySelector('.app-activities-chevron')
- const remaining = [...activityEntries].filter((e) => e.startsWith(pkg + '/'))
- if (chevron) chevron.style.display = remaining.length > 0 ? '' : 'none'
- if (remaining.length === 0) {
- container.classList.remove('show')
- if (chevron) chevron.classList.remove('expanded')
- }
- }
- updateUnsavedStyling()
- reorderDOMApps()
- })
- entryDiv.appendChild(actPath)
- entryDiv.appendChild(delBtn)
- container.appendChild(entryDiv)
- })
-}
-
-export async function loadApps() {
- const container = document.getElementById('app-list-container')
- if (!container) return
- container.innerHTML =
- '
加载中...
'
-
- try {
- // 读取已保存的黑名单(从 JSON 配置读取)
- const cfg = await readConfig()
- const allSaved = Array.isArray(cfg.blacklist_apps) ? cfg.blacklist_apps : []
- savedBlacklist = new Set(allSaved)
- const savedPkgEntries = new Set(allSaved.filter((e) => !e.includes('/')))
- activityEntries = new Set(allSaved.filter((e) => e.includes('/')))
-
- let infoList = []
- try {
- const pkgs = await listPackages()
- if (pkgs && pkgs.length > 0) {
- infoList = await getPackagesInfo(pkgs)
- } else {
- throw new Error('No packages found')
- }
- } catch {
- // 模拟 150 个应用包数据用于调试
- 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) {
- infoList = infoList.filter((app) => !app.isSystem)
- }
-
- container.innerHTML = ''
-
- // 排序:非系统优先,按名称
- infoList.sort((a, b) => {
- if (a.isSystem !== b.isSystem) return a.isSystem ? 1 : -1
- return (a.appLabel || '').localeCompare(b.appLabel || '')
- })
-
- if (infoList.length === 0) {
- infoList.push(
- {
- packageName: 'com.example.app1',
- appLabel: '示例 1',
- isSystem: false,
- uid: 10123,
- },
- {
- packageName: 'com.example.app2',
- appLabel: '示例 2',
- isSystem: false,
- uid: 10124,
- },
- {
- packageName: 'com.example.sys1',
- appLabel: '系统示例 1',
- isSystem: true,
- uid: 1000,
- },
- {
- packageName: 'com.example.sys2',
- appLabel: '系统示例 2',
- isSystem: true,
- uid: 1001,
- },
- )
- if (!showingSystemApps) {
- infoList = infoList.filter((app) => !app.isSystem)
- }
- }
-
- // uid 去重
- const seenUids = new Set()
- infoList = infoList.filter((app) => {
- if (app.uid === undefined || app.uid === null) return true
- if (seenUids.has(app.uid)) return false
- seenUids.add(app.uid)
- return true
- })
-
- infoList.forEach((app) => {
- const item = document.createElement('div')
- item.className = 'app-list-item'
-
- const checkboxLabel = document.createElement('label')
- checkboxLabel.className = 'app-checkbox-label'
-
- const checkbox = document.createElement('input')
- checkbox.type = 'checkbox'
- checkbox.className = 'app-checkbox'
- checkbox.dataset.pkg = app.packageName
-
- // 依据已保存包名条目勾选(不含活动条目)
- checkbox.checked = savedPkgEntries.has(app.packageName)
- checkbox.addEventListener('change', () => {
- updateUnsavedStyling()
- reorderDOMApps()
- })
-
- const customCheckbox = document.createElement('span')
- customCheckbox.className = 'app-checkbox-custom'
- checkboxLabel.appendChild(checkbox)
- checkboxLabel.appendChild(customCheckbox)
-
- const infoDiv = document.createElement('div')
- infoDiv.className = 'app-info'
-
- const nameSpan = document.createElement('span')
- nameSpan.className = 'app-name'
- nameSpan.appendChild(document.createTextNode(app.appLabel || 'Unknown'))
-
- if (app.uid !== undefined) {
- const uidBadge = document.createElement('span')
- uidBadge.className = 'app-uid'
- uidBadge.textContent = String(app.uid)
- nameSpan.appendChild(uidBadge)
- }
-
- const pkgSpan = document.createElement('span')
- pkgSpan.className = 'app-pkg'
- pkgSpan.textContent = app.packageName || ''
-
- if (app.isSystem) {
- const sysBadge = document.createElement('span')
- sysBadge.className = 'app-badge'
- sysBadge.textContent = '系统'
- pkgSpan.appendChild(sysBadge)
- }
-
- infoDiv.appendChild(nameSpan)
- infoDiv.appendChild(pkgSpan)
-
- // 活动展开箭头
- const chevronBtn = document.createElement('button')
- chevronBtn.className = 'app-activities-chevron'
- chevronBtn.innerHTML =
- '
'
- const pkgActivities = [...activityEntries].filter((e) => e.startsWith(app.packageName + '/'))
- chevronBtn.style.display = pkgActivities.length > 0 ? '' : 'none'
-
- const mainRow = document.createElement('div')
- mainRow.className = 'app-item-main-row'
- mainRow.appendChild(checkboxLabel)
- mainRow.appendChild(infoDiv)
- mainRow.appendChild(chevronBtn)
-
- // 活动列表(初始折叠)
- const actListDiv = document.createElement('div')
- actListDiv.className = 'app-activities-list'
- actListDiv.dataset.pkg = app.packageName
- renderActivityList(app.packageName, actListDiv)
-
- chevronBtn.addEventListener('click', (e) => {
- e.stopPropagation()
- actListDiv.classList.toggle('show')
- chevronBtn.classList.toggle('expanded')
- })
-
- item.appendChild(mainRow)
- item.appendChild(actListDiv)
- container.appendChild(item)
- })
-
- updateUnsavedStyling()
- reorderDOMApps()
-
- const badge = document.getElementById('app-count-badge')
- if (badge) badge.textContent = infoList.length
-
- if (infoList.length === 0) {
- container.innerHTML =
- '
无应用
'
- }
- } catch (e) {
- container.innerHTML = `
加载失败: ${e.message || String(e)}
`
- }
-}
-
-export function setupAppsEvents() {
- // 下拉菜单控制
- const btnAppsMenu = document.getElementById('btn-apps-menu')
- const appsDropdownMenu = document.getElementById('apps-dropdown-menu')
-
- if (btnAppsMenu && appsDropdownMenu) {
- btnAppsMenu.addEventListener('click', (e) => {
- e.stopPropagation()
- appsDropdownMenu.classList.toggle('show')
- })
- document.addEventListener('click', (e) => {
- if (!btnAppsMenu.contains(e.target) && !appsDropdownMenu.contains(e.target)) {
- appsDropdownMenu.classList.remove('show')
- }
- })
- }
-
- // 切换系统应用显示
- const btnToggleSysApps = document.getElementById('btn-toggle-sys-apps')
- if (btnToggleSysApps) {
- btnToggleSysApps.addEventListener('click', () => {
- showingSystemApps = !showingSystemApps
-
- const textSpan = document.getElementById('sys-apps-text')
- const iconWrap = document.getElementById('sys-apps-icon')
-
- if (textSpan) textSpan.textContent = showingSystemApps ? '隐藏系统应用' : '显示系统应用'
-
- if (iconWrap) {
- const p = iconWrap.parentNode
- const newIcon = document.createElement('i')
- newIcon.setAttribute('data-lucide', showingSystemApps ? 'eye-off' : 'eye')
- newIcon.id = 'sys-apps-icon'
- p.replaceChild(newIcon, iconWrap)
- createIcons({ icons: { Eye, EyeOff }, nameAttr: 'data-lucide' })
- }
-
- loadApps()
- appsDropdownMenu && appsDropdownMenu.classList.remove('show')
- })
- }
-
- // 智能选择
- const btnSmartSelect = document.getElementById('btn-smart-select')
- if (btnSmartSelect) {
- const smartKeywords = [
- '相册',
- '抖音',
- '快手',
- '视频',
- '哔哩哔哩',
- 'bili',
- 'pili',
- 'netflix',
- 'youtube',
- 'tiktok',
- 'x',
- ]
- btnSmartSelect.addEventListener('click', () => {
- const items = document.querySelectorAll('.app-list-item')
- items.forEach((item) => {
- const name = item.querySelector('.app-name').textContent.toLowerCase()
- const checkbox = item.querySelector('.app-checkbox')
- let match = false
- for (const kw of smartKeywords) {
- if (kw === 'x') {
- if (name === 'x' || name === 'x (twitter)') {
- match = true
- break
- }
- } else if (name.includes(kw)) {
- match = true
- break
- }
- }
- if (match) checkbox.checked = true
- })
- updateUnsavedStyling()
- reorderDOMApps()
- appsDropdownMenu && appsDropdownMenu.classList.remove('show')
- })
- }
-
- // 手动添加包名
- const btnManualAdd = document.getElementById('btn-manual-add')
- if (btnManualAdd) {
- btnManualAdd.addEventListener('click', async () => {
- appsDropdownMenu && appsDropdownMenu.classList.remove('show')
- const pkg = prompt('请输入你要彻底屏蔽的完整应用包名(例如: com.example.app):')
- if (!pkg || !pkg.trim()) return
-
- const realPkg = pkg.trim()
- const existing = document.querySelector(`.app-checkbox[data-pkg="${realPkg}"]`)
- if (existing) {
- existing.checked = true
- updateUnsavedStyling()
- reorderDOMApps()
- showToast('该应用已在列表中,已为你自动勾选并置顶')
- return
- }
-
- showToast('正在尝试获取应用信息...')
- let appData = {
- packageName: realPkg,
- appLabel: '未知 (手动添加)',
- isSystem: false,
- uid: '自定义',
- }
- try {
- const info = await getPackagesInfo([realPkg])
- if (info && info.length > 0) appData = info[0]
- } catch {
- /* ignore */
- }
-
- const container = document.getElementById('app-list-container')
- const item = document.createElement('div')
- item.className = 'app-list-item'
-
- const checkboxLabel = document.createElement('label')
- checkboxLabel.className = 'app-checkbox-label'
-
- const checkbox = document.createElement('input')
- checkbox.type = 'checkbox'
- checkbox.className = 'app-checkbox'
- checkbox.dataset.pkg = realPkg
- checkbox.checked = true
- checkbox.addEventListener('change', () => {
- updateUnsavedStyling()
- reorderDOMApps()
- })
-
- const customCheckbox = document.createElement('span')
- customCheckbox.className = 'app-checkbox-custom'
- checkboxLabel.appendChild(checkbox)
- checkboxLabel.appendChild(customCheckbox)
-
- const infoDiv = document.createElement('div')
- infoDiv.className = 'app-info'
-
- const nameSpan = document.createElement('span')
- nameSpan.className = 'app-name'
- nameSpan.appendChild(document.createTextNode(appData.appLabel || 'Unknown'))
-
- if (appData.uid !== undefined) {
- const uidBadge = document.createElement('span')
- uidBadge.className = 'app-uid'
- uidBadge.textContent = String(appData.uid)
- nameSpan.appendChild(uidBadge)
- }
-
- const pkgSpan = document.createElement('span')
- pkgSpan.className = 'app-pkg'
- pkgSpan.textContent = realPkg
-
- if (appData.isSystem) {
- const sysBadge = document.createElement('span')
- sysBadge.className = 'app-badge'
- sysBadge.textContent = '系统'
- pkgSpan.appendChild(sysBadge)
- }
-
- infoDiv.appendChild(nameSpan)
- infoDiv.appendChild(pkgSpan)
-
- const chevronBtn = document.createElement('button')
- chevronBtn.className = 'app-activities-chevron'
- chevronBtn.innerHTML =
- '
'
- chevronBtn.style.display = 'none'
-
- const mainRow = document.createElement('div')
- mainRow.className = 'app-item-main-row'
- mainRow.appendChild(checkboxLabel)
- mainRow.appendChild(infoDiv)
- mainRow.appendChild(chevronBtn)
-
- const actListDiv = document.createElement('div')
- actListDiv.className = 'app-activities-list'
- actListDiv.dataset.pkg = realPkg
-
- chevronBtn.addEventListener('click', (e) => {
- e.stopPropagation()
- actListDiv.classList.toggle('show')
- chevronBtn.classList.toggle('expanded')
- })
-
- item.appendChild(mainRow)
- item.appendChild(actListDiv)
- container.appendChild(item)
-
- updateUnsavedStyling()
- reorderDOMApps()
- showToast('已成功添加并勾选')
- })
- }
-
- // 全选
- const btnSelectAll = document.getElementById('btn-select-all')
- if (btnSelectAll) {
- btnSelectAll.addEventListener('click', () => {
- document.querySelectorAll('.app-checkbox').forEach((cb) => {
- cb.checked = true
- })
- updateUnsavedStyling()
- appsDropdownMenu && appsDropdownMenu.classList.remove('show')
- })
- }
-
- // 全不选
- const btnSelectNone = document.getElementById('btn-select-none')
- if (btnSelectNone) {
- btnSelectNone.addEventListener('click', () => {
- document.querySelectorAll('.app-checkbox').forEach((cb) => {
- cb.checked = false
- })
- updateUnsavedStyling()
- appsDropdownMenu && appsDropdownMenu.classList.remove('show')
- })
- }
-
- // 反选
- const btnInvertSelection = document.getElementById('btn-invert-selection')
- if (btnInvertSelection) {
- btnInvertSelection.addEventListener('click', () => {
- document.querySelectorAll('.app-checkbox').forEach((cb) => {
- cb.checked = !cb.checked
- })
- updateUnsavedStyling()
- appsDropdownMenu && appsDropdownMenu.classList.remove('show')
- })
- }
-
- // 刷新(重排)
- const btnAppsRefresh = document.getElementById('btn-apps-refresh')
- if (btnAppsRefresh) {
- btnAppsRefresh.addEventListener('click', () => {
- reorderDOMApps()
- })
- }
-
- // 保存黑名单
- const btnSaveBlacklist = document.getElementById('btn-save-blacklist')
- if (btnSaveBlacklist) {
- btnSaveBlacklist.addEventListener('click', async () => {
- showToast('保存中...')
- const selectedPkgs = []
- document.querySelectorAll('.app-checkbox').forEach((cb) => {
- if (cb.checked) selectedPkgs.push(cb.dataset.pkg)
- })
- const allEntries = [...selectedPkgs, ...activityEntries]
- const res = await updateConfig({ blacklist_apps: allEntries })
- if (res.errno === 0 || res.stdout?.includes('OK')) {
- showToast('黑名单保存成功')
- savedBlacklist = new Set(allEntries)
- updateUnsavedStyling()
- reorderDOMApps()
- } else {
- showToast('保存失败: ' + res.stderr)
- }
- })
- }
-
- // 按活动屏蔽
- const btnAddActivity = document.getElementById('btn-add-activity')
- const inputActivityEntry = document.getElementById('input-activity-entry')
- if (btnAddActivity && inputActivityEntry) {
- const doAddActivity = () => {
- const val = inputActivityEntry.value.trim()
- if (!val) return
- const parts = val.split('/')
- if (parts.length !== 2 || !parts[0] || !parts[1]) {
- showToast('格式错误,请输入 包名/完整活动类名')
- return
- }
- activityEntries.add(val)
- inputActivityEntry.value = ''
- const pkg = parts[0]
- document.querySelectorAll('.app-list-item').forEach((appItem) => {
- const cb = appItem.querySelector('.app-checkbox')
- if (cb && cb.dataset.pkg === pkg) {
- const actList = appItem.querySelector('.app-activities-list')
- const chevron = appItem.querySelector('.app-activities-chevron')
- if (actList) {
- renderActivityList(pkg, actList)
- actList.classList.add('show')
- }
- if (chevron) {
- chevron.style.display = ''
- chevron.classList.add('expanded')
- }
- }
- })
- updateUnsavedStyling()
- reorderDOMApps()
- showToast(`已添加: ${val}`)
- }
- btnAddActivity.addEventListener('click', doAddActivity)
- inputActivityEntry.addEventListener('keydown', (e) => {
- if (e.key === 'Enter') doAddActivity()
- })
- }
-
- // 搜索
- const inputAppSearch = document.getElementById('input-app-search')
- if (inputAppSearch) {
- inputAppSearch.addEventListener('input', (e) => {
- const keyword = e.target.value.trim().toLowerCase()
- const items = document.querySelectorAll('.app-list-item')
- let visibleCount = 0
- items.forEach((item) => {
- const name = item.querySelector('.app-name').textContent
- const pkg = item.querySelector('.app-pkg').textContent.toLowerCase()
- if (!keyword || pkg.includes(keyword) || PinyinMatch.match(name, keyword)) {
- item.style.display = 'flex'
- visibleCount++
- } else {
- item.style.display = 'none'
- }
- })
- const badge = document.getElementById('app-count-badge')
- if (badge) badge.textContent = visibleCount
- })
- }
-
- setupActivityPicker()
-}
-
-function setupActivityPicker() {
- const overlay = document.getElementById('activity-picker-overlay')
- if (!overlay) return
-
- const btnPickActivity = document.getElementById('btn-pick-activity')
- const btnPickerBack = document.getElementById('btn-picker-back')
- const step1 = document.getElementById('picker-step-1')
- const step2 = document.getElementById('picker-step-2')
- const step3 = document.getElementById('picker-step-3')
- const dots = [
- document.getElementById('picker-dot-1'),
- document.getElementById('picker-dot-2'),
- document.getElementById('picker-dot-3'),
- ]
- const btnStep1Next = document.getElementById('btn-picker-step1-next')
- const btnPickerStart = document.getElementById('btn-picker-start')
- const btnPickerRetry = document.getElementById('btn-picker-retry')
- const btnPickerConfirm = document.getElementById('btn-picker-confirm')
- const pickerStatusText = document.getElementById('picker-status-text')
- const pickerResultText = document.getElementById('picker-result-text')
-
- let pollingTimer = null
- let detectedActivity = null
-
- function showStep(n) {
- ;[step1, step2, step3].forEach((s, i) => {
- if (s) s.style.display = i + 1 === n ? 'flex' : 'none'
- })
- dots.forEach((d, i) => {
- d?.classList.toggle('active', i + 1 === n)
- })
- }
-
- function stopPolling() {
- if (pollingTimer) {
- clearInterval(pollingTimer)
- pollingTimer = null
- }
- }
-
- function openPicker() {
- stopPolling()
- detectedActivity = null
- if (btnPickerStart) btnPickerStart.disabled = false
- if (pickerStatusText) {
- pickerStatusText.textContent = '等待中...'
- pickerStatusText.classList.remove('polling')
- }
- showStep(1)
- overlay.classList.add('show')
- }
-
- function closePicker() {
- stopPolling()
- overlay.classList.remove('show')
- }
-
- btnPickActivity?.addEventListener('click', openPicker)
- btnPickerBack?.addEventListener('click', closePicker)
- btnStep1Next?.addEventListener('click', () => showStep(2))
-
- btnPickerStart?.addEventListener('click', () => {
- btnPickerStart.disabled = true
- if (pickerStatusText) {
- pickerStatusText.textContent = '检测中,请切换到目标界面...'
- pickerStatusText.classList.add('polling')
- }
- 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()
- // 空值或仍在 WebUI 内则继续等待
- if (!activity || activity.toLowerCase().includes('webui')) return
- stopPolling()
- detectedActivity = activity
- if (pickerStatusText) pickerStatusText.classList.remove('polling')
- if (pickerResultText) pickerResultText.textContent = activity
- if (btnPickerStart) btnPickerStart.disabled = false
- showStep(3)
- } catch {
- /* 忽略,继续轮询 */
- }
- }, 600)
- })
-
- btnPickerRetry?.addEventListener('click', () => {
- stopPolling()
- detectedActivity = null
- if (btnPickerStart) btnPickerStart.disabled = false
- if (pickerStatusText) {
- pickerStatusText.textContent = '等待中...'
- pickerStatusText.classList.remove('polling')
- }
- showStep(2)
- })
-
- btnPickerConfirm?.addEventListener('click', () => {
- if (!detectedActivity) return
- activityEntries.add(detectedActivity)
- const pkg = detectedActivity.split('/')[0]
- document.querySelectorAll('.app-list-item').forEach((appItem) => {
- const cb = appItem.querySelector('.app-checkbox')
- if (cb && cb.dataset.pkg === pkg) {
- const actList = appItem.querySelector('.app-activities-list')
- const chevron = appItem.querySelector('.app-activities-chevron')
- if (actList) {
- renderActivityList(pkg, actList)
- actList.classList.add('show')
- }
- if (chevron) {
- chevron.style.display = ''
- chevron.classList.add('expanded')
- }
- }
- })
- updateUnsavedStyling()
- reorderDOMApps()
- showToast(`已添加: ${detectedActivity}`)
- closePicker()
- })
-}
diff --git a/webui/src/components.css b/webui/src/components.css
deleted file mode 100644
index 26af26f..0000000
--- a/webui/src/components.css
+++ /dev/null
@@ -1,663 +0,0 @@
-/* Cards */
-.card {
- 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);
- display: flex;
- flex-direction: column;
-}
-
-/* Collapsible card header */
-.card-header-toggle {
- cursor: pointer;
- user-select: none;
- -webkit-user-select: none;
- border-radius: var(--border-radius-s);
- transition: background-color 0.15s;
- margin: calc(-1 * var(--spacing-l));
- padding: var(--spacing-l);
-}
-.card-header-toggle:active {
- background-color: rgba(var(--md-sys-color-primary-rgb), 0.06);
-}
-.collapse-chevron {
- color: var(--md-sys-color-on-surface-variant);
- transition: transform 0.3s cubic-bezier(0.25, 1, 0.5, 1);
- flex-shrink: 0;
-}
-.collapse-chevron.open {
- transform: rotate(180deg);
-}
-
-/* grid-template-rows collapse animation */
-.collapsible-body {
- display: grid;
- grid-template-rows: 0fr;
- transition: grid-template-rows 0.35s cubic-bezier(0.25, 1, 0.5, 1);
-}
-.collapsible-body.open {
- grid-template-rows: 1fr;
-}
-.collapsible-body > div {
- overflow: hidden;
- padding-top: 0;
- transition: padding-top 0.35s cubic-bezier(0.25, 1, 0.5, 1);
-}
-.collapsible-body.open > div {
- padding-top: var(--spacing-l);
- overflow: visible;
-}
-
-/* Page Transitions */
-.card-animate-in {
- animation: cardFadeIn 0.4s cubic-bezier(0.2, 0, 0, 1) forwards;
-}
-
-.navbar-slider {
- left: 0;
-}
-
-@keyframes cardFadeIn {
- from {
- opacity: 0;
- transform: translateY(12px) scale(0.985);
- }
- to {
- opacity: 1;
- transform: translateY(0) scale(1);
- }
-}
-
-#log-section {
- flex: 1;
- min-height: calc(100vh - 220px);
-}
-
-.card-header {
- display: flex;
- align-items: center;
- gap: var(--spacing-s);
-}
-
-.card-header h2 {
- margin: 0;
- font-size: 1.125rem;
- font-weight: 500;
- color: var(--md-sys-color-on-surface);
- flex-grow: 1;
-}
-
-/* Config Items */
-.config-group {
- margin-top: 12px;
- margin-bottom: 0;
- padding: 12px;
- background-color: var(--md-sys-color-surface-container);
- border-radius: var(--border-radius-m);
- border: 1px solid rgba(var(--md-sys-color-on-surface-rgb, 0, 0, 0), 0.05);
-}
-
-.group-title {
- margin: 0 0 10px 0;
- color: var(--md-sys-color-primary);
- font-size: 0.875rem;
- font-weight: 600;
- display: flex;
- align-items: center;
- gap: 8px;
-}
-
-.group-title i,
-.group-title svg {
- width: 16px;
- height: 16px;
-}
-
-.config-item {
- display: flex;
- justify-content: space-between;
- align-items: center;
- padding: 4px 0;
-}
-
-#advanced-section .config-item {
- flex-direction: column;
- align-items: flex-start;
- gap: 12px;
- width: 100%;
-}
-
-#advanced-section .config-value {
- width: 100%;
-}
-
-.config-item + .config-item {
- margin-top: 10px;
- border-top: 1px solid rgba(var(--md-sys-color-outline-variant-rgb, 142, 144, 153), 0.1);
- padding-top: 10px;
-}
-
-.config-label {
- display: flex;
- flex-direction: column;
-}
-
-.config-name {
- font-size: 1rem;
- color: var(--md-sys-color-on-surface);
-}
-
-.config-desc {
- font-size: 0.875rem;
- color: var(--md-sys-color-on-surface-variant);
-}
-
-.config-input {
- width: 100px;
- padding: 8px 12px;
- background-color: var(--md-sys-color-surface-container-high);
- border: 1px solid var(--md-sys-color-outline-variant);
- border-radius: var(--border-radius-s);
- color: var(--md-sys-color-on-surface);
- font-size: 1rem;
- font-family: inherit;
- text-align: right;
- outline: none;
- transition: all 0.2s ease;
-}
-
-.config-input:focus {
- border-color: var(--md-sys-color-primary);
- box-shadow: 0 0 0 2px rgba(var(--md-sys-color-primary-rgb), 0.2);
- background-color: var(--md-sys-color-surface);
-}
-
-.config-select {
- padding: 8px 12px;
- background-color: var(--md-sys-color-surface-container-high);
- border: 1px solid var(--md-sys-color-outline-variant);
- border-radius: var(--border-radius-s);
- color: var(--md-sys-color-on-surface);
- font-size: 1rem;
- font-family: inherit;
- outline: none;
- cursor: pointer;
- transition: all 0.2s ease;
-}
-
-.config-select:focus {
- border-color: var(--md-sys-color-primary);
- box-shadow: 0 0 0 2px rgba(var(--md-sys-color-primary-rgb), 0.2);
- background-color: var(--md-sys-color-surface);
-}
-
-#advanced-section .config-input {
- width: 100%;
- text-align: left;
-}
-
-.config-textarea {
- background-color: var(--md-sys-color-surface-container-high);
- width: 100%;
- min-height: 60px;
- max-height: 300px;
- color: var(--md-sys-color-on-surface);
- border: 1px solid var(--md-sys-color-outline-variant);
- border-radius: var(--border-radius-m);
- resize: vertical;
- padding: 10px 14px;
- font-family: 'Geist Mono', system-ui, monospace;
- font-size: 0.875rem;
- line-height: 1.4;
- transition: all 0.2s ease;
- outline: none;
-}
-
-.config-textarea:focus {
- border-color: var(--md-sys-color-primary);
- box-shadow: 0 0 0 2px rgba(var(--md-sys-color-primary-rgb), 0.2);
- background-color: var(--md-sys-color-surface);
-}
-
-.config-input-wide {
- width: 140px;
-}
-
-.config-item-expand {
- display: flex;
- justify-content: flex-end;
- margin-top: var(--spacing-s);
- max-height: 0;
- overflow: hidden;
- opacity: 0;
- transition: all 0.3s ease;
-}
-
-.config-item-expand.show {
- max-height: 100px; /* 调整为适合内容的高度 */
- opacity: 1;
- margin-bottom: var(--spacing-m);
-}
-
-/* Custom Time Picker Styles */
-.custom-time-picker {
- display: flex;
- align-items: center;
- gap: 8px;
-}
-
-.time-unit {
- display: flex;
- align-items: center;
- gap: 2px;
- background-color: var(--md-sys-color-surface-container-high);
- padding: 2px 6px;
- border-radius: var(--border-radius-s);
- border: 1px solid var(--md-sys-color-outline);
-}
-
-.time-input {
- width: 32px;
- background-color: transparent;
- color: var(--md-sys-color-on-surface);
- border: none;
- font-size: 0.875rem;
- text-align: center;
- font-family: 'Geist Mono', monospace;
- outline: none;
- -moz-appearance: textfield;
-}
-
-.time-input-wide {
- width: 48px;
-}
-
-.time-input::-webkit-outer-spin-button,
-.time-input::-webkit-inner-spin-button {
- -webkit-appearance: none;
- margin: 0;
-}
-
-.time-sep {
- color: var(--md-sys-color-on-surface-variant);
- font-size: 0.875rem;
-}
-
-/* Switch Styles */
-.switch {
- position: relative;
- display: inline-block;
- width: 52px;
- height: 32px;
-}
-
-.switch input {
- opacity: 0;
- width: 0;
- height: 0;
-}
-
-.slider {
- position: absolute;
- cursor: pointer;
- top: 0;
- left: 0;
- right: 0;
- bottom: 0;
- background-color: var(--md-sys-color-surface-container-high);
- transition: 0.4s;
- border-radius: 34px;
- border: 2px solid var(--md-sys-color-outline);
-}
-
-.slider:before {
- position: absolute;
- content: '';
- height: 24px;
- width: 24px;
- left: 2px;
- bottom: 2px;
- background-color: var(--md-sys-color-outline);
- transition: 0.4s;
- border-radius: 50%;
-}
-
-input:checked + .slider {
- background-color: var(--md-sys-color-primary-container);
- border-color: var(--md-sys-color-primary);
-}
-
-input:checked + .slider:before {
- transform: translateX(20px);
- background-color: var(--md-sys-color-primary);
-}
-
-/* Status Grid */
-.status-grid {
- display: grid;
- grid-template-columns: 1fr 1fr;
- gap: var(--spacing-m);
- margin-top: var(--spacing-m);
-}
-
-.status-item {
- background-color: var(--md-sys-color-surface-container);
- padding: var(--spacing-m);
- border-radius: var(--border-radius-m);
- display: flex;
- flex-direction: column;
- gap: 8px;
- border: 1px solid rgba(var(--md-sys-color-on-surface-rgb, 0, 0, 0), 0.04);
- transition: transform 0.2s ease;
-}
-
-.status-item:active {
- transform: scale(0.98);
-}
-
-.status-item-header {
- display: flex;
- align-items: center;
- gap: 6px;
- color: var(--md-sys-color-on-surface-variant);
-}
-
-.status-item-header svg {
- width: 14px;
- height: 14px;
- opacity: 0.7;
-}
-
-.status-label {
- font-size: 0.75rem;
- font-weight: 500;
-}
-
-.status-value {
- font-size: 1.125rem;
- font-weight: 600;
- color: var(--md-sys-color-primary);
- word-break: break-all;
-}
-
-/* Brightness Section */
-.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%
- );
- border-radius: var(--border-radius-m);
- border: 1px solid var(--md-sys-color-outline-variant);
-}
-
-.brightness-header {
- display: flex;
- justify-content: space-between;
- align-items: center;
- margin-bottom: var(--spacing-m);
-}
-
-.brightness-title {
- font-size: 1rem;
- font-weight: 600;
- color: var(--md-sys-color-on-surface);
- letter-spacing: 0.5px;
-}
-
-.brightness-percent {
- font-size: 1.25rem;
- font-weight: 700;
- color: var(--md-sys-color-primary);
- min-width: 50px;
- text-align: right;
-}
-
-/* Brightness Slider Container */
-.brightness-container {
- position: relative;
- display: flex;
- align-items: center;
- gap: 8px;
- margin-bottom: var(--spacing-m);
- padding: var(--spacing-s) 0;
-}
-
-.brightness-label {
- font-size: 0.75rem;
- color: var(--md-sys-color-on-surface-variant);
- min-width: 24px;
- text-align: center;
- font-weight: 500;
-}
-
-/* Brightness Slider (Progress Bar Style) */
-.brightness-slider {
- flex: 1;
- height: 24px;
- border-radius: 12px;
- /* 背景将由 JS 通过 linear-gradient 动态更新实现进度条效果 */
- background: var(--md-sys-color-surface-container-high);
- outline: none;
- -webkit-appearance: none;
- appearance: none;
- cursor: grab;
- transition:
- background 0.35s ease,
- height 0.2s,
- box-shadow 0.2s;
- border: 1px solid rgba(255, 255, 255, 0.03);
- box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.2);
- overflow: hidden; /* 确保进度条颜色不溢出圆角 */
-}
-
-.brightness-slider:hover {
- height: 28px;
-}
-
-.brightness-slider:disabled {
- opacity: 0.5;
- cursor: not-allowed;
-}
-
-.brightness-slider:disabled:hover {
- height: 24px;
-}
-
-.brightness-slider::-webkit-slider-thumb {
- -webkit-appearance: none;
- appearance: none;
- width: 0;
- height: 0;
- background: transparent;
- cursor: grab;
- border: none;
-}
-
-.brightness-slider::-webkit-slider-thumb:active {
- cursor: grabbing;
-}
-
-.brightness-slider::-moz-range-thumb {
- width: 28px;
- height: 28px;
- border-radius: 50%;
- 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);
- 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);
- transform: scale(1.1);
-}
-
-.brightness-slider::-moz-range-thumb:active {
- cursor: grabbing;
- box-shadow: 0 0 0 10px rgba(168, 199, 250, 0.2);
-}
-
-.brightness-slider::-moz-range-track {
- background: transparent;
- border: none;
-}
-
-/* Actions */
-.save-badge {
- margin-left: auto;
- flex-shrink: 0;
- padding: 2px 10px;
- border-radius: 999px;
- font-size: 0.75rem;
- font-weight: 600;
- line-height: 1.5;
-}
-
-.save-badge.unsaved {
- color: var(--color-warning);
- background: color-mix(in srgb, var(--color-warning) 15%, transparent);
-}
-
-.save-badge.saved {
- color: #2f9e63;
- background: rgba(47, 158, 99, 0.14);
-}
-
-.card-actions {
- display: flex;
- justify-content: flex-end;
- gap: 12px;
- margin-top: 16px;
- padding-top: 12px;
- border-top: 1px solid var(--md-sys-color-outline-variant);
-}
-
-/* Buttons */
-.btn {
- display: inline-flex;
- align-items: center;
- justify-content: center;
- gap: 8px;
- padding: 10px 24px;
- border-radius: 100px;
- border: none;
- font-size: 0.875rem;
- font-weight: 500;
- font-family: inherit;
- cursor: pointer;
- transition:
- background-color 0.2s,
- opacity 0.2s;
-}
-
-.btn:active {
- opacity: 0.8;
-}
-
-.btn-primary {
- background-color: var(--md-sys-color-primary);
- color: var(--md-sys-color-on-primary);
-}
-
-.btn-outline {
- background-color: transparent;
- border: 1px solid var(--md-sys-color-outline);
- color: var(--md-sys-color-primary);
-}
-
-.btn-outline-s,
-.btn-text-s {
- background-color: transparent;
- border: 1px solid var(--md-sys-color-outline-variant);
- color: var(--md-sys-color-primary);
- padding: 4px 10px;
- min-width: 50px;
- height: 28px;
- font-size: 0.75rem;
- border-radius: var(--border-radius-s);
- cursor: pointer;
- display: inline-flex;
- align-items: center;
- justify-content: center;
- transition: all 0.2s;
- white-space: nowrap;
-}
-
-.btn-text-s:active {
- background-color: var(--md-sys-color-surface-container-high);
-}
-
-.btn-danger {
- background-color: var(--md-sys-color-error) !important;
- color: var(--md-sys-color-on-error) !important;
- border: none !important;
-}
-
-/* Header Actions container */
-.header-actions {
- display: flex;
- align-items: center;
- gap: 8px;
-}
-
-.btn-icon-only {
- background: transparent;
- border: none;
- color: var(--md-sys-color-on-surface-variant);
- font-size: 1.25rem;
- cursor: pointer;
- padding: 4px;
- border-radius: 50%;
- display: flex;
- align-items: center;
- justify-content: center;
-}
-
-.btn-icon-only-s {
- display: flex;
- align-items: center;
- justify-content: center;
- width: 32px;
- height: 32px;
- border-radius: 8px;
- border: none;
- background-color: var(--md-sys-color-surface-container-high);
- color: var(--md-sys-color-primary);
- cursor: pointer;
- transition: all 0.2s ease;
-}
-
-.btn-icon-only-s:active {
- background-color: var(--md-sys-color-primary-container);
- transform: scale(0.9);
-}
-
-.btn-icon-only-s i,
-.btn-icon-only-s svg {
- width: 16px;
- height: 16px;
-}
-
-.animate-spin {
- animation: spin 1s linear infinite;
-}
-
-@keyframes spin {
- from {
- transform: rotate(0deg);
- }
- to {
- transform: rotate(360deg);
- }
-}
diff --git a/webui/src/components/ActionMenu.vue b/webui/src/components/ActionMenu.vue
new file mode 100644
index 0000000..2dc8317
--- /dev/null
+++ b/webui/src/components/ActionMenu.vue
@@ -0,0 +1,40 @@
+
+
+
+
+
+
+
+
+ {{ item.label }}
+
+
+
diff --git a/webui/src/components/AppBottomNav.vue b/webui/src/components/AppBottomNav.vue
new file mode 100644
index 0000000..67fb7cc
--- /dev/null
+++ b/webui/src/components/AppBottomNav.vue
@@ -0,0 +1,31 @@
+
+
+
+
+
+
+
+
+
+
diff --git a/webui/src/components/AppSwitch.vue b/webui/src/components/AppSwitch.vue
new file mode 100644
index 0000000..d3c8a0c
--- /dev/null
+++ b/webui/src/components/AppSwitch.vue
@@ -0,0 +1,28 @@
+
+
+
+
+
+ {{ name }}
+ {{ support }}
+ {{ warning }}
+
+
+
+
+
+
diff --git a/webui/src/components/AppTextField.vue b/webui/src/components/AppTextField.vue
new file mode 100644
index 0000000..35a59e1
--- /dev/null
+++ b/webui/src/components/AppTextField.vue
@@ -0,0 +1,36 @@
+
+
+
+
+
diff --git a/webui/src/components/AppTopBar.vue b/webui/src/components/AppTopBar.vue
new file mode 100644
index 0000000..a980a77
--- /dev/null
+++ b/webui/src/components/AppTopBar.vue
@@ -0,0 +1,59 @@
+
+
+
+
+
diff --git a/webui/src/components/BottomNav.vue b/webui/src/components/BottomNav.vue
deleted file mode 100644
index 102dbc6..0000000
--- a/webui/src/components/BottomNav.vue
+++ /dev/null
@@ -1,143 +0,0 @@
-
-
-
-
-
diff --git a/webui/src/components/ConfirmDialog.vue b/webui/src/components/ConfirmDialog.vue
new file mode 100644
index 0000000..0b85872
--- /dev/null
+++ b/webui/src/components/ConfirmDialog.vue
@@ -0,0 +1,54 @@
+
+
+
+
+ {{ headline }}
+ {{ description }}
+
+ {{ cancelText }}
+
+ {{ confirmText }}
+
+
+
+
+
+
diff --git a/webui/src/components/OpLockBanner.vue b/webui/src/components/OpLockBanner.vue
new file mode 100644
index 0000000..251b2f7
--- /dev/null
+++ b/webui/src/components/OpLockBanner.vue
@@ -0,0 +1,17 @@
+
+
+
+
+
+
+ {{ label }},已暂停刷新
+ {{ seconds }}s
+
+
+
diff --git a/webui/src/components/PromptDialog.vue b/webui/src/components/PromptDialog.vue
new file mode 100644
index 0000000..d8dc531
--- /dev/null
+++ b/webui/src/components/PromptDialog.vue
@@ -0,0 +1,68 @@
+
+
+
+
+ {{ headline }}
+
+
+ {{ cancelText }}
+ {{ confirmText }}
+
+
+
+
+
diff --git a/webui/src/components/SnackbarHost.vue b/webui/src/components/SnackbarHost.vue
new file mode 100644
index 0000000..97fd6fc
--- /dev/null
+++ b/webui/src/components/SnackbarHost.vue
@@ -0,0 +1,15 @@
+
+
+
+
+
+
+ {{ message.text }}
+
+
+
+
diff --git a/webui/src/components/ui/Badge.vue b/webui/src/components/ui/Badge.vue
deleted file mode 100644
index c08a6b0..0000000
--- a/webui/src/components/ui/Badge.vue
+++ /dev/null
@@ -1,32 +0,0 @@
-
-
-
-
-
-
-
diff --git a/webui/src/components/ui/Button.vue b/webui/src/components/ui/Button.vue
deleted file mode 100644
index b0b5170..0000000
--- a/webui/src/components/ui/Button.vue
+++ /dev/null
@@ -1,53 +0,0 @@
-
-
-
-
-
-
-
diff --git a/webui/src/components/ui/Card.vue b/webui/src/components/ui/Card.vue
deleted file mode 100644
index 3e69509..0000000
--- a/webui/src/components/ui/Card.vue
+++ /dev/null
@@ -1,17 +0,0 @@
-
-
-
-
-
-
-
diff --git a/webui/src/components/ui/Input.vue b/webui/src/components/ui/Input.vue
deleted file mode 100644
index bb4aa74..0000000
--- a/webui/src/components/ui/Input.vue
+++ /dev/null
@@ -1,38 +0,0 @@
-
-
-
-
-
diff --git a/webui/src/components/ui/Label.vue b/webui/src/components/ui/Label.vue
deleted file mode 100644
index ce49f42..0000000
--- a/webui/src/components/ui/Label.vue
+++ /dev/null
@@ -1,22 +0,0 @@
-
-
-
-
-
diff --git a/webui/src/components/ui/Separator.vue b/webui/src/components/ui/Separator.vue
deleted file mode 100644
index ff4bb30..0000000
--- a/webui/src/components/ui/Separator.vue
+++ /dev/null
@@ -1,21 +0,0 @@
-
-
-
-
-
diff --git a/webui/src/components/ui/Switch.vue b/webui/src/components/ui/Switch.vue
deleted file mode 100644
index 091c64c..0000000
--- a/webui/src/components/ui/Switch.vue
+++ /dev/null
@@ -1,43 +0,0 @@
-
-
-
-
-
diff --git a/webui/src/components/ui/Textarea.vue b/webui/src/components/ui/Textarea.vue
deleted file mode 100644
index d16e7fc..0000000
--- a/webui/src/components/ui/Textarea.vue
+++ /dev/null
@@ -1,30 +0,0 @@
-
-
-
-
-
diff --git a/webui/src/composables/useApps.js b/webui/src/composables/useApps.js
index fa4a6b5..08d24df 100644
--- a/webui/src/composables/useApps.js
+++ b/webui/src/composables/useApps.js
@@ -1,8 +1,21 @@
-import { ref, reactive } from 'vue'
+import { ref, reactive, computed } from 'vue'
import { listPackages, getPackagesInfo } from 'kernelsu'
-import PinyinMatch from 'pinyin-match'
-import { readConfig, updateConfig } from '../utils.js'
+import { fetchConfig, patchConfig } from '../api/luminpro.js'
+/** 拼音匹配库体积较大,进入黑名单页后再按需加载 */
+let PinyinMatch = null
+const pinyinReady = ref(false)
+async function ensurePinyin() {
+ if (PinyinMatch || pinyinReady.value) return
+ try {
+ PinyinMatch = (await import('pinyin-match')).default
+ } catch {
+ PinyinMatch = null
+ }
+ pinyinReady.value = true
+}
+
+/** 黑名单管理:应用列表来自 KernelSU API,黑名单本身存在 config.json */
export function useApps() {
const apps = ref([])
const isLoading = ref(false)
@@ -12,13 +25,14 @@ export function useApps() {
const savedBlacklist = ref(new Set())
const activityEntries = ref(new Set())
- /** 每个 app 条目结构: { packageName, appLabel, isSystem, uid, checked, hasActivities } */
+ /** 条目结构: { packageName, appLabel, isSystem, uid, checked, expanded } */
async function load() {
isLoading.value = true
loadError.value = ''
+ ensurePinyin() // 后台加载拼音库,不阻塞列表
try {
- const cfg = await readConfig()
+ const cfg = await fetchConfig()
const allSaved = Array.isArray(cfg.blacklist_apps) ? cfg.blacklist_apps : []
savedBlacklist.value = new Set(allSaved)
const savedPkgSet = new Set(allSaved.filter((e) => !e.includes('/')))
@@ -30,7 +44,6 @@ export function useApps() {
if (pkgs && pkgs.length > 0) infoList = await getPackagesInfo(pkgs)
else throw new Error('no pkgs')
} catch {
- console.log('[DEBUG] 使用模拟数据')
infoList = Array.from({ length: 150 }, (_, i) => ({
packageName: `com.mock.app${i}`,
appLabel: i % 10 === 0 ? `测试应用 ${i} (含抖音关键字)` : `模拟应用 ${i}`,
@@ -64,8 +77,7 @@ export function useApps() {
expanded: false,
}),
)
-
- _reorder()
+ reorder()
} catch (e) {
loadError.value = e.message || String(e)
} finally {
@@ -73,7 +85,7 @@ export function useApps() {
}
}
- function _reorder() {
+ 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
@@ -82,7 +94,10 @@ export function useApps() {
}
function hasActivity(pkg) {
- return [...activityEntries.value].some((e) => e.startsWith(pkg + '/'))
+ for (const entry of activityEntries.value) {
+ if (entry.startsWith(pkg + '/')) return true
+ }
+ return false
}
function getActivities(pkg) {
@@ -91,53 +106,44 @@ export function useApps() {
function addActivity(entry) {
activityEntries.value.add(entry)
- _reorder()
+ reorder()
}
function removeActivity(entry) {
activityEntries.value.delete(entry)
- _reorder()
+ 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 })
- if (res.errno === 0) {
- savedBlacklist.value = new Set(allEntries)
- toast('黑名单保存成功')
- } else {
- toast('保存失败: ' + res.stderr)
+ async function save(snackbar) {
+ const selected = apps.value.filter((a) => a.checked).map((a) => a.packageName)
+ const all = [...selected, ...activityEntries.value]
+ try {
+ await patchConfig({ blacklist_apps: all })
+ savedBlacklist.value = new Set(all)
+ snackbar?.('黑名单已保存')
+ } catch (e) {
+ snackbar?.(`保存失败: ${e.message}`)
}
}
- function onCheckboxChange() {
- _reorder()
- }
-
function toggleSystemApps() {
showingSystemApps.value = !showingSystemApps.value
load()
}
function selectAll() {
- apps.value.forEach((a) => {
- a.checked = true
- })
- _reorder()
+ for (const app of apps.value) app.checked = true
+ reorder()
}
+
function selectNone() {
- apps.value.forEach((a) => {
- a.checked = false
- })
- _reorder()
+ for (const app of apps.value) app.checked = false
+ reorder()
}
+
function invertSelection() {
- apps.value.forEach((a) => {
- a.checked = !a.checked
- })
- _reorder()
+ for (const app of apps.value) app.checked = !app.checked
+ reorder()
}
const smartKeywords = [
@@ -166,35 +172,53 @@ export function useApps() {
'x',
]
- function smartSelect() {
- apps.value.forEach((a) => {
- const name = (a.appLabel || '').toLowerCase()
- const pkg = (a.packageName || '').toLowerCase()
- for (const kw of smartKeywords) {
- if (kw === 'x') {
+ function smartSelect(snackbar) {
+ let count = 0
+ for (const app of apps.value) {
+ const name = (app.appLabel || '').toLowerCase()
+ const pkg = (app.packageName || '').toLowerCase()
+ for (const keyword of smartKeywords) {
+ if (keyword === 'x') {
if (name === 'x' || name === 'x (twitter)') {
- a.checked = true
+ if (!app.checked) count++
+ app.checked = true
break
}
- } else if (name.includes(kw) || pkg.includes(kw)) {
- a.checked = true
+ } else if (name.includes(keyword) || pkg.includes(keyword)) {
+ if (!app.checked) count++
+ app.checked = true
break
}
}
- })
- _reorder()
+ }
+ reorder()
+ snackbar?.(count > 0 ? `已智能勾选 ${count} 个应用` : '没有匹配到可勾选的应用')
}
- // 过滤后的列表
+ /** 过滤后的列表(供虚拟滚动使用) */
function getFilteredApps() {
- const kw = searchKeyword.value.trim().toLowerCase()
- if (!kw) return apps.value
+ const keyword = searchKeyword.value.trim().toLowerCase()
+ if (!keyword) return apps.value
return apps.value.filter((a) => {
const pkg = a.packageName.toLowerCase()
- return pkg.includes(kw) || PinyinMatch.match(a.appLabel, kw)
+ if (pkg.includes(keyword)) return true
+ // 拼音库未就绪时退化为普通子串匹配
+ if (!pinyinReady.value || !PinyinMatch) {
+ return (a.appLabel || '').toLowerCase().includes(keyword)
+ }
+ return !!PinyinMatch.match(a.appLabel, keyword)
})
}
+ const unsavedCount = computed(() => {
+ const selected = apps.value.filter((a) => a.checked).map((a) => a.packageName)
+ const all = [...selected, ...activityEntries.value]
+ const saved = [...savedBlacklist.value]
+ if (all.length !== saved.length) return 1
+ const savedSet = new Set(saved)
+ return all.some((e) => !savedSet.has(e)) ? 1 : 0
+ })
+
return {
apps,
isLoading,
@@ -203,13 +227,14 @@ export function useApps() {
showingSystemApps,
savedBlacklist,
activityEntries,
+ unsavedCount,
load,
save,
hasActivity,
getActivities,
addActivity,
removeActivity,
- onCheckboxChange,
+ reorder,
toggleSystemApps,
selectAll,
selectNone,
diff --git a/webui/src/composables/useConfig.js b/webui/src/composables/useConfig.js
index 0757f79..d3e8883 100644
--- a/webui/src/composables/useConfig.js
+++ b/webui/src/composables/useConfig.js
@@ -1,286 +1,168 @@
-import { ref, watch } from 'vue'
-import {
- runCmd,
- readConfig,
- writeConfig,
- updateConfig,
- BACKUP_CONFIG_FILE,
- PID_FILE,
- DEFAULT_NOW_BRI_FILE,
- DEFAULT_SYS_MAX_BRI_FILE,
-} from '../utils.js'
+import { ref, reactive, computed } from 'vue'
+import { fetchConfig, patchConfig, readModuleFile } from '../api/luminpro.js'
+
+/** 主配置卡片负责的字段 */
+const MAIN_KEYS = [
+ 'ui_max_bri',
+ 'max_bri',
+ 'steps_num',
+ 'auto_bri_sleep',
+ 'display_hdr_sleep',
+ 'hdr_enter_ratio',
+ 'hdr_exit_ratio',
+ 'compatibility_mode',
+ 'sleep_time',
+]
+
+/** 高级设置负责的字段 */
+const ADVANCED_KEYS = ['now_bri_file', 'max_bri_file', 'inotify_events', 'debug_mode', 'log_max_size', 'log_level']
+
+const INT_KEYS = new Set([
+ 'ui_max_bri',
+ 'max_bri',
+ 'steps_num',
+ 'log_max_size',
+ 'auto_bri_sleep',
+ 'display_hdr_sleep',
+ 'compatibility_mode',
+ 'debug_mode',
+])
+const FLOAT_KEYS = new Set(['hdr_enter_ratio', 'hdr_exit_ratio'])
+
+/** 配置改动的类型还原:表单里统一用字符串,写回时按字段类型转换 */
+function toTyped(key, value) {
+ if (INT_KEYS.has(key)) return parseInt(value, 10) || 0
+ if (FLOAT_KEYS.has(key)) return parseFloat(value) || 0
+ return value
+}
+
+/** 配置对象 -> 表单字符串(数组字段保持数组) */
+function toForm(cfg, keys) {
+ const out = {}
+ for (const key of keys) {
+ const value = cfg[key]
+ if (Array.isArray(value)) out[key] = value
+ else if (value === null || value === undefined) out[key] = ''
+ else out[key] = String(value)
+ }
+ return out
+}
export function useConfig() {
- // 亮度配置
- const uiMaxBri = ref('')
- const maxBri = ref('')
- const stepsNum = ref('50')
+ const saved = ref({})
+ const loading = ref(false)
+ const error = ref('')
- // 执行策略
- const autoBriSleep = ref(false)
- const displayHdrSleep = ref(false)
- const hdrEnterRatio = ref('1.15')
- const hdrExitRatio = ref('1.05')
- const compatibilityMode = 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 debugMode = ref(false)
- const logLevel = ref('info')
- const logMaxSize = ref('500')
-
- // 脸污标记
- const dirty = ref(false)
- const dirtyAdvanced = ref(false)
- let _silent = false
-
- // Web UI 配置 (localStorage 持久化)
- const autoRefresh = ref(localStorage.getItem('autoRefresh') !== 'false')
- const statusRefreshInterval = ref(
- 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')
-
- // 监听主配置字段
- watch(
- [
- uiMaxBri,
- maxBri,
- stepsNum,
- autoBriSleep,
- displayHdrSleep,
- hdrEnterRatio,
- hdrExitRatio,
- compatibilityMode,
- sleepMode,
- sleepStartH,
- sleepStartM,
- sleepEndH,
- sleepEndM,
- ],
- () => {
- if (!_silent) dirty.value = true
- },
- )
- // 监听高级设置字段 (系统管理的日志项也随「保存设置」写入)
- watch([nowBriFile, sysMaxBriFile, inotifyEvents, debugMode, logLevel, logMaxSize], () => {
- if (!_silent) dirtyAdvanced.value = true
+ const form = reactive({
+ ...toForm({}, [...MAIN_KEYS, ...ADVANCED_KEYS]),
+ blacklist_apps: [],
})
+ function hydrate(cfg) {
+ saved.value = { ...cfg }
+ Object.assign(form, toForm(cfg, [...MAIN_KEYS, ...ADVANCED_KEYS]))
+ form.blacklist_apps = Array.isArray(cfg.blacklist_apps) ? [...cfg.blacklist_apps] : []
+ }
+
async function load() {
- _silent = true
- const cfg = await readConfig()
- if (!cfg || Object.keys(cfg).length === 0) {
- _silent = false
+ loading.value = true
+ try {
+ hydrate(await fetchConfig())
+ error.value = ''
+ } catch (e) {
+ error.value = e.message
+ } finally {
+ loading.value = false
+ }
+ }
+
+ /** 某组字段中相对已保存配置发生变化的项(已按类型还原) */
+ function changedKeys(keys) {
+ const patch = {}
+ for (const key of keys) {
+ const current = key === 'blacklist_apps' ? JSON.stringify(form[key]) : String(form[key])
+ const original = Array.isArray(saved.value[key])
+ ? JSON.stringify(saved.value[key])
+ : String(saved.value[key] ?? '')
+ if (current !== original) patch[key] = toTyped(key, form[key])
+ }
+ return patch
+ }
+
+ const diffMain = computed(() => changedKeys(MAIN_KEYS))
+ const diffAdvanced = computed(() => changedKeys(ADVANCED_KEYS))
+ const dirtyMain = computed(() => Object.keys(diffMain.value).length > 0)
+ const dirtyAdvanced = computed(() => Object.keys(diffAdvanced.value).length > 0)
+
+ async function save(patch, snackbar, message) {
+ if (Object.keys(patch).length === 0) {
+ snackbar?.('没有需要保存的改动')
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
- hdrEnterRatio.value = cfg.hdr_enter_ratio != null ? String(cfg.hdr_enter_ratio) : '1.15'
- hdrExitRatio.value = cfg.hdr_exit_ratio != null ? String(cfg.hdr_exit_ratio) : '1.05'
- compatibilityMode.value = cfg.compatibility_mode === 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'
- debugMode.value = cfg.debug_mode === 1
- logLevel.value = cfg.log_level || 'info'
-
- 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)
- }
- } else {
- sleepMode.value = false
+ try {
+ await patchConfig(patch)
+ await load()
+ snackbar?.(message)
+ } catch (e) {
+ snackbar?.(`保存失败: ${e.message}`)
}
- dirty.value = false
- dirtyAdvanced.value = false
- _silent = 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)}`
- }
+ const saveMain = (snackbar) => save(diffMain.value, snackbar, '配置已保存')
+ const saveAdvanced = (snackbar) => save(diffAdvanced.value, snackbar, '高级设置已保存,需重启模块生效')
- async function save(toast) {
- if (!uiMaxBri.value || !maxBri.value) {
- toast('亮度値不能为空')
- return
- }
- toast('保存中...')
- // 读取当前配置(保留 blacklist_apps 等其他字段)
- 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,
- auto_bri_sleep: autoBriSleep.value ? 1 : 0,
- display_hdr_sleep: displayHdrSleep.value ? 1 : 0,
- hdr_enter_ratio: parseFloat(hdrEnterRatio.value) || 1.15,
- hdr_exit_ratio: parseFloat(hdrExitRatio.value) || 1.05,
- compatibility_mode: compatibilityMode.value ? 1 : 0,
- sleep_time: getSleepTimeStr(),
- })
- const pidRes = await runCmd(`cat "${PID_FILE}"`)
- toast(
- pidRes.errno === 0 && pidRes.stdout.trim()
- ? '配置已保存 (下次重启模块或触发时生效)'
- : '配置已保存 (服务未运行)',
- )
- dirty.value = false
- }
-
- async function saveAdvanced(toast, onPathsChanged) {
- toast('保存中...')
- await updateConfig({
- now_bri_file: nowBriFile.value || DEFAULT_NOW_BRI_FILE,
- max_bri_file: sysMaxBriFile.value || DEFAULT_SYS_MAX_BRI_FILE,
- inotify_events: inotifyEvents.value || 'c',
- debug_mode: debugMode.value ? 1 : 0,
- log_max_size: parseInt(logMaxSize.value) || 500,
- log_level: logLevel.value,
- })
- onPathsChanged?.()
- toast('高级设置已保存,需重启模块生效')
- dirtyAdvanced.value = false
- }
-
- async function resetToDefaults(toast) {
- toast('正在恢复默认配置...')
- const backupRes = await runCmd(`cat "${BACKUP_CONFIG_FILE}"`)
- if (backupRes.errno !== 0 || !backupRes.stdout.trim()) {
- toast('备份文件不存在,无法恢复')
+ /** 从安装时备份恢复默认值(只改表单,需再点保存) */
+ async function restoreBackup(snackbar) {
+ const raw = await readModuleFile('config/.backup/config.json')
+ if (!raw.trim()) {
+ snackbar?.('备份文件不存在,无法恢复')
return
}
let backup
try {
- backup = JSON.parse(backupRes.stdout)
+ backup = JSON.parse(raw)
} catch {
- toast('备份文件损坏')
+ snackbar?.('备份文件损坏')
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
- hdrEnterRatio.value = backup.hdr_enter_ratio != null ? String(backup.hdr_enter_ratio) : '1.15'
- hdrExitRatio.value = backup.hdr_exit_ratio != null ? String(backup.hdr_exit_ratio) : '1.05'
- compatibilityMode.value = backup.compatibility_mode === 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 || ''
- 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)
- }
- } else {
- sleepMode.value = true
- sleepStartH.value = '19'
- sleepStartM.value = '00'
- sleepEndH.value = '06'
- sleepEndM.value = '00'
- }
- await save(toast)
- await saveAdvanced(toast)
+ hydrate({ ...saved.value, ...backup })
+ snackbar?.('已载入安装时的配置,点击保存生效')
}
- 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 sleepEnabled = computed({
+ get: () => !!form.sleep_time,
+ set: (on) => {
+ form.sleep_time = on ? form.sleep_time || '2300-0700' : ''
+ },
+ })
- function applyZoom() {
- document.documentElement.style.zoom = uiZoom.value / 100
- }
+ const sleepParts = computed(() => {
+ const text = String(form.sleep_time || '')
+ const match = /^(\d{2})(\d{2})-(\d{2})(\d{2})$/.exec(text)
+ if (!match) return ['23', '00', '07', '00']
+ return [match[1], match[2], match[3], match[4]]
+ })
- 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')
+ function setSleepPart(index, value) {
+ const parts = [...sleepParts.value]
+ parts[index] = String(value).padStart(2, '0').slice(-2)
+ form.sleep_time = `${parts[0]}${parts[1]}-${parts[2]}${parts[3]}`
}
return {
- uiMaxBri,
- maxBri,
- stepsNum,
- logMaxSize,
- autoBriSleep,
- displayHdrSleep,
- hdrEnterRatio,
- hdrExitRatio,
- compatibilityMode,
- sleepMode,
- sleepStartH,
- sleepStartM,
- sleepEndH,
- sleepEndM,
- nowBriFile,
- sysMaxBriFile,
- inotifyEvents,
- debugMode,
- logLevel,
- dirty,
+ saved,
+ form,
+ loading,
+ error,
+ dirtyMain,
dirtyAdvanced,
- autoRefresh,
- statusRefreshInterval,
- uiZoom,
- themeMode,
load,
- save,
+ saveMain,
saveAdvanced,
- resetToDefaults,
- saveWebUIConfig,
- applyZoom,
- applyTheme,
+ restoreBackup,
+ sleepEnabled,
+ sleepParts,
+ setSleepPart,
}
}
diff --git a/webui/src/composables/useLog.js b/webui/src/composables/useLog.js
index e377fdb..8a8f776 100644
--- a/webui/src/composables/useLog.js
+++ b/webui/src/composables/useLog.js
@@ -1,58 +1,68 @@
import { ref, computed } from 'vue'
-import { runCmd, LOG_FILE } from '../utils.js'
+import { fetchLog, clearLog, exportLog } from '../api/luminpro.js'
+const LEVELS = ['', 'INFO', 'WARN', 'ERROR', 'SUCCESS']
+
+/** 日志:数据来自 Go 侧 `luminpro log tail`,等级过滤在前端进行 */
export function useLog() {
- const fullLog = ref('')
- const filterLevel = ref('')
- const isLoading = ref(false)
+ const entries = ref([])
+ const level = ref('')
+ const error = ref('')
+ const loading = 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}] 等级的日志`
- })
+ const levels = LEVELS
+ const filtered = computed(() =>
+ level.value ? entries.value.filter((e) => e.level === level.value) : entries.value,
+ )
+
+ const asText = (list = filtered.value) =>
+ list.map((e) => `[${e.time}] [${e.tag}] [${e.level}] ${e.message}`.trim()).join('\n')
async function load() {
- const res = await runCmd(`tail -n 100 "${LOG_FILE}"`)
- fullLog.value =
- res.errno === 0 ? res.stdout.trim() || '暂无日志' : '无法读取日志 (可能模块尚未产生日志文件)'
+ loading.value = true
+ try {
+ const page = await fetchLog(200)
+ entries.value = page.entries ?? []
+ error.value = ''
+ } catch (e) {
+ error.value = e.message
+ } finally {
+ loading.value = false
+ }
}
- async function clear(toast) {
- toast('正在清空日志...')
- const res = await runCmd(`> "${LOG_FILE}"`)
- if (res.errno === 0) {
- fullLog.value = ''
- toast('日志已清空')
- } else toast('清空失败: ' + (res.stderr || '未知错误'))
+ async function clear(snackbar) {
+ try {
+ await clearLog()
+ entries.value = []
+ snackbar?.('日志已清空')
+ } catch (e) {
+ snackbar?.(`清空失败: ${e.message}`)
+ }
}
- async function copy(toast) {
- const res = await runCmd(`tail -n 50 "${LOG_FILE}"`)
- if (res.errno !== 0 || !res.stdout.trim()) {
- toast('暂无日志内容')
+ async function exportTo(snackbar) {
+ try {
+ const res = await exportLog('/sdcard')
+ snackbar?.(`已导出到 ${res.path}`)
+ } catch (e) {
+ snackbar?.(`导出失败: ${e.message}`)
+ }
+ }
+
+ async function copy(snackbar) {
+ const text = asText()
+ if (!text) {
+ snackbar?.('暂无日志可复制')
return
}
try {
- await navigator.clipboard.writeText(res.stdout.trim())
+ await navigator.clipboard.writeText(text)
+ snackbar?.('日志已复制到剪贴板')
} 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)
+ snackbar?.('复制失败,请手动选择文本')
}
- 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 || '未知错误'))
- }
-
- return { fullLog, filterLevel, filteredLog, isLoading, load, clear, copy, exportLog }
+ return { entries, filtered, level, levels, error, loading, asText, load, clear, exportTo, copy }
}
diff --git a/webui/src/composables/useOplock.js b/webui/src/composables/useOplock.js
deleted file mode 100644
index 7cc18a7..0000000
--- a/webui/src/composables/useOplock.js
+++ /dev/null
@@ -1,23 +0,0 @@
-import { ref } from 'vue'
-import { runCmd, OPLOCK_FILE } from '../utils.js'
-
-/**
- * 操作锁:后台脚本 (up.sh 渐变 / boost.sh 峰值 / restart.sh 重启) 写亮度节点期间
- * 会创建 oplock 并写入自身 PID。WebUI 据此暂停刷新、禁用写操作。
- * 锁文件中的 PID 不存在时视为遗留锁,就地清理并放行。
- */
-export function useOplock() {
- const isLocked = ref(false)
-
- async function refresh() {
- const res = await runCmd(
- `F="${OPLOCK_FILE}"; if [ -f "$F" ]; then P="$(cat "$F" 2>/dev/null)"; ` +
- `if [ -n "$P" ] && [ -d "/proc/$P" ]; then echo locked; ` +
- `else rm -f "$F"; echo free; fi; else echo free; fi`,
- )
- isLocked.value = res.errno === 0 && res.stdout.trim() === 'locked'
- return isLocked.value
- }
-
- return { isLocked, refresh }
-}
diff --git a/webui/src/composables/useSnackbar.js b/webui/src/composables/useSnackbar.js
new file mode 100644
index 0000000..8825806
--- /dev/null
+++ b/webui/src/composables/useSnackbar.js
@@ -0,0 +1,70 @@
+import { ref, computed } from 'vue'
+
+/** Snackbar(M3):底部浮层提示,自动消失 */
+export function useSnackbar() {
+ const messages = ref([])
+ let seq = 0
+
+ function show(text, { duration = 3000 } = {}) {
+ if (!text) return
+ const id = ++seq
+ messages.value.push({ id, text })
+ if (messages.value.length > 3) messages.value.shift()
+ setTimeout(() => dismiss(id), duration)
+ }
+
+ function dismiss(id) {
+ messages.value = messages.value.filter((m) => m.id !== id)
+ }
+
+ return { messages, show, dismiss }
+}
+
+/**
+ * 主题 / 缩放 / 刷新频率等纯前端偏好(localStorage)。
+ * 模块状态不放这里——它属于 config.json。
+ */
+export function useWebUIPrefs() {
+ const autoRefresh = ref(localStorage.getItem('autoRefresh') !== 'false')
+ const refreshInterval = ref(
+ Math.max(100, parseInt(localStorage.getItem('statusLogRefreshInterval') || '1000', 10)),
+ )
+ const zoom = ref(Math.min(150, Math.max(50, parseInt(localStorage.getItem('uiZoom') || '100', 10))))
+ const themeMode = ref(localStorage.getItem('themeMode') || 'system')
+
+ const zoomScale = computed(() => zoom.value / 100)
+
+ function applyZoom() {
+ document.documentElement.style.zoom = String(zoomScale.value)
+ }
+
+ function applyTheme(mode) {
+ const root = document.documentElement
+ root.classList.remove('light', 'dark')
+ if (mode === 'light' || mode === 'dark') root.classList.add(mode)
+ }
+
+ function save({ autoRefresh: ar, refreshInterval: ri, zoom: z, themeMode: tm }) {
+ autoRefresh.value = ar
+ refreshInterval.value = Math.max(100, parseInt(ri, 10) || 1000)
+ zoom.value = Math.min(150, Math.max(50, parseInt(z, 10) || 100))
+ themeMode.value = tm
+ localStorage.setItem('autoRefresh', String(autoRefresh.value))
+ localStorage.setItem('statusLogRefreshInterval', String(refreshInterval.value))
+ localStorage.setItem('uiZoom', String(zoom.value))
+ localStorage.setItem('themeMode', themeMode.value)
+ applyZoom()
+ applyTheme(themeMode.value)
+ }
+
+ return {
+ autoRefresh,
+ refreshInterval,
+ zoom,
+ themeMode,
+ zoomScale,
+ applyZoom,
+ applyTheme,
+ save,
+ }
+}
diff --git a/webui/src/composables/useStatus.js b/webui/src/composables/useStatus.js
index 6a7d228..6e295a9 100644
--- a/webui/src/composables/useStatus.js
+++ b/webui/src/composables/useStatus.js
@@ -1,150 +1,108 @@
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'
+ fetchStatus,
+ fetchOplock,
+ setBrightness as apiSetBrightness,
+ boost as apiBoost,
+ restart as apiRestart,
+ toggleService as apiToggleService,
+} from '../api/luminpro.js'
+/** 守护进程与亮度状态:数据来自 Go 侧 `luminpro status` */
export function useStatus() {
- // 亮度
- const currentBri = ref(null)
- const sysMaxBri = ref(null)
+ const status = ref(null)
+ const oplock = ref({ locked: false })
+ const error = ref('')
- // 服务状态
- 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'
+ const moduleInfo = computed(() => status.value?.module ?? {})
+ const daemon = computed(() => status.value?.daemon ?? {})
+ const brightness = computed(() => status.value?.brightness ?? { current: 0, max: 0, percent: 0 })
+ const display = computed(() => status.value?.display ?? null)
+ const sleep = computed(() => status.value?.sleep ?? { window: '', active: false })
+ const cfg = computed(() => status.value?.config ?? {})
+
+ const isPaused = computed(() => !!daemon.value.paused)
+ const isRunning = computed(() => !!daemon.value.running && !daemon.value.paused)
+ const statusText = computed(() => (isPaused.value ? '已暂停' : isRunning.value ? '运行中' : '未运行'))
+ const statusClass = computed(() =>
+ isPaused.value ? 'paused' : isRunning.value ? 'running' : 'stopped',
+ )
+ const sleepText = computed(() => {
+ if (!sleep.value.window) return '未配置'
+ return sleep.value.active ? '休眠中' : '非休眠'
})
- const statusText = computed(() => {
- if (isPaused.value) return '已暂停'
- if (isRunning.value) return '运行中'
- return '未运行'
+ const hdrText = computed(() => {
+ const d = display.value
+ if (!d || !d.hdrKnown) return '—'
+ return `${d.hdrRatio.toFixed(2)}${d.hdrStale ? '*' : ''}`
})
- // HDR / 睡眠状态
- const hdrRatio = ref('—')
- const sleepStatus = ref('—')
-
- // 缓存配置字段(避免每次刷新都 readConfig)
- 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 || ''
- }
-
- function invalidatePaths() {
- _nowBriFile = null
- _sysMaxBriFile = null
- _sleepTime = null
- }
-
- async function load(forceFull = false) {
- await _ensurePaths()
-
- const needBri = forceFull || currentBri.value === null || sysMaxBri.value === null
-
- // 所有 Shell 命令一次并发,消除多轮顺序等待
- // PID + 进程状态合并为一条命令以减少 exec 次数
- const [pidStateRes, stopRes, 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(`[ -f "${STOP_FLAG_FILE}" ] && echo "1" || echo "0"`),
- 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'
+ async function load({ display = true } = {}) {
+ try {
+ const next = await fetchStatus({ display })
+ // --no-display 时后端不返回 display 字段,沿用上一次的结果避免界面闪烁
+ if (!display && !next.display && status.value?.display) {
+ next.display = status.value.display
+ }
+ status.value = next
+ error.value = ''
+ } catch (e) {
+ error.value = e.message
}
-
- 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 || '已退出' : '离线'
-
- const hdrRaw = hdrRes.errno === 0 ? hdrRes.stdout.trim() : ''
- hdrRatio.value = hdrRaw && /^\d+(\.\d+)?$/.test(hdrRaw) ? parseFloat(hdrRaw).toFixed(2) : '-'
-
- 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 (sNum > eNum) {
- return nV >= sNum || nV < eNum ? '休眠中' : '非休眠'
+ async function refreshOplock() {
+ try {
+ oplock.value = await fetchOplock()
+ } catch {
+ /* 忽略:下次轮询会重试 */
}
- 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)
+ async function setBrightness(value) {
+ await apiSetBrightness(value)
+ await load({ display: false })
}
- 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)
+ async function toggleService(snackbar) {
+ const res = await apiToggleService()
+ snackbar?.(res.ok ? res.stdout.trim() || '状态已切换' : '操作失败: ' + res.stderr)
+ await load({ display: false })
}
- 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)
- if (!(res.errno === 0 && res.stdout.includes('OK'))) {
- toast('亮度设置失败,已恢复')
- await load(true)
- }
+ async function boost(snackbar) {
+ const res = await apiBoost()
+ snackbar?.(res.ok ? '已切换峰值亮度' : '操作失败: ' + res.stderr)
+ await load({ display: false })
+ }
+
+ async function restart(snackbar) {
+ const res = await apiRestart()
+ snackbar?.(res.ok ? '模块已重启' : '模块重启失败: ' + res.stderr)
+ setTimeout(() => load({ display: false }), 600)
}
return {
- currentBri,
- sysMaxBri,
- inotifydPid,
- inotifydState,
+ status,
+ oplock,
+ error,
+ moduleInfo,
+ daemon,
+ brightness,
+ display,
+ sleep,
+ cfg,
isRunning,
isPaused,
- statusClass,
statusText,
- hdrRatio,
- sleepStatus,
+ statusClass,
+ sleepText,
+ hdrText,
load,
- invalidatePaths,
- toggleService,
- restartService,
+ refreshOplock,
setBrightness,
+ toggleService,
+ boost,
+ restart,
}
}
diff --git a/webui/src/header.css b/webui/src/header.css
deleted file mode 100644
index 0b92e16..0000000
--- a/webui/src/header.css
+++ /dev/null
@@ -1,220 +0,0 @@
-/* Header */
-.app-header {
- position: absolute;
- top: var(--oplock-offset, 0);
- left: 0;
- right: 0;
- z-index: 10;
- display: flex;
- align-items: center;
- justify-content: space-between;
- padding: 25px 25px;
- transition: transform 0.35s cubic-bezier(0.25, 1, 0.5, 1);
- will-change: transform;
-}
-
-.header-content {
- display: flex;
- align-items: center;
- gap: 16px;
- flex: 1;
-}
-
-.header-icon {
- font-size: 2.5rem;
- background: linear-gradient(
- 135deg,
- var(--md-sys-color-primary-container),
- var(--md-sys-color-secondary-container)
- );
- width: 56px;
- height: 56px;
- border-radius: 12px;
- display: flex;
- align-items: center;
- justify-content: center;
- box-shadow: 0 2px 8px rgba(0, 0, 0, 0.12);
- flex-shrink: 0;
-}
-
-.header-text {
- display: flex;
- flex-direction: column;
- gap: 2px;
-}
-
-.header-text h1 {
- margin: 0;
- font-size: 1.5rem;
- font-weight: 700;
- color: var(--md-sys-color-on-background);
- letter-spacing: -0.3px;
-}
-
-.header-subtitle {
- margin: 0;
- font-size: 0.9rem;
- color: var(--md-sys-color-on-surface-variant);
- font-weight: 400;
-}
-
-.header-version {
- margin: 0;
- font-size: 0.75rem;
- color: var(--md-sys-color-primary);
- font-weight: 600;
- letter-spacing: 0.5px;
- text-transform: uppercase;
-}
-
-/* 版本通道徽标 (Beta / Dev) */
-.version-channel {
- display: inline-block;
- margin-left: 6px;
- padding: 1px 6px;
- border-radius: 999px;
- font-size: 0.6875rem;
- font-weight: 700;
- color: var(--color-warning);
- background: color-mix(in srgb, var(--color-warning) 18%, transparent);
- vertical-align: middle;
-}
-
-.header-status-container {
- display: flex;
- flex-direction: column;
- align-items: flex-end;
- gap: 12px;
-}
-
-.header-status {
- display: flex;
- align-items: center;
- gap: 8px;
- background: var(--md-sys-color-surface-container-high);
- padding: 8px 16px;
- border-radius: 12px;
- font-size: 0.8125rem;
- color: var(--md-sys-color-on-surface);
- font-weight: 500;
- box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08);
- border: 1px solid rgba(var(--md-sys-color-on-surface-rgb, 0, 0, 0), 0.08);
-}
-
-.header-status-actions {
- display: flex;
- gap: 16px;
-}
-
-.btn-status-action {
- background: transparent;
- border: none;
- color: var(--md-sys-color-primary);
- font-size: 0.8125rem;
- font-weight: 600;
- cursor: pointer;
- padding: 2px 4px;
- border-radius: 4px;
- transition: all 0.2s;
- opacity: 0.9;
-}
-
-.btn-status-action:active {
- background-color: var(--md-sys-color-primary-container);
- opacity: 1;
-}
-
-.btn-status-action:disabled {
- opacity: 0.4;
- cursor: not-allowed;
- pointer-events: none;
-}
-
-/* 操作锁横幅 */
-.oplock-banner {
- position: fixed;
- top: var(--safe-area-inset-top, 0px);
- left: 0;
- right: 0;
- z-index: 20;
- display: flex;
- align-items: center;
- justify-content: center;
- gap: 8px;
- padding: 8px 16px;
- font-size: 0.8125rem;
- font-weight: 500;
- color: var(--md-sys-color-on-surface);
- background: var(--md-sys-color-surface-container-high);
- border-bottom: 1px solid var(--md-sys-color-outline-variant);
- box-shadow: 0 2px 8px rgba(0, 0, 0, 0.12);
-}
-
-.oplock-spinner {
- width: 14px;
- height: 14px;
- flex-shrink: 0;
- border: 2px solid var(--md-sys-color-primary);
- border-top-color: transparent;
- border-radius: 50%;
- animation: oplock-spin 0.8s linear infinite;
-}
-
-@keyframes oplock-spin {
- to {
- transform: rotate(360deg);
- }
-}
-
-.oplock-fade-enter-active,
-.oplock-fade-leave-active {
- transition:
- opacity 0.2s,
- transform 0.2s;
-}
-
-.oplock-fade-enter-from,
-.oplock-fade-leave-to {
- opacity: 0;
- transform: translateY(-100%);
-}
-
-.status-dot {
- width: 10px;
- height: 10px;
- border-radius: 50%;
- background-color: var(--md-sys-color-error);
- box-shadow: 0 0 8px rgba(244, 67, 54, 0.5);
- animation: status-pulse 2s infinite;
-}
-
-@keyframes status-pulse {
- 0%,
- 100% {
- box-shadow: 0 0 8px rgba(244, 67, 54, 0.5);
- }
- 50% {
- box-shadow: 0 0 12px rgba(244, 67, 54, 0.8);
- }
-}
-
-@keyframes status-pulse-green {
- 0%,
- 100% {
- box-shadow: 0 0 8px rgba(76, 175, 80, 0.6);
- }
- 50% {
- box-shadow: 0 0 12px rgba(76, 175, 80, 0.8);
- }
-}
-
-.header-status.status-running .status-dot {
- background-color: #4caf50;
- box-shadow: 0 0 8px rgba(76, 175, 80, 0.6);
- animation: status-pulse-green 2s infinite;
-}
-
-.header-status.status-paused .status-dot,
-.header-status.status-loading .status-dot {
- animation: status-pulse 2s infinite;
-}
diff --git a/webui/src/index.css b/webui/src/index.css
deleted file mode 100644
index 5ced31b..0000000
--- a/webui/src/index.css
+++ /dev/null
@@ -1,175 +0,0 @@
-@import 'tailwindcss';
-@import 'tw-animate-css';
-
-@custom-variant dark (&:is(.dark *));
-
-@theme inline {
- --color-background: var(--background);
- --color-foreground: var(--foreground);
- --color-card: var(--card);
- --color-card-foreground: var(--card-foreground);
- --color-popover: var(--popover);
- --color-popover-foreground: var(--popover-foreground);
- --color-primary: var(--primary);
- --color-primary-foreground: var(--primary-foreground);
- --color-secondary: var(--secondary);
- --color-secondary-foreground: var(--secondary-foreground);
- --color-muted: var(--muted);
- --color-muted-foreground: var(--muted-foreground);
- --color-accent: var(--accent);
- --color-accent-foreground: var(--accent-foreground);
- --color-destructive: var(--destructive);
- --color-border: var(--border);
- --color-input: var(--input);
- --color-ring: var(--ring);
- --radius-sm: calc(var(--radius) - 4px);
- --radius-md: calc(var(--radius) - 2px);
- --radius-lg: var(--radius);
- --radius-xl: calc(var(--radius) + 4px);
- --font-sans: Geist, system-ui, -apple-system, sans-serif;
- --font-mono: 'Geist Mono', 'Roboto Mono', monospace;
-}
-
-/* ===============================
- Shadcn 主题 Token (暗色, MD3 调色板)
- =============================== */
-:root,
-:root.dark {
- --radius: 0.75rem;
-
- /* Shadcn tokens */
- --background: #111318;
- --foreground: #e2e2e9;
- --card: #1e1f25;
- --card-foreground: #e2e2e9;
- --popover: #2b2930;
- --popover-foreground: #e2e2e9;
- --primary: #a8c7fa;
- --primary-foreground: #062e6f;
- --secondary: #2b2930;
- --secondary-foreground: #e2e2e9;
- --muted: #212429;
- --muted-foreground: #c4c6d0;
- --accent: #1b4b9b;
- --accent-foreground: #d3e3fd;
- --destructive: #ffb4ab;
- --border: #44474f;
- --input: #44474f;
- --ring: rgba(168, 199, 250, 0.5);
-
- /* MD3 tokens (保留,legacy CSS 仍在使用) */
- --md-sys-color-background: #111318;
- --md-sys-color-background-rgb: 17, 19, 24;
- --md-sys-color-on-background: #e2e2e9;
- --md-sys-color-surface: #1e1f25;
- --md-sys-color-surface-container: #212429;
- --md-sys-color-surface-container-high: #2b2930;
- --md-sys-color-surface-container-high-rgb: 43, 41, 48;
- --md-sys-color-on-surface: #e2e2e9;
- --md-sys-color-on-surface-variant: #c4c6d0;
- --md-sys-color-primary: #a8c7fa;
- --md-sys-color-primary-rgb: 168, 199, 250;
- --md-sys-color-on-primary: #062e6f;
- --md-sys-color-primary-container: #1b4b9b;
- --md-sys-color-on-primary-container: #d3e3fd;
- --md-sys-color-outline: #8e9099;
- --md-sys-color-outline-variant: #44474f;
- --md-sys-color-error: #ffb4ab;
- --md-sys-color-on-error: #690005;
- --md-sys-color-error-container: #93000a;
- --border-radius-m: 16px;
- --border-radius-s: 8px;
- --spacing-s: 8px;
- --spacing-m: 16px;
- --spacing-l: 24px;
- --color-warning: #f59e0b;
-}
-
-/* ===============================
- 浅色主题 Token
- =============================== */
-@media (prefers-color-scheme: light) {
- :root:not(.dark) {
- --background: #f8f9fc;
- --foreground: #191c20;
- --card: #ffffff;
- --card-foreground: #191c20;
- --popover: #ffffff;
- --popover-foreground: #191c20;
- --primary: #0b57d0;
- --primary-foreground: #ffffff;
- --secondary: #e8eaf0;
- --secondary-foreground: #191c20;
- --muted: #eff1f6;
- --muted-foreground: #44474f;
- --accent: #d3e3fd;
- --accent-foreground: #062e6f;
- --destructive: #b3261e;
- --border: #c4c7d0;
- --input: #c4c7d0;
- --ring: rgba(11, 87, 208, 0.3);
- /* MD3 */
- --md-sys-color-background: #f8f9fc;
- --md-sys-color-background-rgb: 248, 249, 252;
- --md-sys-color-on-background: #191c20;
- --md-sys-color-surface: #ffffff;
- --md-sys-color-surface-container: #eff1f6;
- --md-sys-color-surface-container-high: #e8eaf0;
- --md-sys-color-surface-container-high-rgb: 232, 234, 240;
- --md-sys-color-on-surface: #191c20;
- --md-sys-color-on-surface-variant: #44474f;
- --md-sys-color-primary: #0b57d0;
- --md-sys-color-primary-rgb: 11, 87, 208;
- --md-sys-color-on-primary: #ffffff;
- --md-sys-color-primary-container: #d3e3fd;
- --md-sys-color-on-primary-container: #062e6f;
- --md-sys-color-outline: #74777f;
- --md-sys-color-outline-variant: #c4c7d0;
- --md-sys-color-error: #b3261e;
- --md-sys-color-on-error: #ffffff;
- --md-sys-color-error-container: #f9dedc;
- --color-warning: #b45309;
- }
-}
-
-:root.light {
- --background: #f8f9fc;
- --foreground: #191c20;
- --card: #ffffff;
- --card-foreground: #191c20;
- --popover: #ffffff;
- --popover-foreground: #191c20;
- --primary: #0b57d0;
- --primary-foreground: #ffffff;
- --secondary: #e8eaf0;
- --secondary-foreground: #191c20;
- --muted: #eff1f6;
- --muted-foreground: #44474f;
- --accent: #d3e3fd;
- --accent-foreground: #062e6f;
- --destructive: #b3261e;
- --border: #c4c7d0;
- --input: #c4c7d0;
- --ring: rgba(11, 87, 208, 0.3);
- /* MD3 */
- --md-sys-color-background: #f8f9fc;
- --md-sys-color-background-rgb: 248, 249, 252;
- --md-sys-color-on-background: #191c20;
- --md-sys-color-surface: #ffffff;
- --md-sys-color-surface-container: #eff1f6;
- --md-sys-color-surface-container-high: #e8eaf0;
- --md-sys-color-surface-container-high-rgb: 232, 234, 240;
- --md-sys-color-on-surface: #191c20;
- --md-sys-color-on-surface-variant: #44474f;
- --md-sys-color-primary: #0b57d0;
- --md-sys-color-primary-rgb: 11, 87, 208;
- --md-sys-color-on-primary: #ffffff;
- --md-sys-color-primary-container: #d3e3fd;
- --md-sys-color-on-primary-container: #062e6f;
- --md-sys-color-outline: #74777f;
- --md-sys-color-outline-variant: #c4c7d0;
- --md-sys-color-error: #b3261e;
- --md-sys-color-on-error: #ffffff;
- --md-sys-color-error-container: #f9dedc;
- --color-warning: #b45309;
-}
diff --git a/webui/src/lib/utils.js b/webui/src/lib/utils.js
deleted file mode 100644
index 9d7d3ea..0000000
--- a/webui/src/lib/utils.js
+++ /dev/null
@@ -1,6 +0,0 @@
-import { clsx } from 'clsx'
-import { twMerge } from 'tailwind-merge'
-
-export function cn(...inputs) {
- return twMerge(clsx(inputs))
-}
diff --git a/webui/src/log.css b/webui/src/log.css
deleted file mode 100644
index dbeab64..0000000
--- a/webui/src/log.css
+++ /dev/null
@@ -1,265 +0,0 @@
-/* Logs */
-.log-output {
- font-family: 'Geist Mono', 'JetBrains Mono', 'Consolas', monospace;
- font-size: 0.6875rem;
- padding: var(--spacing-m);
- background-color: #0d0e12;
- color: #e3e3e3;
- border-radius: var(--border-radius-m);
- border: 1px solid rgba(255, 255, 255, 0.05);
- flex: 1;
- max-height: 60vh;
- overflow-y: auto;
- margin: 0;
- white-space: pre-wrap;
- word-wrap: break-word;
- line-height: 1.5;
- scrollbar-width: thin;
- scrollbar-color: var(--md-sys-color-outline-variant) transparent;
-}
-
-.log-output::-webkit-scrollbar {
- width: 4px;
-}
-
-.log-output::-webkit-scrollbar-thumb {
- background-color: var(--md-sys-color-outline-variant);
- border-radius: 4px;
-}
-
-.log-filter-select {
- padding: 0 12px;
- border: 1px solid var(--md-sys-color-outline-variant);
- border-radius: 8px;
- background-color: var(--md-sys-color-surface-container-high);
- color: var(--md-sys-color-on-surface);
- font-family: inherit;
- font-size: 0.8125rem;
- height: 32px;
- cursor: pointer;
- outline: none;
- transition: all 0.22s ease;
-}
-
-.log-filter-select:focus {
- border-color: var(--md-sys-color-primary);
- box-shadow: 0 0 0 2px rgba(var(--md-sys-color-primary-rgb), 0.2);
-}
-
-.log-output::-webkit-scrollbar {
- display: none; /* Chrome, Safari */
-}
-
-/* Simple Toast */
-.top-blur {
- position: fixed;
- top: 0;
- left: 0;
- right: 0;
- height: calc(85px + var(--safe-area-inset-top, 0px));
- z-index: 998;
- pointer-events: none;
- /* 基础暗色背景,增强状态栏文字可读性 */
- 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%
- );
- /* 核心:毛玻璃滤镜 */
- -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%
- );
- 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;
- transition: opacity 0.3s ease;
-}
-
-.top-blur.scrolled {
- opacity: 1;
-}
-
-.toast {
- position: fixed;
- bottom: 24px;
- left: 50%;
- transform: translateX(-50%) translateY(100px);
- background-color: var(--md-sys-color-on-surface);
- color: var(--md-sys-color-surface);
- padding: 12px 24px;
- border-radius: var(--border-radius-s);
- font-size: 0.875rem;
- box-shadow: 0 2px 5px rgba(0, 0, 0, 0.4);
- transition: transform 0.3s cubic-bezier(0.18, 0.89, 0.32, 1.28);
- z-index: 1000;
- width: max-content;
- max-width: 90vw;
- text-align: center;
-}
-
-.toast.show {
- transform: translateX(-50%) translateY(0);
-}
-
-/* Floating Navigation Bar */
-.floating-navbar {
- position: fixed;
- bottom: calc(18px + var(--safe-area-inset-bottom, 0px));
- left: 50%;
- transform: translateX(-50%) translateZ(0);
- display: flex;
- justify-content: center;
- align-items: center;
- gap: 8px;
- background: rgba(var(--md-sys-color-surface-container-high-rgb, 43, 41, 48), 0.75);
- -webkit-backdrop-filter: blur(12px);
- backdrop-filter: blur(12px);
- will-change: transform;
- 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);
- z-index: 999;
- width: fit-content;
- max-width: calc(100% - 32px);
- user-select: none;
- -webkit-user-select: none;
- -webkit-tap-highlight-color: transparent;
- touch-action: none;
-}
-
-.navbar-slider {
- position: absolute;
- left: 0;
- top: 8px;
- bottom: 8px;
- height: auto;
- background: var(--md-sys-color-primary-container);
- border-radius: 20px;
- will-change: transform, width;
- pointer-events: none;
- z-index: 0;
-}
-
-.navbar-btn {
- display: flex;
- flex-direction: column;
- align-items: center;
- justify-content: center;
- gap: 5px;
- padding: 6px 12px;
- background-color: transparent;
- border: none;
- color: var(--md-sys-color-on-surface-variant);
- font-size: 0.75rem;
- cursor: pointer;
- border-radius: 8px;
- transition: all 0.2s ease;
- flex: 1;
- max-width: 90px;
- white-space: nowrap;
- position: relative;
- z-index: 1;
-}
-
-.navbar-btn i,
-.navbar-btn svg {
- width: 20px;
- height: 20px;
- display: flex;
- align-items: center;
- justify-content: center;
-}
-
-.navbar-btn span {
- font-size: 0.75rem;
-}
-
-.navbar-btn:active {
- /* No scaling here, we rely on the slider feedback */
-}
-
-.navbar-btn.active {
- color: var(--md-sys-color-on-primary-container);
-}
-
-/* Dropdown Menu */
-.dropdown-container {
- position: relative;
-}
-
-.dropdown-menu {
- position: absolute;
- top: 100%;
- right: 0;
- margin-top: 8px;
- background-color: var(--md-sys-color-surface-container-high);
- border: 1px solid var(--md-sys-color-outline-variant);
- border-radius: var(--border-radius-s);
- box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
- min-width: 160px;
- opacity: 0;
- visibility: hidden;
- transform: translateY(-8px);
- transition: all 0.2s cubic-bezier(0.18, 0.89, 0.32, 1.28);
- z-index: 100;
- display: flex;
- flex-direction: column;
- padding: 4px;
-}
-
-.dropdown-menu.show {
- opacity: 1;
- visibility: visible;
- transform: translateY(0);
-}
-
-.dropdown-item {
- display: flex;
- align-items: center;
- gap: 12px;
- padding: 10px 12px;
- border-radius: 4px;
- cursor: pointer;
- color: var(--md-sys-color-on-surface);
- font-size: 0.875rem;
- transition: background-color 0.2s;
-}
-
-.dropdown-item:hover {
- background-color: var(--md-sys-color-surface-container);
-}
-
-.dropdown-item:active {
- background-color: var(--md-sys-color-surface);
-}
-
-.dropdown-item svg {
- color: var(--md-sys-color-primary);
- width: 18px;
- height: 18px;
-}
-
-.dropdown-item-danger {
- color: var(--md-sys-color-error, #cf6679);
-}
-
-.dropdown-item-danger svg {
- color: var(--md-sys-color-error, #cf6679);
-}
diff --git a/webui/src/main.js b/webui/src/main.js
index ff6a16e..88b4de0 100644
--- a/webui/src/main.js
+++ b/webui/src/main.js
@@ -1,11 +1,11 @@
import { createApp } from 'vue'
+import './mwc.js'
+
+import './theme/tokens.css'
+import './theme/base.css'
+import './theme/components.css'
+import './theme/app.css'
+
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')
diff --git a/webui/src/mwc.js b/webui/src/mwc.js
new file mode 100644
index 0000000..a8e5d60
--- /dev/null
+++ b/webui/src/mwc.js
@@ -0,0 +1,31 @@
+// @material/web 组件的唯一引入入口:只 import 本项目实际用到的组件,避免打包体积膨胀。
+// 说明:Material Web Components 官方处于维护模式,不包含 M3 Expressive 的动效;
+// 导航栏(navigationbar/navigationtab)位于 labs/ 目录。
+
+// 按钮与图标按钮
+import '@material/web/button/filled-button.js'
+import '@material/web/button/outlined-button.js'
+import '@material/web/button/text-button.js'
+import '@material/web/iconbutton/icon-button.js'
+
+// 输入类
+import '@material/web/textfield/outlined-text-field.js'
+import '@material/web/select/outlined-select.js'
+import '@material/web/select/select-option.js'
+import '@material/web/switch/switch.js'
+import '@material/web/slider/slider.js'
+import '@material/web/checkbox/checkbox.js'
+
+// 容器与浮层
+import '@material/web/dialog/dialog.js'
+import '@material/web/menu/menu.js'
+import '@material/web/menu/menu-item.js'
+import '@material/web/divider/divider.js'
+
+// 反馈
+import '@material/web/chips/chip-set.js'
+import '@material/web/chips/filter-chip.js'
+
+// 导航(labs)
+import '@material/web/labs/navigationbar/navigation-bar.js'
+import '@material/web/labs/navigationtab/navigation-tab.js'
diff --git a/webui/src/style.css b/webui/src/style.css
deleted file mode 100644
index 09ffaed..0000000
--- a/webui/src/style.css
+++ /dev/null
@@ -1,131 +0,0 @@
-:root,
-:root.dark {
- --md-sys-color-background: #111318;
- --md-sys-color-background-rgb: 17, 19, 24;
- --md-sys-color-on-background: #e2e2e9;
- --md-sys-color-surface: #1e1f25;
- --md-sys-color-surface-container: #212429;
- --md-sys-color-surface-container-high: #2b2930;
- --md-sys-color-surface-container-high-rgb: 43, 41, 48;
- --md-sys-color-on-surface: #e2e2e9;
- --md-sys-color-on-surface-variant: #c4c6d0;
- --md-sys-color-primary: #a8c7fa;
- --md-sys-color-primary-rgb: 168, 199, 250;
- --md-sys-color-on-primary: #062e6f;
- --md-sys-color-primary-container: #1b4b9b;
- --md-sys-color-on-primary-container: #d3e3fd;
- --md-sys-color-outline: #8e9099;
- --md-sys-color-outline-variant: #44474f;
- --md-sys-color-error: #ffb4ab;
- --md-sys-color-on-error: #690005;
-
- --border-radius-m: 16px;
- --border-radius-s: 8px;
- --spacing-s: 8px;
- --spacing-m: 16px;
- --spacing-l: 24px;
-}
-
-@font-face {
- font-family: 'Geist';
- src: url('/Geist[wght].woff2') format('woff2');
- font-weight: 100 900;
- font-style: normal;
-}
-
-@font-face {
- font-family: 'Geist Mono';
- src: url('/GeistMono[wght].woff2') format('woff2');
- font-weight: 100 900;
- font-style: normal;
-}
-
-* {
- box-sizing: border-box;
- -webkit-tap-highlight-color: transparent;
-}
-
-/* 隐藏所有滚动条 */
-html {
- scrollbar-width: none; /* Firefox */
- -ms-overflow-style: none; /* IE/Edge */
- background-color: var(--md-sys-color-background);
-}
-
-html::-webkit-scrollbar {
- display: none; /* Chrome, Safari */
-}
-
-body {
- margin: 0;
- padding: 0;
- zoom: 0.95;
- /* insets 会在这里被 internal/insets.css 处理,我们预留顶底内边距 */
- padding-top: var(--safe-area-inset-top, 0);
- padding-bottom: var(--safe-area-inset-bottom, 0);
- background-color: var(--md-sys-color-background);
- color: var(--md-sys-color-on-background);
- font-family:
- 'Geist',
- system-ui,
- -apple-system,
- sans-serif;
- line-height: 1.5;
- scrollbar-width: none; /* Firefox */
- -ms-overflow-style: none; /* IE/Edge */
-}
-
-body::-webkit-scrollbar {
- display: none; /* Chrome, Safari */
-}
-
-#app {
- position: relative;
- padding: 0;
- max-width: 600px;
- margin: 0 auto;
- display: flex;
- flex-direction: column;
- height: calc(100dvh / 0.95);
- overflow: hidden;
-}
-
-/* header 自动隐藏 */
-#app.header-hidden .app-header {
- transform: translateY(-100%);
-}
-
-/* 滑动页面轨道 */
-.page-viewport {
- flex: 1;
- min-height: 0;
- overflow: hidden;
- position: relative;
-}
-
-.page-track {
- display: flex;
- height: 100%;
- transition: transform 0.38s cubic-bezier(0.25, 1, 0.5, 1);
- will-change: transform;
-}
-
-.page-slide {
- width: 100%;
- flex-shrink: 0;
- height: 100%;
- overflow-y: auto;
- overflow-x: hidden;
- padding: 12px;
- padding-top: calc(var(--header-height, 120px) + var(--oplock-offset, 0px));
- padding-bottom: calc(16px + 80px + var(--safe-area-inset-bottom, 0px));
- scrollbar-width: none;
- -ms-overflow-style: none;
- display: flex;
- flex-direction: column;
- gap: var(--spacing-m);
-}
-
-.page-slide::-webkit-scrollbar {
- display: none;
-}
diff --git a/webui/src/theme/app.css b/webui/src/theme/app.css
new file mode 100644
index 0000000..3ae6b70
--- /dev/null
+++ b/webui/src/theme/app.css
@@ -0,0 +1,274 @@
+/* ==========================================================================
+ 应用外壳:顶栏 / 页面滑动轨 / M3 导航栏 / 操作锁横幅 / snackbar
+ ========================================================================== */
+
+#app {
+ position: relative;
+ display: flex;
+ flex-direction: column;
+ max-width: 600px;
+ margin: 0 auto;
+ height: calc(100dvh / 0.95);
+ overflow: hidden;
+ background-color: var(--md-sys-color-background);
+}
+
+/* ── M3 small top app bar ─────────────────────────────────────────── */
+.app-bar {
+ position: relative;
+ z-index: 3;
+ flex: 0 0 auto;
+ display: flex;
+ align-items: center;
+ gap: var(--md-sys-spacing-1);
+ min-height: 64px;
+ padding: var(--md-sys-spacing-2) var(--md-sys-spacing-1) var(--md-sys-spacing-2)
+ var(--md-sys-spacing-4);
+ background-color: var(--md-sys-color-surface);
+ transition: background-color var(--md-sys-motion-duration-medium2)
+ var(--md-sys-motion-easing-standard);
+}
+
+.app-bar.scrolled {
+ background-color: var(--md-sys-color-surface-container);
+}
+
+.app-bar__text {
+ flex: 1;
+ min-width: 0;
+ display: flex;
+ flex-direction: column;
+ gap: 2px;
+}
+
+.app-bar__title {
+ margin: 0;
+ color: var(--md-sys-color-on-surface);
+ display: flex;
+ align-items: center;
+ gap: var(--md-sys-spacing-2);
+}
+
+.app-bar__subtitle {
+ color: var(--md-sys-color-on-surface-variant);
+}
+
+/* 发布通道徽标(Beta / Dev) */
+.channel-badge {
+ flex: 0 0 auto;
+ padding: 2px 8px;
+ border-radius: var(--md-sys-shape-corner-full);
+ background-color: var(--lp-color-warning-container);
+ color: var(--lp-color-warning);
+ font-size: var(--md-sys-typescale-label-small-size);
+ line-height: var(--md-sys-typescale-label-small-line-height);
+ font-weight: 700;
+ text-transform: uppercase;
+}
+
+/* 守护进程状态胶囊 */
+.status-pill {
+ flex: 0 0 auto;
+ display: inline-flex;
+ align-items: center;
+ gap: 6px;
+ padding: 4px 10px;
+ border-radius: var(--md-sys-shape-corner-full);
+ background-color: var(--md-sys-color-surface-container-high);
+ color: var(--md-sys-color-on-surface-variant);
+ font-size: var(--md-sys-typescale-label-small-size);
+ font-weight: 600;
+}
+
+.status-pill__dot {
+ width: 8px;
+ height: 8px;
+ border-radius: 50%;
+ background-color: var(--md-sys-color-outline);
+}
+
+.status-pill.running .status-pill__dot {
+ background-color: var(--lp-color-success);
+ box-shadow: 0 0 8px var(--lp-color-success-container);
+ animation: status-pulse 2.4s var(--md-sys-motion-easing-standard) infinite;
+}
+
+.status-pill.paused .status-pill__dot {
+ background-color: var(--lp-color-warning);
+}
+
+.status-pill.stopped .status-pill__dot {
+ background-color: var(--md-sys-color-error);
+ animation: status-pulse 2s var(--md-sys-motion-easing-standard) infinite;
+}
+
+@keyframes status-pulse {
+ 0%,
+ 100% {
+ opacity: 1;
+ }
+ 50% {
+ opacity: 0.45;
+ }
+}
+
+.app-bar__actions {
+ flex: 0 0 auto;
+ display: flex;
+ align-items: center;
+ gap: 2px;
+}
+
+/* ── 页面滑动轨 ───────────────────────────────────────────────────── */
+.page-viewport {
+ flex: 1;
+ min-height: 0;
+ overflow: hidden;
+ position: relative;
+}
+
+.page-track {
+ display: flex;
+ height: 100%;
+ transition: transform var(--md-sys-motion-duration-medium4)
+ var(--md-sys-motion-easing-emphasized);
+ will-change: transform;
+}
+
+.page-slide {
+ flex: 0 0 100%;
+ width: 100%;
+ height: 100%;
+ overflow-y: auto;
+ overflow-x: hidden;
+ display: flex;
+ flex-direction: column;
+ gap: var(--md-sys-spacing-3);
+ padding: var(--md-sys-spacing-3) var(--md-sys-spacing-3)
+ calc(var(--md-sys-spacing-5) + var(--safe-area-inset-bottom, 0px));
+ scrollbar-width: none;
+}
+
+/* ── M3 导航栏 ────────────────────────────────────────────────────── */
+md-navigation-bar {
+ flex: 0 0 auto;
+ --md-navigation-bar-container-color: var(--md-sys-color-surface-container);
+ --md-navigation-bar-active-indicator-color: var(--md-sys-color-secondary-container);
+ --md-navigation-bar-active-icon-color: var(--md-sys-color-on-secondary-container);
+ --md-navigation-bar-active-label-text-color: var(--md-sys-color-on-surface);
+ --md-navigation-bar-inactive-icon-color: var(--md-sys-color-on-surface-variant);
+ --md-navigation-bar-inactive-label-text-color: var(--md-sys-color-on-surface-variant);
+}
+
+md-navigation-tab {
+ --md-navigation-tab-active-indicator-shape: var(--md-sys-shape-corner-full);
+}
+
+/* ── 操作锁横幅 ───────────────────────────────────────────────────── */
+.oplock-banner {
+ position: absolute;
+ top: 0;
+ left: 0;
+ right: 0;
+ z-index: 5;
+ display: flex;
+ align-items: center;
+ gap: var(--md-sys-spacing-2);
+ padding: var(--md-sys-spacing-2) var(--md-sys-spacing-4);
+ background-color: var(--md-sys-color-surface-container-highest);
+ border-bottom: 1px solid var(--md-sys-color-outline-variant);
+ color: var(--md-sys-color-on-surface);
+}
+
+.oplock-banner__spinner {
+ flex: 0 0 auto;
+ width: 16px;
+ height: 16px;
+ border: 2px solid var(--md-sys-color-primary);
+ border-top-color: transparent;
+ border-radius: 50%;
+ animation: oplock-spin 0.8s linear infinite;
+}
+
+@keyframes oplock-spin {
+ to {
+ transform: rotate(360deg);
+ }
+}
+
+.oplock-banner__text {
+ flex: 1;
+ min-width: 0;
+ font-size: var(--md-sys-typescale-title-small-size);
+ line-height: var(--md-sys-typescale-title-small-line-height);
+ font-weight: var(--md-sys-typescale-title-small-weight);
+}
+
+.oplock-banner__elapsed {
+ font-family: var(--md-sys-typescale-font-mono);
+ font-size: var(--md-sys-typescale-label-medium-size);
+ color: var(--md-sys-color-on-surface-variant);
+}
+
+.oplock-enter-active,
+.oplock-leave-active {
+ transition:
+ opacity var(--md-sys-motion-duration-short4) var(--md-sys-motion-easing-standard),
+ transform var(--md-sys-motion-duration-short4) var(--md-sys-motion-easing-standard);
+}
+
+.oplock-enter-from,
+.oplock-leave-to {
+ opacity: 0;
+ transform: translateY(-100%);
+}
+
+/* ── Snackbar(M3:反色表面 + 4dp 圆角)───────────────────────────── */
+.snackbar-host {
+ position: absolute;
+ left: var(--md-sys-spacing-3);
+ right: var(--md-sys-spacing-3);
+ bottom: calc(96px + var(--safe-area-inset-bottom, 0px));
+ z-index: 7;
+ display: flex;
+ flex-direction: column;
+ align-items: center;
+ gap: var(--md-sys-spacing-2);
+ pointer-events: none;
+}
+
+.snackbar {
+ pointer-events: auto;
+ display: flex;
+ align-items: center;
+ gap: var(--md-sys-spacing-3);
+ width: 100%;
+ min-height: 48px;
+ padding: var(--md-sys-spacing-3) var(--md-sys-spacing-4);
+ border-radius: var(--md-sys-shape-corner-extra-small);
+ background-color: var(--md-sys-color-inverse-surface);
+ color: var(--md-sys-color-inverse-on-surface);
+ box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
+ font-size: var(--md-sys-typescale-body-medium-size);
+ line-height: var(--md-sys-typescale-body-medium-line-height);
+}
+
+.snackbar-enter-active,
+.snackbar-leave-active {
+ transition:
+ opacity var(--md-sys-motion-duration-short4) var(--md-sys-motion-easing-standard),
+ transform var(--md-sys-motion-duration-short4) var(--md-sys-motion-easing-emphasized-decelerate);
+}
+
+.snackbar-enter-from,
+.snackbar-leave-to {
+ opacity: 0;
+ transform: translateY(16px);
+}
+
+/* ── 对话框:宽屏居中、窄屏留边 ───────────────────────────────────── */
+md-dialog {
+ --md-dialog-container-shape: var(--md-sys-shape-corner-extra-large);
+ max-width: min(560px, calc(100vw - 48px));
+ max-height: calc(100dvh - 96px);
+}
diff --git a/webui/src/theme/base.css b/webui/src/theme/base.css
new file mode 100644
index 0000000..8909f95
--- /dev/null
+++ b/webui/src/theme/base.css
@@ -0,0 +1,214 @@
+/* ==========================================================================
+ 基础层:字体、重置、insets、缩放、滚动条与通用排版/表面类
+ ========================================================================== */
+
+@font-face {
+ font-family: 'Geist';
+ src: url('/Geist[wght].woff2') format('woff2-variations');
+ font-weight: 100 900;
+ font-style: normal;
+ font-display: swap;
+}
+
+@font-face {
+ font-family: 'Geist Mono';
+ src: url('/GeistMono[wght].woff2') format('woff2-variations');
+ font-weight: 100 900;
+ font-style: normal;
+ font-display: swap;
+}
+
+*,
+*::before,
+*::after {
+ box-sizing: border-box;
+}
+
+html,
+body {
+ margin: 0;
+ padding: 0;
+}
+
+body {
+ /* 全局 0.95 视觉缩放;用户自定义缩放叠加在 html 上(沿用既有策略) */
+ zoom: 0.95;
+ padding-top: var(--safe-area-inset-top, 0);
+ padding-bottom: var(--safe-area-inset-bottom, 0);
+ background-color: var(--md-sys-color-background);
+ color: var(--md-sys-color-on-background);
+ font-family: var(--md-sys-typescale-font);
+ font-size: var(--md-sys-typescale-body-medium-size);
+ line-height: var(--md-sys-typescale-body-medium-line-height);
+ font-weight: var(--md-sys-typescale-body-medium-weight);
+ letter-spacing: var(--md-sys-typescale-body-medium-tracking);
+ -webkit-font-smoothing: antialiased;
+ -webkit-tap-highlight-color: transparent;
+}
+
+button,
+input,
+select,
+textarea {
+ font: inherit;
+ color: inherit;
+}
+
+/* 隐藏滚动条(保持移动端观感) */
+html,
+body,
+.scroll-area {
+ scrollbar-width: none;
+ -ms-overflow-style: none;
+}
+
+html::-webkit-scrollbar,
+body::-webkit-scrollbar,
+.scroll-area::-webkit-scrollbar {
+ display: none;
+}
+
+/* ── 排版工具类(直接映射 typescale)───────────────────────────────── */
+.ts-display {
+ font-size: var(--md-sys-typescale-display-small-size);
+ line-height: var(--md-sys-typescale-display-small-line-height);
+ font-weight: var(--md-sys-typescale-display-small-weight);
+}
+.ts-headline {
+ font-size: var(--md-sys-typescale-headline-small-size);
+ line-height: var(--md-sys-typescale-headline-small-line-height);
+ font-weight: var(--md-sys-typescale-headline-small-weight);
+}
+.ts-title-lg {
+ font-size: var(--md-sys-typescale-title-large-size);
+ line-height: var(--md-sys-typescale-title-large-line-height);
+ font-weight: var(--md-sys-typescale-title-large-weight);
+}
+.ts-title-md {
+ font-size: var(--md-sys-typescale-title-medium-size);
+ line-height: var(--md-sys-typescale-title-medium-line-height);
+ font-weight: var(--md-sys-typescale-title-medium-weight);
+ letter-spacing: var(--md-sys-typescale-title-medium-tracking);
+}
+.ts-title-sm {
+ font-size: var(--md-sys-typescale-title-small-size);
+ line-height: var(--md-sys-typescale-title-small-line-height);
+ font-weight: var(--md-sys-typescale-title-small-weight);
+ letter-spacing: var(--md-sys-typescale-title-small-tracking);
+}
+.ts-body-lg {
+ font-size: var(--md-sys-typescale-body-large-size);
+ line-height: var(--md-sys-typescale-body-large-line-height);
+}
+.ts-body {
+ font-size: var(--md-sys-typescale-body-medium-size);
+ line-height: var(--md-sys-typescale-body-medium-line-height);
+ letter-spacing: var(--md-sys-typescale-body-medium-tracking);
+}
+.ts-body-sm {
+ font-size: var(--md-sys-typescale-body-small-size);
+ line-height: var(--md-sys-typescale-body-small-line-height);
+ letter-spacing: var(--md-sys-typescale-body-small-tracking);
+}
+.ts-label {
+ font-size: var(--md-sys-typescale-label-large-size);
+ line-height: var(--md-sys-typescale-label-large-line-height);
+ font-weight: var(--md-sys-typescale-label-large-weight);
+ letter-spacing: var(--md-sys-typescale-label-large-tracking);
+}
+.ts-label-sm {
+ font-size: var(--md-sys-typescale-label-small-size);
+ line-height: var(--md-sys-typescale-label-small-line-height);
+ font-weight: var(--md-sys-typescale-label-small-weight);
+ letter-spacing: var(--md-sys-typescale-label-small-tracking);
+}
+
+.supporting {
+ color: var(--md-sys-color-on-surface-variant);
+}
+
+.mono {
+ font-family: var(--md-sys-typescale-font-mono);
+ font-variant-numeric: tabular-nums;
+}
+
+/* ── 表面:MD3 用色调层级而非阴影表达层级 ─────────────────────────── */
+.section {
+ background-color: var(--md-sys-color-surface-container-low);
+ border-radius: var(--md-sys-shape-corner-large);
+ padding: var(--md-sys-spacing-4);
+ display: flex;
+ flex-direction: column;
+ gap: var(--md-sys-spacing-3);
+}
+
+.section-header {
+ display: flex;
+ align-items: center;
+ gap: var(--md-sys-spacing-2);
+ min-height: 40px;
+}
+
+.section-header .section-title {
+ flex: 1;
+ margin: 0;
+ color: var(--md-sys-color-on-surface);
+}
+
+.divider {
+ height: 1px;
+ background-color: var(--md-sys-color-outline-variant);
+ border: 0;
+ margin: 0;
+}
+
+/* 可点击行:用状态层表达交互反馈(MD3 state layer) */
+.state-layer {
+ position: relative;
+ overflow: hidden;
+ cursor: pointer;
+ transition: background-color var(--md-sys-motion-duration-short4)
+ var(--md-sys-motion-easing-standard);
+}
+
+.state-layer::after {
+ content: '';
+ position: absolute;
+ inset: 0;
+ background-color: currentColor;
+ opacity: 0;
+ pointer-events: none;
+ transition: opacity var(--md-sys-motion-duration-short2)
+ var(--md-sys-motion-easing-standard);
+}
+
+.state-layer:hover::after {
+ opacity: var(--md-sys-state-hover-opacity);
+}
+
+.state-layer:focus-visible::after {
+ opacity: var(--md-sys-state-focus-opacity);
+}
+
+.state-layer:active::after {
+ opacity: var(--md-sys-state-pressed-opacity);
+}
+
+/* 焦点环(不做全局关闭,保证键盘/无障碍可见) */
+:focus-visible {
+ outline: 2px solid var(--md-sys-color-primary);
+ outline-offset: 2px;
+}
+
+/* 屏幕阅读器专用文本 */
+.sr-only {
+ position: absolute;
+ width: 1px;
+ height: 1px;
+ padding: 0;
+ margin: -1px;
+ overflow: hidden;
+ clip: rect(0, 0, 0, 0);
+ white-space: nowrap;
+ border: 0;
+}
diff --git a/webui/src/theme/components.css b/webui/src/theme/components.css
new file mode 100644
index 0000000..65373c0
--- /dev/null
+++ b/webui/src/theme/components.css
@@ -0,0 +1,160 @@
+/* ==========================================================================
+ 跨视图复用的模式:设置行 / 状态徽标 / 空状态 / 折叠区 / 状态网格 / 列表行
+ 视图专属样式放在各自的
diff --git a/webui/src/views/AppsView.vue b/webui/src/views/AppsView.vue
index a057971..c8a58aa 100644
--- a/webui/src/views/AppsView.vue
+++ b/webui/src/views/AppsView.vue
@@ -1,67 +1,99 @@
-
-