mirror of
https://github.com/YuleBest/LuminPro.git
synced 2026-12-04 00:54:42 +08:00
refactor(webui)!: 全量重写为 Material Design 3(@material/web)
- 组件层改为 Material Web Components:按钮/输入/开关/滑条/复选/下拉/对话框/ 菜单/导航栏/过滤芯片,移除 shadcn 风格组件与 Tailwind 全家桶 - 新增完整 MD3 token 体系(颜色全角色、字阶、形状、动效、状态层), 颜色沿用既有 Google Blue;字体保持 Geist 不变 - 壳层重构:M3 固定顶栏(滚动加容器色)+ 标准导航栏(去掉拖拽手势)、 toast 改为 M3 snackbar、原生 confirm/prompt 改为 md-dialog - 数据层改走 Go JSON API(status/oplock/brightness/config/log/focus), 一次调用取代多条 shell 命令;命令参数统一 shellQuote,不再拼接未校验输入 - 懒加载 markdown-it 与拼音库;删除 apps.js 等死代码 - 体积:JS 454KB(gzip 115KB) + CSS 30KB(原 318KB+58KB),懒加载分块另计
This commit is contained in:
1 parent
6a54cdae71
commit
90928d3aeb
54 files changed
+3284
-5525
No files matched your search
+12
-1
@@ -63,6 +63,9 @@ func run(args []string) error {
|
||||
return runStatus(paths, args[1:])
|
||||
case "oplock":
|
||||
return emitJSON(api.ReadOplock(paths.Oplock))
|
||||
case "focus":
|
||||
focus := system.Focus{Runner: system.ExecRunner{}}
|
||||
return emitJSON(map[string]any{"focus": focus.CurrentFocus()})
|
||||
case "brightness":
|
||||
return runBrightness(paths, args[1:])
|
||||
case "config":
|
||||
@@ -86,6 +89,7 @@ func usage() error {
|
||||
|
||||
luminpro status [--no-display] 聚合状态(JSON)
|
||||
luminpro oplock 操作锁状态(JSON)
|
||||
luminpro focus 当前前台 Activity(JSON)
|
||||
luminpro brightness set <值> 设置亮度(JSON)
|
||||
|
||||
luminpro config <操作> 配置管理(JSON)
|
||||
@@ -245,10 +249,17 @@ func runConfig(paths api.Paths, args []string) error {
|
||||
_, err = os.Stdout.Write(append(data, '\n'))
|
||||
return err
|
||||
case "patch":
|
||||
input, err := io.ReadAll(os.Stdin)
|
||||
// 支持两种传参:命令行参数(WebUI 用,exec 无 stdin)或标准输入(脚本用)
|
||||
var input []byte
|
||||
var err error
|
||||
if len(args) >= 2 {
|
||||
input = []byte(args[1])
|
||||
} else {
|
||||
input, err = io.ReadAll(os.Stdin)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
var patch map[string]json.RawMessage
|
||||
if err := json.Unmarshal(input, &patch); err != nil {
|
||||
return fmt.Errorf("补丁必须是 JSON 对象: %w", err)
|
||||
|
||||
+1
-7
@@ -14,25 +14,19 @@
|
||||
"fmt:check": "oxfmt webui/ --check"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@tailwindcss/vite": "^4.2.2",
|
||||
"archiver": "^7.0.1",
|
||||
"kernelsu": "^3.0.2",
|
||||
"oxfmt": "^0.44.0",
|
||||
"oxlint": "^1.59.0",
|
||||
"tailwindcss": "^4.2.2",
|
||||
"tw-animate-css": "^1.4.0",
|
||||
"vite": "^8.0.3"
|
||||
},
|
||||
"dependencies": {
|
||||
"@material/web": "^2.5.0",
|
||||
"@tanstack/vue-virtual": "^3.13.37",
|
||||
"@vitejs/plugin-vue": "^6.0.5",
|
||||
"class-variance-authority": "^0.7.1",
|
||||
"clsx": "^2.1.1",
|
||||
"lucide": "^1.7.0",
|
||||
"lucide-vue-next": "^1.0.0",
|
||||
"markdown-it": "^14.1.1",
|
||||
"pinyin-match": "^1.2.10",
|
||||
"tailwind-merge": "^3.5.0",
|
||||
"vue": "^3.5.32"
|
||||
}
|
||||
}
|
||||
Generated
+61
-261
@@ -8,21 +8,15 @@ importers:
|
||||
|
||||
.:
|
||||
dependencies:
|
||||
'@material/web':
|
||||
specifier: ^2.5.0
|
||||
version: 2.5.0
|
||||
'@tanstack/vue-virtual':
|
||||
specifier: ^3.13.37
|
||||
version: 3.13.37(vue@3.5.32)
|
||||
'@vitejs/plugin-vue':
|
||||
specifier: ^6.0.5
|
||||
version: 6.0.5(vite@8.0.3(@emnapi/core@1.9.2)(@emnapi/runtime@1.9.2)(jiti@2.6.1))(vue@3.5.32)
|
||||
class-variance-authority:
|
||||
specifier: ^0.7.1
|
||||
version: 0.7.1
|
||||
clsx:
|
||||
specifier: ^2.1.1
|
||||
version: 2.1.1
|
||||
lucide:
|
||||
specifier: ^1.7.0
|
||||
version: 1.7.0
|
||||
lucide-vue-next:
|
||||
specifier: ^1.0.0
|
||||
version: 1.0.0(vue@3.5.32)
|
||||
@@ -32,16 +26,10 @@ importers:
|
||||
pinyin-match:
|
||||
specifier: ^1.2.10
|
||||
version: 1.2.10
|
||||
tailwind-merge:
|
||||
specifier: ^3.5.0
|
||||
version: 3.5.0
|
||||
vue:
|
||||
specifier: ^3.5.32
|
||||
version: 3.5.32
|
||||
devDependencies:
|
||||
'@tailwindcss/vite':
|
||||
specifier: ^4.2.2
|
||||
version: 4.2.2(vite@8.0.3(@emnapi/core@1.9.2)(@emnapi/runtime@1.9.2)(jiti@2.6.1))
|
||||
archiver:
|
||||
specifier: ^7.0.1
|
||||
version: 7.0.1
|
||||
@@ -54,12 +42,6 @@ importers:
|
||||
oxlint:
|
||||
specifier: ^1.59.0
|
||||
version: 1.59.0
|
||||
tailwindcss:
|
||||
specifier: ^4.2.2
|
||||
version: 4.2.2
|
||||
tw-animate-css:
|
||||
specifier: ^1.4.0
|
||||
version: 1.4.0
|
||||
vite:
|
||||
specifier: ^8.0.3
|
||||
version: 8.0.3(@emnapi/core@1.9.2)(@emnapi/runtime@1.9.2)(jiti@2.6.1)
|
||||
@@ -96,21 +78,20 @@ packages:
|
||||
resolution: {integrity: sha512-O8jcjabXaleOG9DQ0+ARXWZBTfnP4WNAqzuiJK7ll44AmxGKv/J2M4TPjxjY3znBCfvBXFzucm1twdyFybFqEA==}
|
||||
engines: {node: '>=12'}
|
||||
|
||||
'@jridgewell/gen-mapping@0.3.13':
|
||||
resolution: {integrity: sha512-2kkt/7niJ6MgEPxF0bYdQ6etZaA+fQvDcLKckhy1yIQOzaoKjBBjSj63/aLVjYE3qhRt5dvM+uUyfCg6UKCBbA==}
|
||||
|
||||
'@jridgewell/remapping@2.3.5':
|
||||
resolution: {integrity: sha512-LI9u/+laYG4Ds1TDKSJW2YPrIlcVYOwi2fUC6xB43lueCjgxV4lffOCZCtYFiH6TNOX+tQKXx97T4IKHbhyHEQ==}
|
||||
|
||||
'@jridgewell/resolve-uri@3.1.2':
|
||||
resolution: {integrity: sha512-bRISgCIjP20/tbWSPWMEi54QVPRZExkuD9lJL+UIxUKtwVJA8wW1Trb1jMs1RFXo1CBTNZ/5hpC9QvmKWdopKw==}
|
||||
engines: {node: '>=6.0.0'}
|
||||
|
||||
'@jridgewell/sourcemap-codec@1.5.5':
|
||||
resolution: {integrity: sha512-cYQ9310grqxueWbl+WuIUIaiUaDcj7WOq5fVhEljNVgRfOUhY9fy2zTvfoqWsnebh8Sl70VScFbICvJnLKB0Og==}
|
||||
|
||||
'@jridgewell/trace-mapping@0.3.31':
|
||||
resolution: {integrity: sha512-zzNR+SdQSDJzc8joaeP8QQoCQr8NuYx2dIIytl1QeBEZHJ9uW6hebsrYgbz8hJwUQao3TWCMtmfV8Nu1twOLAw==}
|
||||
'@lit-labs/ssr-dom-shim@1.6.0':
|
||||
resolution: {integrity: sha512-VHb0ALPMTlgKjM6yIxxoQNnpKyUKLD04VzeQdsiXkMqkvYlAHxq9glGLmgbb889/1GsohSOAjvQYoiBppXFqrQ==}
|
||||
|
||||
'@lit/context@1.1.6':
|
||||
resolution: {integrity: sha512-M26qDE6UkQbZA2mQ3RjJ3Gzd8TxP+/0obMgE5HfkfLhEEyYE3Bui4A5XHiGPjy0MUGAyxB3QgVuw2ciS0kHn6A==}
|
||||
|
||||
'@lit/reactive-element@2.1.2':
|
||||
resolution: {integrity: sha512-pbCDiVMnne1lYUIaYNN5wrwQXDtHaYtg7YEFPeW+hws6U47WeFvISGUWekPGKWOP1ygrs0ef0o1VJMk1exos5A==}
|
||||
|
||||
'@material/web@2.5.0':
|
||||
resolution: {integrity: sha512-x2Uovyq8E/Zc1xHXd9s1eBMXF5pMHVAt70pISKd0fL3Ajj4L6zQaQUY/awcfR2RDAMKXC7i4+vr0arv1YaOR/g==}
|
||||
|
||||
'@napi-rs/wasm-runtime@1.1.2':
|
||||
resolution: {integrity: sha512-sNXv5oLJ7ob93xkZ1XnxisYhGYXfaG9f65/ZgYuAu3qt7b3NadcOEhLvx28hv31PgX8SZJRYrAIPQilQmFpLVw==}
|
||||
@@ -470,100 +451,6 @@ packages:
|
||||
'@rolldown/pluginutils@1.0.0-rc.2':
|
||||
resolution: {integrity: sha512-izyXV/v+cHiRfozX62W9htOAvwMo4/bXKDrQ+vom1L1qRuexPock/7VZDAhnpHCLNejd3NJ6hiab+tO0D44Rgw==}
|
||||
|
||||
'@tailwindcss/node@4.2.2':
|
||||
resolution: {integrity: sha512-pXS+wJ2gZpVXqFaUEjojq7jzMpTGf8rU6ipJz5ovJV6PUGmlJ+jvIwGrzdHdQ80Sg+wmQxUFuoW1UAAwHNEdFA==}
|
||||
|
||||
'@tailwindcss/oxide-android-arm64@4.2.2':
|
||||
resolution: {integrity: sha512-dXGR1n+P3B6748jZO/SvHZq7qBOqqzQ+yFrXpoOWWALWndF9MoSKAT3Q0fYgAzYzGhxNYOoysRvYlpixRBBoDg==}
|
||||
engines: {node: '>= 20'}
|
||||
cpu: [arm64]
|
||||
os: [android]
|
||||
|
||||
'@tailwindcss/oxide-darwin-arm64@4.2.2':
|
||||
resolution: {integrity: sha512-iq9Qjr6knfMpZHj55/37ouZeykwbDqF21gPFtfnhCCKGDcPI/21FKC9XdMO/XyBM7qKORx6UIhGgg6jLl7BZlg==}
|
||||
engines: {node: '>= 20'}
|
||||
cpu: [arm64]
|
||||
os: [darwin]
|
||||
|
||||
'@tailwindcss/oxide-darwin-x64@4.2.2':
|
||||
resolution: {integrity: sha512-BlR+2c3nzc8f2G639LpL89YY4bdcIdUmiOOkv2GQv4/4M0vJlpXEa0JXNHhCHU7VWOKWT/CjqHdTP8aUuDJkuw==}
|
||||
engines: {node: '>= 20'}
|
||||
cpu: [x64]
|
||||
os: [darwin]
|
||||
|
||||
'@tailwindcss/oxide-freebsd-x64@4.2.2':
|
||||
resolution: {integrity: sha512-YUqUgrGMSu2CDO82hzlQ5qSb5xmx3RUrke/QgnoEx7KvmRJHQuZHZmZTLSuuHwFf0DJPybFMXMYf+WJdxHy/nQ==}
|
||||
engines: {node: '>= 20'}
|
||||
cpu: [x64]
|
||||
os: [freebsd]
|
||||
|
||||
'@tailwindcss/oxide-linux-arm-gnueabihf@4.2.2':
|
||||
resolution: {integrity: sha512-FPdhvsW6g06T9BWT0qTwiVZYE2WIFo2dY5aCSpjG/S/u1tby+wXoslXS0kl3/KXnULlLr1E3NPRRw0g7t2kgaQ==}
|
||||
engines: {node: '>= 20'}
|
||||
cpu: [arm]
|
||||
os: [linux]
|
||||
|
||||
'@tailwindcss/oxide-linux-arm64-gnu@4.2.2':
|
||||
resolution: {integrity: sha512-4og1V+ftEPXGttOO7eCmW7VICmzzJWgMx+QXAJRAhjrSjumCwWqMfkDrNu1LXEQzNAwz28NCUpucgQPrR4S2yw==}
|
||||
engines: {node: '>= 20'}
|
||||
cpu: [arm64]
|
||||
os: [linux]
|
||||
libc: [glibc]
|
||||
|
||||
'@tailwindcss/oxide-linux-arm64-musl@4.2.2':
|
||||
resolution: {integrity: sha512-oCfG/mS+/+XRlwNjnsNLVwnMWYH7tn/kYPsNPh+JSOMlnt93mYNCKHYzylRhI51X+TbR+ufNhhKKzm6QkqX8ag==}
|
||||
engines: {node: '>= 20'}
|
||||
cpu: [arm64]
|
||||
os: [linux]
|
||||
libc: [musl]
|
||||
|
||||
'@tailwindcss/oxide-linux-x64-gnu@4.2.2':
|
||||
resolution: {integrity: sha512-rTAGAkDgqbXHNp/xW0iugLVmX62wOp2PoE39BTCGKjv3Iocf6AFbRP/wZT/kuCxC9QBh9Pu8XPkv/zCZB2mcMg==}
|
||||
engines: {node: '>= 20'}
|
||||
cpu: [x64]
|
||||
os: [linux]
|
||||
libc: [glibc]
|
||||
|
||||
'@tailwindcss/oxide-linux-x64-musl@4.2.2':
|
||||
resolution: {integrity: sha512-XW3t3qwbIwiSyRCggeO2zxe3KWaEbM0/kW9e8+0XpBgyKU4ATYzcVSMKteZJ1iukJ3HgHBjbg9P5YPRCVUxlnQ==}
|
||||
engines: {node: '>= 20'}
|
||||
cpu: [x64]
|
||||
os: [linux]
|
||||
libc: [musl]
|
||||
|
||||
'@tailwindcss/oxide-wasm32-wasi@4.2.2':
|
||||
resolution: {integrity: sha512-eKSztKsmEsn1O5lJ4ZAfyn41NfG7vzCg496YiGtMDV86jz1q/irhms5O0VrY6ZwTUkFy/EKG3RfWgxSI3VbZ8Q==}
|
||||
engines: {node: '>=14.0.0'}
|
||||
cpu: [wasm32]
|
||||
bundledDependencies:
|
||||
- '@napi-rs/wasm-runtime'
|
||||
- '@emnapi/core'
|
||||
- '@emnapi/runtime'
|
||||
- '@tybys/wasm-util'
|
||||
- '@emnapi/wasi-threads'
|
||||
- tslib
|
||||
|
||||
'@tailwindcss/oxide-win32-arm64-msvc@4.2.2':
|
||||
resolution: {integrity: sha512-qPmaQM4iKu5mxpsrWZMOZRgZv1tOZpUm+zdhhQP0VhJfyGGO3aUKdbh3gDZc/dPLQwW4eSqWGrrcWNBZWUWaXQ==}
|
||||
engines: {node: '>= 20'}
|
||||
cpu: [arm64]
|
||||
os: [win32]
|
||||
|
||||
'@tailwindcss/oxide-win32-x64-msvc@4.2.2':
|
||||
resolution: {integrity: sha512-1T/37VvI7WyH66b+vqHj/cLwnCxt7Qt3WFu5Q8hk65aOvlwAhs7rAp1VkulBJw/N4tMirXjVnylTR72uI0HGcA==}
|
||||
engines: {node: '>= 20'}
|
||||
cpu: [x64]
|
||||
os: [win32]
|
||||
|
||||
'@tailwindcss/oxide@4.2.2':
|
||||
resolution: {integrity: sha512-qEUA07+E5kehxYp9BVMpq9E8vnJuBHfJEC0vPC5e7iL/hw7HR61aDKoVoKzrG+QKp56vhNZe4qwkRmMC0zDLvg==}
|
||||
engines: {node: '>= 20'}
|
||||
|
||||
'@tailwindcss/vite@4.2.2':
|
||||
resolution: {integrity: sha512-mEiF5HO1QqCLXoNEfXVA1Tzo+cYsrqV7w9Juj2wdUFyW07JRenqMG225MvPwr3ZD9N1bFQj46X7r33iHxLUW0w==}
|
||||
peerDependencies:
|
||||
vite: ^5.2.0 || ^6 || ^7 || ^8
|
||||
|
||||
'@tanstack/virtual-core@3.17.9':
|
||||
resolution: {integrity: sha512-M8Bzy7CCMvUjRiuoHVH9mRjyUVczRs8v8RcUEphLFGc445ZP4KQ15Y1sLqhQqJi/HgGJrxfCHnEnIX0x9mVrBg==}
|
||||
|
||||
@@ -575,6 +462,9 @@ packages:
|
||||
'@tybys/wasm-util@0.10.1':
|
||||
resolution: {integrity: sha512-9tTaPJLSiejZKx+Bmog4uSubteqTvFrVrURwkmHixBo0G4seD0zUxp98E1DzUBJxLQ3NPwXrGKDiVjwx/DpPsg==}
|
||||
|
||||
'@types/trusted-types@2.0.7':
|
||||
resolution: {integrity: sha512-ScaPdn1dQczgbl0QFTeTOmVHFULt394XJgOQNoyVhZ6r2vLnMLJfBPd53SB52T/3G36VI1/g2MZaX0cwDuXsfw==}
|
||||
|
||||
'@vitejs/plugin-vue@6.0.5':
|
||||
resolution: {integrity: sha512-bL3AxKuQySfk1iGcBsQnoRVexTPJq0Z/ixFVM8OhVJAP6ZXXXLtM7NFKWhLl30Kg7uTBqIaPXbh+nuQCuBDedg==}
|
||||
engines: {node: ^20.19.0 || >=22.12.0}
|
||||
@@ -710,13 +600,6 @@ packages:
|
||||
buffer@6.0.3:
|
||||
resolution: {integrity: sha512-FTiCpNxtwiZZHEZbcbTIcZjERVICn9yq/pDFkTl95/AxzD1naBctN7YO68riM/gLSDY7sdrMby8hofADYuuqOA==}
|
||||
|
||||
class-variance-authority@0.7.1:
|
||||
resolution: {integrity: sha512-Ka+9Trutv7G8M6WT6SeiRWz792K5qEqIGEGzXKhAE6xOWAY6pPH8U+9IY3oCMv6kqTmLsv7Xh/2w2RigkePMsg==}
|
||||
|
||||
clsx@2.1.1:
|
||||
resolution: {integrity: sha512-eYm0QWBtUrBWZWG0d386OGAw16Z995PiOVo2B7bjWSbHedGl5e0ZWaq65kOGgUSNesEIDkB9ISbTg/JK9dhCZA==}
|
||||
engines: {node: '>=6'}
|
||||
|
||||
color-convert@2.0.1:
|
||||
resolution: {integrity: sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==}
|
||||
engines: {node: '>=7.0.0'}
|
||||
@@ -760,10 +643,6 @@ packages:
|
||||
emoji-regex@9.2.2:
|
||||
resolution: {integrity: sha512-L18DaJsXSUk2+42pv8mLs5jJT2hqFkFE4j21wOmgbUqsZ2hL72NsUU785g9RXgo3s0ZNgVl42TiHp3ZtOv/Vyg==}
|
||||
|
||||
enhanced-resolve@5.20.1:
|
||||
resolution: {integrity: sha512-Qohcme7V1inbAfvjItgw0EaxVX5q2rdVEZHRBrEQdRZTssLDGsL8Lwrznl8oQ/6kuTJONLaDcGjkNP247XEhcA==}
|
||||
engines: {node: '>=10.13.0'}
|
||||
|
||||
entities@4.5.0:
|
||||
resolution: {integrity: sha512-V0hjH4dGPh9Ao5p0MoRY6BVqtwCjhz6vI5LT8AJ55H+4g9/4vbHx1I54fS0XuclLhDHArPQCiMjDxjaL8fPxhw==}
|
||||
engines: {node: '>=0.12'}
|
||||
@@ -925,6 +804,15 @@ packages:
|
||||
linkify-it@5.0.0:
|
||||
resolution: {integrity: sha512-5aHCbzQRADcdP+ATqnDuhhJ/MRIqDkZX5pyjFHRRysS8vZ5AbqGEoFIb6pYHPZ+L/OC2Lc+xT8uHVVR5CAK/wQ==}
|
||||
|
||||
lit-element@4.2.2:
|
||||
resolution: {integrity: sha512-aFKhNToWxoyhkNDmWZwEva2SlQia+jfG0fjIWV//YeTaWrVnOxD89dPKfigCUspXFmjzOEUQpOkejH5Ly6sG0w==}
|
||||
|
||||
lit-html@3.3.3:
|
||||
resolution: {integrity: sha512-el8M6jK2o3RXBnrSHX3ZKrsN8zEV63pSExTO1wYJz7QndGYZ8353e2a5PPX+qHe2aGayfnchQmkAojaWAREOIA==}
|
||||
|
||||
lit@3.3.3:
|
||||
resolution: {integrity: sha512-fycuvZg/hkpozL00lm1pEJH5nN/lr9ZXd6mJI2HSN4+Bzc+LDNdEApJ6HFbPkdFNHLvOplIIuJvxkS4XUxqirw==}
|
||||
|
||||
lodash@4.18.1:
|
||||
resolution: {integrity: sha512-dMInicTPVE8d1e5otfwmmjlxkZoUpiVLwyeTdUsi/Caj/gfzzblBcCE5sRHV/AsjuCmxWrte2TNGSYuCeCq+0Q==}
|
||||
|
||||
@@ -937,9 +825,6 @@ packages:
|
||||
peerDependencies:
|
||||
vue: '>=3.0.1'
|
||||
|
||||
lucide@1.7.0:
|
||||
resolution: {integrity: sha512-aYNogbuIxea3a8offpKjdMGf2FsUk9GECFh0B4iJgXlJOX41+7/ncvLVluKki8477SoybEdyGGf+qGYLBDiEsA==}
|
||||
|
||||
magic-string@0.30.21:
|
||||
resolution: {integrity: sha512-vd2F4YUyEXKGcLHoq+TEyCjxueSeHnFxyyjNp80yg0XV4vUhnDer/lvvlqM/arB5bXQN5K2/3oinyCRyx8T2CQ==}
|
||||
|
||||
@@ -1084,16 +969,6 @@ packages:
|
||||
resolution: {integrity: sha512-yDPMNjp4WyfYBkHnjIRLfca1i6KMyGCtsVgoKe/z1+6vukgaENdgGBZt+ZmKPc4gavvEZ5OgHfHdrazhgNyG7w==}
|
||||
engines: {node: '>=12'}
|
||||
|
||||
tailwind-merge@3.5.0:
|
||||
resolution: {integrity: sha512-I8K9wewnVDkL1NTGoqWmVEIlUcB9gFriAEkXkfCjX5ib8ezGxtR3xD7iZIxrfArjEsH7F1CHD4RFUtxefdqV/A==}
|
||||
|
||||
tailwindcss@4.2.2:
|
||||
resolution: {integrity: sha512-KWBIxs1Xb6NoLdMVqhbhgwZf2PGBpPEiwOqgI4pFIYbNTfBXiKYyWoTsXgBQ9WFg/OlhnvHaY+AEpW7wSmFo2Q==}
|
||||
|
||||
tapable@2.3.2:
|
||||
resolution: {integrity: sha512-1MOpMXuhGzGL5TTCZFItxCc0AARf1EZFQkGqMm7ERKj8+Hgr5oLvJOVFcC+lRmR8hCe2S3jC4T5D7Vg/d7/fhA==}
|
||||
engines: {node: '>=6'}
|
||||
|
||||
tar-stream@3.1.8:
|
||||
resolution: {integrity: sha512-U6QpVRyCGHva435KoNWy9PRoi2IFYCgtEhq9nmrPPpbRacPs9IH4aJ3gbrFC8dPcXvdSZ4XXfXT5Fshbp2MtlQ==}
|
||||
|
||||
@@ -1114,9 +989,6 @@ packages:
|
||||
tslib@2.8.1:
|
||||
resolution: {integrity: sha512-oJFu94HQb+KVduSUQL7wnpmqnfmLsOA/nAh6b6EH0wCEoK0/mPeXU6c3wKDV83MkOuHPRHtSXKKU99IBazS/2w==}
|
||||
|
||||
tw-animate-css@1.4.0:
|
||||
resolution: {integrity: sha512-7bziOlRqH0hJx80h/3mbicLW7o8qLsH5+RaLR2t+OHM3D0JlWGODQKQ4cxbK7WlvmUxpcj6Kgu6EKqjrGFe3QQ==}
|
||||
|
||||
uc.micro@2.1.0:
|
||||
resolution: {integrity: sha512-ARDJmphmdvUk6Glw7y9DQ2bFkKBHwQHLi2lsaH6PPmz/Ka9sFOBsBluozhDltWmnv9u/cF6Rt87znRTPV+yp/A==}
|
||||
|
||||
@@ -1231,24 +1103,23 @@ snapshots:
|
||||
wrap-ansi: 8.1.0
|
||||
wrap-ansi-cjs: wrap-ansi@7.0.0
|
||||
|
||||
'@jridgewell/gen-mapping@0.3.13':
|
||||
dependencies:
|
||||
'@jridgewell/sourcemap-codec': 1.5.5
|
||||
'@jridgewell/trace-mapping': 0.3.31
|
||||
|
||||
'@jridgewell/remapping@2.3.5':
|
||||
dependencies:
|
||||
'@jridgewell/gen-mapping': 0.3.13
|
||||
'@jridgewell/trace-mapping': 0.3.31
|
||||
|
||||
'@jridgewell/resolve-uri@3.1.2': {}
|
||||
|
||||
'@jridgewell/sourcemap-codec@1.5.5': {}
|
||||
|
||||
'@jridgewell/trace-mapping@0.3.31':
|
||||
'@lit-labs/ssr-dom-shim@1.6.0': {}
|
||||
|
||||
'@lit/context@1.1.6':
|
||||
dependencies:
|
||||
'@jridgewell/resolve-uri': 3.1.2
|
||||
'@jridgewell/sourcemap-codec': 1.5.5
|
||||
'@lit/reactive-element': 2.1.2
|
||||
|
||||
'@lit/reactive-element@2.1.2':
|
||||
dependencies:
|
||||
'@lit-labs/ssr-dom-shim': 1.6.0
|
||||
|
||||
'@material/web@2.5.0':
|
||||
dependencies:
|
||||
'@lit/context': 1.1.6
|
||||
lit: 3.3.3
|
||||
tslib: 2.8.1
|
||||
|
||||
'@napi-rs/wasm-runtime@1.1.2(@emnapi/core@1.9.2)(@emnapi/runtime@1.9.2)':
|
||||
dependencies:
|
||||
@@ -1430,74 +1301,6 @@ snapshots:
|
||||
|
||||
'@rolldown/pluginutils@1.0.0-rc.2': {}
|
||||
|
||||
'@tailwindcss/node@4.2.2':
|
||||
dependencies:
|
||||
'@jridgewell/remapping': 2.3.5
|
||||
enhanced-resolve: 5.20.1
|
||||
jiti: 2.6.1
|
||||
lightningcss: 1.32.0
|
||||
magic-string: 0.30.21
|
||||
source-map-js: 1.2.1
|
||||
tailwindcss: 4.2.2
|
||||
|
||||
'@tailwindcss/oxide-android-arm64@4.2.2':
|
||||
optional: true
|
||||
|
||||
'@tailwindcss/oxide-darwin-arm64@4.2.2':
|
||||
optional: true
|
||||
|
||||
'@tailwindcss/oxide-darwin-x64@4.2.2':
|
||||
optional: true
|
||||
|
||||
'@tailwindcss/oxide-freebsd-x64@4.2.2':
|
||||
optional: true
|
||||
|
||||
'@tailwindcss/oxide-linux-arm-gnueabihf@4.2.2':
|
||||
optional: true
|
||||
|
||||
'@tailwindcss/oxide-linux-arm64-gnu@4.2.2':
|
||||
optional: true
|
||||
|
||||
'@tailwindcss/oxide-linux-arm64-musl@4.2.2':
|
||||
optional: true
|
||||
|
||||
'@tailwindcss/oxide-linux-x64-gnu@4.2.2':
|
||||
optional: true
|
||||
|
||||
'@tailwindcss/oxide-linux-x64-musl@4.2.2':
|
||||
optional: true
|
||||
|
||||
'@tailwindcss/oxide-wasm32-wasi@4.2.2':
|
||||
optional: true
|
||||
|
||||
'@tailwindcss/oxide-win32-arm64-msvc@4.2.2':
|
||||
optional: true
|
||||
|
||||
'@tailwindcss/oxide-win32-x64-msvc@4.2.2':
|
||||
optional: true
|
||||
|
||||
'@tailwindcss/oxide@4.2.2':
|
||||
optionalDependencies:
|
||||
'@tailwindcss/oxide-android-arm64': 4.2.2
|
||||
'@tailwindcss/oxide-darwin-arm64': 4.2.2
|
||||
'@tailwindcss/oxide-darwin-x64': 4.2.2
|
||||
'@tailwindcss/oxide-freebsd-x64': 4.2.2
|
||||
'@tailwindcss/oxide-linux-arm-gnueabihf': 4.2.2
|
||||
'@tailwindcss/oxide-linux-arm64-gnu': 4.2.2
|
||||
'@tailwindcss/oxide-linux-arm64-musl': 4.2.2
|
||||
'@tailwindcss/oxide-linux-x64-gnu': 4.2.2
|
||||
'@tailwindcss/oxide-linux-x64-musl': 4.2.2
|
||||
'@tailwindcss/oxide-wasm32-wasi': 4.2.2
|
||||
'@tailwindcss/oxide-win32-arm64-msvc': 4.2.2
|
||||
'@tailwindcss/oxide-win32-x64-msvc': 4.2.2
|
||||
|
||||
'@tailwindcss/vite@4.2.2(vite@8.0.3(@emnapi/core@1.9.2)(@emnapi/runtime@1.9.2)(jiti@2.6.1))':
|
||||
dependencies:
|
||||
'@tailwindcss/node': 4.2.2
|
||||
'@tailwindcss/oxide': 4.2.2
|
||||
tailwindcss: 4.2.2
|
||||
vite: 8.0.3(@emnapi/core@1.9.2)(@emnapi/runtime@1.9.2)(jiti@2.6.1)
|
||||
|
||||
'@tanstack/virtual-core@3.17.9': {}
|
||||
|
||||
'@tanstack/vue-virtual@3.13.37(vue@3.5.32)':
|
||||
@@ -1510,6 +1313,8 @@ snapshots:
|
||||
tslib: 2.8.1
|
||||
optional: true
|
||||
|
||||
'@types/trusted-types@2.0.7': {}
|
||||
|
||||
'@vitejs/plugin-vue@6.0.5(vite@8.0.3(@emnapi/core@1.9.2)(@emnapi/runtime@1.9.2)(jiti@2.6.1))(vue@3.5.32)':
|
||||
dependencies:
|
||||
'@rolldown/pluginutils': 1.0.0-rc.2
|
||||
@@ -1661,12 +1466,6 @@ snapshots:
|
||||
base64-js: 1.5.1
|
||||
ieee754: 1.2.1
|
||||
|
||||
class-variance-authority@0.7.1:
|
||||
dependencies:
|
||||
clsx: 2.1.1
|
||||
|
||||
clsx@2.1.1: {}
|
||||
|
||||
color-convert@2.0.1:
|
||||
dependencies:
|
||||
color-name: 1.1.4
|
||||
@@ -1706,11 +1505,6 @@ snapshots:
|
||||
|
||||
emoji-regex@9.2.2: {}
|
||||
|
||||
enhanced-resolve@5.20.1:
|
||||
dependencies:
|
||||
graceful-fs: 4.2.11
|
||||
tapable: 2.3.2
|
||||
|
||||
entities@4.5.0: {}
|
||||
|
||||
entities@7.0.1: {}
|
||||
@@ -1770,7 +1564,8 @@ snapshots:
|
||||
optionalDependencies:
|
||||
'@pkgjs/parseargs': 0.11.0
|
||||
|
||||
jiti@2.6.1: {}
|
||||
jiti@2.6.1:
|
||||
optional: true
|
||||
|
||||
kernelsu@3.0.2: {}
|
||||
|
||||
@@ -1831,6 +1626,22 @@ snapshots:
|
||||
dependencies:
|
||||
uc.micro: 2.1.0
|
||||
|
||||
lit-element@4.2.2:
|
||||
dependencies:
|
||||
'@lit-labs/ssr-dom-shim': 1.6.0
|
||||
'@lit/reactive-element': 2.1.2
|
||||
lit-html: 3.3.3
|
||||
|
||||
lit-html@3.3.3:
|
||||
dependencies:
|
||||
'@types/trusted-types': 2.0.7
|
||||
|
||||
lit@3.3.3:
|
||||
dependencies:
|
||||
'@lit/reactive-element': 2.1.2
|
||||
lit-element: 4.2.2
|
||||
lit-html: 3.3.3
|
||||
|
||||
lodash@4.18.1: {}
|
||||
|
||||
lru-cache@10.4.3: {}
|
||||
@@ -1839,8 +1650,6 @@ snapshots:
|
||||
dependencies:
|
||||
vue: 3.5.32
|
||||
|
||||
lucide@1.7.0: {}
|
||||
|
||||
magic-string@0.30.21:
|
||||
dependencies:
|
||||
'@jridgewell/sourcemap-codec': 1.5.5
|
||||
@@ -2040,12 +1849,6 @@ snapshots:
|
||||
dependencies:
|
||||
ansi-regex: 6.2.2
|
||||
|
||||
tailwind-merge@3.5.0: {}
|
||||
|
||||
tailwindcss@4.2.2: {}
|
||||
|
||||
tapable@2.3.2: {}
|
||||
|
||||
tar-stream@3.1.8:
|
||||
dependencies:
|
||||
b4a: 1.8.0
|
||||
@@ -2077,10 +1880,7 @@ snapshots:
|
||||
|
||||
tinypool@2.1.0: {}
|
||||
|
||||
tslib@2.8.1:
|
||||
optional: true
|
||||
|
||||
tw-animate-css@1.4.0: {}
|
||||
tslib@2.8.1: {}
|
||||
|
||||
uc.micro@2.1.0: {}
|
||||
|
||||
|
||||
@@ -1,20 +0,0 @@
|
||||
{
|
||||
"$schema": "https://shadcn-vue.com/schema.json",
|
||||
"style": "default",
|
||||
"typescript": false,
|
||||
"tailwind": {
|
||||
"config": "",
|
||||
"css": "src/index.css",
|
||||
"baseColor": "slate",
|
||||
"cssVariables": true,
|
||||
"prefix": ""
|
||||
},
|
||||
"aliases": {
|
||||
"components": "@/components",
|
||||
"utils": "@/lib/utils",
|
||||
"ui": "@/components/ui",
|
||||
"lib": "@/lib",
|
||||
"composables": "@/composables"
|
||||
},
|
||||
"registries": []
|
||||
}
|
||||
+96
-197
@@ -1,12 +1,17 @@
|
||||
<script setup>
|
||||
import { ref, computed, provide, onMounted, onUnmounted, watch, nextTick } from 'vue'
|
||||
import { moduleInfo } from 'kernelsu'
|
||||
import { runCmd, showToast } from './utils.js'
|
||||
import { ref, computed, provide, onMounted, onUnmounted, watch } from 'vue'
|
||||
import { useStatus } from './composables/useStatus.js'
|
||||
import { useConfig } from './composables/useConfig.js'
|
||||
import { useLog } from './composables/useLog.js'
|
||||
import { useOplock } from './composables/useOplock.js'
|
||||
import BottomNav from './components/BottomNav.vue'
|
||||
import { useApps } from './composables/useApps.js'
|
||||
import { useSnackbar, useWebUIPrefs } from './composables/useSnackbar.js'
|
||||
import { moduleVersion } from './api/ksu.js'
|
||||
|
||||
import AppTopBar from './components/AppTopBar.vue'
|
||||
import AppBottomNav from './components/AppBottomNav.vue'
|
||||
import SnackbarHost from './components/SnackbarHost.vue'
|
||||
import OpLockBanner from './components/OpLockBanner.vue'
|
||||
|
||||
import StatusView from './views/StatusView.vue'
|
||||
import ConfigView from './views/ConfigView.vue'
|
||||
import AppsView from './views/AppsView.vue'
|
||||
@@ -15,225 +20,123 @@ import AboutView from './views/AboutView.vue'
|
||||
|
||||
const NAV_ORDER = ['status', 'config', 'apps', 'log', 'about']
|
||||
const currentView = ref('status')
|
||||
const headerEl = ref(null)
|
||||
const headerHidden = ref(false)
|
||||
// 操作锁横幅实测高度,用于把 header 与页面内容整体下移,避免被横幅遮挡
|
||||
const bannerEl = ref(null)
|
||||
const oplockOffset = ref('0px')
|
||||
const scrolled = ref(false)
|
||||
const version = ref(moduleVersion())
|
||||
|
||||
const trackStyle = computed(() => {
|
||||
const idx = NAV_ORDER.indexOf(currentView.value)
|
||||
return { transform: `translateX(${-idx * 100}%)` }
|
||||
})
|
||||
const moduleVersion = ref('')
|
||||
// 通道徽标:版本号里带 -beta / -dev 即为对应通道(打包时写入)
|
||||
const channelBadge = computed(() => {
|
||||
const v = moduleVersion.value.toLowerCase()
|
||||
if (v.includes('-beta')) return 'Beta'
|
||||
if (v.includes('-dev')) return 'Dev'
|
||||
return ''
|
||||
})
|
||||
const snackbar = useSnackbar()
|
||||
const status = useStatus()
|
||||
const config = useConfig()
|
||||
const log = useLog()
|
||||
const oplock = useOplock()
|
||||
const apps = useApps()
|
||||
const prefs = useWebUIPrefs()
|
||||
|
||||
// 供子组件使用
|
||||
provide('showToast', showToast)
|
||||
provide('snackbar', snackbar.show)
|
||||
provide('status', status)
|
||||
provide('config', config)
|
||||
provide('log', log)
|
||||
provide('oplock', oplock)
|
||||
provide('apps', apps)
|
||||
provide('prefs', prefs)
|
||||
|
||||
// 操作锁探测间隔:锁定期间用短间隔以便尽快感知结束;自动刷新关闭时用较轻的空闲间隔
|
||||
const trackStyle = computed(() => ({
|
||||
transform: `translateX(${-NAV_ORDER.indexOf(currentView.value) * 100}%)`,
|
||||
}))
|
||||
const locked = computed(() => status.oplock.value.locked)
|
||||
|
||||
// ── 刷新循环 ────────────────────────────────────────────────────────
|
||||
// 锁定期间只轮询操作锁(轻量),解锁后按用户频率刷新状态与日志;
|
||||
// dumpsys/settings 每 N 次完整刷新才读一次,避免无谓开销。
|
||||
const LOCK_POLL_INTERVAL = 300
|
||||
const LOCK_IDLE_INTERVAL = 2000
|
||||
let refreshTimer = null
|
||||
let refreshStopped = false
|
||||
let _prevLocked = false
|
||||
const DISPLAY_EVERY = 5
|
||||
let timer = null
|
||||
let stopped = false
|
||||
let ticks = 0
|
||||
|
||||
function startRefresh() {
|
||||
stopRefresh()
|
||||
refreshStopped = false
|
||||
refreshTimer = setTimeout(tick, config.statusRefreshInterval.value)
|
||||
}
|
||||
|
||||
function stopRefresh() {
|
||||
refreshStopped = true
|
||||
if (refreshTimer) {
|
||||
clearTimeout(refreshTimer)
|
||||
refreshTimer = null
|
||||
}
|
||||
function schedule(ms) {
|
||||
timer = setTimeout(tick, ms)
|
||||
}
|
||||
|
||||
async function tick() {
|
||||
refreshTimer = null
|
||||
if (refreshStopped) return
|
||||
timer = null
|
||||
if (stopped) return
|
||||
|
||||
let locked = false
|
||||
try {
|
||||
locked = await oplock.refresh()
|
||||
} catch {}
|
||||
|
||||
if (locked) {
|
||||
// 锁定期间不刷新数据,仅以更短间隔探测锁释放
|
||||
_prevLocked = true
|
||||
refreshTimer = setTimeout(tick, LOCK_POLL_INTERVAL)
|
||||
await status.refreshOplock()
|
||||
if (status.oplock.value.locked) {
|
||||
schedule(LOCK_POLL_INTERVAL)
|
||||
return
|
||||
}
|
||||
|
||||
// 锁刚释放时强制全量刷新,否则亮度值会停留在操作前的旧值
|
||||
try {
|
||||
if (config.autoRefresh.value) {
|
||||
await Promise.all([status.load(_prevLocked), log.load()])
|
||||
} else if (_prevLocked) {
|
||||
await status.load(true)
|
||||
}
|
||||
} catch {}
|
||||
_prevLocked = false
|
||||
|
||||
const next = config.autoRefresh.value ? config.statusRefreshInterval.value : LOCK_IDLE_INTERVAL
|
||||
refreshTimer = setTimeout(tick, next)
|
||||
ticks += 1
|
||||
const withDisplay = ticks % DISPLAY_EVERY === 1
|
||||
await Promise.all([status.load({ display: withDisplay }), log.load()])
|
||||
schedule(Math.max(200, prefs.refreshInterval.value))
|
||||
}
|
||||
|
||||
function restartRefresh(enabled, interval) {
|
||||
config.autoRefresh.value = enabled
|
||||
config.statusRefreshInterval.value = interval
|
||||
startRefresh()
|
||||
function startRefresh() {
|
||||
stopRefresh()
|
||||
stopped = false
|
||||
schedule(Math.max(200, prefs.refreshInterval.value))
|
||||
}
|
||||
provide('restartRefresh', restartRefresh)
|
||||
|
||||
// 横幅出现/消失时测量其高度,作为 header 与页面内容的下移量
|
||||
watch(oplock.isLocked, async (locked) => {
|
||||
await nextTick()
|
||||
oplockOffset.value = locked && bannerEl.value ? `${bannerEl.value.offsetHeight}px` : '0px'
|
||||
function stopRefresh() {
|
||||
stopped = true
|
||||
if (timer) {
|
||||
clearTimeout(timer)
|
||||
timer = null
|
||||
}
|
||||
}
|
||||
|
||||
async function manualRefresh() {
|
||||
await Promise.all([status.load({ display: true }), log.load()])
|
||||
snackbar.show('已刷新')
|
||||
}
|
||||
|
||||
function onPageScroll(event) {
|
||||
if (!event.target?.classList?.contains('page-slide')) return
|
||||
scrolled.value = event.target.scrollTop > 8
|
||||
}
|
||||
|
||||
function onViewChange(view) {
|
||||
currentView.value = view
|
||||
scrolled.value = false
|
||||
const slides = document.querySelectorAll('.page-slide')
|
||||
const slide = slides[NAV_ORDER.indexOf(view)]
|
||||
if (slide) slide.scrollTop = 0
|
||||
}
|
||||
|
||||
// 应用列表较慢,首次进入黑名单页再加载
|
||||
watch(currentView, (view) => {
|
||||
if (view === 'apps' && apps.apps.value.length === 0 && !apps.isLoading.value) apps.load()
|
||||
})
|
||||
|
||||
// 跟随系统色彩偏好变化
|
||||
let _mq = null
|
||||
function _onSystemTheme() {
|
||||
if (config.themeMode.value === 'system') config.applyTheme('system')
|
||||
}
|
||||
|
||||
onMounted(async () => {
|
||||
// 应用 UI 缩放 + 主题
|
||||
config.applyZoom()
|
||||
config.applyTheme(config.themeMode.value)
|
||||
_mq = window.matchMedia('(prefers-color-scheme: light)')
|
||||
_mq.addEventListener('change', _onSystemTheme)
|
||||
|
||||
// 读取模块版本
|
||||
try {
|
||||
const info = JSON.parse(moduleInfo())
|
||||
moduleVersion.value = info.version || ''
|
||||
} catch {
|
||||
moduleVersion.value = '[debug]'
|
||||
}
|
||||
|
||||
window.removeEventListener('scroll', onPageScroll)
|
||||
|
||||
// 测量 header 高度,用于隐藏时 viewport 补位
|
||||
if (headerEl.value) {
|
||||
const h = headerEl.value.offsetHeight
|
||||
const appEl = document.getElementById('app')
|
||||
if (appEl) appEl.style.setProperty('--header-height', h + 'px')
|
||||
}
|
||||
|
||||
// 初始加载
|
||||
try {
|
||||
await Promise.all([status.load(true), config.load(), log.load()])
|
||||
} catch {}
|
||||
|
||||
prefs.applyZoom()
|
||||
prefs.applyTheme(prefs.themeMode.value)
|
||||
await Promise.all([status.load({ display: true }), config.load(), log.load()])
|
||||
startRefresh()
|
||||
})
|
||||
|
||||
onUnmounted(() => {
|
||||
stopRefresh()
|
||||
_mq?.removeEventListener('change', _onSystemTheme)
|
||||
})
|
||||
|
||||
function onPageScroll(e) {
|
||||
// 只响应 .page-slide 的滚动,忽略内部子滚动容器(如应用列表)
|
||||
if (!e.target.classList.contains('page-slide')) return
|
||||
const topBlur = document.querySelector('.top-blur')
|
||||
const { scrollTop } = e.target
|
||||
if (topBlur) topBlur.classList.toggle('scrolled', scrollTop > 10)
|
||||
headerHidden.value = scrollTop > 0
|
||||
}
|
||||
|
||||
function handleViewChange(view) {
|
||||
currentView.value = view
|
||||
headerHidden.value = false // 切换页面时恢复显示 header
|
||||
|
||||
const idx = NAV_ORDER.indexOf(view)
|
||||
const slides = document.querySelectorAll('.page-slide')
|
||||
const slide = slides[idx]
|
||||
|
||||
// 切换页面时回顶
|
||||
if (slide) slide.scrollTop = 0
|
||||
|
||||
// 切换后 top-blur 跟随新页面状态(已回顶故一定为 false)
|
||||
const topBlur = document.querySelector('.top-blur')
|
||||
if (topBlur) topBlur.classList.remove('scrolled')
|
||||
}
|
||||
onUnmounted(stopRefresh)
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="min-h-screen bg-background text-foreground">
|
||||
<!-- 顶部状态栏渐变模糊 -->
|
||||
<div class="top-blur"></div>
|
||||
<AppTopBar
|
||||
:version="version"
|
||||
:status-text="status.statusText.value"
|
||||
:status-class="status.statusClass.value"
|
||||
:paused="status.isPaused.value"
|
||||
:locked="locked"
|
||||
:scrolled="scrolled"
|
||||
@refresh="manualRefresh"
|
||||
@toggle-service="status.toggleService(snackbar.show)"
|
||||
@restart="status.restart(snackbar.show)"
|
||||
/>
|
||||
|
||||
<div
|
||||
id="app"
|
||||
:class="{ 'header-hidden': headerHidden }"
|
||||
:style="{ '--oplock-offset': oplockOffset }"
|
||||
>
|
||||
<!-- 操作锁横幅 -->
|
||||
<Transition name="oplock-fade">
|
||||
<div v-if="oplock.isLocked.value" class="oplock-banner" role="status" ref="bannerEl">
|
||||
<span class="oplock-spinner"></span>
|
||||
<span>正在执行后台操作,已暂停刷新</span>
|
||||
</div>
|
||||
</Transition>
|
||||
<OpLockBanner
|
||||
:locked="locked"
|
||||
:label="status.oplock.value.label || '正在执行后台操作'"
|
||||
:seconds="status.oplock.value.seconds || 0"
|
||||
/>
|
||||
|
||||
<!-- 顶部头 -->
|
||||
<header class="app-header" ref="headerEl">
|
||||
<div class="header-content">
|
||||
<div class="header-text">
|
||||
<h1>LuminPro</h1>
|
||||
<p class="header-subtitle">日用屏幕亮度强化</p>
|
||||
<p class="header-version">
|
||||
{{ moduleVersion || 'V2.2' }}
|
||||
<span v-if="channelBadge" class="version-channel">{{ channelBadge }}</span>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="header-status-container">
|
||||
<div class="header-status" id="module-status" :class="status.statusClass.value">
|
||||
<span class="status-dot"></span>
|
||||
<span class="status-text">{{ status.statusText.value }}</span>
|
||||
</div>
|
||||
<div class="header-status-actions">
|
||||
<button
|
||||
class="btn-status-action"
|
||||
id="btn-toggle-service"
|
||||
@click="status.toggleService(showToast)"
|
||||
>
|
||||
{{ status.isPaused.value ? '启用' : '暂停' }}
|
||||
</button>
|
||||
<button
|
||||
class="btn-status-action"
|
||||
id="btn-restart-service"
|
||||
:disabled="oplock.isLocked.value"
|
||||
@click="status.restartService(showToast)"
|
||||
>
|
||||
重启模块
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</header>
|
||||
|
||||
<!-- 左右滑动页面区 -->
|
||||
<div class="page-viewport" @scroll.capture.passive="onPageScroll">
|
||||
<div class="page-track" :style="trackStyle">
|
||||
<div class="page-slide"><StatusView /></div>
|
||||
@@ -243,12 +146,8 @@ function handleViewChange(view) {
|
||||
<div class="page-slide"><AboutView /></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 底栏导航 -->
|
||||
<BottomNav v-model="currentView" @update:model-value="handleViewChange" />
|
||||
<AppBottomNav :model-value="currentView" @update:model-value="onViewChange" />
|
||||
|
||||
<!-- Toast (保持 id="toast" 供 utils.js showToast 使用) -->
|
||||
<div class="toast" id="toast"></div>
|
||||
</div>
|
||||
<SnackbarHost :messages="snackbar.messages.value" />
|
||||
</template>
|
||||
@@ -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;
|
||||
}
|
||||
@@ -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
|
||||
}
|
||||
@@ -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' : ''
|
||||
}
|
||||
}
|
||||
@@ -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 : ''
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
@@ -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 =
|
||||
'<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M18 6 6 18"/><path d="m6 6 12 12"/></svg>'
|
||||
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 =
|
||||
'<div style="text-align:center;padding:20px;color:var(--md-sys-color-on-surface-variant);">加载中...</div>'
|
||||
|
||||
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 =
|
||||
'<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="m6 9 6 6 6-6"/></svg>'
|
||||
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 =
|
||||
'<div style="text-align:center;padding:20px;color:var(--md-sys-color-on-surface-variant);">无应用</div>'
|
||||
}
|
||||
} catch (e) {
|
||||
container.innerHTML = `<div style="text-align:center;padding:20px;color:var(--md-sys-color-error);">加载失败: ${e.message || String(e)}</div>`
|
||||
}
|
||||
}
|
||||
|
||||
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 =
|
||||
'<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="m6 9 6 6 6-6"/></svg>'
|
||||
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()
|
||||
})
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
<script setup>
|
||||
import { ref, watch, nextTick } from 'vue'
|
||||
import { MoreVertical } from 'lucide-vue-next'
|
||||
|
||||
const props = defineProps({
|
||||
items: { type: Array, default: () => [] }, // [{ key, label }]
|
||||
title: { type: String, default: '更多' },
|
||||
disabled: { type: Boolean, default: false },
|
||||
})
|
||||
const emit = defineEmits(['select'])
|
||||
|
||||
const open = ref(false)
|
||||
const anchorEl = ref(null)
|
||||
const menuEl = ref(null)
|
||||
|
||||
async function toggle() {
|
||||
open.value = !open.value
|
||||
if (open.value) {
|
||||
await nextTick()
|
||||
// MWC 菜单需要通过属性接收锚点元素(不能用 attribute 绑定)
|
||||
if (menuEl.value && anchorEl.value) menuEl.value.anchor = anchorEl.value
|
||||
}
|
||||
}
|
||||
|
||||
function pick(item) {
|
||||
open.value = false
|
||||
setTimeout(() => emit('select', item.key), 0)
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<md-icon-button ref="anchorEl" :title="title" :disabled="disabled" @click="toggle">
|
||||
<MoreVertical :size="20" />
|
||||
</md-icon-button>
|
||||
<md-menu ref="menuEl" :open="open" @closed="open = false">
|
||||
<md-menu-item v-for="item in items" :key="item.key" @click="pick(item)">
|
||||
<span slot="headline">{{ item.label }}</span>
|
||||
</md-menu-item>
|
||||
</md-menu>
|
||||
</template>
|
||||
@@ -0,0 +1,31 @@
|
||||
<script setup>
|
||||
import { Activity, SlidersHorizontal, LayoutList, ScrollText, Info } from 'lucide-vue-next'
|
||||
|
||||
defineProps({
|
||||
modelValue: { type: String, required: true },
|
||||
})
|
||||
const emit = defineEmits(['update:modelValue'])
|
||||
|
||||
const tabs = [
|
||||
{ key: 'status', label: '状态', icon: Activity },
|
||||
{ key: 'config', label: '配置', icon: SlidersHorizontal },
|
||||
{ key: 'apps', label: '黑名单', icon: LayoutList },
|
||||
{ key: 'log', label: '日志', icon: ScrollText },
|
||||
{ key: 'about', label: '关于', icon: Info },
|
||||
]
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<md-navigation-bar>
|
||||
<md-navigation-tab
|
||||
v-for="tab in tabs"
|
||||
:key="tab.key"
|
||||
:label="tab.label"
|
||||
:active="modelValue === tab.key"
|
||||
@click="emit('update:modelValue', tab.key)"
|
||||
>
|
||||
<component :is="tab.icon" slot="active-icon" :size="24" />
|
||||
<component :is="tab.icon" slot="inactive-icon" :size="24" />
|
||||
</md-navigation-tab>
|
||||
</md-navigation-bar>
|
||||
</template>
|
||||
@@ -0,0 +1,28 @@
|
||||
<script setup>
|
||||
/** 设置行:左侧标题/说明 + 右侧 M3 开关 */
|
||||
defineProps({
|
||||
modelValue: { type: Boolean, default: false },
|
||||
name: { type: String, default: '' },
|
||||
support: { type: String, default: '' },
|
||||
warning: { type: String, default: '' },
|
||||
disabled: { type: Boolean, default: false },
|
||||
})
|
||||
const emit = defineEmits(['update:modelValue'])
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="row">
|
||||
<div class="row__labels">
|
||||
<span class="row__name">{{ name }}</span>
|
||||
<span v-if="support" class="row__support">{{ support }}</span>
|
||||
<span v-if="warning" class="row__support warning">{{ warning }}</span>
|
||||
</div>
|
||||
<div class="row__control">
|
||||
<md-switch
|
||||
:selected="modelValue"
|
||||
:disabled="disabled"
|
||||
@change="emit('update:modelValue', $event.target.selected)"
|
||||
></md-switch>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
@@ -0,0 +1,36 @@
|
||||
<script setup>
|
||||
/** md-outlined-text-field 的 v-model 封装(MWC 用属性而非 Vue props,需手动接线) */
|
||||
defineProps({
|
||||
modelValue: { type: [String, Number], default: '' },
|
||||
label: { type: String, default: '' },
|
||||
type: { type: String, default: 'text' },
|
||||
min: { type: [String, Number], default: undefined },
|
||||
max: { type: [String, Number], default: undefined },
|
||||
step: { type: [String, Number], default: undefined },
|
||||
supportingText: { type: String, default: '' },
|
||||
disabled: { type: Boolean, default: false },
|
||||
placeholder: { type: String, default: '' },
|
||||
})
|
||||
const emit = defineEmits(['update:modelValue'])
|
||||
|
||||
function onInput(event) {
|
||||
emit('update:modelValue', event.target.value)
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<md-outlined-text-field
|
||||
:label="label"
|
||||
:type="type"
|
||||
:value="modelValue"
|
||||
:min="min"
|
||||
:max="max"
|
||||
:step="step"
|
||||
:supporting-text="supportingText"
|
||||
:disabled="disabled"
|
||||
:placeholder="placeholder"
|
||||
autocomplete="off"
|
||||
spellcheck="false"
|
||||
@input="onInput"
|
||||
></md-outlined-text-field>
|
||||
</template>
|
||||
@@ -0,0 +1,59 @@
|
||||
<script setup>
|
||||
import { computed } from 'vue'
|
||||
import { RefreshCw, Pause, Play, RotateCw } from 'lucide-vue-next'
|
||||
|
||||
const props = defineProps({
|
||||
title: { type: String, default: 'LuminPro' },
|
||||
subtitle: { type: String, default: '' },
|
||||
version: { type: String, default: '' },
|
||||
statusText: { type: String, default: '—' },
|
||||
statusClass: { type: String, default: 'stopped' },
|
||||
paused: { type: Boolean, default: false },
|
||||
locked: { type: Boolean, default: false },
|
||||
scrolled: { type: Boolean, default: false },
|
||||
})
|
||||
|
||||
const emit = defineEmits(['refresh', 'toggle-service', 'restart'])
|
||||
|
||||
/** 通道徽标:版本号里带 -beta / -dev 即为对应通道 */
|
||||
const channel = computed(() => {
|
||||
const v = props.version.toLowerCase()
|
||||
if (v.includes('-beta')) return 'Beta'
|
||||
if (v.includes('-dev')) return 'Dev'
|
||||
return ''
|
||||
})
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<header class="app-bar" :class="{ scrolled }">
|
||||
<div class="app-bar__text">
|
||||
<h1 class="app-bar__title ts-title-lg">
|
||||
{{ title }}
|
||||
<span v-if="channel" class="channel-badge">{{ channel }}</span>
|
||||
</h1>
|
||||
<span class="app-bar__subtitle ts-body-sm">{{ subtitle || version || '—' }}</span>
|
||||
</div>
|
||||
|
||||
<span class="status-pill" :class="statusClass">
|
||||
<span class="status-pill__dot"></span>
|
||||
{{ statusText }}
|
||||
</span>
|
||||
|
||||
<div class="app-bar__actions">
|
||||
<md-icon-button title="刷新" @click="emit('refresh')">
|
||||
<RefreshCw :size="20" />
|
||||
</md-icon-button>
|
||||
<md-icon-button
|
||||
:title="paused ? '启用' : '暂停'"
|
||||
:disabled="locked"
|
||||
@click="emit('toggle-service')"
|
||||
>
|
||||
<Play v-if="paused" :size="20" />
|
||||
<Pause v-else :size="20" />
|
||||
</md-icon-button>
|
||||
<md-icon-button title="重启模块" :disabled="locked" @click="emit('restart')">
|
||||
<RotateCw :size="20" />
|
||||
</md-icon-button>
|
||||
</div>
|
||||
</header>
|
||||
</template>
|
||||
@@ -1,143 +0,0 @@
|
||||
<script setup>
|
||||
import { ref, onMounted, onUnmounted, watch } from 'vue'
|
||||
import {
|
||||
Activity as IconActivity,
|
||||
Settings as IconSettings,
|
||||
AppWindow as IconApps,
|
||||
ScrollText as IconLog,
|
||||
Info as IconInfo,
|
||||
} from 'lucide-vue-next'
|
||||
|
||||
const props = defineProps({ modelValue: { type: String, default: 'status' } })
|
||||
const emit = defineEmits(['update:modelValue'])
|
||||
|
||||
const navItems = [
|
||||
{ key: 'status', label: '状态', icon: IconActivity },
|
||||
{ key: 'config', label: '配置', icon: IconSettings },
|
||||
{ key: 'apps', label: '黑名单', icon: IconApps },
|
||||
{ key: 'log', label: '日志', icon: IconLog },
|
||||
{ key: 'about', label: '关于', icon: IconInfo },
|
||||
]
|
||||
|
||||
const navbarEl = ref(null)
|
||||
const sliderEl = ref(null)
|
||||
const btnRefs = ref([])
|
||||
|
||||
const TRANSITION_ON = 'transform 0.3s cubic-bezier(0.25, 1, 0.5, 1), width 0.3s ease'
|
||||
|
||||
function updateSlider(key, animate = true) {
|
||||
const idx = navItems.findIndex((n) => n.key === key)
|
||||
if (idx < 0) return
|
||||
const btn = btnRefs.value[idx]
|
||||
if (!btn || !sliderEl.value) return
|
||||
sliderEl.value.style.transition = animate ? TRANSITION_ON : 'none'
|
||||
sliderEl.value.style.width = btn.offsetWidth + 'px'
|
||||
sliderEl.value.style.transform = `translateX(${btn.offsetLeft}px)`
|
||||
}
|
||||
|
||||
function select(key) {
|
||||
emit('update:modelValue', key)
|
||||
}
|
||||
|
||||
watch(
|
||||
() => props.modelValue,
|
||||
(v) => updateSlider(v),
|
||||
)
|
||||
|
||||
// ---- 拖拽逻辑 ----
|
||||
let isDragging = false
|
||||
let isActuallyDragging = false
|
||||
let startX = 0
|
||||
let startSliderX = 0
|
||||
|
||||
function onPointerDown(e) {
|
||||
isDragging = true
|
||||
isActuallyDragging = false
|
||||
startX = e.clientX
|
||||
const idx = navItems.findIndex((n) => n.key === props.modelValue)
|
||||
startSliderX = idx >= 0 && btnRefs.value[idx] ? btnRefs.value[idx].offsetLeft : 0
|
||||
}
|
||||
|
||||
function onPointerMove(e) {
|
||||
if (!isDragging) return
|
||||
const dx = e.clientX - startX
|
||||
if (!isActuallyDragging && Math.abs(dx) > 10) {
|
||||
isActuallyDragging = true
|
||||
navbarEl.value?.setPointerCapture(e.pointerId)
|
||||
}
|
||||
if (!isActuallyDragging || !sliderEl.value) return
|
||||
const first = btnRefs.value[0]
|
||||
const last = btnRefs.value[btnRefs.value.length - 1]
|
||||
const minX = first ? first.offsetLeft : 0
|
||||
const maxX = last ? last.offsetLeft : 0
|
||||
let tx = startSliderX + dx
|
||||
if (tx < minX) tx = minX + (tx - minX) * 0.3
|
||||
if (tx > maxX) tx = maxX + (tx - maxX) * 0.3
|
||||
sliderEl.value.style.transition = 'none'
|
||||
sliderEl.value.style.transform = `translateX(${tx}px)`
|
||||
}
|
||||
|
||||
function onPointerUp(e) {
|
||||
if (!isDragging) return
|
||||
const wasDragging = isActuallyDragging
|
||||
isDragging = false
|
||||
isActuallyDragging = false
|
||||
navbarEl.value?.releasePointerCapture(e.pointerId)
|
||||
|
||||
if (wasDragging && sliderEl.value) {
|
||||
const sliderRect = sliderEl.value.getBoundingClientRect()
|
||||
const navRect = navbarEl.value?.getBoundingClientRect()
|
||||
const currentX = navRect ? sliderRect.left - navRect.left : 0
|
||||
let closest = navItems[0].key
|
||||
let minDist = Infinity
|
||||
btnRefs.value.forEach((btn, i) => {
|
||||
if (!btn) return
|
||||
const dist = Math.abs(btn.offsetLeft - currentX)
|
||||
if (dist < minDist) {
|
||||
minDist = dist
|
||||
closest = navItems[i].key
|
||||
}
|
||||
})
|
||||
select(closest)
|
||||
} else {
|
||||
updateSlider(props.modelValue)
|
||||
}
|
||||
}
|
||||
|
||||
function onResize() {
|
||||
updateSlider(props.modelValue, false)
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
updateSlider(props.modelValue, false)
|
||||
window.addEventListener('resize', onResize)
|
||||
})
|
||||
onUnmounted(() => {
|
||||
window.removeEventListener('resize', onResize)
|
||||
})
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<nav
|
||||
class="floating-navbar"
|
||||
ref="navbarEl"
|
||||
@pointerdown="onPointerDown"
|
||||
@pointermove="onPointerMove"
|
||||
@pointerup="onPointerUp"
|
||||
>
|
||||
<div class="navbar-slider" ref="sliderEl"></div>
|
||||
|
||||
<button
|
||||
v-for="(item, i) in navItems"
|
||||
:key="item.key"
|
||||
:ref="(el) => (btnRefs[i] = el)"
|
||||
class="navbar-btn"
|
||||
:class="{ active: modelValue === item.key }"
|
||||
:data-section="item.key"
|
||||
@click="select(item.key)"
|
||||
>
|
||||
<component :is="item.icon" :size="20" :stroke-width="1.75" />
|
||||
<span>{{ item.label }}</span>
|
||||
</button>
|
||||
</nav>
|
||||
</template>
|
||||
@@ -0,0 +1,54 @@
|
||||
<script setup>
|
||||
import { ref, watch, nextTick } from 'vue'
|
||||
|
||||
const props = defineProps({
|
||||
open: { type: Boolean, default: false },
|
||||
headline: { type: String, default: '确认操作' },
|
||||
description: { type: String, default: '' },
|
||||
confirmText: { type: String, default: '确认' },
|
||||
cancelText: { type: String, default: '取消' },
|
||||
danger: { type: Boolean, default: false },
|
||||
})
|
||||
const emit = defineEmits(['confirm', 'cancel'])
|
||||
|
||||
const dialogEl = ref(null)
|
||||
|
||||
watch(
|
||||
() => props.open,
|
||||
async (open) => {
|
||||
await nextTick()
|
||||
if (!dialogEl.value) return
|
||||
if (open) dialogEl.value.show()
|
||||
else dialogEl.value.close()
|
||||
},
|
||||
)
|
||||
|
||||
function onClosed() {
|
||||
if (props.open) emit('cancel') // 点击遮罩/ESC 关闭
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<md-dialog ref="dialogEl" @closed="onClosed">
|
||||
<div slot="headline">{{ headline }}</div>
|
||||
<div slot="content" class="dialog-content">{{ description }}</div>
|
||||
<div slot="actions">
|
||||
<md-text-button @click="emit('cancel')">{{ cancelText }}</md-text-button>
|
||||
<md-filled-button :class="{ danger }" @click="emit('confirm')">
|
||||
{{ confirmText }}
|
||||
</md-filled-button>
|
||||
</div>
|
||||
</md-dialog>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.dialog-content {
|
||||
color: var(--md-sys-color-on-surface-variant);
|
||||
white-space: pre-line;
|
||||
}
|
||||
|
||||
md-filled-button.danger {
|
||||
--md-filled-button-container-color: var(--md-sys-color-error);
|
||||
--md-filled-button-label-text-color: var(--md-sys-color-on-error);
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,17 @@
|
||||
<script setup>
|
||||
defineProps({
|
||||
locked: { type: Boolean, default: false },
|
||||
label: { type: String, default: '正在执行后台操作' },
|
||||
seconds: { type: Number, default: 0 },
|
||||
})
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Transition name="oplock">
|
||||
<div v-if="locked" class="oplock-banner" role="status">
|
||||
<span class="oplock-banner__spinner"></span>
|
||||
<span class="oplock-banner__text">{{ label }},已暂停刷新</span>
|
||||
<span v-if="seconds > 0" class="oplock-banner__elapsed">{{ seconds }}s</span>
|
||||
</div>
|
||||
</Transition>
|
||||
</template>
|
||||
@@ -0,0 +1,68 @@
|
||||
<script setup>
|
||||
import { ref, watch, nextTick } from 'vue'
|
||||
|
||||
const props = defineProps({
|
||||
open: { type: Boolean, default: false },
|
||||
headline: { type: String, default: '输入' },
|
||||
label: { type: String, default: '' },
|
||||
description: { type: String, default: '' },
|
||||
confirmText: { type: String, default: '确认' },
|
||||
cancelText: { type: String, default: '取消' },
|
||||
})
|
||||
const emit = defineEmits(['confirm', 'cancel'])
|
||||
|
||||
const dialogEl = ref(null)
|
||||
const value = ref('')
|
||||
|
||||
watch(
|
||||
() => props.open,
|
||||
async (open) => {
|
||||
await nextTick()
|
||||
if (!dialogEl.value) return
|
||||
if (open) {
|
||||
value.value = ''
|
||||
dialogEl.value.show()
|
||||
} else {
|
||||
dialogEl.value.close()
|
||||
}
|
||||
},
|
||||
)
|
||||
|
||||
function confirm() {
|
||||
emit('confirm', value.value.trim())
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<md-dialog ref="dialogEl" @closed="emit('cancel')">
|
||||
<div slot="headline">{{ headline }}</div>
|
||||
<div slot="content" class="prompt-content">
|
||||
<p v-if="description" class="ts-body supporting">{{ description }}</p>
|
||||
<md-outlined-text-field
|
||||
:label="label"
|
||||
:value="value"
|
||||
autocomplete="off"
|
||||
spellcheck="false"
|
||||
@input="value = $event.target.value"
|
||||
@keydown.enter="confirm"
|
||||
></md-outlined-text-field>
|
||||
</div>
|
||||
<div slot="actions">
|
||||
<md-text-button @click="emit('cancel')">{{ cancelText }}</md-text-button>
|
||||
<md-filled-button @click="confirm">{{ confirmText }}</md-filled-button>
|
||||
</div>
|
||||
</md-dialog>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.prompt-content {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: var(--md-sys-spacing-3);
|
||||
min-width: min(320px, 70vw);
|
||||
}
|
||||
|
||||
.prompt-content p {
|
||||
margin: 0;
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,15 @@
|
||||
<script setup>
|
||||
defineProps({
|
||||
messages: { type: Array, default: () => [] },
|
||||
})
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="snackbar-host">
|
||||
<TransitionGroup name="snackbar">
|
||||
<div v-for="message in messages" :key="message.id" class="snackbar" role="status">
|
||||
{{ message.text }}
|
||||
</div>
|
||||
</TransitionGroup>
|
||||
</div>
|
||||
</template>
|
||||
@@ -1,32 +0,0 @@
|
||||
<script setup>
|
||||
import { cn } from '@/lib/utils'
|
||||
import { cva } from 'class-variance-authority'
|
||||
|
||||
const badgeVariants = cva(
|
||||
'inline-flex items-center rounded-full px-2 py-0.5 text-xs font-medium transition-colors',
|
||||
{
|
||||
variants: {
|
||||
variant: {
|
||||
default: 'bg-primary/20 text-primary border border-primary/30',
|
||||
secondary: 'bg-secondary text-secondary-foreground',
|
||||
destructive: 'bg-destructive/20 text-destructive border border-destructive/30',
|
||||
outline: 'border border-border text-foreground',
|
||||
success: 'bg-green-500/20 text-green-400 border border-green-500/30',
|
||||
warning: 'bg-amber-500/20 text-amber-400 border border-amber-500/30',
|
||||
},
|
||||
},
|
||||
defaultVariants: { variant: 'default' },
|
||||
},
|
||||
)
|
||||
|
||||
const props = defineProps({
|
||||
variant: { type: String, default: 'default' },
|
||||
class: { type: String, default: '' },
|
||||
})
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<span :class="cn(badgeVariants({ variant }), props.class)">
|
||||
<slot />
|
||||
</span>
|
||||
</template>
|
||||
@@ -1,53 +0,0 @@
|
||||
<script setup>
|
||||
import { cn } from '@/lib/utils'
|
||||
import { cva } from 'class-variance-authority'
|
||||
|
||||
const buttonVariants = cva(
|
||||
'inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0',
|
||||
{
|
||||
variants: {
|
||||
variant: {
|
||||
default: 'bg-primary text-primary-foreground hover:bg-primary/90 active:bg-primary/80',
|
||||
destructive:
|
||||
'bg-destructive/20 text-destructive border border-destructive/40 hover:bg-destructive/30',
|
||||
outline:
|
||||
'border border-border bg-transparent hover:bg-secondary hover:text-secondary-foreground',
|
||||
secondary: 'bg-secondary text-secondary-foreground hover:bg-secondary/80',
|
||||
ghost: 'hover:bg-secondary hover:text-secondary-foreground',
|
||||
link: 'text-primary underline-offset-4 hover:underline',
|
||||
},
|
||||
size: {
|
||||
default: 'h-9 px-4 py-2',
|
||||
sm: 'h-8 rounded-md px-3 text-xs',
|
||||
lg: 'h-10 rounded-md px-8',
|
||||
icon: 'h-9 w-9',
|
||||
'icon-sm': 'h-8 w-8',
|
||||
},
|
||||
},
|
||||
defaultVariants: {
|
||||
variant: 'default',
|
||||
size: 'default',
|
||||
},
|
||||
},
|
||||
)
|
||||
|
||||
const props = defineProps({
|
||||
variant: { type: String, default: 'default' },
|
||||
size: { type: String, default: 'default' },
|
||||
class: { type: String, default: '' },
|
||||
disabled: { type: Boolean, default: false },
|
||||
type: { type: String, default: 'button' },
|
||||
as: { type: String, default: 'button' },
|
||||
})
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<component
|
||||
:is="as"
|
||||
:type="as === 'button' ? type : undefined"
|
||||
:disabled="disabled || undefined"
|
||||
:class="cn(buttonVariants({ variant, size }), props.class)"
|
||||
>
|
||||
<slot />
|
||||
</component>
|
||||
</template>
|
||||
@@ -1,17 +0,0 @@
|
||||
<script setup>
|
||||
import { cn } from '@/lib/utils'
|
||||
|
||||
const props = defineProps({
|
||||
class: { type: String, default: '' },
|
||||
})
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div
|
||||
:class="
|
||||
cn('rounded-xl border border-border/40 bg-card text-card-foreground shadow-md', props.class)
|
||||
"
|
||||
>
|
||||
<slot />
|
||||
</div>
|
||||
</template>
|
||||
@@ -1,38 +0,0 @@
|
||||
<script setup>
|
||||
import { cn } from '@/lib/utils'
|
||||
|
||||
const props = defineProps({
|
||||
class: { type: String, default: '' },
|
||||
modelValue: { type: [String, Number], default: '' },
|
||||
type: { type: String, default: 'text' },
|
||||
placeholder: { type: String, default: '' },
|
||||
disabled: { type: Boolean, default: false },
|
||||
min: { type: [String, Number], default: undefined },
|
||||
max: { type: [String, Number], default: undefined },
|
||||
autocomplete: { type: String, default: 'off' },
|
||||
spellcheck: { type: Boolean, default: false },
|
||||
})
|
||||
|
||||
const emit = defineEmits(['update:modelValue'])
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<input
|
||||
v-bind="$attrs"
|
||||
:type="type"
|
||||
:value="modelValue"
|
||||
:placeholder="placeholder"
|
||||
:disabled="disabled"
|
||||
:min="min"
|
||||
:max="max"
|
||||
:autocomplete="autocomplete"
|
||||
:spellcheck="spellcheck"
|
||||
:class="
|
||||
cn(
|
||||
'flex h-9 w-full rounded-md border border-input bg-muted px-3 py-1 text-sm text-foreground shadow-sm transition-colors placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:border-primary disabled:cursor-not-allowed disabled:opacity-50',
|
||||
props.class,
|
||||
)
|
||||
"
|
||||
@input="emit('update:modelValue', $event.target.value)"
|
||||
/>
|
||||
</template>
|
||||
@@ -1,22 +0,0 @@
|
||||
<script setup>
|
||||
import { cn } from '@/lib/utils'
|
||||
|
||||
const props = defineProps({
|
||||
class: { type: String, default: '' },
|
||||
for: { type: String, default: undefined },
|
||||
})
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<label
|
||||
:for="props.for"
|
||||
:class="
|
||||
cn(
|
||||
'text-sm font-medium leading-none text-foreground peer-disabled:cursor-not-allowed peer-disabled:opacity-70',
|
||||
props.class,
|
||||
)
|
||||
"
|
||||
>
|
||||
<slot />
|
||||
</label>
|
||||
</template>
|
||||
@@ -1,21 +0,0 @@
|
||||
<script setup>
|
||||
import { cn } from '@/lib/utils'
|
||||
|
||||
const props = defineProps({
|
||||
class: { type: String, default: '' },
|
||||
vertical: { type: Boolean, default: false },
|
||||
})
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div
|
||||
:role="'separator'"
|
||||
:class="
|
||||
cn(
|
||||
vertical ? 'inline-flex h-full w-px' : 'flex h-px w-full',
|
||||
'bg-border shrink-0',
|
||||
props.class,
|
||||
)
|
||||
"
|
||||
/>
|
||||
</template>
|
||||
@@ -1,43 +0,0 @@
|
||||
<script setup>
|
||||
import { cn } from '@/lib/utils'
|
||||
|
||||
const props = defineProps({
|
||||
class: { type: String, default: '' },
|
||||
modelValue: { type: Boolean, default: false },
|
||||
disabled: { type: Boolean, default: false },
|
||||
id: { type: String, default: undefined },
|
||||
})
|
||||
|
||||
const emit = defineEmits(['update:modelValue'])
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<button
|
||||
type="button"
|
||||
role="switch"
|
||||
:aria-checked="modelValue"
|
||||
:disabled="disabled"
|
||||
:id="id"
|
||||
:class="
|
||||
cn(
|
||||
'relative inline-flex h-6 w-11 shrink-0 cursor-pointer items-center rounded-full transition-colors duration-200 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50',
|
||||
modelValue
|
||||
? 'bg-primary border-2 border-transparent'
|
||||
: 'bg-transparent border-2 border-muted-foreground/40',
|
||||
props.class,
|
||||
)
|
||||
"
|
||||
@click="emit('update:modelValue', !modelValue)"
|
||||
>
|
||||
<span
|
||||
:class="
|
||||
cn(
|
||||
'pointer-events-none block rounded-full shadow-sm ring-0 transition-all duration-200',
|
||||
modelValue
|
||||
? 'h-5 w-5 translate-x-5 bg-white'
|
||||
: 'h-4 w-4 translate-x-0.5 bg-muted-foreground/60',
|
||||
)
|
||||
"
|
||||
/>
|
||||
</button>
|
||||
</template>
|
||||
@@ -1,30 +0,0 @@
|
||||
<script setup>
|
||||
import { cn } from '@/lib/utils'
|
||||
|
||||
const props = defineProps({
|
||||
class: { type: String, default: '' },
|
||||
modelValue: { type: String, default: '' },
|
||||
placeholder: { type: String, default: '' },
|
||||
disabled: { type: Boolean, default: false },
|
||||
rows: { type: Number, default: 2 },
|
||||
})
|
||||
|
||||
const emit = defineEmits(['update:modelValue'])
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<textarea
|
||||
v-bind="$attrs"
|
||||
:value="modelValue"
|
||||
:placeholder="placeholder"
|
||||
:disabled="disabled"
|
||||
:rows="rows"
|
||||
:class="
|
||||
cn(
|
||||
'flex min-h-15 w-full rounded-md border border-input bg-muted px-3 py-2 text-sm font-mono text-foreground shadow-sm transition-colors placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:border-primary disabled:cursor-not-allowed disabled:opacity-50 resize-vertical',
|
||||
props.class,
|
||||
)
|
||||
"
|
||||
@input="emit('update:modelValue', $event.target.value)"
|
||||
/>
|
||||
</template>
|
||||
@@ -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,
|
||||
|
||||
+137
-255
@@ -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)
|
||||
try {
|
||||
await patchConfig(patch)
|
||||
await load()
|
||||
snackbar?.(message)
|
||||
} catch (e) {
|
||||
snackbar?.(`保存失败: ${e.message}`)
|
||||
}
|
||||
if (e.length === 4) {
|
||||
sleepEndH.value = e.slice(0, 2)
|
||||
sleepEndM.value = e.slice(2)
|
||||
}
|
||||
} else {
|
||||
sleepMode.value = false
|
||||
}
|
||||
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,
|
||||
}
|
||||
}
|
||||
@@ -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 }
|
||||
}
|
||||
@@ -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 }
|
||||
}
|
||||
@@ -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,
|
||||
}
|
||||
}
|
||||
@@ -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 || ''
|
||||
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
|
||||
}
|
||||
}
|
||||
|
||||
function invalidatePaths() {
|
||||
_nowBriFile = null
|
||||
_sysMaxBriFile = null
|
||||
_sleepTime = null
|
||||
async function refreshOplock() {
|
||||
try {
|
||||
oplock.value = await fetchOplock()
|
||||
} catch {
|
||||
/* 忽略:下次轮询会重试 */
|
||||
}
|
||||
}
|
||||
|
||||
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 setBrightness(value) {
|
||||
await apiSetBrightness(value)
|
||||
await load({ display: false })
|
||||
}
|
||||
|
||||
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)
|
||||
async function toggleService(snackbar) {
|
||||
const res = await apiToggleService()
|
||||
snackbar?.(res.ok ? res.stdout.trim() || '状态已切换' : '操作失败: ' + res.stderr)
|
||||
await load({ display: false })
|
||||
}
|
||||
|
||||
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 ? '休眠中' : '非休眠'
|
||||
}
|
||||
return nV >= sNum && nV < eNum ? '休眠中' : '非休眠'
|
||||
async function boost(snackbar) {
|
||||
const res = await apiBoost()
|
||||
snackbar?.(res.ok ? '已切换峰值亮度' : '操作失败: ' + res.stderr)
|
||||
await load({ display: false })
|
||||
}
|
||||
|
||||
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 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 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 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,
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
@@ -1,6 +0,0 @@
|
||||
import { clsx } from 'clsx'
|
||||
import { twMerge } from 'tailwind-merge'
|
||||
|
||||
export function cn(...inputs) {
|
||||
return twMerge(clsx(inputs))
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
+7
-7
@@ -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')
|
||||
@@ -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'
|
||||
@@ -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;
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
@@ -0,0 +1,160 @@
|
||||
/* ==========================================================================
|
||||
跨视图复用的模式:设置行 / 状态徽标 / 空状态 / 折叠区 / 状态网格 / 列表行
|
||||
视图专属样式放在各自的 <style scoped> 中。
|
||||
========================================================================== */
|
||||
|
||||
/* ── 设置行(标签 + 控件)─────────────────────────────────────────── */
|
||||
.row {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: var(--md-sys-spacing-4);
|
||||
padding: var(--md-sys-spacing-2) 0;
|
||||
min-height: 48px;
|
||||
}
|
||||
|
||||
.row__labels {
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 2px;
|
||||
}
|
||||
|
||||
.row__name {
|
||||
color: var(--md-sys-color-on-surface);
|
||||
font-size: var(--md-sys-typescale-body-large-size);
|
||||
line-height: var(--md-sys-typescale-body-large-line-height);
|
||||
font-weight: 500;
|
||||
}
|
||||
|
||||
.row__support {
|
||||
color: var(--md-sys-color-on-surface-variant);
|
||||
font-size: var(--md-sys-typescale-body-small-size);
|
||||
line-height: var(--md-sys-typescale-body-small-line-height);
|
||||
}
|
||||
|
||||
.row__support.warning {
|
||||
color: var(--lp-color-warning);
|
||||
}
|
||||
|
||||
.row__control {
|
||||
flex: 0 0 auto;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: var(--md-sys-spacing-2);
|
||||
}
|
||||
|
||||
/* ── 状态徽标(已保存 / 未保存、计数等)───────────────────────────── */
|
||||
.state-badge {
|
||||
flex: 0 0 auto;
|
||||
padding: 2px 10px;
|
||||
border-radius: var(--md-sys-shape-corner-full);
|
||||
font-size: var(--md-sys-typescale-label-small-size);
|
||||
line-height: var(--md-sys-typescale-label-small-line-height);
|
||||
font-weight: 700;
|
||||
}
|
||||
|
||||
.state-badge.is-saved {
|
||||
background-color: var(--lp-color-success-container);
|
||||
color: var(--lp-color-success);
|
||||
}
|
||||
|
||||
.state-badge.is-unsaved {
|
||||
background-color: var(--lp-color-warning-container);
|
||||
color: var(--lp-color-warning);
|
||||
}
|
||||
|
||||
/* ── 折叠区(grid-template-rows 动画)────────────────────────────── */
|
||||
.collapse {
|
||||
display: grid;
|
||||
grid-template-rows: 0fr;
|
||||
transition: grid-template-rows var(--md-sys-motion-duration-medium2)
|
||||
var(--md-sys-motion-easing-emphasized);
|
||||
}
|
||||
|
||||
.collapse.open {
|
||||
grid-template-rows: 1fr;
|
||||
}
|
||||
|
||||
.collapse > * {
|
||||
overflow: hidden;
|
||||
min-height: 0;
|
||||
}
|
||||
|
||||
/* ── 空状态 ───────────────────────────────────────────────────────── */
|
||||
.empty-state {
|
||||
padding: var(--md-sys-spacing-6) var(--md-sys-spacing-4);
|
||||
text-align: center;
|
||||
color: var(--md-sys-color-on-surface-variant);
|
||||
font-size: var(--md-sys-typescale-body-medium-size);
|
||||
}
|
||||
|
||||
.empty-state.error {
|
||||
color: var(--md-sys-color-error);
|
||||
}
|
||||
|
||||
/* ── 状态网格(实时状态页)────────────────────────────────────────── */
|
||||
.status-grid {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(2, minmax(0, 1fr));
|
||||
gap: var(--md-sys-spacing-2);
|
||||
}
|
||||
|
||||
.status-item {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 2px;
|
||||
padding: var(--md-sys-spacing-3);
|
||||
border-radius: var(--md-sys-shape-corner-medium);
|
||||
background-color: var(--md-sys-color-surface-container);
|
||||
}
|
||||
|
||||
.status-item__label {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 6px;
|
||||
color: var(--md-sys-color-on-surface-variant);
|
||||
font-size: var(--md-sys-typescale-label-medium-size);
|
||||
line-height: var(--md-sys-typescale-label-medium-line-height);
|
||||
}
|
||||
|
||||
.status-item__value {
|
||||
color: var(--md-sys-color-on-surface);
|
||||
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);
|
||||
word-break: break-all;
|
||||
}
|
||||
|
||||
/* ── 列表行(黑名单 / 文档 / 菜单项)──────────────────────────────── */
|
||||
.list {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: var(--md-sys-spacing-2);
|
||||
}
|
||||
|
||||
.list-item {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: var(--md-sys-spacing-3);
|
||||
padding: var(--md-sys-spacing-3) var(--md-sys-spacing-4);
|
||||
border-radius: var(--md-sys-shape-corner-medium);
|
||||
background-color: var(--md-sys-color-surface-container);
|
||||
color: var(--md-sys-color-on-surface);
|
||||
}
|
||||
|
||||
/* ── 扫描/进行中 的脉冲文字 ───────────────────────────────────────── */
|
||||
.pulse-text {
|
||||
color: var(--lp-color-warning);
|
||||
animation: status-pulse 1.6s var(--md-sys-motion-easing-standard) infinite;
|
||||
}
|
||||
|
||||
@keyframes status-pulse {
|
||||
0%,
|
||||
100% {
|
||||
opacity: 1;
|
||||
}
|
||||
50% {
|
||||
opacity: 0.45;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,286 @@
|
||||
/* ==========================================================================
|
||||
MD3 设计令牌
|
||||
- 颜色:完整 MD3 角色集,沿用项目既有的 Google Blue 调色板
|
||||
- 字阶 / 形状 / 动效 / 状态层:官方命名(--md-sys-*)
|
||||
暗色为默认;浅色通过「系统偏好」或手动 .light 类生效。
|
||||
========================================================================== */
|
||||
|
||||
:root {
|
||||
/* ── 字阶 typescale ─────────────────────────────────────────────── */
|
||||
--md-sys-typescale-display-large-size: 3.5625rem; /* 57sp */
|
||||
--md-sys-typescale-display-large-line-height: 4rem;
|
||||
--md-sys-typescale-display-large-weight: 400;
|
||||
--md-sys-typescale-display-medium-size: 2.8125rem; /* 45sp */
|
||||
--md-sys-typescale-display-medium-line-height: 3.25rem;
|
||||
--md-sys-typescale-display-medium-weight: 400;
|
||||
--md-sys-typescale-display-small-size: 2.25rem; /* 36sp */
|
||||
--md-sys-typescale-display-small-line-height: 2.75rem;
|
||||
--md-sys-typescale-display-small-weight: 400;
|
||||
|
||||
--md-sys-typescale-headline-large-size: 2rem; /* 32sp */
|
||||
--md-sys-typescale-headline-large-line-height: 2.5rem;
|
||||
--md-sys-typescale-headline-large-weight: 400;
|
||||
--md-sys-typescale-headline-medium-size: 1.75rem; /* 28sp */
|
||||
--md-sys-typescale-headline-medium-line-height: 2.25rem;
|
||||
--md-sys-typescale-headline-medium-weight: 400;
|
||||
--md-sys-typescale-headline-small-size: 1.5rem; /* 24sp */
|
||||
--md-sys-typescale-headline-small-line-height: 2rem;
|
||||
--md-sys-typescale-headline-small-weight: 400;
|
||||
|
||||
--md-sys-typescale-title-large-size: 1.375rem; /* 22sp */
|
||||
--md-sys-typescale-title-large-line-height: 1.75rem;
|
||||
--md-sys-typescale-title-large-weight: 400;
|
||||
--md-sys-typescale-title-medium-size: 1rem; /* 16sp */
|
||||
--md-sys-typescale-title-medium-line-height: 1.5rem;
|
||||
--md-sys-typescale-title-medium-weight: 500;
|
||||
--md-sys-typescale-title-medium-tracking: 0.0094em;
|
||||
--md-sys-typescale-title-small-size: 0.875rem; /* 14sp */
|
||||
--md-sys-typescale-title-small-line-height: 1.25rem;
|
||||
--md-sys-typescale-title-small-weight: 500;
|
||||
--md-sys-typescale-title-small-tracking: 0.0063em;
|
||||
|
||||
--md-sys-typescale-body-large-size: 1rem; /* 16sp */
|
||||
--md-sys-typescale-body-large-line-height: 1.5rem;
|
||||
--md-sys-typescale-body-large-weight: 400;
|
||||
--md-sys-typescale-body-large-tracking: 0.0313em;
|
||||
--md-sys-typescale-body-medium-size: 0.875rem; /* 14sp */
|
||||
--md-sys-typescale-body-medium-line-height: 1.25rem;
|
||||
--md-sys-typescale-body-medium-weight: 400;
|
||||
--md-sys-typescale-body-medium-tracking: 0.0156em;
|
||||
--md-sys-typescale-body-small-size: 0.75rem; /* 12sp */
|
||||
--md-sys-typescale-body-small-line-height: 1rem;
|
||||
--md-sys-typescale-body-small-weight: 400;
|
||||
--md-sys-typescale-body-small-tracking: 0.025em;
|
||||
|
||||
--md-sys-typescale-label-large-size: 0.875rem; /* 14sp */
|
||||
--md-sys-typescale-label-large-line-height: 1.25rem;
|
||||
--md-sys-typescale-label-large-weight: 500;
|
||||
--md-sys-typescale-label-large-tracking: 0.0063em;
|
||||
--md-sys-typescale-label-medium-size: 0.75rem; /* 12sp */
|
||||
--md-sys-typescale-label-medium-line-height: 1rem;
|
||||
--md-sys-typescale-label-medium-weight: 500;
|
||||
--md-sys-typescale-label-medium-tracking: 0.0313em;
|
||||
--md-sys-typescale-label-small-size: 0.6875rem; /* 11sp */
|
||||
--md-sys-typescale-label-small-line-height: 1rem;
|
||||
--md-sys-typescale-label-small-weight: 500;
|
||||
--md-sys-typescale-label-small-tracking: 0.0313em;
|
||||
|
||||
--md-sys-typescale-font: 'Geist', system-ui, -apple-system, sans-serif;
|
||||
--md-sys-typescale-font-mono: 'Geist Mono', ui-monospace, monospace;
|
||||
|
||||
/* ── 形状 shape ─────────────────────────────────────────────────── */
|
||||
--md-sys-shape-corner-none: 0;
|
||||
--md-sys-shape-corner-extra-small: 4px;
|
||||
--md-sys-shape-corner-small: 8px;
|
||||
--md-sys-shape-corner-medium: 12px;
|
||||
--md-sys-shape-corner-large: 16px;
|
||||
--md-sys-shape-corner-large-increased: 20px;
|
||||
--md-sys-shape-corner-extra-large: 28px;
|
||||
--md-sys-shape-corner-extra-large-increased: 32px;
|
||||
--md-sys-shape-corner-full: 9999px;
|
||||
|
||||
/* ── 间距(8dp 系统)────────────────────────────────────────────── */
|
||||
--md-sys-spacing-1: 4px;
|
||||
--md-sys-spacing-2: 8px;
|
||||
--md-sys-spacing-3: 12px;
|
||||
--md-sys-spacing-4: 16px;
|
||||
--md-sys-spacing-5: 24px;
|
||||
--md-sys-spacing-6: 32px;
|
||||
|
||||
/* ── 动效 motion ────────────────────────────────────────────────── */
|
||||
--md-sys-motion-duration-short2: 100ms;
|
||||
--md-sys-motion-duration-short4: 200ms;
|
||||
--md-sys-motion-duration-medium2: 300ms;
|
||||
--md-sys-motion-duration-medium4: 400ms;
|
||||
--md-sys-motion-duration-long2: 500ms;
|
||||
--md-sys-motion-easing-standard: cubic-bezier(0.2, 0, 0, 1);
|
||||
--md-sys-motion-easing-standard-decelerate: cubic-bezier(0, 0, 0, 1);
|
||||
--md-sys-motion-easing-standard-accelerate: cubic-bezier(0.3, 0, 1, 1);
|
||||
--md-sys-motion-easing-emphasized: cubic-bezier(0.2, 0, 0, 1);
|
||||
--md-sys-motion-easing-emphasized-decelerate: cubic-bezier(0.05, 0.7, 0.1, 1);
|
||||
--md-sys-motion-easing-emphasized-accelerate: cubic-bezier(0.3, 0, 0.8, 0.15);
|
||||
|
||||
/* ── 状态层 state layer ─────────────────────────────────────────── */
|
||||
--md-sys-state-hover-opacity: 0.08;
|
||||
--md-sys-state-focus-opacity: 0.1;
|
||||
--md-sys-state-pressed-opacity: 0.1;
|
||||
--md-sys-state-dragged-opacity: 0.16;
|
||||
|
||||
/* ── 项目扩展角色(MD3 无 warning/success)──────────────────────── */
|
||||
--lp-color-warning: #f59e0b;
|
||||
--lp-color-success: #4ade80;
|
||||
}
|
||||
|
||||
/* ==========================================================================
|
||||
暗色(默认)
|
||||
========================================================================== */
|
||||
:root,
|
||||
:root.dark {
|
||||
--md-sys-color-primary: #a8c7fa;
|
||||
--md-sys-color-on-primary: #062e6f;
|
||||
--md-sys-color-primary-container: #1b4b9b;
|
||||
--md-sys-color-on-primary-container: #d3e3fd;
|
||||
|
||||
--md-sys-color-secondary: #bec6dc;
|
||||
--md-sys-color-on-secondary: #283141;
|
||||
--md-sys-color-secondary-container: #3e4759;
|
||||
--md-sys-color-on-secondary-container: #dae2f9;
|
||||
|
||||
--md-sys-color-tertiary: #d6bee4;
|
||||
--md-sys-color-on-tertiary: #3b2948;
|
||||
--md-sys-color-tertiary-container: #523f5f;
|
||||
--md-sys-color-on-tertiary-container: #f2daff;
|
||||
|
||||
--md-sys-color-error: #ffb4ab;
|
||||
--md-sys-color-on-error: #690005;
|
||||
--md-sys-color-error-container: #93000a;
|
||||
--md-sys-color-on-error-container: #ffdad6;
|
||||
|
||||
--md-sys-color-background: #111318;
|
||||
--md-sys-color-on-background: #e2e2e9;
|
||||
--md-sys-color-surface: #1e1f25;
|
||||
--md-sys-color-on-surface: #e2e2e9;
|
||||
--md-sys-color-surface-variant: #44474f;
|
||||
--md-sys-color-on-surface-variant: #c4c6d0;
|
||||
|
||||
--md-sys-color-surface-dim: #111318;
|
||||
--md-sys-color-surface-bright: #37393f;
|
||||
--md-sys-color-surface-container-lowest: #0d0e12;
|
||||
--md-sys-color-surface-container-low: #1a1c22;
|
||||
--md-sys-color-surface-container: #212429;
|
||||
--md-sys-color-surface-container-high: #2b2930;
|
||||
--md-sys-color-surface-container-highest: #36343b;
|
||||
|
||||
--md-sys-color-inverse-surface: #e2e2e9;
|
||||
--md-sys-color-inverse-on-surface: #2f3033;
|
||||
--md-sys-color-inverse-primary: #0b57d0;
|
||||
|
||||
--md-sys-color-outline: #8e9099;
|
||||
--md-sys-color-outline-variant: #44474f;
|
||||
--md-sys-color-shadow: #000000;
|
||||
--md-sys-color-scrim: #000000;
|
||||
|
||||
--lp-color-warning: #f59e0b;
|
||||
--lp-color-warning-container: rgba(245, 158, 11, 0.16);
|
||||
--lp-color-success: #4ade80;
|
||||
--lp-color-success-container: rgba(74, 222, 128, 0.16);
|
||||
--md-sys-color-scrim-rgb: 0, 0, 0;
|
||||
}
|
||||
|
||||
/* ==========================================================================
|
||||
浅色
|
||||
========================================================================== */
|
||||
@media (prefers-color-scheme: light) {
|
||||
:root:not(.dark) {
|
||||
--md-sys-color-primary: #0b57d0;
|
||||
--md-sys-color-on-primary: #ffffff;
|
||||
--md-sys-color-primary-container: #d3e3fd;
|
||||
--md-sys-color-on-primary-container: #041e49;
|
||||
|
||||
--md-sys-color-secondary: #565e71;
|
||||
--md-sys-color-on-secondary: #ffffff;
|
||||
--md-sys-color-secondary-container: #dae2f9;
|
||||
--md-sys-color-on-secondary-container: #131c2b;
|
||||
|
||||
--md-sys-color-tertiary: #6b5778;
|
||||
--md-sys-color-on-tertiary: #ffffff;
|
||||
--md-sys-color-tertiary-container: #f2daff;
|
||||
--md-sys-color-on-tertiary-container: #251431;
|
||||
|
||||
--md-sys-color-error: #b3261e;
|
||||
--md-sys-color-on-error: #ffffff;
|
||||
--md-sys-color-error-container: #f9dedc;
|
||||
--md-sys-color-on-error-container: #410e0b;
|
||||
|
||||
--md-sys-color-background: #f8f9fc;
|
||||
--md-sys-color-on-background: #191c20;
|
||||
--md-sys-color-surface: #ffffff;
|
||||
--md-sys-color-on-surface: #191c20;
|
||||
--md-sys-color-surface-variant: #e1e2ec;
|
||||
--md-sys-color-on-surface-variant: #44474f;
|
||||
|
||||
--md-sys-color-surface-dim: #d9dae0;
|
||||
--md-sys-color-surface-bright: #ffffff;
|
||||
--md-sys-color-surface-container-lowest: #ffffff;
|
||||
--md-sys-color-surface-container-low: #f3f4f9;
|
||||
--md-sys-color-surface-container: #eff1f6;
|
||||
--md-sys-color-surface-container-high: #e8eaf0;
|
||||
--md-sys-color-surface-container-highest: #e2e4eb;
|
||||
|
||||
--md-sys-color-inverse-surface: #2f3033;
|
||||
--md-sys-color-inverse-on-surface: #f1f0f4;
|
||||
--md-sys-color-inverse-primary: #a8c7fa;
|
||||
|
||||
--md-sys-color-outline: #74777f;
|
||||
--md-sys-color-outline-variant: #c4c7d0;
|
||||
|
||||
--lp-color-warning: #b45309;
|
||||
--lp-color-warning-container: rgba(180, 83, 9, 0.14);
|
||||
--lp-color-success: #2f9e63;
|
||||
--lp-color-success-container: rgba(47, 158, 99, 0.14);
|
||||
}
|
||||
}
|
||||
|
||||
/* 手动指定浅色(Web UI 设置里的「浅色」)*/
|
||||
:root.light {
|
||||
--md-sys-color-primary: #0b57d0;
|
||||
--md-sys-color-on-primary: #ffffff;
|
||||
--md-sys-color-primary-container: #d3e3fd;
|
||||
--md-sys-color-on-primary-container: #041e49;
|
||||
|
||||
--md-sys-color-secondary: #565e71;
|
||||
--md-sys-color-on-secondary: #ffffff;
|
||||
--md-sys-color-secondary-container: #dae2f9;
|
||||
--md-sys-color-on-secondary-container: #131c2b;
|
||||
|
||||
--md-sys-color-tertiary: #6b5778;
|
||||
--md-sys-color-on-tertiary: #ffffff;
|
||||
--md-sys-color-tertiary-container: #f2daff;
|
||||
--md-sys-color-on-tertiary-container: #251431;
|
||||
|
||||
--md-sys-color-error: #b3261e;
|
||||
--md-sys-color-on-error: #ffffff;
|
||||
--md-sys-color-error-container: #f9dedc;
|
||||
--md-sys-color-on-error-container: #410e0b;
|
||||
|
||||
--md-sys-color-background: #f8f9fc;
|
||||
--md-sys-color-on-background: #191c20;
|
||||
--md-sys-color-surface: #ffffff;
|
||||
--md-sys-color-on-surface: #191c20;
|
||||
--md-sys-color-surface-variant: #e1e2ec;
|
||||
--md-sys-color-on-surface-variant: #44474f;
|
||||
|
||||
--md-sys-color-surface-dim: #d9dae0;
|
||||
--md-sys-color-surface-bright: #ffffff;
|
||||
--md-sys-color-surface-container-lowest: #ffffff;
|
||||
--md-sys-color-surface-container-low: #f3f4f9;
|
||||
--md-sys-color-surface-container: #eff1f6;
|
||||
--md-sys-color-surface-container-high: #e8eaf0;
|
||||
--md-sys-color-surface-container-highest: #e2e4eb;
|
||||
|
||||
--md-sys-color-inverse-surface: #2f3033;
|
||||
--md-sys-color-inverse-on-surface: #f1f0f4;
|
||||
--md-sys-color-inverse-primary: #a8c7fa;
|
||||
|
||||
--md-sys-color-outline: #74777f;
|
||||
--md-sys-color-outline-variant: #c4c7d0;
|
||||
--md-sys-color-scrim-rgb: 0, 0, 0;
|
||||
|
||||
--lp-color-warning: #b45309;
|
||||
--lp-color-warning-container: rgba(180, 83, 9, 0.14);
|
||||
--lp-color-success: #2f9e63;
|
||||
--lp-color-success-container: rgba(47, 158, 99, 0.14);
|
||||
}
|
||||
|
||||
/* ==========================================================================
|
||||
@material/web 组件接入令牌
|
||||
========================================================================== */
|
||||
:root {
|
||||
/* 默认控件高度与形状对齐 MD3 */
|
||||
--md-filled-button-container-shape: var(--md-sys-shape-corner-full);
|
||||
--md-outlined-button-container-shape: var(--md-sys-shape-corner-full);
|
||||
--md-text-button-container-shape: var(--md-sys-shape-corner-full);
|
||||
--md-filled-tonal-button-container-shape: var(--md-sys-shape-corner-full);
|
||||
--md-outlined-text-field-container-shape: var(--md-sys-shape-corner-small);
|
||||
--md-outlined-select-text-field-container-shape: var(--md-sys-shape-corner-small);
|
||||
}
|
||||
@@ -1,113 +0,0 @@
|
||||
import { exec } from 'kernelsu'
|
||||
|
||||
export const MODULE_DIR = '/data/adb/modules/LuminPro'
|
||||
export const CONFIG_DIR = `${MODULE_DIR}/config`
|
||||
export const CONFIG_FILE = `${MODULE_DIR}/config/config.json`
|
||||
export const BACKUP_CONFIG_FILE = `${MODULE_DIR}/config/.backup/config.json`
|
||||
export const PID_FILE = `${MODULE_DIR}/pid/inotifyd.pid`
|
||||
export const STOP_FLAG_FILE = `${MODULE_DIR}/pid/stop.flag`
|
||||
export const OPLOCK_FILE = `${MODULE_DIR}/pid/oplock`
|
||||
export const LOG_FILE = `${MODULE_DIR}/service.log`
|
||||
export const DEFAULT_NOW_BRI_FILE = '/sys/class/backlight/panel0-backlight/brightness'
|
||||
export const DEFAULT_SYS_MAX_BRI_FILE = '/sys/class/backlight/panel0-backlight/max_brightness'
|
||||
|
||||
export function showToast(msg) {
|
||||
const toast = document.getElementById('toast')
|
||||
toast.textContent = msg
|
||||
toast.classList.add('show')
|
||||
setTimeout(() => toast.classList.remove('show'), 3000)
|
||||
}
|
||||
|
||||
export async function runCmd(cmd) {
|
||||
try {
|
||||
const res = await exec(cmd)
|
||||
return res
|
||||
} catch (e) {
|
||||
console.warn(`[DEBUG] 执行命令失败 (可能是非 KSU 环境): ${cmd}`)
|
||||
|
||||
// JSON 配置模拟
|
||||
if (cmd.includes('cat') && cmd.includes('config.json')) {
|
||||
return {
|
||||
errno: 0,
|
||||
stdout: JSON.stringify({
|
||||
ui_max_bri: 4095,
|
||||
max_bri: 3500,
|
||||
steps_num: 100,
|
||||
log_max_size: 1024,
|
||||
auto_bri_sleep: 1,
|
||||
display_hdr_sleep: 0,
|
||||
hdr_enter_ratio: 1.15,
|
||||
hdr_exit_ratio: 1.05,
|
||||
sleep_time: '1900-0600',
|
||||
inotify_events: 'c',
|
||||
now_bri_file: '/sys/mock/brightness',
|
||||
max_bri_file: '/sys/mock/max_brightness',
|
||||
blacklist_apps: ['com.example.app'],
|
||||
}),
|
||||
stderr: '',
|
||||
}
|
||||
}
|
||||
|
||||
// 状态模拟
|
||||
if (cmd.includes('cat') && cmd.includes('inotifyd.pid'))
|
||||
return { errno: 0, stdout: '12345', stderr: '' }
|
||||
if (cmd.includes('[ -f') && cmd.includes('stop.flag'))
|
||||
return { errno: 0, stdout: '0', stderr: '' }
|
||||
if (cmd.includes('oplock')) return { errno: 0, stdout: 'free', stderr: '' }
|
||||
if (cmd.includes('cat') && (cmd.includes('brightness') || cmd.includes('now_bri')))
|
||||
return { errno: 0, stdout: '1200', stderr: '' }
|
||||
if (cmd.includes('cat') && (cmd.includes('max_brightness') || cmd.includes('max_bri')))
|
||||
return { errno: 0, stdout: '4095', stderr: '' }
|
||||
|
||||
// 日志模拟
|
||||
if (cmd.includes('tail') && cmd.includes('service.log')) {
|
||||
return {
|
||||
errno: 0,
|
||||
stdout:
|
||||
'[04-07 15:40:01] [service] [INFO ] LuminPro 服务启动\n[04-07 15:41:05] [up] [INFO ] 触发提升: 当前亮度 1200 ≥ 阈値 1000\n[04-07 15:42:10] [up] [SUCCESS ] 亮度提升完成 (3500)',
|
||||
stderr: '',
|
||||
}
|
||||
}
|
||||
|
||||
// 文档模拟
|
||||
if (cmd.includes('cat') && cmd.includes('.md'))
|
||||
return {
|
||||
errno: 0,
|
||||
stdout: '# 调试模式\n\n当前处于 **Web 调试模式**,显示的是模拟测试数据。',
|
||||
stderr: '',
|
||||
}
|
||||
if (cmd.includes('cat') && cmd.includes('.txt'))
|
||||
return { errno: 0, stdout: '这是 NOTE.txt 的模拟内容。', stderr: '' }
|
||||
|
||||
return { errno: -1, stdout: '', stderr: String(e) }
|
||||
}
|
||||
}
|
||||
|
||||
// 读取完整 JSON 配置
|
||||
export async function readConfig() {
|
||||
const res = await runCmd(`cat "${CONFIG_FILE}"`)
|
||||
if (res.errno !== 0 || !res.stdout.trim()) return {}
|
||||
try {
|
||||
return JSON.parse(res.stdout)
|
||||
} catch {
|
||||
return {}
|
||||
}
|
||||
}
|
||||
|
||||
// 写入完整 JSON 配置
|
||||
export async function writeConfig(obj) {
|
||||
const content = JSON.stringify(obj).replace(/'/g, "'\\''")
|
||||
return runCmd(`printf '%s' '${content}' > "${CONFIG_FILE}"`)
|
||||
}
|
||||
|
||||
// 合并更新 JSON 配置(保留其他字段)
|
||||
export async function updateConfig(updates) {
|
||||
const current = await readConfig()
|
||||
return writeConfig({ ...current, ...updates })
|
||||
}
|
||||
|
||||
// 将文件内容写入指定路径
|
||||
export async function writeFile(path, content) {
|
||||
const safeContent = String(content).replace(/'/g, "'\\''")
|
||||
return runCmd(`printf '%s' '${safeContent}' > "${path}"`)
|
||||
}
|
||||
+208
-80
@@ -1,105 +1,233 @@
|
||||
<script setup>
|
||||
import { ref } from 'vue'
|
||||
import MarkdownIt from 'markdown-it'
|
||||
import Button from '@/components/ui/Button.vue'
|
||||
import { BookOpen, ScrollText, StickyNote, X, Github } from 'lucide-vue-next'
|
||||
import { runCmd } from '../utils.js'
|
||||
import { inject, ref, computed, nextTick } from 'vue'
|
||||
import { BookOpen, ScrollText, StickyNote, Github, ExternalLink } from 'lucide-vue-next'
|
||||
import { readModuleFile } from '../api/luminpro.js'
|
||||
import { runCmd, shellQuote } from '../api/ksu.js'
|
||||
|
||||
const MODULE_DIR = '/data/adb/modules/LuminPro'
|
||||
const status = inject('status')
|
||||
const snackbar = inject('snackbar')
|
||||
|
||||
const sheetOpen = ref(false)
|
||||
const sheetTitle = ref('')
|
||||
const sheetContent = ref('')
|
||||
const sheetLoading = ref(false)
|
||||
/** markdown-it 体积较大且只有文档页用得到,打开文档时再按需加载 */
|
||||
let renderMarkdown = null
|
||||
async function ensureMarkdown() {
|
||||
if (renderMarkdown) return renderMarkdown
|
||||
const { default: MarkdownIt } = await import('markdown-it')
|
||||
const md = new MarkdownIt({ html: false, linkify: true, breaks: true })
|
||||
renderMarkdown = (text) => md.render(text)
|
||||
return renderMarkdown
|
||||
}
|
||||
|
||||
const md = new MarkdownIt({ html: true, linkify: true, typographer: true })
|
||||
|
||||
const moduleDocs = [
|
||||
{ title: 'README', file: `${MODULE_DIR}/README.md`, icon: BookOpen, md: true },
|
||||
{ title: 'README (EN)', file: `${MODULE_DIR}/README_en.md`, icon: BookOpen, md: true },
|
||||
{ title: '更新日志', file: `${MODULE_DIR}/changelog.md`, icon: ScrollText, md: true },
|
||||
{ title: 'NOTE', file: `${MODULE_DIR}/NOTE.txt`, icon: StickyNote, md: false },
|
||||
const docs = [
|
||||
{ key: 'README.md', label: '模块说明', icon: BookOpen },
|
||||
{ key: 'changelog.md', label: '更新日志', icon: ScrollText },
|
||||
{ key: 'NOTE.txt', label: '注意事项', icon: StickyNote },
|
||||
]
|
||||
|
||||
async function openModuleDoc(doc) {
|
||||
sheetTitle.value = doc.title
|
||||
sheetContent.value = ''
|
||||
sheetLoading.value = true
|
||||
sheetOpen.value = true
|
||||
try {
|
||||
const res = await runCmd(`cat "${doc.file}" 2>/dev/null`)
|
||||
if (res.errno !== 0 || !res.stdout.trim()) throw new Error('文件不存在或为空')
|
||||
sheetContent.value = doc.md
|
||||
? md.render(res.stdout)
|
||||
: res.stdout
|
||||
.replace(/&/g, '&')
|
||||
.replace(/</g, '<')
|
||||
.replace(/>/g, '>')
|
||||
.replace(/\n/g, '<br>')
|
||||
} catch (e) {
|
||||
sheetContent.value = `加载失败: ${e.message}`
|
||||
} finally {
|
||||
sheetLoading.value = false
|
||||
const docOpen = ref(false)
|
||||
const docTitle = ref('')
|
||||
const docHtml = ref('')
|
||||
const docDialog = ref(null)
|
||||
const loading = ref(false)
|
||||
|
||||
const module = computed(() => status.moduleInfo.value)
|
||||
const version = computed(() => module.value.version || '—')
|
||||
const channel = computed(() => {
|
||||
const value = module.value.channel
|
||||
if (!value || value === 'stable') return ''
|
||||
return value === 'beta' ? 'Beta' : 'Dev'
|
||||
})
|
||||
|
||||
async function openDoc(doc) {
|
||||
loading.value = true
|
||||
docTitle.value = doc.label
|
||||
docHtml.value = ''
|
||||
docOpen.value = true
|
||||
await nextTick()
|
||||
docDialog.value?.show()
|
||||
|
||||
const text = await readModuleFile(doc.key)
|
||||
loading.value = false
|
||||
if (!text.trim()) {
|
||||
docHtml.value = '<p>无法读取该文档。</p>'
|
||||
return
|
||||
}
|
||||
docHtml.value = doc.key.endsWith('.md')
|
||||
? (await ensureMarkdown())(text)
|
||||
: `<pre class="plain">${text.replace(/</g, '<')}</pre>`
|
||||
}
|
||||
|
||||
function closeSheet() {
|
||||
sheetOpen.value = false
|
||||
function closeDoc() {
|
||||
docOpen.value = false
|
||||
docDialog.value?.close()
|
||||
}
|
||||
|
||||
async function openLink(url) {
|
||||
const res = await runCmd(`am start -a android.intent.action.VIEW -d ${shellQuote(url)}`)
|
||||
if (!res.ok) snackbar('无法打开链接')
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div style="display: contents">
|
||||
<section class="card" id="about-section">
|
||||
<!-- 模块文档 -->
|
||||
<div class="about-section-title">模块文档</div>
|
||||
<div class="about-list">
|
||||
<button
|
||||
v-for="doc in moduleDocs"
|
||||
:key="doc.file"
|
||||
class="about-list-item"
|
||||
@click="openModuleDoc(doc)"
|
||||
>
|
||||
<component :is="doc.icon" :size="18" class="about-list-icon" />
|
||||
<span>{{ doc.title }}</span>
|
||||
</button>
|
||||
<section class="section">
|
||||
<div class="section-header">
|
||||
<h2 class="section-title ts-title-md">关于 LuminPro</h2>
|
||||
<span v-if="channel" class="channel-badge">{{ channel }}</span>
|
||||
</div>
|
||||
|
||||
<!-- 链接列表 -->
|
||||
<div class="about-section-title">链接</div>
|
||||
<div class="about-list">
|
||||
<button
|
||||
class="about-list-item"
|
||||
@click="
|
||||
runCmd(
|
||||
'am start -a android.intent.action.VIEW -d \'https://github.com/YuleBest/LuminPro\'',
|
||||
)
|
||||
"
|
||||
>
|
||||
<Github :size="18" class="about-list-icon" />
|
||||
<span>GitHub 项目主页</span>
|
||||
</button>
|
||||
<div class="about-meta">
|
||||
<div class="about-meta__item">
|
||||
<span class="ts-body-sm supporting">版本</span>
|
||||
<span class="ts-body mono">{{ version }}</span>
|
||||
</div>
|
||||
<div class="about-meta__item">
|
||||
<span class="ts-body-sm supporting">作者</span>
|
||||
<span class="ts-body">酷安 @于乐yule</span>
|
||||
</div>
|
||||
<div class="about-meta__item">
|
||||
<span class="ts-body-sm supporting">状态</span>
|
||||
<span class="ts-body">{{ status.statusText.value }}</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<p class="about-footer">Made with ❤ by Yule</p>
|
||||
<p class="ts-body-sm supporting">
|
||||
模块在亮度达到设定阈值时平滑提升到硬件峰值亮度,并支持休眠时段、应用黑名单与 HDR 内容避让。
|
||||
</p>
|
||||
</section>
|
||||
|
||||
<!-- 文档底部弹出抽屉 -->
|
||||
<Teleport to="body">
|
||||
<div class="doc-sheet-backdrop" :class="{ show: sheetOpen }" @click="closeSheet"></div>
|
||||
<div class="doc-sheet" :class="{ show: sheetOpen }">
|
||||
<div class="doc-sheet-header">
|
||||
<span class="doc-sheet-title">{{ sheetTitle }}</span>
|
||||
<button class="doc-sheet-close" @click="closeSheet">
|
||||
<X :size="20" />
|
||||
<section class="section">
|
||||
<h2 class="section-title ts-title-md">文档</h2>
|
||||
<div class="list">
|
||||
<button
|
||||
v-for="doc in docs"
|
||||
:key="doc.key"
|
||||
class="list-item state-layer"
|
||||
@click="openDoc(doc)"
|
||||
>
|
||||
<component :is="doc.icon" :size="18" />
|
||||
<span class="ts-body">{{ doc.label }}</span>
|
||||
</button>
|
||||
</div>
|
||||
<div class="doc-sheet-body">
|
||||
<div v-if="sheetLoading" class="doc-sheet-loading">加载中...</div>
|
||||
<!-- eslint-disable-next-line vue/no-v-html -->
|
||||
<div v-else class="doc-sheet-content" v-html="sheetContent"></div>
|
||||
</section>
|
||||
|
||||
<section class="section">
|
||||
<h2 class="section-title ts-title-md">链接</h2>
|
||||
<div class="list">
|
||||
<button
|
||||
class="list-item state-layer"
|
||||
@click="openLink('https://github.com/YuleBest/LuminPro')"
|
||||
>
|
||||
<Github :size="18" />
|
||||
<span class="ts-body">GitHub 仓库</span>
|
||||
<ExternalLink :size="16" class="link-trail" />
|
||||
</button>
|
||||
<button
|
||||
class="list-item state-layer"
|
||||
@click="openLink('https://github.com/YuleBest/LuminPro/releases')"
|
||||
>
|
||||
<ExternalLink :size="18" />
|
||||
<span class="ts-body">版本发布与更新通道</span>
|
||||
<ExternalLink :size="16" class="link-trail" />
|
||||
</button>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<md-dialog ref="docDialog" @closed="docOpen = false">
|
||||
<div slot="headline">{{ docTitle }}</div>
|
||||
<div slot="content" class="doc-content">
|
||||
<div v-if="loading" class="ts-body supporting">加载中…</div>
|
||||
<div v-else class="markdown" v-html="docHtml"></div>
|
||||
</div>
|
||||
</Teleport>
|
||||
<div slot="actions">
|
||||
<md-filled-button @click="closeDoc">关闭</md-filled-button>
|
||||
</div>
|
||||
</md-dialog>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.about-meta {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: var(--md-sys-spacing-4);
|
||||
}
|
||||
|
||||
.about-meta__item {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 2px;
|
||||
}
|
||||
|
||||
.list-item {
|
||||
border: 0;
|
||||
text-align: left;
|
||||
font: inherit;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.link-trail {
|
||||
margin-left: auto;
|
||||
color: var(--md-sys-color-on-surface-variant);
|
||||
}
|
||||
|
||||
.doc-content {
|
||||
max-height: 60vh;
|
||||
overflow-y: auto;
|
||||
min-width: min(360px, 78vw);
|
||||
}
|
||||
|
||||
.markdown {
|
||||
color: var(--md-sys-color-on-surface);
|
||||
font-size: var(--md-sys-typescale-body-medium-size);
|
||||
line-height: 1.7;
|
||||
}
|
||||
|
||||
.markdown :deep(h1),
|
||||
.markdown :deep(h2),
|
||||
.markdown :deep(h3) {
|
||||
font-size: var(--md-sys-typescale-title-medium-size);
|
||||
line-height: var(--md-sys-typescale-title-medium-line-height);
|
||||
margin: var(--md-sys-spacing-4) 0 var(--md-sys-spacing-2);
|
||||
}
|
||||
|
||||
.markdown :deep(h1) {
|
||||
font-size: var(--md-sys-typescale-title-large-size);
|
||||
}
|
||||
|
||||
.markdown :deep(p),
|
||||
.markdown :deep(li) {
|
||||
margin: 0 0 var(--md-sys-spacing-2);
|
||||
}
|
||||
|
||||
.markdown :deep(code) {
|
||||
font-family: var(--md-sys-typescale-font-mono);
|
||||
background-color: var(--md-sys-color-surface-container-high);
|
||||
padding: 1px 4px;
|
||||
border-radius: var(--md-sys-shape-corner-extra-small);
|
||||
}
|
||||
|
||||
.markdown :deep(pre) {
|
||||
background-color: var(--md-sys-color-surface-container-high);
|
||||
padding: var(--md-sys-spacing-3);
|
||||
border-radius: var(--md-sys-shape-corner-small);
|
||||
overflow-x: auto;
|
||||
}
|
||||
|
||||
.markdown :deep(a) {
|
||||
color: var(--md-sys-color-primary);
|
||||
}
|
||||
|
||||
.markdown :deep(.plain) {
|
||||
white-space: pre-wrap;
|
||||
}
|
||||
|
||||
.markdown :deep(table) {
|
||||
border-collapse: collapse;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.markdown :deep(th),
|
||||
.markdown :deep(td) {
|
||||
border-bottom: 1px solid var(--md-sys-color-outline-variant);
|
||||
padding: 6px 8px;
|
||||
text-align: left;
|
||||
}
|
||||
</style>
|
||||
+417
-333
@@ -1,67 +1,99 @@
|
||||
<script setup>
|
||||
import { inject, ref, computed, onMounted, reactive } from 'vue'
|
||||
import { getPackagesInfo } from 'kernelsu'
|
||||
import { inject, ref, computed, onUnmounted, nextTick } from 'vue'
|
||||
import { useVirtualizer } from '@tanstack/vue-virtual'
|
||||
import { useApps } from '@/composables/useApps.js'
|
||||
import { runCmd } from '../utils.js'
|
||||
import Button from '@/components/ui/Button.vue'
|
||||
import {
|
||||
RefreshCw,
|
||||
Eye,
|
||||
EyeOff,
|
||||
Sparkles,
|
||||
Plus,
|
||||
CheckCheck,
|
||||
Square,
|
||||
CheckSquare,
|
||||
Search,
|
||||
Save,
|
||||
X,
|
||||
Check,
|
||||
ChevronDown,
|
||||
ScanSearch,
|
||||
ChevronLeft,
|
||||
Monitor,
|
||||
Clock,
|
||||
CircleCheck,
|
||||
Check,
|
||||
} from 'lucide-vue-next'
|
||||
import ActionMenu from '../components/ActionMenu.vue'
|
||||
import AppTextField from '../components/AppTextField.vue'
|
||||
import PromptDialog from '../components/PromptDialog.vue'
|
||||
import { fetchFocus } from '../api/luminpro.js'
|
||||
|
||||
const showToast = inject('showToast')
|
||||
const oplock = inject('oplock')
|
||||
const appsMenuOpen = ref(false)
|
||||
const appsApi = inject('apps')
|
||||
const status = inject('status')
|
||||
const snackbar = inject('snackbar')
|
||||
|
||||
const {
|
||||
apps,
|
||||
isLoading,
|
||||
loadError,
|
||||
searchKeyword,
|
||||
showingSystemApps,
|
||||
savedBlacklist,
|
||||
activityEntries,
|
||||
load,
|
||||
save,
|
||||
hasActivity,
|
||||
getActivities,
|
||||
addActivity,
|
||||
removeActivity,
|
||||
onCheckboxChange,
|
||||
toggleSystemApps,
|
||||
selectAll,
|
||||
selectNone,
|
||||
invertSelection,
|
||||
smartSelect,
|
||||
getFilteredApps,
|
||||
} = useApps()
|
||||
const locked = computed(() => status.oplock.value.locked)
|
||||
|
||||
const filteredApps = computed(() => getFilteredApps())
|
||||
const menuItems = computed(() => [
|
||||
{
|
||||
key: 'toggle-system',
|
||||
label: appsApi.showingSystemApps.value ? '隐藏系统应用' : '显示系统应用',
|
||||
},
|
||||
{ key: 'smart', label: '智能选择' },
|
||||
{ key: 'manual', label: '手动添加包名' },
|
||||
{ key: 'all', label: '全选' },
|
||||
{ key: 'none', label: '全不选' },
|
||||
{ key: 'invert', label: '反选' },
|
||||
])
|
||||
|
||||
const filteredApps = computed(() => appsApi.getFilteredApps())
|
||||
const appCount = computed(() => filteredApps.value.length)
|
||||
|
||||
// 虚拟滚动:真机 500+ 应用时只渲染可视区附近的行
|
||||
function onMenuSelect(key) {
|
||||
switch (key) {
|
||||
case 'toggle-system':
|
||||
appsApi.toggleSystemApps()
|
||||
break
|
||||
case 'smart':
|
||||
appsApi.smartSelect(snackbar)
|
||||
break
|
||||
case 'manual':
|
||||
manualOpen.value = true
|
||||
break
|
||||
case 'all':
|
||||
appsApi.selectAll()
|
||||
break
|
||||
case 'none':
|
||||
appsApi.selectNone()
|
||||
break
|
||||
case 'invert':
|
||||
appsApi.invertSelection()
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
// ── 手动添加包名 ───────────────────────────────────────────────────
|
||||
const manualOpen = ref(false)
|
||||
|
||||
async function onManualAdd(pkg) {
|
||||
manualOpen.value = false
|
||||
if (!pkg) return
|
||||
const existing = appsApi.apps.value.find((a) => a.packageName === pkg)
|
||||
if (existing) {
|
||||
existing.checked = true
|
||||
appsApi.reorder()
|
||||
snackbar('已为你自动勾选并置顶')
|
||||
return
|
||||
}
|
||||
appsApi.apps.value.unshift({
|
||||
packageName: pkg,
|
||||
appLabel: '未知 (手动添加)',
|
||||
isSystem: false,
|
||||
uid: '自定义',
|
||||
checked: true,
|
||||
expanded: false,
|
||||
})
|
||||
appsApi.reorder()
|
||||
snackbar('已添加到列表顶部')
|
||||
}
|
||||
|
||||
// ── 虚拟滚动 ───────────────────────────────────────────────────────
|
||||
const listEl = ref(null)
|
||||
const rowVirtualizer = useVirtualizer(
|
||||
computed(() => ({
|
||||
count: filteredApps.value.length,
|
||||
getScrollElement: () => listEl.value,
|
||||
estimateSize: () => 52,
|
||||
estimateSize: () => 64,
|
||||
overscan: 6,
|
||||
})),
|
||||
)
|
||||
@@ -77,263 +109,149 @@ function measureElement(el) {
|
||||
if (el) rowVirtualizer.value.measureElement(el)
|
||||
}
|
||||
|
||||
onMounted(() => load())
|
||||
|
||||
// 关闭下拉菜单 (点击外部)
|
||||
function handleBodyClick() {
|
||||
appsMenuOpen.value = false
|
||||
}
|
||||
|
||||
// 按活动屏蔽
|
||||
// ── 按活动屏蔽 ─────────────────────────────────────────────────────
|
||||
const activityInput = ref('')
|
||||
function doAddActivity() {
|
||||
const val = activityInput.value.trim()
|
||||
if (!val) return
|
||||
const parts = val.split('/')
|
||||
|
||||
function addActivityEntry() {
|
||||
const value = activityInput.value.trim()
|
||||
const parts = value.split('/')
|
||||
if (parts.length !== 2 || !parts[0] || !parts[1]) {
|
||||
showToast('格式错误,请输入 包名/完整活动类名')
|
||||
snackbar('格式错误,请输入 包名/完整活动类名')
|
||||
return
|
||||
}
|
||||
addActivity(val)
|
||||
appsApi.addActivity(value)
|
||||
activityInput.value = ''
|
||||
showToast(`已添加: ${val}`)
|
||||
snackbar(`已添加: ${value}`)
|
||||
}
|
||||
|
||||
function menuToggleSystemApps() {
|
||||
toggleSystemApps()
|
||||
appsMenuOpen.value = false
|
||||
}
|
||||
function menuSelectAll() {
|
||||
selectAll()
|
||||
appsMenuOpen.value = false
|
||||
}
|
||||
function menuSelectNone() {
|
||||
selectNone()
|
||||
appsMenuOpen.value = false
|
||||
}
|
||||
function menuInvertSelection() {
|
||||
invertSelection()
|
||||
appsMenuOpen.value = false
|
||||
}
|
||||
|
||||
// 手动添加包名
|
||||
async function handleManualAdd() {
|
||||
appsMenuOpen.value = false
|
||||
const pkg = prompt('请输入完整应用包名(例如: com.example.app):')
|
||||
if (!pkg?.trim()) return
|
||||
const realPkg = pkg.trim()
|
||||
const existing = apps.value.find((a) => a.packageName === realPkg)
|
||||
if (existing) {
|
||||
existing.checked = true
|
||||
onCheckboxChange()
|
||||
showToast('已为你自动勾选并置顶')
|
||||
return
|
||||
}
|
||||
showToast('正在获取应用信息...')
|
||||
let appData = {
|
||||
packageName: realPkg,
|
||||
appLabel: '未知 (手动添加)',
|
||||
isSystem: false,
|
||||
uid: '自定义',
|
||||
}
|
||||
try {
|
||||
const info = await getPackagesInfo([realPkg])
|
||||
if (info?.length > 0) appData = info[0]
|
||||
} catch {}
|
||||
apps.value.unshift(reactive({ ...appData, checked: true, expanded: false }))
|
||||
onCheckboxChange()
|
||||
showToast('已添加到列表顶部')
|
||||
}
|
||||
|
||||
// Activity Picker
|
||||
const pickerVisible = ref(false)
|
||||
// ── 活动抓取(扫描当前前台 Activity)────────────────────────────────
|
||||
const pickerOpen = ref(false)
|
||||
const pickerStep = ref(1)
|
||||
const pickerStatusText = ref('等待中...')
|
||||
const pickerStatus = ref('等待中...')
|
||||
const pickerPolling = ref(false)
|
||||
const pickerResult = ref('')
|
||||
const pickerDialog = ref(null)
|
||||
let pollingTimer = null
|
||||
|
||||
function openPicker() {
|
||||
stopPolling()
|
||||
async function openPicker() {
|
||||
pickerStep.value = 1
|
||||
pickerStatusText.value = '等待中...'
|
||||
pickerStatus.value = '等待中...'
|
||||
pickerResult.value = ''
|
||||
pickerPolling.value = false
|
||||
pickerVisible.value = true
|
||||
pickerOpen.value = true
|
||||
await nextTick()
|
||||
pickerDialog.value?.show()
|
||||
}
|
||||
|
||||
function closePicker() {
|
||||
stopPolling()
|
||||
pickerVisible.value = false
|
||||
pickerOpen.value = false
|
||||
pickerDialog.value?.close()
|
||||
}
|
||||
|
||||
function stopPolling() {
|
||||
if (pollingTimer) {
|
||||
clearInterval(pollingTimer)
|
||||
pollingTimer = null
|
||||
}
|
||||
}
|
||||
|
||||
function startPolling() {
|
||||
pickerPolling.value = true
|
||||
pickerStatusText.value = '检测中,请切换到目标界面...'
|
||||
pickerStatus.value = '检测中,请切换到目标界面...'
|
||||
stopPolling()
|
||||
pollingTimer = setInterval(async () => {
|
||||
try {
|
||||
const res = await runCmd(
|
||||
`dumpsys window 2>/dev/null | grep mCurrentFocus | sed 's/.*u[0-9][0-9]* //' | sed 's/}.*//'`,
|
||||
)
|
||||
if (res.errno !== 0) return
|
||||
const activity = res.stdout.trim()
|
||||
const res = await fetchFocus()
|
||||
const activity = (res.focus || '').trim()
|
||||
if (!activity || activity.toLowerCase().includes('webui')) return
|
||||
stopPolling()
|
||||
pickerPolling.value = false
|
||||
pickerResult.value = activity
|
||||
pickerStep.value = 3
|
||||
} catch {}
|
||||
} catch {
|
||||
/* 忽略单次失败,继续轮询 */
|
||||
}
|
||||
}, 600)
|
||||
}
|
||||
|
||||
function confirmPicker() {
|
||||
if (!pickerResult.value) return
|
||||
addActivity(pickerResult.value)
|
||||
showToast(`已添加: ${pickerResult.value}`)
|
||||
appsApi.addActivity(pickerResult.value)
|
||||
snackbar(`已添加: ${pickerResult.value}`)
|
||||
closePicker()
|
||||
}
|
||||
function retryPicker() {
|
||||
pickerStep.value = 2
|
||||
pickerPolling.value = false
|
||||
stopPolling()
|
||||
}
|
||||
|
||||
onUnmounted(stopPolling)
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div style="display: contents">
|
||||
<section class="card" id="apps-section">
|
||||
<div class="card-header" style="margin-bottom: 8px">
|
||||
<h2>黑名单</h2>
|
||||
<div class="header-actions dropdown-container">
|
||||
<Button variant="ghost" size="icon" @click="load">
|
||||
<RefreshCw :size="18" />
|
||||
</Button>
|
||||
<Button variant="ghost" size="icon" @click="smartSelect">
|
||||
<span class="sr-only">智能选择</span>
|
||||
<Sparkles :size="18" />
|
||||
</Button>
|
||||
<Button variant="ghost" size="icon" @click="appsMenuOpen = !appsMenuOpen">
|
||||
<span class="sr-only">更多</span>
|
||||
<svg
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
width="18"
|
||||
height="18"
|
||||
viewBox="0 0 24 24"
|
||||
fill="none"
|
||||
stroke="currentColor"
|
||||
stroke-width="2"
|
||||
stroke-linecap="round"
|
||||
stroke-linejoin="round"
|
||||
>
|
||||
<circle cx="12" cy="12" r="1" />
|
||||
<circle cx="12" cy="5" r="1" />
|
||||
<circle cx="12" cy="19" r="1" />
|
||||
</svg>
|
||||
</Button>
|
||||
<div class="dropdown-menu" :class="{ show: appsMenuOpen }" @click.stop>
|
||||
<div class="dropdown-item" @click="menuToggleSystemApps">
|
||||
<component :is="showingSystemApps ? EyeOff : Eye" :size="18" />
|
||||
<span>{{ showingSystemApps ? '隐藏系统应用' : '显示系统应用' }}</span>
|
||||
</div>
|
||||
<div class="dropdown-item" @click="handleManualAdd">
|
||||
<Plus :size="18" /><span>手动添加包名</span>
|
||||
</div>
|
||||
<div class="dropdown-item" @click="menuSelectAll">
|
||||
<CheckCheck :size="18" /><span>全选</span>
|
||||
</div>
|
||||
<div class="dropdown-item" @click="menuSelectNone">
|
||||
<Square :size="18" /><span>全不选</span>
|
||||
</div>
|
||||
<div class="dropdown-item" @click="menuInvertSelection">
|
||||
<CheckSquare :size="18" /><span>反选</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<section class="section">
|
||||
<div class="section-header">
|
||||
<h2 class="section-title ts-title-md">黑名单</h2>
|
||||
<span
|
||||
v-if="appsApi.unsavedCount.value"
|
||||
class="state-badge is-unsaved"
|
||||
>未保存</span>
|
||||
<ActionMenu :items="menuItems" :disabled="locked" @select="onMenuSelect" />
|
||||
</div>
|
||||
|
||||
<p class="app-list-hint">
|
||||
被选中的应用将不生效本模块<br />推荐选择视频类、相册等需展示 HDR 内容的应用
|
||||
<p class="ts-body-sm supporting">
|
||||
被选中的应用在前台时不执行亮度提升。<br />
|
||||
推荐选择视频类、相册等需要展示 HDR 内容的应用。
|
||||
</p>
|
||||
|
||||
<!-- 按活动屏蔽 -->
|
||||
<div class="activity-block-card">
|
||||
<div class="activity-block-header">
|
||||
<span class="activity-block-label">按活动屏蔽</span>
|
||||
<button class="btn-picker-trigger" @click="openPicker">
|
||||
<ScanSearch :size="12" /> 扫描获取
|
||||
</button>
|
||||
<div class="activity-block">
|
||||
<div class="activity-block__header">
|
||||
<span class="ts-title-sm">按活动屏蔽</span>
|
||||
<md-text-button @click="openPicker">
|
||||
<ScanSearch :size="14" /> 扫描获取
|
||||
</md-text-button>
|
||||
</div>
|
||||
<div class="activity-block-row">
|
||||
<input
|
||||
<div class="activity-block__row">
|
||||
<AppTextField
|
||||
v-model="activityInput"
|
||||
type="text"
|
||||
class="activity-block-input"
|
||||
placeholder="com.pkg/com.pkg.ActivityClass"
|
||||
autocomplete="off"
|
||||
spellcheck="false"
|
||||
@keydown.enter="doAddActivity"
|
||||
label="com.pkg/com.pkg.ActivityClass"
|
||||
@keydown.enter="addActivityEntry"
|
||||
/>
|
||||
<Button
|
||||
style="
|
||||
padding: 0 14px;
|
||||
border-radius: var(--border-radius-s);
|
||||
font-size: 0.8125rem;
|
||||
white-space: nowrap;
|
||||
flex-shrink: 0;
|
||||
"
|
||||
@click="doAddActivity"
|
||||
>确认</Button
|
||||
>
|
||||
<md-filled-button :disabled="locked" @click="addActivityEntry">确认</md-filled-button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 搜索栏 + 保存 -->
|
||||
<div style="display: flex; gap: 8px; align-items: stretch; margin-bottom: var(--spacing-m)">
|
||||
<div class="app-search-container" style="flex: 1; margin-bottom: 0">
|
||||
<Search :size="18" class="search-icon" />
|
||||
<input
|
||||
v-model="searchKeyword"
|
||||
type="text"
|
||||
class="app-search-input"
|
||||
placeholder="应用名称或包名"
|
||||
<!-- 搜索 -->
|
||||
<div class="search-row">
|
||||
<md-outlined-text-field
|
||||
:value="appsApi.searchKeyword.value"
|
||||
label="应用名称或包名"
|
||||
autocomplete="off"
|
||||
spellcheck="false"
|
||||
/>
|
||||
<span class="count-badge">{{ appCount }}</span>
|
||||
</div>
|
||||
<Button
|
||||
style="
|
||||
padding: 0 16px;
|
||||
border-radius: var(--border-radius-s);
|
||||
font-size: 0.8125rem;
|
||||
white-space: nowrap;
|
||||
flex-shrink: 0;
|
||||
"
|
||||
:disabled="oplock.isLocked.value"
|
||||
@click="save(showToast)"
|
||||
>保存</Button
|
||||
@input="appsApi.searchKeyword.value = $event.target.value"
|
||||
>
|
||||
<Search slot="leading-icon" :size="18" />
|
||||
</md-outlined-text-field>
|
||||
<md-filled-button :disabled="locked" @click="appsApi.save(snackbar)">
|
||||
<Save :size="16" /> 保存
|
||||
</md-filled-button>
|
||||
</div>
|
||||
|
||||
<!-- 应用列表 -->
|
||||
<div class="app-list-container" id="app-list-container" ref="listEl">
|
||||
<div
|
||||
v-if="isLoading"
|
||||
style="text-align: center; padding: 20px; color: var(--md-sys-color-on-surface-variant)"
|
||||
>
|
||||
加载中...
|
||||
<div class="count-row ts-body-sm supporting">
|
||||
<span>共 {{ appCount }} 个应用</span>
|
||||
<span v-if="appsApi.isLoading.value">加载中…</span>
|
||||
</div>
|
||||
<div
|
||||
v-else-if="loadError"
|
||||
style="text-align: center; padding: 20px; color: var(--md-sys-color-error)"
|
||||
>
|
||||
加载失败: {{ loadError }}
|
||||
|
||||
<!-- 应用列表(虚拟滚动) -->
|
||||
<div ref="listEl" class="app-list scroll-area">
|
||||
<div v-if="appsApi.isLoading.value" class="empty-state">加载中…</div>
|
||||
<div v-else-if="appsApi.loadError.value" class="empty-state error">
|
||||
加载失败: {{ appsApi.loadError.value }}
|
||||
</div>
|
||||
<div v-else class="app-virtual-spacer" :style="{ height: `${totalListHeight}px` }">
|
||||
<div v-else-if="appCount === 0" class="empty-state">没有匹配的应用</div>
|
||||
<div
|
||||
v-else
|
||||
class="app-virtual-spacer"
|
||||
:style="{ height: `${totalListHeight}px` }"
|
||||
>
|
||||
<div
|
||||
v-for="row in virtualRows"
|
||||
:key="row.app.packageName"
|
||||
@@ -342,56 +260,43 @@ function retryPicker() {
|
||||
class="app-virtual-item"
|
||||
:style="{ transform: `translateY(${row.start}px)` }"
|
||||
>
|
||||
<div class="app-list-item">
|
||||
<div class="app-item-main-row">
|
||||
<label class="app-checkbox-label">
|
||||
<input
|
||||
type="checkbox"
|
||||
class="app-checkbox"
|
||||
:class="{ unsaved: row.app.checked && !savedBlacklist?.has(row.app.packageName) }"
|
||||
:data-pkg="row.app.packageName"
|
||||
v-model="row.app.checked"
|
||||
@change="onCheckboxChange"
|
||||
/>
|
||||
<span
|
||||
class="app-checkbox-custom"
|
||||
:class="{ partial: !row.app.checked && hasActivity(row.app.packageName) }"
|
||||
></span>
|
||||
</label>
|
||||
<div class="app-info">
|
||||
<span class="app-name">
|
||||
<div class="app-row">
|
||||
<div class="app-row__main">
|
||||
<md-checkbox
|
||||
:checked="row.app.checked"
|
||||
@change="row.app.checked = $event.target.checked; appsApi.reorder()"
|
||||
></md-checkbox>
|
||||
<div class="app-row__text">
|
||||
<span class="app-row__name">
|
||||
{{ row.app.appLabel }}
|
||||
<span class="app-uid">{{ row.app.uid }}</span>
|
||||
<span class="app-row__uid ts-body-sm supporting">{{ row.app.uid }}</span>
|
||||
</span>
|
||||
<span class="app-pkg">
|
||||
<span class="app-row__pkg ts-body-sm supporting">
|
||||
{{ row.app.packageName }}
|
||||
<span v-if="row.app.isSystem" class="app-badge">系统</span>
|
||||
<span v-if="row.app.isSystem" class="app-row__badge">系统</span>
|
||||
</span>
|
||||
</div>
|
||||
<button
|
||||
v-if="hasActivity(row.app.packageName)"
|
||||
class="app-activities-chevron"
|
||||
:class="{ expanded: row.app.expanded }"
|
||||
@click.stop="row.app.expanded = !row.app.expanded"
|
||||
<md-icon-button
|
||||
v-if="appsApi.hasActivity(row.app.packageName)"
|
||||
:title="row.app.expanded ? '收起活动' : '展开活动'"
|
||||
@click="row.app.expanded = !row.app.expanded"
|
||||
>
|
||||
<ChevronDown :size="16" />
|
||||
</button>
|
||||
<ChevronDown :size="18" :class="['chevron', { open: row.app.expanded }]" />
|
||||
</md-icon-button>
|
||||
</div>
|
||||
<!-- 活动列表 -->
|
||||
|
||||
<div v-if="appsApi.hasActivity(row.app.packageName)" class="app-row__activities" :class="{ open: row.app.expanded }">
|
||||
<div
|
||||
v-if="hasActivity(row.app.packageName)"
|
||||
class="app-activities-list"
|
||||
:class="{ show: row.app.expanded }"
|
||||
>
|
||||
<div
|
||||
v-for="entry in getActivities(row.app.packageName)"
|
||||
v-for="entry in appsApi.getActivities(row.app.packageName)"
|
||||
:key="entry"
|
||||
class="activity-entry-item"
|
||||
class="activity-entry"
|
||||
>
|
||||
<span class="activity-entry-path">{{ entry.slice(row.app.packageName.length + 1) }}</span>
|
||||
<button class="activity-entry-delete" @click="removeActivity(entry)">
|
||||
<X :size="14" />
|
||||
</button>
|
||||
<span class="activity-entry__path ts-body-sm mono">
|
||||
{{ entry.slice(row.app.packageName.length + 1) }}
|
||||
</span>
|
||||
<md-icon-button title="移除" @click="appsApi.removeActivity(entry)">
|
||||
<X :size="16" />
|
||||
</md-icon-button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -400,68 +305,247 @@ function retryPicker() {
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<!-- Activity Picker 覆盖层 -->
|
||||
<Teleport to="body">
|
||||
<div
|
||||
class="activity-picker-overlay"
|
||||
:class="{ show: pickerVisible }"
|
||||
id="activity-picker-overlay"
|
||||
>
|
||||
<div class="activity-picker-header">
|
||||
<button class="picker-back-btn" @click="closePicker">
|
||||
<ChevronLeft :size="20" />
|
||||
</button>
|
||||
<span class="picker-title">获取活动名</span>
|
||||
<PromptDialog
|
||||
:open="manualOpen"
|
||||
headline="手动添加包名"
|
||||
label="应用包名"
|
||||
description="例如 com.example.app;若该应用不在列表中,将直接加入黑名单。"
|
||||
confirm-text="添加"
|
||||
@confirm="onManualAdd"
|
||||
@cancel="manualOpen = false"
|
||||
/>
|
||||
|
||||
<!-- 活动抓取向导 -->
|
||||
<md-dialog ref="pickerDialog" @closed="pickerOpen = false">
|
||||
<div slot="headline">
|
||||
<span class="picker-headline">
|
||||
<md-icon-button @click="closePicker"><ChevronLeft :size="20" /></md-icon-button>
|
||||
获取活动名
|
||||
</span>
|
||||
</div>
|
||||
<div class="picker-steps-indicator">
|
||||
<div
|
||||
v-for="n in 3"
|
||||
:key="n"
|
||||
class="picker-step-dot"
|
||||
:class="{ active: pickerStep === n }"
|
||||
></div>
|
||||
</div>
|
||||
<div class="activity-picker-body">
|
||||
<!-- 步骤 1 -->
|
||||
<div class="picker-step" v-show="pickerStep === 1">
|
||||
<div class="picker-step-icon"><Monitor :size="52" stroke-width="1.5" /></div>
|
||||
<h3 class="picker-step-title">将 Web UI 挂小窗</h3>
|
||||
<p class="picker-step-desc">
|
||||
在开始获取前,请先将当前 Web UI 调整为<strong>小窗模式</strong>。<br /><br />
|
||||
这样在后续步骤中,你可以同时操作目标应用并看到 Web UI 的反馈。
|
||||
<div slot="content" class="picker-content">
|
||||
<div v-if="pickerStep === 1" class="picker-step">
|
||||
<Monitor :size="48" :stroke-width="1.5" />
|
||||
<h3 class="ts-title-md">将 Web UI 挂为小窗</h3>
|
||||
<p class="ts-body supporting">
|
||||
开始之前先把当前 Web UI 切到小窗模式,这样后续可以一边操作目标应用,一边看到这里的反馈。
|
||||
</p>
|
||||
<Button class="picker-action-btn" @click="pickerStep = 2">已挂小窗,下一步</Button>
|
||||
<md-filled-button @click="pickerStep = 2">已挂小窗,下一步</md-filled-button>
|
||||
</div>
|
||||
<!-- 步骤 2 -->
|
||||
<div class="picker-step" v-show="pickerStep === 2">
|
||||
<div class="picker-step-icon"><Clock :size="52" stroke-width="1.5" /></div>
|
||||
<h3 class="picker-step-title">切换到目标界面</h3>
|
||||
<p class="picker-step-desc">
|
||||
切换到需要屏蔽的应用界面,并点击 「开始获取」<br /><br />
|
||||
检测到非 Web UI 界面后将<strong>自动停止</strong>。<br /><br />
|
||||
<span class="picker-status-text" :class="{ polling: pickerPolling }">{{
|
||||
pickerStatusText
|
||||
}}</span>
|
||||
|
||||
<div v-else-if="pickerStep === 2" class="picker-step">
|
||||
<Clock :size="48" :stroke-width="1.5" />
|
||||
<h3 class="ts-title-md">切换到目标界面</h3>
|
||||
<p class="ts-body supporting">
|
||||
切换到需要屏蔽的应用界面,然后点击「开始获取」。检测到非 Web UI 界面后会自动停止。
|
||||
</p>
|
||||
<Button class="picker-action-btn" :disabled="pickerPolling" @click="startPolling"
|
||||
>开始获取</Button
|
||||
>
|
||||
<p class="ts-body" :class="{ 'pulse-text': pickerPolling }">{{ pickerStatus }}</p>
|
||||
<md-filled-button :disabled="pickerPolling" @click="startPolling">开始获取</md-filled-button>
|
||||
</div>
|
||||
<!-- 步骤 3 -->
|
||||
<div class="picker-step" v-show="pickerStep === 3">
|
||||
<div class="picker-step-icon">
|
||||
<CircleCheck :size="52" stroke-width="1.5" />
|
||||
</div>
|
||||
<h3 class="picker-step-title">检测到活动</h3>
|
||||
<p class="picker-step-desc">以下活动将被添加到按活动屏蔽列表:</p>
|
||||
<div class="picker-result-box">{{ pickerResult }}</div>
|
||||
<div class="picker-result-actions">
|
||||
<Button variant="secondary" @click="retryPicker">重试</Button>
|
||||
<Button @click="confirmPicker"><Check :size="15" /> 确认添加</Button>
|
||||
|
||||
<div v-else class="picker-step">
|
||||
<CircleCheck :size="48" :stroke-width="1.5" />
|
||||
<h3 class="ts-title-md">检测到活动</h3>
|
||||
<p class="ts-body supporting">以下活动将被添加到按活动屏蔽列表:</p>
|
||||
<code class="picker-result ts-body mono">{{ pickerResult }}</code>
|
||||
</div>
|
||||
</div>
|
||||
<div slot="actions">
|
||||
<md-text-button v-if="pickerStep === 3" @click="pickerStep = 2; pickerPolling = false">
|
||||
重试
|
||||
</md-text-button>
|
||||
<md-filled-button v-if="pickerStep === 3" @click="confirmPicker">
|
||||
<Check :size="16" /> 确认添加
|
||||
</md-filled-button>
|
||||
</div>
|
||||
</div>
|
||||
</Teleport>
|
||||
</div>
|
||||
</md-dialog>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.activity-block {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: var(--md-sys-spacing-2);
|
||||
padding: var(--md-sys-spacing-3);
|
||||
border-radius: var(--md-sys-shape-corner-medium);
|
||||
background-color: var(--md-sys-color-surface-container);
|
||||
}
|
||||
|
||||
.activity-block__header {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: var(--md-sys-spacing-2);
|
||||
}
|
||||
|
||||
.activity-block__row,
|
||||
.search-row {
|
||||
display: flex;
|
||||
align-items: flex-start;
|
||||
gap: var(--md-sys-spacing-2);
|
||||
}
|
||||
|
||||
.activity-block__row > :first-child,
|
||||
.search-row > :first-child {
|
||||
flex: 1;
|
||||
}
|
||||
|
||||
.activity-block__row > md-filled-button,
|
||||
.search-row > md-filled-button {
|
||||
flex: 0 0 auto;
|
||||
margin-top: 4px;
|
||||
}
|
||||
|
||||
.count-row {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
}
|
||||
|
||||
.app-list {
|
||||
max-height: 60vh;
|
||||
overflow-y: auto;
|
||||
border-radius: var(--md-sys-shape-corner-medium);
|
||||
}
|
||||
|
||||
.app-virtual-spacer {
|
||||
position: relative;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.app-virtual-item {
|
||||
position: absolute;
|
||||
top: 0;
|
||||
left: 0;
|
||||
width: 100%;
|
||||
padding-bottom: var(--md-sys-spacing-2);
|
||||
}
|
||||
|
||||
.app-row {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
border-radius: var(--md-sys-shape-corner-medium);
|
||||
background-color: var(--md-sys-color-surface-container);
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.app-row__main {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: var(--md-sys-spacing-2);
|
||||
padding: var(--md-sys-spacing-2) var(--md-sys-spacing-3) var(--md-sys-spacing-2) 0;
|
||||
min-height: 64px;
|
||||
}
|
||||
|
||||
.app-row__text {
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 2px;
|
||||
}
|
||||
|
||||
.app-row__name {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 6px;
|
||||
color: var(--md-sys-color-on-surface);
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.app-row__uid {
|
||||
flex: 0 0 auto;
|
||||
}
|
||||
|
||||
.app-row__pkg {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 6px;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.app-row__badge {
|
||||
flex: 0 0 auto;
|
||||
padding: 1px 6px;
|
||||
border-radius: var(--md-sys-shape-corner-full);
|
||||
background-color: var(--md-sys-color-surface-container-highest);
|
||||
font-size: var(--md-sys-typescale-label-small-size);
|
||||
}
|
||||
|
||||
.chevron {
|
||||
transition: transform var(--md-sys-motion-duration-short4)
|
||||
var(--md-sys-motion-easing-standard);
|
||||
}
|
||||
|
||||
.chevron.open {
|
||||
transform: rotate(180deg);
|
||||
}
|
||||
|
||||
.app-row__activities {
|
||||
max-height: 0;
|
||||
overflow: hidden;
|
||||
transition: max-height var(--md-sys-motion-duration-medium2)
|
||||
var(--md-sys-motion-easing-emphasized);
|
||||
}
|
||||
|
||||
.app-row__activities.open {
|
||||
max-height: 320px;
|
||||
overflow-y: auto;
|
||||
}
|
||||
|
||||
.activity-entry {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: var(--md-sys-spacing-2);
|
||||
padding: 2px var(--md-sys-spacing-2) 2px var(--md-sys-spacing-4);
|
||||
border-top: 1px solid var(--md-sys-color-outline-variant);
|
||||
}
|
||||
|
||||
.activity-entry__path {
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
color: var(--md-sys-color-on-surface-variant);
|
||||
}
|
||||
|
||||
.picker-headline {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: var(--md-sys-spacing-2);
|
||||
}
|
||||
|
||||
.picker-content {
|
||||
min-width: min(320px, 76vw);
|
||||
}
|
||||
|
||||
.picker-step {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
gap: var(--md-sys-spacing-3);
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.picker-step h3 {
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.picker-step p {
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.picker-result {
|
||||
display: block;
|
||||
width: 100%;
|
||||
padding: var(--md-sys-spacing-3);
|
||||
border-radius: var(--md-sys-shape-corner-small);
|
||||
background-color: var(--md-sys-color-surface-container-high);
|
||||
word-break: break-all;
|
||||
text-align: left;
|
||||
}
|
||||
</style>
|
||||
+304
-345
@@ -1,430 +1,389 @@
|
||||
<script setup>
|
||||
import { inject, ref } from 'vue'
|
||||
import Button from '@/components/ui/Button.vue'
|
||||
import Input from '@/components/ui/Input.vue'
|
||||
import Textarea from '@/components/ui/Textarea.vue'
|
||||
import Switch from '@/components/ui/Switch.vue'
|
||||
import Label from '@/components/ui/Label.vue'
|
||||
import {
|
||||
Save,
|
||||
Settings2,
|
||||
ShieldCheck,
|
||||
FileText,
|
||||
Settings,
|
||||
Monitor,
|
||||
HelpCircle,
|
||||
ChevronDown,
|
||||
} from 'lucide-vue-next'
|
||||
import { runCmd } from '../utils.js'
|
||||
import { inject, ref, computed, nextTick } from 'vue'
|
||||
import { Save, RotateCcw, Settings2, ShieldCheck, Wrench, Palette, ChevronDown, ListTree } from 'lucide-vue-next'
|
||||
import AppTextField from '../components/AppTextField.vue'
|
||||
import AppSwitch from '../components/AppSwitch.vue'
|
||||
import ConfirmDialog from '../components/ConfirmDialog.vue'
|
||||
|
||||
const config = inject('config')
|
||||
const showToast = inject('showToast')
|
||||
const restartRefresh = inject('restartRefresh')
|
||||
const oplock = inject('oplock')
|
||||
const prefs = inject('prefs')
|
||||
const status = inject('status')
|
||||
const snackbar = inject('snackbar')
|
||||
|
||||
const form = config.form
|
||||
const locked = computed(() => status.oplock.value.locked)
|
||||
|
||||
const advancedOpen = ref(false)
|
||||
const webuiOpen = ref(false)
|
||||
const resetOpen = ref(false)
|
||||
const helpOpen = ref(false)
|
||||
const helpDialog = ref(null)
|
||||
|
||||
// 恢复默认二次确认
|
||||
const resetConfirming = ref(false)
|
||||
let resetTimer = null
|
||||
function handleReset() {
|
||||
if (!resetConfirming.value) {
|
||||
resetConfirming.value = true
|
||||
resetTimer = setTimeout(() => {
|
||||
resetConfirming.value = false
|
||||
}, 5000)
|
||||
return
|
||||
}
|
||||
clearTimeout(resetTimer)
|
||||
resetConfirming.value = false
|
||||
config.resetToDefaults(showToast)
|
||||
}
|
||||
|
||||
function setTheme(v) {
|
||||
config.themeMode.value = v
|
||||
config.applyTheme(v)
|
||||
}
|
||||
|
||||
async function viewInotifyHelp() {
|
||||
const msg = `支持的事件字母 (toybox/busybox inotifyd 兼容):
|
||||
const INOTIFY_HELP = `支持的事件字母(与 toybox inotifyd 兼容):
|
||||
a = accessed 读取
|
||||
c = modified 内容修改 (亮度节点推荐用此)
|
||||
c = modified 内容修改(亮度节点推荐用此,默认值)
|
||||
e = metadata change 属性变更
|
||||
w = closed (writable) 写入后关闭
|
||||
0 = closed (unwritable) 查看后关闭
|
||||
0 = closed (unwritable) 只读打开后关闭
|
||||
r = opened 打开
|
||||
n = created 创建
|
||||
d = deleted 删除(目录内)
|
||||
d = deleted 删除(目录内)
|
||||
D = deleted (self) 自身被删除
|
||||
M = moved (self) 自身被移动
|
||||
m = moved in 移入目录
|
||||
y = moved out 移出目录
|
||||
u = unmounted 挂载卷卸载
|
||||
* = all events
|
||||
* = all events 全部事件`
|
||||
|
||||
提示: sysfs 亮度节点使用 c (MODIFY),这也是默认值`
|
||||
alert(msg)
|
||||
async function openHelp() {
|
||||
helpOpen.value = true
|
||||
await nextTick()
|
||||
helpDialog.value?.show()
|
||||
}
|
||||
|
||||
function handleSaveWebUI() {
|
||||
config.saveWebUIConfig(
|
||||
showToast,
|
||||
config.autoRefresh.value,
|
||||
config.statusRefreshInterval.value,
|
||||
config.uiZoom.value,
|
||||
config.themeMode.value,
|
||||
restartRefresh,
|
||||
// ── 定时休眠:HHMM 起止时间 ────────────────────────────────────────
|
||||
const sleepStart = computed(() => config.sleepParts.value[0] + config.sleepParts.value[1])
|
||||
const sleepEnd = computed(() => config.sleepParts.value[2] + config.sleepParts.value[3])
|
||||
|
||||
function updateSleep(which, value) {
|
||||
const digits = String(value).replace(/\D/g, '').slice(0, 4)
|
||||
const parts = [...config.sleepParts.value]
|
||||
if (which === 'start') {
|
||||
parts[0] = digits.slice(0, 2)
|
||||
parts[1] = digits.slice(2)
|
||||
} else {
|
||||
parts[2] = digits.slice(0, 2)
|
||||
parts[3] = digits.slice(2)
|
||||
}
|
||||
form.sleep_time = `${parts[0].padEnd(2, '0')}${parts[1].padEnd(2, '0')}-${parts[2].padEnd(2, '0')}${parts[3].padEnd(2, '0')}`
|
||||
}
|
||||
|
||||
// ── Web UI 偏好(localStorage,不写模块配置)────────────────────────
|
||||
const webuiForm = ref({
|
||||
autoRefresh: prefs.autoRefresh.value,
|
||||
refreshInterval: String(prefs.refreshInterval.value),
|
||||
zoom: String(prefs.zoom.value),
|
||||
themeMode: prefs.themeMode.value,
|
||||
})
|
||||
|
||||
const webuiDirty = computed(
|
||||
() =>
|
||||
webuiForm.value.autoRefresh !== prefs.autoRefresh.value ||
|
||||
Number(webuiForm.value.refreshInterval) !== prefs.refreshInterval.value ||
|
||||
Number(webuiForm.value.zoom) !== prefs.zoom.value ||
|
||||
webuiForm.value.themeMode !== prefs.themeMode.value,
|
||||
)
|
||||
|
||||
function saveWebUI() {
|
||||
prefs.save(webuiForm.value)
|
||||
webuiForm.value.refreshInterval = String(prefs.refreshInterval.value)
|
||||
webuiForm.value.zoom = String(prefs.zoom.value)
|
||||
snackbar('Web UI 配置已保存')
|
||||
}
|
||||
|
||||
async function confirmReset() {
|
||||
resetOpen.value = false
|
||||
await config.restoreBackup(snackbar)
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div style="display: contents">
|
||||
<!-- === 亮度配置 === -->
|
||||
<section class="card" id="config-section" data-nav-group="config">
|
||||
<div class="card-header">
|
||||
<h2>亮度配置</h2>
|
||||
<span class="save-badge" :class="config.dirty.value ? 'unsaved' : 'saved'">
|
||||
{{ config.dirty.value ? '未保存' : '已保存' }}
|
||||
<!-- ── 亮度配置 ─────────────────────────────────────────────── -->
|
||||
<section class="section">
|
||||
<div class="section-header">
|
||||
<h2 class="section-title ts-title-md">亮度配置</h2>
|
||||
<span class="state-badge" :class="config.dirtyMain.value ? 'is-unsaved' : 'is-saved'">
|
||||
{{ config.dirtyMain.value ? '未保存' : '已保存' }}
|
||||
</span>
|
||||
</div>
|
||||
|
||||
<div class="config-group">
|
||||
<h3 class="group-title"><Settings2 :size="16" /> 亮度调节</h3>
|
||||
<div class="group-title ts-title-sm supporting">
|
||||
<Settings2 :size="16" aria-hidden="true" /> 亮度调节
|
||||
</div>
|
||||
<AppTextField v-model="form.ui_max_bri" type="number" min="0" label="前台最大亮度"
|
||||
supporting-text="触发亮度提升的阈值" />
|
||||
<AppTextField v-model="form.max_bri" type="number" min="0" label="峰值最大亮度"
|
||||
supporting-text="亮度提升的目标值" />
|
||||
<AppTextField v-model="form.steps_num" type="number" min="1" max="500" label="亮度提升步数"
|
||||
supporting-text="每步约 0.02 秒" />
|
||||
|
||||
<div class="config-item">
|
||||
<div class="config-label">
|
||||
<span class="config-name">前台最大亮度</span>
|
||||
<span class="config-desc">触发亮度提升的阈值</span>
|
||||
</div>
|
||||
<Input v-model="config.uiMaxBri.value" type="number" min="0" class="config-input" />
|
||||
</div>
|
||||
<md-divider></md-divider>
|
||||
|
||||
<div class="config-item">
|
||||
<div class="config-label">
|
||||
<span class="config-name">峰值最大亮度</span>
|
||||
<span class="config-desc">亮度提升的目标值</span>
|
||||
<div class="group-title ts-title-sm supporting">
|
||||
<ShieldCheck :size="16" aria-hidden="true" /> 执行策略
|
||||
</div>
|
||||
<Input v-model="config.maxBri.value" type="number" min="0" class="config-input" />
|
||||
</div>
|
||||
|
||||
<div class="config-item">
|
||||
<div class="config-label">
|
||||
<span class="config-name">亮度提升步数</span>
|
||||
<span class="config-desc">约 0.02 秒 / 步</span>
|
||||
</div>
|
||||
<Input
|
||||
v-model="config.stepsNum.value"
|
||||
type="number"
|
||||
min="1"
|
||||
max="500"
|
||||
class="config-input"
|
||||
<AppSwitch v-model="config.sleepEnabled.value" name="定时休眠" support="设定时段内不提升亮度" />
|
||||
<div class="collapse" :class="{ open: config.sleepEnabled.value }">
|
||||
<div class="sleep-row">
|
||||
<AppTextField
|
||||
:model-value="sleepStart"
|
||||
label="开始 (HHMM)"
|
||||
@update:model-value="updateSleep('start', $event)"
|
||||
/>
|
||||
<AppTextField
|
||||
:model-value="sleepEnd"
|
||||
label="结束 (HHMM)"
|
||||
@update:model-value="updateSleep('end', $event)"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="config-group">
|
||||
<h3 class="group-title"><ShieldCheck :size="16" /> 执行策略</h3>
|
||||
|
||||
<div class="config-item">
|
||||
<div class="config-label">
|
||||
<span class="config-name">自动亮度时休眠</span>
|
||||
<span class="config-desc">开启自动亮度时不提升</span>
|
||||
</div>
|
||||
<Switch v-model="config.autoBriSleep.value" />
|
||||
</div>
|
||||
|
||||
<div class="config-item">
|
||||
<div class="config-label">
|
||||
<span class="config-name">显示 HDR 内容时休眠</span>
|
||||
<span class="config-desc">比率 ≥ 进入阈值休眠,≤ 退出阈值恢复</span>
|
||||
<span class="config-desc" style="color: var(--color-warning)"
|
||||
>出现闪屏建议改用黑名单</span
|
||||
>
|
||||
</div>
|
||||
<Switch v-model="config.displayHdrSleep.value" />
|
||||
</div>
|
||||
|
||||
<div class="config-item-expand" :class="{ show: config.displayHdrSleep.value }">
|
||||
<div class="custom-time-picker">
|
||||
<div class="time-unit">
|
||||
<input
|
||||
<AppSwitch v-model="form.auto_bri_sleep" name="自动亮度时休眠" support="系统自动亮度开启时不提升" />
|
||||
<AppSwitch
|
||||
v-model="form.display_hdr_sleep"
|
||||
name="显示 HDR 内容时休眠"
|
||||
support="比率 ≥ 进入阈值休眠,≤ 退出阈值恢复"
|
||||
/>
|
||||
<div class="collapse" :class="{ open: form.display_hdr_sleep === '1' }">
|
||||
<div class="sleep-row">
|
||||
<AppTextField
|
||||
v-model="form.hdr_enter_ratio"
|
||||
type="number"
|
||||
v-model="config.hdrEnterRatio.value"
|
||||
class="time-input time-input-wide"
|
||||
step="0.01"
|
||||
min="1"
|
||||
max="5"
|
||||
step="0.01"
|
||||
autocomplete="off"
|
||||
label="进入阈值"
|
||||
supporting-text="≥ 该比率时休眠"
|
||||
/>
|
||||
<span class="time-sep">进入</span>
|
||||
</div>
|
||||
<div class="time-unit">
|
||||
<input
|
||||
<AppTextField
|
||||
v-model="form.hdr_exit_ratio"
|
||||
type="number"
|
||||
v-model="config.hdrExitRatio.value"
|
||||
class="time-input time-input-wide"
|
||||
step="0.01"
|
||||
min="1"
|
||||
max="5"
|
||||
step="0.01"
|
||||
autocomplete="off"
|
||||
label="退出阈值"
|
||||
supporting-text="≤ 该比率时恢复"
|
||||
/>
|
||||
<span class="time-sep">退出</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<AppSwitch
|
||||
v-model="form.compatibility_mode"
|
||||
name="兼容模式(轮询驱动)"
|
||||
support="不使用事件监听,改为 2 秒一次轮询"
|
||||
warning="仅在事件驱动失效时开启,会略微增加耗电"
|
||||
/>
|
||||
|
||||
<div class="config-item">
|
||||
<div class="config-label">
|
||||
<span class="config-name">兼容模式 (轮询驱动)</span>
|
||||
<span class="config-desc">不使用事件监听,改用 2 秒一次轮询</span>
|
||||
<span class="config-desc" style="color: var(--color-warning)"
|
||||
>仅在事件驱动失效时开启,会略微增加耗电</span
|
||||
<div class="actions">
|
||||
<md-outlined-button :disabled="locked" @click="resetOpen = true">
|
||||
<RotateCcw :size="16" /> 恢复默认
|
||||
</md-outlined-button>
|
||||
<md-filled-button
|
||||
:disabled="locked || !config.dirtyMain.value"
|
||||
@click="config.saveMain(snackbar)"
|
||||
>
|
||||
</div>
|
||||
<Switch v-model="config.compatibilityMode.value" />
|
||||
</div>
|
||||
|
||||
<div class="config-item">
|
||||
<div class="config-label">
|
||||
<span class="config-name">定时休眠</span>
|
||||
<span class="config-desc">设定时段内不提升亮度</span>
|
||||
</div>
|
||||
<Switch v-model="config.sleepMode.value" />
|
||||
</div>
|
||||
|
||||
<div class="config-item-expand" :class="{ show: config.sleepMode.value }">
|
||||
<div class="custom-time-picker">
|
||||
<div class="time-unit">
|
||||
<input
|
||||
type="number"
|
||||
v-model="config.sleepStartH.value"
|
||||
class="time-input"
|
||||
min="0"
|
||||
max="23"
|
||||
placeholder="00"
|
||||
/>
|
||||
<span>:</span>
|
||||
<input
|
||||
type="number"
|
||||
v-model="config.sleepStartM.value"
|
||||
class="time-input"
|
||||
min="0"
|
||||
max="59"
|
||||
placeholder="00"
|
||||
/>
|
||||
</div>
|
||||
<span class="time-sep">至</span>
|
||||
<div class="time-unit">
|
||||
<input
|
||||
type="number"
|
||||
v-model="config.sleepEndH.value"
|
||||
class="time-input"
|
||||
min="0"
|
||||
max="23"
|
||||
placeholder="00"
|
||||
/>
|
||||
<span>:</span>
|
||||
<input
|
||||
type="number"
|
||||
v-model="config.sleepEndM.value"
|
||||
class="time-input"
|
||||
min="0"
|
||||
max="59"
|
||||
placeholder="00"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="card-actions">
|
||||
<Button
|
||||
variant="outline"
|
||||
:disabled="oplock.isLocked.value"
|
||||
@click="handleReset"
|
||||
:class="resetConfirming ? 'border-destructive text-destructive' : ''"
|
||||
>
|
||||
{{ resetConfirming ? '确认恢复?' : '恢复默认' }}
|
||||
</Button>
|
||||
<Button :disabled="oplock.isLocked.value" @click="config.save(showToast)">
|
||||
<Save :size="15" /> 保存配置
|
||||
</Button>
|
||||
<Save :size="16" /> 保存配置
|
||||
</md-filled-button>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<!-- === 高级设置 === -->
|
||||
<section class="card" id="advanced-section" data-nav-group="config">
|
||||
<div class="card-header card-header-toggle" @click="advancedOpen = !advancedOpen">
|
||||
<h2>高级设置</h2>
|
||||
<span class="save-badge" :class="config.dirtyAdvanced.value ? 'unsaved' : 'saved'">
|
||||
<!-- ── 高级设置 ─────────────────────────────────────────────── -->
|
||||
<section class="section">
|
||||
<button class="section-header toggle" @click="advancedOpen = !advancedOpen">
|
||||
<h2 class="section-title ts-title-md">高级设置</h2>
|
||||
<span class="state-badge" :class="config.dirtyAdvanced.value ? 'is-unsaved' : 'is-saved'">
|
||||
{{ config.dirtyAdvanced.value ? '未保存' : '已保存' }}
|
||||
</span>
|
||||
<ChevronDown :size="18" class="collapse-chevron" :class="{ open: advancedOpen }" />
|
||||
</div>
|
||||
<div class="collapsible-body" :class="{ open: advancedOpen }">
|
||||
<div>
|
||||
<div class="config-group">
|
||||
<h3 class="group-title"><Settings :size="16" /> 运行环境</h3>
|
||||
|
||||
<div class="config-item">
|
||||
<div class="config-label">
|
||||
<span class="config-name">调试模式</span>
|
||||
<span class="config-desc">记录详细 inotify 事件到日志</span>
|
||||
<span class="config-desc" style="color: var(--color-warning)"
|
||||
>需重启模块生效,用完请关闭</span
|
||||
>
|
||||
</div>
|
||||
<Switch v-model="config.debugMode.value" />
|
||||
</div>
|
||||
|
||||
<div class="config-item">
|
||||
<div class="config-label">
|
||||
<span class="config-name">监听事件</span>
|
||||
<span class="config-desc">默认 c,改后需重启模块</span>
|
||||
<button
|
||||
class="btn-text-s"
|
||||
style="margin-top: 6px; padding: 2px 6px"
|
||||
@click="viewInotifyHelp"
|
||||
>
|
||||
查看支持事件
|
||||
<ChevronDown :size="18" class="chevron" :class="{ open: advancedOpen }" />
|
||||
</button>
|
||||
|
||||
<div class="collapse" :class="{ open: advancedOpen }">
|
||||
<div class="collapse-inner">
|
||||
<div class="group-title ts-title-sm supporting">
|
||||
<Wrench :size="16" aria-hidden="true" /> 运行环境
|
||||
</div>
|
||||
<Input
|
||||
v-model="config.inotifyEvents.value"
|
||||
type="text"
|
||||
placeholder="c"
|
||||
class="config-input"
|
||||
<AppSwitch
|
||||
v-model="form.debug_mode"
|
||||
name="调试模式"
|
||||
support="记录详细事件到日志"
|
||||
warning="需重启模块生效,用完请关闭"
|
||||
/>
|
||||
<div class="field-row">
|
||||
<AppTextField
|
||||
v-model="form.inotify_events"
|
||||
label="监听事件"
|
||||
supporting-text="默认 c,改后需重启模块"
|
||||
/>
|
||||
<md-text-button @click="openHelp">
|
||||
<ListTree :size="16" /> 支持的事件
|
||||
</md-text-button>
|
||||
</div>
|
||||
<AppTextField
|
||||
v-model="form.now_bri_file"
|
||||
label="当前亮度节点"
|
||||
supporting-text="改后需重启模块"
|
||||
/>
|
||||
<AppTextField
|
||||
v-model="form.max_bri_file"
|
||||
label="最大亮度节点"
|
||||
supporting-text="改后需重启模块"
|
||||
/>
|
||||
|
||||
<div class="config-item" id="advanced-section">
|
||||
<div class="config-label">
|
||||
<span class="config-name">当前亮度节点</span>
|
||||
<span class="config-desc">改后需重启模块</span>
|
||||
</div>
|
||||
<Textarea v-model="config.nowBriFile.value" class="config-textarea" />
|
||||
</div>
|
||||
<md-divider></md-divider>
|
||||
|
||||
<div class="config-item">
|
||||
<div class="config-label">
|
||||
<span class="config-name">最大亮度节点</span>
|
||||
<span class="config-desc">改后需重启模块</span>
|
||||
<div class="group-title ts-title-sm supporting">
|
||||
<Settings2 :size="16" aria-hidden="true" /> 系统管理
|
||||
</div>
|
||||
<Textarea v-model="config.sysMaxBriFile.value" class="config-textarea" />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="config-group">
|
||||
<h3 class="group-title"><FileText :size="16" /> 系统管理</h3>
|
||||
<div class="config-item">
|
||||
<div class="config-label">
|
||||
<span class="config-name">日志大小限制</span>
|
||||
<span class="config-desc">单位: KB</span>
|
||||
</div>
|
||||
<Input
|
||||
v-model="config.logMaxSize.value"
|
||||
<AppTextField
|
||||
v-model="form.log_max_size"
|
||||
type="number"
|
||||
min="1"
|
||||
max="10240"
|
||||
class="config-input"
|
||||
label="日志大小限制 (KB)"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div class="config-item">
|
||||
<div class="config-label">
|
||||
<span class="config-name">日志等级</span>
|
||||
<span class="config-desc">低于此级别不写入日志</span>
|
||||
</div>
|
||||
<select v-model="config.logLevel.value" class="config-select">
|
||||
<option value="off">关闭</option>
|
||||
<option value="error">仅错误</option>
|
||||
<option value="warn">警告+</option>
|
||||
<option value="info">全部</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="card-actions">
|
||||
<Button
|
||||
:disabled="oplock.isLocked.value"
|
||||
@click="config.saveAdvanced(showToast, () => {})"
|
||||
<md-outlined-select
|
||||
label="日志等级"
|
||||
supporting-text="低于此级别不写入日志"
|
||||
:value="form.log_level"
|
||||
@change="form.log_level = $event.target.value"
|
||||
>
|
||||
<Save :size="15" /> 保存设置
|
||||
</Button>
|
||||
<md-select-option value="off"><div slot="headline">关闭</div></md-select-option>
|
||||
<md-select-option value="error"><div slot="headline">仅错误</div></md-select-option>
|
||||
<md-select-option value="warn"><div slot="headline">警告+</div></md-select-option>
|
||||
<md-select-option value="info"><div slot="headline">全部</div></md-select-option>
|
||||
</md-outlined-select>
|
||||
|
||||
<div class="actions">
|
||||
<md-filled-button
|
||||
:disabled="locked || !config.dirtyAdvanced.value"
|
||||
@click="config.saveAdvanced(snackbar)"
|
||||
>
|
||||
<Save :size="16" /> 保存设置
|
||||
</md-filled-button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<!-- === Web UI 配置 === -->
|
||||
<section class="card" id="webui-config-section" data-nav-group="config">
|
||||
<div class="card-header card-header-toggle" @click="webuiOpen = !webuiOpen">
|
||||
<h2>Web UI 配置</h2>
|
||||
<ChevronDown :size="18" class="collapse-chevron" :class="{ open: webuiOpen }" />
|
||||
</div>
|
||||
<div class="collapsible-body" :class="{ open: webuiOpen }">
|
||||
<div>
|
||||
<div class="config-group">
|
||||
<h3 class="group-title"><Monitor :size="16" /> 界面设置</h3>
|
||||
<!-- ── Web UI 配置 ──────────────────────────────────────────── -->
|
||||
<section class="section">
|
||||
<button class="section-header toggle" @click="webuiOpen = !webuiOpen">
|
||||
<h2 class="section-title ts-title-md">Web UI 配置</h2>
|
||||
<span class="state-badge" :class="webuiDirty ? 'is-unsaved' : 'is-saved'">
|
||||
{{ webuiDirty ? '未保存' : '已保存' }}
|
||||
</span>
|
||||
<ChevronDown :size="18" class="chevron" :class="{ open: webuiOpen }" />
|
||||
</button>
|
||||
|
||||
<div class="config-item">
|
||||
<div class="config-label">
|
||||
<span class="config-name">自动刷新</span>
|
||||
<span class="config-desc">定时拉取状态和日志</span>
|
||||
<div class="collapse" :class="{ open: webuiOpen }">
|
||||
<div class="collapse-inner">
|
||||
<div class="group-title ts-title-sm supporting">
|
||||
<Palette :size="16" aria-hidden="true" /> 界面设置
|
||||
</div>
|
||||
<Switch v-model="config.autoRefresh.value" />
|
||||
</div>
|
||||
|
||||
<div class="config-item" v-show="config.autoRefresh.value">
|
||||
<div class="config-label">
|
||||
<span class="config-name">状态/日志刷新间隔</span>
|
||||
<span class="config-desc">ms,最小 100</span>
|
||||
</div>
|
||||
<Input
|
||||
v-model="config.statusRefreshInterval.value"
|
||||
<AppSwitch v-model="webuiForm.autoRefresh" name="自动刷新" support="定时拉取状态与日志" />
|
||||
<AppTextField
|
||||
v-model="webuiForm.refreshInterval"
|
||||
type="number"
|
||||
min="100"
|
||||
class="config-input"
|
||||
label="刷新间隔 (ms)"
|
||||
supporting-text="最小 100"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div class="config-item">
|
||||
<div class="config-label">
|
||||
<span class="config-name">外观主题</span>
|
||||
</div>
|
||||
<select
|
||||
class="config-select"
|
||||
:value="config.themeMode.value"
|
||||
@change="setTheme($event.target.value)"
|
||||
<md-outlined-select
|
||||
label="外观主题"
|
||||
:value="webuiForm.themeMode"
|
||||
@change="webuiForm.themeMode = $event.target.value"
|
||||
>
|
||||
<option value="system">跟随系统</option>
|
||||
<option value="light">浅色</option>
|
||||
<option value="dark">深色</option>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<div class="config-item">
|
||||
<div class="config-label">
|
||||
<span class="config-name">界面缩放</span>
|
||||
<span class="config-desc">50%–150%,立即生效</span>
|
||||
</div>
|
||||
<Input
|
||||
v-model="config.uiZoom.value"
|
||||
<md-select-option value="system"><div slot="headline">跟随系统</div></md-select-option>
|
||||
<md-select-option value="light"><div slot="headline">浅色</div></md-select-option>
|
||||
<md-select-option value="dark"><div slot="headline">深色</div></md-select-option>
|
||||
</md-outlined-select>
|
||||
<AppTextField
|
||||
v-model="webuiForm.zoom"
|
||||
type="number"
|
||||
min="50"
|
||||
max="150"
|
||||
class="config-input"
|
||||
label="界面缩放 (%)"
|
||||
supporting-text="50–150,立即生效"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="card-actions">
|
||||
<Button @click="handleSaveWebUI"> <Save :size="15" /> 保存配置 </Button>
|
||||
<div class="actions">
|
||||
<md-filled-button :disabled="!webuiDirty" @click="saveWebUI">
|
||||
<Save :size="16" /> 保存配置
|
||||
</md-filled-button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<ConfirmDialog
|
||||
:open="resetOpen"
|
||||
headline="恢复默认配置"
|
||||
description="将载入安装时备份的配置到表单,需再点击保存才会写入。确定继续吗?"
|
||||
confirm-text="载入备份"
|
||||
@confirm="confirmReset"
|
||||
@cancel="resetOpen = false"
|
||||
/>
|
||||
|
||||
<md-dialog ref="helpDialog" @closed="helpOpen = false">
|
||||
<div slot="headline">支持的事件字母</div>
|
||||
<pre slot="content" class="help-text">{{ INOTIFY_HELP }}</pre>
|
||||
<div slot="actions">
|
||||
<md-filled-button @click="helpOpen = false">知道了</md-filled-button>
|
||||
</div>
|
||||
</md-dialog>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.group-title {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: var(--md-sys-spacing-2);
|
||||
margin-top: var(--md-sys-spacing-2);
|
||||
}
|
||||
|
||||
.section-header.toggle {
|
||||
width: 100%;
|
||||
background: none;
|
||||
border: 0;
|
||||
padding: 0;
|
||||
cursor: pointer;
|
||||
text-align: left;
|
||||
}
|
||||
|
||||
.chevron {
|
||||
transition: transform var(--md-sys-motion-duration-medium2)
|
||||
var(--md-sys-motion-easing-emphasized);
|
||||
color: var(--md-sys-color-on-surface-variant);
|
||||
}
|
||||
|
||||
.chevron.open {
|
||||
transform: rotate(180deg);
|
||||
}
|
||||
|
||||
.collapse-inner {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: var(--md-sys-spacing-3);
|
||||
padding-top: var(--md-sys-spacing-3);
|
||||
}
|
||||
|
||||
.sleep-row {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(2, minmax(0, 1fr));
|
||||
gap: var(--md-sys-spacing-2);
|
||||
padding-bottom: var(--md-sys-spacing-2);
|
||||
}
|
||||
|
||||
.field-row {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: var(--md-sys-spacing-2);
|
||||
}
|
||||
|
||||
.field-row > :first-child {
|
||||
flex: 1;
|
||||
}
|
||||
|
||||
.actions {
|
||||
display: flex;
|
||||
justify-content: flex-end;
|
||||
gap: var(--md-sys-spacing-2);
|
||||
padding-top: var(--md-sys-spacing-2);
|
||||
}
|
||||
|
||||
.help-text {
|
||||
margin: 0;
|
||||
white-space: pre-wrap;
|
||||
font-family: var(--md-sys-typescale-font-mono);
|
||||
font-size: var(--md-sys-typescale-body-small-size);
|
||||
line-height: 1.6;
|
||||
}
|
||||
</style>
|
||||
+99
-88
@@ -1,107 +1,118 @@
|
||||
<script setup>
|
||||
import { inject, ref, onMounted } from 'vue'
|
||||
import Button from '@/components/ui/Button.vue'
|
||||
import { RefreshCw, Copy, Download, Trash2 } from 'lucide-vue-next'
|
||||
import { inject, computed, ref } from 'vue'
|
||||
import { RefreshCw } from 'lucide-vue-next'
|
||||
import ActionMenu from '../components/ActionMenu.vue'
|
||||
import ConfirmDialog from '../components/ConfirmDialog.vue'
|
||||
|
||||
const showToast = inject('showToast')
|
||||
const log = inject('log')
|
||||
const snackbar = inject('snackbar')
|
||||
|
||||
const logMenuOpen = ref(false)
|
||||
const clearConfirming = ref(false)
|
||||
const clearOpen = ref(false)
|
||||
|
||||
let clearConfirmTimer = null
|
||||
function copyLog() {
|
||||
log.copy(showToast)
|
||||
logMenuOpen.value = false
|
||||
}
|
||||
function exportLog() {
|
||||
log.exportLog(showToast)
|
||||
logMenuOpen.value = false
|
||||
}
|
||||
function handleClear() {
|
||||
if (!clearConfirming.value) {
|
||||
clearConfirming.value = true
|
||||
clearConfirmTimer = setTimeout(() => {
|
||||
clearConfirming.value = false
|
||||
}, 3000)
|
||||
return
|
||||
}
|
||||
clearTimeout(clearConfirmTimer)
|
||||
clearConfirming.value = false
|
||||
logMenuOpen.value = false
|
||||
log.clear(showToast)
|
||||
}
|
||||
const menuItems = [
|
||||
{ key: 'copy', label: '复制当前日志' },
|
||||
{ key: 'export', label: '导出到 /sdcard' },
|
||||
{ key: 'clear', label: '清空日志' },
|
||||
]
|
||||
|
||||
// filter options
|
||||
const filterOptions = [
|
||||
const filterItems = computed(() => [
|
||||
{ key: '', label: '全部' },
|
||||
{ key: 'INFO', label: 'INFO' },
|
||||
{ key: 'WARN', label: 'WARN' },
|
||||
{ key: 'ERROR', label: 'ERROR' },
|
||||
]
|
||||
{ key: 'SUCCESS', label: 'SUCCESS' },
|
||||
])
|
||||
|
||||
onMounted(() => log.load())
|
||||
function onMenuSelect(key) {
|
||||
if (key === 'copy') log.copy(snackbar)
|
||||
else if (key === 'export') log.exportTo(snackbar)
|
||||
else if (key === 'clear') clearOpen.value = true
|
||||
}
|
||||
|
||||
const levelClass = (level) => `log-line--${(level || 'plain').toLowerCase()}`
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<section class="card" id="log-section">
|
||||
<div class="card-header" style="margin-bottom: 8px">
|
||||
<h2>运行日志</h2>
|
||||
<div class="header-actions dropdown-container">
|
||||
<Button variant="ghost" size="icon" @click="log.load">
|
||||
<RefreshCw :size="18" />
|
||||
</Button>
|
||||
<Button variant="ghost" size="icon" @click="logMenuOpen = !logMenuOpen">
|
||||
<span class="sr-only">更多操作</span>
|
||||
<svg
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
width="18"
|
||||
height="18"
|
||||
viewBox="0 0 24 24"
|
||||
fill="none"
|
||||
stroke="currentColor"
|
||||
stroke-width="2"
|
||||
stroke-linecap="round"
|
||||
stroke-linejoin="round"
|
||||
>
|
||||
<circle cx="12" cy="12" r="1" />
|
||||
<circle cx="12" cy="5" r="1" />
|
||||
<circle cx="12" cy="19" r="1" />
|
||||
</svg>
|
||||
</Button>
|
||||
<div class="dropdown-menu" :class="{ show: logMenuOpen }" @click.stop>
|
||||
<div class="dropdown-item" @click="copyLog"><Copy :size="18" /><span>复制日志</span></div>
|
||||
<div class="dropdown-item" @click="exportLog">
|
||||
<Download :size="18" /><span>导出日志文件</span>
|
||||
</div>
|
||||
<div
|
||||
class="dropdown-item"
|
||||
:class="{ 'dropdown-item-danger': clearConfirming }"
|
||||
@click="handleClear"
|
||||
>
|
||||
<Trash2 :size="18" />
|
||||
<span>{{ clearConfirming ? '再次点击确认清除' : '清除日志' }}</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<section class="section">
|
||||
<div class="section-header">
|
||||
<h2 class="section-title ts-title-md">运行日志</h2>
|
||||
<md-icon-button title="刷新" @click="log.load()">
|
||||
<RefreshCw :size="20" />
|
||||
</md-icon-button>
|
||||
<ActionMenu :items="menuItems" @select="onMenuSelect" />
|
||||
</div>
|
||||
|
||||
<!-- 过滤器 -->
|
||||
<div class="log-filter-container" style="margin-bottom: var(--spacing-s)">
|
||||
<div class="log-filter-tabs">
|
||||
<button
|
||||
v-for="opt in filterOptions"
|
||||
:key="opt.key"
|
||||
class="log-filter-tab"
|
||||
:class="{ active: log.filterLevel.value === opt.key }"
|
||||
@click="log.filterLevel.value = opt.key"
|
||||
>
|
||||
{{ opt.label }}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
<md-chip-set class="filter-chips">
|
||||
<md-filter-chip
|
||||
v-for="item in filterItems"
|
||||
:key="item.key || 'all'"
|
||||
:label="item.label"
|
||||
:selected="log.level.value === item.key"
|
||||
@click="log.level.value = item.key"
|
||||
></md-filter-chip>
|
||||
</md-chip-set>
|
||||
|
||||
<!-- 日志内容 -->
|
||||
<pre class="log-output" id="log-output">{{ log.filteredLog.value || '暂无日志' }}</pre>
|
||||
<div v-if="log.error.value" class="empty-state error">{{ log.error.value }}</div>
|
||||
<div v-else-if="log.filtered.value.length === 0" class="empty-state">
|
||||
暂无{{ log.level.value ? ` [${log.level.value}] ` : '' }}日志
|
||||
</div>
|
||||
<pre v-else class="log-output scroll-area"><code><span
|
||||
v-for="(entry, index) in log.filtered.value"
|
||||
:key="index"
|
||||
:class="levelClass(entry.level)"
|
||||
class="log-line"
|
||||
>[{{ entry.time }}] [{{ entry.tag }}] [{{ entry.level }}] {{ entry.message }}
|
||||
</span></code></pre>
|
||||
</section>
|
||||
|
||||
<ConfirmDialog
|
||||
:open="clearOpen"
|
||||
headline="清空日志"
|
||||
description="日志文件内容将被清空,此操作不可撤销。"
|
||||
confirm-text="清空"
|
||||
danger
|
||||
@confirm="clearOpen = false; log.clear(snackbar)"
|
||||
@cancel="clearOpen = false"
|
||||
/>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.filter-chips {
|
||||
--md-filter-chip-label-text-size: var(--md-sys-typescale-label-medium-size);
|
||||
}
|
||||
|
||||
.log-output {
|
||||
margin: 0;
|
||||
padding: var(--md-sys-spacing-3);
|
||||
max-height: 58vh;
|
||||
overflow: auto;
|
||||
border-radius: var(--md-sys-shape-corner-medium);
|
||||
background-color: var(--md-sys-color-surface-container-lowest);
|
||||
color: var(--md-sys-color-on-surface);
|
||||
font-family: var(--md-sys-typescale-font-mono);
|
||||
font-size: var(--md-sys-typescale-body-small-size);
|
||||
line-height: 1.55;
|
||||
}
|
||||
|
||||
.log-line {
|
||||
display: block;
|
||||
white-space: pre-wrap;
|
||||
word-break: break-all;
|
||||
}
|
||||
|
||||
.log-line--warn {
|
||||
color: var(--lp-color-warning);
|
||||
}
|
||||
|
||||
.log-line--error {
|
||||
color: var(--md-sys-color-error);
|
||||
}
|
||||
|
||||
.log-line--success {
|
||||
color: var(--lp-color-success);
|
||||
}
|
||||
|
||||
.log-line--info {
|
||||
color: var(--md-sys-color-on-surface-variant);
|
||||
}
|
||||
</style>
|
||||
+124
-92
@@ -1,116 +1,148 @@
|
||||
<script setup>
|
||||
import { inject, computed, ref } from 'vue'
|
||||
import Button from '@/components/ui/Button.vue'
|
||||
import Badge from '@/components/ui/Badge.vue'
|
||||
import {
|
||||
RefreshCw,
|
||||
Play,
|
||||
RotateCcw,
|
||||
SunMedium,
|
||||
Smartphone,
|
||||
Activity,
|
||||
Clock,
|
||||
Moon,
|
||||
Layers,
|
||||
} from 'lucide-vue-next'
|
||||
import { SunMedium, Smartphone, Activity, Clock, Moon, Layers, Gauge } from 'lucide-vue-next'
|
||||
import ConfirmDialog from '../components/ConfirmDialog.vue'
|
||||
|
||||
const status = inject('status')
|
||||
const showToast = inject('showToast')
|
||||
const config = inject('config')
|
||||
const oplock = inject('oplock')
|
||||
const snackbar = inject('snackbar')
|
||||
|
||||
const confirmedLowBri = ref(false)
|
||||
const sliderEl = ref(null)
|
||||
const confirmLowOpen = ref(false)
|
||||
const pendingValue = ref(0)
|
||||
|
||||
// --------- 亮度滑条渐变 ----------
|
||||
const sliderStyle = computed(() => {
|
||||
const sysMax = parseInt(status.sysMaxBri.value) || 255
|
||||
const curr = parseInt(status.currentBri.value) || 0
|
||||
const uiMax = parseInt(config.uiMaxBri.value) || sysMax
|
||||
const c = (curr / sysMax) * 100
|
||||
const u = (uiMax / sysMax) * 100
|
||||
const pri = '#a8c7fa'
|
||||
const bst = '#fb8c00'
|
||||
const trk = 'var(--md-sys-color-surface-container-high)'
|
||||
const btrk = 'rgba(251,140,0,0.15)'
|
||||
if (c <= u) {
|
||||
return `background: linear-gradient(to right, ${pri} 0%, ${pri} ${c}%, ${trk} ${c}%, ${trk} ${u}%, ${btrk} ${u}%, ${btrk} 100%)`
|
||||
const DAEMON_STATES = { S: '休眠中', R: '运行中', D: '等待中', T: '已停止', Z: '异常' }
|
||||
|
||||
const items = computed(() => {
|
||||
const daemon = status.daemon.value
|
||||
const brightness = status.brightness.value
|
||||
return [
|
||||
{ label: '当前亮度', value: brightness.current ?? '—', icon: SunMedium },
|
||||
{ label: '系统最大亮度', value: brightness.max || '—', icon: Smartphone },
|
||||
{ label: '守护进程 PID', value: daemon.running ? daemon.pid : '离线', icon: Activity },
|
||||
{
|
||||
label: '守护进程状态',
|
||||
value: daemon.running ? DAEMON_STATES[daemon.state] || daemon.state || '运行中' : '未运行',
|
||||
icon: Clock,
|
||||
},
|
||||
{ label: '休眠状态', value: status.sleepText.value, icon: Moon },
|
||||
{ label: 'HDR/SDR 比率', value: status.hdrText.value, icon: Layers },
|
||||
]
|
||||
})
|
||||
|
||||
const maxBrightness = computed(() => status.brightness.value.max || 255)
|
||||
const currentBrightness = computed(() => status.brightness.value.current || 0)
|
||||
const percent = computed(() => status.brightness.value.percent ?? 0)
|
||||
const uiThreshold = computed(() => status.cfg.value.uiMaxBri ?? 0)
|
||||
const thresholdPercent = computed(() =>
|
||||
Math.round((uiThreshold.value / maxBrightness.value) * 100),
|
||||
)
|
||||
const autoBrightness = computed(() => status.display.value?.autoBrightness ?? null)
|
||||
const nodeError = computed(() => status.brightness.value.error || '')
|
||||
|
||||
async function applyBrightness(value) {
|
||||
try {
|
||||
await status.setBrightness(value)
|
||||
snackbar(`亮度已设为 ${value}`)
|
||||
} catch (e) {
|
||||
snackbar(`设置失败: ${e.message}`)
|
||||
}
|
||||
}
|
||||
return `background: linear-gradient(to right, ${pri} 0%, ${pri} ${u}%, ${bst} ${u}%, ${bst} ${c}%, ${btrk} ${c}%, ${btrk} 100%)`
|
||||
})
|
||||
|
||||
const brightnessPercent = computed(() => {
|
||||
const sysMax = parseInt(status.sysMaxBri.value) || 255
|
||||
const curr = parseInt(status.currentBri.value) || 0
|
||||
return Math.round((curr / sysMax) * 100) + '%'
|
||||
})
|
||||
|
||||
async function onSliderChange(e) {
|
||||
const newBri = parseInt(e.target.value, 10)
|
||||
const sysMax = parseInt(status.sysMaxBri.value) || 255
|
||||
const pct = Math.round((newBri / sysMax) * 100)
|
||||
if (pct < 5 && !confirmedLowBri.value) {
|
||||
const ok = confirm('⚠️ 警告:亮度低于 5% 可能导致屏幕近似黑屏。\n\n确定要继续吗?')
|
||||
if (!ok) {
|
||||
const safe = Math.ceil(sysMax * 0.05)
|
||||
e.target.value = safe
|
||||
async function onSliderChange(event) {
|
||||
const value = Number(event.target.value)
|
||||
const pct = Math.round((value / maxBrightness.value) * 100)
|
||||
if (pct < 5) {
|
||||
pendingValue.value = value
|
||||
confirmLowOpen.value = true
|
||||
return
|
||||
}
|
||||
confirmedLowBri.value = true
|
||||
}
|
||||
if (pct >= 5) confirmedLowBri.value = false
|
||||
await status.setBrightness(newBri, showToast)
|
||||
await applyBrightness(value)
|
||||
}
|
||||
|
||||
const statusItems = computed(() => [
|
||||
{ label: '当前亮度', value: status.currentBri.value || '—', icon: SunMedium },
|
||||
{ label: '系统最大亮度', value: status.sysMaxBri.value || '—', icon: Smartphone },
|
||||
{ label: '守护进程 PID', value: status.inotifydPid.value, icon: Activity },
|
||||
{ label: '守护进程状态', value: status.inotifydState.value, icon: Clock },
|
||||
{ label: '休眠状态', value: status.sleepStatus.value, icon: Moon },
|
||||
{ label: 'HDR/SDR 比率', value: status.hdrRatio.value, icon: Layers },
|
||||
])
|
||||
function cancelLow() {
|
||||
confirmLowOpen.value = false
|
||||
if (sliderEl.value) sliderEl.value.value = currentBrightness.value
|
||||
}
|
||||
|
||||
async function confirmLow() {
|
||||
confirmLowOpen.value = false
|
||||
await applyBrightness(pendingValue.value)
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<section class="card" id="status-section" data-nav-group="status">
|
||||
<div class="card-header">
|
||||
<h2>实时状态</h2>
|
||||
<Button variant="ghost" size="icon" @click="status.load(true)">
|
||||
<RefreshCw :size="18" />
|
||||
</Button>
|
||||
<section class="section">
|
||||
<div class="section-header">
|
||||
<h2 class="section-title ts-title-md">实时状态</h2>
|
||||
<span v-if="status.error.value" class="state-badge is-unsaved">读取失败</span>
|
||||
</div>
|
||||
|
||||
<!-- 状态网格 -->
|
||||
<div class="status-grid">
|
||||
<div v-for="item in statusItems" :key="item.label" class="status-item">
|
||||
<div class="status-item-header">
|
||||
<div v-for="item in items" :key="item.label" class="status-item">
|
||||
<span class="status-item__label">
|
||||
<component :is="item.icon" :size="14" aria-hidden="true" />
|
||||
<span class="status-label">{{ item.label }}</span>
|
||||
</div>
|
||||
<span class="status-value">{{ item.value }}</span>
|
||||
{{ item.label }}
|
||||
</span>
|
||||
<span class="status-item__value mono">{{ item.value }}</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 亮度控制 -->
|
||||
<div class="brightness-section">
|
||||
<div class="brightness-header">
|
||||
<span class="brightness-title">亮度</span>
|
||||
<span class="brightness-percent">{{ brightnessPercent }}</span>
|
||||
</div>
|
||||
<div class="brightness-container">
|
||||
<span class="brightness-label">0%</span>
|
||||
<input
|
||||
type="range"
|
||||
class="brightness-slider"
|
||||
min="0"
|
||||
:max="status.sysMaxBri.value || 255"
|
||||
:value="status.currentBri.value || 0"
|
||||
:style="sliderStyle"
|
||||
:disabled="oplock.isLocked.value"
|
||||
@change="onSliderChange"
|
||||
/>
|
||||
<span class="brightness-label">100%</span>
|
||||
</div>
|
||||
</div>
|
||||
<p v-if="nodeError" class="ts-body-sm supporting">
|
||||
亮度节点不可用:{{ nodeError }}
|
||||
</p>
|
||||
<p v-else-if="autoBrightness" class="ts-body-sm supporting">
|
||||
系统自动亮度已开启,模块会跳过亮度提升
|
||||
</p>
|
||||
</section>
|
||||
|
||||
<section class="section">
|
||||
<div class="section-header">
|
||||
<h2 class="section-title ts-title-md">亮度</h2>
|
||||
<span class="ts-title-md mono">{{ percent }}%</span>
|
||||
</div>
|
||||
|
||||
<div class="slider-row">
|
||||
<Gauge :size="18" aria-hidden="true" />
|
||||
<md-slider
|
||||
ref="sliderEl"
|
||||
class="brightness-slider"
|
||||
:min="0"
|
||||
:max="maxBrightness"
|
||||
:value="currentBrightness"
|
||||
labeled
|
||||
@change="onSliderChange"
|
||||
></md-slider>
|
||||
</div>
|
||||
|
||||
<p class="ts-body-sm supporting">
|
||||
触发阈值 {{ uiThreshold }}(约 {{ thresholdPercent }}%):亮度达到该值后模块会平滑提升到峰值。
|
||||
</p>
|
||||
</section>
|
||||
|
||||
<ConfirmDialog
|
||||
:open="confirmLowOpen"
|
||||
headline="亮度低于 5%"
|
||||
description="继续可能让屏幕接近黑屏,确定要设置吗?"
|
||||
confirm-text="仍然设置"
|
||||
danger
|
||||
@confirm="confirmLow"
|
||||
@cancel="cancelLow"
|
||||
/>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.slider-row {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: var(--md-sys-spacing-3);
|
||||
color: var(--md-sys-color-on-surface-variant);
|
||||
}
|
||||
|
||||
.brightness-slider {
|
||||
flex: 1;
|
||||
--md-slider-active-track-color: var(--md-sys-color-primary);
|
||||
--md-slider-handle-color: var(--md-sys-color-primary);
|
||||
--md-slider-inactive-track-color: var(--md-sys-color-surface-variant);
|
||||
--md-slider-label-container-color: var(--md-sys-color-primary);
|
||||
}
|
||||
</style>
|
||||
+10
-2
@@ -1,10 +1,18 @@
|
||||
import { defineConfig } from 'vite'
|
||||
import vue from '@vitejs/plugin-vue'
|
||||
import tailwindcss from '@tailwindcss/vite'
|
||||
import { fileURLToPath, URL } from 'node:url'
|
||||
|
||||
export default defineConfig({
|
||||
plugins: [vue(), tailwindcss()],
|
||||
plugins: [
|
||||
vue({
|
||||
template: {
|
||||
compilerOptions: {
|
||||
// @material/web 提供的是自定义元素(md-*),交由浏览器处理而非 Vue 组件
|
||||
isCustomElement: (tag) => tag.startsWith('md-'),
|
||||
},
|
||||
},
|
||||
}),
|
||||
],
|
||||
resolve: {
|
||||
alias: {
|
||||
'@': fileURLToPath(new URL('./src', import.meta.url)),
|
||||
|
||||
Reference in new issue
Block a user