62 Commits

Author SHA1 Message Date
鲁树人
665524ee34 0.5.0 2025-07-05 04:51:47 +09:00
鲁树人
7c319fa4d9 ci: exclude zip file from gitea artifact 2025-07-05 04:51:47 +09:00
鲁树人
2598b977ab ci: product win64 zip (wry) on build 2025-07-05 04:51:47 +09:00
鲁树人
d81963ddcd Merge pull request '框架迁移: Chakra 迁移到 Daisy UI' (#86) from chakra-to-daisy into main
Reviewed-on: https://git.unlock-music.dev/um/um-react/pulls/86
2025-07-04 16:46:19 +00:00
鲁树人
99bce5c4ef fix: improve dark mode color 2025-07-05 01:13:39 +09:00
鲁树人
3fcbe054b0 chore: bump node types version 2025-07-05 00:55:37 +09:00
鲁树人
67fbe77157 chore: bump minor dep version 2025-07-05 00:53:13 +09:00
鲁树人
d57cdcdb49 fix: reduce footer text, move project information to faq page 2025-06-16 22:31:08 +09:00
鲁树人
ff79b4ce27 chore: fix type issue with filesystem access api 2025-06-16 22:31:03 +09:00
鲁树人
cbb6347251 Merge pull request 'feat: 全部下载' (#91) from awalol/um-react:downloadall-fork-chakra-to-daisy into chakra-to-daisy
Reviewed-on: https://git.unlock-music.dev/um/um-react/pulls/91
Reviewed-by: 鲁树人 <lsr@noreply.unlock-music.dev>
2025-06-16 10:15:13 +00:00
awalol
a5d0ec29a1 增加文件夹选取取消判断
使用 toast 进行提示
使用 react-icons 获取下载图标
使用 pipeTo 方法写出到文件
2025-06-16 00:56:20 +08:00
awalol
fa7292f65b ui: 完善全部下载按钮的样式和位置 2025-06-15 14:05:11 +08:00
awalol
519ced5e88 feat: 全部下载 2025-06-15 04:01:52 +08:00
鲁树人
b33ffa6ca7 build: include _redirects for netlify deployment 2025-05-19 10:00:53 +09:00
鲁树人
09c1bc474e child: remove base 2025-05-19 09:58:13 +09:00
鲁树人
e0b3bd60c2 chore: update wording for settings 2025-05-19 09:51:00 +09:00
鲁树人
6371c58cd5 fix: theme support 2025-05-19 09:50:52 +09:00
鲁树人
98f1be9ac7 fix: default sub-nav to align top on large screen 2025-05-19 09:26:54 +09:00
鲁树人
3541af7a96 refactor: deep link for faq 2025-05-19 09:23:14 +09:00
鲁树人
3ab73d8369 adjust dark mode and layout 2025-05-18 23:18:01 +09:00
鲁树人
6cb1f9f87f fix: adjust layout for settings 2025-05-18 11:05:50 +09:00
鲁树人
9518b813bd refactor: batch 4 2025-05-18 09:58:34 +09:00
鲁树人
2e4e57be45 refactor: batch 3 2025-05-18 02:41:20 +09:00
鲁树人
75b43e1e84 refactor: batch 2 2025-05-17 11:20:52 +09:00
鲁树人
246ba48135 fix: build/test issue 2025-05-17 06:09:00 +09:00
鲁树人
13c669b4ea refactor: batch 1 2025-05-17 05:59:39 +09:00
鲁树人
089d66cbf4 feat: add daisy ui 2025-05-17 01:44:55 +09:00
鲁树人
33a5f277fa chore: bump major versions 2025-05-17 01:42:58 +09:00
鲁树人
8a77cb0dc8 chore: update packages 2025-05-17 01:39:01 +09:00
鲁树人
0a820b620b docs: use gitea actions badge 2025-05-08 07:22:52 +09:00
鲁树人
721d947fdb docs: add link to lib_um_crypto_rust 2025-05-06 10:28:22 +09:00
鲁树人
1880220aaa docs: add issue template 2025-05-04 22:13:25 +09:00
鲁树人
d91e2fffe4 chore: bump version to v0.4.7; upgrade deps 2025-03-31 09:37:58 +09:00
鲁树人
88cfbcd337 build: retrive git hash 2025-03-31 04:03:27 +09:00
鲁树人
e9480ce6a4 chore: bump version to v0.4.2 2025-03-28 12:15:57 +09:00
鲁树人
a07bcf2575 build: build with docker 2025-03-28 12:14:59 +09:00
鲁树人
a40ecc4569 chore: reduce vscode extensions recommended 2025-03-28 11:27:51 +09:00
鲁树人
1abfe3498f chore: bump version to v0.4.1 2025-02-25 20:30:59 +09:00
鲁树人
e69393d1bc fix(kgm): extract hash/key from both tables 2025-02-25 20:30:25 +09:00
鲁树人
19c5d0aab9 docs: update readme 2025-02-25 07:08:37 +09:00
鲁树人
baab3057cf 0.4.0 2025-02-25 07:08:31 +09:00
鲁树人
c71078f5da feat(kgm): kgm v5 (aka. kgg) support 2025-02-25 07:05:31 +09:00
鲁树人
acb7a634b1 docs: update readme on where to find artifact 2024-12-15 21:39:52 +09:00
鲁树人
ce969af57f CI: 替换 Drone CI 为 Gitea 内建的 Actions (#80)
自动构建相关。

Reviewed-on: https://git.unlock-music.dev/um/um-react/pulls/80
Co-authored-by: 鲁树人 <lu.shuren@um-react.app>
Co-committed-by: 鲁树人 <lu.shuren@um-react.app>
2024-12-15 12:37:40 +00:00
鲁树人
ec4bd16b03 test: make vite happy 2024-12-15 04:52:36 +09:00
鲁树人
531930a6ec chore: bump version to 0.3.3 2024-12-15 04:51:12 +09:00
鲁树人
3862f2d38e fix: update packages 2024-12-15 03:57:14 +09:00
鲁树人
ddc073fbcc chore: move husky to sgh 2024-12-15 03:57:08 +09:00
鲁树人
82dbfc2d1f chore: bump node version 2024-12-15 03:57:00 +09:00
鲁树人
87d2d71193 chore: add packageManager field 2024-10-14 11:03:53 +09:00
鲁树人
759252cec5 docs: improve faq page
- add toc for faq page
- fix #79: add note about oem build
- add plat form specific instructions for qqmusic faq
2024-10-14 11:03:01 +09:00
鲁树人
afc65fd5d0 docs: added notes about mac client version requirements (close #70) 2024-10-13 05:54:12 +09:00
鲁树人
9f587212bc docs: remove todo list, add link to crypto issues 2024-10-13 05:51:31 +09:00
鲁树人
9ede00037e docs: fix link to um-crypto docs 2024-10-13 05:48:35 +09:00
鲁树人
0951963f46 docs: format with prettier 2024-10-13 05:47:07 +09:00
鲁树人
c57bc9cfbb docs: add do not fork notice 2024-10-13 05:46:38 +09:00
鲁树人
b16e3bf3ea chore: update readme 2024-09-26 21:15:03 +01:00
鲁树人
e9a95d1bd6 0.3.2 2024-09-26 21:06:00 +01:00
鲁树人
00813957d6 feat: make unsaved settings obvious 2024-09-26 21:02:42 +01:00
鲁树人
b26e62e8d9 chore: bump version to 0.3.1 2024-09-26 20:43:23 +01:00
鲁树人
9fed1ee610 fix: footer-less qmcv2 file support 2024-09-26 20:41:02 +01:00
鲁树人
5e890bca77 chore: fix husky hooks 2024-09-24 23:20:57 +01:00
138 changed files with 18248 additions and 6374 deletions

3
.dockerignore Normal file
View File

@@ -0,0 +1,3 @@
dist
node_modules
*.log

View File

@@ -1,35 +0,0 @@
---
kind: pipeline
type: docker
name: default
steps:
- name: test & build
image: node:20.10.0-bookworm
commands:
# - git config --global --add safe.directory "/drone/src"
- corepack enable
- corepack prepare pnpm@latest --activate
- pnpm i --frozen-lockfile
- pnpm build
environment:
# 让 npm 使用淘宝源
npm_config_registry: https://registry.npmmirror.com
- name: publish
image: node:20.10.0-bookworm
environment:
DRONE_GITEA_SERVER: https://git.unlock-music.dev
GITEA_API_KEY:
from_secret: GITEA_API_KEY
NETLIFY_SITE_ID:
from_secret: NETLIFY_SITE_ID
NETLIFY_API_KEY:
from_secret: NETLIFY_API_KEY
commands:
- |
python3 -m zipfile -c um-react.zip dist/.
cp um-react.zip dist/"release-${DRONE_COMMIT_SHA}.zip"
python3 -m zipfile -c um-react-site.zip dist/.
- ./scripts/publish.sh
- ./scripts/deploy.sh

View File

@@ -11,5 +11,5 @@ charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true
[*.{{c,m,}js{x,on,},ts{x,}}]
[*.{{c,m,}js{x,on,},ts{x,},y{,a}ml}]
indent_size = 2

View File

@@ -1,3 +0,0 @@
dist/
node_modules/
coverage/

View File

@@ -1,27 +0,0 @@
/* eslint-env node */
module.exports = {
root: true,
env: { browser: true, es2020: true },
extends: [
'eslint:recommended',
'plugin:@typescript-eslint/recommended',
'plugin:react-hooks/recommended',
'prettier',
],
parser: '@typescript-eslint/parser',
parserOptions: { ecmaVersion: 'latest', sourceType: 'module' },
plugins: ['react-refresh'],
rules: {
'react-refresh/only-export-components': 'warn',
'@typescript-eslint/no-unused-vars': [
'error',
{
varsIgnorePattern: '^_',
argsIgnorePattern: '^_',
destructuredArrayIgnorePattern: '^_',
ignoreRestSiblings: true,
},
],
},
};

View File

@@ -0,0 +1,46 @@
name: QQ 音乐 (安卓)
about: 解密使用「QQ 音乐」的「安卓」客户端下载的文件失败时选择该项。
title: '[QQ音乐]: 请填写标题'
body:
- type: markdown
attributes:
value: |
### 安卓客户端
你的手机需要 root 权限。注意 root 可能会导致手机保修失效,操作不当可能会导致手机变砖。
请参考 [um-react](https://um-react.netlify.app/) 上方的答疑区域获取说明。
此外请使用 Chrome 或 Firefox 浏览器,而非系统自带的浏览器或轻量浏览器,如 Via 浏览器。
---
如果你确定你的客户端版本符合上述描述,并遇到了问题,请继续填写下面的表单。
- type: textarea
id: what-happened
attributes:
label: 错误描述
description: |
请详细描述你遇到的问题,例如下载使用的客户端、提供下载后的文件、操作步骤、错误提示等你认为会帮助修正错误的信息。
validations:
required: true
- type: textarea
id: logs
attributes:
label: 相关日志
description: 如果有相关日志,请附上。浏览器日志可以通过 F12 打开开发者工具,在 Console 选项卡中查看。
- type: checkboxes
id: terms
attributes:
label: 检查清单
description: 请检查下方的快速检查清单,确保你已经完成了所有步骤。
options:
- label: 我有填写一个简单易懂的标题
required: true
- label: 我有阅读上方的说明
required: true
- label: 我有阅读 um-react 的答疑部分
required: true
- label: 我的安卓设备已获得 root 权限
required: true

View File

@@ -0,0 +1,63 @@
name: QQ 音乐 (Windows/Mac)
about: 解密使用「QQ 音乐」的「Windows」或「Mac」客户端下载的文件失败时选择该项。
title: '[QQ音乐]: 请填写标题'
body:
- type: markdown
attributes:
value: |
### Windows 客户端
目前 Windows 客户端仅支持 19.51 或更低版本下载的歌曲文件。
* [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/6)
### Mac 客户端
目前 Mac 客户端仅支持 v8.8.0 或更低版本下载的歌曲文件。
* [通过 Telegram 下载](https://t.me/um_lsr_ch/21)
---
如果你确定你的客户端版本符合上述描述,并遇到了问题,请继续填写下面的表单。
- type: dropdown
id: platform
attributes:
label: 平台
description: 你使用的客户端平台是…
options:
- Windows
- Mac
validations:
required: true
- type: textarea
id: what-happened
attributes:
label: 错误描述
description: |
请详细描述你遇到的问题,例如下载使用的客户端、提供下载后的文件、操作步骤、错误提示等你认为会帮助修正错误的信息。
validations:
required: true
- type: textarea
id: logs
attributes:
label: 相关日志
description: 如果有相关日志,请附上。浏览器日志可以通过 F12 打开开发者工具,在 Console 选项卡中查看。
- type: checkboxes
id: terms
attributes:
label: 检查清单
description: 请检查下方的快速检查清单,确保你已经完成了所有步骤。
options:
- label: 我有填写一个简单易懂的标题
required: true
- label: 我有阅读上方的说明
required: true
- label: 我有阅读 um-react 的答疑部分
required: true

View File

@@ -0,0 +1,51 @@
name: 酷我音乐 (安卓)
about: 解密使用「酷我音乐」的「安卓」客户端下载的文件失败时选择该项。
title: '[酷我音乐]: 请填写标题'
body:
- type: markdown
attributes:
value: |
### 酷我音乐 - 安卓客户端
你的手机需要 root 权限。注意 root 可能会导致手机保修失效,操作不当可能会导致手机变砖。
请参考 [um-react](https://um-react.netlify.app/) 上方的答疑区域获取说明。
此外请使用 Chrome 或 Firefox 浏览器,而非系统自带的浏览器或轻量浏览器,如 Via 浏览器。
※ 如果你使用酷我音乐的是所谓“破解版”,你的问题会被忽略。
已知部分“第三方魔改”会破坏密钥写出过程,请从官方渠道安装酷我音乐。
---
如果你确定你的客户端版本符合上述描述,并遇到了问题,请继续填写下面的表单。
- type: textarea
id: what-happened
attributes:
label: 错误描述
description: |
请详细描述你遇到的问题,例如下载使用的客户端、提供下载后的文件、操作步骤、错误提示等你认为会帮助修正错误的信息。
validations:
required: true
- type: textarea
id: logs
attributes:
label: 相关日志
description: 如果有相关日志,请附上。浏览器日志可以通过 F12 打开开发者工具,在 Console 选项卡中查看。
- type: checkboxes
id: terms
attributes:
label: 检查清单
description: 请检查下方的快速检查清单,确保你已经完成了所有步骤。
options:
- label: 我有填写一个简单易懂的标题
required: true
- label: 我有阅读上方的说明
required: true
- label: 我有阅读 um-react 的答疑部分
required: true
- label: 我的安卓设备已获得 root 权限
required: true
- label: 我能使用官方渠道下载的酷我音乐客户端复现该问题
required: true

View File

@@ -0,0 +1,4 @@
---
name: '其它'
about: '如果你遇到的问题不符合上述模板的描述,请选择此项。'
---

View File

@@ -0,0 +1 @@
blank_issues_enabled: false

View File

@@ -0,0 +1,38 @@
name: Build and Deploy
on: [push]
jobs:
build:
runs-on: ubuntu-latest
env:
npm_config_registry: https://registry.npmmirror.com
steps:
- name: Check out repository code
uses: actions/checkout@v4
- name: Setup pnpm
uses: pnpm/action-setup@v4.0.0
with:
standalone: true
run_install: |
- args: [--frozen-lockfile, --strict-peer-dependencies]
- name: Build
run: pnpm build
- name: Pack Win64
run: |
python3 -m zipfile -c um-react.zip dist/.
./scripts/make-win64.sh
- name: Publish Artifact
uses: christopherhx/gitea-upload-artifact@v4
with:
name: site
path: dist/
- name: Prepare for deployment
run: |
cp um-react.zip dist/"release-${GITHUB_SHA}.zip"
cp win64/dist/*.zip dist/"release-${GITHUB_SHA}-win64.zip"
python3 -m zipfile -c um-react-site.zip dist/.
- name: Deploy
env:
NETLIFY_SITE_ID: ${{ secrets.NETLIFY_SITE_ID }}
NETLIFY_API_KEY: ${{ secrets.NETLIFY_API_KEY }}
run: ./scripts/deploy.sh

4
.gitignore vendored
View File

@@ -32,3 +32,7 @@ dist-ssr
/um-react*.exe
/win64/
# Python
*.py[cod]
__pycache__

View File

@@ -1,4 +0,0 @@
#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"
pnpm exec lint-staged

View File

@@ -1,4 +0,0 @@
#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"
pnpm test

4
.npmrc
View File

@@ -1,5 +1,3 @@
use-node-version=20.10.0
node-version=20.10.0
use-node-version=22.12.0
engine-strict=true
@um:registry=https://git.unlock-music.dev/api/packages/um/npm/
@unlock-music:registry=https://git.unlock-music.dev/api/packages/um/npm/

View File

@@ -1,11 +1,9 @@
{
"recommendations": [
"editorconfig.editorconfig",
"bradlc.vscode-tailwindcss",
"dbaeumer.vscode-eslint",
"editorconfig.editorconfig",
"esbenp.prettier-vscode",
"christian-kohler.path-intellisense",
"txava.region-marker",
"foxundermoon.shell-format",
"jock.svg"
"foxundermoon.shell-format"
]
}

25
Dockerfile Normal file
View File

@@ -0,0 +1,25 @@
FROM node:22-slim AS build
ENV PNPM_HOME="/p"
ENV PATH="$PNPM_HOME:$PATH"
WORKDIR /app
RUN corepack enable pnpm \
&& apt-get update \
&& apt-get install -y --no-install-recommends git \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*
COPY package.json pnpm-lock.yaml .npmrc ./
RUN pnpm exec true
COPY . .
RUN pnpm install --frozen-lockfile
ARG GIT_COMMIT=
ARG GIT_COMMIT_FULL=
RUN pnpm build
FROM caddy:latest
COPY --from=build /app/dist /srv/um-react
EXPOSE 80
CMD ["caddy", "file-server", "--root", "/srv/um-react"]

View File

@@ -1,20 +1,23 @@
# Unlock Music 音乐解锁 (React)
[![Build Status](https://ci.unlock-music.dev/api/badges/um/um-react/status.svg)](https://ci.unlock-music.dev/um/um-react)
[![Build Status](https://git.unlock-music.dev/um/um-react/actions/workflows/build.yaml/badge.svg)][um-react-actions]
- 在浏览器中解锁加密的音乐文件。 Unlock encrypted music file in the browser.
- 查看[原基于 Vue 的 Unlock Music 项目][um-vue]
- Unlock Music 项目是以学习和技术研究的初衷创建的,修改、再分发时请遵循[授权协议]。
- Unlock Music 的 CLI 版本可以在 [unlock-music/cli] 找到,大批量转换建议使用 CLI 版本。
- 我们新建了 Telegram 群组 [`@unlock_music_chat`] ,欢迎加入!
- CI 自动构建已经部署,可以在 [Packages][um-react-packages] 下载。
- CI 自动构建已经部署,可以在 [Actions][um-react-actions] 寻找对应的<ruby>构建产物<rp>(</rp><rt>Artifact</rt><rp>)</rp> </ruby>下载。
- [常见问题参考](./docs/faq_zh-hans.md)
> **WARNING**
> 在本站 fork 不会起到备份的作用,只会浪费服务器储存空间。如无必要请勿 fork 该仓库。
[授权协议]: https://git.unlock-music.dev/um/um-react/src/branch/main/LICENSE
[um-vue]: https://git.unlock-music.dev/um/web
[unlock-music/cli]: https://git.unlock-music.dev/um/cli
[`@unlock_music_chat`]: https://t.me/unlock_music_chat
[um-react-packages]: https://git.unlock-music.dev/um/-/packages/generic/um-react/
[um-react-actions]: https://git.unlock-music.dev/um/um-react/actions?workflow=build.yaml
⚠️ 手机端浏览器支持有限,请使用最新版本的 Chrome 或 Firefox 官方浏览器。
@@ -29,24 +32,60 @@
- [x] 网易云音乐 (`.ncm`)
- [x] 虾米音乐 (`.xm`)
- [x] 酷我音乐 (`.kwm`)
- [x] 酷狗音乐 (`.kgm` / `.vpr`)
- [x] 喜马拉雅 Android 端 (`.x2m` / `.x3m`)
- [x] 酷狗音乐 (`.kgm` / `.vpr` / `.kgg`)
- PC / 安卓客户端的 `kgg` 文件需要提供密钥数据库。
- [x] 喜马拉雅 (`.x2m` / `.x3m` / `.xm`)
- [x] 咪咕音乐格式 (`.mg3d`)
- [x] 蜻蜓 FM (`.qta`)
- [ ] ~~<ruby>QQ 音乐海外版<rt>JOOX Music</rt></ruby> (`.ofl_en`)~~
[^qm-key-pc]: PC 客户端仅支持 v19.43 或更低版本。
[^qm-key-android]: 需要获取超级管理员权限后提取密钥数据库,并导入后使用。
[^qm-key-ios]: 需要越狱获取密钥数据库,或对设备进行完整备份后提取密钥数据库,并导入后使用。
[^qm-key-mac]: 需要导入密钥数据库。
不支持的格式?请提交样本(加密文件)与客户端信息(或一并上传其安装包)到[仓库的问题追踪区][project-issues]
。如果文件太大,请上传到不需要登入下载的网盘,如 [mega.nz](https://mega.nz)、[OneDrive](https://www.onedrive.com/) 等。
## 错误报告
如果遇到解密出错的情况,请一并携带错误信息并简单描述错误的重现过程
有不支持的格式?请提交样本(加密文件)与客户端信息版本信息(如系统版本、下载渠道),或一并上传其安装包到[仓库的问题追踪区][project-issues]
⚠️ 如果文件太大,请上传到不需要登入下载的网盘,如 [mega.nz](https://mega.nz)、[OneDrive](https://www.onedrive.com/) 等。
遇到解密出错的情况,请一并携带错误信息(诊断信息)并简单描述错误的重现过程。
待实现的算法支持可[追踪 `crypto` 标签](https://git.unlock-music.dev/um/um-react/issues?labels=67)。
[project-issues]: https://git.unlock-music.dev/um/um-react/issues/new
## 使用 Docker 构建、部署 (Linux)
首先克隆仓库并进入目录:
```sh
git clone https://git.unlock-music.dev/um/um-react.git
cd um-react
```
构建 Docker 镜像:
```sh
docker build \
-t um-react \
--build-arg GIT_COMMIT_FULL="$(git describe --long --dirty --tags --always)" \
--build-arg GIT_COMMIT="$(git rev-parse --short HEAD)" \
.
```
在后台运行 Docker 容器:
```sh
docker run -d -p 8080:80 --name um-react um-react
```
然后访问 `http://localhost:8080` 即可。
## 开发相关
从源码运行或编译生产版本,请参考文档「[新手上路](./docs/getting-started.zh.md)」。
@@ -55,7 +94,7 @@
⚠️ 如果只是进行前端方面的更改,你可以跳过该节。
请参考文档「[面向 `@unlock-music/crypto` 开发](./docs/develop-with-um_crypto.zh)」。
请参考文档「[面向 `@unlock-music/crypto` 开发](./docs/develop-with-um_crypto.zh.md)」。
### 架构
@@ -78,6 +117,8 @@
- [Unlock Music (Web)](https://git.unlock-music.dev/um/web) - 原始项目
- [Unlock Music (Cli)](https://git.unlock-music.dev/um/cli) - 命令行批量处理版
- [lib_um_crypto_rust](https://git.unlock-music.dev/um/lib_um_crypto_rust) - 项目引入的解密算法实现
- [NPM 包](https://git.unlock-music.dev/um/-/packages/npm/@unlock-music%2Fcrypto)
- [um-react (Electron 前端)](https://github.com/CarlGao4/um-react-electron) - 使用 Electron 框架封装的本地可执行文件。
- [GitHub 下载](https://github.com/CarlGao4/um-react-electron/releases/latest) | [仓库镜像](https://git.unlock-music.dev/CarlGao4/um-react-electron)
- [um-react-wry](https://git.unlock-music.dev/um/um-react-wry) - 使用 WRY 框架封装的 Win64 单文件 (
@@ -87,13 +128,3 @@
[webview2_redist]: https://go.microsoft.com/fwlink/p/?LinkId=2124703
有新的项目提交?欢迎[提交 issue][project-issues],请带上项目名称和链接。
## TODO
- 待定
- [ ] 各类算法 [追踪 `crypto` 标签](https://git.unlock-music.dev/um/um-react/issues?labels=67)
- 完成
- [x] #7 ~~简易元数据编辑器~~ 放弃
- [x] #8 ~~添加单元测试~~ 框架加上了,以后慢慢添加更多测试即可。
- [x] #2 解密内容探测 (解密过程)
- [x] #6 文件拖放 (利用 `react-dropzone`?)

43
eslint.config.mjs Normal file
View File

@@ -0,0 +1,43 @@
import eslint from '@eslint/js';
import tseslint from 'typescript-eslint';
import reactRefresh from 'eslint-plugin-react-refresh';
import reactHooks from 'eslint-plugin-react-hooks';
import eslintConfigPrettier from 'eslint-config-prettier/flat';
import globals from 'globals';
export default tseslint.config(
eslint.configs.recommended,
tseslint.configs.recommended,
reactRefresh.configs.recommended,
reactHooks.configs['recommended-latest'],
eslintConfigPrettier,
{
rules: {
'react-refresh/only-export-components': 'warn',
'@typescript-eslint/no-unused-vars': [
'error',
{
varsIgnorePattern: '^_',
argsIgnorePattern: '^_',
destructuredArrayIgnorePattern: '^_',
ignoreRestSiblings: true,
},
],
},
},
{
ignores: ['**/dist/', '**/node_modules/', '**/coverage/'],
},
{
files: ['scripts/*.mjs'],
languageOptions: {
globals: {
...globals.node,
},
},
},
);

View File

@@ -1,8 +1,8 @@
<!DOCTYPE html>
<!doctype html>
<html lang="zh-cmn-Hans-CN">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
<title>音乐解锁 - Unlock Music</title>
<meta name="description" content="音乐解锁 - Unlock Music" />
@@ -10,6 +10,7 @@
<link rel="apple-touch-icon" href="/pwa-512x512.png" sizes="512x512" />
<meta name="theme-color" content="#4DBA87" />
</head>
<body>
<main id="root"></main>
<script type="module" src="/src/main.tsx"></script>

11870
package-lock.json generated Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -1,12 +1,12 @@
{
"name": "um-react",
"private": true,
"version": "0.3.0",
"version": "0.5.0",
"type": "module",
"scripts": {
"start": "vite",
"build": "tsc -p tsconfig.prod.json && vite build && pnpm build:finalize",
"build:finalize": "node scripts/write-version.mjs && node scripts/minify-mjs.mjs",
"build:finalize": "node scripts/write-version.mjs",
"lint": "eslint src --ext ts,tsx --report-unused-disable-directives --max-warnings 0",
"format": "prettier -w .",
"test": "vitest run",
@@ -14,66 +14,75 @@
"test:coverage": "vitest run --coverage",
"preview": "vite preview",
"preview:coverage": "vite preview --outDir coverage --port 5175",
"prepare": "husky install"
"prepare": "simple-git-hooks"
},
"dependencies": {
"@chakra-ui/anatomy": "^2.2.2",
"@chakra-ui/icons": "^2.1.1",
"@chakra-ui/react": "^2.8.2",
"@emotion/react": "^11.11.1",
"@emotion/styled": "^11.11.0",
"@reduxjs/toolkit": "^2.0.1",
"@unlock-music/crypto": "0.1.0",
"framer-motion": "^11.5.6",
"nanoid": "^5.0.7",
"radash": "^12.1.0",
"react": "^18.3.1",
"react-dom": "^18.3.1",
"react-dropzone": "^14.2.3",
"react-icons": "^5.3.0",
"react-promise-suspense": "^0.3.4",
"react-redux": "^9.1.2",
"react-syntax-highlighter": "^15.5.0",
"sass": "^1.79.3",
"sql.js": "^1.11.0"
"@reduxjs/toolkit": "^2.8.2",
"@unlock-music/crypto": "0.1.10",
"classnames": "^2.5.1",
"nanoid": "^5.1.5",
"radash": "^12.1.1",
"react": "^19.1.0",
"react-dom": "^19.1.0",
"react-dropzone": "^14.3.8",
"react-icons": "^5.5.0",
"react-redux": "^9.2.0",
"react-router": "^7.6.3",
"react-syntax-highlighter": "^15.6.1",
"react-toastify": "^11.0.5",
"sql.js": "^1.13.0"
},
"devDependencies": {
"@rollup/plugin-replace": "^6.0.1",
"@testing-library/jest-dom": "^6.5.0",
"@testing-library/react": "^16.0.1",
"@testing-library/user-event": "^14.5.2",
"@types/node": "^22.6.1",
"@types/react": "^18.3.9",
"@types/react-dom": "^18.3.0",
"@eslint/js": "^9.30.1",
"@rollup/plugin-replace": "^6.0.2",
"@tailwindcss/vite": "^4.1.11",
"@testing-library/jest-dom": "^6.6.3",
"@testing-library/react": "^16.3.0",
"@testing-library/user-event": "^14.6.1",
"@types/node": "^24.0.10",
"@types/react": "^19.1.8",
"@types/react-dom": "^19.1.6",
"@types/react-syntax-highlighter": "^15.5.13",
"@types/sql.js": "^1.4.9",
"@typescript-eslint/eslint-plugin": "^8.7.0",
"@typescript-eslint/parser": "^8.7.0",
"@vitejs/plugin-react": "^4.3.1",
"@vitest/coverage-v8": "^2.1.1",
"@vitest/ui": "^2.1.1",
"eslint": "^8.57.1",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-react-hooks": "^4.6.2",
"eslint-plugin-react-refresh": "^0.4.12",
"husky": "^9.1.6",
"jsdom": "^25.0.1",
"lint-staged": "^15.2.10",
"prettier": "^3.3.3",
"rollup": "^4.22.4",
"terser": "^5.33.0",
"typescript": "^5.6.2",
"vite": "^5.4.7",
"vite-plugin-pwa": "^0.20.5",
"vite-plugin-top-level-await": "^1.4.4",
"vite-plugin-wasm": "^3.3.0",
"vitest": "^2.1.1",
"workbox-window": "^7.1.0"
"@types/wicg-file-system-access": "^2023.10.6",
"@typescript-eslint/eslint-plugin": "^8.35.1",
"@typescript-eslint/parser": "^8.35.1",
"@vitejs/plugin-react": "^4.6.0",
"@vitest/coverage-v8": "^3.2.4",
"@vitest/ui": "^3.2.4",
"daisyui": "^5.0.43",
"eslint": "^9.30.1",
"eslint-config-prettier": "^10.1.5",
"eslint-plugin-react-hooks": "^5.2.0",
"eslint-plugin-react-refresh": "^0.4.20",
"globals": "^16.3.0",
"husky": "^9.1.7",
"jsdom": "^26.1.0",
"lint-staged": "^16.1.2",
"prettier": "^3.6.2",
"rollup": "^4.44.2",
"sass": "^1.89.2",
"simple-git-hooks": "^2.13.0",
"tailwindcss": "^4.1.11",
"terser": "^5.43.1",
"typescript": "^5.8.3",
"typescript-eslint": "^8.35.1",
"vite": "^6.3.5",
"vite-plugin-pwa": "^1.0.1",
"vite-plugin-top-level-await": "^1.5.0",
"vite-plugin-wasm": "^3.4.1",
"vitest": "^3.2.4",
"workbox-build": "^7.3.0",
"workbox-window": "^7.3.0"
},
"lint-staged": {
"*": "prettier --write --ignore-unknown",
"*.{js,jsx,ts,tsx}": "eslint --fix --report-unused-disable-directives --max-warnings 0"
},
"simple-git-hooks": {
"pre-commit": "pnpm exec lint-staged",
"pre-push": "pnpm test"
},
"prettier": {
"singleQuote": true,
"printWidth": 120,
@@ -88,5 +97,6 @@
"rollup-plugin-terser": "npm:@rollup/plugin-terser@0.4.3",
"sourcemap-codec": "npm:@jridgewell/sourcemap-codec@1.4.15"
}
}
},
"packageManager": "pnpm@9.12.1+sha512.e5a7e52a4183a02d5931057f7a0dbff9d5e9ce3161e33fa68ae392125b79282a8a8a470a51dfc8a0ed86221442eb2fb57019b0990ed24fab519bf0e1bc5ccfc4"
}

View File

@@ -1,11 +1,23 @@
diff --git a/dist/sql-wasm.js b/dist/sql-wasm.js
index b16cee5c3cbdf523f9beae920258094ae7fcbd0f..ae67be7145625c60995c5044860e87d6144a8837 100644
index 6ef6c1f54a368431b22dea4da123f1341b4a1780..8dd8a53cefa7779f0556eb1038be35ad547beabb 100644
--- a/dist/sql-wasm.js
+++ b/dist/sql-wasm.js
@@ -187,3 +187,6 @@ else if (typeof define === 'function' && define['amd']) {
else if (typeof exports === 'object'){
exports["Module"] = initSqlJs;
}
+
@@ -173,16 +173,5 @@ if(0<K)Sa=Yc;else{if(f.preRun)for("function"==typeof f.preRun&&(f.preRun=[f.preR
return initSqlJsPromise;
} // The end of our initSqlJs function
-// This bit below is copied almost exactly from what you get when you use the MODULARIZE=1 flag with emcc
-// However, we don't want to use the emcc modularization. See shell-pre.js
-if (typeof exports === 'object' && typeof module === 'object'){
- module.exports = initSqlJs;
- // This will allow the module to be used in ES6 or CommonJS
- module.exports.default = initSqlJs;
-}
-else if (typeof define === 'function' && define['amd']) {
- define([], function() { return initSqlJs; });
-}
-else if (typeof exports === 'object'){
- exports["Module"] = initSqlJs;
-}
+var module;
+export default initSqlJs;

7824
pnpm-lock.yaml generated

File diff suppressed because it is too large Load Diff

2
public/_redirects Normal file
View File

@@ -0,0 +1,2 @@
# Support SPA routing in Netlify
/* /index.html 200

View File

@@ -103,7 +103,7 @@ deploy_netlify() {
# For deployment, we care a bit less
if [[ -n "${NETLIFY_API_KEY}" && -n "${NETLIFY_SITE_ID}" ]]; then
echo "Deploy to netlify..."
echo "Deploy to netlify (branch: ${BRANCH_NAME})..."
deploy_netlify um-react-site.zip
else
echo "skip netlify deployment."

View File

@@ -26,8 +26,8 @@ ZIP_NAME="um-react-win64-${APP_VERSION}.zip"
-r um-react.zip \
-o "win64/dist/${EXE_NAME}"
touch -d 1970-01-01T00:00:00Z "win64/dist/${EXE_NAME}"
zip -9oX "win64/dist/${ZIP_NAME}" -- "win64/dist/${EXE_NAME}"
touch -d 1980-01-01T00:00:00Z "win64/dist/${EXE_NAME}"
zip -9oXj "win64/dist/${ZIP_NAME}" -- "win64/dist/${EXE_NAME}"
echo "[Build OK] 'win64/dist/${ZIP_NAME}'."
popd

View File

@@ -7,8 +7,13 @@ import { execSync } from 'node:child_process';
const __filename = fileURLToPath(import.meta.url);
const __dirname = dirname(__filename);
const commitHash = execSync('git rev-parse --short HEAD').toString('utf-8').trim();
let commitHash = process.env.GIT_COMMIT || 'unknown';
try {
commitHash = execSync('git rev-parse --short HEAD').toString('utf-8').trim();
} catch (e) {
console.error('Failed to get commit hash:', e);
}
const pkgJson = JSON.parse(readFileSync(__dirname + '/../package.json', 'utf-8'));
const pkgVer = `${pkgJson.version ?? 'unknown'}-${commitHash ?? 'unknown'}` + '\n';
const pkgVer = `${pkgJson.version ?? 'unknown'}-${commitHash}` + '\n';
writeFileSync(__dirname + '/../dist/version.txt', pkgVer, 'utf-8');

67
src/App.css Normal file
View File

@@ -0,0 +1,67 @@
@import 'tailwindcss';
@plugin "daisyui" {
themes: dracula --prefersdark;
}
/* theme: https://daisyui.com/theme-generator/#theme=eJx1kuFupCAUhV-FmGyym1TCBQHt2zB67Zg6MAFNu2323ZdhGkdH_Annu9dzjnwX1lyweC1OZjS2xa54KcrSm26YQxlwxHZyPsqMSo-XtdgPOHZZ5eQ-t_dh-MLtMr7VHrsewsn5Dm80XD_TRYfX6Xw7p5N1Q8CfU-tG58vQnjFFGYe385Sgu3AyAUtgLErufWzPv5v6F2GE_Xlm-JpRkaGMAeG1okLLHS3WNL_TinBVUSlgR7fOTminZYKznQeL8-TNuCBCHyG7bZlEg-3dolfJHzRN9CepEvWaDHPbYggLLO-wrAjIGEo1a_jDeDvYtwVWqSfQDZE1FbBZjN6n__2z9haH8koSrqng8tnsPlQaYFARLiuqWJUxfTTEgYBSFEBkzOfri0OcNJJyrXchDr0JAjHMJvXVDxfj_z4aYqkhqAnUFdVPMTBu7jI4j0-JA9V8E8DE0CsXElKl0Tco2giZsXGUNbYKNYv7s24Op-IDYozWOuNqPyPSjOC3jjSkVjvszTxGZvIzvhRXjz36ED_5Xrz2Zgz47z_whE0z */
@plugin "daisyui/theme" {
name: 'balanced';
default: true;
prefersdark: false;
color-scheme: 'light';
--color-base-100: oklch(98% 0 0);
--color-base-200: oklch(96% 0.001 286.375);
--color-base-300: oklch(92% 0.006 264.531);
--color-base-content: oklch(20% 0 0);
--color-primary: oklch(60% 0.118 184.704);
--color-primary-content: oklch(98% 0.014 180.72);
--color-secondary: oklch(60% 0.126 221.723);
--color-secondary-content: oklch(98% 0.019 200.873);
--color-accent: oklch(51% 0.222 16.935);
--color-accent-content: oklch(93% 0.032 17.717);
--color-neutral: oklch(37% 0 0);
--color-neutral-content: oklch(98% 0 0);
--color-info: oklch(42% 0.199 265.638);
--color-info-content: oklch(97% 0.014 254.604);
--color-success: oklch(52% 0.154 150.069);
--color-success-content: oklch(97% 0.021 166.113);
--color-warning: oklch(66% 0.179 58.318);
--color-warning-content: oklch(98% 0.022 95.277);
--color-error: oklch(57% 0.245 27.325);
--color-error-content: oklch(97% 0.013 17.38);
--radius-selector: 0.5rem;
--radius-field: 0.5rem;
--radius-box: 0.5rem;
--size-selector: 0.25rem;
--size-field: 0.25rem;
--border: 1px;
--depth: 1;
--noise: 1;
}
@theme {
--font-display:
system-ui, Sarasa UI SC, Source Han Sans CN, Noto Sans CJK SC, sans-serif, Apple Color Emoji, Segoe UI Emoji;
--font-mono:
ui-monospace, Consolas, Sarasa Mono CJK SC, Sarasa UI SC, Source Han Sans CN, Noto Sans CJK SC, Microsoft YaHei UI,
monospace, Apple Color Emoji, Segoe UI Emoji;
}
#root {
display: flex;
flex-direction: column;
height: 100vh;
display: flex;
flex-direction: column;
}
h1,
h2,
h3,
h4,
h5,
h6 {
&:hover > a[data-anchor] {
opacity: 0.75;
}
}

View File

@@ -16,6 +16,7 @@ test('should be able to render App', async () => {
await waitFor(() => screen.getByTestId('sdk-version'));
// Quick sanity check of known strings.
expect(screen.getByText(/在浏览器内对文件进行解锁/i)).toBeInTheDocument();
expect(screen.getByText(/UnlockMusic 团队/i)).toBeInTheDocument();
expect(screen.getByText(/音乐解锁/i)).toBeInTheDocument();
expect(screen.getByText(/Unlock Music/i)).toBeInTheDocument();
expect(screen.getByText(/MIT/i)).toBeInTheDocument();
});

49
src/components/AddKey.tsx Normal file
View File

@@ -0,0 +1,49 @@
import type { RefObject } from 'react';
import { MdAdd, MdDeleteForever, MdFileUpload } from 'react-icons/md';
export interface AddKeyProps {
addKey: () => void;
importKeyFromFile?: () => void;
clearKeys?: () => void;
refContainer?: RefObject<HTMLElement | null>;
}
export function AddKey({ addKey, refContainer, importKeyFromFile, clearKeys }: AddKeyProps) {
const scrollToLastKey = () => {
const container = refContainer?.current;
if (container) {
const inputs = container.querySelectorAll('input[data-name="key-input--name"]');
const lastInput = inputs[inputs.length - 1] as HTMLInputElement | null;
if (lastInput) {
lastInput.focus({ preventScroll: true });
lastInput.scrollIntoView({
behavior: 'smooth',
block: 'center',
});
}
}
};
const handleAddKey = () => {
addKey();
setTimeout(scrollToLastKey);
};
return (
<div className="flex flex-row justify-between items-center">
<div className="join">
<button type="button" className="join-item btn flex items-center gap-2" onClick={handleAddKey}>
<MdAdd className="text-lg" />
</button>
<button type="button" className="join-item btn flex items-center gap-2" onClick={importKeyFromFile}>
<MdFileUpload className="text-lg" />
</button>
<button type="button" className="join-item btn flex items-center gap-2 btn-error" onClick={clearKeys}>
<MdDeleteForever className="text-lg" />
</button>
</div>
</div>
);
}

View File

@@ -0,0 +1,62 @@
import { Light as SyntaxHighlighter } from 'react-syntax-highlighter';
import hljsStyleGitHub from 'react-syntax-highlighter/dist/esm/styles/hljs/github';
import { ExtLink } from '../ExtLink';
import PowerShellAdbDumpCommandTemplate from './adb_dump.ps1?raw';
import ShellAdbDumpCommandTemplate from './adb_dump.sh?raw';
import { applyTemplate } from '~/util/applyTemplate';
export interface AdbInstructionTemplateProps {
dir: string;
file: string;
platform: 'win32' | 'linux';
}
const URL_USB_DEBUGGING = 'https://developer.android.com/studio/debug/dev-options?hl=zh-cn#Enable-debugging';
const LANGUAGE_MAP = {
win32: { language: 'ps1', template: PowerShellAdbDumpCommandTemplate },
linux: { language: 'sh', template: ShellAdbDumpCommandTemplate },
};
export function AdbInstructionTemplate({ dir, file, platform }: AdbInstructionTemplateProps) {
const { language, template } = LANGUAGE_MAP[platform];
const command = applyTemplate(template, { dir, file });
return (
<ol className="list-decimal pl-4">
<li>
<p>
<code>adb</code>
</p>
{platform === 'win32' && (
<div>
<span>
💡
<ExtLink href="https://scoop.sh/#/apps?q=adb">使 Scoop </ExtLink>
</span>
</div>
)}
</li>
<li> PowerShell </li>
<li>
<ExtLink href={URL_USB_DEBUGGING}> USB </ExtLink>
</li>
<li></li>
<li>
<p> USB </p>
<SyntaxHighlighter language={language} style={hljsStyleGitHub}>
{command}
</SyntaxHighlighter>
<br />
<ExtLink className="text-nowrap" href="https://g.126.fm/04jewvw">
MuMu
</ExtLink>
使 <code>adb connect ...</code>
</li>
<li>
<code>{file}</code>
</li>
</ol>
);
}

View File

@@ -1,171 +1,73 @@
import {
Accordion,
AccordionButton,
AccordionIcon,
AccordionItem,
AccordionPanel,
Box,
Code,
Heading,
ListItem,
OrderedList,
Text,
chakra,
} from '@chakra-ui/react';
import { ExternalLinkIcon } from '@chakra-ui/icons';
import { Light as SyntaxHighlighter } from 'react-syntax-highlighter';
import hljsStyleGitHub from 'react-syntax-highlighter/dist/esm/styles/hljs/github';
import PowerShellAdbDumpCommandTemplate from './adb_dump.ps1?raw';
import ShellAdbDumpCommandTemplate from './adb_dump.sh?raw';
import { ExtLink } from '../ExtLink';
const applyTemplate = (tpl: string, values: Record<string, unknown>) => {
return tpl.replace(/\{\{\s*(\w+)\s*\}\}/g, (_, key) => (Object.hasOwn(values, key) ? String(values[key]) : '<nil>'));
};
import { Ruby } from '../Ruby';
import { useId } from 'react';
import { RootExplorerGuide } from './RootExplorerGuide';
import { AdbInstructionTemplate } from './AdbInstructionTemplate';
import { HiWord } from '../HelpText/HiWord';
export interface AndroidADBPullInstructionProps {
dir: string;
file: string;
}
const URL_AMAZE = 'https://github.com/TeamAmaze/AmazeFileManager/releases/latest';
const URL_MT2 = 'https://mt2.cn/download/';
export function AndroidADBPullInstruction({ dir, file }: AndroidADBPullInstructionProps) {
const psAdbDumpCommand = applyTemplate(PowerShellAdbDumpCommandTemplate, { dir, file });
const shAdbDumpCommand = applyTemplate(ShellAdbDumpCommandTemplate, { dir, file });
const androidInstructionId = useId();
return (
<>
<Text>
<ruby>
<rp> (</rp>
<rt>
<code>root</code>
</rt>
<rp>)</rp>
</ruby>
访访
</Text>
<Text>
<p>
<Ruby caption="root"></Ruby>访访
</p>
<p>
<chakra.span color="red.400"></chakra.span>
</Text>
<HiWord></HiWord>
</p>
<Accordion allowToggle mt="2">
<AccordionItem>
<Heading as="h3" size="md">
<AccordionButton>
<Box as="span" flex="1" textAlign="left">
</Box>
<AccordionIcon />
</AccordionButton>
</Heading>
<AccordionPanel pb={4}>
<OrderedList>
<ListItem>
<Text>
<Code>root</Code>
</Text>
</ListItem>
<ListItem>
<Text>
访 <Code>{dir}/</Code>
</Text>
</ListItem>
<ListItem>
<Text>
<Code>{file}</Code> 访
<br />
</Text>
</ListItem>
<ListItem>
<Text></Text>
</ListItem>
</OrderedList>
</AccordionPanel>
</AccordionItem>
<AccordionItem>
<Heading as="h3" size="md">
<AccordionButton>
<Box as="span" flex="1" textAlign="left">
PC ADB / PowerShell
</Box>
<AccordionIcon />
</AccordionButton>
</Heading>
<AccordionPanel pb={4}>
<OrderedList>
<ListItem>
<Text>
<Code>adb</Code>
</Text>
<Text>
💡
<ExtLink href="https://scoop.sh/#/apps?q=adb">
使 Scoop <ExternalLinkIcon />
</ExtLink>
</Text>
</ListItem>
<ListItem>
<Text> PowerShell 7 </Text>
</ListItem>
<ListItem>
<Text></Text>
</ListItem>
<ListItem>
<Text></Text>
<SyntaxHighlighter language="ps1" style={hljsStyleGitHub}>
{psAdbDumpCommand}
</SyntaxHighlighter>
</ListItem>
<ListItem>
<Text>
<Code>{file}</Code>
</Text>
</ListItem>
</OrderedList>
</AccordionPanel>
</AccordionItem>
<AccordionItem>
<Heading as="h3" size="md">
<AccordionButton>
<Box as="span" flex="1" textAlign="left">
Linux / Mac ADB / Shell
</Box>
<AccordionIcon />
</AccordionButton>
</Heading>
<AccordionPanel pb={4}>
<OrderedList>
<ListItem>
<Text>
<Code>adb</Code>
</Text>
</ListItem>
<ListItem>
<Text></Text>
</ListItem>
<ListItem>
<Text></Text>
<SyntaxHighlighter language="bash" style={hljsStyleGitHub}>
{shAdbDumpCommand}
</SyntaxHighlighter>
</ListItem>
<ListItem>
<Text>
<Code>{file}</Code>
</Text>
</ListItem>
</OrderedList>
</AccordionPanel>
</AccordionItem>
</Accordion>
<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={androidInstructionId} />
<div className="collapse-title font-semibold"></div>
<div className="collapse-content text-sm min-w-0">
<ol className="list-decimal pl-4">
<li>
<code>root</code> <ExtLink href={URL_AMAZE}>Amaze </ExtLink>
<ExtLink href={URL_MT2}>MT </ExtLink>
</li>
<li>
root
<RootExplorerGuide />
</li>
<li>
<p>
访 <code>{dir}/</code>
</p>
<p> </p>
</li>
<li>
<code>{file}</code> 访
</li>
<li></li>
</ol>
</div>
</div>
<div className="collapse collapse-arrow join-item border-base-300 border">
<input type="radio" name={androidInstructionId} />
<div className="collapse-title font-semibold"> PC 使 ADB / PowerShell</div>
<div className="collapse-content text-sm min-w-0">
<AdbInstructionTemplate dir={dir} file={file} platform="win32" />
</div>
</div>
<div className="collapse collapse-arrow join-item border-base-300 border">
<input type="radio" name={androidInstructionId} />
<div className="collapse-title font-semibold"> Linux / Mac 使 ADB / Shell</div>
<div className="collapse-content text-sm min-w-0">
<AdbInstructionTemplate dir={dir} file={file} platform="linux" />
</div>
</div>
</div>
</>
);
}

View File

@@ -0,0 +1,64 @@
import { FiMenu, FiMoreVertical } from 'react-icons/fi';
import { Header5 } from '../HelpText/Headers';
import { Ruby } from '../Ruby';
import { VQuote } from '../HelpText/VQuote';
export function RootExplorerGuide() {
return (
<div className="@container inline-flex flex-col items-start w-full pl-4">
<div className="flex flex-col items-start gap-4 @md:flex-row">
<div>
<Header5 className="[&]:mt-0 [&]:pt-0">Amaze </Header5>
<ul className="ml-2 list-disc list-inside">
<li>
<div className="inline-flex items-center gap-1">
<FiMenu />
</div>
</li>
<li>
<VQuote>
<Ruby caption="Settings"></Ruby>
</VQuote>
</li>
<li>
<VQuote>
<Ruby caption="Behaviour"></Ruby>
</VQuote>
</li>
<li>
<VQuote>
<Ruby caption="Advanced"></Ruby>
</VQuote>
<VQuote>
<Ruby caption="Root Explorer"></Ruby>
</VQuote>
</li>
</ul>
</div>
<div>
<Header5 className="[&]:mt-0 [&]:pt-0">MT </Header5>
<ul className="ml-2 list-disc list-inside">
<li>
<div className="inline-flex items-center gap-1">
<FiMenu />
</div>
</li>
<li>
<div className="inline-flex items-center">
<FiMoreVertical className="ml-1" />
<VQuote></VQuote>
</div>
</li>
<li>
<VQuote> Root </VQuote>
</li>
</ul>
</div>
</div>
</div>
);
}

View File

@@ -1,57 +1,80 @@
import { useEffect } from 'react';
import { BrowserRouter, NavLink, Route, Routes } from 'react-router';
import { MdSettings, MdHome, MdQuestionAnswer } from 'react-icons/md';
import { ChakraProvider, Tabs, TabList, TabPanels, Tab, TabPanel, Icon, chakra } from '@chakra-ui/react';
import { MainTab } from '~/tabs/MainTab';
import { SettingsTab } from '~/tabs/SettingsTab';
import { Provider } from 'react-redux';
import { theme } from '~/theme';
import { persistSettings } from '~/features/settings/persistSettings';
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';
import { DownloadAll } from '~/components/DownloadAll.tsx';
// Private to this file only.
const store = setupStore();
const tabClassNames = ({ isActive }: { isActive: boolean }) => `mb-[-2px] tab ${isActive ? 'tab-active' : ''}`;
export function AppRoot() {
useEffect(() => persistSettings(store), []);
return (
<ChakraProvider theme={theme}>
<BrowserRouter>
<Provider store={store}>
<Tabs flex={1} minH={0} display="flex" flexDir="column">
<TabList justifyContent="center">
<Tab>
<Icon as={MdHome} mr="1" />
<chakra.span></chakra.span>
</Tab>
<Tab>
<Icon as={MdSettings} mr="1" />
<chakra.span></chakra.span>
</Tab>
<Tab>
<Icon as={MdQuestionAnswer} mr="1" />
<chakra.span></chakra.span>
</Tab>
</TabList>
<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>
<TabPanels overflow="auto" minW={0} flexDir="column" flex={1} display="flex">
<TabPanel>
<MainTab />
</TabPanel>
<TabPanel flex={1} display="flex">
<SettingsTab />
</TabPanel>
<TabPanel>
<FaqTab />
</TabPanel>
</TabPanels>
</Tabs>
<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}
/>
<DownloadAll />
<Footer />
</Provider>
</ChakraProvider>
</BrowserRouter>
);
}

40
src/components/Dialog.tsx Normal file
View File

@@ -0,0 +1,40 @@
import { useEffect, useRef } from 'react';
export interface DialogProps {
closeButton?: boolean;
backdropClose?: boolean;
title?: React.ReactNode;
children: React.ReactNode;
show: boolean;
onClose: () => void;
}
export function Dialog({ closeButton, backdropClose, title, children, show, onClose }: DialogProps) {
const refModel = useRef<HTMLDialogElement>(null);
useEffect(() => {
if (show) {
refModel.current?.showModal();
} else {
refModel.current?.close();
}
}, [show]);
return (
<dialog ref={refModel} className="modal">
<div className="modal-box">
{closeButton && (
<form method="dialog" onSubmit={onClose}>
<button className="btn btn-sm btn-circle btn-ghost absolute right-2 top-2"></button>
</form>
)}
<h3 className="font-bold text-lg pb-3">{title}</h3>
{children}
</div>
{backdropClose && (
<form method="dialog" className="modal-backdrop" onSubmit={onClose}>
<button>close</button>
</form>
)}
</dialog>
);
}

View File

@@ -0,0 +1,65 @@
import { DecryptedAudioFile, selectFiles } from '~/features/file-listing/fileListingSlice';
import { FaDownload } from 'react-icons/fa';
import { useAppSelector } from '~/hooks';
import { toast } from 'react-toastify';
export function DownloadAll() {
const files = useAppSelector(selectFiles);
const filesLength = Object.keys(files).length;
const onClickDownloadAll = async () => {
let dir: FileSystemDirectoryHandle | undefined;
let success = 0;
try {
dir = await window.showDirectoryPicker();
} catch (e) {
console.error(e);
if (e instanceof Error && e.name === 'AbortError') {
return;
}
}
for (const [_, file] of Object.entries(files)) {
try {
if (dir) {
await DownloadNew(dir, file);
} else {
await DownloadOld(file);
}
success++;
} catch (e) {
console.error(`下载失败: ${file.fileName}`, e);
toast.error(`出现错误: ${e}`);
}
}
if (success === filesLength) {
toast.success(`成功下载: ${success}/${filesLength}`);
} else {
toast.error(`成功下载: ${success}/${filesLength}`);
}
};
return (
<button
style={{ width: '48px', height: '48px', paddingInline: '0px', margin: '10px', marginLeft: 'auto' }}
className="btn btn-primary"
onClick={onClickDownloadAll}
title="下载全部"
>
<FaDownload />
</button>
);
}
async function DownloadNew(dir: FileSystemDirectoryHandle, file: DecryptedAudioFile) {
const fileHandle = await dir.getFileHandle(file.cleanName + '.' + file.ext, { create: true });
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();
}

View File

@@ -1,12 +1,15 @@
import type { AnchorHTMLAttributes } from 'react';
import { ExternalLinkIcon } from '@chakra-ui/icons';
import { Link } from '@chakra-ui/react';
import { FiExternalLink } from 'react-icons/fi';
export function ExtLink({ children, ...props }: AnchorHTMLAttributes<HTMLAnchorElement>) {
export type ExtLinkProps = AnchorHTMLAttributes<HTMLAnchorElement> & {
icon?: boolean;
};
export function ExtLink({ className, icon = true, children, ...props }: ExtLinkProps) {
return (
<Link isExternal {...props} rel="noreferrer noopener nofollow">
<a rel="noreferrer noopener nofollow" target="_blank" className={`link ${className}`} {...props}>
{children}
<ExternalLinkIcon />
</Link>
{icon && <FiExternalLink className="inline size-sm ml-1" />}
</a>
);
}

View File

@@ -1,5 +1,5 @@
import classnames from 'classnames';
import { useDropzone } from 'react-dropzone';
import { Box } from '@chakra-ui/react';
export interface FileInputProps {
onReceiveFiles: (files: File[]) => void;
@@ -14,30 +14,19 @@ export function FileInput({ children, onReceiveFiles }: FileInputProps) {
});
return (
<Box
<div
{...getRootProps()}
w="100%"
maxW={480}
borderWidth="1px"
borderRadius="lg"
transitionDuration="0.5s"
p="6"
cursor="pointer"
display="flex"
flexDir="column"
alignItems="center"
_hover={{
borderColor: 'gray.400',
bg: 'gray.50',
}}
{...(isDragActive && {
bg: 'blue.50',
borderColor: 'blue.700',
})}
className={classnames(
'w-full max-w-xl border rounded-lg transition duration-500 p-6 border-base-300 mx-auto',
'cursor-pointer flex flex-col items-center bg-base-200 hover:border-gray-400 hover:bg-gray-50 hover:dark:bg-gray-800',
{
'bg-blue-50 dark:bg-blue-900 border-blue-700': isDragActive,
},
)}
tabIndex={0}
>
<input {...getInputProps()} />
{children}
</Box>
</div>
);
}

View File

@@ -1,10 +1,9 @@
import { Code, Text } from '@chakra-ui/react';
import React from 'react';
import type { ReactNode } from 'react';
export function FilePathBlock({ children }: { children: React.ReactNode }) {
export function FilePathBlock({ children }: { children: ReactNode }) {
return (
<Text as="pre" whiteSpace="pre-wrap" wordBreak="break-all">
<Code>{children}</Code>
</Text>
<pre className="whitespace-pre-wrap break-all">
<code>{children}</code>
</pre>
);
}

View File

@@ -1,45 +1,32 @@
import { Center, Flex, Link, Text } from '@chakra-ui/react';
import { Suspense } from 'react';
import { SDKVersion } from './SDKVersion';
import { CurrentYear } from './CurrentYear';
export function Footer() {
const appVersionShort = '__APP_VERSION_SHORT__';
return (
<Center
fontSize="sm"
textAlign="center"
bottom="0"
w="full"
pt="3"
pb="3"
borderTop="1px solid"
borderColor="gray.300"
bg="gray.100"
color="gray.800"
flexDir="column"
flexShrink={0}
>
<Flex as={Text}>
<Link href="https://git.unlock-music.dev/um/um-react" isExternal>
<footer className="flex flex-col text-center p-4 bg-base-200">
<p className="flex flex-row justify-center items-center h-[1em]">
<a className="link link-info mr-1" href="https://git.unlock-music.dev/um/um-react">
</Link>
{' (__APP_VERSION_SHORT__'}
<Suspense>
<SDKVersion />
</Suspense>
{') - 移除已购音乐的加密保护。'}
</Flex>
<Text>
</a>
(
<a
title="使用 MIT 授权协议"
className="link link-info"
href="https://git.unlock-music.dev/um/um-react/src/branch/main/LICENSE"
>
MIT
</a>
, v{appVersionShort}
<SDKVersion />)
</p>
<p>
{'© 2019 - '}
<CurrentYear />{' '}
<Link href="https://git.unlock-music.dev/um" isExternal>
UnlockMusic
</Link>
{' | '}
<Link href="https://git.unlock-music.dev/um/um-react/src/branch/main/LICENSE" isExternal>
使 MIT
</Link>
</Text>
</Center>
<CurrentYear />
<a className="ml-1 link link-info" href="https://git.unlock-music.dev/um">
Unlock Music
</a>
</p>
</footer>
);
}

View File

@@ -1,26 +0,0 @@
import { Heading } from '@chakra-ui/react';
import React from 'react';
export interface Header3Props {
children: React.ReactNode;
id?: string;
className?: string;
}
export function Header3({ children, className, id }: Header3Props) {
return (
<Heading
as="h3"
id={id}
className={className}
pt={3}
pb={1}
borderBottom={'1px solid'}
borderColor="gray.300"
color="gray.800"
size="lg"
>
{children}
</Heading>
);
}

View File

@@ -1,16 +0,0 @@
import { Heading } from '@chakra-ui/react';
import React from 'react';
export interface Header4Props {
children: React.ReactNode;
id?: string;
className?: string;
}
export function Header4({ children, className, id }: Header4Props) {
return (
<Heading as="h4" id={id} className={className} pt={3} pb={1} color="gray.700" size="md">
{children}
</Heading>
);
}

View File

@@ -0,0 +1,9 @@
import { RiLink } from 'react-icons/ri';
export function HeaderAnchor({ id }: { id: string }) {
return (
<a href={`#${id}`} data-anchor={id} className="absolute -left-6 opacity-10 transition-opacity duration-200">
<RiLink className="max-h-[.75em]" />
</a>
);
}

View File

@@ -0,0 +1,45 @@
import React from 'react';
import { HeaderAnchor } from './HeaderAnchor';
export interface HeaderProps {
children: React.ReactNode;
id?: string;
className?: string;
}
const commonHeaderClasses = 'relative flex items-center pt-3 pb-1 font-bold';
export function Header2({ children, className, id }: HeaderProps) {
return (
<h2 id={id} className={`${commonHeaderClasses} text-3xl border-b border-base-300 ${className}`}>
{id && <HeaderAnchor id={id} />}
{children}
</h2>
);
}
export function Header3({ children, className, id }: HeaderProps) {
return (
<h3 id={id} className={`${commonHeaderClasses} text-2xl border-b border-base-300 ${className}`}>
{id && <HeaderAnchor id={id} />}
{children}
</h3>
);
}
export function Header4({ children, className, id }: HeaderProps) {
return (
<h4 id={id} className={`${commonHeaderClasses} text-xl ${className}`}>
{id && <HeaderAnchor id={id} />}
{children}
</h4>
);
}
export function Header5({ children, className, id }: HeaderProps) {
return (
<h5 id={id} className={`${commonHeaderClasses} text-lg ${className}`}>
{id && <HeaderAnchor id={id} />}
{children}
</h5>
);
}

View File

@@ -1,9 +1,3 @@
import { Mark } from '@chakra-ui/react';
export function HiWord({ children }: { children: React.ReactNode }) {
return (
<Mark bg="orange.100" borderRadius={5} px={2} mx={1}>
{children}
</Mark>
);
export function HiWord({ className = '', children }: { className?: string; children: React.ReactNode }) {
return <mark className={`bg-orange-100 rounded-md px-2 mx-1 ${className}`}>{children}</mark>;
}

View File

@@ -1,13 +1,9 @@
import { chakra, css } from '@chakra-ui/react';
const cssUnselectable = css({ pointerEvents: 'none', userSelect: 'none' });
export function VQuote({ children }: { children: React.ReactNode }) {
return (
<>
<chakra.span css={cssUnselectable}></chakra.span>
<span className="select-none"></span>
{children}
<chakra.span css={cssUnselectable}></chakra.span>
<span className="select-none"></span>
</>
);
}

View File

@@ -0,0 +1,43 @@
import classNames from 'classnames';
import { useRef } from 'react';
export interface ImageFigureProps {
srcSet: string;
alt: string;
className?: string;
loading?: 'lazy' | 'eager';
children?: React.ReactNode;
}
export function ImageFigure({ alt, srcSet, children, className, loading }: ImageFigureProps) {
const refDialog = useRef<HTMLDialogElement>(null);
return (
<figure className={classNames(className, 'inline-flex flex-col items-center')}>
<img
className={`rounded-md cursor-pointer border border-base-300 max-h-48`}
loading={loading}
srcSet={srcSet}
alt={alt}
onClick={() => refDialog?.current?.showModal()}
/>
{children && <figcaption className="text-sm text-base-content/70">{children}</figcaption>}
<dialog ref={refDialog} className="modal text-left">
<div className="modal-box max-w-[50vw]">
<form method="dialog">
<button className="btn btn-sm btn-circle btn-ghost absolute right-2 top-2"></button>
</form>
<h3 className="font-bold text-lg"></h3>
<figure className="flex flex-col justify-center text-center">
<img srcSet={srcSet} alt={alt} />
{children && <figcaption className="text-sm text-base-content/70">{children}</figcaption>}
</figure>
</div>
<form method="dialog" className="modal-backdrop">
<button></button>
</form>
</dialog>
</figure>
);
}

View File

@@ -1,15 +1,4 @@
import {
Center,
Flex,
Modal,
ModalBody,
ModalCloseButton,
ModalContent,
ModalHeader,
ModalOverlay,
Tabs,
Text,
} from '@chakra-ui/react';
import { useEffect, useRef } from 'react';
import { FileInput } from '~/components/FileInput';
@@ -18,31 +7,43 @@ export interface ImportSecretModalProps {
children: React.ReactNode;
show: boolean;
onClose: () => void;
onImport: (file: File) => void;
onImport: (file: File) => void | Promise<void>;
}
export function ImportSecretModal({ clientName, children, show, onClose, onImport }: ImportSecretModalProps) {
const handleFileReceived = (files: File[]) => onImport(files[0]);
const handleFileReceived = (files: File[]) => {
const promise = onImport(files[0]);
if (promise instanceof Promise) {
promise.catch((err) => {
console.error('could not import: ', err);
});
}
return promise;
};
const refModel = useRef<HTMLDialogElement>(null);
useEffect(() => {
if (show) {
refModel.current?.showModal();
} else {
refModel.current?.close();
}
}, [show]);
return (
<Modal isOpen={show} onClose={onClose} closeOnOverlayClick={false} scrollBehavior="inside" size="xl">
<ModalOverlay />
<ModalContent>
<ModalHeader></ModalHeader>
<ModalCloseButton />
<Flex as={ModalBody} gap={2} flexDir="column" flex={1}>
<Center>
<FileInput onReceiveFiles={handleFileReceived}></FileInput>
</Center>
<dialog ref={refModel} className="modal">
<div className="modal-box">
<form method="dialog" onSubmit={() => onClose()}>
<button className="btn btn-sm btn-circle btn-ghost absolute right-2 top-2"></button>
</form>
<h3 className="font-bold text-lg"></h3>
<div className="py-4 flex flex-col gap-2 flex-1">
<FileInput onReceiveFiles={handleFileReceived}></FileInput>
<Text as="div" mt={2}>
{clientName && <>{clientName}</>}
</Text>
<Flex as={Tabs} variant="enclosed" flexDir="column" flex={1} minH={0}>
{children}
</Flex>
</Flex>
</ModalContent>
</Modal>
<div className="mt-2">{clientName && <>{clientName}</>}</div>
<div>{children}</div>
</div>
</div>
</dialog>
);
}

View File

@@ -0,0 +1,25 @@
import { Dialog } from '~/components/Dialog.tsx';
import React, { useState } from 'react';
interface InfoModalProps {
title?: React.ReactNode;
description?: React.ReactNode;
children?: React.ReactNode;
}
export function InfoModal(props: InfoModalProps) {
const { title, description, children } = props;
const [showModal, setShowModal] = useState(false);
return (
<div>
<button className="btn btn-info btn-sm" type="button" onClick={() => setShowModal(true)}>
{children || '这是什么?'}
</button>
<Dialog closeButton backdropClose show={showModal} onClose={() => setShowModal(false)} title={title}>
{description}
</Dialog>
</div>
);
}

View File

@@ -0,0 +1,39 @@
import classNames from 'classnames';
import React, { Fragment, useId } from 'react';
export type InstructionTab = {
id: string | number;
label: React.ReactNode;
content: React.ReactNode;
};
export interface InstructionsTabsProps {
tabs: InstructionTab[];
limitHeight?: boolean;
}
export function InstructionsTabs({ limitHeight = false, tabs }: InstructionsTabsProps) {
const id = useId();
return (
<div className={classNames('tabs tabs-lift pb-4 mt-2', { 'max-h-[32rem]': limitHeight })}>
{tabs.map(({ id: _tabId, label, content }, index) => (
<Fragment key={_tabId}>
<label className="tab dark:[--tab-border-color:#555]">
<input type="radio" name={id} defaultChecked={index === 0} />
{label}
</label>
<div
className={classNames(
'tab-content border-base-300 dark:border-[#555] bg-base-100 px-4 py-2 overflow-y-auto',
{
'max-h-[30rem]': limitHeight,
},
)}
>
{content}
</div>
</Fragment>
))}
</div>
);
}

View File

@@ -1,15 +1,12 @@
import { Icon, Kbd } from '@chakra-ui/react';
import { BsCommand } from 'react-icons/bs';
import { Ruby } from '../Ruby';
export function MacCommandKey() {
export function MacCommandKey({ className }: { className?: string }) {
return (
<ruby>
<Kbd>
<Icon as={BsCommand} />
</Kbd>
<rp> (</rp>
<rt>command</rt>
<rp>)</rp>
</ruby>
<Ruby caption="command" className={className}>
<kbd className="kbd">
<BsCommand className="text-sm" />
</kbd>
</Ruby>
);
}

View File

@@ -1,15 +1,12 @@
import { Icon, Kbd } from '@chakra-ui/react';
import { BsShift } from 'react-icons/bs';
import { Ruby } from '../Ruby';
export function ShiftKey() {
export function ShiftKey({ className }: { className?: string }) {
return (
<ruby>
<Kbd>
<Icon as={BsShift} />
</Kbd>
<rp> (</rp>
<rt>shift</rt>
<rp>)</rp>
</ruby>
<Ruby caption="shift" className={className}>
<kbd className="kbd">
<BsShift className="text-sm" />
</kbd>
</Ruby>
);
}

112
src/components/KeyInput.tsx Normal file
View File

@@ -0,0 +1,112 @@
import { PiFileAudio } from 'react-icons/pi';
import { MdDelete, MdVpnKey } from 'react-icons/md';
import type { ReactNode } from 'react';
export interface KeyInputProps {
sequence: number;
name: string;
value: string;
isValidKey?: boolean;
onSetName: (name: string) => void;
onSetValue: (value: string) => void;
onDelete: () => void;
quality?: string;
onSetQuality?: (quality: string) => void;
nameLabel?: ReactNode;
valueLabel?: ReactNode;
qualityLabel?: ReactNode;
namePlaceholder?: string;
valuePlaceholder?: string;
qualityPlaceholder?: string;
}
export function KeyInput(props: KeyInputProps) {
const {
nameLabel,
valueLabel,
qualityLabel,
namePlaceholder,
qualityPlaceholder,
valuePlaceholder,
sequence,
name,
quality,
value,
onSetName,
onSetValue,
onDelete,
onSetQuality,
isValidKey,
} = props;
return (
<li className="list-row items-center">
<div className="flex items-center justify-center w-8 h-8 text-sm font-bold text-gray-500 bg-gray-200 rounded-full">
{sequence}
</div>
<div className="join join-vertical flex-1">
<div className="flex">
<label className="input w-full rounded-tl-md last:rounded-tr-md">
<span className="cucursor-default inline-flex items-center gap-1 select-none">
{nameLabel || (
<>
<PiFileAudio />
</>
)}
</span>
<input
type="text"
className="font-mono"
placeholder={namePlaceholder}
value={name}
onChange={(e) => onSetName(e.target.value)}
data-name="key-input--name"
/>
</label>
{onSetQuality && (
<label className="input min-w-0 max-w-[10rem] ml-[-1px] rounded-tr-md">
<span className="cucursor-default inline-flex items-center gap-1 select-none">
{qualityLabel || '音质'}
</span>
<input
type="text"
className="font-mono"
placeholder={qualityPlaceholder}
value={quality}
onChange={(e) => onSetQuality(e.target.value)}
/>
</label>
)}
</div>
<label className="input w-full rounded-bl-md rounded-br-md mt-[-1px]">
<span className="cursor-default inline-flex items-center gap-1 select-none">
{valueLabel || (
<>
<MdVpnKey />
</>
)}
</span>
<input
type="text"
className="font-mono"
placeholder={valuePlaceholder}
value={value}
onChange={(e) => onSetValue(e.target.value)}
/>
<span className={isValidKey ? 'text-green-600' : 'text-red-600'}>
<code>{value.length || '?'}</code>
</span>
</label>
</div>
<button type="button" className="btn btn-error btn-sm px-1 btn-outline" onClick={onDelete}>
<MdDelete className="size-6" />
</button>
</li>
);
}

View File

@@ -0,0 +1,21 @@
import type { ReactNode, RefObject } from 'react';
export interface KeyListContainerProps {
keys: unknown[];
children?: ReactNode;
ref?: RefObject<HTMLDivElement | null>;
}
export function KeyListContainer({ keys, children, ref }: KeyListContainerProps) {
const count = keys.length;
return (
<div ref={ref} className="flex grow min-h-0 pr-4 pt-3">
{count > 0 && (
<ul className="list bg-base-100 rounded-box shadow-sm border border-base-300 w-full min-h-0 overflow-auto">
{children}
</ul>
)}
{count === 0 && <p></p>}
</div>
);
}

View File

@@ -1,4 +1,4 @@
import { Link } from '@chakra-ui/react';
import { ExtLink } from './ExtLink';
export interface ProjectIssueProps {
id: number | string;
@@ -7,9 +7,9 @@ export interface ProjectIssueProps {
export function ProjectIssue({ id, title }: ProjectIssueProps) {
return (
<Link isExternal target="_blank" href={`https://git.unlock-music.dev/um/um-react/issues/${id}`}>
<ExtLink target="_blank" href={`https://git.unlock-music.dev/um/um-react/issues/${id}`}>
{`#${id}`}
{title && ` - ${title}`}
</Link>
</ExtLink>
);
}

20
src/components/Ruby.tsx Normal file
View File

@@ -0,0 +1,20 @@
import React from 'react';
export interface RubyProps {
caption: React.ReactNode;
children: React.ReactNode;
className?: string;
}
export function Ruby(props: RubyProps) {
const { caption, children, ...rest } = props;
return (
<ruby {...rest}>
{children}
<rp>(</rp>
<rt>{caption}</rt>
<rp>)</rp>
</ruby>
);
}

View File

@@ -1,33 +1,41 @@
import { InfoOutlineIcon } from '@chakra-ui/icons';
import { Tooltip, VStack, Text, Flex } from '@chakra-ui/react';
import { MdInfoOutline } from 'react-icons/md';
import { workerClientBus } from '~/decrypt-worker/client';
import { DECRYPTION_WORKER_ACTION_NAME } from '~/decrypt-worker/constants';
import usePromise from 'react-promise-suspense';
import { useEffect, useRef, useState } from 'react';
const getSDKVersion = async (): Promise<string> => {
return workerClientBus.request(DECRYPTION_WORKER_ACTION_NAME.VERSION, null);
};
export function SDKVersion() {
const sdkVersion = usePromise(getSDKVersion, []);
const refDialog = useRef<HTMLDialogElement>(null);
const [sdkVersion, setSdkVersion] = useState('...');
useEffect(() => {
getSDKVersion().then(setSdkVersion);
}, []);
return (
<Flex as="span" pl="1" alignItems="center" data-testid="sdk-version">
<Tooltip
hasArrow
placement="top"
label={
<VStack>
<Text>App: __APP_VERSION__</Text>
<Text>SDK: {sdkVersion}</Text>
</VStack>
}
bg="gray.300"
color="black"
>
<InfoOutlineIcon />
</Tooltip>
</Flex>
<>
<span className="btn btn-ghost inline-flex p-0" onClick={() => refDialog.current?.showModal()}>
<MdInfoOutline />
</span>
<dialog ref={refDialog} className="modal text-left">
<div className="modal-box">
<form method="dialog">
<button className="btn btn-sm btn-circle btn-ghost absolute right-2 top-2"></button>
</form>
<h3 className="font-bold text-lg"></h3>
<p>App: __APP_VERSION__</p>
<p>
SDK: <span data-testid="sdk-version">{sdkVersion}</span>
</p>
</div>
<form method="dialog" className="modal-backdrop">
<button></button>
</form>
</dialog>
</>
);
}

View File

@@ -1,5 +1,4 @@
import { Box, Text } from '@chakra-ui/react';
import { UnlockIcon } from '@chakra-ui/icons';
import { FiUnlock } from 'react-icons/fi';
import { useAppDispatch } from '~/hooks';
import { addNewFile, processFile } from '~/features/file-listing/fileListingSlice';
@@ -12,7 +11,7 @@ export function SelectFile() {
console.debug(
'react-dropzone/onDropAccepted(%o, %o)',
files.length,
files.map((x) => x.name)
files.map((x) => x.name),
);
for (const file of files) {
@@ -26,7 +25,7 @@ export function SelectFile() {
id: fileId,
blobURI,
fileName,
})
}),
);
dispatch(processFile({ fileId }));
}
@@ -34,19 +33,13 @@ export function SelectFile() {
return (
<FileInput multiple onReceiveFiles={handleFileReceived}>
<Box pb={3}>
<UnlockIcon boxSize={8} />
</Box>
<Text as="div" textAlign="center">
<FiUnlock className="size-8 mb-4" />
<p className="text-center">
<Text as="span" color="teal.400">
</Text>
<span className="text-teal-700 font-semibold"></span>
<Text fontSize="sm" opacity="50%">
</Text>
</Text>
</p>
<p className="text-sm opacity-50 m-0"></p>
</FileInput>
);
}

View File

@@ -2,6 +2,7 @@ export enum DECRYPTION_WORKER_ACTION_NAME {
DECRYPT = 'DECRYPT',
FIND_QMC_MUSICEX_NAME = 'FIND_QMC_MUSICEX_NAME',
KUWO_PARSE_HEADER = 'KUWO_PARSE_HEADER',
KUGOU_PARSE_HEADER = 'KUGOU_PARSE_HEADER',
QINGTING_FM_GET_DEVICE_KEY = 'QINGTING_FM_GET_DEVICE_KEY',
VERSION = 'VERSION',
}

View File

@@ -1,16 +1,18 @@
import { DecipherInstance, DecipherOK, DecipherResult, Status } from '~/decrypt-worker/Deciphers';
import { KuGou } from '@unlock-music/crypto';
import { KuGou, KuGouHeader } from '@unlock-music/crypto';
import type { DecryptCommandOptions } from '~/decrypt-worker/types.ts';
import { chunkBuffer } from '~/decrypt-worker/util/buffer.ts';
export class KugouMusicDecipher implements DecipherInstance {
cipherName = 'Kugou';
async decrypt(buffer: Uint8Array, _options: DecryptCommandOptions): Promise<DecipherResult | DecipherOK> {
async decrypt(buffer: Uint8Array, options: DecryptCommandOptions): Promise<DecipherResult | DecipherOK> {
let kgm: KuGou | undefined;
let kgmHdr: KuGouHeader | undefined;
try {
kgm = KuGou.from_header(buffer.subarray(0, 0x400));
kgmHdr = new KuGouHeader(buffer.subarray(0, 0x400));
kgm = KuGou.fromHeaderV5(kgmHdr, options.kugouKey);
const audioBuffer = new Uint8Array(buffer.subarray(0x400));
for (const [block, offset] of chunkBuffer(audioBuffer)) {
@@ -23,6 +25,7 @@ export class KugouMusicDecipher implements DecipherInstance {
data: audioBuffer,
};
} finally {
kgmHdr?.free();
kgm?.free();
}
}

View File

@@ -38,20 +38,32 @@ export class QQMusicV2Decipher implements DecipherInstance {
this.cipherName = `QQMusic/QMC2(user_key=${+useUserKey})`;
}
async decrypt(buffer: Uint8Array, options: DecryptCommandOptions): Promise<DecipherResult | DecipherOK> {
parseFooter(buffer: Uint8Array): { size: number; ekey?: undefined | string } {
const footer = QMCFooter.parse(buffer.subarray(buffer.byteLength - 1024));
if (!footer) {
if (footer) {
const { size, ekey } = footer;
footer.free();
return { size, ekey };
}
// No footer, and we don't accept user key:
if (!this.useUserKey) {
throw new UnsupportedSourceFile('Not QMC2 File');
}
const audioBuffer = buffer.slice(0, buffer.byteLength - footer.size);
return { size: 0 };
}
async decrypt(buffer: Uint8Array, options: DecryptCommandOptions): Promise<DecipherResult | DecipherOK> {
const footer = this.parseFooter(buffer.subarray(buffer.byteLength - 1024));
const ekey = this.useUserKey ? options.qmc2Key : footer.ekey;
footer.free();
if (!ekey) {
throw new Error('EKey missing');
throw new Error('EKey required');
}
const qmc2 = new QMC2(ekey);
const audioBuffer = buffer.slice(0, buffer.byteLength - footer.size);
for (const [block, offset] of chunkBuffer(audioBuffer)) {
qmc2.decrypt(block, offset);
}

View File

@@ -2,6 +2,7 @@ export interface DecryptCommandOptions {
fileName: string;
qmc2Key?: string;
kwm2key?: string;
kugouKey?: string;
qingTingAndroidKey?: string;
}
@@ -24,6 +25,15 @@ export type ParseKuwoHeaderResponse = null | {
qualityId: number;
};
export interface ParseKugouHeaderPayload {
blobURI: string;
}
export type ParseKugouHeaderResponse = null | {
version: number;
audioHash: string;
};
export interface GetQingTingFMDeviceKeyPayload {
product: string;
device: string;

View File

@@ -1,5 +1,7 @@
export const toArrayBuffer = async (src: Blob | ArrayBuffer) => (src instanceof Blob ? await src.arrayBuffer() : src);
export const toBlob = (src: Blob | ArrayBuffer) => (src instanceof Blob ? src : new Blob([src]));
export const toArrayBuffer = async (src: Blob | ArrayBuffer | Uint8Array<ArrayBufferLike>) =>
src instanceof Blob ? await src.arrayBuffer() : src;
export const toBlob = (src: Blob | ArrayBuffer | Uint8Array<ArrayBufferLike>) =>
src instanceof Blob ? src : new Blob([src]);
export function* chunkBuffer(buffer: Uint8Array, blockLen = 4096): Generator<[Uint8Array, number], void> {
const len = buffer.byteLength;

View File

@@ -6,6 +6,7 @@ import { workerDecryptHandler } from './worker/decrypt.ts';
import { workerParseMusicExMediaName } from './worker/qmcv2_parser.ts';
import { workerGetQtfmDeviceKey } from '~/decrypt-worker/worker/qtfm_device_key.ts';
import { workerParseKuwoHeader } from '~/decrypt-worker/worker/kuwo_header_parse.ts';
import { workerParseKugouHeader } from '~/decrypt-worker/worker/kugou_parse_header.ts';
const bus = new WorkerServerBus();
onmessage = bus.onmessage;
@@ -14,4 +15,5 @@ bus.addEventHandler(DECRYPTION_WORKER_ACTION_NAME.DECRYPT, workerDecryptHandler)
bus.addEventHandler(DECRYPTION_WORKER_ACTION_NAME.FIND_QMC_MUSICEX_NAME, workerParseMusicExMediaName);
bus.addEventHandler(DECRYPTION_WORKER_ACTION_NAME.VERSION, getUmcVersion);
bus.addEventHandler(DECRYPTION_WORKER_ACTION_NAME.KUWO_PARSE_HEADER, workerParseKuwoHeader);
bus.addEventHandler(DECRYPTION_WORKER_ACTION_NAME.KUGOU_PARSE_HEADER, workerParseKugouHeader);
bus.addEventHandler(DECRYPTION_WORKER_ACTION_NAME.QINGTING_FM_GET_DEVICE_KEY, workerGetQtfmDeviceKey);

View File

@@ -0,0 +1,23 @@
import {
ParseKugouHeaderPayload, ParseKugouHeaderResponse,
} from '~/decrypt-worker/types.ts';
import { KuGouHeader } from '@unlock-music/crypto';
export const workerParseKugouHeader = async ({ blobURI }: ParseKugouHeaderPayload): Promise<ParseKugouHeaderResponse> => {
const blob = await fetch(blobURI, { headers: { Range: 'bytes=0-1023' } }).then((r) => r.blob());
const arrayBuffer = await blob.arrayBuffer();
const buffer = new Uint8Array(arrayBuffer.slice(0, 0x400));
let kwm : KuGouHeader | undefined;
try {
kwm = new KuGouHeader(buffer);
const { version, audioHash } = kwm;
return { version, audioHash };
} catch {
return null;
} finally {
kwm?.free();
}
}

View File

@@ -1,7 +1,7 @@
import { FetchMusicExNamePayload, ParseKuwoHeaderResponse } from '~/decrypt-worker/types.ts';
import { ParseKuwoHeaderPayload, ParseKuwoHeaderResponse } from '~/decrypt-worker/types.ts';
import { KuwoHeader } from '@unlock-music/crypto';
export const workerParseKuwoHeader = async ({ blobURI }: FetchMusicExNamePayload): Promise<ParseKuwoHeaderResponse> => {
export const workerParseKuwoHeader = async ({ blobURI }: ParseKuwoHeaderPayload): Promise<ParseKuwoHeaderResponse> => {
const blob = await fetch(blobURI, { headers: { Range: 'bytes=0-1023' } }).then((r) => r.blob());
const arrayBuffer = await blob.arrayBuffer();

View File

@@ -0,0 +1,75 @@
import { ExtLink } from '~/components/ExtLink';
import { Header2, Header3, Header4 } from '~/components/HelpText/Headers';
import { VQuote } from '~/components/HelpText/VQuote';
import { RiErrorWarningLine } from 'react-icons/ri';
import LdPlayerSettingsMisc2x from './assets/ld_settings_misc@2x.webp';
import MumuSettingsMisc2x from './assets/mumu_settings_misc@2x.webp';
import { ImageFigure } from '~/components/ImageFigure';
export function AndroidEmulatorFAQ() {
return (
<>
<Header2></Header2>
<p className="mb-2">便 root </p>
<ul className="list-disc pl-6 mb-2">
<li>
<ExtLink href="https://mumu.163.com/"> MuMu 12</ExtLink> - Hyper-V
</li>
<li>
<ExtLink href="https://www.ldmnq.com/"> 9</ExtLink>
</li>
</ul>
<p className="mb-2">广使</p>
<div className="my-2 alert alert-warning">
<RiErrorWarningLine className="text-lg" />
<p>
使<strong></strong>
</p>
</div>
<p className="mb-2">使</p>
<Header3 id="enable-root"> root</Header3>
<p className="mb-2"> root </p>
<Header4 id="root-mumu"> MuMu </Header4>
<ul className="list-disc pl-6">
<li>
<VQuote></VQuote>
</li>
<li>
<VQuote></VQuote>
</li>
<li>
<VQuote>Root权限</VQuote>
</li>
</ul>
<div>
<ImageFigure className="ml-2" alt="网易木木模拟器设置界面" loading="lazy" srcSet={`${MumuSettingsMisc2x} 2x`}>
</ImageFigure>
</div>
<Header4 id="root-ld"></Header4>
<ul className="list-disc pl-6">
<li>
<VQuote></VQuote>
</li>
<li>
<VQuote></VQuote>
</li>
<li>
<VQuote>ROOT </VQuote><VQuote></VQuote>
</li>
</ul>
<div>
<ImageFigure className="ml-2" alt="雷电模拟器设置界面" loading="lazy" srcSet={`${LdPlayerSettingsMisc2x} 2x`}>
</ImageFigure>
</div>
</>
);
}

45
src/faq/FAQAbout.tsx Normal file
View File

@@ -0,0 +1,45 @@
import { Header2, Header3 } from '~/components/HelpText/Headers';
import { FaRust } from 'react-icons/fa';
export function FAQAboutProject() {
return (
<div className="flex flex-col gap-4">
<Header2></Header2>
<Header3 id="failed">um-react </Header3>
<p>
um-react
<a className="mx-1 link link-info" href="https://git.unlock-music.dev/um">
Unlock Music
</a>
React 使
<a className="mx-1 link link-info" href="https://git.unlock-music.dev/um/um-react/src/branch/main/LICENSE">
MIT
</a>
</p>
<p>
<FaRust className="inline" />
<a className="mx-1 link link-info" href="https://git.unlock-music.dev/um/lib_um_crypto_rust">
<code>lib_um_crypto_rust</code>
</a>
使
<a
className="mx-1 link link-info"
href="https://git.unlock-music.dev/um/lib_um_crypto_rust/src/branch/main/LICENSE_MIT"
>
MIT
</a>
+
<a
className="mx-1 link link-info"
href="https://git.unlock-music.dev/um/lib_um_crypto_rust/src/branch/main/LICENSE_APACHE"
>
Apache
</a>
</p>
<p>使</p>
</div>
);
}

22
src/faq/FAQPages.tsx Normal file
View File

@@ -0,0 +1,22 @@
import type { ComponentType } from 'react';
import { QQMusicFAQ } from './QQMusicFAQ';
import { KuwoFAQ } from './KuwoFAQ';
import { KugouFAQ } from './KugouFAQ';
import { OtherFAQ } from './OtherFAQ';
import { AndroidEmulatorFAQ } from './AndroidEmulatorFAQ';
import { FAQAboutProject } from './FAQAbout';
export type FAQEntry = {
id: string;
name: string;
Component: ComponentType;
};
export const FAQ_PAGES: FAQEntry[] = [
{ id: 'qqmusic', name: 'QQ 音乐', Component: QQMusicFAQ },
{ id: 'kuwo', name: '酷我音乐', Component: KuwoFAQ },
{ id: 'kugou', name: '酷狗音乐', Component: KugouFAQ },
{ id: 'android-emu', name: '安卓模拟器', Component: AndroidEmulatorFAQ },
{ id: 'other', name: '其它问题', Component: OtherFAQ },
{ id: 'about', name: '关于项目', Component: FAQAboutProject },
];

15
src/faq/FaqHome.tsx Normal file
View File

@@ -0,0 +1,15 @@
import { ExtLink } from '~/components/ExtLink';
import { Header2 } from '~/components/HelpText/Headers';
export function FaqHome() {
return (
<div className="flex flex-col gap-4">
<Header2></Header2>
<p></p>
<p>
访
<ExtLink href={'https://t.me/unlock_music_chat'}>- </ExtLink>
</p>
</div>
);
}

25
src/faq/KugouFAQ.tsx Normal file
View File

@@ -0,0 +1,25 @@
import { Header2, Header3 } from '~/components/HelpText/Headers';
import { SegmentKeyImportInstructions } from './SegmentKeyImportInstructions';
import { KugouAllInstructions } from '~/features/settings/panels/Kugou/KugouAllInstructions.tsx';
import { RiErrorWarningLine } from 'react-icons/ri';
export function KugouFAQ() {
return (
<>
<Header2></Header2>
<Header3 id="failed"></Header3>
<p className="mb-2">
<code>kgg</code> Windows
</p>
<p className="mb-2"></p>
<div className="alert alert-warning mb-2">
<RiErrorWarningLine className="size-6" />
<p> root </p>
</div>
<Header3 id="keys"></Header3>
<SegmentKeyImportInstructions tab="酷狗密钥" clientInstructions={<KugouAllInstructions />} />
</>
);
}

View File

@@ -1,55 +1,47 @@
import { Alert, AlertIcon, Container, Flex, List, ListItem, Text, chakra } from '@chakra-ui/react';
import { Header4 } from '~/components/HelpText/Header4';
import { Header2, Header3 } from '~/components/HelpText/Headers';
import { VQuote } from '~/components/HelpText/VQuote';
import { SegmentTryOfficialPlayer } from './SegmentTryOfficialPlayer';
import { HiWord } from '~/components/HelpText/HiWord';
import { KWMv2AllInstructions } from '~/features/settings/panels/KWMv2/KWMv2AllInstructions';
import { SegmentKeyImportInstructions } from './SegmentKeyImportInstructions';
import { RiErrorWarningLine } from 'react-icons/ri';
export function KuwoFAQ() {
return (
<>
<Header4></Header4>
<List spacing={2}>
<ListItem>
<SegmentTryOfficialPlayer />
</ListItem>
<ListItem>
<Text>
<chakra.strong>2</chakra.strong>
</Text>
<Text>
<HiWord></HiWord>
<VQuote>
<strong></strong>
</VQuote>
<VQuote>
<strong></strong>
</VQuote>
{'音质的音乐文件采用新版加密。'}
</Text>
<Text></Text>
<Text>PC平台暂未推出使用新版加密的音质</Text>
<Header2></Header2>
<Header3 id="failed"></Header3>
<SegmentTryOfficialPlayer />
<p className="mb-2">
<HiWord></HiWord>
<VQuote>
<strong></strong>
</VQuote>
<VQuote>
<strong></strong>
</VQuote>
</p>
<p className="mb-2"></p>
<p className="mb-2">PC平台暂未推出使用新版加密的音质</p>
<Container p={2}>
<Alert status="warning" borderRadius={5}>
<AlertIcon />
<Flex flexDir="column">
<Text> root </Text>
<Text>
<strong></strong>
</Text>
<Text>
<strong></strong>使使
</Text>
</Flex>
</Alert>
</Container>
<Header3 id="keys"></Header3>
<div className="alert alert-warning my-2">
<RiErrorWarningLine className="text-2xl" />
<div>
<p> root </p>
<p>
<strong className="pr-2"></strong>
</p>
<p>
<strong className="pr-2"></strong>
使使
</p>
</div>
</div>
<SegmentKeyImportInstructions tab="KWMv2 密钥" clientInstructions={<KWMv2AllInstructions />} />
</ListItem>
</List>
<SegmentKeyImportInstructions tab="KWMv2 密钥" clientInstructions={<KWMv2AllInstructions />} />
</>
);
}

View File

@@ -1,139 +1,109 @@
import { Alert, AlertIcon, Code, Container, Flex, Img, ListItem, Text, UnorderedList } from '@chakra-ui/react';
import { ExtLink } from '~/components/ExtLink';
import { Header4 } from '~/components/HelpText/Header4';
import { VQuote } from '~/components/HelpText/VQuote';
import { Header2, Header3, Header4 } from '~/components/HelpText/Headers';
import { ProjectIssue } from '~/components/ProjectIssue';
import LdPlayerSettingsScreen from './assets/ld_settings_misc.webp';
import { NavLink } from 'react-router';
export function OtherFAQ() {
return (
<>
<Header4></Header4>
<Text></Text>
<Text>使</Text>
<Header2></Header2>
<Header3 id="metadata"></Header3>
<p></p>
<p>使</p>
<Header4></Header4>
<Text>
<Header3 id="batch-dl"></Header3>
<p>
{'暂时没有实现,不过你可以在 '}
<ProjectIssue id={34} title="[UI] 全部下载功能" />
{' 以及 '}
<ProjectIssue id={43} title="批量下载" />
{' 追踪该问题。'}
</Text>
</p>
<Header4>安卓: 浏览器支持说明</Header4>
<Text> 使 Chrome Firefox </Text>
<Text></Text>
<UnorderedList>
<ListItem>Via </ListItem>
<ListItem></ListItem>
<ListItem>UC </ListItem>
</UnorderedList>
<Text></Text>
<UnorderedList>
<ListItem></ListItem>
<ListItem></ListItem>
<ListItem></ListItem>
</UnorderedList>
<Header3 id="android-browsers">安卓: 浏览器支持说明</Header3>
<p> 使 Chrome Firefox </p>
<div className="flex flex-col md:flex-row gap-2 md:gap-8">
<div>
<Header4></Header4>
<ul className="list-disc list-inside pl-2">
<li>Via </li>
<li></li>
<li>UC </li>
</ul>
</div>
<Header4>安卓: root </Header4>
<Text>
<div>
<Header4></Header4>
<ul className="list-disc list-inside pl-2">
<li></li>
<li></li>
<li></li>
</ul>
</div>
</div>
<Header3 id="android-root"> root</Header3>
<p>
root 使
使 NFC
</Text>
<Text>使</Text>
<Text>
root 广 Windows 11
<ExtLink href="https://learn.microsoft.com/zh-cn/windows/android/wsa/">
<ruby>
Android Windows (WSA)
<rp> (</rp>
<rt>
<code>Windows Subsystem for Android</code>
</rt>
<rp>)</rp>
</ruby>
</ExtLink>
使 NFC
</p>
<p className="my-2">
使
<NavLink className="link link-info" to="/questions/android-emu">
</NavLink>
</Text>
</p>
<Container p={2}>
<Alert status="warning" borderRadius={5}>
<AlertIcon />
<Flex flexDir="column">
<Text>
<strong></strong>使<strong></strong>
{';使用前请自行评估风险。'}
</Text>
</Flex>
</Alert>
</Container>
<UnorderedList>
<ListItem>
<Text>
{'WSA 可以参考 '}
<ExtLink href="https://github.com/LSPosed/MagiskOnWSALocal">MagiskOnWSALocal</ExtLink>
{' 的说明操作。'}
</Text>
</ListItem>
<ListItem>
<Text>
<VQuote></VQuote> <VQuote></VQuote> root
</Text>
<Img borderRadius={5} border="1px solid #ccc" src={LdPlayerSettingsScreen}></Img>
</ListItem>
</UnorderedList>
<Header4></Header4>
<UnorderedList>
<ListItem>
<Text>
<ExtLink href="https://github.com/CarlGao4/um-react-electron">
<Header3 id="projects"></Header3>
<ul className="list-disc pl-6">
<li>
<p>
<ExtLink className="mr-2" href="https://github.com/CarlGao4/um-react-electron">
<strong>
<Code>um-react-electron</Code>
<code>um-react-electron</code>
</strong>
</ExtLink>
Electron WindowsLinux Mac
</Text>
<UnorderedList>
<ListItem>
<Text>
Electron WindowsLinux Mac
</p>
<ul className="list-disc pl-6">
<li>
<p>
<ExtLink href="https://github.com/CarlGao4/um-react-electron/releases/latest">GitHub </ExtLink>
</Text>
</ListItem>
</UnorderedList>
</ListItem>
<ListItem>
<Text>
<ExtLink href="https://git.unlock-music.dev/um/um-react-wry">
</p>
</li>
</ul>
</li>
<li>
<p>
<ExtLink className="mr-2" href="https://git.unlock-music.dev/um/um-react-wry">
<strong>
<Code>um-react-wry</Code>
<code>um-react-wry</code>
</strong>
</ExtLink>
: 使 WRY Win64
使 WRY Win64
<ExtLink href="https://go.microsoft.com/fwlink/p/?LinkId=2124703"> Edge WebView2 </ExtLink>
{'Win10+ 操作系统自带)'}
</Text>
<UnorderedList>
<ListItem>
<Text>
</p>
<ul className="list-disc pl-6">
<li>
<p>
<ExtLink href="https://git.unlock-music.dev/um/um-react/releases/latest"></ExtLink>
{' | 寻找文件名为 '}
<Code>um-react-win64-</Code>
</Text>
</ListItem>
</UnorderedList>
</ListItem>
</UnorderedList>
<code>um-react-win64-</code>
</p>
</li>
</ul>
</li>
</ul>
<Header4></Header4>
<Text>
{'欢迎进入 '}
<ExtLink href={'https://t.me/unlock_music_chat'}>Telegram - </ExtLink>
{' 一起探讨。'}
</Text>
<Header3 id="more-questions"></Header3>
<p className="flex flex-row gap-1">
<ExtLink href={'https://t.me/unlock_music_chat'}>- </ExtLink>
</p>
</>
);
}

View File

@@ -1,63 +1,25 @@
import { Alert, AlertIcon, Container, Flex, List, ListItem, Text, UnorderedList, chakra } from '@chakra-ui/react';
import { Header4 } from '~/components/HelpText/Header4';
import { Header2, Header3 } from '~/components/HelpText/Headers';
import { SegmentTryOfficialPlayer } from './SegmentTryOfficialPlayer';
import { QMCv2QQMusicAllInstructions } from '~/features/settings/panels/QMCv2/QMCv2QQMusicAllInstructions';
import { SegmentKeyImportInstructions } from './SegmentKeyImportInstructions';
import { ExtLink } from '~/components/ExtLink';
export function QQMusicFAQ() {
return (
<>
<Header4></Header4>
<List spacing={2}>
<ListItem>
<SegmentTryOfficialPlayer />
</ListItem>
<ListItem>
<Text>
<chakra.strong>2</chakra.strong>
</Text>
<Text>
Windows 19.43
QQ Windows v19.43
</Text>
<UnorderedList pl={3}>
<ListItem>
<Text>
<ExtLink href="https://dldir1v6.qq.com/music/clntupate/QQMusic_Setup_1943.exe">
<code>qq.com</code>
</ExtLink>
</Text>
</ListItem>
<ListItem>
<Text>
<ExtLink href="https://web.archive.org/web/2023/https://dldir1v6.qq.com/music/clntupate/QQMusic_Setup_1943.exe">
<code>Archive.org</code>
</ExtLink>
</Text>
</ListItem>
</UnorderedList>
<Header2>QQ </Header2>
<Header3 id="failed"></Header3>
<SegmentTryOfficialPlayer />
<p className="mb-2"> QQ </p>
<p className="mb-2"></p>
<p className="mb-2"></p>
<Container p={2}>
<Alert status="warning" borderRadius={5}>
<AlertIcon />
<Flex flexDir="column">
<Text>iOS </Text>
<Text>root</Text>
</Flex>
</Alert>
</Container>
<Header3 id="about-download"></Header3>
<p></p>
<p className="my-2">
<strong></strong>使
</p>
<Container p={2} pt={0}>
<Alert status="info" borderRadius={5}>
<AlertIcon />
</Alert>
</Container>
<SegmentKeyImportInstructions tab="QMCv2 密钥" clientInstructions={<QMCv2QQMusicAllInstructions />} />
</ListItem>
</List>
<Header3 id="keys-or-downgrade"></Header3>
<QMCv2QQMusicAllInstructions />
</>
);
}

View File

@@ -1,24 +1,13 @@
import { Flex, IconButton } from '@chakra-ui/react';
import { MdExpandMore } from 'react-icons/md';
import { HiWord } from '~/components/HelpText/HiWord';
import { VQuote } from '~/components/HelpText/VQuote';
import { MdFileUpload } from 'react-icons/md';
export function SegmentAddKeyDropdown() {
return (
<Flex as="span" alignItems="center" flexWrap="wrap">
<VQuote></VQuote>
<HiWord></HiWord>
<IconButton
colorScheme="purple"
variant="outline"
size="sm"
icon={<MdExpandMore />}
ml="2"
borderTopLeftRadius={0}
borderBottomLeftRadius={0}
pointerEvents="none"
aria-label="下拉按钮"
/>
</Flex>
<span className="inline-flex items-center flex-wrap">
<button type="button" className="btn flex items-center gap-2">
<MdFileUpload className="text-lg" />
</button>
</span>
);
}

View File

@@ -1,44 +1,37 @@
import { Flex, Icon, ListItem, OrderedList, Tabs, Text } from '@chakra-ui/react';
import { SegmentTopNavSettings } from './SegmentTopNavSettings';
import { VQuote } from '~/components/HelpText/VQuote';
import { SegmentAddKeyDropdown } from './SegmentAddKeyDropdown';
import React from 'react';
import { MdFileUpload } from 'react-icons/md';
export interface SegmentKeyImportInstructionsProps {
clientInstructions: React.ReactNode;
tab: string;
keyInstructionText?: React.ReactNode;
}
export function SegmentKeyImportInstructions({ clientInstructions, tab }: SegmentKeyImportInstructionsProps) {
export function SegmentKeyImportInstructions({
clientInstructions,
tab,
keyInstructionText = '选择你的客户端平台来查看密钥提取说明:',
}: SegmentKeyImportInstructionsProps) {
return (
<>
<Text></Text>
<OrderedList>
<ListItem>
<p className="mt-2"></p>
<ol className="list-decimal pl-5">
<li>
<SegmentTopNavSettings />
</ListItem>
<ListItem>
</li>
<li>
<VQuote>{tab}</VQuote>
</ListItem>
<ListItem>
</li>
<li>
<SegmentAddKeyDropdown />
</ListItem>
<ListItem>
<Flex flexDir="row" alignItems="center">
{'选择 '}
<VQuote>
<Icon as={MdFileUpload} boxSize={5} mr={2} />
</VQuote>
</Flex>
</ListItem>
<ListItem>
<Text></Text>
<Tabs display="flex" flexDir="column" border="1px solid" borderColor="gray.300" borderRadius={5}>
{clientInstructions}
</Tabs>
</ListItem>
</OrderedList>
</li>
<li>
<p className="mb-2">{keyInstructionText}</p>
{clientInstructions}
</li>
</ol>
</>
);
}

View File

@@ -1,12 +1,10 @@
import { Text, chakra } from '@chakra-ui/react';
import { RiErrorWarningLine } from 'react-icons/ri';
export function SegmentTryOfficialPlayer() {
export function SegmentTryOfficialPlayer({ className = '' }: { className?: string }) {
return (
<>
<Text>
<chakra.strong>1</chakra.strong>
</Text>
<Text></Text>
</>
<div className={`alert alert-warning my-2 ${className}`}>
<RiErrorWarningLine className="text-2xl" />
<p></p>
</div>
);
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 30 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 22 KiB

View File

@@ -1,24 +0,0 @@
import { Box, Image } from '@chakra-ui/react';
import noCoverFallbackImageURL from '~/assets/no-cover.svg';
interface AlbumImageProps {
url?: string;
name?: string;
}
export function AlbumImage({ name, url }: AlbumImageProps) {
const coverAlternativeText = name ? `${name} 的专辑封面` : '专辑封面';
return (
<Box w="160px" h="160px" m="auto">
<Image
border="2px solid"
borderColor="gray.400"
borderRadius="50%"
objectFit="cover"
src={url || noCoverFallbackImageURL}
alt={coverAlternativeText}
/>
</Box>
);
}

View File

@@ -1,5 +1,6 @@
import { Box, Button, chakra, Collapse, Text, useDisclosure } from '@chakra-ui/react';
import { toast } from 'react-toastify';
import { DecryptErrorType } from '~/decrypt-worker/util/DecryptError';
import { applyTemplate } from '~/util/applyTemplate';
export interface FileErrorProps {
error: null | string;
@@ -7,33 +8,55 @@ export interface FileErrorProps {
}
const errorMap = new Map<string | null | DecryptErrorType, string>([
[DecryptErrorType.UNSUPPORTED_FILE, '尚未支持的文件格式'],
[DecryptErrorType.UNSUPPORTED_FILE, '支持的文件类型'],
]);
const ERROR_TEMPLATE = `解密错误:{{summary}}
详细错误信息:
\`\`\`text
{{error}}
\`\`\`
<!-- 报告错误时请提交上述【全部内容】 -->
`;
export function FileError({ error, code }: FileErrorProps) {
const { isOpen, onToggle } = useDisclosure();
const errorSummary = errorMap.get(code) ?? '未知错误';
const summary = errorMap.get(code) ?? '未知错误';
const copyError = () => {
if (error) {
navigator.clipboard
.writeText(applyTemplate(ERROR_TEMPLATE, { summary, error }))
.then(() => {
toast.success('错误信息已复制到剪贴板');
})
.catch((e) => {
toast.error(`复制错误信息失败: ${e}`);
});
}
};
return (
<Box>
<Text>
<chakra.span>
<chakra.span color="red.700">{errorSummary}</chakra.span>
</chakra.span>
{error && (
<Button ml="2" onClick={onToggle} type="button">
</Button>
)}
</Text>
<>
<p>
<span className="text-red-600">{summary}</span>
</p>
{error && (
<Collapse in={isOpen} animateOpacity>
<Box as="pre" display="inline-block" mt="2" px="4" py="2" bg="red.100" color="red.800" rounded="md">
{error}
</Box>
</Collapse>
<div className="collapse border-error border w-full text-left my-2 py-0">
<input className="[&&&]:py-2 [&&&]:min-h-[1.5rem]" type="checkbox" />
<div className="collapse-title font-semibold text-center [&&&]:min-h-[1.5rem] [&&&]:py-2"></div>
<div className="collapse-content text-sm overflow-hidden">
<pre className="overflow-x-auto w-full">{error}</pre>
<p className="mt-2 text-center">
<button type="button" className="btn btn-secondary" onClick={copyError}>
</button>
</p>
</div>
</div>
)}
</Box>
</>
);
}

View File

@@ -1,5 +1,3 @@
import { VStack } from '@chakra-ui/react';
import { selectFiles } from './fileListingSlice';
import { useAppSelector } from '~/hooks';
import { FileRow } from './FileRow';
@@ -8,10 +6,10 @@ export function FileListing() {
const files = useAppSelector(selectFiles);
return (
<VStack>
<div className="flex flex-row flex-wrap gap-8">
{Object.entries(files).map(([id, file]) => (
<FileRow key={id} id={id} file={file} />
))}
</VStack>
</div>
);
}

View File

@@ -1,24 +1,7 @@
import { useRef } from 'react';
import {
Box,
Button,
Card,
CardBody,
Collapse,
GridItem,
Link,
VStack,
Wrap,
WrapItem,
useDisclosure,
} from '@chakra-ui/react';
import { FileRowResponsiveGrid } from './FileRowResponsiveGrid';
import { DecryptedAudioFile, deleteFile, ProcessState } from './fileListingSlice';
import { useAppDispatch } from '~/hooks';
import { AnimationDefinition } from 'framer-motion';
import { AlbumImage } from './AlbumImage';
import { SongMetadata } from './SongMetadata';
import { FileError } from './FileError';
import classNames from 'classnames';
interface FileRowProps {
id: string;
@@ -26,90 +9,46 @@ interface FileRowProps {
}
export function FileRow({ id, file }: FileRowProps) {
const { isOpen, onClose } = useDisclosure({ defaultIsOpen: true });
const dispatch = useAppDispatch();
const isDecrypted = file.state === ProcessState.COMPLETE;
const metadata = file.metadata;
const nameWithoutExt = file.fileName.replace(/\.[a-z\d]{3,6}$/, '');
const decryptedName = nameWithoutExt + '.' + file.ext;
const audioPlayerRef = useRef<HTMLAudioElement>(null);
const togglePlay = () => {
const player = audioPlayerRef.current;
if (!player) {
return;
}
if (player.paused) {
player.play();
} else {
player.pause();
}
};
const onCollapseAnimationComplete = (definition: AnimationDefinition) => {
if (definition === 'exit') {
dispatch(deleteFile({ id }));
}
};
const decryptedName = file.cleanName + '.' + file.ext;
return (
<Collapse
in={isOpen}
animateOpacity
unmountOnExit
startingHeight={0}
onAnimationComplete={onCollapseAnimationComplete}
style={{ width: '100%', padding: '0.25rem' }}
>
<Card w="full" data-testid="file-row">
<CardBody>
<FileRowResponsiveGrid>
<GridItem area="cover">
<AlbumImage name={metadata?.album} url={metadata?.cover} />
</GridItem>
<GridItem area="title">
<Box w="full" as="h4" fontWeight="semibold" mt="1" textAlign={{ base: 'center', md: 'left' }}>
<span data-testid="audio-meta-song-name">{metadata?.name ?? nameWithoutExt}</span>
</Box>
</GridItem>
<GridItem area="meta">
{isDecrypted && metadata && <SongMetadata metadata={metadata} />}
{file.state === ProcessState.ERROR && <FileError error={file.errorMessage} code={file.errorCode} />}
</GridItem>
<GridItem area="action" alignSelf="center">
<VStack>
{file.decrypted && <audio controls autoPlay={false} src={file.decrypted} ref={audioPlayerRef} />}
<div className="card bg-base-100 dark:bg-gray-700 shadow-sm w-full md:w-[30%] " data-testid="file-row">
<div className="card-body items-center text-center px-2">
<h2 className="card-title max-w-full whitespace-nowrap flex gap-0" data-testid="audio-meta-song-name">
<span className="grow overflow-hidden text-ellipsis" title={decryptedName}>
{file.cleanName}
</span>
{isDecrypted && file.ext && <div className="ml-2 badge badge-accent">{file.ext}</div>}
</h2>
<Wrap>
{isDecrypted && (
<>
<WrapItem>
<Button type="button" onClick={togglePlay}>
/
</Button>
</WrapItem>
<WrapItem>
{file.decrypted && (
<Link href={file.decrypted} download={decryptedName}>
<Button as="span"></Button>
</Link>
)}
</WrapItem>
</>
)}
<WrapItem>
<Button type="button" onClick={onClose}>
</Button>
</WrapItem>
</Wrap>
</VStack>
</GridItem>
</FileRowResponsiveGrid>
</CardBody>
</Card>
</Collapse>
<div className="w-full grow">
{file.state === ProcessState.ERROR && <FileError error={file.errorMessage} code={file.errorCode} />}
{isDecrypted && (
<audio className="w-full" aria-disabled={!file.decrypted} controls autoPlay={false} src={file.decrypted} />
)}
</div>
<div className="card-actions justify-end">
<a
href={file.decrypted}
download={decryptedName}
title={`下载: ${decryptedName}`}
className={classNames('btn', {
'btn-primary': file.decrypted,
'cursor-not-allowed pointer-events-none': !file.decrypted,
})}
data-testid="audio-download"
>
</a>
<button type="button" className="btn btn-error" onClick={() => dispatch(deleteFile({ id }))}>
</button>
</div>
</div>
</div>
);
}

View File

@@ -1,27 +0,0 @@
import { Grid, chakra } from '@chakra-ui/react';
export const FileRowResponsiveGrid = chakra(Grid, {
baseStyle: {
gridTemplateAreas: {
base: `
"cover"
"title"
"meta"
"action"
`,
md: `
"cover title action"
"cover meta action"
`,
},
gridTemplateRows: {
base: 'repeat(auto-fill)',
md: 'min-content 1fr',
},
gridTemplateColumns: {
base: '1fr',
md: '160px 1fr',
},
gap: 3,
},
});

View File

@@ -1,22 +0,0 @@
import { Box, Text } from '@chakra-ui/react';
import type { AudioMetadata } from './fileListingSlice';
export interface SongMetadataProps {
metadata: AudioMetadata;
}
export function SongMetadata({ metadata }: SongMetadataProps) {
return (
<Box>
<Text>
: <span data-testid="audio-meta-album-name">{metadata.album}</span>
</Text>
<Text>
: <span data-testid="audio-meta-song-artist">{metadata.artist}</span>
</Text>
<Text>
: <span data-testid="audio-meta-album-artist">{metadata.albumArtist}</span>
</Text>
</Box>
);
}

View File

@@ -14,5 +14,5 @@ test('should be able to render a list of 3 items', () => {
});
expect(screen.getAllByTestId('file-row')).toHaveLength(3);
expect(screen.getByText('Für Alice')).toBeInTheDocument();
expect(screen.getByText('ready')).toBeInTheDocument();
});

View File

@@ -3,22 +3,15 @@ import { untouchedFile } from './__fixture__/file-list';
import { FileRow } from '../FileRow';
import { completedFile } from './__fixture__/file-list';
test('should render no metadata when unavailable', () => {
test('should render basic title (ready)', () => {
renderWithProviders(<FileRow id="file://ready" file={untouchedFile} />);
expect(screen.getAllByTestId('file-row')).toHaveLength(1);
expect(screen.getByTestId('audio-meta-song-name')).toHaveTextContent('ready');
expect(screen.queryByTestId('audio-meta-album-name')).toBeFalsy();
expect(screen.queryByTestId('audio-meta-song-artist')).toBeFalsy();
expect(screen.queryByTestId('audio-meta-album-artist')).toBeFalsy();
});
test('should render metadata when file has been processed', () => {
test('should render basic title (done)', () => {
renderWithProviders(<FileRow id="file://done" file={completedFile} />);
expect(screen.getAllByTestId('file-row')).toHaveLength(1);
expect(screen.getByTestId('audio-meta-song-name')).toHaveTextContent('Für Alice');
expect(screen.getByTestId('audio-meta-album-name')).toHaveTextContent("NOW That's What I Call Cryptography 2023");
expect(screen.getByTestId('audio-meta-song-artist')).toHaveTextContent('Jixun');
expect(screen.getByTestId('audio-meta-album-artist')).toHaveTextContent('Cipher Lovers');
});

View File

@@ -1,6 +1,7 @@
import { DecryptedAudioFile, ProcessState } from '../../fileListingSlice';
export const untouchedFile: DecryptedAudioFile = {
cleanName: 'ready',
fileName: 'ready.bin',
raw: 'blob://localhost/file-a',
decrypted: '',
@@ -13,6 +14,7 @@ export const untouchedFile: DecryptedAudioFile = {
export const completedFile: DecryptedAudioFile = {
fileName: 'hello-b.bin',
cleanName: 'hello-b',
raw: 'blob://localhost/file-b',
decrypted: 'blob://localhost/file-b-decrypted',
ext: 'flac',
@@ -30,6 +32,7 @@ export const completedFile: DecryptedAudioFile = {
export const fileWithError: DecryptedAudioFile = {
fileName: 'hello-c.bin',
cleanName: 'hello-c',
raw: 'blob://localhost/file-c',
decrypted: 'blob://localhost/file-c-decrypted',
ext: 'flac',

View File

@@ -6,12 +6,20 @@ import { DECRYPTION_WORKER_ACTION_NAME, type DecryptionResult } from '~/decrypt-
import type {
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 { selectKWMv2Key, selectQMCv2KeyByFileName, selectQtfmAndroidKey } from '../settings/settingsSelector';
import {
selectKugouKey,
selectKWMv2Key,
selectQMCv2KeyByFileName,
selectQtfmAndroidKey,
} from '../settings/settingsSelector';
import { cleanFilename } from '~/util/cleanFilename';
export enum ProcessState {
QUEUED = 'QUEUED',
@@ -35,6 +43,7 @@ export interface AudioMetadata {
export interface DecryptedAudioFile {
fileName: string;
cleanName: string;
raw: string; // blob uri
ext: string;
decrypted: string; // blob uri
@@ -70,7 +79,7 @@ export const processFile = createAsyncThunk<
thunkAPI.dispatch(setFileAsProcessing({ id: fileId }));
};
const [qmcv2MusicExMediaFile, kuwoHdr] = await Promise.all([
const [qmcv2MusicExMediaFile, kuwoHdr, kugouHdr] = await Promise.all([
workerClientBus.request<string, FetchMusicExNamePayload>(DECRYPTION_WORKER_ACTION_NAME.FIND_QMC_MUSICEX_NAME, {
blobURI: file.raw,
}),
@@ -78,12 +87,17 @@ export const processFile = createAsyncThunk<
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 = {
fileName: file.fileName,
qmc2Key: selectQMCv2KeyByFileName(state, qmcv2MusicExMediaFile || file.fileName),
kwm2key: selectKWMv2Key(state, kuwoHdr),
kugouKey: selectKugouKey(state, kugouHdr),
qingTingAndroidKey: selectQtfmAndroidKey(state),
};
return decryptionQueue.add({ id: fileId, blobURI: file.raw, options }, onPreProcess);
@@ -96,6 +110,7 @@ export const fileListingSlice = createSlice({
addNewFile: (state, { payload }: PayloadAction<{ id: string; fileName: string; blobURI: string }>) => {
state.files[payload.id] = {
fileName: payload.fileName,
cleanName: cleanFilename(payload.fileName),
raw: payload.blobURI,
decrypted: '',
ext: '',

View File

@@ -0,0 +1,29 @@
export interface ResponsiveNavProps {
navigationClassName?: string;
navigation?: React.ReactNode;
className?: string;
contentClassName?: string;
children?: React.ReactNode;
}
export function ResponsiveNav({
className = '',
navigationClassName = '',
contentClassName = '',
children,
navigation,
}: ResponsiveNavProps) {
return (
<div
className={`@container/nav grow grid grid-cols-1 grid-rows-[auto_1fr] md:grid-rows-1 md:grid-cols-[10rem_1fr] ${className}`}
>
{/* Sidebar */}
<aside className={`bg-base-100 md:p-4 md:block ${navigationClassName}`}>{navigation}</aside>
{/* Main content */}
<div className={`p-4 grow ${contentClassName}`}>{children}</div>
</div>
);
}

View File

@@ -0,0 +1,21 @@
import classNames from 'classnames';
import type { RefAttributes } from 'react';
import { NavLink, type NavLinkProps } from 'react-router';
const tabClassNames = ({ isActive }: { isActive: boolean }) =>
classNames(
'link inline-flex text-nowrap mb-[-2px] no-underline w-full',
'border-b-2 md:border-b-0 md:border-r-2',
'tab md:grow',
{
'tab-active bg-accent/10 border-accent': isActive,
},
);
export function TabNavLink({ children, ...props }: NavLinkProps & RefAttributes<HTMLAnchorElement>) {
return (
<NavLink className={tabClassNames} role="tab" {...props}>
{children}
</NavLink>
);
}

View File

@@ -1,161 +1,75 @@
import {
chakra,
Box,
Button,
Center,
Flex,
HStack,
Icon,
IconButton,
Menu,
MenuButton,
MenuItem,
MenuList,
Portal,
Spacer,
Tab,
TabList,
TabPanel,
TabPanels,
Tabs,
Text,
VStack,
useBreakpointValue,
useToast,
} from '@chakra-ui/react';
import { PanelQMCv2Key } from './panels/PanelQMCv2Key';
import { useState } from 'react';
import { MdExpandMore, MdMenu, MdOutlineSettingsBackupRestore } from 'react-icons/md';
import { useAppDispatch, useAppSelector } from '~/hooks';
import { commitStagingChange, discardStagingChanges } from './settingsSlice';
import { PanelKWMv2Key } from './panels/PanelKWMv2Key';
import { selectIsSettingsNotSaved } from './settingsSelector';
import { PanelQingTing } from './panels/PanelQingTing';
const TABS: { name: string; Tab: () => JSX.Element }[] = [
{ name: 'QMCv2 密钥', Tab: PanelQMCv2Key },
{ name: 'KWMv2 密钥', Tab: PanelKWMv2Key },
{ name: '蜻蜓 FM', Tab: PanelQingTing },
{
name: '其它/待定',
Tab: () => <Text></Text>,
},
];
import { Outlet } from 'react-router';
import { SETTINGS_TABS } from '~/features/settings/settingsTabs.tsx';
import { MdOutlineSettingsBackupRestore } from 'react-icons/md';
import { toast } from 'react-toastify';
import { ResponsiveNav } from '../nav/ResponsiveNav';
import { TabNavLink } from '../nav/TabNavLink';
export function Settings() {
const toast = useToast();
const dispatch = useAppDispatch();
const isLargeWidthDevice =
useBreakpointValue({
base: false,
lg: true,
}) ?? false;
const [tabIndex, setTabIndex] = useState(0);
const handleTabChange = (idx: number) => {
setTabIndex(idx);
};
const handleResetSettings = () => {
dispatch(discardStagingChanges());
toast({
status: 'info',
title: '未储存的设定已舍弃',
description: '已还原到更改前的状态。',
isClosable: true,
});
toast.info(() => (
<div>
<h3 className="text-lg font-bold"></h3>
<p className="text-sm"></p>
</div>
));
};
const handleApplySettings = () => {
dispatch(commitStagingChange());
toast({
status: 'success',
title: '设定已应用',
isClosable: true,
});
toast.success('设定已应用');
};
const isSettingsNotSaved = useAppSelector(selectIsSettingsNotSaved);
return (
<Flex flexDir="column" flex={1}>
<Menu>
<MenuButton
as={Button}
leftIcon={<MdMenu />}
rightIcon={<MdExpandMore />}
colorScheme="gray"
variant="outline"
w="full"
flexShrink={0}
hidden={isLargeWidthDevice}
mb="4"
>
{TABS[tabIndex].name}
</MenuButton>
<Portal>
<MenuList w="100px">
{TABS.map(({ name }, i) => (
<MenuItem key={name} onClick={() => setTabIndex(i)}>
<div className="flex flex-col flex-1 container w-full">
<ResponsiveNav
className="grow h-full overflow-auto"
contentClassName="flex flex-col overflow-auto"
navigationClassName="overflow-x-auto pb-[2px] md:pb-0 h-full items-start [&]:md:flex"
navigation={
<div role="tablist" className="tabs gap-1 flex-nowrap md:flex-col grow items-center">
{Object.entries(SETTINGS_TABS).map(([id, { name }]) => (
<TabNavLink key={id} to={`/settings/${id}`}>
{name}
</MenuItem>
</TabNavLink>
))}
</MenuList>
</Portal>
</Menu>
<Tabs
orientation={isLargeWidthDevice ? 'vertical' : 'horizontal'}
align="start"
variant="line-i"
display="flex"
flex={1}
index={tabIndex}
onChange={handleTabChange}
</div>
}
>
<TabList hidden={!isLargeWidthDevice} minW="8em" width="8em" textAlign="right" justifyContent="center">
{TABS.map(({ name }) => (
<Tab key={name}>{name}</Tab>
))}
</TabList>
<Outlet />
</ResponsiveNav>
<TabPanels>
{TABS.map(({ name, Tab }) => (
<Flex as={TabPanel} flex={1} flexDir="column" h="100%" key={name}>
<Flex h="100%" flex={1} minH={0}>
<Tab />
</Flex>
<footer className="flex flex-row gap-2 w-full p-2 border-t border-base-200 bg-base-100">
<div className="grow inline-flex items-center">
{isSettingsNotSaved ? (
<span>
<span className="text-red-600"></span>
</span>
) : (
<span className="text-base-700"></span>
)}
</div>
<VStack mt="4" alignItems="flex-start" w="full">
<Flex flexDir="row" gap="2" w="full">
<Center>
{isSettingsNotSaved ? (
<Box color="gray">
{' '}
<chakra.span color="red" wordBreak="keep-all">
</chakra.span>
</Box>
) : (
<Box color="gray"></Box>
)}
</Center>
<Spacer />
<HStack gap="2" justifyContent="flex-end">
<IconButton
icon={<Icon as={MdOutlineSettingsBackupRestore} />}
onClick={handleResetSettings}
colorScheme="red"
variant="ghost"
title="放弃未储存的更改,将设定还原为储存前的状态。"
aria-label="放弃未储存的更改"
/>
<Button onClick={handleApplySettings}></Button>
</HStack>
</Flex>
</VStack>
</Flex>
))}
</TabPanels>
</Tabs>
</Flex>
<div className="flex flex-row gap-2">
<button
className="btn btn-sm btn-ghost text-error"
onClick={handleResetSettings}
title="放弃未储存的更改,将设定还原未储存前的状态。"
>
<MdOutlineSettingsBackupRestore className="size-4" />
</button>
<button className="btn btn-sm btn-primary" onClick={handleApplySettings}>
</button>
</div>
</footer>
</div>
);
}

View File

@@ -0,0 +1,8 @@
export function SettingsHome() {
return (
<div className="flex flex-col gap-4">
<h1 className="text-2xl font-bold"></h1>
<p></p>
</div>
);
}

View File

@@ -14,6 +14,7 @@ export function productionKeyToStaging<S, P extends Record<string, unknown>>(
}
return result;
}
export function stagingKeyToProduction<S, P>(src: S[], toKey: (s: S) => keyof P, toValue: (s: S) => P[keyof P]): P {
return objectify(src, toKey, toValue) as P;
}
@@ -41,7 +42,6 @@ export const qmc2ProductionToStaging = (
};
// KWMv2 (KuWo)
export interface StagingKWMv2Key {
id: string;
/**
@@ -64,7 +64,7 @@ export const parseKwm2ProductionKey = (key: string): null | { rid: string; quali
return { rid, quality };
};
export const kwm2StagingToProductionKey = (key: StagingKWMv2Key) => `${key.rid}-${key.quality.replace(/[\D]/g, '')}`;
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,
@@ -78,3 +78,21 @@ export const kwm2ProductionToStaging = (
return { id: nanoid(), rid, quality, ekey: value };
};
// KuGou (kgg, kgm v5)
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 };
};

View File

@@ -1,33 +1,28 @@
import { Code, ListItem, OrderedList, Text, chakra } from '@chakra-ui/react';
const KUWO_IOS_DIR = '/var/mobile/Containers/Data/Application/<酷我数据目录>/mmkv';
import { HiWord } from '~/components/HelpText/HiWord';
export function InstructionsIOS() {
return (
<>
<Text>访 iOS </Text>
<Text>
<p>访 iOS </p>
<p>
<chakra.span color="red.400"></chakra.span>
</Text>
<OrderedList>
<ListItem>
<Text>
访
<Code wordBreak="break-word">{KUWO_IOS_DIR}</Code>
</Text>
</ListItem>
<ListItem>
<Text>
<Code>kw_ekey</Code> 访
</Text>
</ListItem>
<ListItem>
<Text>
<Code>kw_ekey</Code>
</Text>
</ListItem>
</OrderedList>
<span className="text-red-600"></span>
</p>
<ol className="list-decimal pl-6">
<li>
访
<br />
<code className="break-words">
/var/mobile/Containers/Data/Application/<HiWord className="text-nowrap">{'<>'}</HiWord>/mmkv
</code>
</li>
<li>
<code>kw_ekey</code> 访
</li>
<li>
<code>kw_ekey</code>
</li>
</ol>
</>
);
}

View File

@@ -1,9 +1,3 @@
import { Text } from '@chakra-ui/react';
export function InstructionsPC() {
return (
<>
<Text>使 Windows </Text>
</>
);
return <p>使 Windows </p>;
}

View File

@@ -1,30 +1,16 @@
import { Tab, TabList, TabPanel, TabPanels } from '@chakra-ui/react';
import { AndroidADBPullInstruction } from '~/components/AndroidADBPullInstruction/AndroidADBPullInstruction';
import { InstructionsPC } from './InstructionsPC';
import { InstructionsIOS } from './InstructionsIOS';
import { InstructionsTabs, InstructionTab } from '~/components/InstructionsTabs';
export function KWMv2AllInstructions() {
return (
<>
<TabList>
<Tab></Tab>
<Tab>iOS</Tab>
<Tab>Windows</Tab>
</TabList>
<TabPanels flex={1} overflow="auto">
<TabPanel>
<AndroidADBPullInstruction
dir="/data/data/cn.kuwo.player/files/mmkv"
file="cn.kuwo.player.mmkv.defaultconfig"
/>
</TabPanel>
<TabPanel>
<InstructionsIOS />
</TabPanel>
<TabPanel>
<InstructionsPC />
</TabPanel>
</TabPanels>
</>
);
const ANDROID_DIR = '/data/data/cn.kuwo.player/files/mmkv';
const ANDROID_FILE = 'cn.kuwo.player.mmkv.defaultconfig';
const tabs: InstructionTab[] = [
{ id: 'android', label: '安卓', content: <AndroidADBPullInstruction dir={ANDROID_DIR} file={ANDROID_FILE} /> },
{ id: 'ios', label: 'iOS', content: <InstructionsIOS /> },
{ id: 'windows', label: 'Windows', content: <InstructionsPC /> },
];
return <InstructionsTabs tabs={tabs} />;
}

View File

@@ -1,81 +1,41 @@
import {
HStack,
Icon,
IconButton,
Input,
InputGroup,
InputLeftElement,
InputRightElement,
ListItem,
Text,
VStack,
} from '@chakra-ui/react';
import { MdDelete, MdVpnKey } from 'react-icons/md';
import { PiFileAudio, PiHash } from 'react-icons/pi';
import { kwm2DeleteKey, kwm2UpdateKey } from '../../settingsSlice';
import { useAppDispatch } from '~/hooks';
import { memo } from 'react';
import { StagingKWMv2Key } from '../../keyFormats';
import { KeyInput } from '~/components/KeyInput';
export const KWMv2EKeyItem = memo(({ id, ekey, quality, rid, i }: StagingKWMv2Key & { i: number }) => {
const dispatch = useAppDispatch();
const updateKey = (prop: keyof StagingKWMv2Key, e: React.ChangeEvent<HTMLInputElement>) =>
dispatch(kwm2UpdateKey({ id, field: prop, value: e.target.value }));
const deleteKey = () => dispatch(kwm2DeleteKey({ id }));
const ekeyLen = ekey.length;
const isValidEKey = ekeyLen === 364 || ekeyLen === 704;
return (
<ListItem mt={0} pt={2} pb={2} _even={{ bg: 'gray.50' }}>
<HStack>
<Text w="2em" textAlign="center">
{i + 1}
</Text>
<VStack flex={1}>
<HStack flex={1} w="full">
<Input
variant="flushed"
placeholder="资源 ID"
value={rid}
onChange={(e) => updateKey('rid', e)}
type="number"
maxW="8em"
/>
<Input
variant="flushed"
placeholder="音质格式"
value={quality}
onChange={(e) => updateKey('quality', e)}
flex={1}
/>
</HStack>
<InputGroup size="xs">
<InputLeftElement pr="2">
<Icon as={MdVpnKey} />
</InputLeftElement>
<Input
variant="flushed"
placeholder="密钥,通常包含 364 或 704 位字符,没有空格。"
value={ekey}
onChange={(e) => updateKey('ekey', e)}
/>
<InputRightElement>
<Text pl="2" color={ekey.length ? 'green.500' : 'red.500'}>
<code>{ekey.length || '?'}</code>
</Text>
</InputRightElement>
</InputGroup>
</VStack>
<IconButton
aria-label="删除该密钥"
icon={<Icon as={MdDelete} boxSize={6} />}
variant="ghost"
colorScheme="red"
type="button"
onClick={deleteKey}
/>
</HStack>
</ListItem>
<KeyInput
name={rid}
quality={quality}
value={ekey}
isValidKey={isValidEKey}
onSetName={(value) => dispatch(kwm2UpdateKey({ id, field: 'rid', value }))}
onSetQuality={(value) => dispatch(kwm2UpdateKey({ id, field: 'quality', value }))}
onSetValue={(value) => dispatch(kwm2UpdateKey({ id, field: 'ekey', value }))}
onDelete={() => dispatch(kwm2DeleteKey({ id }))}
sequence={i + 1}
nameLabel={
<>
ID
<PiHash className="hidden md:inline-block" />
</>
}
qualityLabel={
<>
<PiFileAudio className="hidden md:inline-block" />
</>
}
namePlaceholder="音频哈希。不建议手动填写。"
qualityPlaceholder="比特率 ID"
valuePlaceholder="密钥,通常包含 364 或 704 位字符,没有空格。"
/>
);
});

Some files were not shown because too many files have changed in this diff Show More