From 406b4bdbe79b5b0b68fcdcb3c4b6e419460a0258 Mon Sep 17 00:00:00 2001 From: zyoshoka <107108195+zyoshoka@users.noreply.github.com> Date: Thu, 7 Dec 2023 14:42:09 +0900 Subject: refactor(frontend): 非推奨となったReactivity Transformを使わないように (#12539) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * refactor(frontend): 非推奨となったReactivity Transformを使わないように * refactor: 不要な括弧を除去 * fix: 不要なアノテーションを除去 * fix: Refの配列をrefしている部分の対応 * refactor: 不要な括弧を除去 * fix: lint * refactor: Ref、ShallowRef、ComputedRefの変数の宣言をletからconstに置換 * fix: type error * chore: drop reactivity transform from eslint configuration * refactor: remove unnecessary import * fix: 対応漏れ --- packages/frontend/src/components/MkAnalogClock.vue | 64 +++++++++++----------- 1 file changed, 32 insertions(+), 32 deletions(-) (limited to 'packages/frontend/src/components/MkAnalogClock.vue') diff --git a/packages/frontend/src/components/MkAnalogClock.vue b/packages/frontend/src/components/MkAnalogClock.vue index cd2c4d8264..0e252f7b1d 100644 --- a/packages/frontend/src/components/MkAnalogClock.vue +++ b/packages/frontend/src/components/MkAnalogClock.vue @@ -138,45 +138,45 @@ const texts = computed(() => { }); let enabled = true; -let majorGraduationColor = $ref(); +const majorGraduationColor = ref(); //let minorGraduationColor = $ref(); -let sHandColor = $ref(); -let mHandColor = $ref(); -let hHandColor = $ref(); -let nowColor = $ref(); -let h = $ref(0); -let m = $ref(0); -let s = $ref(0); -let hAngle = $ref(0); -let mAngle = $ref(0); -let sAngle = $ref(0); -let disableSAnimate = $ref(false); +const sHandColor = ref(); +const mHandColor = ref(); +const hHandColor = ref(); +const nowColor = ref(); +const h = ref(0); +const m = ref(0); +const s = ref(0); +const hAngle = ref(0); +const mAngle = ref(0); +const sAngle = ref(0); +const disableSAnimate = ref(false); let sOneRound = false; const sLine = ref(); function tick() { const now = props.now(); now.setMinutes(now.getMinutes() + now.getTimezoneOffset() + props.offset); - const previousS = s; - const previousM = m; - const previousH = h; - s = now.getSeconds(); - m = now.getMinutes(); - h = now.getHours(); - if (previousS === s && previousM === m && previousH === h) { + const previousS = s.value; + const previousM = m.value; + const previousH = h.value; + s.value = now.getSeconds(); + m.value = now.getMinutes(); + h.value = now.getHours(); + if (previousS === s.value && previousM === m.value && previousH === h.value) { return; } - hAngle = Math.PI * (h % (props.twentyfour ? 24 : 12) + (m + s / 60) / 60) / (props.twentyfour ? 12 : 6); - mAngle = Math.PI * (m + s / 60) / 30; + hAngle.value = Math.PI * (h.value % (props.twentyfour ? 24 : 12) + (m.value + s.value / 60) / 60) / (props.twentyfour ? 12 : 6); + mAngle.value = Math.PI * (m.value + s.value / 60) / 30; if (sOneRound && sLine.value) { // 秒針が一周した際のアニメーションをよしなに処理する(これが無いと秒が59->0になったときに期待したアニメーションにならない) - sAngle = Math.PI * 60 / 30; + sAngle.value = Math.PI * 60 / 30; defaultIdlingRenderScheduler.delete(tick); sLine.value.addEventListener('transitionend', () => { - disableSAnimate = true; + disableSAnimate.value = true; requestAnimationFrame(() => { - sAngle = 0; + sAngle.value = 0; requestAnimationFrame(() => { - disableSAnimate = false; + disableSAnimate.value = false; if (enabled) { defaultIdlingRenderScheduler.add(tick); } @@ -184,9 +184,9 @@ function tick() { }); }, { once: true }); } else { - sAngle = Math.PI * s / 30; + sAngle.value = Math.PI * s.value / 30; } - sOneRound = s === 59; + sOneRound = s.value === 59; } tick(); @@ -195,12 +195,12 @@ function calcColors() { const computedStyle = getComputedStyle(document.documentElement); const dark = tinycolor(computedStyle.getPropertyValue('--bg')).isDark(); const accent = tinycolor(computedStyle.getPropertyValue('--accent')).toHexString(); - majorGraduationColor = dark ? 'rgba(255, 255, 255, 0.3)' : 'rgba(0, 0, 0, 0.3)'; + majorGraduationColor.value = dark ? 'rgba(255, 255, 255, 0.3)' : 'rgba(0, 0, 0, 0.3)'; //minorGraduationColor = dark ? 'rgba(255, 255, 255, 0.2)' : 'rgba(0, 0, 0, 0.2)'; - sHandColor = dark ? 'rgba(255, 255, 255, 0.5)' : 'rgba(0, 0, 0, 0.3)'; - mHandColor = tinycolor(computedStyle.getPropertyValue('--fg')).toHexString(); - hHandColor = accent; - nowColor = accent; + sHandColor.value = dark ? 'rgba(255, 255, 255, 0.5)' : 'rgba(0, 0, 0, 0.3)'; + mHandColor.value = tinycolor(computedStyle.getPropertyValue('--fg')).toHexString(); + hHandColor.value = accent; + nowColor.value = accent; } calcColors(); -- cgit v1.2.3-freya