From f422842aefc234cf83dc264e3a8939ddad2e7e95 Mon Sep 17 00:00:00 2001 From: Lhcfl Date: Fri, 12 Apr 2024 16:55:34 +0800 Subject: [PATCH] use Number.parseInt --- packages/client/src/components/MkChart.vue | 6 +++--- .../client/src/components/MkPollEditor.vue | 2 +- packages/client/src/components/MkWindow.vue | 18 +++++++++--------- .../src/pages/admin/overview.queue-chart.vue | 6 +++--- .../src/pages/admin/queue.chart.chart.vue | 6 +++--- packages/client/src/scripts/2fa.ts | 2 +- packages/client/src/scripts/color.ts | 6 +++--- packages/client/src/scripts/hpml/evaluator.ts | 2 +- packages/client/src/scripts/hpml/lib.ts | 4 ++-- packages/client/src/scripts/physics.ts | 6 +++--- packages/client/src/scripts/popout.ts | 4 ++-- 11 files changed, 31 insertions(+), 31 deletions(-) diff --git a/packages/client/src/components/MkChart.vue b/packages/client/src/components/MkChart.vue index d62f52d26f..abca01f199 100644 --- a/packages/client/src/components/MkChart.vue +++ b/packages/client/src/components/MkChart.vue @@ -100,9 +100,9 @@ const sum = (...arr) => arr.reduce((r, a) => r.map((b, i) => a[i] + b)); const negate = (arr) => arr.map((x) => -x); const alpha = (hex, a) => { const result = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(hex)!; - const r = parseInt(result[1], 16); - const g = parseInt(result[2], 16); - const b = parseInt(result[3], 16); + const r = Number.parseInt(result[1], 16); + const g = Number.parseInt(result[2], 16); + const b = Number.parseInt(result[3], 16); return `rgba(${r}, ${g}, ${b}, ${a})`; }; diff --git a/packages/client/src/components/MkPollEditor.vue b/packages/client/src/components/MkPollEditor.vue index 51bc99ec77..982a432e26 100644 --- a/packages/client/src/components/MkPollEditor.vue +++ b/packages/client/src/components/MkPollEditor.vue @@ -147,7 +147,7 @@ function get() { }; const calcAfter = () => { - let base = parseInt(after.value); + let base = Number.parseInt(after.value); switch (unit.value) { case "day": base *= 24; diff --git a/packages/client/src/components/MkWindow.vue b/packages/client/src/components/MkWindow.vue index 147d0bec1f..8e0747abd5 100644 --- a/packages/client/src/components/MkWindow.vue +++ b/packages/client/src/components/MkWindow.vue @@ -271,7 +271,7 @@ function onHeaderMousedown(evt: MouseEvent) { ? evt.touches[0].clientY : evt.clientY; const moveBaseX = beforeMaximized - ? parseInt(unMaximizedWidth, 10) / 2 + ? Number.parseInt(unMaximizedWidth, 10) / 2 : clickX - position.left; // TODO: parseIntやめる const moveBaseY = beforeMaximized ? 20 : clickY - position.top; const browserWidth = window.innerWidth; @@ -321,8 +321,8 @@ function onTopHandleMousedown(evt) { const main = rootEl.value; const base = evt.clientY; - const height = parseInt(getComputedStyle(main, "").height, 10); - const top = parseInt(getComputedStyle(main, "").top, 10); + const height = Number.parseInt(getComputedStyle(main, "").height, 10); + const top = Number.parseInt(getComputedStyle(main, "").top, 10); // 動かした時 dragListen((me) => { @@ -349,8 +349,8 @@ function onRightHandleMousedown(evt) { const main = rootEl.value; const base = evt.clientX; - const width = parseInt(getComputedStyle(main, "").width, 10); - const left = parseInt(getComputedStyle(main, "").left, 10); + const width = Number.parseInt(getComputedStyle(main, "").width, 10); + const left = Number.parseInt(getComputedStyle(main, "").left, 10); const browserWidth = window.innerWidth; // 動かした時 @@ -375,8 +375,8 @@ function onBottomHandleMousedown(evt) { const main = rootEl.value; const base = evt.clientY; - const height = parseInt(getComputedStyle(main, "").height, 10); - const top = parseInt(getComputedStyle(main, "").top, 10); + const height = Number.parseInt(getComputedStyle(main, "").height, 10); + const top = Number.parseInt(getComputedStyle(main, "").top, 10); const browserHeight = window.innerHeight; // 動かした時 @@ -401,8 +401,8 @@ function onLeftHandleMousedown(evt) { const main = rootEl.value; const base = evt.clientX; - const width = parseInt(getComputedStyle(main, "").width, 10); - const left = parseInt(getComputedStyle(main, "").left, 10); + const width = Number.parseInt(getComputedStyle(main, "").width, 10); + const left = Number.parseInt(getComputedStyle(main, "").left, 10); // 動かした時 dragListen((me) => { diff --git a/packages/client/src/pages/admin/overview.queue-chart.vue b/packages/client/src/pages/admin/overview.queue-chart.vue index cfbcbe6a11..f74cbb7e7e 100644 --- a/packages/client/src/pages/admin/overview.queue-chart.vue +++ b/packages/client/src/pages/admin/overview.queue-chart.vue @@ -47,9 +47,9 @@ const props = defineProps<{ const alpha = (hex, a) => { const result = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(hex)!; - const r = parseInt(result[1], 16); - const g = parseInt(result[2], 16); - const b = parseInt(result[3], 16); + const r = Number.parseInt(result[1], 16); + const g = Number.parseInt(result[2], 16); + const b = Number.parseInt(result[3], 16); return `rgba(${r}, ${g}, ${b}, ${a})`; }; diff --git a/packages/client/src/pages/admin/queue.chart.chart.vue b/packages/client/src/pages/admin/queue.chart.chart.vue index b802457b4a..e8951709f2 100644 --- a/packages/client/src/pages/admin/queue.chart.chart.vue +++ b/packages/client/src/pages/admin/queue.chart.chart.vue @@ -47,9 +47,9 @@ const props = defineProps<{ const alpha = (hex, a) => { const result = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(hex)!; - const r = parseInt(result[1], 16); - const g = parseInt(result[2], 16); - const b = parseInt(result[3], 16); + const r = Number.parseInt(result[1], 16); + const g = Number.parseInt(result[2], 16); + const b = Number.parseInt(result[3], 16); return `rgba(${r}, ${g}, ${b}, ${a})`; }; diff --git a/packages/client/src/scripts/2fa.ts b/packages/client/src/scripts/2fa.ts index 14d59bebec..9c34c8fb70 100644 --- a/packages/client/src/scripts/2fa.ts +++ b/packages/client/src/scripts/2fa.ts @@ -9,7 +9,7 @@ export function byteify(string: string, encoding: "ascii" | "base64" | "hex") { ); case "hex": return new Uint8Array( - string.match(/.{1,2}/g).map((byte) => parseInt(byte, 16)), + string.match(/.{1,2}/g).map((byte) => Number.parseInt(byte, 16)), ); } } diff --git a/packages/client/src/scripts/color.ts b/packages/client/src/scripts/color.ts index 10a99a5a05..10b5ea0e54 100644 --- a/packages/client/src/scripts/color.ts +++ b/packages/client/src/scripts/color.ts @@ -1,7 +1,7 @@ export const alpha = (hex: string, a: number): string => { const result = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(hex)!; - const r = parseInt(result[1], 16); - const g = parseInt(result[2], 16); - const b = parseInt(result[3], 16); + const r = Number.parseInt(result[1], 16); + const g = Number.parseInt(result[2], 16); + const b = Number.parseInt(result[3], 16); return `rgba(${r}, ${g}, ${b}, ${a})`; }; diff --git a/packages/client/src/scripts/hpml/evaluator.ts b/packages/client/src/scripts/hpml/evaluator.ts index ba06a87442..65f8f6a9f5 100644 --- a/packages/client/src/scripts/hpml/evaluator.ts +++ b/packages/client/src/scripts/hpml/evaluator.ts @@ -183,7 +183,7 @@ export class Hpml { } if (expr.type === "number") { - return parseInt(expr.value as any, 10); + return Number.parseInt(expr.value as any, 10); } if (expr.type === "text" || expr.type === "multiLineText") { diff --git a/packages/client/src/scripts/hpml/lib.ts b/packages/client/src/scripts/hpml/lib.ts index 0a2226be8a..06bda34655 100644 --- a/packages/client/src/scripts/hpml/lib.ts +++ b/packages/client/src/scripts/hpml/lib.ts @@ -505,7 +505,7 @@ export function initHpmlLib( strReplace: (a: string, b: string, c: string) => a.split(b).join(c), strReverse: (a: string) => a.split("").reverse().join(""), join: (texts: string[], separator: string) => texts.join(separator || ""), - stringToNumber: (a: string) => parseInt(a), + stringToNumber: (a: string) => Number.parseInt(a), numberToString: (a: number) => a.toString(), splitStrByLine: (a: string) => a.split("\n"), pick: (list: any[], i: number) => list[i - 1], @@ -534,7 +534,7 @@ export function initHpmlLib( let totalFactor = 0; for (const x of list) { const parts = x.split(" "); - const factor = parseInt(parts.pop()!, 10); + const factor = Number.parseInt(parts.pop()!, 10); const text = parts.join(" "); totalFactor += factor; xs.push({ factor, text }); diff --git a/packages/client/src/scripts/physics.ts b/packages/client/src/scripts/physics.ts index 5375c01d29..76dd117a79 100644 --- a/packages/client/src/scripts/physics.ts +++ b/packages/client/src/scripts/physics.ts @@ -65,10 +65,10 @@ export function physics(container: HTMLElement) { const objs = []; for (const objEl of objEls) { const left = objEl.dataset.physicsX - ? parseInt(objEl.dataset.physicsX) + ? Number.parseInt(objEl.dataset.physicsX) : objEl.offsetLeft; const top = objEl.dataset.physicsY - ? parseInt(objEl.dataset.physicsY) + ? Number.parseInt(objEl.dataset.physicsY) : objEl.offsetTop; let obj; @@ -90,7 +90,7 @@ export function physics(container: HTMLElement) { objEl.offsetHeight, { chamfer: { - radius: parseInt(style.borderRadius || "0", 10), + radius: Number.parseInt(style.borderRadius || "0", 10), }, restitution: 0.5, }, diff --git a/packages/client/src/scripts/popout.ts b/packages/client/src/scripts/popout.ts index 54aa422257..9113f4a9a4 100644 --- a/packages/client/src/scripts/popout.ts +++ b/packages/client/src/scripts/popout.ts @@ -9,8 +9,8 @@ export function popout(path: string, w?: HTMLElement) { url = appendQuery(url, "zen"); if (w) { const position = w.getBoundingClientRect(); - const width = parseInt(getComputedStyle(w, "").width, 10); - const height = parseInt(getComputedStyle(w, "").height, 10); + const width = Number.parseInt(getComputedStyle(w, "").width, 10); + const height = Number.parseInt(getComputedStyle(w, "").height, 10); const x = window.screenX + position.left; const y = window.screenY + position.top; window.open(