mirror of
https://git.um-react.app/um/um-react.git
synced 2025-11-28 11:33:02 +00:00
feat: kwm v2 key import ui
This commit is contained in:
@@ -3,7 +3,7 @@ import { SQLDatabase, SQLStatic, loadSQL } from './sqlite';
|
||||
|
||||
export interface QMAndroidKeyEntry {
|
||||
name: string;
|
||||
key: string;
|
||||
ekey: string;
|
||||
}
|
||||
|
||||
export class DatabaseKeyExtractor {
|
||||
@@ -33,10 +33,10 @@ export class DatabaseKeyExtractor {
|
||||
}
|
||||
|
||||
const keys = db.exec('select file_path, ekey from `audio_file_ekey_table`')[0].values;
|
||||
return keys.map(([path, key]) => ({
|
||||
return keys.map(([path, ekey]) => ({
|
||||
// strip dir name
|
||||
name: getFileName(String(path)),
|
||||
key: String(key),
|
||||
ekey: String(ekey),
|
||||
}));
|
||||
} finally {
|
||||
db?.close();
|
||||
|
||||
@@ -95,4 +95,8 @@ export class MMKVParser {
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public static parseKuwoEKey(_view: DataView): unknown[] {
|
||||
return [];
|
||||
}
|
||||
}
|
||||
|
||||
10
src/util/__tests__/splitN.ts.test.ts
Normal file
10
src/util/__tests__/splitN.ts.test.ts
Normal file
@@ -0,0 +1,10 @@
|
||||
import { splitN } from '../splitN';
|
||||
|
||||
test('some test cases', () => {
|
||||
expect(splitN('1,2,3', ',', 2)).toEqual(['1', '2,3']);
|
||||
expect(splitN('1,2,3', ',', 3)).toEqual(['1', '2', '3']);
|
||||
expect(splitN('1,2,3', ',', 4)).toEqual(['1', '2', '3']);
|
||||
|
||||
expect(splitN('1,2,3', '.', 3)).toEqual(['1,2,3']);
|
||||
expect(splitN('1,2,3', '?', 0)).toEqual(['1,2,3']);
|
||||
});
|
||||
20
src/util/splitN.ts
Normal file
20
src/util/splitN.ts
Normal file
@@ -0,0 +1,20 @@
|
||||
export function splitN(str: string, sep: string, maxN: number) {
|
||||
if (maxN <= 1) {
|
||||
return [str];
|
||||
}
|
||||
|
||||
const chunks: string[] = [];
|
||||
const lenSep = sep.length;
|
||||
let searchIdx = 0;
|
||||
for (; maxN > 1; maxN--) {
|
||||
const nextIdx = str.indexOf(sep, searchIdx);
|
||||
if (nextIdx === -1) {
|
||||
break;
|
||||
}
|
||||
chunks.push(str.slice(searchIdx, nextIdx));
|
||||
searchIdx = nextIdx + lenSep;
|
||||
}
|
||||
|
||||
chunks.push(str.slice(searchIdx));
|
||||
return chunks;
|
||||
}
|
||||
Reference in New Issue
Block a user