1
0
mirror of https://github.com/misskey-dev/misskey.git synced 2026-05-20 14:06:05 +02:00

enhance(frontend): ウィンドウの初期サイズを画面サイズから動的に決めるように (#17257)

* enhance(frontend): ウィンドウの初期サイズを画面サイズから動的に決めるように

* Update Changelog

---------

Co-authored-by: syuilo <4439005+syuilo@users.noreply.github.com>
This commit is contained in:
かっこかり
2026-03-22 13:32:45 +09:00
committed by GitHub
parent b5a6e12439
commit c5fd36094d
4 changed files with 18 additions and 9 deletions

View File

@@ -4,6 +4,7 @@
- 依存関係の更新 - 依存関係の更新
### Client ### Client
- Enhance: アプリ内ウィンドウの初期サイズを画面サイズに応じて自動で調整するように
- Fix: 絵文字パレットが空の状態でMisskeyについてのページが閲覧できない問題を修正 - Fix: 絵文字パレットが空の状態でMisskeyについてのページが閲覧できない問題を修正
- Fix: ウィンドウのタイトルをクリックしても最前面に出ないことがある問題を修正 - Fix: ウィンドウのタイトルをクリックしても最前面に出ないことがある問題を修正

View File

@@ -6,8 +6,6 @@ SPDX-License-Identifier: AGPL-3.0-only
<template> <template>
<MkWindow <MkWindow
ref="window" ref="window"
:initialWidth="800"
:initialHeight="500"
:canResize="true" :canResize="true"
@closed="emit('closed')" @closed="emit('closed')"
> >

View File

@@ -6,8 +6,6 @@ SPDX-License-Identifier: AGPL-3.0-only
<template> <template>
<MkWindow <MkWindow
ref="windowEl" ref="windowEl"
:initialWidth="500"
:initialHeight="500"
:canResize="true" :canResize="true"
:closeButton="true" :closeButton="true"
:buttonsLeft="buttonsLeft" :buttonsLeft="buttonsLeft"

View File

@@ -106,8 +106,8 @@ function capturePointer(evt: PointerEvent) {
} }
const props = withDefaults(defineProps<{ const props = withDefaults(defineProps<{
initialWidth: number; initialWidth?: number | null;
initialHeight: number | null; initialHeight?: number | null;
canResize?: boolean; canResize?: boolean;
closeButton?: boolean; closeButton?: boolean;
mini?: boolean; mini?: boolean;
@@ -116,7 +116,7 @@ const props = withDefaults(defineProps<{
buttonsLeft?: WindowButton[]; buttonsLeft?: WindowButton[];
buttonsRight?: WindowButton[]; buttonsRight?: WindowButton[];
}>(), { }>(), {
initialWidth: 400, initialWidth: null,
initialHeight: null, initialHeight: null,
canResize: false, canResize: false,
closeButton: true, closeButton: true,
@@ -131,6 +131,12 @@ const emit = defineEmits<{
(ev: 'closed'): void; (ev: 'closed'): void;
}>(); }>();
const INITIAL_WINDOW_WIDTH_RATIO = 0.5;
const INITIAL_WINDOW_HEIGHT_RATIO = 0.75;
const INITIAL_WINDOW_WIDTH_MIN = 400; // スクリーンの最小幅に合わせるのはapplyTransormWidthの担当
const INITIAL_WINDOW_WIDTH_MAX = 1000; // 画面幅いっぱいに広がるのを防止するための最大幅
const INITIAL_WINDOW_HEIGHT_MIN = 500; // スクリーンの最小幅に合わせるのはapplyTransormHeightの担当
provide('inWindow', true); provide('inWindow', true);
const rootEl = useTemplateRef('rootEl'); const rootEl = useTemplateRef('rootEl');
@@ -484,8 +490,14 @@ function onBrowserResize() {
} }
onMounted(() => { onMounted(() => {
applyTransformWidth(props.initialWidth); let initialWidth = props.initialWidth;
if (props.initialHeight) applyTransformHeight(props.initialHeight); let initialHeight = props.initialHeight;
if (initialWidth == null) initialWidth = Math.min(Math.max(Math.round(window.innerWidth * INITIAL_WINDOW_WIDTH_RATIO), INITIAL_WINDOW_WIDTH_MIN), INITIAL_WINDOW_WIDTH_MAX);
if (initialHeight == null) initialHeight = Math.max(Math.round(window.innerHeight * INITIAL_WINDOW_HEIGHT_RATIO), INITIAL_WINDOW_HEIGHT_MIN);
applyTransformWidth(initialWidth);
applyTransformHeight(initialHeight);
if (rootEl.value) { if (rootEl.value) {
applyTransformTop((window.innerHeight / 2) - (rootEl.value.offsetHeight / 2)); applyTransformTop((window.innerHeight / 2) - (rootEl.value.offsetHeight / 2));