diff --git a/src/features/settings/panels/QMCv2/InstructionsAndroid.tsx b/src/components/AndroidADBPullInstruction/AndroidADBPullInstruction.tsx similarity index 80% rename from src/features/settings/panels/QMCv2/InstructionsAndroid.tsx rename to src/components/AndroidADBPullInstruction/AndroidADBPullInstruction.tsx index 9128444..b489e41 100644 --- a/src/features/settings/panels/QMCv2/InstructionsAndroid.tsx +++ b/src/components/AndroidADBPullInstruction/AndroidADBPullInstruction.tsx @@ -17,10 +17,22 @@ 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 PowerShellAdbDumpCommand from './adb_dump.ps1?raw'; -import ShellAdbDumpCommand from './adb_dump.sh?raw'; +import PowerShellAdbDumpCommandTemplate from './adb_dump.ps1?raw'; +import ShellAdbDumpCommandTemplate from './adb_dump.sh?raw'; + +const applyTemplate = (tpl: string, values: Record) => { + return tpl.replace(/\{\{\s*(\w+)\s*\}\}/g, (_, key) => (Object.hasOwn(values, key) ? String(values[key]) : '')); +}; + +export interface AndroidADBPullInstructionProps { + dir: string; + file: string; +} + +export function AndroidADBPullInstruction({ dir, file }: AndroidADBPullInstructionProps) { + const psAdbDumpCommand = applyTemplate(PowerShellAdbDumpCommandTemplate, { dir, file }); + const shAdbDumpCommand = applyTemplate(ShellAdbDumpCommandTemplate, { dir, file }); -export function InstructionsAndroid() { return ( <> @@ -50,12 +62,12 @@ export function InstructionsAndroid() { - 访问 /data/data/com.tencent.qqmusic/databases/ 目录。 + 访问 {dir}/ 目录。 - 将文件 player_process_db 复制到浏览器可访问的目录。 + 将文件 {file} 复制到浏览器可访问的目录。
(例如下载目录)
@@ -99,12 +111,12 @@ export function InstructionsAndroid() { 粘贴执行下述代码。若设备提示「超级用户请求」请允许: - {PowerShellAdbDumpCommand} + {psAdbDumpCommand} - 提交当前目录下的 player_process_db 文件。 + 提交当前目录下的 {file} 文件。 @@ -128,12 +140,12 @@ export function InstructionsAndroid() { 粘贴执行下述代码。若设备提示「超级用户请求」请允许: - {ShellAdbDumpCommand} + {shAdbDumpCommand} - 提交当前目录下的 player_process_db 文件。 + 提交当前目录下的 {file} 文件。 diff --git a/src/features/settings/panels/QMCv2/adb_dump.ps1 b/src/components/AndroidADBPullInstruction/adb_dump.ps1 similarity index 61% rename from src/features/settings/panels/QMCv2/adb_dump.ps1 rename to src/components/AndroidADBPullInstruction/adb_dump.ps1 index f9a4fdf..3f40ac7 100644 --- a/src/features/settings/panels/QMCv2/adb_dump.ps1 +++ b/src/components/AndroidADBPullInstruction/adb_dump.ps1 @@ -1,8 +1,8 @@ try { - $gz_b64 = adb shell su -c "cat '/data/data/com.tencent.qqmusic/databases/player_process_db' | gzip | base64" | Out-String + $gz_b64 = adb shell su -c "cat '{{ dir }}/{{ file }}' | gzip | base64" | Out-String $bStream = New-Object System.IO.MemoryStream(,[System.Convert]::FromBase64String($gz_b64)) $decoded = New-Object System.IO.Compression.GzipStream($bStream, [System.IO.Compression.CompressionMode]::Decompress) - $outFile = New-Object System.IO.FileStream("player_process_db", [System.IO.FileMode]::Create, [System.IO.FileAccess]::Write) + $outFile = New-Object System.IO.FileStream("{{ file }}", [System.IO.FileMode]::Create, [System.IO.FileAccess]::Write) $decoded.CopyTo($outFile) } finally { if ($outFile -ne $null) { $outFile.Dispose() } diff --git a/src/components/AndroidADBPullInstruction/adb_dump.sh b/src/components/AndroidADBPullInstruction/adb_dump.sh new file mode 100644 index 0000000..38947c8 --- /dev/null +++ b/src/components/AndroidADBPullInstruction/adb_dump.sh @@ -0,0 +1,2 @@ +sh adb shell su -c "cat '{{ dir }}/{{ file }}' | gzip | base64" \ + | base64 -d | gzip -d '{{ file }}' diff --git a/src/features/settings/panels/KWMv2/InstructionsPC.tsx b/src/features/settings/panels/KWMv2/InstructionsPC.tsx new file mode 100644 index 0000000..86d0a07 --- /dev/null +++ b/src/features/settings/panels/KWMv2/InstructionsPC.tsx @@ -0,0 +1,9 @@ +import { Text } from '@chakra-ui/react'; + +export function InstructionsPC() { + return ( + <> + 使用 Windows 客户端下载的文件不需要导入密钥。 + + ); +} diff --git a/src/features/settings/panels/PanelKWMv2Key.tsx b/src/features/settings/panels/PanelKWMv2Key.tsx index b656066..9c41ac4 100644 --- a/src/features/settings/panels/PanelKWMv2Key.tsx +++ b/src/features/settings/panels/PanelKWMv2Key.tsx @@ -14,6 +14,10 @@ import { MenuDivider, MenuItem, MenuList, + Tab, + TabList, + TabPanel, + TabPanels, Text, useToast, } from '@chakra-ui/react'; @@ -28,6 +32,8 @@ import { kwm2AddKey, kwm2ClearKeys, kwm2ImportKeys } from '../settingsSlice'; import { selectStagingKWMv2Keys } from '../settingsSelector'; import { KWMv2EKeyItem } from './KWMv2/KWMv2EKeyItem'; import type { StagingKWMv2Key } from '../keyFormats'; +import { InstructionsPC } from './KWMv2/InstructionsPC'; +import { AndroidADBPullInstruction } from '~/components/AndroidADBPullInstruction/AndroidADBPullInstruction'; export function PanelKWMv2Key() { const toast = useToast(); @@ -39,7 +45,7 @@ export function PanelKWMv2Key() { const clearAll = () => dispatch(kwm2ClearKeys()); const handleSecretImport = async (file: File) => { let keys: Omit[] | null = null; - if (/cn\.kuwo\.player\.mmkv\.defaultconfig/i.test(file.name)) { + if (/cn\.kuwo\.player\.mmkv/i.test(file.name)) { const fileBuffer = await file.arrayBuffer(); keys = MMKVParser.parseKuwoEKey(new DataView(fileBuffer)); } @@ -108,7 +114,21 @@ export function PanelKWMv2Key() { onClose={() => setShowImportModal(false)} onImport={handleSecretImport} > - 文档缺失 + + 安卓 + Windows + + + + + + + + + ); diff --git a/src/features/settings/panels/PanelQMCv2Key.tsx b/src/features/settings/panels/PanelQMCv2Key.tsx index e18709d..2d9d67a 100644 --- a/src/features/settings/panels/PanelQMCv2Key.tsx +++ b/src/features/settings/panels/PanelQMCv2Key.tsx @@ -34,10 +34,10 @@ import { StagingQMCv2Key } from '../keyFormats'; import { DatabaseKeyExtractor } from '~/util/DatabaseKeyExtractor'; import { MMKVParser } from '~/util/MMKVParser'; import { getFileName } from '~/util/pathHelper'; -import { InstructionsAndroid } from './QMCv2/InstructionsAndroid'; import { InstructionsIOS } from './QMCv2/InstructionsIOS'; import { InstructionsMac } from './QMCv2/InstructionsMac'; import { InstructionsPC } from './QMCv2/InstructionsPC'; +import { AndroidADBPullInstruction } from '~/components/AndroidADBPullInstruction/AndroidADBPullInstruction'; export function PanelQMCv2Key() { const toast = useToast(); @@ -172,7 +172,7 @@ export function PanelQMCv2Key() { - + diff --git a/src/features/settings/panels/QMCv2/adb_dump.sh b/src/features/settings/panels/QMCv2/adb_dump.sh deleted file mode 100644 index 42fa8ad..0000000 --- a/src/features/settings/panels/QMCv2/adb_dump.sh +++ /dev/null @@ -1,2 +0,0 @@ -sh adb shell su -c "cat '/data/data/com.tencent.qqmusic/databases/player_process_db' | gzip | base64" \ - | base64 -d | gzip -d player_process_db