mirror of
https://github.com/MewoLab/AquaDX.git
synced 2025-10-26 04:22:38 +00:00
[O] Lint
This commit is contained in:
parent
6afcb364d1
commit
643e0e0c1f
@ -1,18 +1,18 @@
|
|||||||
import {aqua_host, data_host} from "./config";
|
import { aqua_host, data_host } from './config'
|
||||||
import type {TrendEntry} from "./generalTypes";
|
import type { TrendEntry } from './generalTypes'
|
||||||
import type {MaimaiUserSummaryEntry} from "./maimaiTypes";
|
import type { MaimaiUserSummaryEntry } from './maimaiTypes'
|
||||||
|
|
||||||
|
|
||||||
const multTable = [
|
const multTable = [
|
||||||
[100.5, 22.4, "SSSp"],
|
[ 100.5, 22.4, 'SSSp' ],
|
||||||
[100, 21.6, "SSS"],
|
[ 100, 21.6, 'SSS' ],
|
||||||
[99.5, 21.1, "SSp"],
|
[ 99.5, 21.1, 'SSp' ],
|
||||||
[99, 20.8, "SS"],
|
[ 99, 20.8, 'SS' ],
|
||||||
[98, 20.3, "Sp"],
|
[ 98, 20.3, 'Sp' ],
|
||||||
[97, 20, "S"],
|
[ 97, 20, 'S' ],
|
||||||
[94, 16.8, "AAA"],
|
[ 94, 16.8, 'AAA' ],
|
||||||
[90, 15.2, "AA"],
|
[ 90, 15.2, 'AA' ],
|
||||||
[80, 13.6, "A"]
|
[ 80, 13.6, 'A' ]
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
@ -21,13 +21,13 @@ export function getMult(achievement: number) {
|
|||||||
for (let i = 0; i < multTable.length; i++) {
|
for (let i = 0; i < multTable.length; i++) {
|
||||||
if (achievement >= (multTable[i][0] as number)) return multTable[i]
|
if (achievement >= (multTable[i][0] as number)) return multTable[i]
|
||||||
}
|
}
|
||||||
return [0, 0, 0]
|
return [ 0, 0, 0 ]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
export async function getMaimai(endpoint: string, params: any) {
|
export async function getMaimai(endpoint: string, params: any) {
|
||||||
return await fetch(`${aqua_host}/Maimai2Servlet/${endpoint}`, {
|
return await fetch(`${aqua_host}/Maimai2Servlet/${endpoint}`, {
|
||||||
method: "POST",
|
method: 'POST',
|
||||||
body: JSON.stringify(params)
|
body: JSON.stringify(params)
|
||||||
}).then(res => res.json())
|
}).then(res => res.json())
|
||||||
}
|
}
|
||||||
@ -37,15 +37,15 @@ export async function getMaimaiAllMusic(): Promise<{ [key: string]: any }> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export async function getMaimaiApi(endpoint: string, params: any) {
|
export async function getMaimaiApi(endpoint: string, params: any) {
|
||||||
let url = new URL(`${aqua_host}/api/game/maimai2new/${endpoint}`)
|
const url = new URL(`${aqua_host}/api/game/maimai2new/${endpoint}`)
|
||||||
Object.keys(params).forEach(key => url.searchParams.append(key, params[key]))
|
Object.keys(params).forEach(key => url.searchParams.append(key, params[key]))
|
||||||
return await fetch(url).then(res => res.json())
|
return await fetch(url).then(res => res.json())
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function getMaimaiTrend(userId: number): Promise<TrendEntry[]> {
|
export async function getMaimaiTrend(userId: number): Promise<TrendEntry[]> {
|
||||||
return await getMaimaiApi("trend", {userId})
|
return await getMaimaiApi('trend', { userId })
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function getMaimaiUser(userId: number): Promise<MaimaiUserSummaryEntry> {
|
export async function getMaimaiUser(userId: number): Promise<MaimaiUserSummaryEntry> {
|
||||||
return await getMaimaiApi("user-summary", {userId})
|
return await getMaimaiApi('user-summary', { userId })
|
||||||
}
|
}
|
||||||
@ -7,13 +7,12 @@ import {
|
|||||||
LinearScale,
|
LinearScale,
|
||||||
PointElement,
|
PointElement,
|
||||||
CategoryScale, TimeScale, type ChartOptions, type LineOptions,
|
CategoryScale, TimeScale, type ChartOptions, type LineOptions,
|
||||||
} from 'chart.js';
|
} from 'chart.js'
|
||||||
import moment from "moment/moment";
|
import moment from 'moment/moment'
|
||||||
// @ts-ignore
|
// @ts-expect-error Cal-heatmap does not have proper types
|
||||||
import CalHeatmap from "cal-heatmap";
|
import CalHeatmap from 'cal-heatmap'
|
||||||
// @ts-ignore
|
// @ts-expect-error Cal-heatmap does not have proper types
|
||||||
import CalTooltip from 'cal-heatmap/plugins/Tooltip';
|
import CalTooltip from 'cal-heatmap/plugins/Tooltip'
|
||||||
import type {Line} from "svelte-chartjs";
|
|
||||||
|
|
||||||
export function title(t: string) {
|
export function title(t: string) {
|
||||||
document.title = `AquaNet - ${t}`
|
document.title = `AquaNet - ${t}`
|
||||||
@ -29,11 +28,11 @@ export function registerChart() {
|
|||||||
PointElement,
|
PointElement,
|
||||||
CategoryScale,
|
CategoryScale,
|
||||||
TimeScale
|
TimeScale
|
||||||
);
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
export function renderCal(el: HTMLElement, d: {date: any, value: any}[]) {
|
export function renderCal(el: HTMLElement, d: {date: any, value: any}[]) {
|
||||||
const cal = new CalHeatmap();
|
const cal = new CalHeatmap()
|
||||||
return cal.paint({
|
return cal.paint({
|
||||||
itemSelector: el,
|
itemSelector: el,
|
||||||
domain: {
|
domain: {
|
||||||
@ -45,24 +44,24 @@ export function renderCal(el: HTMLElement, d: {date: any, value: any}[]) {
|
|||||||
radius: 2, width: 11, height: 11, gutter: 4
|
radius: 2, width: 11, height: 11, gutter: 4
|
||||||
},
|
},
|
||||||
range: 12,
|
range: 12,
|
||||||
data: {source: d, x: 'date', y: 'value'},
|
data: { source: d, x: 'date', y: 'value' },
|
||||||
scale: {
|
scale: {
|
||||||
color: {
|
color: {
|
||||||
type: 'linear',
|
type: 'linear',
|
||||||
range: ['#14432a', '#4dd05a'],
|
range: [ '#14432a', '#4dd05a' ],
|
||||||
domain: [0, d.reduce((a, b) => Math.max(a, b.value), 0)]
|
domain: [ 0, d.reduce((a, b) => Math.max(a, b.value), 0) ]
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
date: {start: moment().subtract(1, 'year').add(1, 'month').toDate()},
|
date: { start: moment().subtract(1, 'year').add(1, 'month').toDate() },
|
||||||
theme: "dark",
|
theme: 'dark',
|
||||||
}, [
|
}, [
|
||||||
[CalTooltip, {text: (_: Date, v: number, d: any) =>
|
[ CalTooltip, { text: (_: Date, v: number, d: any) =>
|
||||||
`${v ?? "No"} songs played on ${d.format('MMMM D, YYYY')}`}]
|
`${v ?? 'No'} songs played on ${d.format('MMMM D, YYYY')}` }]
|
||||||
]);
|
])
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
export const CHARTJS_OPT: ChartOptions<"line"> = {
|
export const CHARTJS_OPT: ChartOptions<'line'> = {
|
||||||
responsive: true,
|
responsive: true,
|
||||||
maintainAspectRatio: false,
|
maintainAspectRatio: false,
|
||||||
// TODO: Show point on hover
|
// TODO: Show point on hover
|
||||||
@ -85,7 +84,7 @@ export const CHARTJS_OPT: ChartOptions<"line"> = {
|
|||||||
display: false
|
display: false
|
||||||
},
|
},
|
||||||
tooltip: {
|
tooltip: {
|
||||||
mode: "index",
|
mode: 'index',
|
||||||
intersect: false
|
intersect: false
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@ -97,5 +96,5 @@ export const CHARTJS_OPT: ChartOptions<"line"> = {
|
|||||||
* @param obj HashMap<string, boolean>
|
* @param obj HashMap<string, boolean>
|
||||||
*/
|
*/
|
||||||
export function clazz(obj: { [key: string]: boolean }) {
|
export function clazz(obj: { [key: string]: boolean }) {
|
||||||
return Object.keys(obj).filter(k => obj[k]).join(" ")
|
return Object.keys(obj).filter(k => obj[k]).join(' ')
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,7 +1,6 @@
|
|||||||
import './app.sass'
|
import './app.sass'
|
||||||
import App from './App.svelte'
|
import App from './App.svelte'
|
||||||
|
|
||||||
// @ts-ignore
|
const app = new App({ target: document.getElementById('app')! })
|
||||||
const app = new App({target: document.getElementById('app')})
|
|
||||||
|
|
||||||
export default app
|
export default app
|
||||||
Loading…
x
Reference in New Issue
Block a user