refactor: 画面サイズのしきい値をconstにまとめる
This commit is contained in:
@@ -86,6 +86,7 @@ SPDX-License-Identifier: AGPL-3.0-only
|
||||
import { defineAsyncComponent, onDeactivated, onUnmounted, ref } from 'vue';
|
||||
import type { summaly } from '@misskey-dev/summaly';
|
||||
import { url as local } from '@/config.js';
|
||||
import { MOBILE_THRESHOLD } from '@/const.js';
|
||||
import { i18n } from '@/i18n.js';
|
||||
import * as os from '@/os.js';
|
||||
import { deviceKind } from '@/scripts/device-kind.js';
|
||||
@@ -106,7 +107,6 @@ const props = withDefaults(defineProps<{
|
||||
showActions: true,
|
||||
});
|
||||
|
||||
const MOBILE_THRESHOLD = 500;
|
||||
const isMobile = ref(deviceKind === 'smartphone' || window.innerWidth <= MOBILE_THRESHOLD);
|
||||
|
||||
const self = props.url.startsWith(local);
|
||||
|
@@ -48,6 +48,7 @@ import { scrollToTop } from '@/scripts/scroll.js';
|
||||
import { globalEvents } from '@/events.js';
|
||||
import { injectReactiveMetadata } from '@/scripts/page-metadata.js';
|
||||
import { $i, openAccountMenu as openAccountMenu_ } from '@/account.js';
|
||||
import { MOBILE_THRESHOLD } from '@/const.js';
|
||||
import { PageHeaderItem } from '@/types/page-header.js';
|
||||
|
||||
const props = withDefaults(defineProps<{
|
||||
@@ -112,10 +113,10 @@ onMounted(() => {
|
||||
globalEvents.on('themeChanged', calcBg);
|
||||
|
||||
if (el.value && el.value.parentElement) {
|
||||
narrow.value = el.value.parentElement.offsetWidth < 500;
|
||||
narrow.value = el.value.parentElement.offsetWidth < MOBILE_THRESHOLD;
|
||||
ro = new ResizeObserver((entries, observer) => {
|
||||
if (el.value && el.value.parentElement && document.body.contains(el.value as HTMLElement)) {
|
||||
narrow.value = el.value.parentElement.offsetWidth < 500;
|
||||
narrow.value = el.value.parentElement.offsetWidth < MOBILE_THRESHOLD;
|
||||
}
|
||||
});
|
||||
ro.observe(el.value.parentElement as HTMLElement);
|
||||
|
Reference in New Issue
Block a user