From 0882c8915093666f9b821e4853998943273343a0 Mon Sep 17 00:00:00 2001 From: Yule Date: Fri, 10 Apr 2026 01:59:23 +0800 Subject: [PATCH] =?UTF-8?q?style:=20=E4=BB=A3=E7=A0=81=E6=A0=BC=E5=BC=8F?= =?UTF-8?q?=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .oxfmtrc.json | 7 + .oxlintrc.json | 9 + .vscode/extensions.json | 3 + .vscode/settings.json | 8 +- package.json | 8 +- pnpm-lock.yaml | 431 +++++++++++++ webui/index.html | 24 +- webui/src/App.vue | 125 ++-- webui/src/about.css | 20 +- webui/src/apps.css | 36 +- webui/src/apps.js | 876 ++++++++++++++------------ webui/src/components.css | 58 +- webui/src/components/BottomNav.vue | 145 +++-- webui/src/components/ui/Badge.vue | 10 +- webui/src/components/ui/Button.vue | 16 +- webui/src/components/ui/Card.vue | 10 +- webui/src/components/ui/Input.vue | 16 +- webui/src/components/ui/Label.vue | 14 +- webui/src/components/ui/Separator.vue | 16 +- webui/src/components/ui/Switch.vue | 36 +- webui/src/components/ui/Textarea.vue | 16 +- webui/src/composables/useApps.js | 245 ++++--- webui/src/composables/useConfig.js | 283 +++++---- webui/src/composables/useLog.js | 69 +- webui/src/composables/useStatus.js | 191 +++--- webui/src/header.css | 13 +- webui/src/index.css | 7 +- webui/src/lib/utils.js | 6 +- webui/src/log.css | 38 +- webui/src/main.js | 20 +- webui/src/style.css | 10 +- webui/src/utils.js | 117 ++-- webui/src/views/AboutView.vue | 164 ++--- webui/src/views/AppsView.vue | 673 +++++++++++--------- webui/src/views/ConfigView.vue | 499 +++++++++------ webui/src/views/LogView.vue | 88 ++- webui/src/views/StatusView.vue | 83 +-- webui/vite.config.js | 10 +- 38 files changed, 2708 insertions(+), 1692 deletions(-) create mode 100644 .oxfmtrc.json create mode 100644 .oxlintrc.json create mode 100644 .vscode/extensions.json diff --git a/.oxfmtrc.json b/.oxfmtrc.json new file mode 100644 index 0000000..2bbbe13 --- /dev/null +++ b/.oxfmtrc.json @@ -0,0 +1,7 @@ +{ + "$schema": "./node_modules/oxfmt/configuration_schema.json", + "printWidth": 100, + "semi": false, + "singleQuote": true, + "tabWidth": 2 +} diff --git a/.oxlintrc.json b/.oxlintrc.json new file mode 100644 index 0000000..9ea2cab --- /dev/null +++ b/.oxlintrc.json @@ -0,0 +1,9 @@ +{ + "$schema": "./node_modules/oxlint/configuration_schema.json", + "categories": { + "correctness": "warn" + }, + "rules": { + "eslint/no-unused-vars": "warn" + } +} \ No newline at end of file diff --git a/.vscode/extensions.json b/.vscode/extensions.json new file mode 100644 index 0000000..db111ea --- /dev/null +++ b/.vscode/extensions.json @@ -0,0 +1,3 @@ +{ + "recommendations": ["oxc.oxc-vscode", "Vue.volar", "rust-lang.rust-analyzer"] +} \ No newline at end of file diff --git a/.vscode/settings.json b/.vscode/settings.json index 384ffac..6a6fae2 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,7 +1,9 @@ { "editor.formatOnSave": true, -"editor.defaultFormatter": "timonwong.shellcheck", -"[shellscript]": { + "editor.codeActionsOnSave": { + "source.fixAll.oxc": "always" + }, + "[shellscript]": { "editor.defaultFormatter": "mads-hartmann.bash-ide-vscode" -} + } } diff --git a/package.json b/package.json index 9440168..312bad2 100644 --- a/package.json +++ b/package.json @@ -6,12 +6,18 @@ "scripts": { "dev": "cd webui && vite", "build": "cd webui && vite build && cd .. && node build-module.js", - "preview": "cd webui && vite preview" + "preview": "cd webui && vite preview", + "lint": "oxlint", + "lint:fix": "oxlint --fix", + "fmt": "oxfmt webui/", + "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" diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 01dd03c..9ac70e1 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -45,6 +45,12 @@ importers: kernelsu: specifier: ^3.0.2 version: 3.0.2 + oxfmt: + specifier: ^0.44.0 + version: 0.44.0 + oxlint: + specifier: ^1.59.0 + version: 1.59.0 tailwindcss: specifier: ^4.2.2 version: 4.2.2 @@ -112,6 +118,250 @@ packages: '@oxc-project/types@0.122.0': resolution: {integrity: sha512-oLAl5kBpV4w69UtFZ9xqcmTi+GENWOcPF7FCrczTiBbmC0ibXxCwyvZGbO39rCVEuLGAZM84DH0pUIyyv/YJzA==} + '@oxfmt/binding-android-arm-eabi@0.44.0': + resolution: {integrity: sha512-5UvghMd9SA/yvKTWCAxMAPXS1d2i054UeOf4iFjZjfayTwCINcC3oaSXjtbZfCaEpxgJod7XiOjTtby5yEv/BQ==} + engines: {node: ^20.19.0 || >=22.12.0} + cpu: [arm] + os: [android] + + '@oxfmt/binding-android-arm64@0.44.0': + resolution: {integrity: sha512-IVudM1BWfvrYO++Khtzr8q9n5Rxu7msUvoFMqzGJVdX7HfUXUDHwaH2zHZNB58svx2J56pmCUzophyaPFkcG/A==} + engines: {node: ^20.19.0 || >=22.12.0} + cpu: [arm64] + os: [android] + + '@oxfmt/binding-darwin-arm64@0.44.0': + resolution: {integrity: sha512-eWCLAIKAHfx88EqEP1Ga2yz7qVcqDU5lemn4xck+07bH182hDdprOHjbogyk0In1Djys3T0/pO2JepFnRJ41Mg==} + engines: {node: ^20.19.0 || >=22.12.0} + cpu: [arm64] + os: [darwin] + + '@oxfmt/binding-darwin-x64@0.44.0': + resolution: {integrity: sha512-eHTBznHLM49++dwz07MblQ2cOXyIgeedmE3Wgy4ptUESj38/qYZyRi1MPwC9olQJWssMeY6WI3UZ7YmU5ggvyQ==} + engines: {node: ^20.19.0 || >=22.12.0} + cpu: [x64] + os: [darwin] + + '@oxfmt/binding-freebsd-x64@0.44.0': + resolution: {integrity: sha512-jLMmbj0u0Ft43QpkUVr/0v1ZfQCGWAvU+WznEHcN3wZC/q6ox7XeSJtk9P36CCpiDSUf3sGnzbIuG1KdEMEDJQ==} + engines: {node: ^20.19.0 || >=22.12.0} + cpu: [x64] + os: [freebsd] + + '@oxfmt/binding-linux-arm-gnueabihf@0.44.0': + resolution: {integrity: sha512-n+A/u/ByK1qV8FVGOwyaSpw5NPNl0qlZfgTBqHeGIqr8Qzq1tyWZ4lAaxPoe5mZqE3w88vn3+jZtMxriHPE7tg==} + engines: {node: ^20.19.0 || >=22.12.0} + cpu: [arm] + os: [linux] + + '@oxfmt/binding-linux-arm-musleabihf@0.44.0': + resolution: {integrity: sha512-5eax+FkxyCqAi3Rw0mrZFr7+KTt/XweFsbALR+B5ljWBLBl8nHe4ADrUnb1gLEfQCJLl+Ca5FIVD4xEt95AwIw==} + engines: {node: ^20.19.0 || >=22.12.0} + cpu: [arm] + os: [linux] + + '@oxfmt/binding-linux-arm64-gnu@0.44.0': + resolution: {integrity: sha512-58l8JaHxSGOmOMOG2CIrNsnkRJAj0YcHQCmvNACniOa/vd1iRHhlPajczegzS5jwMENlqgreyiTR9iNlke8qCw==} + engines: {node: ^20.19.0 || >=22.12.0} + cpu: [arm64] + os: [linux] + libc: [glibc] + + '@oxfmt/binding-linux-arm64-musl@0.44.0': + resolution: {integrity: sha512-AlObQIXyVRZ96LbtVljtFq0JqH5B92NU+BQeDFrXWBUWlCKAM0wF5GLfIhCLT5kQ3Sl+U0YjRJ7Alqj5hGQaCg==} + engines: {node: ^20.19.0 || >=22.12.0} + cpu: [arm64] + os: [linux] + libc: [musl] + + '@oxfmt/binding-linux-ppc64-gnu@0.44.0': + resolution: {integrity: sha512-YcFE8/q/BbrCiIiM5piwbkA6GwJc5QqhMQp2yDrqQ2fuVkZ7CInb1aIijZ/k8EXc72qXMSwKpVlBv1w/MsGO/A==} + engines: {node: ^20.19.0 || >=22.12.0} + cpu: [ppc64] + os: [linux] + libc: [glibc] + + '@oxfmt/binding-linux-riscv64-gnu@0.44.0': + resolution: {integrity: sha512-eOdzs6RqkRzuqNHUX5C8ISN5xfGh4xDww8OEd9YAmc3OWN8oAe5bmlIqQ+rrHLpv58/0BuU48bxkhnIGjA/ATQ==} + engines: {node: ^20.19.0 || >=22.12.0} + cpu: [riscv64] + os: [linux] + libc: [glibc] + + '@oxfmt/binding-linux-riscv64-musl@0.44.0': + resolution: {integrity: sha512-YBgNTxntD/QvlFUfgvh8bEdwOhXiquX8gaofZJAwYa/Xp1S1DQrFVZEeck7GFktr24DztsSp8N8WtWCBwxs0Hw==} + engines: {node: ^20.19.0 || >=22.12.0} + cpu: [riscv64] + os: [linux] + libc: [musl] + + '@oxfmt/binding-linux-s390x-gnu@0.44.0': + resolution: {integrity: sha512-GLIh1R6WHWshl/i4QQDNgj0WtT25aRO4HNUWEoitxiywyRdhTFmFEYT2rXlcl9U6/26vhmOqG5cRlMLG3ocaIA==} + engines: {node: ^20.19.0 || >=22.12.0} + cpu: [s390x] + os: [linux] + libc: [glibc] + + '@oxfmt/binding-linux-x64-gnu@0.44.0': + resolution: {integrity: sha512-gZOpgTlOsLcLfAF9qgpTr7FIIFSKnQN3hDf/0JvQ4CIwMY7h+eilNjxq/CorqvYcEOu+LRt1W4ZS7KccEHLOdA==} + engines: {node: ^20.19.0 || >=22.12.0} + cpu: [x64] + os: [linux] + libc: [glibc] + + '@oxfmt/binding-linux-x64-musl@0.44.0': + resolution: {integrity: sha512-1CyS9JTB+pCUFYFI6pkQGGZaT/AY5gnhHVrQQLhFba6idP9AzVYm1xbdWfywoldTYvjxQJV6x4SuduCIfP3W+A==} + engines: {node: ^20.19.0 || >=22.12.0} + cpu: [x64] + os: [linux] + libc: [musl] + + '@oxfmt/binding-openharmony-arm64@0.44.0': + resolution: {integrity: sha512-bmEv70Ak6jLr1xotCbF5TxIKjsmQaiX+jFRtnGtfA03tJPf6VG3cKh96S21boAt3JZc+Vjx8PYcDuLj39vM2Pw==} + engines: {node: ^20.19.0 || >=22.12.0} + cpu: [arm64] + os: [openharmony] + + '@oxfmt/binding-win32-arm64-msvc@0.44.0': + resolution: {integrity: sha512-yWzB+oCpSnP/dmw85eFLAT5o35Ve5pkGS2uF/UCISpIwDqf1xa7OpmtomiqY/Vzg8VyvMbuf6vroF2khF/+1Vg==} + engines: {node: ^20.19.0 || >=22.12.0} + cpu: [arm64] + os: [win32] + + '@oxfmt/binding-win32-ia32-msvc@0.44.0': + resolution: {integrity: sha512-TcWpo18xEIE3AmIG2kpr3kz5IEhQgnx0lazl2+8L+3eTopOAUevQcmlr4nhguImNWz0OMeOZrYZOhJNCf16nlQ==} + engines: {node: ^20.19.0 || >=22.12.0} + cpu: [ia32] + os: [win32] + + '@oxfmt/binding-win32-x64-msvc@0.44.0': + resolution: {integrity: sha512-oj8aLkPJZppIM4CMQNsyir9ybM1Xw/CfGPTSsTnzpVGyljgfbdP0EVUlURiGM0BDrmw5psQ6ArmGCcUY/yABaQ==} + engines: {node: ^20.19.0 || >=22.12.0} + cpu: [x64] + os: [win32] + + '@oxlint/binding-android-arm-eabi@1.59.0': + resolution: {integrity: sha512-etYDw/UaEv936AQUd/CRMBVd+e+XuuU6wC+VzOv1STvsTyZenLChepLWqLtnyTTp4YMlM22ypzogDDwqYxv5cg==} + engines: {node: ^20.19.0 || >=22.12.0} + cpu: [arm] + os: [android] + + '@oxlint/binding-android-arm64@1.59.0': + resolution: {integrity: sha512-TgLc7XVLKH2a4h8j3vn1MDjfK33i9MY60f/bKhRGWyVzbk5LCZ4X01VZG7iHrMmi5vYbAp8//Ponigx03CLsdw==} + engines: {node: ^20.19.0 || >=22.12.0} + cpu: [arm64] + os: [android] + + '@oxlint/binding-darwin-arm64@1.59.0': + resolution: {integrity: sha512-DXyFPf5ZKldMLloRHx/B9fsxsiTQomaw7cmEW3YIJko2HgCh+GUhp9gGYwHrqlLJPsEe3dYj9JebjX92D3j3AA==} + engines: {node: ^20.19.0 || >=22.12.0} + cpu: [arm64] + os: [darwin] + + '@oxlint/binding-darwin-x64@1.59.0': + resolution: {integrity: sha512-LgvrsdgVLX1qWqIEmNsSmMXJhpAWdtUQ0M+oR0CySwi+9IHWyOGuIL8w8+u/kbZNMyZr4WUyYB5i0+D+AKgkLg==} + engines: {node: ^20.19.0 || >=22.12.0} + cpu: [x64] + os: [darwin] + + '@oxlint/binding-freebsd-x64@1.59.0': + resolution: {integrity: sha512-bOJhqX/ny4hrFuTPlyk8foSRx/vLRpxJh0jOOKN2NWW6FScXHPAA5rQbrwdQPcgGB5V8Ua51RS03fke8ssBcug==} + engines: {node: ^20.19.0 || >=22.12.0} + cpu: [x64] + os: [freebsd] + + '@oxlint/binding-linux-arm-gnueabihf@1.59.0': + resolution: {integrity: sha512-vVUXxYMF9trXCsz4m9H6U0IjehosVHxBzVgJUxly1uz4W1PdDyicaBnpC0KRXsHYretLVe+uS9pJy8iM57Kujw==} + engines: {node: ^20.19.0 || >=22.12.0} + cpu: [arm] + os: [linux] + + '@oxlint/binding-linux-arm-musleabihf@1.59.0': + resolution: {integrity: sha512-TULQW8YBPGRWg5yZpFPL54HLOnJ3/HiX6VenDPi6YfxB/jlItwSMFh3/hCeSNbh+DAMaE1Py0j5MOaivHkI/9Q==} + engines: {node: ^20.19.0 || >=22.12.0} + cpu: [arm] + os: [linux] + + '@oxlint/binding-linux-arm64-gnu@1.59.0': + resolution: {integrity: sha512-Gt54Y4eqSgYJ90xipm24xeyaPV854706o/kiT8oZvUt3VDY7qqxdqyGqchMaujd87ib+/MXvnl9WkK8Cc1BExg==} + engines: {node: ^20.19.0 || >=22.12.0} + cpu: [arm64] + os: [linux] + libc: [glibc] + + '@oxlint/binding-linux-arm64-musl@1.59.0': + resolution: {integrity: sha512-3CtsKp7NFB3OfqQzbuAecrY7GIZeiv7AD+xutU4tefVQzlfmTI7/ygWLrvkzsDEjTlMq41rYHxgsn6Yh8tybmA==} + engines: {node: ^20.19.0 || >=22.12.0} + cpu: [arm64] + os: [linux] + libc: [musl] + + '@oxlint/binding-linux-ppc64-gnu@1.59.0': + resolution: {integrity: sha512-K0diOpT3ncDmOfl9I1HuvpEsAuTxkts0VYwIv/w6Xiy9CdwyPBVX88Ga9l8VlGgMrwBMnSY4xIvVlVY/fkQk7Q==} + engines: {node: ^20.19.0 || >=22.12.0} + cpu: [ppc64] + os: [linux] + libc: [glibc] + + '@oxlint/binding-linux-riscv64-gnu@1.59.0': + resolution: {integrity: sha512-xAU7+QDU6kTJJ7mJLOGgo7oOjtAtkKyFZ0Yjdb5cEo3DiCCPFLvyr08rWiQh6evZ7RiUTf+o65NY/bqttzJiQQ==} + engines: {node: ^20.19.0 || >=22.12.0} + cpu: [riscv64] + os: [linux] + libc: [glibc] + + '@oxlint/binding-linux-riscv64-musl@1.59.0': + resolution: {integrity: sha512-KUmZmKlTTyauOnvUNVxK7G40sSSx0+w5l1UhaGsC6KPpOYHenx2oqJTnabmpLJicok7IC+3Y6fXAUOMyexaeJQ==} + engines: {node: ^20.19.0 || >=22.12.0} + cpu: [riscv64] + os: [linux] + libc: [musl] + + '@oxlint/binding-linux-s390x-gnu@1.59.0': + resolution: {integrity: sha512-4usRxC8gS0PGdkHnRmwJt/4zrQNZyk6vL0trCxwZSsAKM+OxhB8nKiR+mhjdBbl8lbMh2gc3bZpNN/ik8c4c2A==} + engines: {node: ^20.19.0 || >=22.12.0} + cpu: [s390x] + os: [linux] + libc: [glibc] + + '@oxlint/binding-linux-x64-gnu@1.59.0': + resolution: {integrity: sha512-s/rNE2gDmbwAOOP493xk2X7M8LZfI1LJFSSW1+yanz3vuQCFPiHkx4GY+O1HuLUDtkzGlhtMrIcxxzyYLv308w==} + engines: {node: ^20.19.0 || >=22.12.0} + cpu: [x64] + os: [linux] + libc: [glibc] + + '@oxlint/binding-linux-x64-musl@1.59.0': + resolution: {integrity: sha512-+yYj1udJa2UvvIUmEm0IcKgc0UlPMgz0nsSTvkPL2y6n0uU5LgIHSwVu4AHhrve6j9BpVSoRksnz8c9QcvITJA==} + engines: {node: ^20.19.0 || >=22.12.0} + cpu: [x64] + os: [linux] + libc: [musl] + + '@oxlint/binding-openharmony-arm64@1.59.0': + resolution: {integrity: sha512-bUplUb48LYsB3hHlQXP2ZMOenpieWoOyppLAnnAhuPag3MGPnt+7caxE3w/Vl9wpQsTA3gzLntQi9rxWrs7Xqg==} + engines: {node: ^20.19.0 || >=22.12.0} + cpu: [arm64] + os: [openharmony] + + '@oxlint/binding-win32-arm64-msvc@1.59.0': + resolution: {integrity: sha512-/HLsLuz42rWl7h7ePdmMTpHm2HIDmPtcEMYgm5BBEHiEiuNOrzMaUpd2z7UnNni5LGN9obJy2YoAYBLXQwazrA==} + engines: {node: ^20.19.0 || >=22.12.0} + cpu: [arm64] + os: [win32] + + '@oxlint/binding-win32-ia32-msvc@1.59.0': + resolution: {integrity: sha512-rUPy+JnanpPwV/aJCPnxAD1fW50+XPI0VkWr7f0vEbqcdsS8NpB24Rw6RsS7SdpFv8Dw+8ugCwao5nCFbqOUSg==} + engines: {node: ^20.19.0 || >=22.12.0} + cpu: [ia32] + os: [win32] + + '@oxlint/binding-win32-x64-msvc@1.59.0': + resolution: {integrity: sha512-xkE7puteDS/vUyRngLXW0t8WgdWoS/tfxXjhP/P7SMqPDx+hs44SpssO3h3qmTqECYEuXBUPzcAw5257Ka+ofA==} + engines: {node: ^20.19.0 || >=22.12.0} + cpu: [x64] + os: [win32] + '@pkgjs/parseargs@0.11.0': resolution: {integrity: sha512-+1VkjdD0QBLPodGrJUeqarH8VAIvQODIbwh9XpP5Syisf7YoQgsJKPNFoqqLQlu+VQ/tVSshMR6loPMn8U+dPg==} engines: {node: '>=14'} @@ -709,6 +959,21 @@ packages: resolution: {integrity: sha512-6eZs5Ls3WtCisHWp9S2GUy8dqkpGi4BVSz3GaqiE6ezub0512ESztXUwUB6C6IKbQkY2Pnb/mD4WYojCRwcwLA==} engines: {node: '>=0.10.0'} + oxfmt@0.44.0: + resolution: {integrity: sha512-lnncqvHewyRvaqdrnntVIrZV2tEddz8lbvPsQzG/zlkfvgZkwy0HP1p/2u1aCDToeg1jb9zBpbJdfkV73Itw+w==} + engines: {node: ^20.19.0 || >=22.12.0} + hasBin: true + + oxlint@1.59.0: + resolution: {integrity: sha512-0xBLeGGjP4vD9pygRo8iuOkOzEU1MqOnfiOl7KYezL/QvWL8NUg6n03zXc7ZVqltiOpUxBk2zgHI3PnRIEdAvw==} + engines: {node: ^20.19.0 || >=22.12.0} + hasBin: true + peerDependencies: + oxlint-tsgolint: '>=0.18.0' + peerDependenciesMeta: + oxlint-tsgolint: + optional: true + package-json-from-dist@1.0.1: resolution: {integrity: sha512-UEZIS3/by4OC8vL3P2dTXRETpebLI2NiI5vIrjaD/5UtrkFX/tNbwjTSRAGC/+7CAo2pIcBaRgWmcBBHcsaCIw==} @@ -830,6 +1095,10 @@ packages: resolution: {integrity: sha512-j2Zq4NyQYG5XMST4cbs02Ak8iJUdxRM0XI5QyxXuZOzKOINmWurp3smXu3y5wDcJrptwpSjgXHzIQxR0omXljQ==} engines: {node: '>=12.0.0'} + tinypool@2.1.0: + resolution: {integrity: sha512-Pugqs6M0m7Lv1I7FtxN4aoyToKg1C4tu+/381vH35y8oENM/Ai7f7C4StcoK4/+BSw9ebcS8jRiVrORFKCALLw==} + engines: {node: ^20.0.0 || >=22.0.0} + tslib@2.8.1: resolution: {integrity: sha512-oJFu94HQb+KVduSUQL7wnpmqnfmLsOA/nAh6b6EH0wCEoK0/mPeXU6c3wKDV83MkOuHPRHtSXKKU99IBazS/2w==} @@ -978,6 +1247,120 @@ snapshots: '@oxc-project/types@0.122.0': {} + '@oxfmt/binding-android-arm-eabi@0.44.0': + optional: true + + '@oxfmt/binding-android-arm64@0.44.0': + optional: true + + '@oxfmt/binding-darwin-arm64@0.44.0': + optional: true + + '@oxfmt/binding-darwin-x64@0.44.0': + optional: true + + '@oxfmt/binding-freebsd-x64@0.44.0': + optional: true + + '@oxfmt/binding-linux-arm-gnueabihf@0.44.0': + optional: true + + '@oxfmt/binding-linux-arm-musleabihf@0.44.0': + optional: true + + '@oxfmt/binding-linux-arm64-gnu@0.44.0': + optional: true + + '@oxfmt/binding-linux-arm64-musl@0.44.0': + optional: true + + '@oxfmt/binding-linux-ppc64-gnu@0.44.0': + optional: true + + '@oxfmt/binding-linux-riscv64-gnu@0.44.0': + optional: true + + '@oxfmt/binding-linux-riscv64-musl@0.44.0': + optional: true + + '@oxfmt/binding-linux-s390x-gnu@0.44.0': + optional: true + + '@oxfmt/binding-linux-x64-gnu@0.44.0': + optional: true + + '@oxfmt/binding-linux-x64-musl@0.44.0': + optional: true + + '@oxfmt/binding-openharmony-arm64@0.44.0': + optional: true + + '@oxfmt/binding-win32-arm64-msvc@0.44.0': + optional: true + + '@oxfmt/binding-win32-ia32-msvc@0.44.0': + optional: true + + '@oxfmt/binding-win32-x64-msvc@0.44.0': + optional: true + + '@oxlint/binding-android-arm-eabi@1.59.0': + optional: true + + '@oxlint/binding-android-arm64@1.59.0': + optional: true + + '@oxlint/binding-darwin-arm64@1.59.0': + optional: true + + '@oxlint/binding-darwin-x64@1.59.0': + optional: true + + '@oxlint/binding-freebsd-x64@1.59.0': + optional: true + + '@oxlint/binding-linux-arm-gnueabihf@1.59.0': + optional: true + + '@oxlint/binding-linux-arm-musleabihf@1.59.0': + optional: true + + '@oxlint/binding-linux-arm64-gnu@1.59.0': + optional: true + + '@oxlint/binding-linux-arm64-musl@1.59.0': + optional: true + + '@oxlint/binding-linux-ppc64-gnu@1.59.0': + optional: true + + '@oxlint/binding-linux-riscv64-gnu@1.59.0': + optional: true + + '@oxlint/binding-linux-riscv64-musl@1.59.0': + optional: true + + '@oxlint/binding-linux-s390x-gnu@1.59.0': + optional: true + + '@oxlint/binding-linux-x64-gnu@1.59.0': + optional: true + + '@oxlint/binding-linux-x64-musl@1.59.0': + optional: true + + '@oxlint/binding-openharmony-arm64@1.59.0': + optional: true + + '@oxlint/binding-win32-arm64-msvc@1.59.0': + optional: true + + '@oxlint/binding-win32-ia32-msvc@1.59.0': + optional: true + + '@oxlint/binding-win32-x64-msvc@1.59.0': + optional: true + '@pkgjs/parseargs@0.11.0': optional: true @@ -1468,6 +1851,52 @@ snapshots: normalize-path@3.0.0: {} + oxfmt@0.44.0: + dependencies: + tinypool: 2.1.0 + optionalDependencies: + '@oxfmt/binding-android-arm-eabi': 0.44.0 + '@oxfmt/binding-android-arm64': 0.44.0 + '@oxfmt/binding-darwin-arm64': 0.44.0 + '@oxfmt/binding-darwin-x64': 0.44.0 + '@oxfmt/binding-freebsd-x64': 0.44.0 + '@oxfmt/binding-linux-arm-gnueabihf': 0.44.0 + '@oxfmt/binding-linux-arm-musleabihf': 0.44.0 + '@oxfmt/binding-linux-arm64-gnu': 0.44.0 + '@oxfmt/binding-linux-arm64-musl': 0.44.0 + '@oxfmt/binding-linux-ppc64-gnu': 0.44.0 + '@oxfmt/binding-linux-riscv64-gnu': 0.44.0 + '@oxfmt/binding-linux-riscv64-musl': 0.44.0 + '@oxfmt/binding-linux-s390x-gnu': 0.44.0 + '@oxfmt/binding-linux-x64-gnu': 0.44.0 + '@oxfmt/binding-linux-x64-musl': 0.44.0 + '@oxfmt/binding-openharmony-arm64': 0.44.0 + '@oxfmt/binding-win32-arm64-msvc': 0.44.0 + '@oxfmt/binding-win32-ia32-msvc': 0.44.0 + '@oxfmt/binding-win32-x64-msvc': 0.44.0 + + oxlint@1.59.0: + optionalDependencies: + '@oxlint/binding-android-arm-eabi': 1.59.0 + '@oxlint/binding-android-arm64': 1.59.0 + '@oxlint/binding-darwin-arm64': 1.59.0 + '@oxlint/binding-darwin-x64': 1.59.0 + '@oxlint/binding-freebsd-x64': 1.59.0 + '@oxlint/binding-linux-arm-gnueabihf': 1.59.0 + '@oxlint/binding-linux-arm-musleabihf': 1.59.0 + '@oxlint/binding-linux-arm64-gnu': 1.59.0 + '@oxlint/binding-linux-arm64-musl': 1.59.0 + '@oxlint/binding-linux-ppc64-gnu': 1.59.0 + '@oxlint/binding-linux-riscv64-gnu': 1.59.0 + '@oxlint/binding-linux-riscv64-musl': 1.59.0 + '@oxlint/binding-linux-s390x-gnu': 1.59.0 + '@oxlint/binding-linux-x64-gnu': 1.59.0 + '@oxlint/binding-linux-x64-musl': 1.59.0 + '@oxlint/binding-openharmony-arm64': 1.59.0 + '@oxlint/binding-win32-arm64-msvc': 1.59.0 + '@oxlint/binding-win32-ia32-msvc': 1.59.0 + '@oxlint/binding-win32-x64-msvc': 1.59.0 + package-json-from-dist@1.0.1: {} path-key@3.1.1: {} @@ -1627,6 +2056,8 @@ snapshots: fdir: 6.5.0(picomatch@4.0.4) picomatch: 4.0.4 + tinypool@2.1.0: {} + tslib@2.8.1: optional: true diff --git a/webui/index.html b/webui/index.html index 8f0c64d..3bc5fe8 100644 --- a/webui/index.html +++ b/webui/index.html @@ -1,16 +1,14 @@ - + + + + + LuminPro + + - - - - LuminPro - - - - -
- - - + +
+ + diff --git a/webui/src/App.vue b/webui/src/App.vue index 3ca5258..03f954a 100644 --- a/webui/src/App.vue +++ b/webui/src/App.vue @@ -1,98 +1,101 @@ @@ -112,19 +115,23 @@ function handleViewChange(view) {
-
+
{{ status.statusText.value }}
- -
diff --git a/webui/src/about.css b/webui/src/about.css index 1389705..a735d0f 100644 --- a/webui/src/about.css +++ b/webui/src/about.css @@ -12,7 +12,11 @@ width: 72px; height: 72px; border-radius: 20px; - background: linear-gradient(135deg, var(--md-sys-color-primary-container), var(--md-sys-color-secondary-container)); + background: linear-gradient( + 135deg, + var(--md-sys-color-primary-container), + var(--md-sys-color-secondary-container) + ); display: flex; align-items: center; justify-content: center; @@ -73,7 +77,7 @@ width: 100%; } .about-list-item + .about-list-item { - border-top: 1px solid rgba(var(--md-sys-color-on-surface-rgb, 0,0,0), 0.06); + border-top: 1px solid rgba(var(--md-sys-color-on-surface-rgb, 0, 0, 0), 0.06); } .about-list-item:active { background-color: var(--md-sys-color-surface-container-high); @@ -103,7 +107,7 @@ .doc-sheet-backdrop { position: fixed; inset: 0; - background: rgba(0,0,0,0.5); + background: rgba(0, 0, 0, 0.5); backdrop-filter: blur(4px); z-index: 1999; opacity: 0; @@ -127,7 +131,7 @@ flex-direction: column; transform: translateY(100%); transition: transform 0.35s cubic-bezier(0.19, 1, 0.22, 1); - box-shadow: 0 -8px 32px rgba(0,0,0,0.3); + box-shadow: 0 -8px 32px rgba(0, 0, 0, 0.3); overflow: hidden; } .doc-sheet.show { @@ -137,7 +141,7 @@ display: flex; align-items: center; padding: 16px 16px 12px; - border-bottom: 1px solid rgba(var(--md-sys-color-on-surface-rgb, 0,0,0), 0.07); + border-bottom: 1px solid rgba(var(--md-sys-color-on-surface-rgb, 0, 0, 0), 0.07); gap: 12px; flex-shrink: 0; } @@ -183,7 +187,8 @@ color: var(--md-sys-color-on-surface); word-break: break-word; } -.doc-sheet-content h1, .doc-sheet-content h2 { +.doc-sheet-content h1, +.doc-sheet-content h2 { color: var(--md-sys-color-primary); margin-top: 1.4em; } @@ -232,7 +237,6 @@ font-weight: 600; } - /* ========================================== Theme Segmented Button ========================================== */ @@ -262,5 +266,3 @@ color: var(--md-sys-color-on-primary-container); font-weight: 600; } - - diff --git a/webui/src/apps.css b/webui/src/apps.css index 9efb3ed..7933983 100644 --- a/webui/src/apps.css +++ b/webui/src/apps.css @@ -14,7 +14,9 @@ border-radius: var(--border-radius-m); padding: 8px 12px; margin-bottom: var(--spacing-m); - transition: border-color 0.2s, box-shadow 0.2s; + transition: + border-color 0.2s, + box-shadow 0.2s; } .app-search-container:focus-within { @@ -188,7 +190,11 @@ width: 40px; height: 40px; border-radius: 8px; - background: linear-gradient(135deg, var(--md-sys-color-primary-container), rgba(168, 199, 250, 0.5)); + background: linear-gradient( + 135deg, + var(--md-sys-color-primary-container), + rgba(168, 199, 250, 0.5) + ); color: var(--md-sys-color-on-primary-container); display: flex; align-items: center; @@ -239,7 +245,9 @@ border-radius: var(--border-radius-s); color: var(--md-sys-color-on-surface-variant); cursor: pointer; - transition: transform 0.2s, background-color 0.2s; + transition: + transform 0.2s, + background-color 0.2s; padding: 0; } @@ -337,7 +345,9 @@ font-weight: 500; padding: 3px 8px; cursor: pointer; - transition: background-color 0.2s, border-color 0.2s; + transition: + background-color 0.2s, + border-color 0.2s; white-space: nowrap; font-family: inherit; } @@ -363,7 +373,9 @@ font-size: 0.8125rem; color: var(--md-sys-color-on-surface); outline: none; - transition: border-color 0.2s, box-shadow 0.2s; + transition: + border-color 0.2s, + box-shadow 0.2s; } .activity-block-input:focus { @@ -437,7 +449,10 @@ height: 6px; border-radius: 50%; background-color: var(--md-sys-color-outline-variant); - transition: background-color 0.3s, transform 0.3s, width 0.3s; + transition: + background-color 0.3s, + transform 0.3s, + width 0.3s; } .picker-step-dot.active { @@ -504,8 +519,13 @@ } @keyframes picker-pulse { - 0%, 100% { opacity: 1; } - 50% { opacity: 0.35; } + 0%, + 100% { + opacity: 1; + } + 50% { + opacity: 0.35; + } } .picker-result-box { diff --git a/webui/src/apps.js b/webui/src/apps.js index 3c99366..c085ec3 100644 --- a/webui/src/apps.js +++ b/webui/src/apps.js @@ -1,646 +1,714 @@ // oxlint-disable no-unused-expressions -import { listPackages, getPackagesInfo } from 'kernelsu'; -import { createIcons, Eye, EyeOff } from 'lucide'; -import PinyinMatch from 'pinyin-match'; -import { CONFIG_DIR, showToast, runCmd, readConfig, updateConfig } from './utils.js'; +import { listPackages, getPackagesInfo } from 'kernelsu' +import { createIcons, Eye, EyeOff } from 'lucide' +import PinyinMatch from 'pinyin-match' +import { CONFIG_DIR, showToast, runCmd, readConfig, updateConfig } from './utils.js' -let showingSystemApps = true; -let savedBlacklist = new Set(); -let activityEntries = new Set(); // 活动级黑名单条目(格式:pkg/ActivityClass) +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 + '/')); + 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'); + custom.classList.add('partial') } else { - custom.classList.remove('partial'); + custom.classList.remove('partial') } // 未保存高亮 if (cb.checked && !savedBlacklist.has(pkg)) { - cb.classList.add('unsaved'); + cb.classList.add('unsaved') } else { - cb.classList.remove('unsaved'); + cb.classList.remove('unsaved') } // 箭头可见性 - const chevron = item.querySelector('.app-activities-chevron'); + const chevron = item.querySelector('.app-activities-chevron') if (chevron) { - chevron.style.display = hasActivities ? '' : 'none'; + chevron.style.display = hasActivities ? '' : 'none' if (!hasActivities) { - const actList = item.querySelector('.app-activities-list'); - if (actList) { actList.classList.remove('show'); chevron.classList.remove('expanded'); } + 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 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)); + 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 = ''; + const entries = [...activityEntries].filter((e) => e.startsWith(pkg + '/')) + container.innerHTML = '' + entries.forEach((entry) => { + const entryDiv = document.createElement('div') + entryDiv.className = 'activity-entry-item' + const actPath = document.createElement('span') + actPath.className = 'activity-entry-path' + actPath.textContent = entry.slice(pkg.length + 1) + const delBtn = document.createElement('button') + delBtn.className = 'activity-entry-delete' + delBtn.innerHTML = + '' delBtn.addEventListener('click', (e) => { - e.stopPropagation(); - activityEntries.delete(entry); - renderActivityList(pkg, container); - const actItem = container.closest('.app-list-item'); + 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'); } + 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); - }); + 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 = '
加载中...
'; + const container = document.getElementById('app-list-container') + if (!container) return + container.innerHTML = + '
加载中...
' try { // 读取已保存的黑名单(从 JSON 配置读取) - const cfg = await readConfig(); - const allSaved = Array.isArray(cfg.blacklist_apps) ? cfg.blacklist_apps : []; - savedBlacklist = new Set(allSaved); - const savedPkgEntries = new Set(allSaved.filter(e => !e.includes('/'))); - activityEntries = new Set(allSaved.filter(e => e.includes('/'))); + 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 = []; + let infoList = [] try { - const pkgs = await listPackages(); + const pkgs = await listPackages() if (pkgs && pkgs.length > 0) { - infoList = await getPackagesInfo(pkgs); + infoList = await getPackagesInfo(pkgs) } else { - throw new Error('No packages found'); + throw new Error('No packages found') } } catch { // 模拟 150 个应用包数据用于调试 - console.log("[DEBUG] 使用模拟应用列表数据"); + console.log('[DEBUG] 使用模拟应用列表数据') infoList = Array.from({ length: 150 }, (_, i) => ({ packageName: `com.mock.app${i}`, appLabel: i % 10 === 0 ? `测试应用 ${i} (含抖音关键字)` : `模拟应用 ${i}`, isSystem: i % 5 === 0, - uid: 10000 + i - })); + uid: 10000 + i, + })) } // 过滤系统应用 if (!showingSystemApps) { - infoList = infoList.filter(app => !app.isSystem); + infoList = infoList.filter((app) => !app.isSystem) } - container.innerHTML = ''; + container.innerHTML = '' // 排序:非系统优先,按名称 infoList.sort((a, b) => { - if (a.isSystem !== b.isSystem) return a.isSystem ? 1 : -1; - return (a.appLabel || "").localeCompare(b.appLabel || ""); - }); + if (a.isSystem !== b.isSystem) return a.isSystem ? 1 : -1 + return (a.appLabel || '').localeCompare(b.appLabel || '') + }) 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 } - ); + { 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); + 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; - }); + 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'; + infoList.forEach((app) => { + const item = document.createElement('div') + item.className = 'app-list-item' - const checkboxLabel = document.createElement('label'); - checkboxLabel.className = 'app-checkbox-label'; + 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; + const checkbox = document.createElement('input') + checkbox.type = 'checkbox' + checkbox.className = 'app-checkbox' + checkbox.dataset.pkg = app.packageName // 依据已保存包名条目勾选(不含活动条目) - checkbox.checked = savedPkgEntries.has(app.packageName); + checkbox.checked = savedPkgEntries.has(app.packageName) checkbox.addEventListener('change', () => { - updateUnsavedStyling(); - reorderDOMApps(); - }); + updateUnsavedStyling() + reorderDOMApps() + }) - const customCheckbox = document.createElement('span'); - customCheckbox.className = 'app-checkbox-custom'; - checkboxLabel.appendChild(checkbox); - checkboxLabel.appendChild(customCheckbox); + 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 infoDiv = document.createElement('div') + infoDiv.className = 'app-info' - const nameSpan = document.createElement('span'); - nameSpan.className = 'app-name'; - nameSpan.appendChild(document.createTextNode(app.appLabel || 'Unknown')); + 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 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 || ''; + 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); + const sysBadge = document.createElement('span') + sysBadge.className = 'app-badge' + sysBadge.textContent = '系统' + pkgSpan.appendChild(sysBadge) } - infoDiv.appendChild(nameSpan); - infoDiv.appendChild(pkgSpan); + infoDiv.appendChild(nameSpan) + infoDiv.appendChild(pkgSpan) // 活动展开箭头 - const chevronBtn = document.createElement('button'); - chevronBtn.className = 'app-activities-chevron'; - chevronBtn.innerHTML = ''; - const pkgActivities = [...activityEntries].filter(e => e.startsWith(app.packageName + '/')); - chevronBtn.style.display = pkgActivities.length > 0 ? '' : 'none'; + const chevronBtn = document.createElement('button') + chevronBtn.className = 'app-activities-chevron' + chevronBtn.innerHTML = + '' + const pkgActivities = [...activityEntries].filter((e) => e.startsWith(app.packageName + '/')) + chevronBtn.style.display = pkgActivities.length > 0 ? '' : 'none' - const mainRow = document.createElement('div'); - mainRow.className = 'app-item-main-row'; - mainRow.appendChild(checkboxLabel); - mainRow.appendChild(infoDiv); - mainRow.appendChild(chevronBtn); + const 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); + 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'); - }); + e.stopPropagation() + actListDiv.classList.toggle('show') + chevronBtn.classList.toggle('expanded') + }) - item.appendChild(mainRow); - item.appendChild(actListDiv); - container.appendChild(item); - }); + item.appendChild(mainRow) + item.appendChild(actListDiv) + container.appendChild(item) + }) - updateUnsavedStyling(); - reorderDOMApps(); + updateUnsavedStyling() + reorderDOMApps() - const badge = document.getElementById('app-count-badge'); - if (badge) badge.textContent = infoList.length; + const badge = document.getElementById('app-count-badge') + if (badge) badge.textContent = infoList.length if (infoList.length === 0) { - container.innerHTML = '
无应用
'; + container.innerHTML = + '
无应用
' } } catch (e) { - container.innerHTML = `
加载失败: ${e.message || String(e)}
`; + container.innerHTML = `
加载失败: ${e.message || String(e)}
` } } export function setupAppsEvents() { // 下拉菜单控制 - const btnAppsMenu = document.getElementById('btn-apps-menu'); - const appsDropdownMenu = document.getElementById('apps-dropdown-menu'); + 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'); - }); + e.stopPropagation() + appsDropdownMenu.classList.toggle('show') + }) document.addEventListener('click', (e) => { if (!btnAppsMenu.contains(e.target) && !appsDropdownMenu.contains(e.target)) { - appsDropdownMenu.classList.remove('show'); + appsDropdownMenu.classList.remove('show') } - }); + }) } // 切换系统应用显示 - const btnToggleSysApps = document.getElementById('btn-toggle-sys-apps'); + const btnToggleSysApps = document.getElementById('btn-toggle-sys-apps') if (btnToggleSysApps) { btnToggleSysApps.addEventListener('click', () => { - showingSystemApps = !showingSystemApps; + showingSystemApps = !showingSystemApps - const textSpan = document.getElementById('sys-apps-text'); - const iconWrap = document.getElementById('sys-apps-icon'); + const textSpan = document.getElementById('sys-apps-text') + const iconWrap = document.getElementById('sys-apps-icon') - if (textSpan) textSpan.textContent = showingSystemApps ? '隐藏系统应用' : '显示系统应用'; + 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' }); + 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'); - }); + loadApps() + appsDropdownMenu && appsDropdownMenu.classList.remove('show') + }) } // 智能选择 - const btnSmartSelect = document.getElementById('btn-smart-select'); + const btnSmartSelect = document.getElementById('btn-smart-select') if (btnSmartSelect) { - const smartKeywords = ["相册", "抖音", "快手", "视频", "哔哩哔哩", "bili", "pili", "netflix", "youtube", "tiktok", "x"]; + 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; + 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; } + if (name === 'x' || name === 'x (twitter)') { + match = true + break + } } else if (name.includes(kw)) { - match = true; break; + match = true + break } } - if (match) checkbox.checked = true; - }); - updateUnsavedStyling(); - reorderDOMApps(); - appsDropdownMenu && appsDropdownMenu.classList.remove('show'); - }); + if (match) checkbox.checked = true + }) + updateUnsavedStyling() + reorderDOMApps() + appsDropdownMenu && appsDropdownMenu.classList.remove('show') + }) } // 手动添加包名 - const btnManualAdd = document.getElementById('btn-manual-add'); + 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; + 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}"]`); + const realPkg = pkg.trim() + const existing = document.querySelector(`.app-checkbox[data-pkg="${realPkg}"]`) if (existing) { - existing.checked = true; - updateUnsavedStyling(); - reorderDOMApps(); - showToast('该应用已在列表中,已为你自动勾选并置顶'); - return; + existing.checked = true + updateUnsavedStyling() + reorderDOMApps() + showToast('该应用已在列表中,已为你自动勾选并置顶') + return } - showToast('正在尝试获取应用信息...'); - let appData = { packageName: realPkg, appLabel: '未知 (手动添加)', isSystem: false, uid: '自定义' }; + 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 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 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 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 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 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 infoDiv = document.createElement('div') + infoDiv.className = 'app-info' - const nameSpan = document.createElement('span'); - nameSpan.className = 'app-name'; - nameSpan.appendChild(document.createTextNode(appData.appLabel || 'Unknown')); + 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 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; + 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); + const sysBadge = document.createElement('span') + sysBadge.className = 'app-badge' + sysBadge.textContent = '系统' + pkgSpan.appendChild(sysBadge) } - infoDiv.appendChild(nameSpan); - infoDiv.appendChild(pkgSpan); + infoDiv.appendChild(nameSpan) + infoDiv.appendChild(pkgSpan) - const chevronBtn = document.createElement('button'); - chevronBtn.className = 'app-activities-chevron'; - chevronBtn.innerHTML = ''; - chevronBtn.style.display = 'none'; + const chevronBtn = document.createElement('button') + chevronBtn.className = 'app-activities-chevron' + chevronBtn.innerHTML = + '' + chevronBtn.style.display = 'none' - const mainRow = document.createElement('div'); - mainRow.className = 'app-item-main-row'; - mainRow.appendChild(checkboxLabel); - mainRow.appendChild(infoDiv); - mainRow.appendChild(chevronBtn); + const 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; + 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'); - }); + e.stopPropagation() + actListDiv.classList.toggle('show') + chevronBtn.classList.toggle('expanded') + }) - item.appendChild(mainRow); - item.appendChild(actListDiv); - container.appendChild(item); + item.appendChild(mainRow) + item.appendChild(actListDiv) + container.appendChild(item) - updateUnsavedStyling(); - reorderDOMApps(); - showToast('已成功添加并勾选'); - }); + updateUnsavedStyling() + reorderDOMApps() + showToast('已成功添加并勾选') + }) } // 全选 - const btnSelectAll = document.getElementById('btn-select-all'); + 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'); - }); + document.querySelectorAll('.app-checkbox').forEach((cb) => { + cb.checked = true + }) + updateUnsavedStyling() + appsDropdownMenu && appsDropdownMenu.classList.remove('show') + }) } // 全不选 - const btnSelectNone = document.getElementById('btn-select-none'); + 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'); - }); + document.querySelectorAll('.app-checkbox').forEach((cb) => { + cb.checked = false + }) + updateUnsavedStyling() + appsDropdownMenu && appsDropdownMenu.classList.remove('show') + }) } // 反选 - const btnInvertSelection = document.getElementById('btn-invert-selection'); + 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'); - }); + document.querySelectorAll('.app-checkbox').forEach((cb) => { + cb.checked = !cb.checked + }) + updateUnsavedStyling() + appsDropdownMenu && appsDropdownMenu.classList.remove('show') + }) } // 刷新(重排) - const btnAppsRefresh = document.getElementById('btn-apps-refresh'); + const btnAppsRefresh = document.getElementById('btn-apps-refresh') if (btnAppsRefresh) { - btnAppsRefresh.addEventListener('click', () => { reorderDOMApps(); }); + btnAppsRefresh.addEventListener('click', () => { + reorderDOMApps() + }) } // 保存黑名单 - const btnSaveBlacklist = document.getElementById('btn-save-blacklist'); + 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 }); + 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(); + showToast('黑名单保存成功') + savedBlacklist = new Set(allEntries) + updateUnsavedStyling() + reorderDOMApps() } else { - showToast('保存失败: ' + res.stderr); + showToast('保存失败: ' + res.stderr) } - }); + }) } // 按活动屏蔽 - const btnAddActivity = document.getElementById('btn-add-activity'); - const inputActivityEntry = document.getElementById('input-activity-entry'); + 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('/'); + const val = inputActivityEntry.value.trim() + if (!val) return + const parts = val.split('/') if (parts.length !== 2 || !parts[0] || !parts[1]) { - showToast('格式错误,请输入 包名/完整活动类名'); - return; + showToast('格式错误,请输入 包名/完整活动类名') + return } - activityEntries.add(val); - inputActivityEntry.value = ''; - const pkg = parts[0]; - document.querySelectorAll('.app-list-item').forEach(appItem => { - const cb = appItem.querySelector('.app-checkbox'); + 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'); } + 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(); }); + }) + updateUnsavedStyling() + reorderDOMApps() + showToast(`已添加: ${val}`) + } + btnAddActivity.addEventListener('click', doAddActivity) + inputActivityEntry.addEventListener('keydown', (e) => { + if (e.key === 'Enter') doAddActivity() + }) } // 搜索 - const inputAppSearch = document.getElementById('input-app-search'); + 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(); + 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++; + item.style.display = 'flex' + visibleCount++ } else { - item.style.display = 'none'; + item.style.display = 'none' } - }); - const badge = document.getElementById('app-count-badge'); - if (badge) badge.textContent = visibleCount; - }); + }) + const badge = document.getElementById('app-count-badge') + if (badge) badge.textContent = visibleCount + }) } - setupActivityPicker(); + setupActivityPicker() } function setupActivityPicker() { - const overlay = document.getElementById('activity-picker-overlay'); - if (!overlay) return; + 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 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'); + ] + 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; + 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'; - }); + ;[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); - }); + d?.classList.toggle('active', i + 1 === n) + }) } function stopPolling() { - if (pollingTimer) { clearInterval(pollingTimer); pollingTimer = null; } + if (pollingTimer) { + clearInterval(pollingTimer) + pollingTimer = null + } } function openPicker() { - stopPolling(); - detectedActivity = null; - if (btnPickerStart) btnPickerStart.disabled = false; + stopPolling() + detectedActivity = null + if (btnPickerStart) btnPickerStart.disabled = false if (pickerStatusText) { - pickerStatusText.textContent = '等待中...'; - pickerStatusText.classList.remove('polling'); + pickerStatusText.textContent = '等待中...' + pickerStatusText.classList.remove('polling') } - showStep(1); - overlay.classList.add('show'); + showStep(1) + overlay.classList.add('show') } function closePicker() { - stopPolling(); - overlay.classList.remove('show'); + stopPolling() + overlay.classList.remove('show') } - btnPickActivity?.addEventListener('click', openPicker); - btnPickerBack?.addEventListener('click', closePicker); - btnStep1Next?.addEventListener('click', () => showStep(2)); + btnPickActivity?.addEventListener('click', openPicker) + btnPickerBack?.addEventListener('click', closePicker) + btnStep1Next?.addEventListener('click', () => showStep(2)) btnPickerStart?.addEventListener('click', () => { - btnPickerStart.disabled = true; + btnPickerStart.disabled = true if (pickerStatusText) { - pickerStatusText.textContent = '检测中,请切换到目标界面...'; - pickerStatusText.classList.add('polling'); + pickerStatusText.textContent = '检测中,请切换到目标界面...' + pickerStatusText.classList.add('polling') } - stopPolling(); + 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 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); - }); + 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; + stopPolling() + detectedActivity = null + if (btnPickerStart) btnPickerStart.disabled = false if (pickerStatusText) { - pickerStatusText.textContent = '等待中...'; - pickerStatusText.classList.remove('polling'); + pickerStatusText.textContent = '等待中...' + pickerStatusText.classList.remove('polling') } - showStep(2); - }); + 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 (!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'); } + 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(); - }); + }) + updateUnsavedStyling() + reorderDOMApps() + showToast(`已添加: ${detectedActivity}`) + closePicker() + }) } diff --git a/webui/src/components.css b/webui/src/components.css index 10a6bab..ab3a9ad 100644 --- a/webui/src/components.css +++ b/webui/src/components.css @@ -3,7 +3,9 @@ background-color: var(--md-sys-color-surface); border-radius: var(--border-radius-m); padding: var(--spacing-l); - box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.3), 0 4px 8px 3px rgba(0, 0, 0, 0.15); + box-shadow: + 0 1px 3px 0 rgba(0, 0, 0, 0.3), + 0 4px 8px 3px rgba(0, 0, 0, 0.15); display: flex; flex-direction: column; } @@ -54,7 +56,7 @@ padding: var(--spacing-m); background-color: var(--md-sys-color-surface-container); border-radius: var(--border-radius-m); - border: 1px solid rgba(var(--md-sys-color-on-surface-rgb, 0,0,0), 0.05); + border: 1px solid rgba(var(--md-sys-color-on-surface-rgb, 0, 0, 0), 0.05); } .group-title { @@ -67,7 +69,8 @@ gap: 8px; } -.group-title i, .group-title svg { +.group-title i, +.group-title svg { width: 16px; height: 16px; } @@ -241,20 +244,20 @@ right: 0; bottom: 0; background-color: var(--md-sys-color-surface-container-high); - transition: .4s; + transition: 0.4s; border-radius: 34px; border: 2px solid var(--md-sys-color-outline); } .slider:before { position: absolute; - content: ""; + content: ''; height: 24px; width: 24px; left: 2px; bottom: 2px; background-color: var(--md-sys-color-outline); - transition: .4s; + transition: 0.4s; border-radius: 50%; } @@ -282,7 +285,7 @@ input:checked + .slider:before { display: flex; flex-direction: column; gap: 8px; - border: 1px solid rgba(var(--md-sys-color-on-surface-rgb, 0,0,0), 0.04); + border: 1px solid rgba(var(--md-sys-color-on-surface-rgb, 0, 0, 0), 0.04); transition: transform 0.2s ease; } @@ -319,7 +322,11 @@ input:checked + .slider:before { .brightness-section { margin-top: var(--spacing-l); padding: var(--spacing-m); - background: linear-gradient(135deg, var(--md-sys-color-surface-container-high) 0%, var(--md-sys-color-surface-container) 100%); + background: linear-gradient( + 135deg, + var(--md-sys-color-surface-container-high) 0%, + var(--md-sys-color-surface-container) 100% + ); border-radius: var(--border-radius-m); border: 1px solid var(--md-sys-color-outline-variant); } @@ -370,14 +377,16 @@ input:checked + .slider:before { height: 24px; border-radius: 12px; /* 背景将由 JS 通过 linear-gradient 动态更新实现进度条效果 */ - background: var(--md-sys-color-surface-container-high); + background: var(--md-sys-color-surface-container-high); outline: none; -webkit-appearance: none; appearance: none; cursor: grab; - transition: height 0.2s, box-shadow 0.2s; + transition: + height 0.2s, + box-shadow 0.2s; border: 1px solid rgba(255, 255, 255, 0.03); - box-shadow: inset 0 1px 2px rgba(0,0,0,0.2); + box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.2); overflow: hidden; /* 确保进度条颜色不溢出圆角 */ } @@ -406,12 +415,16 @@ input:checked + .slider:before { background: var(--md-sys-color-primary); cursor: grab; border: 2px solid var(--md-sys-color-surface); - box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4), inset 0 1px 2px rgba(255, 255, 255, 0.3); + box-shadow: + 0 2px 8px rgba(0, 0, 0, 0.4), + inset 0 1px 2px rgba(255, 255, 255, 0.3); transition: all 0.2s; } .brightness-slider::-moz-range-thumb:hover { - box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5), inset 0 1px 2px rgba(255, 255, 255, 0.3); + box-shadow: + 0 4px 12px rgba(0, 0, 0, 0.5), + inset 0 1px 2px rgba(255, 255, 255, 0.3); transform: scale(1.1); } @@ -464,7 +477,9 @@ input:checked + .slider:before { font-weight: 500; font-family: inherit; cursor: pointer; - transition: background-color 0.2s, opacity 0.2s; + transition: + background-color 0.2s, + opacity 0.2s; } .btn:active { @@ -482,7 +497,8 @@ input:checked + .slider:before { color: var(--md-sys-color-primary); } -.btn-outline-s, .btn-text-s { +.btn-outline-s, +.btn-text-s { background-color: transparent; border: 1px solid var(--md-sys-color-outline-variant); color: var(--md-sys-color-primary); @@ -548,7 +564,8 @@ input:checked + .slider:before { transform: scale(0.9); } -.btn-icon-only-s i, .btn-icon-only-s svg { +.btn-icon-only-s i, +.btn-icon-only-s svg { width: 16px; height: 16px; } @@ -557,8 +574,11 @@ input:checked + .slider:before { animation: spin 1s linear infinite; } - @keyframes spin { - from { transform: rotate(0deg); } - to { transform: rotate(360deg); } + from { + transform: rotate(0deg); + } + to { + transform: rotate(360deg); + } } diff --git a/webui/src/components/BottomNav.vue b/webui/src/components/BottomNav.vue index 6816c41..e683607 100644 --- a/webui/src/components/BottomNav.vue +++ b/webui/src/components/BottomNav.vue @@ -1,111 +1,122 @@