Skip to content

Commit ffa5d1c

Browse files
update
1 parent 691fd94 commit ffa5d1c

20 files changed

Lines changed: 127 additions & 84 deletions

package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
"compressing": "^1.10.1",
1919
"music-metadata": "^7.12.6",
2020
"@seald-io/nedb": "^4.0.4",
21-
"NeteaseCloudMusicApi": "^4.24.0"
21+
"NeteaseCloudMusicApi": "^4.27.0"
2222
},
2323
"devDependencies": {
2424
"@rollup/plugin-commonjs": "^22.0.0",
@@ -70,7 +70,6 @@
7070
"tar.xz"
7171
],
7272
"desktop": {
73-
"Icon": "rem"
7473
}
7574
}
7675
}

pages/Login.svelte

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@
152152
</h3>
153153
{#if !loginType}
154154
<input type="tel" class="{error ? 'error' : ''}" bind:value={phone} placeholder={s('phone_number')}>
155-
<input type="number" class="{error ? 'error' : ''}" bind:value={passwd} placeholder={s('captcha')}>
155+
<input type="text" class="{error ? 'error' : ''}" bind:value={passwd} placeholder={s('captcha')}>
156156
<div class="btn outlined" on:click={getCaptcha}>{s('get_captcha')}</div>
157157
<div style="padding: 24px 0px 12px 0px">
158158
<RippleLayer

pages/components/Nav.svelte

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -235,19 +235,19 @@
235235
{#if i === selected}
236236
<!-- svelte-ignore a11y-click-events-have-key-events -->
237237
{#if tab.startsWith('#')}
238-
<div id="nav_selected" class="tab selected tab-text" on:mousedown={() => onClick(i)}>{s(tab)}</div>
238+
<div id="nav_selected" class="tab selected tab-text" on:pointerdown={() => onClick(i)}>{s(tab)}</div>
239239
{:else}
240-
<div id="nav_selected" class="tab selected column" style="padding-right: 2px;" on:mousedown={() => onClick(i)}>
240+
<div id="nav_selected" class="tab selected column" style="padding-right: 2px;" on:pointerdown={() => onClick(i)}>
241241
<span class="tab-text">{s(tab)}</span>
242-
<div class="column cross" on:click={() => delTab()}>{'\ue5cd'}</div>
242+
<div class="column cross" on:pointerdown|nonpassive={() => delTab()}>{'\ue5cd'}</div>
243243
</div>
244244
{/if}
245245
{:else}
246246
<!-- svelte-ignore a11y-click-events-have-key-events -->
247-
<div class="tab tab-text Row" on:mousedown={() => onClick(i)}>
247+
<div class="tab tab-text Row" on:pointerdown={() => onClick(i)}>
248248
<span>{s(tab)}</span>
249249
{#if !tab.startsWith('#')}
250-
<div class="Row cross closeable" on:click={() => delTab(i)}>{'\ue5cd'}</div>
250+
<div class="Row cross closeable" on:pointerdown={() => delTab(i)}>{'\ue5cd'}</div>
251251
{/if}
252252
</div>
253253
{/if}

pages/components/Toggle.svelte

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
11
<script>
2-
import { createEventDispatcher } from "svelte";
2+
import { createEventDispatcher } from "svelte"
33
44
5-
export let checked = false;
5+
export let checked = false
66
7-
const emit = createEventDispatcher();
7+
const emit = createEventDispatcher()
88
99
function onToggle() {
10-
checked = !checked;
11-
emit('toggle', checked);
10+
checked = !checked
11+
emit('toggle', checked)
1212
}
1313
1414
export function toggle() {
15-
onToggle();
15+
onToggle()
1616
}
1717
1818
</script>
@@ -22,7 +22,8 @@
2222
position: relative;
2323
width: 40px;
2424
height: 20px;
25-
border-radius: 10px;
25+
border-radius: 12px;
26+
border: solid 2px var(--controlAcrylicDark);
2627
background-color: var(--controlBackgroundAcrylic);
2728
cursor: pointer;
2829
transition: background-color 0.2s;
@@ -45,12 +46,16 @@
4546
}
4647
4748
.thumb-active {
48-
left: calc(100% - 10px);
49+
width: 16px;
50+
height: 16px;
51+
top: 2px;
52+
left: calc(100% - 11px);
4953
background-color: var(--controlColor);
5054
}
5155
5256
.active {
5357
background-color: var(--controlBright);
58+
border-color: transparent;
5459
/* border: solid 2px var(--controlColor); */
5560
}
5661
</style>

pages/components/ToggleListTile.svelte

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
<script>
2-
import { createEventDispatcher } from "svelte";
2+
import { createEventDispatcher } from "svelte"
33
4-
import ListTile from "./ListTile.svelte";
5-
import Toggle from "./Toggle.svelte";
4+
import ListTile from "./ListTile.svelte"
5+
import Toggle from "./Toggle.svelte"
66
7-
let emit = createEventDispatcher();
8-
let t;
9-
export let checked = false;
7+
let emit = createEventDispatcher()
8+
let t
9+
export let checked = false
1010
export let bold = true
1111
1212
function onToggle(ev) {
13-
let checked = ev.detail;
14-
emit('toggle', checked);
13+
let checked = ev.detail
14+
emit('toggle', checked)
1515
}
1616
1717
export let customClickListener = false

pages/entry.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ LifeCycle.when('controlsReady')
6767

6868
// await fileFindService.addDir('C:/Users/rgb/Music/albums/EVANGELION FINALLY')
6969

70-
console.log(await defaultConsumer.read('1'))
70+
console.log(await defaultConsumer.read('2'))
7171
console.log(
7272
await fileFindService.find(await fileFindService.getDirs())
7373
)

pages/settings/initSettings.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ export function initSettings() {
3838
__init_setting('AppSettings/beta_features', {
3939
showDevTools: false,
4040
useBufferOutput: false,
41+
showNetworkErrors: false,
4142
}, ({ showDevTools }) => {
4243
hooks.send(`devtools:${
4344
showDevTools ? 'open': 'close'

protocol/common/decorator.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import { StructDataTypes } from './struct/struct'
2+
3+
export type ConstructorOf<T> = new (...args: any[]) => T
4+
const STRUCTS = new Map<ConstructorOf<any>, StructDataTypes[]>()
5+
6+
export const Struct = (...desc: StructDataTypes[]) => <V>(target: ConstructorOf<V>) => {
7+
STRUCTS.set(target, desc)
8+
}
9+
10+
export function getStruct(cls: ConstructorOf<any>) {
11+
//@ts-ignore
12+
return STRUCTS.get(cls) ?? cls?.struct?.layout?.()
13+
}

protocol/common/struct/album.ts

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,16 @@
1+
import { Struct } from "../decorator"
12
import { encodeDecoder } from "../encodeDecoder"
2-
import { malloc, StructDescriptor } from "./struct"
3+
import { malloc } from "./struct"
34

45
/**
56
* cue sheet
67
*/
8+
@Struct(
9+
'Uint16', // year
10+
'string', // title
11+
'string', // genre
12+
'string', // artists
13+
)
714
export class Album {
815
constructor(
916
public title: string,
@@ -12,21 +19,11 @@ export class Album {
1219
public year: number,
1320
) {}
1421

15-
static readonly struct: StructDescriptor = {
16-
layout: () =>
17-
[
18-
'Uint16', // year
19-
'string', // title
20-
'string', // genre
21-
'string', // artists
22-
]
23-
}
24-
2522
static encode({
2623
year, title, genre, artists,
2724
}: Album): Uint8Array {
2825
const artistsStr = artists.join('\0')
29-
const mem = malloc(Album.struct)
26+
const mem = malloc(Album)
3027

3128
mem.setArray([
3229
year, title, genre, artistsStr
@@ -36,7 +33,7 @@ export class Album {
3633
}
3734

3835
static decode(buffer: Uint8Array): Album {
39-
const mem = malloc(Album.struct)
36+
const mem = malloc(Album)
4037
mem.setUint8Array(buffer)
4138

4239
const [ year, title, genre, artistsStr ] = mem.get()
Lines changed: 28 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,16 @@
1-
import { encodeDecoder } from "../encodeDecoder"
2-
import { malloc, StructDescriptor } from "./struct"
1+
import { Struct } from "../decorator"
2+
import { EncodeDecoder } from "../encodeDecoder"
3+
import { malloc } from "./struct"
34

5+
@Struct(
6+
'Float32', // duration
7+
'Uint32', // no
8+
'Uint32', // start
9+
'string', // titles
10+
'string', // artist
11+
'string', // album
12+
'string', // uri
13+
)
414
export class AudioTrack {
515
constructor(
616
public titles: string[],
@@ -11,26 +21,16 @@ export class AudioTrack {
1121
public no: number,
1222
public start = 0
1323
) {}
24+
}
1425

15-
static readonly struct: StructDescriptor = {
16-
layout: () =>
17-
[
18-
'Float32', // duration
19-
'Uint32', // no
20-
'Uint32', // start
21-
'string', // titles
22-
'string', // artist
23-
'string', // album
24-
'string', // uri
25-
]
26-
}
26+
export class AudioTrackEncoderDecoder implements EncodeDecoder<AudioTrack> {
2727

28-
static encode({
28+
encode({
2929
titles, artists, album, duration, uri, no, start
3030
}: AudioTrack): Uint8Array {
3131
const titlesStr = titles.join('\0')
3232
const artistStr = artists.join('\0')
33-
const mem = malloc(AudioTrack.struct)
33+
const mem = malloc(AudioTrack)
3434

3535
mem.setArray([
3636
duration, no, start,
@@ -40,18 +40,25 @@ export class AudioTrack {
4040
return new Uint8Array(mem.getBytes())
4141
}
4242

43-
static decode(encoded: Uint8Array): AudioTrack {
44-
const mem = malloc(AudioTrack.struct)
43+
decode(encoded: Uint8Array): AudioTrack {
44+
const mem = malloc(AudioTrack)
4545
mem.setUint8Array(encoded)
4646

4747
const [
4848
duration, no, start,
4949
titles, artists, album, uri,
5050
] = mem.get()
5151

52-
return new AudioTrack(titles.split('\0'), artists.split('\0'), album, duration, uri, no, start)
52+
return new AudioTrack(
53+
titles.split('\0'),
54+
artists.split('\0'),
55+
album,
56+
duration,
57+
uri,
58+
no,
59+
start
60+
)
5361
}
54-
5562
}
5663

57-
export const songEncodeDecoder = encodeDecoder<AudioTrack>(AudioTrack.encode, AudioTrack.decode)
64+
export const songEncodeDecoder = new AudioTrackEncoderDecoder()

0 commit comments

Comments
 (0)