mirror of
https://git.um-react.app/um/um-react.git
synced 2026-11-29 00:26:59 +00:00
Compare commits
40
Commits
v0.5.2
..
c8bb7d4430
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c8bb7d4430 | ||
|
|
6571dc5344 | ||
|
|
4d688af4ca | ||
|
|
b9c8d5b3cd | ||
|
|
79e5b45e6b | ||
|
|
ef4cd9c21e | ||
|
|
94eab8ecf6 | ||
|
|
d424837e66 | ||
|
|
b5fdc8ebbe | ||
|
|
cb5531e9e4 | ||
|
|
cc688b85bd | ||
|
|
d86323e38a | ||
|
|
4a7994df96 | ||
|
|
7a11d4f941 | ||
|
|
a9a937bc5e | ||
|
|
75d786c747 | ||
|
|
10e857a903 | ||
|
|
537391ed03 | ||
|
|
881aa5e44c | ||
|
|
757bbd2172 | ||
|
|
3f14a3acff | ||
|
|
b142c1ba34 | ||
|
|
4df197ac4d | ||
|
|
07d160c547 | ||
|
|
3059f495ab | ||
|
|
024847a45a | ||
|
|
a11caaae92 | ||
|
|
2e52c67533 | ||
|
|
56bb94b90c | ||
|
|
c1a5c6bde6 | ||
|
|
009804cbbd | ||
|
|
ff6fc467ae | ||
|
|
d514a87198 | ||
|
|
5c537ab8d9 | ||
|
|
48f10e8e30 | ||
|
|
dfac382cbd | ||
|
|
7b2558c585 | ||
|
|
fb52b0197c | ||
|
|
f49f629917 | ||
|
|
8093d30579 |
No files matched your search
@@ -7,7 +7,9 @@ body:
|
|||||||
value: |
|
value: |
|
||||||
### Windows 客户端
|
### Windows 客户端
|
||||||
|
|
||||||
目前 Windows 客户端仅支持 19.51 或更低版本下载的歌曲文件。
|
目前 Windows 客户端支持 19.57 至 22.76(目前最新版)下载的歌曲文件,但需要导入由 [qmpc-mmkv-cli](https://git.um-react.app/um/qmpc-mmkv/releases) 提取的密钥文件 `qmpc-mmkv-v1.mmkv`。
|
||||||
|
|
||||||
|
使用 19.51 或更低版本下载的歌曲文件无需密钥。
|
||||||
|
|
||||||
* [web.archive.org 镜像](https://web.archive.org/web/2023/https://dldir1v6.qq.com/music/clntupate/QQMusic_Setup_1951.exe)
|
* [web.archive.org 镜像](https://web.archive.org/web/2023/https://dldir1v6.qq.com/music/clntupate/QQMusic_Setup_1951.exe)
|
||||||
* [通过 Telegram 下载](https://t.me/um_lsr_ch/24)
|
* [通过 Telegram 下载](https://t.me/um_lsr_ch/24)
|
||||||
|
|||||||
@@ -4,8 +4,6 @@ on: [push]
|
|||||||
jobs:
|
jobs:
|
||||||
build:
|
build:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
env:
|
|
||||||
npm_config_registry: https://registry.npmmirror.com
|
|
||||||
steps:
|
steps:
|
||||||
- name: Check out repository code
|
- name: Check out repository code
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
@@ -26,6 +24,34 @@ jobs:
|
|||||||
with:
|
with:
|
||||||
name: site
|
name: site
|
||||||
path: dist/
|
path: dist/
|
||||||
|
- name: Create Release Package
|
||||||
|
if: startsWith(github.ref, 'refs/tags/')
|
||||||
|
run: |
|
||||||
|
VERSION=${GITHUB_REF#refs/tags/v}
|
||||||
|
mkdir release/
|
||||||
|
python3 -m zipfile -c "release/um-react-${VERSION}.zip" dist/.
|
||||||
|
cp win64/dist/*.zip "release/um-react-win64-${VERSION}.zip"
|
||||||
|
- name: Create Draft Release
|
||||||
|
if: startsWith(github.ref, 'refs/tags/')
|
||||||
|
uses: akkuman/gitea-release-action@v1
|
||||||
|
with:
|
||||||
|
draft: true
|
||||||
|
files: |
|
||||||
|
release/um-react-*.zip
|
||||||
|
body: |
|
||||||
|
上个版本:[v0.0.0](https://git.um-react.app/um/um-react/releases/tag/v0.0.0)
|
||||||
|
|
||||||
|
## 🐛 修正
|
||||||
|
|
||||||
|
- 修正内容
|
||||||
|
|
||||||
|
## ✨ 新增
|
||||||
|
|
||||||
|
- 新增内容
|
||||||
|
|
||||||
|
## 🔧 维护
|
||||||
|
|
||||||
|
- 维护内容
|
||||||
- name: Prepare for deployment
|
- name: Prepare for deployment
|
||||||
run: |
|
run: |
|
||||||
cp um-react.zip dist/"release-${GITHUB_SHA}.zip"
|
cp um-react.zip dist/"release-${GITHUB_SHA}.zip"
|
||||||
|
|||||||
@@ -1,3 +1 @@
|
|||||||
use-node-version=24.7.0
|
|
||||||
engine-strict=true
|
|
||||||
@unlock-music:registry=https://git.um-react.app/api/packages/um/npm/
|
@unlock-music:registry=https://git.um-react.app/api/packages/um/npm/
|
||||||
@@ -0,0 +1,156 @@
|
|||||||
|
# AGENTS.md — Unlock Music (um-react)
|
||||||
|
|
||||||
|
Browser SPA that decrypts locally selected encrypted music files (no upload). React rewrite of Unlock Music.
|
||||||
|
|
||||||
|
Hosted at [git.um-react.app/um/um-react](https://git.um-react.app/um/um-react). Crypto algorithms live in `@unlock-music/crypto` (WASM), **not** in this repo.
|
||||||
|
|
||||||
|
## Quick start
|
||||||
|
|
||||||
|
```sh
|
||||||
|
corepack prepare [email protected] --activate
|
||||||
|
pnpm i --frozen-lockfile
|
||||||
|
pnpm start # http://localhost:5173/
|
||||||
|
pnpm test # vitest run (also pre-push)
|
||||||
|
pnpm lint
|
||||||
|
pnpm build # tsc -p tsconfig.prod.json && vite build && write-version
|
||||||
|
```
|
||||||
|
|
||||||
|
- **Package manager:** pnpm `@12.14.0` (`engineStrict`)
|
||||||
|
- **Node:** `24.22.0` (`devEngines`)
|
||||||
|
- **TypeScript:** stay on **6.x** (do not bump to 7)
|
||||||
|
- **Registry:** `@unlock-music/*` from `git.um-react.app` (see `.npmrc`)
|
||||||
|
- App **does not support subdirectory deploy**
|
||||||
|
|
||||||
|
## Architecture
|
||||||
|
|
||||||
|
```
|
||||||
|
Main thread (UI / Redux / key import)
|
||||||
|
SelectFile → blob URL → fileListingSlice.processFile
|
||||||
|
→ keyLookup(production settings) → DecryptCommandOptions
|
||||||
|
→ DecryptionQueue → WorkerClientBus
|
||||||
|
Web Worker (decrypt-worker)
|
||||||
|
fetch(blobURI) → try Deciphers in order → blob URL result
|
||||||
|
```
|
||||||
|
|
||||||
|
- Blob URIs are passed via `postMessage`; worker loads bytes with `fetch`.
|
||||||
|
- Single worker today (`decrypt-worker/client.ts`); concurrency via `ConcurrentQueue` (default 5).
|
||||||
|
- Key DB / MMKV parsing runs on the **main thread** (`util/sqlite.ts`, `util/mmkv/`, `util/DatabaseKeyExtractor.ts`).
|
||||||
|
|
||||||
|
### Entry points
|
||||||
|
|
||||||
|
| Concern | Path |
|
||||||
|
| ---------------------- | ----------------------------------------------------- |
|
||||||
|
| Bootstrap | `src/main.tsx` → `src/components/AppRoot.tsx` |
|
||||||
|
| Redux store | `src/store.ts` (`fileListing` + `settings` only) |
|
||||||
|
| Typed hooks | `src/hooks.ts` |
|
||||||
|
| Decrypt queue UI | `src/features/file-listing/` |
|
||||||
|
| Settings + persist | `src/features/settings/` |
|
||||||
|
| Worker client / server | `src/decrypt-worker/client.ts`, `worker.ts` |
|
||||||
|
| Decipher registry | `src/decrypt-worker/Deciphers.ts` (**order matters**) |
|
||||||
|
| Path alias | `~/*` → `src/*` |
|
||||||
|
|
||||||
|
### Routes (`AppRoot`)
|
||||||
|
|
||||||
|
| Path | Tab |
|
||||||
|
| -------------- | -------------------------- |
|
||||||
|
| `/` | Main unlock UI |
|
||||||
|
| `/settings/*` | Settings (`SETTINGS_TABS`) |
|
||||||
|
| `/questions/*` | FAQ (`FAQ_PAGES`) |
|
||||||
|
|
||||||
|
## `src/` layout
|
||||||
|
|
||||||
|
| Dir | Role |
|
||||||
|
| ----------------- | --------------------------------------------------------------------- |
|
||||||
|
| `components/` | Shared UI (AppRoot, Dialog, key import, downloads) — **no `App.tsx`** |
|
||||||
|
| `tabs/` | Top-level route shells |
|
||||||
|
| `features/` | Domain modules (see below) |
|
||||||
|
| `decrypt-worker/` | Worker + `decipher/*` + worker parsers |
|
||||||
|
| `faq/` | FAQ pages + registry |
|
||||||
|
| `util/` | Queues, worker bus, SQLite/MMKV, downloads, helpers |
|
||||||
|
| `test-utils/` | Vitest setup + `renderWithProviders` |
|
||||||
|
|
||||||
|
### Features
|
||||||
|
|
||||||
|
| Folder | Purpose |
|
||||||
|
| --------------- | ------------------------------------------------------------------ |
|
||||||
|
| `settings/` | Staging/production slice, persistence, general panel, tab registry |
|
||||||
|
| `file-listing/` | Decrypt queue + `processFile` thunk |
|
||||||
|
| `nav/` | Settings/FAQ nested nav |
|
||||||
|
| `qmc/` | QQ Music QMCv2 keys |
|
||||||
|
| `kwm/` | Kuwo KWMv2 keys |
|
||||||
|
| `kugou/` | Kugou KGG/KGM keys |
|
||||||
|
| `qtfm/` | QingTing FM device key |
|
||||||
|
|
||||||
|
Provider features typically contain: `types.ts`, `importKeys.ts`, `keyLookup.ts`, `panel/`, `instructions/`, `__tests__/`. They do **not** own Redux slices — they plug into `settingsSlice`.
|
||||||
|
|
||||||
|
## Settings model (critical)
|
||||||
|
|
||||||
|
- **`staging`**: editable UI state (key rows with `id`).
|
||||||
|
- **`production`**: committed shape used for decrypt + `localStorage` (`um-react-settings`).
|
||||||
|
- Decrypt **`keyLookup` selectors always read `production`**. Dirty settings must be committed (保存) before decrypt sees them.
|
||||||
|
- Persist: `features/settings/persistSettings.ts` (debounced save; `mergeSettings` on load).
|
||||||
|
- Key-list CRUD: `createKeyListReducers.ts` for `qmc2` / `kwm2` / `kugou`.
|
||||||
|
|
||||||
|
**Route id ≠ Redux key** (do not “fix” rename persist keys):
|
||||||
|
|
||||||
|
| Route | Redux / persist |
|
||||||
|
| ------ | --------------- |
|
||||||
|
| `qmc` | `qmc2` |
|
||||||
|
| `kwm` | `kwm2` |
|
||||||
|
| `kgg` | `kugou` |
|
||||||
|
| `qtfm` | `qtfm` |
|
||||||
|
|
||||||
|
## Adding / changing a music format
|
||||||
|
|
||||||
|
1. Prefer implementing crypto in `@unlock-music/crypto` / `lib_um_crypto_rust` (see `docs/develop-with-um_crypto.zh.md`).
|
||||||
|
2. Add `src/decrypt-worker/decipher/YourFormat.ts` implementing `DecipherInstance`.
|
||||||
|
3. Register factory in `Deciphers.ts` at the right priority (fixed header → footer → expensive full-file last).
|
||||||
|
4. If user keys needed: extend `DecryptCommandOptions`; add `features/<name>/` + wire `settingsSlice`, `persistSettings.mergeSettings`, `settingsTabs.tsx`.
|
||||||
|
5. If header parse needed before decrypt: worker action in `actions.ts` / `worker.ts` / `worker/*`, call from `fileListingSlice.processFile`.
|
||||||
|
6. Tests + README supported-formats / FAQ as appropriate.
|
||||||
|
|
||||||
|
## UI & copy
|
||||||
|
|
||||||
|
- Tailwind CSS 4 + **DaisyUI 5** (`src/App.css`). Prefer existing patterns (`btn`, `modal`, `list`, `alert`, …).
|
||||||
|
- Shared: `Dialog`, `KeyListContainer`, `ImportSecretModal`, `HelpText/*`, `react-icons`.
|
||||||
|
- **No i18n library** — user-facing strings are hard-coded Simplified Chinese (some Traditional phrasing exists; match nearby copy).
|
||||||
|
- Import from `react-router` (v8), not `react-router-dom`.
|
||||||
|
|
||||||
|
## Testing
|
||||||
|
|
||||||
|
- Vitest + jsdom; `globals: true`; setup `src/test-utils/setup-jest.ts` (mocks `Worker`, `matchMedia`).
|
||||||
|
- Colocate under `__tests__/` as `*.test.ts(x)`.
|
||||||
|
- Components: `renderWithProviders` from `src/test-utils/test-helper.tsx`.
|
||||||
|
- Selectors/converters: mini-store or `setupStore({ preloadedState })`.
|
||||||
|
- Contribution rule: coverage must not drop below main branch; Prettier + ESLint clean before PR.
|
||||||
|
- Hooks: `pre-commit` → lint-staged; `pre-push` → `pnpm test`.
|
||||||
|
|
||||||
|
## Tooling gotchas
|
||||||
|
|
||||||
|
| Topic | Note |
|
||||||
|
| ----------------- | ---------------------------------------------------------------------------------------------------- |
|
||||||
|
| WASM | `vite-plugin-wasm`; exclude `@unlock-music/crypto` from `optimizeDeps`; worker awaits crypto `ready` |
|
||||||
|
| Local crypto link | `LIB_UM_WASM_LOADER_DIR` / pnpm link; Vite `server.fs.allow` |
|
||||||
|
| sql.js | Patched via `pnpm-workspace.yaml` → `patches/sql.js.patch`; alias `@sql-wasm` |
|
||||||
|
| PWA | `vite-plugin-pwa`; `src/dummy.mjs` aliases `module` for Workbox |
|
||||||
|
| Prettier | singleQuote, printWidth 120 |
|
||||||
|
| Unused vars | prefix with `_` (ESLint) |
|
||||||
|
| CI | `.gitea/workflows/build.yaml` (build, zip, win64, Netlify deploy) |
|
||||||
|
|
||||||
|
## Docs to read first
|
||||||
|
|
||||||
|
| Doc | When |
|
||||||
|
| ------------------------------------------ | ------------------------------------------- |
|
||||||
|
| `README.MD` | Formats, architecture summary, contribution |
|
||||||
|
| `docs/getting-started.zh.md` | Install / build / pack |
|
||||||
|
| `docs/develop-with-um_crypto.zh.md` | Crypto SDK local development |
|
||||||
|
| `docs/faq_zh-hans.md` / `docs/adb_dump.md` | User FAQ / ADB key dump |
|
||||||
|
|
||||||
|
## Agent working rules for this repo
|
||||||
|
|
||||||
|
- Prefer **surgical edits**; match existing DaisyUI/Tailwind and feature folder patterns.
|
||||||
|
- Do not rename `kugou` persist key or casually change staging↔production semantics.
|
||||||
|
- Do not move heavy crypto into the main thread; keep decryption in the worker.
|
||||||
|
- Do not invent an i18n framework for one-off strings.
|
||||||
|
- Run `pnpm test` / `pnpm lint` after behavioral changes when practical.
|
||||||
|
- Crypto algorithm work usually belongs upstream in `@unlock-music/crypto`, not duplicated here.
|
||||||
+2
-2
@@ -1,4 +1,4 @@
|
|||||||
FROM node:22-slim AS build
|
FROM node:24.22.0-slim AS build
|
||||||
ENV PNPM_HOME="/p"
|
ENV PNPM_HOME="/p"
|
||||||
ENV PATH="$PNPM_HOME:$PATH"
|
ENV PATH="$PNPM_HOME:$PATH"
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
@@ -9,7 +9,7 @@ RUN corepack enable pnpm \
|
|||||||
&& apt-get clean \
|
&& apt-get clean \
|
||||||
&& rm -rf /var/lib/apt/lists/*
|
&& rm -rf /var/lib/apt/lists/*
|
||||||
|
|
||||||
COPY package.json pnpm-lock.yaml .npmrc ./
|
COPY package.json pnpm-lock.yaml pnpm-workspace.yaml .npmrc ./
|
||||||
RUN pnpm exec true
|
RUN pnpm exec true
|
||||||
COPY . .
|
COPY . .
|
||||||
RUN pnpm install --frozen-lockfile
|
RUN pnpm install --frozen-lockfile
|
||||||
|
|||||||
@@ -10,7 +10,7 @@
|
|||||||
- CI 自动构建已经部署,可以在 [Actions][um-react-actions] 寻找对应的<ruby>构建产物<rp>(</rp><rt>Artifact</rt><rp>)</rp> </ruby>下载。
|
- CI 自动构建已经部署,可以在 [Actions][um-react-actions] 寻找对应的<ruby>构建产物<rp>(</rp><rt>Artifact</rt><rp>)</rp> </ruby>下载。
|
||||||
- [常见问题参考](./docs/faq_zh-hans.md)
|
- [常见问题参考](./docs/faq_zh-hans.md)
|
||||||
|
|
||||||
> **WARNING**
|
> [!WARNING]
|
||||||
> 在本站 fork 不会起到备份的作用,只会浪费服务器储存空间。如无必要请勿 fork 该仓库。
|
> 在本站 fork 不会起到备份的作用,只会浪费服务器储存空间。如无必要请勿 fork 该仓库。
|
||||||
|
|
||||||
[授权协议]: https://git.um-react.app/um/um-react/src/branch/main/LICENSE
|
[授权协议]: https://git.um-react.app/um/um-react/src/branch/main/LICENSE
|
||||||
@@ -19,7 +19,8 @@
|
|||||||
[`@unlock_music_chat`]: https://t.me/unlock_music_chat
|
[`@unlock_music_chat`]: https://t.me/unlock_music_chat
|
||||||
[um-react-actions]: https://git.um-react.app/um/um-react/actions?workflow=build.yaml
|
[um-react-actions]: https://git.um-react.app/um/um-react/actions?workflow=build.yaml
|
||||||
|
|
||||||
⚠️ 手机端浏览器支持有限,请使用最新版本的 Chrome 或 Firefox 官方浏览器。
|
> [!TIP]
|
||||||
|
> 手机端浏览器支持有限,请使用最新版本的 Chrome 或 Firefox 官方浏览器。
|
||||||
|
|
||||||
## 支持的格式
|
## 支持的格式
|
||||||
|
|
||||||
@@ -31,27 +32,32 @@
|
|||||||
- Mac 客户端 (`.mflach` 等) [^qm-key-mac]
|
- Mac 客户端 (`.mflach` 等) [^qm-key-mac]
|
||||||
- [x] 网易云音乐 (`.ncm`)
|
- [x] 网易云音乐 (`.ncm`)
|
||||||
- [x] 虾米音乐 (`.xm`)
|
- [x] 虾米音乐 (`.xm`)
|
||||||
- [x] 酷我音乐 (`.kwm`)
|
- [x] 酷我音乐 (`.kwm` / `.mflac`) [^kuwo-key-android]
|
||||||
- [x] 酷狗音乐 (`.kgm` / `.vpr` / `.kgg`)
|
- [x] 酷狗音乐 (`.kgm` / `.vpr` / `.kgg`)
|
||||||
- PC / 安卓客户端的 `kgg` 文件需要提供密钥数据库。
|
- PC / 安卓客户端[^kgg-android]的 `kgg` 文件需要提供密钥数据库。
|
||||||
- [x] 喜马拉雅 (`.x2m` / `.x3m` / `.xm`)
|
- [x] 喜马拉雅 (`.x2m` / `.x3m` / `.xm`)
|
||||||
- [x] 咪咕音乐格式 (`.mg3d`)
|
- [x] 咪咕音乐格式 (`.mg3d`)
|
||||||
- [x] 蜻蜓 FM (`.qta`)
|
- [x] 蜻蜓 FM (`.qta`)
|
||||||
- [ ] ~~<ruby>QQ 音乐海外版<rt>JOOX Music</rt></ruby> (`.ofl_en`)~~
|
- 需要提取设备 ID。
|
||||||
|
|
||||||
[^qm-key-pc]: PC 客户端仅支持 v19.43 或更低版本。
|
[^qm-key-pc]: QQ 音乐的 PC 客户端(v19.57 至 v22.76)需要导入由 [qmpc-mmkv-cli](https://git.um-react.app/um/qmpc-mmkv/releases) 提取的密钥文件 `qmpc-mmkv-v1.mmkv`。
|
||||||
|
|
||||||
[^qm-key-android]: 需要获取超级管理员权限后提取密钥数据库,并导入后使用。
|
[^qm-key-android]: QQ 音乐的安卓客户端支持需要获取超级管理员权限后提取密钥数据库并导入后使用。
|
||||||
|
|
||||||
[^qm-key-ios]: 需要越狱获取密钥数据库,或对设备进行完整备份后提取密钥数据库,并导入后使用。
|
[^qm-key-ios]: QQ 音乐 iOS 客户端支持需要越狱获取密钥数据库,或对设备进行完整备份后提取密钥数据库并导入后使用。
|
||||||
|
|
||||||
[^qm-key-mac]: 需要导入密钥数据库。
|
[^qm-key-mac]: QQ 音乐 Mac 客户端支持需要导入密钥数据库,目前支持 v8.8.0 及 v10.7.1。
|
||||||
|
|
||||||
|
[^kgg-android]: 酷狗音乐的安卓客户端支持需要获取超级管理员权限后提取密钥数据库并导入后使用。
|
||||||
|
|
||||||
|
[^kuwo-key-android]: 酷我音乐的安卓客户端下载的 AI 升频文件需要获取超级管理员权限后提取密钥数据库并导入后使用。
|
||||||
|
|
||||||
## 错误报告
|
## 错误报告
|
||||||
|
|
||||||
有不支持的格式?请提交样本(加密文件)与客户端信息版本信息(如系统版本、下载渠道),或一并上传其安装包到[仓库的问题追踪区][project-issues]。
|
有不支持的格式?请提交样本(加密文件)与客户端信息版本信息(如系统版本、下载渠道),或一并上传其安装包到[仓库的问题追踪区][project-issues]。
|
||||||
|
|
||||||
⚠️ 如果文件太大,请上传到不需要登入下载的网盘,如 [mega.nz](https://mega.nz)、[OneDrive](https://www.onedrive.com/) 等。
|
> [!NOTE]
|
||||||
|
> 如果文件太大,请上传到不需要登入下载的网盘,如 [mega.nz](https://mega.nz)、[OneDrive](https://www.onedrive.com/) 等。
|
||||||
|
|
||||||
遇到解密出错的情况,请一并携带错误信息(诊断信息)并简单描述错误的重现过程。
|
遇到解密出错的情况,请一并携带错误信息(诊断信息)并简单描述错误的重现过程。
|
||||||
|
|
||||||
@@ -59,7 +65,7 @@
|
|||||||
|
|
||||||
[project-issues]: https://git.um-react.app/um/um-react/issues/new
|
[project-issues]: https://git.um-react.app/um/um-react/issues/new
|
||||||
|
|
||||||
## 使用 Docker 构建、部署 (Linux)
|
## 使用 Docker 构建、部署
|
||||||
|
|
||||||
首先克隆仓库并进入目录:
|
首先克隆仓库并进入目录:
|
||||||
|
|
||||||
@@ -86,13 +92,30 @@ docker run -d -p 8080:80 --name um-react um-react
|
|||||||
|
|
||||||
然后访问 `http://localhost:8080` 即可。
|
然后访问 `http://localhost:8080` 即可。
|
||||||
|
|
||||||
|
## 部署到子目录
|
||||||
|
|
||||||
|
> [!NOTE]
|
||||||
|
> 官方 Docker 镜像与默认构建产物按站点**根路径**(`/`)部署,不支持部署到子目录下。
|
||||||
|
|
||||||
|
若要部署到子目录(例如 `https://example.com/um-react/`),你需要重新使用 Vite 进行构建,并指定 `--base` 参数(路径以 `/` 开头、以 `/` 结尾)。
|
||||||
|
|
||||||
|
以部署到 `https://example.com/um-react/` 为例:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
pnpm exec vite build --base=/um-react/
|
||||||
|
pnpm build:finalize
|
||||||
|
```
|
||||||
|
|
||||||
|
部署时,服务器还需把该子目录下的所有前端路由回退到对应的 `index.html`(SPA)。
|
||||||
|
|
||||||
## 开发相关
|
## 开发相关
|
||||||
|
|
||||||
从源码运行或编译生产版本,请参考文档「[新手上路](./docs/getting-started.zh.md)」。
|
从源码运行或编译生产版本,请参考文档「[新手上路](./docs/getting-started.zh.md)」。
|
||||||
|
|
||||||
### 解密库开发
|
### 解密库开发
|
||||||
|
|
||||||
⚠️ 如果只是进行前端方面的更改,你可以跳过该节。
|
> [!TIP]
|
||||||
|
> 如果只是进行前端方面的更改,你可以跳过该节。
|
||||||
|
|
||||||
请参考文档「[面向 `@unlock-music/crypto` 开发](./docs/develop-with-um_crypto.zh.md)」。
|
请参考文档「[面向 `@unlock-music/crypto` 开发](./docs/develop-with-um_crypto.zh.md)」。
|
||||||
|
|
||||||
|
|||||||
+13
-1
@@ -10,7 +10,7 @@
|
|||||||
|
|
||||||
#### 2、检查您的平台。
|
#### 2、检查您的平台。
|
||||||
|
|
||||||
日前,<mark>仅 Windows 客户端 v19.43 或以下版本</mark>下载的歌曲无需密钥,其余平台的官方正式版本均需要提取密钥。
|
日前,Windows 客户端 <mark>v19.57 至 v22.76</mark>(目前最新版)下载的歌曲需要导入由 [qmpc-mmkv-cli](https://git.um-react.app/um/qmpc-mmkv/releases) 提取的密钥文件 `qmpc-mmkv-v1.mmkv`;<mark>v19.51 或更低版本</mark>下载的歌曲无需密钥。其余平台的官方正式版本均需要提取密钥。
|
||||||
|
|
||||||
> iOS 用户提取歌曲困难,建议换用电脑操作;Android 用户提取密钥需要 root,也建议用电脑操作。
|
> iOS 用户提取歌曲困难,建议换用电脑操作;Android 用户提取密钥需要 root,也建议用电脑操作。
|
||||||
|
|
||||||
@@ -71,6 +71,18 @@
|
|||||||
- 雷电模拟器可以在「模拟器设置」 → 「其他设置」中启用 root 特权。
|
- 雷电模拟器可以在「模拟器设置」 → 「其他设置」中启用 root 特权。
|
||||||

|

|
||||||
|
|
||||||
|
### 批量下载约十首后失败 / 无法全部下载
|
||||||
|
|
||||||
|
Chromium 系浏览器会限制页面在短时间内通过程序触发的**多个**文件下载(常见表现为大约十个文件后静默中断,或提示「此网站正在尝试下载多个文件」)。
|
||||||
|
|
||||||
|
本站的「下载全部」会按「设定 → 通用设置 → 批量下载」中勾选的顺序尝试:
|
||||||
|
|
||||||
|
1. 选择输出目录,直接写入文件(推荐,Chrome / Edge)
|
||||||
|
2. 流式生成单个 ZIP 并保存
|
||||||
|
3. 在内存中生成 ZIP 后触发一次下载(兼容性最好)
|
||||||
|
|
||||||
|
若全部失败会弹出提示。大批量转换也可使用 [命令行版本](https://git.um-react.app/um/cli)。
|
||||||
|
|
||||||
### Via 等浏览器无法正常解密/下载
|
### Via 等浏览器无法正常解密/下载
|
||||||
|
|
||||||
⚠️ 手机端浏览器支持有限,请使用最新版本的 Chrome 或 Firefox 官方浏览器。
|
⚠️ 手机端浏览器支持有限,请使用最新版本的 Chrome 或 Firefox 官方浏览器。
|
||||||
|
|||||||
@@ -4,8 +4,8 @@
|
|||||||
|
|
||||||
## 安装依赖
|
## 安装依赖
|
||||||
|
|
||||||
- 安装 Node v16.17 或更高,推荐当前最新的 Node LTS 版本。
|
- 安装 Node 24.22.0;pnpm 也会根据 `package.json` 中的 `devEngines.runtime` 自动获取该版本。
|
||||||
- 安装/激活 `pnpm` [^1]:`corepack prepare pnpm@latest --activate`
|
- 安装/激活项目指定的 `pnpm` [^1]:`corepack prepare pnpm@12.14.0 --activate`
|
||||||
- 安装软件依赖:`pnpm i --frozen-lockfile`
|
- 安装软件依赖:`pnpm i --frozen-lockfile`
|
||||||
|
|
||||||
[^1]: 参考 pnpm 说明「[使用 Corepack 安装](https://pnpm.io/zh/installation#使用-corepack-安装)」。
|
[^1]: 参考 pnpm 说明「[使用 Corepack 安装](https://pnpm.io/zh/installation#使用-corepack-安装)」。
|
||||||
@@ -34,6 +34,10 @@ pnpm build
|
|||||||
|
|
||||||
[vite-preview-url]: http://localhost:4173/
|
[vite-preview-url]: http://localhost:4173/
|
||||||
|
|
||||||
|
### TypeScript 工具链
|
||||||
|
|
||||||
|
编译和 ESLint 统一使用 TypeScript 6.x,暂不升级到 TypeScript 7。
|
||||||
|
|
||||||
## 打包 `.zip`
|
## 打包 `.zip`
|
||||||
|
|
||||||
建议在 Linux 环境下执行,可参考 `.drone.yml` CI 文件。
|
建议在 Linux 环境下执行,可参考 `.drone.yml` CI 文件。
|
||||||
|
|||||||
+14
-3
@@ -1,15 +1,16 @@
|
|||||||
import eslint from '@eslint/js';
|
import eslint from '@eslint/js';
|
||||||
|
import { defineConfig } from 'eslint/config';
|
||||||
import tseslint from 'typescript-eslint';
|
import tseslint from 'typescript-eslint';
|
||||||
import reactRefresh from 'eslint-plugin-react-refresh';
|
import reactRefresh from 'eslint-plugin-react-refresh';
|
||||||
import reactHooks from 'eslint-plugin-react-hooks';
|
import reactHooks from 'eslint-plugin-react-hooks';
|
||||||
import eslintConfigPrettier from 'eslint-config-prettier/flat';
|
import eslintConfigPrettier from 'eslint-config-prettier/flat';
|
||||||
import globals from 'globals';
|
import globals from 'globals';
|
||||||
|
|
||||||
export default tseslint.config(
|
export default defineConfig(
|
||||||
eslint.configs.recommended,
|
eslint.configs.recommended,
|
||||||
tseslint.configs.recommended,
|
tseslint.configs.recommendedTypeChecked,
|
||||||
reactRefresh.configs.recommended,
|
reactRefresh.configs.recommended,
|
||||||
reactHooks.configs['recommended-latest'],
|
reactHooks.configs.flat.recommended,
|
||||||
eslintConfigPrettier,
|
eslintConfigPrettier,
|
||||||
|
|
||||||
{
|
{
|
||||||
@@ -40,4 +41,14 @@ export default tseslint.config(
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
|
{
|
||||||
|
languageOptions: {
|
||||||
|
parserOptions: {
|
||||||
|
projectService: {
|
||||||
|
allowDefaultProject: ['*.mjs', 'src/*.mjs', 'scripts/*.mjs'],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
);
|
);
|
||||||
Generated
-11870
File diff suppressed because it is too large.
Load diff
+60
-64
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"name": "um-react",
|
"name": "um-react",
|
||||||
"private": true,
|
"private": true,
|
||||||
"version": "0.5.2",
|
"version": "0.6.2",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"start": "vite",
|
"start": "vite",
|
||||||
@@ -17,63 +17,66 @@
|
|||||||
"prepare": "simple-git-hooks"
|
"prepare": "simple-git-hooks"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@reduxjs/toolkit": "^2.9.0",
|
"@reduxjs/toolkit": "^2.13.0",
|
||||||
"@unlock-music/crypto": "^0.1.12",
|
"@unlock-music/crypto": "^0.1.12",
|
||||||
"classnames": "^2.5.1",
|
"classnames": "^2.5.1",
|
||||||
"nanoid": "^5.1.5",
|
"fflate": "^0.8.3",
|
||||||
|
"idb-keyval": "^6.3.0",
|
||||||
|
"nanoid": "^6.0.2",
|
||||||
"radash": "^12.1.1",
|
"radash": "^12.1.1",
|
||||||
"react": "^19.1.1",
|
"react": "^19.3.1",
|
||||||
"react-dom": "^19.1.1",
|
"react-dom": "^19.3.1",
|
||||||
"react-dropzone": "^14.3.8",
|
"react-dropzone": "^20.1.4",
|
||||||
"react-icons": "^5.5.0",
|
"react-icons": "^5.7.0",
|
||||||
"react-redux": "^9.2.0",
|
"react-redux": "^9.3.0",
|
||||||
"react-router": "^7.8.2",
|
"react-router": "^8.5.0",
|
||||||
"react-syntax-highlighter": "^15.6.6",
|
"react-syntax-highlighter": "^16.1.2",
|
||||||
"react-toastify": "^11.0.5",
|
"react-toastify": "^11.1.0",
|
||||||
"sql.js": "^1.13.0"
|
"sql.js": "^1.15.1"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@eslint/js": "^9.35.0",
|
"@eslint/js": "^10.0.1",
|
||||||
"@rollup/plugin-replace": "^6.0.2",
|
"@rollup/plugin-replace": "^6.0.3",
|
||||||
"@tailwindcss/vite": "^4.1.13",
|
"@tailwindcss/vite": "^4.3.3",
|
||||||
"@testing-library/jest-dom": "^6.8.0",
|
"@testing-library/jest-dom": "^7.0.1",
|
||||||
"@testing-library/react": "^16.3.0",
|
"@testing-library/react": "^16.3.3",
|
||||||
"@testing-library/user-event": "^14.6.1",
|
"@testing-library/user-event": "^14.6.8",
|
||||||
"@types/node": "^24.3.1",
|
"@types/node": "^26.6.5",
|
||||||
"@types/react": "^19.1.12",
|
"@types/react": "^19.3.0",
|
||||||
"@types/react-dom": "^19.1.9",
|
"@types/react-dom": "^19.3.0",
|
||||||
"@types/react-syntax-highlighter": "^15.5.13",
|
"@types/react-syntax-highlighter": "^15.5.13",
|
||||||
"@types/sql.js": "^1.4.9",
|
"@types/sql.js": "^1.4.11",
|
||||||
"@types/wicg-file-system-access": "^2023.10.6",
|
"@types/tar-stream": "^3.1.5",
|
||||||
"@typescript-eslint/eslint-plugin": "^8.42.0",
|
"@types/wicg-file-system-access": "^2023.10.7",
|
||||||
"@typescript-eslint/parser": "^8.42.0",
|
"@typescript-eslint/eslint-plugin": "^8.72.0",
|
||||||
"@vitejs/plugin-react": "^5.0.2",
|
"@typescript-eslint/parser": "^8.72.0",
|
||||||
"@vitest/coverage-v8": "^3.2.4",
|
"@vitejs/plugin-react": "^6.1.2",
|
||||||
"@vitest/ui": "^3.2.4",
|
"@vitest/coverage-v8": "^5.0.5",
|
||||||
"daisyui": "^5.1.8",
|
"@vitest/ui": "^5.0.5",
|
||||||
"eslint": "^9.35.0",
|
"daisyui": "^5.7.50",
|
||||||
|
"eslint": "^10.13.0",
|
||||||
"eslint-config-prettier": "^10.1.8",
|
"eslint-config-prettier": "^10.1.8",
|
||||||
"eslint-plugin-react-hooks": "^5.2.0",
|
"eslint-plugin-react-hooks": "^7.1.1",
|
||||||
"eslint-plugin-react-refresh": "^0.4.20",
|
"eslint-plugin-react-refresh": "^0.5.7",
|
||||||
"globals": "^16.3.0",
|
"globals": "^17.13.0",
|
||||||
"husky": "^9.1.7",
|
"husky": "^9.1.7",
|
||||||
"jsdom": "^26.1.0",
|
"jsdom": "^30.1.3",
|
||||||
"lint-staged": "^16.1.6",
|
"lint-staged": "^17.6.0",
|
||||||
"prettier": "^3.6.2",
|
"prettier": "^3.9.10",
|
||||||
"rollup": "^4.50.1",
|
"rollup": "^4.64.12",
|
||||||
"sass": "^1.92.1",
|
"sass": "^1.105.2",
|
||||||
"simple-git-hooks": "^2.13.1",
|
"simple-git-hooks": "^2.14.0",
|
||||||
"tailwindcss": "^4.1.13",
|
"tailwindcss": "^4.3.3",
|
||||||
"terser": "^5.44.0",
|
"tar-stream": "^3.2.2",
|
||||||
"typescript": "^5.9.2",
|
"terser": "^5.51.2",
|
||||||
"typescript-eslint": "^8.42.0",
|
"typescript": "^6.0.3",
|
||||||
"vite": "^7.1.5",
|
"typescript-eslint": "^8.72.0",
|
||||||
"vite-plugin-pwa": "^1.0.3",
|
"vite": "^8.3.4",
|
||||||
"vite-plugin-top-level-await": "^1.6.0",
|
"vite-plugin-pwa": "^2.0.0",
|
||||||
"vite-plugin-wasm": "^3.5.0",
|
"vite-plugin-wasm": "^3.6.0",
|
||||||
"vitest": "^3.2.4",
|
"vitest": "^5.0.5",
|
||||||
"workbox-build": "^7.3.0",
|
"workbox-build": "^7.4.1",
|
||||||
"workbox-window": "^7.3.0"
|
"workbox-window": "^7.4.1"
|
||||||
},
|
},
|
||||||
"lint-staged": {
|
"lint-staged": {
|
||||||
"*": "prettier --write --ignore-unknown",
|
"*": "prettier --write --ignore-unknown",
|
||||||
@@ -88,19 +91,12 @@
|
|||||||
"printWidth": 120,
|
"printWidth": 120,
|
||||||
"tabWidth": 2
|
"tabWidth": 2
|
||||||
},
|
},
|
||||||
"pnpm": {
|
"devEngines": {
|
||||||
"patchedDependencies": {
|
"runtime": {
|
||||||
"sql.js": "patches/sql.js.patch"
|
"name": "node",
|
||||||
},
|
"version": "24.22.0",
|
||||||
"overrides": {
|
"onFail": "download"
|
||||||
"sourcemap-codec": "npm:@jridgewell/[email protected]"
|
}
|
||||||
},
|
|
||||||
"onlyBuiltDependencies": [
|
|
||||||
"@swc/core",
|
|
||||||
"@tailwindcss/oxide",
|
|
||||||
"esbuild",
|
|
||||||
"simple-git-hooks"
|
|
||||||
]
|
|
||||||
},
|
},
|
||||||
"packageManager": "pnpm@10.15.1"
|
"packageManager": "pnpm@12.14.0"
|
||||||
}
|
}
|
||||||
Generated
+3551
-3702
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,16 @@
|
|||||||
|
engineStrict: true
|
||||||
|
|
||||||
|
patchedDependencies:
|
||||||
|
sql.js: patches/sql.js.patch
|
||||||
|
|
||||||
|
overrides:
|
||||||
|
sourcemap-codec: npm:@jridgewell/[email protected]
|
||||||
|
|
||||||
|
allowBuilds:
|
||||||
|
'@parcel/watcher': false
|
||||||
|
'@swc/core': true
|
||||||
|
'@tailwindcss/oxide': true
|
||||||
|
esbuild: true
|
||||||
|
simple-git-hooks: true
|
||||||
|
|
||||||
|
minimumReleaseAge: 0
|
||||||
@@ -1,7 +1,9 @@
|
|||||||
import { minify } from 'terser';
|
import { minify } from 'terser';
|
||||||
import { readFileSync, writeFileSync, readdirSync } from 'fs';
|
import { readFileSync, writeFileSync, readdirSync } from 'fs';
|
||||||
|
|
||||||
for (const file of readdirSync('dist/assets')) {
|
const assetsDir = 'dist/um-react.assets';
|
||||||
|
|
||||||
|
for (const file of readdirSync(assetsDir)) {
|
||||||
if (!/\.(mjs|js)$/.test(file)) {
|
if (!/\.(mjs|js)$/.test(file)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@@ -9,11 +11,11 @@ for (const file of readdirSync('dist/assets')) {
|
|||||||
console.log(`minifying ${file}...`);
|
console.log(`minifying ${file}...`);
|
||||||
const isModule = /\.mjs$/.test(file);
|
const isModule = /\.mjs$/.test(file);
|
||||||
|
|
||||||
const output = await minify(readFileSync(`dist/assets/${file}`, 'utf-8'), {
|
const output = await minify(readFileSync(`${assetsDir}/${file}`, 'utf-8'), {
|
||||||
compress: true,
|
compress: true,
|
||||||
mangle: true,
|
mangle: true,
|
||||||
module: isModule,
|
module: isModule,
|
||||||
});
|
});
|
||||||
|
|
||||||
writeFileSync(`dist/assets/${file}`, output.code);
|
writeFileSync(`${assetsDir}/${file}`, output.code);
|
||||||
}
|
}
|
||||||
@@ -1,19 +1,28 @@
|
|||||||
import { renderWithProviders, screen, waitFor } from '~/test-utils/test-helper';
|
import { act, renderWithProviders, screen } from '~/test-utils/test-helper';
|
||||||
import { AppRoot } from '~/components/AppRoot';
|
import { AppRoot } from '~/components/AppRoot';
|
||||||
|
|
||||||
vi.mock('../decrypt-worker/client', () => {
|
// Must match the dynamic import specifier used by browserCrypto (`~/decrypt-worker/client`).
|
||||||
|
// Plain functions: vitest `mockReset` clears vi.fn mockResolvedValue between tests.
|
||||||
|
vi.mock('~/decrypt-worker/client', () => {
|
||||||
return {
|
return {
|
||||||
workerClientBus: {
|
workerClientBus: {
|
||||||
request: vi.fn().mockResolvedValue('dummy'),
|
request: () => Promise.resolve('dummy'),
|
||||||
|
},
|
||||||
|
decryptionQueue: {
|
||||||
|
add: () => Promise.resolve({ decrypted: 'blob://dummy', ext: 'flac' }),
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
test('should be able to render App', async () => {
|
test('should be able to render App', async () => {
|
||||||
renderWithProviders(<AppRoot />);
|
await act(async () => {
|
||||||
|
renderWithProviders(<AppRoot />);
|
||||||
|
// Flush Suspense retry after platform.init() (dynamic import) settles.
|
||||||
|
await Promise.resolve();
|
||||||
|
});
|
||||||
|
|
||||||
// Should eventually load sdk version
|
// Platform Suspense gate + SDK version fetch
|
||||||
await waitFor(() => screen.getByTestId('sdk-version'));
|
expect(await screen.findByTestId('sdk-version')).toBeInTheDocument();
|
||||||
|
|
||||||
// Quick sanity check of known strings.
|
// Quick sanity check of known strings.
|
||||||
expect(screen.getByText(/音乐解锁/i)).toBeInTheDocument();
|
expect(screen.getByText(/音乐解锁/i)).toBeInTheDocument();
|
||||||
|
|||||||
@@ -9,10 +9,10 @@ export function RootExplorerGuide() {
|
|||||||
<div className="flex flex-col items-start gap-4 @md:flex-row">
|
<div className="flex flex-col items-start gap-4 @md:flex-row">
|
||||||
<div>
|
<div>
|
||||||
<Header5 className="[&]:mt-0 [&]:pt-0">Amaze 文件浏览器</Header5>
|
<Header5 className="[&]:mt-0 [&]:pt-0">Amaze 文件浏览器</Header5>
|
||||||
<ul className="ml-2 list-disc list-inside">
|
<ul className="ml-2 list-disc">
|
||||||
<li>
|
<li>
|
||||||
<div className="inline-flex items-center gap-1">
|
<div className="inline-flex items-center flex-wrap">
|
||||||
点触主界面左上角的 <FiMenu /> 打开侧边栏
|
点触主界面左上角的 <FiMenu className="m-1" /> 打开侧边栏
|
||||||
</div>
|
</div>
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
@@ -41,16 +41,16 @@ export function RootExplorerGuide() {
|
|||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
<Header5 className="[&]:mt-0 [&]:pt-0">MT 管理器</Header5>
|
<Header5 className="[&]:mt-0 [&]:pt-0">MT 管理器</Header5>
|
||||||
<ul className="ml-2 list-disc list-inside">
|
<ul className="ml-2 list-disc">
|
||||||
<li>
|
<li>
|
||||||
<div className="inline-flex items-center gap-1">
|
<div className="inline-flex items-center flex-wrap">
|
||||||
点触主界面左上角的 <FiMenu /> 打开侧边栏
|
点触主界面左上角的 <FiMenu className="m-1" /> 打开侧边栏
|
||||||
</div>
|
</div>
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
<div className="inline-flex items-center">
|
<div className="inline-flex items-center flex-wrap">
|
||||||
点触侧边栏右上方的 <FiMoreVertical className="ml-1" />
|
点触侧边栏右上方的 <FiMoreVertical className="ml-1" />
|
||||||
,点触<VQuote>设置</VQuote>
|
弹出菜单,点触<VQuote>设置</VQuote>
|
||||||
</div>
|
</div>
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
|
|||||||
@@ -0,0 +1,73 @@
|
|||||||
|
import { NavLink, Navigate, Route, Routes } from 'react-router';
|
||||||
|
import { MdHome, MdQuestionAnswer, MdSettings } from 'react-icons/md';
|
||||||
|
import { Bounce, ToastContainer } from 'react-toastify';
|
||||||
|
|
||||||
|
import { Footer } from '~/components/Footer';
|
||||||
|
import { FaqHome } from '~/faq/FaqHome';
|
||||||
|
import { FAQ_PAGES } from '~/faq/FAQPages';
|
||||||
|
import { SettingsHome } from '~/features/settings/SettingsHome';
|
||||||
|
import { getSettingsTabs, hasOneClickImportCapability, ONE_CLICK_TAB_ID } from '~/features/settings/settingsTabs';
|
||||||
|
import { usePlatform } from '~/platform/PlatformContext';
|
||||||
|
import { FaqTab } from '~/tabs/FaqTab';
|
||||||
|
import { MainTab } from '~/tabs/MainTab';
|
||||||
|
import { SettingsTab } from '~/tabs/SettingsTab';
|
||||||
|
|
||||||
|
const tabClassNames = ({ isActive }: { isActive: boolean }) => `mb-[-2px] tab ${isActive ? 'tab-active' : ''}`;
|
||||||
|
|
||||||
|
/** Main chrome (nav / routes / toast / footer). Render only after platform `init()` resolves. */
|
||||||
|
export function AppLayout() {
|
||||||
|
const { capabilities } = usePlatform();
|
||||||
|
const settingsTabs = getSettingsTabs(capabilities);
|
||||||
|
const showOneClick = hasOneClickImportCapability(capabilities);
|
||||||
|
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
<div role="tablist" className="tabs tabs-border w-full justify-center border-b-2 border-base-200 box-content">
|
||||||
|
<NavLink to="/" role="tab" className={tabClassNames}>
|
||||||
|
<MdHome />
|
||||||
|
应用
|
||||||
|
</NavLink>
|
||||||
|
<NavLink to="/settings" role="tab" className={tabClassNames}>
|
||||||
|
<MdSettings />
|
||||||
|
设置
|
||||||
|
</NavLink>
|
||||||
|
<NavLink to="/questions" role="tab" className={tabClassNames}>
|
||||||
|
<MdQuestionAnswer />
|
||||||
|
答疑
|
||||||
|
</NavLink>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<main className="flex-1 flex justify-center min-h-0 overflow-auto">
|
||||||
|
<Routes>
|
||||||
|
<Route path="/" Component={MainTab} />
|
||||||
|
<Route path="/settings" Component={SettingsTab}>
|
||||||
|
<Route index Component={SettingsHome} />
|
||||||
|
{Object.entries(settingsTabs).map(([key, { Tab }]) => (
|
||||||
|
<Route key={key} path={key} Component={Tab} />
|
||||||
|
))}
|
||||||
|
{!showOneClick && <Route path={ONE_CLICK_TAB_ID} element={<Navigate to="/settings/general" replace />} />}
|
||||||
|
</Route>
|
||||||
|
<Route path="/questions" Component={FaqTab}>
|
||||||
|
<Route index Component={FaqHome} />
|
||||||
|
{FAQ_PAGES.map(({ id, Component }) => (
|
||||||
|
<Route key={id} path={id} Component={Component} />
|
||||||
|
))}
|
||||||
|
</Route>
|
||||||
|
</Routes>
|
||||||
|
</main>
|
||||||
|
|
||||||
|
<ToastContainer
|
||||||
|
position="bottom-center"
|
||||||
|
autoClose={5000}
|
||||||
|
newestOnTop
|
||||||
|
closeOnClick={false}
|
||||||
|
pauseOnFocusLoss
|
||||||
|
draggable
|
||||||
|
theme="colored"
|
||||||
|
transition={Bounce}
|
||||||
|
/>
|
||||||
|
|
||||||
|
<Footer />
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
}
|
||||||
+30
-63
@@ -1,77 +1,44 @@
|
|||||||
import { useEffect } from 'react';
|
import { Suspense } from 'react';
|
||||||
import { BrowserRouter, NavLink, Route, Routes } from 'react-router';
|
import { BrowserRouter } from 'react-router';
|
||||||
import { MdSettings, MdHome, MdQuestionAnswer } from 'react-icons/md';
|
|
||||||
|
|
||||||
import { MainTab } from '~/tabs/MainTab';
|
|
||||||
import { SettingsTab } from '~/tabs/SettingsTab';
|
|
||||||
|
|
||||||
import { Provider } from 'react-redux';
|
import { Provider } from 'react-redux';
|
||||||
|
|
||||||
|
import { AppLayout } from '~/components/AppLayout';
|
||||||
import { persistSettings } from '~/features/settings/persistSettings';
|
import { persistSettings } from '~/features/settings/persistSettings';
|
||||||
|
import { createPlatformProvider } from '~/platform/createPlatformProvider';
|
||||||
|
import { PlatformLoadGuard } from '~/platform/PlatformLoadGuard';
|
||||||
|
import { PlatformProviderHost } from '~/platform/PlatformContext';
|
||||||
|
import { setPlatform } from '~/platform/platformSingleton';
|
||||||
import { setupStore } from '~/store';
|
import { setupStore } from '~/store';
|
||||||
import { Footer } from '~/components/Footer';
|
|
||||||
import { FaqTab } from '~/tabs/FaqTab';
|
|
||||||
import { SETTINGS_TABS } from '~/features/settings/settingsTabs';
|
|
||||||
import { Bounce, ToastContainer } from 'react-toastify';
|
|
||||||
import { SettingsHome } from '~/features/settings/SettingsHome';
|
|
||||||
import { FAQ_PAGES } from '~/faq/FAQPages';
|
|
||||||
import { FaqHome } from '~/faq/FaqHome';
|
|
||||||
|
|
||||||
// Private to this file only.
|
// Private to this file only.
|
||||||
const store = setupStore();
|
const store = setupStore();
|
||||||
|
const platform = createPlatformProvider();
|
||||||
|
|
||||||
const tabClassNames = ({ isActive }: { isActive: boolean }) => `mb-[-2px] tab ${isActive ? 'tab-active' : ''}`;
|
const platformReady = platform.init().then(() => {
|
||||||
|
setPlatform(platform);
|
||||||
|
persistSettings(store, platform);
|
||||||
|
});
|
||||||
|
|
||||||
|
function AppBootFallback() {
|
||||||
|
return (
|
||||||
|
<div className="flex flex-1 items-center justify-center min-h-0" role="status" aria-live="polite">
|
||||||
|
<span className="loading loading-spinner loading-lg text-primary" />
|
||||||
|
<span className="sr-only">加载中</span>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
export function AppRoot() {
|
export function AppRoot() {
|
||||||
useEffect(() => persistSettings(store), []);
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<BrowserRouter>
|
<BrowserRouter basename={import.meta.env.BASE_URL}>
|
||||||
<Provider store={store}>
|
<Provider store={store}>
|
||||||
<div role="tablist" className="tabs tabs-border w-full justify-center border-b-2 border-base-200 box-content">
|
<PlatformProviderHost provider={platform}>
|
||||||
<NavLink to="/" role="tab" className={tabClassNames}>
|
<Suspense fallback={<AppBootFallback />}>
|
||||||
<MdHome />
|
<PlatformLoadGuard ready={platformReady}>
|
||||||
应用
|
<AppLayout />
|
||||||
</NavLink>
|
</PlatformLoadGuard>
|
||||||
<NavLink to="/settings" role="tab" className={tabClassNames}>
|
</Suspense>
|
||||||
<MdSettings />
|
</PlatformProviderHost>
|
||||||
设置
|
|
||||||
</NavLink>
|
|
||||||
<NavLink to="/questions" role="tab" className={tabClassNames}>
|
|
||||||
<MdQuestionAnswer />
|
|
||||||
答疑
|
|
||||||
</NavLink>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<main className="flex-1 flex justify-center min-h-0 overflow-auto">
|
|
||||||
<Routes>
|
|
||||||
<Route path="/" Component={MainTab} />
|
|
||||||
<Route path="/settings" Component={SettingsTab}>
|
|
||||||
<Route index Component={SettingsHome} />
|
|
||||||
{Object.entries(SETTINGS_TABS).map(([key, { Tab }]) => (
|
|
||||||
<Route key={key} path={key} Component={Tab} />
|
|
||||||
))}
|
|
||||||
</Route>
|
|
||||||
<Route path="/questions" Component={FaqTab}>
|
|
||||||
<Route index Component={FaqHome} />
|
|
||||||
{FAQ_PAGES.map(({ id, Component }) => (
|
|
||||||
<Route key={id} path={id} Component={Component} />
|
|
||||||
))}
|
|
||||||
</Route>
|
|
||||||
</Routes>
|
|
||||||
</main>
|
|
||||||
|
|
||||||
<ToastContainer
|
|
||||||
position="bottom-center"
|
|
||||||
autoClose={5000}
|
|
||||||
newestOnTop
|
|
||||||
closeOnClick={false}
|
|
||||||
pauseOnFocusLoss
|
|
||||||
draggable
|
|
||||||
theme="colored"
|
|
||||||
transition={Bounce}
|
|
||||||
/>
|
|
||||||
|
|
||||||
<Footer />
|
|
||||||
</Provider>
|
</Provider>
|
||||||
</BrowserRouter>
|
</BrowserRouter>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -2,83 +2,96 @@ import { DecryptedAudioFile, ProcessState, selectFiles } from '~/features/file-l
|
|||||||
import { FaDownload } from 'react-icons/fa';
|
import { FaDownload } from 'react-icons/fa';
|
||||||
import { useAppSelector } from '~/hooks';
|
import { useAppSelector } from '~/hooks';
|
||||||
import { toast } from 'react-toastify';
|
import { toast } from 'react-toastify';
|
||||||
|
import { selectFinalBatchDownloadSettings } from '~/features/settings/settingsSelector';
|
||||||
|
import { buildEnabledDownloadModes } from '~/platform/buildEnabledDownloadModes';
|
||||||
|
import { usePlatform } from '~/platform/PlatformContext';
|
||||||
|
|
||||||
export function DownloadAll() {
|
export function DownloadAll() {
|
||||||
const files = useAppSelector(selectFiles);
|
const files = useAppSelector(selectFiles);
|
||||||
const onClickDownloadAll = async () => {
|
const batchSettings = useAppSelector(selectFinalBatchDownloadSettings);
|
||||||
console.time('DownloadAll'); //开始计时
|
const { download, capabilities } = usePlatform();
|
||||||
const fileCount = Object.keys(files).length;
|
|
||||||
|
if (capabilities.downloadTypes.length === 0) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
const downloadAllAsync = async () => {
|
||||||
|
const fileList = Object.values(files);
|
||||||
|
const fileCount = fileList.length;
|
||||||
if (fileCount === 0) {
|
if (fileCount === 0) {
|
||||||
toast.warning('未添加文件');
|
toast.warning('未添加文件');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
//判断所有文件是否处理完成
|
const allComplete = fileList.every((file) => file.state !== ProcessState.PROCESSING);
|
||||||
const allComplete = Object.values(files).every((file) => file.state !== ProcessState.PROCESSING);
|
|
||||||
if (!allComplete) {
|
if (!allComplete) {
|
||||||
toast.warning('请等待所有文件解密完成');
|
toast.warning('请等待所有文件解密完成');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
//过滤处理失败的文件
|
const completeFiles = fileList.filter((file) => file.state === ProcessState.COMPLETE);
|
||||||
const completeFiles = Object.values(files).filter((file) => file.state === ProcessState.COMPLETE);
|
if (completeFiles.length === 0) {
|
||||||
|
toast.warning('没有可下载的已解密文件');
|
||||||
//开始下载
|
return;
|
||||||
let dir: FileSystemDirectoryHandle | undefined;
|
|
||||||
try {
|
|
||||||
dir = await window.showDirectoryPicker({ mode: 'readwrite' });
|
|
||||||
} catch (e) {
|
|
||||||
console.error(e);
|
|
||||||
if (e instanceof Error && e.name === 'AbortError') {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Single file: direct blob download, no ZIP / directory picker.
|
||||||
|
if (completeFiles.length === 1) {
|
||||||
|
const file = completeFiles[0];
|
||||||
|
await download.saveOne({
|
||||||
|
url: file.decrypted,
|
||||||
|
fileName: decryptedDownloadName(file),
|
||||||
|
});
|
||||||
|
toast.success('已开始下载');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const modes = buildEnabledDownloadModes(batchSettings, capabilities.downloadTypes);
|
||||||
|
if (modes.length === 0) {
|
||||||
|
toast.error('批量下载失败:未启用任何可用的下载方式,请在「设定 → 通用设置」中勾选。');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
toast.warning('开始下载,请稍候');
|
toast.warning('开始下载,请稍候');
|
||||||
|
|
||||||
const promises = Object.values(completeFiles).map(async (file) => {
|
const manyInput = {
|
||||||
console.log(`开始下载: ${file.fileName}`);
|
files: completeFiles.map((file) => ({
|
||||||
|
url: file.decrypted,
|
||||||
|
fileName: decryptedDownloadName(file),
|
||||||
|
})),
|
||||||
|
rememberDirectory: batchSettings.rememberDirectory,
|
||||||
|
};
|
||||||
|
|
||||||
|
for (const mode of modes) {
|
||||||
try {
|
try {
|
||||||
if (dir) {
|
const result = await download.saveMany(mode, manyInput);
|
||||||
await DownloadNew(dir, file);
|
if (result === 'ok') {
|
||||||
} else {
|
return;
|
||||||
await DownloadOld(file);
|
|
||||||
}
|
}
|
||||||
console.log(`成功下载: ${file.fileName}`);
|
// cancelled / skipped → try next mode
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.error(`下载失败: ${file.fileName}`, e);
|
console.error(`批量下载模式 ${mode} 失败`, e);
|
||||||
toast.error(`出现错误: ${e}`);
|
toast.error(`下载方式失败,尝试下一种: ${e instanceof Error ? e.message : String(e)}`);
|
||||||
throw e;
|
|
||||||
}
|
}
|
||||||
});
|
}
|
||||||
await Promise.allSettled(promises).then((f) => {
|
|
||||||
const success = f.filter((result) => result.status === 'fulfilled').length;
|
toast.error('批量下载失败:当前浏览器不支持或您取消了所有可用方式。可在「设定 → 通用设置」调整选项。');
|
||||||
if (success === fileCount) {
|
|
||||||
toast.success(`成功下载: ${success}/${fileCount}首`);
|
|
||||||
} else {
|
|
||||||
toast.warning(`成功下载: ${success}/${fileCount}首`);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
console.timeEnd('DownloadAll'); //停止计时
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
function onDownloadAll() {
|
||||||
|
downloadAllAsync().catch((e) => {
|
||||||
|
console.error('下载全部出现错误', e);
|
||||||
|
toast.error(`批量下载出现错误: ${e instanceof Error ? e.message : String(e)}`);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<button className="btn btn-primary" id="downloadAll" onClick={onClickDownloadAll} title="下载全部">
|
<button className="btn btn-primary" id="downloadAll" onClick={onDownloadAll} title="下载全部">
|
||||||
<FaDownload />
|
<FaDownload />
|
||||||
</button>
|
</button>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
async function DownloadNew(dir: FileSystemDirectoryHandle, file: DecryptedAudioFile) {
|
function decryptedDownloadName(file: DecryptedAudioFile): string {
|
||||||
const fileHandle = await dir.getFileHandle(file.cleanName + '.' + file.ext, { create: true });
|
return `${file.cleanName}.${file.ext}`;
|
||||||
const writable = await fileHandle.createWritable();
|
|
||||||
await fetch(file.decrypted).then((res) => res.body?.pipeTo(writable));
|
|
||||||
}
|
|
||||||
|
|
||||||
async function DownloadOld(file: DecryptedAudioFile) {
|
|
||||||
const a = document.createElement('a');
|
|
||||||
a.href = file.decrypted;
|
|
||||||
a.download = file.cleanName + '.' + file.ext;
|
|
||||||
document.body.append(a);
|
|
||||||
a.click();
|
|
||||||
a.remove();
|
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,32 @@
|
|||||||
|
import type { ReactNode } from 'react';
|
||||||
|
import { ExtLink } from './ExtLink';
|
||||||
|
import { IoMdArchive } from 'react-icons/io';
|
||||||
|
|
||||||
|
export type DownloadBase64Props = {
|
||||||
|
data: string;
|
||||||
|
filename: string;
|
||||||
|
mimetype?: string;
|
||||||
|
className?: string;
|
||||||
|
icon?: ReactNode | true | false;
|
||||||
|
children?: ReactNode;
|
||||||
|
};
|
||||||
|
|
||||||
|
export function DownloadBase64({
|
||||||
|
className,
|
||||||
|
children,
|
||||||
|
data,
|
||||||
|
filename,
|
||||||
|
icon,
|
||||||
|
mimetype = 'application/octet-stream',
|
||||||
|
}: DownloadBase64Props) {
|
||||||
|
return (
|
||||||
|
<ExtLink
|
||||||
|
icon={icon ?? <IoMdArchive className="inline size-sm ml-1" />}
|
||||||
|
className={className ?? 'link-info mx-1'}
|
||||||
|
download={filename}
|
||||||
|
href={`data:${mimetype};base64,${data}`}
|
||||||
|
>
|
||||||
|
{children ?? <code>{filename}</code>}
|
||||||
|
</ExtLink>
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -1,15 +1,15 @@
|
|||||||
import type { AnchorHTMLAttributes } from 'react';
|
import type { AnchorHTMLAttributes, ReactNode } from 'react';
|
||||||
import { FiExternalLink } from 'react-icons/fi';
|
import { FiExternalLink } from 'react-icons/fi';
|
||||||
|
|
||||||
export type ExtLinkProps = AnchorHTMLAttributes<HTMLAnchorElement> & {
|
export type ExtLinkProps = AnchorHTMLAttributes<HTMLAnchorElement> & {
|
||||||
icon?: boolean;
|
icon?: ReactNode | true | false;
|
||||||
};
|
};
|
||||||
|
|
||||||
export function ExtLink({ className, icon = true, children, ...props }: ExtLinkProps) {
|
export function ExtLink({ className, icon = true, children, ...props }: ExtLinkProps) {
|
||||||
return (
|
return (
|
||||||
<a rel="noreferrer noopener nofollow" target="_blank" className={`link ${className}`} {...props}>
|
<a rel="noreferrer noopener nofollow" target="_blank" className={`link ${className}`} {...props}>
|
||||||
{children}
|
{children}
|
||||||
{icon && <FiExternalLink className="inline size-sm ml-1" />}
|
{icon === true ? <FiExternalLink className="inline size-sm ml-1" /> : icon}
|
||||||
</a>
|
</a>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -5,7 +5,7 @@ export function Footer() {
|
|||||||
const appVersionShort = '__APP_VERSION_SHORT__';
|
const appVersionShort = '__APP_VERSION_SHORT__';
|
||||||
return (
|
return (
|
||||||
<footer className="flex flex-col text-center p-4 bg-base-200">
|
<footer className="flex flex-col text-center p-4 bg-base-200">
|
||||||
<p className="flex flex-row justify-center items-center h-[1em]">
|
<div className="flex flex-row justify-center items-center h-[1em]">
|
||||||
<a className="link link-info mr-1" href="https://git.um-react.app/um/um-react">
|
<a className="link link-info mr-1" href="https://git.um-react.app/um/um-react">
|
||||||
音乐解锁
|
音乐解锁
|
||||||
</a>
|
</a>
|
||||||
@@ -19,7 +19,7 @@ export function Footer() {
|
|||||||
</a>
|
</a>
|
||||||
, v{appVersionShort}
|
, v{appVersionShort}
|
||||||
<SDKVersion />)
|
<SDKVersion />)
|
||||||
</p>
|
</div>
|
||||||
<p>
|
<p>
|
||||||
{'© 2019 - '}
|
{'© 2019 - '}
|
||||||
<CurrentYear />
|
<CurrentYear />
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
import { useEffect, useRef } from 'react';
|
import { useEffect, useRef } from 'react';
|
||||||
|
|
||||||
import { FileInput } from '~/components/FileInput';
|
import { FileInput } from '~/components/FileInput';
|
||||||
|
import { InSecretImportModalContext } from '~/context/InSecretImportModal';
|
||||||
|
|
||||||
export interface ImportSecretModalProps {
|
export interface ImportSecretModalProps {
|
||||||
clientName?: React.ReactNode;
|
clientName?: React.ReactNode;
|
||||||
@@ -12,13 +13,12 @@ export interface ImportSecretModalProps {
|
|||||||
|
|
||||||
export function ImportSecretModal({ clientName, children, show, onClose, onImport }: ImportSecretModalProps) {
|
export function ImportSecretModal({ clientName, children, show, onClose, onImport }: ImportSecretModalProps) {
|
||||||
const handleFileReceived = (files: File[]) => {
|
const handleFileReceived = (files: File[]) => {
|
||||||
const promise = onImport(files[0]);
|
const importResult = onImport(files[0]);
|
||||||
if (promise instanceof Promise) {
|
if (importResult instanceof Promise) {
|
||||||
promise.catch((err) => {
|
importResult.catch((err) => {
|
||||||
console.error('could not import: ', err);
|
console.error('could not import: ', err);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
return promise;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const refModel = useRef<HTMLDialogElement>(null);
|
const refModel = useRef<HTMLDialogElement>(null);
|
||||||
@@ -31,7 +31,7 @@ export function ImportSecretModal({ clientName, children, show, onClose, onImpor
|
|||||||
}, [show]);
|
}, [show]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<dialog ref={refModel} className="modal">
|
<dialog ref={refModel} className="modal" onClose={onClose}>
|
||||||
<div className="modal-box">
|
<div className="modal-box">
|
||||||
<form method="dialog" onSubmit={() => onClose()}>
|
<form method="dialog" onSubmit={() => onClose()}>
|
||||||
<button className="btn btn-sm btn-circle btn-ghost absolute right-2 top-2">✕</button>
|
<button className="btn btn-sm btn-circle btn-ghost absolute right-2 top-2">✕</button>
|
||||||
@@ -41,7 +41,9 @@ export function ImportSecretModal({ clientName, children, show, onClose, onImpor
|
|||||||
<FileInput onReceiveFiles={handleFileReceived}>拖放或点我选择含有密钥的数据库文件</FileInput>
|
<FileInput onReceiveFiles={handleFileReceived}>拖放或点我选择含有密钥的数据库文件</FileInput>
|
||||||
|
|
||||||
<div className="mt-2">选择你的{clientName && <>「{clientName}」</>}客户端平台以查看对应说明:</div>
|
<div className="mt-2">选择你的{clientName && <>「{clientName}」</>}客户端平台以查看对应说明:</div>
|
||||||
<div>{children}</div>
|
<InSecretImportModalContext.Provider value={true}>
|
||||||
|
<div>{children}</div>
|
||||||
|
</InSecretImportModalContext.Provider>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</dialog>
|
</dialog>
|
||||||
|
|||||||
@@ -1,18 +1,15 @@
|
|||||||
import { MdInfoOutline } from 'react-icons/md';
|
import { MdInfoOutline } from 'react-icons/md';
|
||||||
import { workerClientBus } from '~/decrypt-worker/client';
|
|
||||||
import { DECRYPTION_WORKER_ACTION_NAME } from '~/decrypt-worker/constants';
|
import { DECRYPTION_WORKER_ACTION_NAME } from '~/decrypt-worker/constants';
|
||||||
|
import { usePlatform } from '~/platform/PlatformContext';
|
||||||
import { useEffect, useRef, useState } from 'react';
|
import { useEffect, useRef, useState } from 'react';
|
||||||
|
|
||||||
const getSDKVersion = async (): Promise<string> => {
|
|
||||||
return workerClientBus.request(DECRYPTION_WORKER_ACTION_NAME.VERSION, null);
|
|
||||||
};
|
|
||||||
|
|
||||||
export function SDKVersion() {
|
export function SDKVersion() {
|
||||||
|
const { crypto } = usePlatform();
|
||||||
const refDialog = useRef<HTMLDialogElement>(null);
|
const refDialog = useRef<HTMLDialogElement>(null);
|
||||||
const [sdkVersion, setSdkVersion] = useState('...');
|
const [sdkVersion, setSdkVersion] = useState('...');
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
getSDKVersion().then(setSdkVersion);
|
crypto.request(DECRYPTION_WORKER_ACTION_NAME.VERSION, null).then(setSdkVersion, () => setSdkVersion('N/A'));
|
||||||
}, []);
|
}, [crypto]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
|
|||||||
@@ -27,7 +27,10 @@ export function SelectFile() {
|
|||||||
fileName,
|
fileName,
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
dispatch(processFile({ fileId }));
|
|
||||||
|
dispatch(processFile({ fileId })).catch((err) => {
|
||||||
|
console.log(`failed to add file (id=${fileId}, name=${fileName}, err=${err as Error})`);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,25 @@
|
|||||||
|
import { DownloadAll } from '~/components/DownloadAll';
|
||||||
|
import { createBrowserProvider } from '~/platform/browser/BrowserProvider';
|
||||||
|
import { renderWithProviders, screen } from '~/test-utils/test-helper';
|
||||||
|
|
||||||
|
test('hides download-all control when platform has no downloadTypes', () => {
|
||||||
|
const platform = createBrowserProvider({
|
||||||
|
crypto: {
|
||||||
|
request: () => Promise.resolve(null as never),
|
||||||
|
enqueueDecrypt: () => Promise.reject(new Error('unused')),
|
||||||
|
},
|
||||||
|
downloadTypes: [],
|
||||||
|
});
|
||||||
|
|
||||||
|
renderWithProviders(<DownloadAll />, { platform });
|
||||||
|
|
||||||
|
expect(screen.queryByTitle('下载全部')).not.toBeInTheDocument();
|
||||||
|
expect(document.getElementById('downloadAll')).toBeNull();
|
||||||
|
});
|
||||||
|
|
||||||
|
test('renders download-all control when PackZip is available', () => {
|
||||||
|
renderWithProviders(<DownloadAll />);
|
||||||
|
|
||||||
|
expect(screen.getByTitle('下载全部')).toBeInTheDocument();
|
||||||
|
expect(document.getElementById('downloadAll')).not.toBeNull();
|
||||||
|
});
|
||||||
@@ -0,0 +1,33 @@
|
|||||||
|
import { fireEvent, render, screen, waitFor } from '@testing-library/react';
|
||||||
|
import userEvent from '@testing-library/user-event';
|
||||||
|
import { FileInput } from '../FileInput';
|
||||||
|
|
||||||
|
test('receives multiple files from the file picker', async () => {
|
||||||
|
const onReceiveFiles = vi.fn();
|
||||||
|
const files = [new File(['first'], 'first.qmc3'), new File(['second'], 'second.mflac')];
|
||||||
|
const { container } = render(<FileInput onReceiveFiles={onReceiveFiles}>Choose files</FileInput>);
|
||||||
|
const input = container.querySelector('input');
|
||||||
|
if (!input) throw new Error('File input is missing');
|
||||||
|
|
||||||
|
await userEvent.upload(input, files);
|
||||||
|
|
||||||
|
await waitFor(() => expect(onReceiveFiles).toHaveBeenCalledOnce());
|
||||||
|
expect(onReceiveFiles.mock.calls[0][0]).toEqual(files);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('receives multiple dropped files', async () => {
|
||||||
|
const onReceiveFiles = vi.fn();
|
||||||
|
const files = [new File(['first'], 'first.kgm'), new File(['second'], 'second.ncm')];
|
||||||
|
render(<FileInput onReceiveFiles={onReceiveFiles}>Drop files</FileInput>);
|
||||||
|
|
||||||
|
fireEvent.drop(screen.getByText('Drop files'), {
|
||||||
|
dataTransfer: {
|
||||||
|
files,
|
||||||
|
items: files.map((file) => ({ kind: 'file', type: file.type, getAsFile: () => file })),
|
||||||
|
types: ['Files'],
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
await waitFor(() => expect(onReceiveFiles).toHaveBeenCalledOnce());
|
||||||
|
expect(onReceiveFiles.mock.calls[0][0]).toEqual(files);
|
||||||
|
});
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
import { createContext } from 'react';
|
||||||
|
|
||||||
|
export const InSecretImportModalContext = createContext<boolean>(false);
|
||||||
@@ -0,0 +1,21 @@
|
|||||||
|
import type { DecryptionResult } from './constants';
|
||||||
|
import type {
|
||||||
|
DecryptCommandPayload,
|
||||||
|
FetchMusicExNamePayload,
|
||||||
|
GetQingTingFMDeviceKeyPayload,
|
||||||
|
ParseKugouHeaderPayload,
|
||||||
|
ParseKugouHeaderResponse,
|
||||||
|
ParseKuwoHeaderPayload,
|
||||||
|
ParseKuwoHeaderResponse,
|
||||||
|
} from './types';
|
||||||
|
|
||||||
|
export type WorkerActionMap = {
|
||||||
|
DECRYPT: { req: DecryptCommandPayload; res: DecryptionResult };
|
||||||
|
FIND_QMC_MUSICEX_NAME: { req: FetchMusicExNamePayload; res: string | null };
|
||||||
|
KUWO_PARSE_HEADER: { req: ParseKuwoHeaderPayload; res: ParseKuwoHeaderResponse };
|
||||||
|
KUGOU_PARSE_HEADER: { req: ParseKugouHeaderPayload; res: ParseKugouHeaderResponse };
|
||||||
|
QINGTING_FM_GET_DEVICE_KEY: { req: GetQingTingFMDeviceKeyPayload; res: string };
|
||||||
|
VERSION: { req: null; res: string };
|
||||||
|
};
|
||||||
|
|
||||||
|
export type WorkerActionName = keyof WorkerActionMap;
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
import { WorkerClientBus } from '~/util/WorkerEventBus';
|
import { WorkerClientBus } from '~/util/WorkerEventBus';
|
||||||
import { DECRYPTION_WORKER_ACTION_NAME } from './constants';
|
import type { WorkerActionMap } from './actions';
|
||||||
import { DecryptionQueue } from '~/util/DecryptionQueue';
|
import { DecryptionQueue } from '~/util/DecryptionQueue';
|
||||||
|
|
||||||
// TODO: Worker pool?
|
// TODO: Worker pool?
|
||||||
@@ -8,5 +8,5 @@ export const workerClient = new Worker(new URL('./worker', import.meta.url), { t
|
|||||||
// FIXME: report the error so is obvious to the user.
|
// FIXME: report the error so is obvious to the user.
|
||||||
workerClient.addEventListener('error', console.error);
|
workerClient.addEventListener('error', console.error);
|
||||||
|
|
||||||
export const workerClientBus = new WorkerClientBus<DECRYPTION_WORKER_ACTION_NAME>(workerClient);
|
export const workerClientBus = new WorkerClientBus<WorkerActionMap>(workerClient);
|
||||||
export const decryptionQueue = new DecryptionQueue(workerClientBus);
|
export const decryptionQueue = new DecryptionQueue(workerClientBus);
|
||||||
@@ -19,18 +19,18 @@ export class KugouMusicDecipher implements DecipherInstance {
|
|||||||
kgm.decrypt(block, offset);
|
kgm.decrypt(block, offset);
|
||||||
}
|
}
|
||||||
|
|
||||||
return {
|
return Promise.resolve({
|
||||||
status: Status.OK,
|
status: Status.OK,
|
||||||
cipherName: this.cipherName,
|
cipherName: this.cipherName,
|
||||||
data: audioBuffer,
|
data: audioBuffer,
|
||||||
};
|
});
|
||||||
} finally {
|
} finally {
|
||||||
kgmHdr?.free();
|
kgmHdr?.free();
|
||||||
kgm?.free();
|
kgm?.free();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static make() {
|
public static make(this: void) {
|
||||||
return new KugouMusicDecipher();
|
return new KugouMusicDecipher();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -12,24 +12,24 @@ export class KuwoMusicDecipher implements DecipherInstance {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
header = KuwoHeader.parse(buffer.subarray(0, 0x400));
|
header = KuwoHeader.parse(buffer.subarray(0, 0x400));
|
||||||
kwm = new KWMDecipher(header, options.kwm2key);
|
kwm = new KWMDecipher(header, options.kwm2Key);
|
||||||
|
|
||||||
const audioBuffer = new Uint8Array(buffer.subarray(0x400));
|
const audioBuffer = new Uint8Array(buffer.subarray(0x400));
|
||||||
for (const [block, offset] of chunkBuffer(audioBuffer)) {
|
for (const [block, offset] of chunkBuffer(audioBuffer)) {
|
||||||
kwm.decrypt(block, offset);
|
kwm.decrypt(block, offset);
|
||||||
}
|
}
|
||||||
return {
|
return Promise.resolve({
|
||||||
status: Status.OK,
|
status: Status.OK,
|
||||||
cipherName: this.cipherName,
|
cipherName: this.cipherName,
|
||||||
data: audioBuffer,
|
data: audioBuffer,
|
||||||
};
|
});
|
||||||
} finally {
|
} finally {
|
||||||
kwm?.free();
|
kwm?.free();
|
||||||
header?.free();
|
header?.free();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static make() {
|
public static make(this: void) {
|
||||||
return new KuwoMusicDecipher();
|
return new KuwoMusicDecipher();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -6,22 +6,25 @@ export class Migu3DKeylessDecipher implements DecipherInstance {
|
|||||||
cipherName = 'Migu3D (Keyless)';
|
cipherName = 'Migu3D (Keyless)';
|
||||||
|
|
||||||
async decrypt(buffer: Uint8Array): Promise<DecipherResult | DecipherOK> {
|
async decrypt(buffer: Uint8Array): Promise<DecipherResult | DecipherOK> {
|
||||||
const mg3d = Migu3D.fromHeader(buffer.subarray(0, 0x100));
|
|
||||||
const audioBuffer = new Uint8Array(buffer);
|
const audioBuffer = new Uint8Array(buffer);
|
||||||
|
const mg3d = Migu3D.fromHeader(buffer.subarray(0, 0x100));
|
||||||
|
|
||||||
for (const [block, i] of chunkBuffer(audioBuffer)) {
|
try {
|
||||||
mg3d.decrypt(block, i);
|
for (const [block, i] of chunkBuffer(audioBuffer)) {
|
||||||
|
mg3d.decrypt(block, i);
|
||||||
|
}
|
||||||
|
} finally {
|
||||||
|
mg3d.free();
|
||||||
}
|
}
|
||||||
mg3d.free();
|
|
||||||
|
|
||||||
return {
|
return Promise.resolve({
|
||||||
cipherName: this.cipherName,
|
cipherName: this.cipherName,
|
||||||
status: Status.OK,
|
status: Status.OK,
|
||||||
data: audioBuffer,
|
data: audioBuffer,
|
||||||
};
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public static make() {
|
public static make(this: void) {
|
||||||
return new Migu3DKeylessDecipher();
|
return new Migu3DKeylessDecipher();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -26,17 +26,17 @@ export class NetEaseCloudMusicDecipher implements DecipherInstance {
|
|||||||
for (const [block, offset] of chunkBuffer(audioBuffer)) {
|
for (const [block, offset] of chunkBuffer(audioBuffer)) {
|
||||||
ncm.decrypt(block, offset);
|
ncm.decrypt(block, offset);
|
||||||
}
|
}
|
||||||
return {
|
return Promise.resolve({
|
||||||
status: Status.OK,
|
status: Status.OK,
|
||||||
cipherName: this.cipherName,
|
cipherName: this.cipherName,
|
||||||
data: audioBuffer,
|
data: audioBuffer,
|
||||||
};
|
});
|
||||||
} finally {
|
} finally {
|
||||||
ncm.free();
|
ncm.free();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static make() {
|
public static make(this: void) {
|
||||||
return new NetEaseCloudMusicDecipher();
|
return new NetEaseCloudMusicDecipher();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -19,14 +19,14 @@ export class QQMusicV1Decipher implements DecipherInstance {
|
|||||||
for (const [block, offset] of chunkBuffer(audioBuffer)) {
|
for (const [block, offset] of chunkBuffer(audioBuffer)) {
|
||||||
decryptQMC1(block, offset);
|
decryptQMC1(block, offset);
|
||||||
}
|
}
|
||||||
return {
|
return Promise.resolve({
|
||||||
status: Status.OK,
|
status: Status.OK,
|
||||||
cipherName: this.cipherName,
|
cipherName: this.cipherName,
|
||||||
data: audioBuffer,
|
data: audioBuffer,
|
||||||
};
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public static create() {
|
public static create(this: void) {
|
||||||
return new QQMusicV1Decipher();
|
return new QQMusicV1Decipher();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -62,25 +62,28 @@ export class QQMusicV2Decipher implements DecipherInstance {
|
|||||||
throw new Error('EKey required');
|
throw new Error('EKey required');
|
||||||
}
|
}
|
||||||
|
|
||||||
const qmc2 = new QMC2(ekey);
|
|
||||||
const audioBuffer = buffer.slice(0, buffer.byteLength - footer.size);
|
const audioBuffer = buffer.slice(0, buffer.byteLength - footer.size);
|
||||||
for (const [block, offset] of chunkBuffer(audioBuffer)) {
|
const qmc2 = new QMC2(ekey);
|
||||||
qmc2.decrypt(block, offset);
|
try {
|
||||||
|
for (const [block, offset] of chunkBuffer(audioBuffer)) {
|
||||||
|
qmc2.decrypt(block, offset);
|
||||||
|
}
|
||||||
|
} finally {
|
||||||
|
qmc2.free();
|
||||||
}
|
}
|
||||||
qmc2.free();
|
|
||||||
|
|
||||||
return {
|
return Promise.resolve({
|
||||||
status: Status.OK,
|
status: Status.OK,
|
||||||
cipherName: this.cipherName,
|
cipherName: this.cipherName,
|
||||||
data: audioBuffer,
|
data: audioBuffer,
|
||||||
};
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public static createWithUserKey() {
|
public static createWithUserKey(this: void) {
|
||||||
return new QQMusicV2Decipher(true);
|
return new QQMusicV2Decipher(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static createWithEmbeddedEKey() {
|
public static createWithEmbeddedEKey(this: void) {
|
||||||
return new QQMusicV2Decipher(false);
|
return new QQMusicV2Decipher(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -18,20 +18,23 @@ export class QignTingFMDecipher implements DecipherInstance {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
const qtfm = new QingTingFM(key, iv);
|
|
||||||
const audioBuffer = new Uint8Array(buffer);
|
const audioBuffer = new Uint8Array(buffer);
|
||||||
for (const [block, i] of chunkBuffer(audioBuffer)) {
|
const qtfm = new QingTingFM(key, iv);
|
||||||
qtfm.decrypt(block, i);
|
try {
|
||||||
|
for (const [block, i] of chunkBuffer(audioBuffer)) {
|
||||||
|
qtfm.decrypt(block, i);
|
||||||
|
}
|
||||||
|
} finally {
|
||||||
|
qtfm.free();
|
||||||
}
|
}
|
||||||
|
return Promise.resolve({
|
||||||
return {
|
|
||||||
cipherName: this.cipherName,
|
cipherName: this.cipherName,
|
||||||
status: Status.OK,
|
status: Status.OK,
|
||||||
data: audioBuffer,
|
data: audioBuffer,
|
||||||
};
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public static make() {
|
public static make(this: void) {
|
||||||
return new QignTingFMDecipher();
|
return new QignTingFMDecipher();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -4,15 +4,15 @@ export class TransparentDecipher implements DecipherInstance {
|
|||||||
cipherName = 'none';
|
cipherName = 'none';
|
||||||
|
|
||||||
async decrypt(buffer: Uint8Array<ArrayBuffer>): Promise<DecipherResult | DecipherOK> {
|
async decrypt(buffer: Uint8Array<ArrayBuffer>): Promise<DecipherResult | DecipherOK> {
|
||||||
return {
|
return Promise.resolve({
|
||||||
cipherName: 'None',
|
cipherName: 'None',
|
||||||
status: Status.OK,
|
status: Status.OK,
|
||||||
data: buffer,
|
data: buffer,
|
||||||
message: 'No decipher applied',
|
message: 'No decipher applied',
|
||||||
};
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public static make() {
|
public static make(this: void) {
|
||||||
return new TransparentDecipher();
|
return new TransparentDecipher();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -6,23 +6,26 @@ export class XiamiDecipher implements DecipherInstance {
|
|||||||
cipherName = 'Xiami (XM)';
|
cipherName = 'Xiami (XM)';
|
||||||
|
|
||||||
async decrypt(buffer: Uint8Array): Promise<DecipherResult | DecipherOK> {
|
async decrypt(buffer: Uint8Array): Promise<DecipherResult | DecipherOK> {
|
||||||
const xm = Xiami.from_header(buffer.subarray(0, 0x10));
|
|
||||||
const { copyPlainLength } = xm;
|
|
||||||
const audioBuffer = buffer.slice(0x10);
|
const audioBuffer = buffer.slice(0x10);
|
||||||
|
|
||||||
for (const [block] of chunkBuffer(audioBuffer.subarray(copyPlainLength))) {
|
const xm = Xiami.from_header(buffer.subarray(0, 0x10));
|
||||||
xm.decrypt(block);
|
try {
|
||||||
|
const { copyPlainLength } = xm;
|
||||||
|
for (const [block] of chunkBuffer(audioBuffer.subarray(copyPlainLength))) {
|
||||||
|
xm.decrypt(block);
|
||||||
|
}
|
||||||
|
} finally {
|
||||||
|
xm.free();
|
||||||
}
|
}
|
||||||
xm.free();
|
|
||||||
|
|
||||||
return {
|
return Promise.resolve({
|
||||||
cipherName: this.cipherName,
|
cipherName: this.cipherName,
|
||||||
status: Status.OK,
|
status: Status.OK,
|
||||||
data: audioBuffer,
|
data: audioBuffer,
|
||||||
};
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public static make() {
|
public static make(this: void) {
|
||||||
return new XiamiDecipher();
|
return new XiamiDecipher();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -23,18 +23,18 @@ export class XimalayaAndroidDecipher implements DecipherInstance {
|
|||||||
}
|
}
|
||||||
const result = new Uint8Array(buffer);
|
const result = new Uint8Array(buffer);
|
||||||
result.set(slice, 0);
|
result.set(slice, 0);
|
||||||
return {
|
return Promise.resolve({
|
||||||
cipherName: this.cipherName,
|
cipherName: this.cipherName,
|
||||||
status: Status.OK,
|
status: Status.OK,
|
||||||
data: result,
|
data: result,
|
||||||
};
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public static makeX2M() {
|
public static makeX2M(this: void) {
|
||||||
return new XimalayaAndroidDecipher(decryptX2MHeader, 'X2M');
|
return new XimalayaAndroidDecipher(decryptX2MHeader, 'X2M');
|
||||||
}
|
}
|
||||||
|
|
||||||
public static makeX3M() {
|
public static makeX3M(this: void) {
|
||||||
return new XimalayaAndroidDecipher(decryptX3MHeader, 'X3M');
|
return new XimalayaAndroidDecipher(decryptX3MHeader, 'X3M');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -45,27 +45,31 @@ export class XimalayaPCDecipher implements DecipherInstance {
|
|||||||
async decrypt(buffer: Uint8Array, _options: DecryptCommandOptions): Promise<DecipherResult | DecipherOK> {
|
async decrypt(buffer: Uint8Array, _options: DecryptCommandOptions): Promise<DecipherResult | DecipherOK> {
|
||||||
// Detect with first 0x400 bytes
|
// Detect with first 0x400 bytes
|
||||||
const headerSize = XmlyPC.getHeaderSize(buffer.subarray(0, 1024));
|
const headerSize = XmlyPC.getHeaderSize(buffer.subarray(0, 1024));
|
||||||
const xm = new XmlyPC(buffer.subarray(0, headerSize));
|
const xmly = new XmlyPC(buffer.subarray(0, headerSize));
|
||||||
const { audioHeader, encryptedHeaderOffset, encryptedHeaderSize } = xm;
|
|
||||||
const plainAudioDataOffset = encryptedHeaderOffset + encryptedHeaderSize;
|
|
||||||
const plainAudioDataLength = buffer.byteLength - plainAudioDataOffset;
|
|
||||||
const encryptedAudioPart = buffer.slice(encryptedHeaderOffset, plainAudioDataOffset);
|
|
||||||
const encryptedAudioPartLen = xm.decrypt(encryptedAudioPart);
|
|
||||||
const audioSize = audioHeader.byteLength + encryptedAudioPartLen + plainAudioDataLength;
|
|
||||||
xm.free();
|
|
||||||
|
|
||||||
const result = new Uint8Array(audioSize);
|
try {
|
||||||
result.set(audioHeader);
|
const { audioHeader, encryptedHeaderOffset, encryptedHeaderSize } = xmly;
|
||||||
result.set(encryptedAudioPart, audioHeader.byteLength);
|
const plainAudioDataOffset = encryptedHeaderOffset + encryptedHeaderSize;
|
||||||
result.set(buffer.subarray(plainAudioDataOffset), audioHeader.byteLength + encryptedAudioPartLen);
|
const plainAudioDataLength = buffer.byteLength - plainAudioDataOffset;
|
||||||
return {
|
const encryptedAudioPart = buffer.slice(encryptedHeaderOffset, plainAudioDataOffset);
|
||||||
status: Status.OK,
|
const encryptedAudioPartLen = xmly.decrypt(encryptedAudioPart);
|
||||||
data: result,
|
const audioSize = audioHeader.byteLength + encryptedAudioPartLen + plainAudioDataLength;
|
||||||
cipherName: this.cipherName,
|
|
||||||
};
|
const result = new Uint8Array(audioSize);
|
||||||
|
result.set(audioHeader);
|
||||||
|
result.set(encryptedAudioPart, audioHeader.byteLength);
|
||||||
|
result.set(buffer.subarray(plainAudioDataOffset), audioHeader.byteLength + encryptedAudioPartLen);
|
||||||
|
return Promise.resolve({
|
||||||
|
status: Status.OK,
|
||||||
|
data: result,
|
||||||
|
cipherName: this.cipherName,
|
||||||
|
});
|
||||||
|
} finally {
|
||||||
|
xmly.free();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static make() {
|
public static make(this: void) {
|
||||||
return new XimalayaPCDecipher();
|
return new XimalayaPCDecipher();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,13 +1,13 @@
|
|||||||
export interface DecryptCommandOptions {
|
export interface DecryptCommandOptions {
|
||||||
fileName: string;
|
fileName: string;
|
||||||
qmc2Key?: string;
|
qmc2Key?: string;
|
||||||
kwm2key?: string;
|
kwm2Key?: string;
|
||||||
kugouKey?: string;
|
kugouKey?: string;
|
||||||
qingTingAndroidKey?: string;
|
qingTingAndroidKey?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface DecryptCommandPayload {
|
export interface DecryptCommandPayload {
|
||||||
id: string;
|
fileId: string;
|
||||||
blobURI: string;
|
blobURI: string;
|
||||||
options: DecryptCommandOptions;
|
options: DecryptCommandOptions;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ export function withWasmClass<T extends { free: () => void }, R>(instance: T, cb
|
|||||||
const resp = cb(instance);
|
const resp = cb(instance);
|
||||||
if (resp && isPromise(resp)) {
|
if (resp && isPromise(resp)) {
|
||||||
isAsync = true;
|
isAsync = true;
|
||||||
resp.finally(() => instance.free());
|
resp.finally(() => instance.free()).catch(() => {});
|
||||||
}
|
}
|
||||||
return resp;
|
return resp;
|
||||||
} finally {
|
} finally {
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
import { WorkerServerBus } from '~/util/WorkerEventBus';
|
import { WorkerServerBus } from '~/util/WorkerEventBus';
|
||||||
|
import type { WorkerActionMap } from './actions';
|
||||||
import { DECRYPTION_WORKER_ACTION_NAME } from './constants';
|
import { DECRYPTION_WORKER_ACTION_NAME } from './constants';
|
||||||
import { getUmcVersion } from '@unlock-music/crypto';
|
import { getUmcVersion } from '@unlock-music/crypto';
|
||||||
|
|
||||||
@@ -8,7 +9,7 @@ import { workerGetQtfmDeviceKey } from '~/decrypt-worker/worker/qtfm_device_key.
|
|||||||
import { workerParseKuwoHeader } from '~/decrypt-worker/worker/kuwo_header_parse.ts';
|
import { workerParseKuwoHeader } from '~/decrypt-worker/worker/kuwo_header_parse.ts';
|
||||||
import { workerParseKugouHeader } from '~/decrypt-worker/worker/kugou_parse_header.ts';
|
import { workerParseKugouHeader } from '~/decrypt-worker/worker/kugou_parse_header.ts';
|
||||||
|
|
||||||
const bus = new WorkerServerBus();
|
const bus = new WorkerServerBus<WorkerActionMap>();
|
||||||
onmessage = bus.onmessage;
|
onmessage = bus.onmessage;
|
||||||
|
|
||||||
bus.addEventHandler(DECRYPTION_WORKER_ACTION_NAME.DECRYPT, workerDecryptHandler);
|
bus.addEventHandler(DECRYPTION_WORKER_ACTION_NAME.DECRYPT, workerDecryptHandler);
|
||||||
|
|||||||
@@ -80,13 +80,12 @@ class DecryptCommandHandler {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export const workerDecryptHandler = async ({ id: payloadId, blobURI, options }: DecryptCommandPayload) => {
|
export const workerDecryptHandler = async ({ fileId, blobURI, options }: DecryptCommandPayload) => {
|
||||||
await umCryptoReady;
|
await umCryptoReady;
|
||||||
const id = payloadId.replace('://', ':');
|
const label = `decrypt(${fileId})`;
|
||||||
const label = `decrypt(${id})`;
|
|
||||||
return withTimeGroupedLogs(label, async () => {
|
return withTimeGroupedLogs(label, async () => {
|
||||||
const buffer = await fetch(blobURI).then((r) => r.arrayBuffer());
|
const buffer = await fetch(blobURI).then((r) => r.arrayBuffer());
|
||||||
const handler = new DecryptCommandHandler(id, new Uint8Array(buffer), options);
|
const handler = new DecryptCommandHandler(fileId, new Uint8Array(buffer), options);
|
||||||
return handler.decrypt(allCryptoFactories);
|
return handler.decrypt(allCryptoFactories);
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
@@ -1,15 +1,14 @@
|
|||||||
import {
|
import { ParseKugouHeaderPayload, ParseKugouHeaderResponse } from '~/decrypt-worker/types.ts';
|
||||||
ParseKugouHeaderPayload, ParseKugouHeaderResponse,
|
|
||||||
|
|
||||||
} from '~/decrypt-worker/types.ts';
|
|
||||||
import { KuGouHeader } from '@unlock-music/crypto';
|
import { KuGouHeader } from '@unlock-music/crypto';
|
||||||
|
|
||||||
export const workerParseKugouHeader = async ({ blobURI }: ParseKugouHeaderPayload): Promise<ParseKugouHeaderResponse> => {
|
export const workerParseKugouHeader = async ({
|
||||||
|
blobURI,
|
||||||
|
}: ParseKugouHeaderPayload): Promise<ParseKugouHeaderResponse> => {
|
||||||
const blob = await fetch(blobURI, { headers: { Range: 'bytes=0-1023' } }).then((r) => r.blob());
|
const blob = await fetch(blobURI, { headers: { Range: 'bytes=0-1023' } }).then((r) => r.blob());
|
||||||
const arrayBuffer = await blob.arrayBuffer();
|
const arrayBuffer = await blob.arrayBuffer();
|
||||||
const buffer = new Uint8Array(arrayBuffer.slice(0, 0x400));
|
const buffer = new Uint8Array(arrayBuffer.slice(0, 0x400));
|
||||||
|
|
||||||
let kwm : KuGouHeader | undefined;
|
let kwm: KuGouHeader | undefined;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
kwm = new KuGouHeader(buffer);
|
kwm = new KuGouHeader(buffer);
|
||||||
@@ -20,4 +19,4 @@ export const workerParseKugouHeader = async ({ blobURI }: ParseKugouHeaderPayloa
|
|||||||
} finally {
|
} finally {
|
||||||
kwm?.free();
|
kwm?.free();
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
import { ParseKuwoHeaderPayload, ParseKuwoHeaderResponse } from '~/decrypt-worker/types.ts';
|
import { ParseKuwoHeaderPayload, ParseKuwoHeaderResponse } from '~/decrypt-worker/types.ts';
|
||||||
import { KuwoHeader } from '@unlock-music/crypto';
|
import { KuwoHeader } from '@unlock-music/crypto';
|
||||||
|
|
||||||
export const workerParseKuwoHeader = async ({ blobURI }: ParseKuwoHeaderPayload): Promise<ParseKuwoHeaderResponse> => {
|
export const workerParseKuwoHeader = async ({ blobURI }: ParseKuwoHeaderPayload): Promise<ParseKuwoHeaderResponse> => {
|
||||||
|
|||||||
@@ -11,5 +11,5 @@ export async function workerGetQtfmDeviceKey({
|
|||||||
board,
|
board,
|
||||||
}: GetQingTingFMDeviceKeyPayload) {
|
}: GetQingTingFMDeviceKeyPayload) {
|
||||||
const buffer = QingTingFM.getDeviceKey(device, brand, model, product, manufacturer, board);
|
const buffer = QingTingFM.getDeviceKey(device, brand, model, product, manufacturer, board);
|
||||||
return hex(buffer);
|
return Promise.resolve(hex(buffer));
|
||||||
}
|
}
|
||||||
+1
-1
@@ -1,5 +1,5 @@
|
|||||||
// This is a dummy module for vite/rollup to resolve.
|
// This is a dummy module for vite/rollup to resolve.
|
||||||
export function createRequire() {
|
export function createRequire() {
|
||||||
import('radash'); // we need to import something, so vite don't complain on build
|
const _ = import('radash'); // we need to import something, so vite don't complain on build
|
||||||
throw new Error('this is a dummy module. Do not use');
|
throw new Error('this is a dummy module. Do not use');
|
||||||
}
|
}
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
import { Header2, Header3 } from '~/components/HelpText/Headers';
|
import { Header2, Header3 } from '~/components/HelpText/Headers';
|
||||||
import { SegmentKeyImportInstructions } from './SegmentKeyImportInstructions';
|
import { SegmentKeyImportInstructions } from './SegmentKeyImportInstructions';
|
||||||
import { KugouAllInstructions } from '~/features/settings/panels/Kugou/KugouAllInstructions.tsx';
|
import { KugouAllInstructions } from '~/features/kugou/instructions/KugouAllInstructions';
|
||||||
import { RiErrorWarningLine } from 'react-icons/ri';
|
import { RiErrorWarningLine } from 'react-icons/ri';
|
||||||
|
|
||||||
export function KugouFAQ() {
|
export function KugouFAQ() {
|
||||||
|
|||||||
+1
-1
@@ -2,7 +2,7 @@ import { Header2, Header3 } from '~/components/HelpText/Headers';
|
|||||||
import { VQuote } from '~/components/HelpText/VQuote';
|
import { VQuote } from '~/components/HelpText/VQuote';
|
||||||
import { SegmentTryOfficialPlayer } from './SegmentTryOfficialPlayer';
|
import { SegmentTryOfficialPlayer } from './SegmentTryOfficialPlayer';
|
||||||
import { HiWord } from '~/components/HelpText/HiWord';
|
import { HiWord } from '~/components/HelpText/HiWord';
|
||||||
import { KWMv2AllInstructions } from '~/features/settings/panels/KWMv2/KWMv2AllInstructions';
|
import { KWMv2AllInstructions } from '~/features/kwm/instructions/KWMv2AllInstructions';
|
||||||
import { SegmentKeyImportInstructions } from './SegmentKeyImportInstructions';
|
import { SegmentKeyImportInstructions } from './SegmentKeyImportInstructions';
|
||||||
import { RiErrorWarningLine } from 'react-icons/ri';
|
import { RiErrorWarningLine } from 'react-icons/ri';
|
||||||
|
|
||||||
|
|||||||
+18
-2
@@ -11,12 +11,28 @@ export function OtherFAQ() {
|
|||||||
<p>该项目进行解密处理。如果加密前的资源没有内嵌元信息或封面,解密的文件也没有。</p>
|
<p>该项目进行解密处理。如果加密前的资源没有内嵌元信息或封面,解密的文件也没有。</p>
|
||||||
<p>请使用第三方工具进行编辑或管理元信息。</p>
|
<p>请使用第三方工具进行编辑或管理元信息。</p>
|
||||||
|
|
||||||
|
<Header3 id="batch-download">批量下载约十首后失败 / 无法全部下载</Header3>
|
||||||
|
<p>
|
||||||
|
Chromium 系浏览器会限制页面在短时间内通过程序触发的<strong>多个</strong>
|
||||||
|
文件下载(常见表现为大约十个文件后静默中断,或提示「此网站正在尝试下载多个文件」)。
|
||||||
|
</p>
|
||||||
|
<p className="my-2">本站的「下载全部」会按「设定 → 通用设置 → 批量下载」中勾选的顺序尝试:</p>
|
||||||
|
<ol className="list-decimal pl-8 my-2">
|
||||||
|
<li>选择输出目录,直接写入文件(推荐,Chrome / Edge)</li>
|
||||||
|
<li>流式生成单个 ZIP 并保存</li>
|
||||||
|
<li>在内存中生成 ZIP 后触发一次下载(兼容性最好)</li>
|
||||||
|
</ol>
|
||||||
|
<p>
|
||||||
|
若全部失败会弹出提示。大批量转换也可使用
|
||||||
|
<ExtLink href="https://git.um-react.app/um/cli">命令行版本</ExtLink>。
|
||||||
|
</p>
|
||||||
|
|
||||||
<Header3 id="android-browsers">安卓: 浏览器支持说明</Header3>
|
<Header3 id="android-browsers">安卓: 浏览器支持说明</Header3>
|
||||||
<p>⚠️ 手机端浏览器支持有限,请使用最新版本的 Chrome 或 Firefox 官方浏览器。</p>
|
<p>⚠️ 手机端浏览器支持有限,请使用最新版本的 Chrome 或 Firefox 官方浏览器。</p>
|
||||||
<div className="flex flex-col md:flex-row gap-2 md:gap-8">
|
<div className="flex flex-col md:flex-row gap-2 md:gap-8">
|
||||||
<div>
|
<div>
|
||||||
<Header4>已知有问题的浏览器</Header4>
|
<Header4>已知有问题的浏览器</Header4>
|
||||||
<ul className="list-disc list-inside pl-2">
|
<ul className="list-disc pl-8">
|
||||||
<li>Via 浏览器</li>
|
<li>Via 浏览器</li>
|
||||||
<li>夸克浏览器</li>
|
<li>夸克浏览器</li>
|
||||||
<li>UC 浏览器</li>
|
<li>UC 浏览器</li>
|
||||||
@@ -25,7 +41,7 @@ export function OtherFAQ() {
|
|||||||
|
|
||||||
<div>
|
<div>
|
||||||
<Header4>可能会遇到的问题包括</Header4>
|
<Header4>可能会遇到的问题包括</Header4>
|
||||||
<ul className="list-disc list-inside pl-2">
|
<ul className="list-disc pl-8">
|
||||||
<li>网页白屏</li>
|
<li>网页白屏</li>
|
||||||
<li>无法下载解密后内容</li>
|
<li>无法下载解密后内容</li>
|
||||||
<li>下载的文件名错误</li>
|
<li>下载的文件名错误</li>
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import { Header2, Header3 } from '~/components/HelpText/Headers';
|
import { Header2, Header3 } from '~/components/HelpText/Headers';
|
||||||
import { SegmentTryOfficialPlayer } from './SegmentTryOfficialPlayer';
|
import { SegmentTryOfficialPlayer } from './SegmentTryOfficialPlayer';
|
||||||
import { QMCv2QQMusicAllInstructions } from '~/features/settings/panels/QMCv2/QMCv2QQMusicAllInstructions';
|
import { QMCv2QQMusicAllInstructions } from '~/features/qmc/instructions/QMCv2QQMusicAllInstructions';
|
||||||
|
|
||||||
export function QQMusicFAQ() {
|
export function QQMusicFAQ() {
|
||||||
return (
|
return (
|
||||||
|
|||||||
@@ -26,14 +26,10 @@ export function FileError({ error, code }: FileErrorProps) {
|
|||||||
|
|
||||||
const copyError = () => {
|
const copyError = () => {
|
||||||
if (error) {
|
if (error) {
|
||||||
navigator.clipboard
|
navigator.clipboard.writeText(applyTemplate(ERROR_TEMPLATE, { summary, error })).then(
|
||||||
.writeText(applyTemplate(ERROR_TEMPLATE, { summary, error }))
|
() => toast.success('错误信息已复制到剪贴板'),
|
||||||
.then(() => {
|
(e) => toast.error(`复制错误信息失败: ${e as Error}`),
|
||||||
toast.success('错误信息已复制到剪贴板');
|
);
|
||||||
})
|
|
||||||
.catch((e) => {
|
|
||||||
toast.error(`复制错误信息失败: ${e}`);
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ import { DecryptedAudioFile, deleteFile, ProcessState } from './fileListingSlice
|
|||||||
import { useAppDispatch } from '~/hooks';
|
import { useAppDispatch } from '~/hooks';
|
||||||
import { FileError } from './FileError';
|
import { FileError } from './FileError';
|
||||||
import classNames from 'classnames';
|
import classNames from 'classnames';
|
||||||
|
import { usePlatform } from '~/platform/PlatformContext';
|
||||||
|
|
||||||
interface FileRowProps {
|
interface FileRowProps {
|
||||||
id: string;
|
id: string;
|
||||||
@@ -10,7 +11,9 @@ interface FileRowProps {
|
|||||||
|
|
||||||
export function FileRow({ id, file }: FileRowProps) {
|
export function FileRow({ id, file }: FileRowProps) {
|
||||||
const dispatch = useAppDispatch();
|
const dispatch = useAppDispatch();
|
||||||
|
const { capabilities } = usePlatform();
|
||||||
const isDecrypted = file.state === ProcessState.COMPLETE;
|
const isDecrypted = file.state === ProcessState.COMPLETE;
|
||||||
|
const showDownload = capabilities.downloadTypes.length > 0;
|
||||||
|
|
||||||
const decryptedName = file.cleanName + '.' + file.ext;
|
const decryptedName = file.cleanName + '.' + file.ext;
|
||||||
|
|
||||||
@@ -32,18 +35,20 @@ export function FileRow({ id, file }: FileRowProps) {
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="card-actions justify-end">
|
<div className="card-actions justify-end">
|
||||||
<a
|
{showDownload && (
|
||||||
href={file.decrypted}
|
<a
|
||||||
download={decryptedName}
|
href={file.decrypted}
|
||||||
title={`下载: ${decryptedName}`}
|
download={decryptedName}
|
||||||
className={classNames('btn', {
|
title={`下载: ${decryptedName}`}
|
||||||
'btn-primary': file.decrypted,
|
className={classNames('btn', {
|
||||||
'cursor-not-allowed pointer-events-none': !file.decrypted,
|
'btn-primary': file.decrypted,
|
||||||
})}
|
'cursor-not-allowed pointer-events-none': !file.decrypted,
|
||||||
data-testid="audio-download"
|
})}
|
||||||
>
|
data-testid="audio-download"
|
||||||
下载
|
>
|
||||||
</a>
|
下载
|
||||||
|
</a>
|
||||||
|
)}
|
||||||
<button type="button" className="btn btn-error" onClick={() => dispatch(deleteFile({ id }))}>
|
<button type="button" className="btn btn-error" onClick={() => dispatch(deleteFile({ id }))}>
|
||||||
删除
|
删除
|
||||||
</button>
|
</button>
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
import { createBrowserProvider } from '~/platform/browser/BrowserProvider';
|
||||||
import { renderWithProviders, screen } from '~/test-utils/test-helper';
|
import { renderWithProviders, screen } from '~/test-utils/test-helper';
|
||||||
import { untouchedFile } from './__fixture__/file-list';
|
import { untouchedFile } from './__fixture__/file-list';
|
||||||
import { FileRow } from '../FileRow';
|
import { FileRow } from '../FileRow';
|
||||||
@@ -14,4 +15,19 @@ test('should render basic title (done)', () => {
|
|||||||
renderWithProviders(<FileRow id="file://done" file={completedFile} />);
|
renderWithProviders(<FileRow id="file://done" file={completedFile} />);
|
||||||
|
|
||||||
expect(screen.getAllByTestId('file-row')).toHaveLength(1);
|
expect(screen.getAllByTestId('file-row')).toHaveLength(1);
|
||||||
|
expect(screen.getByTestId('audio-download')).toBeInTheDocument();
|
||||||
|
});
|
||||||
|
|
||||||
|
test('hides single-file download when platform has no downloadTypes', () => {
|
||||||
|
const platform = createBrowserProvider({
|
||||||
|
crypto: {
|
||||||
|
request: () => Promise.resolve(null as never),
|
||||||
|
enqueueDecrypt: () => Promise.reject(new Error('unused')),
|
||||||
|
},
|
||||||
|
downloadTypes: [],
|
||||||
|
});
|
||||||
|
|
||||||
|
renderWithProviders(<FileRow id="file://done" file={completedFile} />, { platform });
|
||||||
|
|
||||||
|
expect(screen.queryByTestId('audio-download')).not.toBeInTheDocument();
|
||||||
});
|
});
|
||||||
@@ -0,0 +1,76 @@
|
|||||||
|
import type { WorkerActionName } from '~/decrypt-worker/actions';
|
||||||
|
import { DECRYPTION_WORKER_ACTION_NAME } from '~/decrypt-worker/constants';
|
||||||
|
import type { BrowserCrypto } from '~/platform/browser/browserCrypto';
|
||||||
|
import { createBrowserProvider } from '~/platform/browser/BrowserProvider';
|
||||||
|
import { setPlatform } from '~/platform/platformSingleton';
|
||||||
|
import { setupStore } from '~/store';
|
||||||
|
import { ListingMode, ProcessState, processFile, selectFiles } from '../fileListingSlice';
|
||||||
|
import { untouchedFile } from './__fixture__/file-list';
|
||||||
|
|
||||||
|
describe('processFile', () => {
|
||||||
|
test('parses headers via platform.crypto then enqueueDecrypts', async () => {
|
||||||
|
const request = vi.fn((action: WorkerActionName) => {
|
||||||
|
if (action === 'FIND_QMC_MUSICEX_NAME') {
|
||||||
|
return Promise.resolve('track.mflac');
|
||||||
|
}
|
||||||
|
return Promise.resolve(null);
|
||||||
|
});
|
||||||
|
const enqueueDecrypt = vi.fn().mockResolvedValue({ decrypted: 'blob://out', ext: 'flac' });
|
||||||
|
const crypto: BrowserCrypto = { request, enqueueDecrypt };
|
||||||
|
setPlatform(createBrowserProvider({ crypto }));
|
||||||
|
|
||||||
|
const fileId = 'file://untouched';
|
||||||
|
const store = setupStore({
|
||||||
|
fileListing: {
|
||||||
|
files: { [fileId]: { ...untouchedFile } },
|
||||||
|
displayMode: ListingMode.LIST,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
const result = await store.dispatch(processFile({ fileId }));
|
||||||
|
|
||||||
|
expect(result.type).toBe(processFile.fulfilled.type);
|
||||||
|
expect(request).toHaveBeenCalledWith(DECRYPTION_WORKER_ACTION_NAME.FIND_QMC_MUSICEX_NAME, {
|
||||||
|
blobURI: untouchedFile.raw,
|
||||||
|
});
|
||||||
|
expect(request).toHaveBeenCalledWith(DECRYPTION_WORKER_ACTION_NAME.KUWO_PARSE_HEADER, {
|
||||||
|
blobURI: untouchedFile.raw,
|
||||||
|
});
|
||||||
|
expect(request).toHaveBeenCalledWith(DECRYPTION_WORKER_ACTION_NAME.KUGOU_PARSE_HEADER, {
|
||||||
|
blobURI: untouchedFile.raw,
|
||||||
|
});
|
||||||
|
expect(enqueueDecrypt).toHaveBeenCalledTimes(1);
|
||||||
|
const [decryptPayload, onPreProcess] = enqueueDecrypt.mock.calls[0] as [
|
||||||
|
{ fileId: string; blobURI: string; options: { fileName: string } },
|
||||||
|
() => void,
|
||||||
|
];
|
||||||
|
expect(decryptPayload).toMatchObject({
|
||||||
|
fileId,
|
||||||
|
blobURI: untouchedFile.raw,
|
||||||
|
options: { fileName: untouchedFile.fileName },
|
||||||
|
});
|
||||||
|
expect(typeof onPreProcess).toBe('function');
|
||||||
|
|
||||||
|
const file = selectFiles(store.getState())[fileId];
|
||||||
|
expect(file.state).toBe(ProcessState.COMPLETE);
|
||||||
|
expect(file.decrypted).toBe('blob://out');
|
||||||
|
expect(file.ext).toBe('flac');
|
||||||
|
});
|
||||||
|
|
||||||
|
test('rejects when file id is missing', async () => {
|
||||||
|
const crypto: BrowserCrypto = {
|
||||||
|
request: vi.fn(),
|
||||||
|
enqueueDecrypt: vi.fn(),
|
||||||
|
};
|
||||||
|
setPlatform(createBrowserProvider({ crypto }));
|
||||||
|
const store = setupStore({
|
||||||
|
fileListing: {
|
||||||
|
files: {},
|
||||||
|
displayMode: ListingMode.LIST,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
const result = await store.dispatch(processFile({ fileId: 'missing' }));
|
||||||
|
expect(result.type).toBe(processFile.rejected.type);
|
||||||
|
});
|
||||||
|
});
|
||||||
@@ -3,22 +3,13 @@ import { createAsyncThunk, createSlice } from '@reduxjs/toolkit';
|
|||||||
import type { RootState } from '~/store';
|
import type { RootState } from '~/store';
|
||||||
|
|
||||||
import { DECRYPTION_WORKER_ACTION_NAME, type DecryptionResult } from '~/decrypt-worker/constants';
|
import { DECRYPTION_WORKER_ACTION_NAME, type DecryptionResult } from '~/decrypt-worker/constants';
|
||||||
import type {
|
import type { DecryptCommandOptions } from '~/decrypt-worker/types';
|
||||||
DecryptCommandOptions,
|
|
||||||
FetchMusicExNamePayload,
|
|
||||||
ParseKugouHeaderPayload,
|
|
||||||
ParseKugouHeaderResponse,
|
|
||||||
ParseKuwoHeaderPayload,
|
|
||||||
ParseKuwoHeaderResponse,
|
|
||||||
} from '~/decrypt-worker/types';
|
|
||||||
import { decryptionQueue, workerClientBus } from '~/decrypt-worker/client';
|
|
||||||
import { DecryptErrorType } from '~/decrypt-worker/util/DecryptError';
|
import { DecryptErrorType } from '~/decrypt-worker/util/DecryptError';
|
||||||
import {
|
import { selectQMCv2KeyByFileName } from '~/features/qmc/keyLookup';
|
||||||
selectKugouKey,
|
import { selectKWMv2Key } from '~/features/kwm/keyLookup';
|
||||||
selectKWMv2Key,
|
import { selectKugouKey } from '~/features/kugou/keyLookup';
|
||||||
selectQMCv2KeyByFileName,
|
import { selectQtfmAndroidKey } from '~/features/qtfm/keyLookup';
|
||||||
selectQtfmAndroidKey,
|
import { getPlatform } from '~/platform/platformSingleton';
|
||||||
} from '../settings/settingsSelector';
|
|
||||||
import { cleanFilename } from '~/util/cleanFilename';
|
import { cleanFilename } from '~/util/cleanFilename';
|
||||||
|
|
||||||
export enum ProcessState {
|
export enum ProcessState {
|
||||||
@@ -79,28 +70,27 @@ export const processFile = createAsyncThunk<
|
|||||||
thunkAPI.dispatch(setFileAsProcessing({ id: fileId }));
|
thunkAPI.dispatch(setFileAsProcessing({ id: fileId }));
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const { crypto } = getPlatform();
|
||||||
const [qmcv2MusicExMediaFile, kuwoHdr, kugouHdr] = await Promise.all([
|
const [qmcv2MusicExMediaFile, kuwoHdr, kugouHdr] = await Promise.all([
|
||||||
workerClientBus.request<string, FetchMusicExNamePayload>(DECRYPTION_WORKER_ACTION_NAME.FIND_QMC_MUSICEX_NAME, {
|
crypto.request(DECRYPTION_WORKER_ACTION_NAME.FIND_QMC_MUSICEX_NAME, {
|
||||||
|
blobURI: file.raw,
|
||||||
|
}),
|
||||||
|
crypto.request(DECRYPTION_WORKER_ACTION_NAME.KUWO_PARSE_HEADER, {
|
||||||
|
blobURI: file.raw,
|
||||||
|
}),
|
||||||
|
crypto.request(DECRYPTION_WORKER_ACTION_NAME.KUGOU_PARSE_HEADER, {
|
||||||
blobURI: file.raw,
|
blobURI: file.raw,
|
||||||
}),
|
}),
|
||||||
workerClientBus.request<ParseKuwoHeaderResponse, ParseKuwoHeaderPayload>(
|
|
||||||
DECRYPTION_WORKER_ACTION_NAME.KUWO_PARSE_HEADER,
|
|
||||||
{ blobURI: file.raw },
|
|
||||||
),
|
|
||||||
workerClientBus.request<ParseKugouHeaderResponse, ParseKugouHeaderPayload>(
|
|
||||||
DECRYPTION_WORKER_ACTION_NAME.KUGOU_PARSE_HEADER,
|
|
||||||
{ blobURI: file.raw },
|
|
||||||
),
|
|
||||||
]);
|
]);
|
||||||
|
|
||||||
const options: DecryptCommandOptions = {
|
const options: DecryptCommandOptions = {
|
||||||
fileName: file.fileName,
|
fileName: file.fileName,
|
||||||
qmc2Key: selectQMCv2KeyByFileName(state, qmcv2MusicExMediaFile || file.fileName),
|
qmc2Key: selectQMCv2KeyByFileName(state, qmcv2MusicExMediaFile || file.fileName),
|
||||||
kwm2key: selectKWMv2Key(state, kuwoHdr),
|
kwm2Key: selectKWMv2Key(state, kuwoHdr),
|
||||||
kugouKey: selectKugouKey(state, kugouHdr),
|
kugouKey: selectKugouKey(state, kugouHdr),
|
||||||
qingTingAndroidKey: selectQtfmAndroidKey(state),
|
qingTingAndroidKey: selectQtfmAndroidKey(state),
|
||||||
};
|
};
|
||||||
return decryptionQueue.add({ id: fileId, blobURI: file.raw, options }, onPreProcess);
|
return crypto.enqueueDecrypt({ fileId, blobURI: file.raw, options }, onPreProcess);
|
||||||
});
|
});
|
||||||
|
|
||||||
export const fileListingSlice = createSlice({
|
export const fileListingSlice = createSlice({
|
||||||
|
|||||||
@@ -0,0 +1,35 @@
|
|||||||
|
import { configureStore } from '@reduxjs/toolkit';
|
||||||
|
|
||||||
|
import settingsReducer, { settingsSlice } from '~/features/settings/settingsSlice';
|
||||||
|
import type { RootState } from '~/store';
|
||||||
|
import { selectKugouKey } from '../keyLookup';
|
||||||
|
|
||||||
|
function storeWithKugouKeys(keys: Record<string, string>) {
|
||||||
|
const base = settingsSlice.getInitialState();
|
||||||
|
return configureStore({
|
||||||
|
reducer: { settings: settingsReducer },
|
||||||
|
preloadedState: {
|
||||||
|
settings: {
|
||||||
|
...base,
|
||||||
|
production: {
|
||||||
|
...base.production,
|
||||||
|
kugou: { keys },
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
describe('selectKugouKey', () => {
|
||||||
|
test('returns key for matching audioHash', () => {
|
||||||
|
const hash = 'a'.repeat(32);
|
||||||
|
const store = storeWithKugouKeys({ [hash]: 'ek' });
|
||||||
|
expect(selectKugouKey(store.getState() as RootState, { audioHash: hash } as never)).toBe('ek');
|
||||||
|
});
|
||||||
|
|
||||||
|
test('returns undefined for unknown hash or null header', () => {
|
||||||
|
const store = storeWithKugouKeys({ ['b'.repeat(32)]: 'ek' });
|
||||||
|
expect(selectKugouKey(store.getState() as RootState, { audioHash: 'c'.repeat(32) } as never)).toBeUndefined();
|
||||||
|
expect(selectKugouKey(store.getState() as RootState, null)).toBeUndefined();
|
||||||
|
});
|
||||||
|
});
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
import { DatabaseKeyExtractor } from '~/util/DatabaseKeyExtractor';
|
||||||
|
import { parseAndroidKugouMMKV } from '~/util/mmkv/kugou';
|
||||||
|
import type { StagingKugouKey } from './types';
|
||||||
|
|
||||||
|
/** Parse a Kugou MMKV / encrypted DB dump into staging key rows (without `id`). */
|
||||||
|
export async function importKugouKeysFromFile(file: File): Promise<null | Omit<StagingKugouKey, 'id'>[]> {
|
||||||
|
if (/mggkey_multi_process/i.test(file.name)) {
|
||||||
|
return parseAndroidKugouMMKV(new DataView(await file.arrayBuffer()));
|
||||||
|
}
|
||||||
|
if (/^KGMusicV3\.db$/.test(file.name)) {
|
||||||
|
const extractor = await DatabaseKeyExtractor.getInstance();
|
||||||
|
return extractor.extractKugouKeyFromEncryptedDb(await file.arrayBuffer());
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
+3
-12
@@ -1,20 +1,11 @@
|
|||||||
import { RiFileCopyLine } from 'react-icons/ri';
|
import { RiFileCopyLine } from 'react-icons/ri';
|
||||||
import { toast } from 'react-toastify';
|
|
||||||
import { ExtLink } from '~/components/ExtLink';
|
import { ExtLink } from '~/components/ExtLink';
|
||||||
import { FilePathBlock } from '~/components/FilePathBlock.tsx';
|
import { FilePathBlock } from '~/components/FilePathBlock.tsx';
|
||||||
|
import { copyToClipboard } from '~/util/clipboard';
|
||||||
|
|
||||||
|
const DB_PATH = '%APPDATA%\\KuGou8\\KGMusicV3.db';
|
||||||
export function InstructionsPC() {
|
export function InstructionsPC() {
|
||||||
const DB_PATH = '%APPDATA%\\KuGou8\\KGMusicV3.db';
|
const copyDbPathToClipboard = () => copyToClipboard(DB_PATH);
|
||||||
const copyDbPathToClipboard = () => {
|
|
||||||
navigator.clipboard
|
|
||||||
.writeText(DB_PATH)
|
|
||||||
.then(() => {
|
|
||||||
toast.success('已复制到剪贴板');
|
|
||||||
})
|
|
||||||
.catch((err) => {
|
|
||||||
toast.error(`复制失败,请手动复制\n${err}`);
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
File renamed without changes.
@@ -0,0 +1,19 @@
|
|||||||
|
import type { RootState } from '~/store';
|
||||||
|
import type { ParseKugouHeaderResponse } from '~/decrypt-worker/types.ts';
|
||||||
|
import { hasOwn } from '~/util/objects';
|
||||||
|
|
||||||
|
/** Staging KuGou/KGG keys (`state.settings.staging.kugou`; UI tab `kgg`). */
|
||||||
|
export const selectStagingKugouV5Keys = (state: RootState) => state.settings.staging.kugou.keys;
|
||||||
|
/** Production KuGou/KGG keys (`state.settings.production.kugou`; persist key `kugou`). */
|
||||||
|
export const selectFinalKugouV5Keys = (state: RootState) => state.settings.production.kugou.keys;
|
||||||
|
|
||||||
|
export const selectKugouKey = (state: RootState, hdr: ParseKugouHeaderResponse): string | undefined => {
|
||||||
|
if (!hdr) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const keys = selectFinalKugouV5Keys(state);
|
||||||
|
const lookupKey = hdr.audioHash;
|
||||||
|
|
||||||
|
return hasOwn(keys, lookupKey) ? keys[lookupKey] : undefined;
|
||||||
|
};
|
||||||
+2
-2
@@ -1,7 +1,7 @@
|
|||||||
import { kugouDeleteKey, kugouUpdateKey } from '../../settingsSlice';
|
import { kugouDeleteKey, kugouUpdateKey } from '~/features/settings/settingsSlice';
|
||||||
import { useAppDispatch } from '~/hooks';
|
import { useAppDispatch } from '~/hooks';
|
||||||
import { memo } from 'react';
|
import { memo } from 'react';
|
||||||
import { StagingKugouKey } from '../../keyFormats';
|
import type { StagingKugouKey } from '~/features/kugou/types';
|
||||||
import { KeyInput } from '~/components/KeyInput';
|
import { KeyInput } from '~/components/KeyInput';
|
||||||
|
|
||||||
export const KugouEKeyItem = memo(({ id, ekey, audioHash, i }: StagingKugouKey & { i: number }) => {
|
export const KugouEKeyItem = memo(({ id, ekey, audioHash, i }: StagingKugouKey & { i: number }) => {
|
||||||
+6
-15
@@ -2,15 +2,12 @@ import { useRef, useState } from 'react';
|
|||||||
import { useDispatch, useSelector } from 'react-redux';
|
import { useDispatch, useSelector } from 'react-redux';
|
||||||
|
|
||||||
import { ImportSecretModal } from '~/components/ImportSecretModal';
|
import { ImportSecretModal } from '~/components/ImportSecretModal';
|
||||||
|
import { kugouAddKey, kugouClearKeys, kugouImportKeys } from '~/features/settings/settingsSlice';
|
||||||
import { kugouAddKey, kugouClearKeys, kugouImportKeys } from '../settingsSlice';
|
import { selectStagingKugouV5Keys } from '~/features/kugou/keyLookup';
|
||||||
import { selectStagingKugouV5Keys } from '../settingsSelector';
|
|
||||||
import type { StagingKugouKey } from '../keyFormats';
|
|
||||||
import { AddKey } from '~/components/AddKey.tsx';
|
import { AddKey } from '~/components/AddKey.tsx';
|
||||||
import { KugouEKeyItem } from '~/features/settings/panels/Kugou/KugouEKeyItem.tsx';
|
import { KugouEKeyItem } from './KugouEKeyItem';
|
||||||
import { KugouAllInstructions } from '~/features/settings/panels/Kugou/KugouAllInstructions.tsx';
|
import { KugouAllInstructions } from '~/features/kugou/instructions/KugouAllInstructions';
|
||||||
import { parseAndroidKugouMMKV } from '~/util/mmkv/kugou.ts';
|
import { importKugouKeysFromFile } from '~/features/kugou/importKeys';
|
||||||
import { DatabaseKeyExtractor } from '~/util/DatabaseKeyExtractor.ts';
|
|
||||||
import { KeyListContainer } from '~/components/KeyListContainer';
|
import { KeyListContainer } from '~/components/KeyListContainer';
|
||||||
import { toastImportResult } from '~/util/toastImportResult';
|
import { toastImportResult } from '~/util/toastImportResult';
|
||||||
|
|
||||||
@@ -22,13 +19,7 @@ export function PanelKGGKey() {
|
|||||||
const addKey = () => dispatch(kugouAddKey());
|
const addKey = () => dispatch(kugouAddKey());
|
||||||
const clearAll = () => dispatch(kugouClearKeys());
|
const clearAll = () => dispatch(kugouClearKeys());
|
||||||
const handleSecretImport = async (file: File) => {
|
const handleSecretImport = async (file: File) => {
|
||||||
let keys: Omit<StagingKugouKey, 'id'>[] | null = null;
|
const keys = await importKugouKeysFromFile(file);
|
||||||
if (/mggkey_multi_process/i.test(file.name)) {
|
|
||||||
keys = parseAndroidKugouMMKV(new DataView(await file.arrayBuffer()));
|
|
||||||
} else if (/^KGMusicV3\.db$/.test(file.name)) {
|
|
||||||
const extractor = await DatabaseKeyExtractor.getInstance();
|
|
||||||
keys = extractor.extractKugouKeyFromEncryptedDb(await file.arrayBuffer());
|
|
||||||
}
|
|
||||||
|
|
||||||
if (keys && keys.length > 0) {
|
if (keys && keys.length > 0) {
|
||||||
dispatch(kugouImportKeys(keys));
|
dispatch(kugouImportKeys(keys));
|
||||||
@@ -0,0 +1,22 @@
|
|||||||
|
import { nanoid } from 'nanoid';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* KuGou / KGG (kgm v5).
|
||||||
|
* UI settings tab route: `kgg`. Redux + localStorage production field: `kugou`.
|
||||||
|
*/
|
||||||
|
export interface StagingKugouKey {
|
||||||
|
id: string;
|
||||||
|
audioHash: string;
|
||||||
|
ekey: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export type ProductionKugouKey = Record<string /* audioHash */, string /* ekey */>;
|
||||||
|
export const kugouStagingToProductionKey = (key: StagingKugouKey) => key.audioHash.normalize();
|
||||||
|
export const kugouStagingToProductionValue = (key: StagingKugouKey) => key.ekey.normalize();
|
||||||
|
export const kugouProductionToStaging = (
|
||||||
|
key: keyof ProductionKugouKey,
|
||||||
|
value: ProductionKugouKey[keyof ProductionKugouKey],
|
||||||
|
): null | StagingKugouKey => {
|
||||||
|
if (typeof value !== 'string') return null;
|
||||||
|
return { id: nanoid(), audioHash: key.normalize(), ekey: value };
|
||||||
|
};
|
||||||
@@ -0,0 +1,32 @@
|
|||||||
|
import { readFileSync } from 'node:fs';
|
||||||
|
import { dirname, join } from 'node:path';
|
||||||
|
import { fileURLToPath } from 'node:url';
|
||||||
|
|
||||||
|
import { importKWMv2KeysFromFile } from '../importKeys';
|
||||||
|
|
||||||
|
const fixtureDir = join(dirname(fileURLToPath(import.meta.url)), '../../../util/mmkv/__tests__/__fixture__');
|
||||||
|
|
||||||
|
function fileFromFixture(name: string, path: string): File {
|
||||||
|
const buff = readFileSync(path);
|
||||||
|
return new File([buff], name);
|
||||||
|
}
|
||||||
|
|
||||||
|
describe('importKWMv2KeysFromFile', () => {
|
||||||
|
test('parses Android Kuwo MMKV by filename', async () => {
|
||||||
|
const file = fileFromFixture('cn.kuwo.player.mmkv.defaultconfig', join(fixtureDir, 'kuwo_android.mmkv'));
|
||||||
|
await expect(importKWMv2KeysFromFile(file)).resolves.toEqual([
|
||||||
|
{ rid: '1234567', quality: '20201kmflac', ekey: 'xyz123' },
|
||||||
|
]);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('parses iOS Kuwo ekey dump by filename', async () => {
|
||||||
|
const file = fileFromFixture('kw_ekey', join(fixtureDir, 'kuwo_ios.mmkv'));
|
||||||
|
await expect(importKWMv2KeysFromFile(file)).resolves.toEqual([
|
||||||
|
{ rid: '1234567', quality: '20201', ekey: 'xyz123' },
|
||||||
|
]);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('returns null for unrecognized filenames', async () => {
|
||||||
|
await expect(importKWMv2KeysFromFile(new File([], 'notes.txt'))).resolves.toBeNull();
|
||||||
|
});
|
||||||
|
});
|
||||||
@@ -0,0 +1,13 @@
|
|||||||
|
import { parseAndroidKuwoEKey, parseIosKuwoEKey } from '~/util/mmkv/kuwo';
|
||||||
|
import type { StagingKWMv2Key } from './types';
|
||||||
|
|
||||||
|
/** Parse a Kuwo MMKV / iOS ekey dump into staging key rows (without `id`). */
|
||||||
|
export async function importKWMv2KeysFromFile(file: File): Promise<null | Omit<StagingKWMv2Key, 'id'>[]> {
|
||||||
|
if (/cn\.kuwo\.player\.mmkv/i.test(file.name)) {
|
||||||
|
return parseAndroidKuwoEKey(new DataView(await file.arrayBuffer()));
|
||||||
|
}
|
||||||
|
if (/kw_ekey/.test(file.name)) {
|
||||||
|
return parseIosKuwoEKey(new DataView(await file.arrayBuffer()));
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
File renamed without changes.
File renamed without changes.
File renamed without changes.
@@ -0,0 +1,26 @@
|
|||||||
|
import type { RootState } from '~/store';
|
||||||
|
import type { ParseKuwoHeaderResponse } from '~/decrypt-worker/types.ts';
|
||||||
|
import { hasOwn } from '~/util/objects';
|
||||||
|
import { kwm2StagingToProductionKey } from './types';
|
||||||
|
|
||||||
|
export const selectStagingKWMv2Keys = (state: RootState) => state.settings.staging.kwm2.keys;
|
||||||
|
export const selectFinalKWMv2Keys = (state: RootState) => state.settings.production.kwm2.keys;
|
||||||
|
|
||||||
|
export const selectKWMv2Key = (state: RootState, hdr: ParseKuwoHeaderResponse): string | undefined => {
|
||||||
|
if (!hdr) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const quality = String(hdr.qualityId);
|
||||||
|
const rid = String(hdr.resourceId);
|
||||||
|
|
||||||
|
const keys = selectFinalKWMv2Keys(state);
|
||||||
|
const lookupKey = kwm2StagingToProductionKey({ id: '', ekey: '', quality, rid });
|
||||||
|
|
||||||
|
let ekey: string | undefined;
|
||||||
|
if (hasOwn(keys, lookupKey)) {
|
||||||
|
ekey = keys[lookupKey];
|
||||||
|
}
|
||||||
|
|
||||||
|
return ekey;
|
||||||
|
};
|
||||||
+2
-2
@@ -1,8 +1,8 @@
|
|||||||
import { PiFileAudio, PiHash } from 'react-icons/pi';
|
import { PiFileAudio, PiHash } from 'react-icons/pi';
|
||||||
import { kwm2DeleteKey, kwm2UpdateKey } from '../../settingsSlice';
|
import { kwm2DeleteKey, kwm2UpdateKey } from '~/features/settings/settingsSlice';
|
||||||
import { useAppDispatch } from '~/hooks';
|
import { useAppDispatch } from '~/hooks';
|
||||||
import { memo } from 'react';
|
import { memo } from 'react';
|
||||||
import { StagingKWMv2Key } from '../../keyFormats';
|
import type { StagingKWMv2Key } from '~/features/kwm/types';
|
||||||
import { KeyInput } from '~/components/KeyInput';
|
import { KeyInput } from '~/components/KeyInput';
|
||||||
|
|
||||||
export const KWMv2EKeyItem = memo(({ id, ekey, quality, rid, i }: StagingKWMv2Key & { i: number }) => {
|
export const KWMv2EKeyItem = memo(({ id, ekey, quality, rid, i }: StagingKWMv2Key & { i: number }) => {
|
||||||
+6
-13
@@ -2,13 +2,11 @@ import { useRef, useState } from 'react';
|
|||||||
import { useDispatch, useSelector } from 'react-redux';
|
import { useDispatch, useSelector } from 'react-redux';
|
||||||
|
|
||||||
import { ImportSecretModal } from '~/components/ImportSecretModal';
|
import { ImportSecretModal } from '~/components/ImportSecretModal';
|
||||||
import { parseAndroidKuwoEKey, parseIosKuwoEKey } from '~/util/mmkv/kuwo';
|
import { kwm2AddKey, kwm2ClearKeys, kwm2ImportKeys } from '~/features/settings/settingsSlice';
|
||||||
|
import { selectStagingKWMv2Keys } from '~/features/kwm/keyLookup';
|
||||||
import { kwm2AddKey, kwm2ClearKeys, kwm2ImportKeys } from '../settingsSlice';
|
import { KWMv2EKeyItem } from './KWMv2EKeyItem';
|
||||||
import { selectStagingKWMv2Keys } from '../settingsSelector';
|
import { importKWMv2KeysFromFile } from '~/features/kwm/importKeys';
|
||||||
import { KWMv2EKeyItem } from './KWMv2/KWMv2EKeyItem';
|
import { KWMv2AllInstructions } from '~/features/kwm/instructions/KWMv2AllInstructions';
|
||||||
import type { StagingKWMv2Key } from '../keyFormats';
|
|
||||||
import { KWMv2AllInstructions } from './KWMv2/KWMv2AllInstructions';
|
|
||||||
import { AddKey } from '~/components/AddKey';
|
import { AddKey } from '~/components/AddKey';
|
||||||
import { KeyListContainer } from '~/components/KeyListContainer';
|
import { KeyListContainer } from '~/components/KeyListContainer';
|
||||||
import { toastImportResult } from '~/util/toastImportResult';
|
import { toastImportResult } from '~/util/toastImportResult';
|
||||||
@@ -21,12 +19,7 @@ export function PanelKWMv2Key() {
|
|||||||
const addKey = () => dispatch(kwm2AddKey());
|
const addKey = () => dispatch(kwm2AddKey());
|
||||||
const clearAll = () => dispatch(kwm2ClearKeys());
|
const clearAll = () => dispatch(kwm2ClearKeys());
|
||||||
const handleSecretImport = async (file: File) => {
|
const handleSecretImport = async (file: File) => {
|
||||||
let keys: Omit<StagingKWMv2Key, 'id'>[] | null = null;
|
const keys = await importKWMv2KeysFromFile(file);
|
||||||
if (/cn\.kuwo\.player\.mmkv/i.test(file.name)) {
|
|
||||||
keys = parseAndroidKuwoEKey(new DataView(await file.arrayBuffer()));
|
|
||||||
} else if (/kw_ekey/.test(file.name)) {
|
|
||||||
keys = parseIosKuwoEKey(new DataView(await file.arrayBuffer()));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (keys && keys.length > 0) {
|
if (keys && keys.length > 0) {
|
||||||
dispatch(kwm2ImportKeys(keys));
|
dispatch(kwm2ImportKeys(keys));
|
||||||
@@ -0,0 +1,39 @@
|
|||||||
|
import { nanoid } from 'nanoid';
|
||||||
|
|
||||||
|
/** KWMv2 staging key row (Kuwo). */
|
||||||
|
export interface StagingKWMv2Key {
|
||||||
|
id: string;
|
||||||
|
/**
|
||||||
|
* Resource ID
|
||||||
|
*/
|
||||||
|
rid: string;
|
||||||
|
/**
|
||||||
|
* Quality String
|
||||||
|
*/
|
||||||
|
quality: string;
|
||||||
|
ekey: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export type ProductionKWMv2Keys = Record<string /* `${rid}-${quality}` */, string /* ekey */>;
|
||||||
|
|
||||||
|
export const parseKwm2ProductionKey = (key: string): null | { rid: string; quality: string } => {
|
||||||
|
const m = key.match(/^(\d+)-(\w+)$/);
|
||||||
|
if (!m) return null;
|
||||||
|
const [_, rid, quality] = m;
|
||||||
|
|
||||||
|
return { rid, quality };
|
||||||
|
};
|
||||||
|
export const kwm2StagingToProductionKey = (key: StagingKWMv2Key) => `${key.rid}-${key.quality.replace(/\D/g, '')}`;
|
||||||
|
export const kwm2StagingToProductionValue = (key: StagingKWMv2Key) => key.ekey;
|
||||||
|
export const kwm2ProductionToStaging = (
|
||||||
|
key: keyof ProductionKWMv2Keys,
|
||||||
|
value: ProductionKWMv2Keys[keyof ProductionKWMv2Keys],
|
||||||
|
): null | StagingKWMv2Key => {
|
||||||
|
if (typeof value !== 'string') return null;
|
||||||
|
|
||||||
|
const parsed = parseKwm2ProductionKey(key);
|
||||||
|
if (!parsed) return null;
|
||||||
|
const { quality, rid } = parsed;
|
||||||
|
|
||||||
|
return { id: nanoid(), rid, quality, ekey: value };
|
||||||
|
};
|
||||||
@@ -0,0 +1,38 @@
|
|||||||
|
import { configureStore } from '@reduxjs/toolkit';
|
||||||
|
|
||||||
|
import settingsReducer, { settingsSlice } from '~/features/settings/settingsSlice';
|
||||||
|
import type { RootState } from '~/store';
|
||||||
|
import { selectQMCv2KeyByFileName } from '../keyLookup';
|
||||||
|
|
||||||
|
function storeWithQmcKeys(keys: Record<string, string>, allowFuzzyNameSearch = true) {
|
||||||
|
const base = settingsSlice.getInitialState();
|
||||||
|
return configureStore({
|
||||||
|
reducer: { settings: settingsReducer },
|
||||||
|
preloadedState: {
|
||||||
|
settings: {
|
||||||
|
...base,
|
||||||
|
production: {
|
||||||
|
...base.production,
|
||||||
|
qmc2: { allowFuzzyNameSearch, keys },
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
describe('selectQMCv2KeyByFileName', () => {
|
||||||
|
test('returns exact match', () => {
|
||||||
|
const store = storeWithQmcKeys({ 'song.mflac': 'ek-exact' });
|
||||||
|
expect(selectQMCv2KeyByFileName(store.getState() as RootState, 'song.mflac')).toBe('ek-exact');
|
||||||
|
});
|
||||||
|
|
||||||
|
test('falls back to closest name when fuzzy search is enabled', () => {
|
||||||
|
const store = storeWithQmcKeys({ 'song.mflac': 'ek-fuzzy' });
|
||||||
|
expect(selectQMCv2KeyByFileName(store.getState() as RootState, 'songg.mflac')).toBe('ek-fuzzy');
|
||||||
|
});
|
||||||
|
|
||||||
|
test('returns undefined when fuzzy search is disabled and name misses', () => {
|
||||||
|
const store = storeWithQmcKeys({ 'song.mflac': 'ek' }, false);
|
||||||
|
expect(selectQMCv2KeyByFileName(store.getState() as RootState, 'other.mflac')).toBeUndefined();
|
||||||
|
});
|
||||||
|
});
|
||||||
@@ -0,0 +1,21 @@
|
|||||||
|
import { DatabaseKeyExtractor } from '~/util/DatabaseKeyExtractor';
|
||||||
|
import { parseAndroidQmEKey } from '~/util/mmkv/qm';
|
||||||
|
import { getFileName } from '~/util/pathHelper';
|
||||||
|
import type { StagingQMCv2Key } from './types';
|
||||||
|
|
||||||
|
/** Parse a QMCv2 key database / MMKV dump into staging key rows (without `id`). */
|
||||||
|
export async function importQMCv2KeysFromFile(file: File): Promise<null | Omit<StagingQMCv2Key, 'id'>[]> {
|
||||||
|
const fileBuffer = await file.arrayBuffer();
|
||||||
|
|
||||||
|
if (/(player_process[_.]db|music_audio_play)(\.db)?$/i.test(file.name)) {
|
||||||
|
const extractor = await DatabaseKeyExtractor.getInstance();
|
||||||
|
return extractor.extractQmcV2KeysFromSqliteDb(fileBuffer);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (/MMKVStreamEncryptId|filenameEkeyMap|qmpc-mmkv-v1|(\.mmkv$)/i.test(file.name)) {
|
||||||
|
const map = parseAndroidQmEKey(new DataView(fileBuffer));
|
||||||
|
return Array.from(map.entries(), ([name, ekey]) => ({ name: getFileName(name), ekey }));
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
File renamed without changes.
File renamed without changes.
@@ -0,0 +1,31 @@
|
|||||||
|
import { useId } from 'react';
|
||||||
|
import { InstructionsMacV8 } from './InstructionsMacV8';
|
||||||
|
import { InstructionsMacV10 } from './InstructionsMacV10';
|
||||||
|
|
||||||
|
export function InstructionsMac() {
|
||||||
|
const macInstructionId = useId();
|
||||||
|
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
<p>Mac 客户端使用 mmkv 数据库储存密钥。</p>
|
||||||
|
<p>建议使用 v8.8.0 或 v10.7 版本的客户端,其中 v8.8.0 版本需要屏蔽更新。</p>
|
||||||
|
|
||||||
|
<div className="join join-vertical bg-base-100 mt-2 max-w-full">
|
||||||
|
<div className="collapse collapse-arrow join-item border-base-300 border">
|
||||||
|
<input type="radio" name={macInstructionId} />
|
||||||
|
<div className="collapse-title font-semibold">使用 QQ 音乐 Mac v8.8.0</div>
|
||||||
|
<div className="collapse-content text-sm min-w-0">
|
||||||
|
<InstructionsMacV8 />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div className="collapse collapse-arrow join-item border-base-300 border">
|
||||||
|
<input type="radio" name={macInstructionId} />
|
||||||
|
<div className="collapse-title font-semibold">使用 QQ 音乐 Mac v10.7.1</div>
|
||||||
|
<div className="collapse-content text-sm min-w-0">
|
||||||
|
<InstructionsMacV10 />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -0,0 +1,65 @@
|
|||||||
|
import { ExtLink } from '~/components/ExtLink';
|
||||||
|
|
||||||
|
import {
|
||||||
|
commandName as DUMP_COMMAND_NAME,
|
||||||
|
tarName as DUMP_COMMAND_TARBALL_NAME,
|
||||||
|
tarball as DUMP_COMMAND_BASE64,
|
||||||
|
} from './assets/qqmusic_v10.7_dump.command?&name=QQ 音乐 Mac v10 密钥提取.command&mac-command';
|
||||||
|
import { DownloadBase64 } from '~/components/DownloadBase64';
|
||||||
|
import { VQuote } from '~/components/HelpText/VQuote';
|
||||||
|
import { InSecretImportModalContext } from '~/context/InSecretImportModal';
|
||||||
|
import { useContext } from 'react';
|
||||||
|
|
||||||
|
const MAC_CLIENT_URL =
|
||||||
|
'https://c.y.qq.com/cgi-bin/file_redirect.fcg?bid=dldir&file=ecosfile%2Fmusic_clntupate%2Fmac%2Fother%2FQQMusicMac10.7.1Build00.dmg&sign=1-0cb9ee4c40e7447e2113cfdee2dc11c88487b0e31fe37cfe1c59e12c20956dce-689e9373';
|
||||||
|
const MAC_CLIENT_TG_URL = 'https://t.me/um_lsr_ch/30';
|
||||||
|
|
||||||
|
export function InstructionsMacV10() {
|
||||||
|
const inSecretImportModal = useContext(InSecretImportModalContext);
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
<p className="mt-4">获取 QQ 音乐 Mac 客户端 10.7.1:</p>
|
||||||
|
<ul className="list-disc pl-6">
|
||||||
|
<li>
|
||||||
|
<ExtLink className="link-info" href={MAC_CLIENT_URL}>
|
||||||
|
通过 QQ 音乐官网下载(高速,但可能失效)
|
||||||
|
</ExtLink>
|
||||||
|
</li>
|
||||||
|
<li>
|
||||||
|
<ExtLink className="link-info" href={MAC_CLIENT_TG_URL}>
|
||||||
|
通过 Telegram 下载(缓存,需要账号)
|
||||||
|
</ExtLink>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
<h4 className="font-bold text-lg mt-4">导入密钥</h4>
|
||||||
|
<ol className="list-decimal pl-6">
|
||||||
|
<li>
|
||||||
|
下载 <DownloadBase64 data={DUMP_COMMAND_BASE64} filename={DUMP_COMMAND_TARBALL_NAME}></DownloadBase64>
|
||||||
|
,打开得到 <code>{DUMP_COMMAND_NAME}</code>。
|
||||||
|
</li>
|
||||||
|
<li>
|
||||||
|
<p>
|
||||||
|
双击 <code>{DUMP_COMMAND_NAME}</code> 执行。
|
||||||
|
</p>
|
||||||
|
<p>
|
||||||
|
※ 若是提示文件来自未知开发者,请右键点击该文件,选择菜单第一项
|
||||||
|
<VQuote>打开</VQuote>,在警告窗口再次选择<VQuote>打开</VQuote>。
|
||||||
|
</p>
|
||||||
|
</li>
|
||||||
|
<li>
|
||||||
|
运行后会在脚本当前目录生成 <code>qqmusic-mac-*.mmkv</code> 文件,其中 <code>*</code> 是一串随机字符。
|
||||||
|
</li>
|
||||||
|
{inSecretImportModal ? (
|
||||||
|
<li>
|
||||||
|
上传刚生成的 <code>qqmusic-mac-*.mmkv</code> 文件到上方的<VQuote>文件选择区域</VQuote>。
|
||||||
|
</li>
|
||||||
|
) : (
|
||||||
|
<li>
|
||||||
|
前往设定页面,提交生成的 <code>qqmusic-mac-*.mmkv</code> 文件。
|
||||||
|
</li>
|
||||||
|
)}
|
||||||
|
</ol>
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -0,0 +1,89 @@
|
|||||||
|
import { RiFileCopyLine } from 'react-icons/ri';
|
||||||
|
import { ExtLink } from '~/components/ExtLink';
|
||||||
|
import { FilePathBlock } from '~/components/FilePathBlock';
|
||||||
|
import { VQuote } from '~/components/HelpText/VQuote';
|
||||||
|
import { MacCommandKey } from '~/components/Key/MacCommandKey';
|
||||||
|
import { ShiftKey } from '~/components/Key/ShiftKey';
|
||||||
|
import { copyToClipboard } from '~/util/clipboard';
|
||||||
|
|
||||||
|
import {
|
||||||
|
commandName as BLOCK_UPDATE_COMAND,
|
||||||
|
tarName as BLOCK_UPDATE_TAR_NAME,
|
||||||
|
tarball as BLOCK_UPDATE_BASE64,
|
||||||
|
} from './assets/qqmusic_v8.8.0_patch_update.command?&name=QQ 音乐 Mac v8.8.0 屏蔽更新.command&mac-command';
|
||||||
|
import { DownloadBase64 } from '~/components/DownloadBase64';
|
||||||
|
import { useContext } from 'react';
|
||||||
|
import { InSecretImportModalContext } from '~/context/InSecretImportModal';
|
||||||
|
|
||||||
|
const MAC_CLIENT_URL =
|
||||||
|
'https://web.archive.org/web/20230903/https://dldir1.qq.com/music/clntupate/mac/QQMusicMac_Mgr.dmg';
|
||||||
|
const MAC_CLIENT_TG_URL = 'https://t.me/um_lsr_ch/21';
|
||||||
|
const DB_PATH =
|
||||||
|
'~/Library/Containers/com.tencent.QQMusicMac/Data/Library/Application Support/QQMusicMac/mmkv/MMKVStreamEncryptId';
|
||||||
|
|
||||||
|
export function InstructionsMacV8() {
|
||||||
|
const inSecretImportModal = useContext(InSecretImportModalContext);
|
||||||
|
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
<p className="mt-4">获取 QQ 音乐 Mac 客户端 8.8.0:</p>
|
||||||
|
<ul className="list-disc pl-6">
|
||||||
|
<li>
|
||||||
|
<ExtLink className="link-info" href={MAC_CLIENT_URL}>
|
||||||
|
通过 <code>Archive.org</code> 缓存下载(慢)
|
||||||
|
</ExtLink>
|
||||||
|
</li>
|
||||||
|
<li>
|
||||||
|
<ExtLink className="link-info" href={MAC_CLIENT_TG_URL}>
|
||||||
|
通过 Telegram 下载(需要账号)
|
||||||
|
</ExtLink>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
<p className="mt-4">
|
||||||
|
部分用户可能会被强制要求更新。你可以下载
|
||||||
|
<DownloadBase64 filename={BLOCK_UPDATE_TAR_NAME} data={BLOCK_UPDATE_BASE64}></DownloadBase64>
|
||||||
|
并执行 <code>{BLOCK_UPDATE_COMAND}</code>。
|
||||||
|
<span>其原理是修改 QQ 音乐的版本号,让其认为自己是最新版本,从而达到屏蔽更新的效果。</span>
|
||||||
|
</p>
|
||||||
|
<p>
|
||||||
|
※ 若是提示文件来自未知开发者,请右键点击该文件,选择菜单第一项
|
||||||
|
<VQuote>打开</VQuote>,在警告窗口再次选择<VQuote>打开</VQuote>。
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<p className="mt-4">密钥文件通常存储在下述路径:</p>
|
||||||
|
<FilePathBlock>{DB_PATH}</FilePathBlock>
|
||||||
|
|
||||||
|
<h4 className="font-bold text-lg mt-4">导入密钥</h4>
|
||||||
|
<ol className="list-decimal pl-6">
|
||||||
|
<li>
|
||||||
|
<button className="btn btn-sm btn-outline btn-accent mr-2" onClick={() => copyToClipboard(DB_PATH)}>
|
||||||
|
<RiFileCopyLine className="text-xl" />
|
||||||
|
<span>复制</span>
|
||||||
|
</button>
|
||||||
|
<code>MMKVStreamEncryptId</code> 文件路径
|
||||||
|
</li>
|
||||||
|
<li>
|
||||||
|
{inSecretImportModal ? (
|
||||||
|
<p>
|
||||||
|
点击上方的<VQuote>文件选择区域</VQuote>,打开<VQuote>文件选择框</VQuote>
|
||||||
|
</p>
|
||||||
|
) : (
|
||||||
|
<p>前往设定页面,提交该密钥文件。</p>
|
||||||
|
)}
|
||||||
|
<p>
|
||||||
|
※ 你可以在文件选择对话框按下
|
||||||
|
<VQuote>
|
||||||
|
<ShiftKey className="mx-1" />
|
||||||
|
{'+'}
|
||||||
|
<MacCommandKey className="mx-1" />
|
||||||
|
{'+'}
|
||||||
|
<kbd className="kbd mx-1">G</kbd>
|
||||||
|
</VQuote>
|
||||||
|
组合键打开<VQuote>路径输入框</VQuote>,粘贴文件路径并回车提交。
|
||||||
|
</p>
|
||||||
|
</li>
|
||||||
|
</ol>
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
}
|
||||||
+11
-4
@@ -3,6 +3,7 @@ import { HiWord } from '~/components/HelpText/HiWord';
|
|||||||
import NoopExecutable from './assets/noop.exe?base64';
|
import NoopExecutable from './assets/noop.exe?base64';
|
||||||
import NoopExecutableSource from './assets/noop.asm.txt?base64';
|
import NoopExecutableSource from './assets/noop.asm.txt?base64';
|
||||||
|
|
||||||
|
const QMPC_MMKV_RELEASES_URL = 'https://git.um-react.app/um/qmpc-mmkv/releases';
|
||||||
const PC_CLIENT_URL = 'https://web.archive.org/web/2023/https://dldir1v6.qq.com/music/clntupate/QQMusic_Setup_1951.exe';
|
const PC_CLIENT_URL = 'https://web.archive.org/web/2023/https://dldir1v6.qq.com/music/clntupate/QQMusic_Setup_1951.exe';
|
||||||
const PC_CLIENT_TG_URL = 'https://t.me/um_lsr_ch/24';
|
const PC_CLIENT_TG_URL = 'https://t.me/um_lsr_ch/24';
|
||||||
|
|
||||||
@@ -10,14 +11,20 @@ export function InstructionsPC() {
|
|||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<p className="mt-2">
|
<p className="mt-2">
|
||||||
使用 <span className="text-error">19.57 或更高版本</span>下载的歌曲文件
|
使用 <span className="text-primary">19.57 至 22.76</span>下载的歌曲文件
|
||||||
<HiWord>需要导入密钥</HiWord>。
|
<HiWord>需要导入密钥</HiWord>。
|
||||||
<br />
|
|
||||||
目前未公开密钥获取方式,因此不支持。
|
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<p className="mt-4">
|
<p className="mt-4">
|
||||||
使用 <span className="text-primary">19.51 或更低版本</span>下载的歌曲文件
|
请从{' '}
|
||||||
|
<ExtLink className="link-info" href={QMPC_MMKV_RELEASES_URL}>
|
||||||
|
qmpc-mmkv-cli
|
||||||
|
</ExtLink>{' '}
|
||||||
|
获取工具,提取密钥文件 <code>qmpc-mmkv-v1.mmkv</code> 后在本页导入。
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<p className="mt-4">
|
||||||
|
使用 <span className="text-base-content/70">19.51 或更低版本</span>下载的歌曲文件
|
||||||
<HiWord>无需密钥</HiWord>。
|
<HiWord>无需密钥</HiWord>。
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
File renamed without changes.
File renamed without changes.
@@ -0,0 +1,3 @@
|
|||||||
|
com.tencent.QQMusicMac.plist
|
||||||
|
iData/
|
||||||
|
qqmusic-mac-*.mmkv
|
||||||
File renamed without changes.
File renamed without changes.
@@ -0,0 +1,213 @@
|
|||||||
|
#!/usr/bin/env python3
|
||||||
|
|
||||||
|
# QQMusic Mac MMKV Decryptor by LSR@Unlock Music
|
||||||
|
|
||||||
|
import hashlib
|
||||||
|
import re
|
||||||
|
import sys
|
||||||
|
from argparse import ArgumentParser
|
||||||
|
from dataclasses import dataclass
|
||||||
|
from os import PathLike
|
||||||
|
from os.path import dirname
|
||||||
|
from pathlib import Path
|
||||||
|
from struct import pack, unpack
|
||||||
|
|
||||||
|
|
||||||
|
@dataclass
|
||||||
|
class MMKVDecryptionData:
|
||||||
|
udid: str
|
||||||
|
mmkv_path: Path
|
||||||
|
mmkv_key: str
|
||||||
|
data: bytes
|
||||||
|
|
||||||
|
@property
|
||||||
|
def mmkv_name(self) -> str:
|
||||||
|
return self.mmkv_path.name
|
||||||
|
|
||||||
|
|
||||||
|
def _aes_128_cfb_decrypt(key: bytes, iv: bytes, ciphertext: bytes) -> bytes:
|
||||||
|
"""Decrypt using `Crypto.Cipher.AES` _or_ fallback to `OpenSSL` otherwise"""
|
||||||
|
try:
|
||||||
|
from Crypto.Cipher import AES # pyright: ignore[reportMissingImports]
|
||||||
|
|
||||||
|
aes = AES.new(key[:16], AES.MODE_CFB, iv=iv, segment_size=128)
|
||||||
|
return aes.decrypt(ciphertext)
|
||||||
|
except ImportError:
|
||||||
|
from subprocess import PIPE, Popen
|
||||||
|
|
||||||
|
process = Popen(
|
||||||
|
["openssl", "enc", "-aes-128-cfb", "-d", "-K", key.hex(), "-iv", iv.hex()],
|
||||||
|
stdin=PIPE,
|
||||||
|
stdout=PIPE,
|
||||||
|
stderr=PIPE,
|
||||||
|
text=False,
|
||||||
|
)
|
||||||
|
stdout, stderr = process.communicate(input=ciphertext)
|
||||||
|
if process.returncode != 0:
|
||||||
|
raise RuntimeError(
|
||||||
|
f"OpenSSL error (install PyCryptodome instead): {stderr.decode()}"
|
||||||
|
)
|
||||||
|
return stdout
|
||||||
|
|
||||||
|
|
||||||
|
def _caesar(text: str, shift: int) -> str:
|
||||||
|
"""A simple Caesar cipher implementation for alphanumeric characters"""
|
||||||
|
result = ""
|
||||||
|
for char in text:
|
||||||
|
if char.isalpha():
|
||||||
|
base = ord("A") if char.isupper() else ord("a")
|
||||||
|
result += chr((ord(char) - base + shift) % 26 + base)
|
||||||
|
elif char.isdigit():
|
||||||
|
result += chr((ord(char) - ord("0") + shift) % 10 + ord("0"))
|
||||||
|
else:
|
||||||
|
result += char
|
||||||
|
return result
|
||||||
|
|
||||||
|
|
||||||
|
__MMKV_TYPE_STREAM_KEY = 1
|
||||||
|
|
||||||
|
|
||||||
|
def _derive_mmkv_config(udid: str, mmkv_type: int):
|
||||||
|
"""Derive MMKV name and key from UDID, return (name, key)"""
|
||||||
|
str1 = _caesar(udid, mmkv_type + 3)
|
||||||
|
int1 = int(udid[5:7], 16)
|
||||||
|
int2 = 5 + (int1 + mmkv_type) % 4
|
||||||
|
mmkv_name = str1[0:int2]
|
||||||
|
|
||||||
|
int3 = mmkv_type + 0xA546
|
||||||
|
str3 = f"{udid}{int3:04x}"
|
||||||
|
mmkv_key = hashlib.md5(str3.encode()).hexdigest()
|
||||||
|
|
||||||
|
return mmkv_name, mmkv_key
|
||||||
|
|
||||||
|
|
||||||
|
def _decrypt_mmkv(path: PathLike, key: bytes):
|
||||||
|
"""Decrypt MMKV file using the given key, return decrypted data"""
|
||||||
|
with open(path, "rb") as mmkv, open(str(path) + ".crc", "rb") as crc:
|
||||||
|
crc.seek(12)
|
||||||
|
iv = crc.read(16)
|
||||||
|
(real_size,) = unpack("<I", crc.read(4))
|
||||||
|
(mmkv_payload_size,) = unpack("<I", mmkv.read(4))
|
||||||
|
|
||||||
|
if mmkv_payload_size != real_size:
|
||||||
|
raise ValueError("MMKV file size mismatch")
|
||||||
|
decrypted_data = pack("<I", real_size)
|
||||||
|
decrypted_data += _aes_128_cfb_decrypt(key, iv, mmkv.read(real_size))
|
||||||
|
return decrypted_data
|
||||||
|
|
||||||
|
|
||||||
|
def _dump_udid(plist_file: PathLike):
|
||||||
|
"""Extract UDIDs from the given plist file"""
|
||||||
|
with open(plist_file, "rb") as f:
|
||||||
|
plist = f.read()
|
||||||
|
for m in re.finditer(rb"_\x10\(([0-9a-f]{40})_", plist):
|
||||||
|
yield m.group(1).decode()
|
||||||
|
|
||||||
|
|
||||||
|
def _dump_mmkv(plist_file: PathLike, data_dir: PathLike):
|
||||||
|
"""Dump all MMKV files from the given plist file and iData directory"""
|
||||||
|
for udid in _dump_udid(plist_file):
|
||||||
|
mmkv_name, mmkv_key = _derive_mmkv_config(udid, __MMKV_TYPE_STREAM_KEY)
|
||||||
|
mmkv_path = Path(data_dir) / mmkv_name
|
||||||
|
|
||||||
|
if not mmkv_path.exists() or not mmkv_path.is_file():
|
||||||
|
print(f"MMKV file not found, skipping (path={mmkv_path})", file=sys.stderr)
|
||||||
|
continue
|
||||||
|
|
||||||
|
try:
|
||||||
|
decrypted_mmkv = _decrypt_mmkv(mmkv_path, mmkv_key.encode())
|
||||||
|
except Exception as e:
|
||||||
|
print(
|
||||||
|
"Error decrypting mmkv, skipping"
|
||||||
|
f" (path={mmkv_path}, key={mmkv_key}, error={e})",
|
||||||
|
file=sys.stderr,
|
||||||
|
)
|
||||||
|
continue
|
||||||
|
yield MMKVDecryptionData(
|
||||||
|
udid=udid,
|
||||||
|
mmkv_path=mmkv_path,
|
||||||
|
mmkv_key=mmkv_key,
|
||||||
|
data=decrypted_mmkv,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
def main():
|
||||||
|
parser = ArgumentParser(
|
||||||
|
description="QQMusic Mac MMKV Decryptor by LSR@Unlock Music"
|
||||||
|
)
|
||||||
|
parser.add_argument(
|
||||||
|
"-p",
|
||||||
|
"--plist",
|
||||||
|
type=str,
|
||||||
|
nargs="+",
|
||||||
|
help="Path to com.tencent.QQMusicMac.plist file or files",
|
||||||
|
default=[],
|
||||||
|
)
|
||||||
|
parser.add_argument(
|
||||||
|
"-i",
|
||||||
|
"--idata",
|
||||||
|
type=str,
|
||||||
|
help="Path to iData directory",
|
||||||
|
default="",
|
||||||
|
)
|
||||||
|
parser.add_argument("-f", "--force", action="store_true", help="Force overwrite")
|
||||||
|
parser.add_argument(
|
||||||
|
"-o",
|
||||||
|
"--output",
|
||||||
|
type=str,
|
||||||
|
help="Output directory for decrypted MMKV files (default: script directory)",
|
||||||
|
default=dirname(__file__),
|
||||||
|
)
|
||||||
|
parser.add_argument(
|
||||||
|
"-v", "--verbose", action="store_true", help="Enable verbose output"
|
||||||
|
)
|
||||||
|
args = parser.parse_args()
|
||||||
|
|
||||||
|
home_dir = Path.home()
|
||||||
|
app_sandbox_dir = home_dir / "Library/Containers/com.tencent.QQMusicMac/Data"
|
||||||
|
idata_dir = app_sandbox_dir / "Library/Application Support/QQMusicMac/iData"
|
||||||
|
|
||||||
|
if args.idata:
|
||||||
|
idata_dir = Path(args.idata)
|
||||||
|
|
||||||
|
plists = []
|
||||||
|
if args.plist:
|
||||||
|
plists = [Path(p) for p in args.plist]
|
||||||
|
else:
|
||||||
|
for base_dir in (home_dir, app_sandbox_dir):
|
||||||
|
plists.append(base_dir / "Library/Preferences/com.tencent.QQMusicMac.plist")
|
||||||
|
|
||||||
|
output_dir = Path(args.output)
|
||||||
|
output_dir.mkdir(parents=True, exist_ok=True)
|
||||||
|
|
||||||
|
force = args.force
|
||||||
|
verbose = args.verbose
|
||||||
|
|
||||||
|
for plist_file in plists:
|
||||||
|
if plist_file.exists() and plist_file.is_file():
|
||||||
|
for dump in _dump_mmkv(plist_file, idata_dir):
|
||||||
|
out_path = output_dir / f"qqmusic-mac-{dump.mmkv_path.name}.mmkv"
|
||||||
|
if out_path.exists() and not force:
|
||||||
|
print(f"output exists, skipping (name={out_path.name})")
|
||||||
|
continue
|
||||||
|
|
||||||
|
if verbose:
|
||||||
|
print("*** MMKV DUMP ENTRY START ***")
|
||||||
|
print(f"UDID: {dump.udid}")
|
||||||
|
print(f"MMKV Name: {dump.mmkv_path.name}")
|
||||||
|
print(f"MMKV Key: {dump.mmkv_key}")
|
||||||
|
print(f"Output: {out_path.name}")
|
||||||
|
print("**** MMKV DUMP ENTRY END ****")
|
||||||
|
else:
|
||||||
|
print(f"Dumping mmkv: {out_path.name}...")
|
||||||
|
|
||||||
|
try:
|
||||||
|
with open(out_path, "wb") as f:
|
||||||
|
f.write(dump.data)
|
||||||
|
except Exception as e:
|
||||||
|
print(f"Error writing decrypted mmkv: {e}", file=sys.stderr)
|
||||||
|
continue
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
main()
|
||||||
@@ -0,0 +1,28 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
echo '补丁中…'
|
||||||
|
|
||||||
|
patch_count=0
|
||||||
|
|
||||||
|
patch_qqmusic() {
|
||||||
|
SUDO="$1"
|
||||||
|
APP="$2"
|
||||||
|
|
||||||
|
if [ ! -d "$APP" ]; then
|
||||||
|
echo "路径不存在,跳过 $APP..."
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "修补 $APP..."
|
||||||
|
$SUDO sed -i.bak 's#<string>8.8.0</string>#<string>88.8.0</string>#' \
|
||||||
|
"$APP/Contents/Info.plist"
|
||||||
|
$SUDO codesign --force --deep --sign - "$APP"
|
||||||
|
$SUDO xattr -d com.apple.quarantine "$APP"
|
||||||
|
|
||||||
|
patch_count=$((patch_count + 1))
|
||||||
|
}
|
||||||
|
|
||||||
|
patch_qqmusic sudo "/Applications/QQMusic.app"
|
||||||
|
patch_qqmusic "" "$HOME/Applications/QQMusic.app"
|
||||||
|
|
||||||
|
echo "完成,已修补 $patch_count 个 QQ 音乐安装"
|
||||||
File renamed without changes.
|
Before Width: | Height: | Size: 5.1 KiB After Width: | Height: | Size: 5.1 KiB |
@@ -0,0 +1,25 @@
|
|||||||
|
import type { RootState } from '~/store';
|
||||||
|
import { closestByLevenshtein } from '~/util/levenshtein';
|
||||||
|
import { hasOwn } from '~/util/objects';
|
||||||
|
|
||||||
|
export const selectStagingQMCv2Settings = (state: RootState) => state.settings.staging.qmc2;
|
||||||
|
export const selectFinalQMCv2Settings = (state: RootState) => state.settings.production.qmc2;
|
||||||
|
|
||||||
|
export const selectQMCv2KeyByFileName = (state: RootState, name: string): string | undefined => {
|
||||||
|
const normalizedName = name.normalize();
|
||||||
|
|
||||||
|
let ekey: string | undefined;
|
||||||
|
const { keys, allowFuzzyNameSearch } = selectFinalQMCv2Settings(state);
|
||||||
|
if (hasOwn(keys, normalizedName)) {
|
||||||
|
ekey = keys[normalizedName];
|
||||||
|
} else if (allowFuzzyNameSearch) {
|
||||||
|
const qmc2KeyStoreNames = Object.keys(keys);
|
||||||
|
if (qmc2KeyStoreNames.length > 0) {
|
||||||
|
const closestName = closestByLevenshtein(normalizedName, qmc2KeyStoreNames);
|
||||||
|
console.debug('qmc2: key db could not find %o, using closest %o instead.', normalizedName, closestName);
|
||||||
|
ekey = keys[closestName];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return ekey;
|
||||||
|
};
|
||||||
+8
-22
@@ -1,15 +1,12 @@
|
|||||||
import { useDispatch, useSelector } from 'react-redux';
|
import { useDispatch, useSelector } from 'react-redux';
|
||||||
import { qmc2AddKey, qmc2AllowFuzzyNameSearch, qmc2ClearKeys, qmc2ImportKeys } from '../settingsSlice';
|
import { qmc2AddKey, qmc2AllowFuzzyNameSearch, qmc2ClearKeys, qmc2ImportKeys } from '~/features/settings/settingsSlice';
|
||||||
import { selectStagingQMCv2Settings } from '../settingsSelector';
|
import { selectStagingQMCv2Settings } from '~/features/qmc/keyLookup';
|
||||||
import React, { useRef, useState } from 'react';
|
import React, { useRef, useState } from 'react';
|
||||||
import { QMCv2EKeyItem } from './QMCv2/QMCv2EKeyItem';
|
import { QMCv2EKeyItem } from './QMCv2EKeyItem';
|
||||||
import { ImportSecretModal } from '~/components/ImportSecretModal';
|
import { ImportSecretModal } from '~/components/ImportSecretModal';
|
||||||
import { StagingQMCv2Key } from '../keyFormats';
|
import { importQMCv2KeysFromFile } from '~/features/qmc/importKeys';
|
||||||
import { DatabaseKeyExtractor } from '~/util/DatabaseKeyExtractor';
|
import { QMCv2QQMusicAllInstructions } from '~/features/qmc/instructions/QMCv2QQMusicAllInstructions';
|
||||||
import { parseAndroidQmEKey } from '~/util/mmkv/qm';
|
import { QMCv2DoubanAllInstructions } from '~/features/qmc/instructions/QMCv2DoubanAllInstructions';
|
||||||
import { getFileName } from '~/util/pathHelper';
|
|
||||||
import { QMCv2QQMusicAllInstructions } from './QMCv2/QMCv2QQMusicAllInstructions';
|
|
||||||
import { QMCv2DoubanAllInstructions } from './QMCv2/QMCv2DoubanAllInstructions';
|
|
||||||
import { AddKey } from '~/components/AddKey';
|
import { AddKey } from '~/components/AddKey';
|
||||||
import { InfoModal } from '~/components/InfoModal.tsx';
|
import { InfoModal } from '~/components/InfoModal.tsx';
|
||||||
import { Ruby } from '~/components/Ruby.tsx';
|
import { Ruby } from '~/components/Ruby.tsx';
|
||||||
@@ -32,18 +29,7 @@ export function PanelQMCv2Key() {
|
|||||||
|
|
||||||
const handleSecretImport = async (file: File) => {
|
const handleSecretImport = async (file: File) => {
|
||||||
try {
|
try {
|
||||||
const fileBuffer = await file.arrayBuffer();
|
const keys = await importQMCv2KeysFromFile(file);
|
||||||
|
|
||||||
let keys: null | Omit<StagingQMCv2Key, 'id'>[] = null;
|
|
||||||
|
|
||||||
if (/(player_process[_.]db|music_audio_play)(\.db)?$/i.test(file.name)) {
|
|
||||||
const extractor = await DatabaseKeyExtractor.getInstance();
|
|
||||||
keys = extractor.extractQmcV2KeysFromSqliteDb(fileBuffer);
|
|
||||||
} else if (/MMKVStreamEncryptId|filenameEkeyMap|qmpc-mmkv-v1|(\.mmkv$)/i.test(file.name)) {
|
|
||||||
const fileBuffer = await file.arrayBuffer();
|
|
||||||
const map = parseAndroidQmEKey(new DataView(fileBuffer));
|
|
||||||
keys = Array.from(map.entries(), ([name, ekey]) => ({ name: getFileName(name), ekey }));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (keys && keys.length > 0) {
|
if (keys && keys.length > 0) {
|
||||||
dispatch(qmc2ImportKeys(keys));
|
dispatch(qmc2ImportKeys(keys));
|
||||||
@@ -53,7 +39,7 @@ export function PanelQMCv2Key() {
|
|||||||
toastImportResult(file.name, keys);
|
toastImportResult(file.name, keys);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.error('error during import: ', e);
|
console.error('error during import: ', e);
|
||||||
alert(`导入数据库时发生错误:${e}`);
|
alert(`导入数据库时发生错误:${e as Error}`);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
+1
-1
@@ -1,4 +1,4 @@
|
|||||||
import { qmc2DeleteKey, qmc2UpdateKey } from '../../settingsSlice';
|
import { qmc2DeleteKey, qmc2UpdateKey } from '~/features/settings/settingsSlice';
|
||||||
import { useAppDispatch } from '~/hooks';
|
import { useAppDispatch } from '~/hooks';
|
||||||
import { memo } from 'react';
|
import { memo } from 'react';
|
||||||
import { KeyInput } from '~/components/KeyInput.tsx';
|
import { KeyInput } from '~/components/KeyInput.tsx';
|
||||||
@@ -0,0 +1,23 @@
|
|||||||
|
import { nanoid } from 'nanoid';
|
||||||
|
|
||||||
|
/** QMCv2 staging key row (QQ Music / Douban FM). */
|
||||||
|
export interface StagingQMCv2Key {
|
||||||
|
id: string;
|
||||||
|
name: string;
|
||||||
|
ekey: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export type ProductionQMCv2Keys = Record<string /* filename */, string /* ekey */>;
|
||||||
|
|
||||||
|
export const qmc2StagingToProductionKey = (key: StagingQMCv2Key) => key.name.normalize();
|
||||||
|
export const qmc2StagingToProductionValue = (key: StagingQMCv2Key) => key.ekey.trim();
|
||||||
|
export const qmc2ProductionToStaging = (
|
||||||
|
key: keyof ProductionQMCv2Keys,
|
||||||
|
value: ProductionQMCv2Keys[keyof ProductionQMCv2Keys],
|
||||||
|
): StagingQMCv2Key => {
|
||||||
|
return {
|
||||||
|
id: nanoid(),
|
||||||
|
name: key.normalize(),
|
||||||
|
ekey: value.trim(),
|
||||||
|
};
|
||||||
|
};
|
||||||
@@ -0,0 +1,27 @@
|
|||||||
|
import { parseQtfmDeviceInfoFromText, parseQtfmDeviceSecretFromText } from '../importKeys';
|
||||||
|
import { sanitizeQtfmAndroidKey } from '../types';
|
||||||
|
|
||||||
|
describe('qtfm import / sanitize', () => {
|
||||||
|
test('parseQtfmDeviceSecretFromText extracts DEVICE_SECRET line', () => {
|
||||||
|
const text = 'foo\nDEVICE_SECRET: aBcD1234\nbar';
|
||||||
|
expect(parseQtfmDeviceSecretFromText(text)).toBe('aBcD1234');
|
||||||
|
expect(parseQtfmDeviceSecretFromText('no secret here')).toBeNull();
|
||||||
|
});
|
||||||
|
|
||||||
|
test('parseQtfmDeviceInfoFromText requires all fields', () => {
|
||||||
|
const full = ['PRODUCT: p', 'DEVICE: d', 'MANUFACTURER: m', 'BRAND: b', 'BOARD: board', 'MODEL: model'].join('\n');
|
||||||
|
expect(parseQtfmDeviceInfoFromText(full)).toEqual({
|
||||||
|
product: 'p',
|
||||||
|
device: 'd',
|
||||||
|
manufacturer: 'm',
|
||||||
|
brand: 'b',
|
||||||
|
board: 'board',
|
||||||
|
model: 'model',
|
||||||
|
});
|
||||||
|
expect(parseQtfmDeviceInfoFromText('PRODUCT: p\nDEVICE: d')).toBeNull();
|
||||||
|
});
|
||||||
|
|
||||||
|
test('sanitizeQtfmAndroidKey strips non-hex', () => {
|
||||||
|
expect(sanitizeQtfmAndroidKey('de-ad_be ef!!')).toBe('deadbeef');
|
||||||
|
});
|
||||||
|
});
|
||||||
@@ -0,0 +1,26 @@
|
|||||||
|
import type { GetQingTingFMDeviceKeyPayload } from '~/decrypt-worker/types.ts';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Extract a hex device secret from clipboard / dump text.
|
||||||
|
* Matches lines like `DEVICE_SECRET: deadbeef…` (from qtfm-device-id).
|
||||||
|
*/
|
||||||
|
export function parseQtfmDeviceSecretFromText(text: string): string | null {
|
||||||
|
const match = text.match(/^DEVICE_SECRET: ([0-9a-fA-F]+)/m);
|
||||||
|
return match?.[1] ?? null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Extract build.prop-style device fields for worker-side key derivation.
|
||||||
|
* Returns null unless all required fields are present.
|
||||||
|
*/
|
||||||
|
export function parseQtfmDeviceInfoFromText(text: string): GetQingTingFMDeviceKeyPayload | null {
|
||||||
|
const dataMap = Object.create(null) as GetQingTingFMDeviceKeyPayload;
|
||||||
|
for (const [, key, value] of text.matchAll(/^(PRODUCT|DEVICE|MANUFACTURER|BRAND|BOARD|MODEL): (.+)/gim)) {
|
||||||
|
dataMap[key.toLowerCase() as keyof GetQingTingFMDeviceKeyPayload] = value;
|
||||||
|
}
|
||||||
|
const { product, device, manufacturer, brand, board, model } = dataMap;
|
||||||
|
if (product && device && manufacturer && brand && board && model) {
|
||||||
|
return dataMap;
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
@@ -0,0 +1,48 @@
|
|||||||
|
import { VQuote } from '~/components/HelpText/VQuote';
|
||||||
|
import { HiWord } from '~/components/HelpText/HiWord';
|
||||||
|
import { Ruby } from '~/components/Ruby';
|
||||||
|
|
||||||
|
/** File-location / naming notes for QingTing FM Android downloads. */
|
||||||
|
export function QingTingNotes() {
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
<h3 className="text-xl font-bold my-2">注意事项</h3>
|
||||||
|
<ul className="list-disc pl-6">
|
||||||
|
<li>
|
||||||
|
<p>
|
||||||
|
下载的文件位于
|
||||||
|
<VQuote>
|
||||||
|
<code className="break-words">
|
||||||
|
<HiWord>[内部储存]</HiWord>/<wbr />
|
||||||
|
Android/
|
||||||
|
<wbr />
|
||||||
|
data/
|
||||||
|
<wbr />
|
||||||
|
fm.qingting.qtradio/
|
||||||
|
<wbr />
|
||||||
|
files/Music/
|
||||||
|
</code>
|
||||||
|
</VQuote>
|
||||||
|
</p>
|
||||||
|
<ul className="list-disc pl-6">
|
||||||
|
<li>
|
||||||
|
<p>
|
||||||
|
你可能需要使用有
|
||||||
|
<Ruby caption="root">特权</Ruby>
|
||||||
|
的文件浏览器访问。
|
||||||
|
</p>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
</li>
|
||||||
|
<li>
|
||||||
|
<p>
|
||||||
|
音频文件文件名为「<code>.p~!</code>」后缀。
|
||||||
|
</p>
|
||||||
|
</li>
|
||||||
|
<li>
|
||||||
|
<p>因为解密密钥与文件名相关,因此解密前请不要更改文件名。</p>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -0,0 +1,4 @@
|
|||||||
|
import type { RootState } from '~/store';
|
||||||
|
|
||||||
|
export const selectStagingQtfmAndroidKey = (state: RootState) => state.settings.staging.qtfm.android;
|
||||||
|
export const selectQtfmAndroidKey = (state: RootState) => state.settings.production.qtfm.android;
|
||||||
@@ -0,0 +1,81 @@
|
|||||||
|
import { useAppDispatch, useAppSelector } from '~/hooks';
|
||||||
|
import { ExtLink } from '~/components/ExtLink';
|
||||||
|
import { ChangeEvent, ClipboardEvent, useId } from 'react';
|
||||||
|
import { VQuote } from '~/components/HelpText/VQuote';
|
||||||
|
import { selectStagingQtfmAndroidKey } from '~/features/qtfm/keyLookup';
|
||||||
|
import { parseQtfmDeviceInfoFromText, parseQtfmDeviceSecretFromText } from '~/features/qtfm/importKeys';
|
||||||
|
import { QingTingNotes } from '~/features/qtfm/instructions/QingTingNotes';
|
||||||
|
import { qtfmAndroidUpdateKey } from '~/features/settings/settingsSlice';
|
||||||
|
import { DECRYPTION_WORKER_ACTION_NAME } from '~/decrypt-worker/constants.ts';
|
||||||
|
import { usePlatform } from '~/platform/PlatformContext';
|
||||||
|
import { toast } from 'react-toastify';
|
||||||
|
|
||||||
|
const QTFM_DEVICE_ID_URL = 'https://github.com/parakeet-rs/qtfm-device-id/releases/latest';
|
||||||
|
|
||||||
|
export function PanelQingTing() {
|
||||||
|
const dispatch = useAppDispatch();
|
||||||
|
const { crypto } = usePlatform();
|
||||||
|
const secretKey = useAppSelector(selectStagingQtfmAndroidKey);
|
||||||
|
const setSecretKey = (secretKey: string) => {
|
||||||
|
dispatch(qtfmAndroidUpdateKey({ deviceKey: secretKey }));
|
||||||
|
};
|
||||||
|
|
||||||
|
const handleDataPaste = (e: ClipboardEvent<HTMLInputElement>) => {
|
||||||
|
const plainText = e.clipboardData.getData('text/plain');
|
||||||
|
const deviceSecret = parseQtfmDeviceSecretFromText(plainText);
|
||||||
|
if (deviceSecret) {
|
||||||
|
e.preventDefault();
|
||||||
|
setSecretKey(deviceSecret);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const dataMap = parseQtfmDeviceInfoFromText(plainText);
|
||||||
|
if (dataMap) {
|
||||||
|
e.preventDefault();
|
||||||
|
crypto
|
||||||
|
.request(DECRYPTION_WORKER_ACTION_NAME.QINGTING_FM_GET_DEVICE_KEY, dataMap)
|
||||||
|
.then(setSecretKey, (err) => toast.error(`生成设备密钥时发生错误: ${err}`));
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const handleDataInput = (e: ChangeEvent<HTMLInputElement>) => {
|
||||||
|
setSecretKey(e.target.value);
|
||||||
|
};
|
||||||
|
|
||||||
|
const idSecretKey = useId();
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className="min-h-0 flex-col grow px-1">
|
||||||
|
<h2 className="text-2xl font-bold mb-4">蜻蜓 FM</h2>
|
||||||
|
|
||||||
|
<p>
|
||||||
|
<VQuote>蜻蜓 FM</VQuote>的安卓版本需要获取设备密钥,并以此来生成解密密钥。
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<div className="my-4">
|
||||||
|
<fieldset className="fieldset">
|
||||||
|
<legend className="fieldset-legend text-lg">
|
||||||
|
<label htmlFor={idSecretKey}>设备密钥</label>
|
||||||
|
</legend>
|
||||||
|
<input
|
||||||
|
id={idSecretKey}
|
||||||
|
type="text"
|
||||||
|
className="input font-mono"
|
||||||
|
onPaste={handleDataPaste}
|
||||||
|
value={secretKey}
|
||||||
|
onChange={handleDataInput}
|
||||||
|
/>
|
||||||
|
<p className="label flex-wrap">
|
||||||
|
粘贴含有设备密钥的信息的内容时将自动提取密钥(如通过
|
||||||
|
<ExtLink href={QTFM_DEVICE_ID_URL}>
|
||||||
|
<code>qtfm-device-id</code>
|
||||||
|
</ExtLink>
|
||||||
|
获取的设备信息),不需要 root。
|
||||||
|
</p>
|
||||||
|
</fieldset>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<QingTingNotes />
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
/** QingTing FM staging settings (`state.settings.staging.qtfm`). */
|
||||||
|
export interface StagingQtfmSettings {
|
||||||
|
/** Android device key (hex). */
|
||||||
|
android: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** QingTing FM production settings (`state.settings.production.qtfm`; persist key `qtfm`). */
|
||||||
|
export type ProductionQtfmSettings = StagingQtfmSettings;
|
||||||
|
|
||||||
|
export const EMPTY_QTFM_SETTINGS: StagingQtfmSettings = { android: '' };
|
||||||
|
|
||||||
|
/** Strip non-hex characters from a pasted / typed device key. */
|
||||||
|
export function sanitizeQtfmAndroidKey(key: string): string {
|
||||||
|
return key.replace(/[^0-9a-fA-F]/g, '');
|
||||||
|
}
|
||||||
@@ -2,14 +2,17 @@ import { useAppDispatch, useAppSelector } from '~/hooks';
|
|||||||
import { commitStagingChange, discardStagingChanges } from './settingsSlice';
|
import { commitStagingChange, discardStagingChanges } from './settingsSlice';
|
||||||
import { selectIsSettingsNotSaved } from './settingsSelector';
|
import { selectIsSettingsNotSaved } from './settingsSelector';
|
||||||
import { Outlet } from 'react-router';
|
import { Outlet } from 'react-router';
|
||||||
import { SETTINGS_TABS } from '~/features/settings/settingsTabs.tsx';
|
import { getSettingsTabs } from '~/features/settings/settingsTabs.tsx';
|
||||||
import { MdOutlineSettingsBackupRestore } from 'react-icons/md';
|
import { MdOutlineSettingsBackupRestore } from 'react-icons/md';
|
||||||
import { toast } from 'react-toastify';
|
import { toast } from 'react-toastify';
|
||||||
import { ResponsiveNav } from '../nav/ResponsiveNav';
|
import { ResponsiveNav } from '../nav/ResponsiveNav';
|
||||||
import { TabNavLink } from '../nav/TabNavLink';
|
import { TabNavLink } from '../nav/TabNavLink';
|
||||||
|
import { usePlatform } from '~/platform/PlatformContext';
|
||||||
|
|
||||||
export function Settings() {
|
export function Settings() {
|
||||||
const dispatch = useAppDispatch();
|
const dispatch = useAppDispatch();
|
||||||
|
const { capabilities } = usePlatform();
|
||||||
|
const settingsTabs = getSettingsTabs(capabilities);
|
||||||
|
|
||||||
const handleResetSettings = () => {
|
const handleResetSettings = () => {
|
||||||
dispatch(discardStagingChanges());
|
dispatch(discardStagingChanges());
|
||||||
@@ -35,7 +38,7 @@ export function Settings() {
|
|||||||
navigationClassName="overflow-x-auto pb-[2px] md:pb-0 h-full items-start [&]:md:flex"
|
navigationClassName="overflow-x-auto pb-[2px] md:pb-0 h-full items-start [&]:md:flex"
|
||||||
navigation={
|
navigation={
|
||||||
<div role="tablist" className="tabs gap-1 flex-nowrap md:flex-col grow items-center">
|
<div role="tablist" className="tabs gap-1 flex-nowrap md:flex-col grow items-center">
|
||||||
{Object.entries(SETTINGS_TABS).map(([id, { name }]) => (
|
{Object.entries(settingsTabs).map(([id, { name }]) => (
|
||||||
<TabNavLink key={id} to={`/settings/${id}`}>
|
<TabNavLink key={id} to={`/settings/${id}`}>
|
||||||
{name}
|
{name}
|
||||||
</TabNavLink>
|
</TabNavLink>
|
||||||
|
|||||||
Loaded 100 of 171 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user