From 7c45dc1cdd5b1ad68adbb9a55b7291b0bf0c4edf Mon Sep 17 00:00:00 2001 From: kakkokari-gtyih <67428053+kakkokari-gtyih@users.noreply.github.com> Date: Mon, 8 Apr 2024 19:13:46 +0900 Subject: [PATCH] =?UTF-8?q?enhance(frontend):=20=E3=82=A2=E3=82=A4?= =?UTF-8?q?=E3=82=B3=E3=83=B3=E7=94=BB=E5=83=8F=E3=83=BB=E3=83=90=E3=83=8A?= =?UTF-8?q?=E3=83=BC=E7=94=BB=E5=83=8F=E3=82=92=E5=A4=96=E3=81=9B=E3=82=8B?= =?UTF-8?q?=E3=82=88=E3=81=86=E3=81=AB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CHANGELOG.md | 1 + .../frontend/src/pages/settings/profile.vue | 36 +++++++++++++++++-- packages/frontend/src/scripts/select-file.ts | 13 +++---- 3 files changed, 42 insertions(+), 8 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6d172915eb..ef31ea8e87 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -26,6 +26,7 @@ - Enhance: ノートについているリアクションの「もっと!」から、リアクションの一覧を表示できるように - Enhance: リプライにて引用がある場合テキストが空でもノートできるように - 引用したいノートのURLをコピーしリプライ投稿画面にペーストして添付することで達成できます +- Enhance: アイコン画像・バナー画像を外せるように - Fix: 一部のページ内リンクが正しく動作しない問題を修正 - Fix: 周年の実績が閏年を考慮しない問題を修正 - Fix: ローカルURLのプレビューポップアップが左上に表示される diff --git a/packages/frontend/src/pages/settings/profile.vue b/packages/frontend/src/pages/settings/profile.vue index 4b0363ef33..03d31f870b 100644 --- a/packages/frontend/src/pages/settings/profile.vue +++ b/packages/frontend/src/pages/settings/profile.vue @@ -204,7 +204,23 @@ function save() { } function changeAvatar(ev) { - selectFile(ev.currentTarget ?? ev.target, i18n.ts.avatar, true).then(async (file) => { + selectFile(ev.currentTarget ?? ev.target, i18n.ts.avatar, true, $i.avatarId ? [ + { type: 'divider' }, + { + type: 'button', + text: i18n.ts.detach, + icon: 'ti ti-circle-x', + action: () => { + os.apiWithDialog('i/update', { + avatarId: null, + }).then(() => { + $i.avatarId = null; + $i.avatarUrl = null; + globalEvents.emit('requestClearPageCache'); + }); + }, + }, + ] : undefined).then(async (file) => { let originalOrCropped = file; const { canceled } = await os.confirm({ @@ -231,7 +247,23 @@ function changeAvatar(ev) { } function changeBanner(ev) { - selectFile(ev.currentTarget ?? ev.target, i18n.ts.banner, true).then(async (file) => { + selectFile(ev.currentTarget ?? ev.target, i18n.ts.banner, true, $i.bannerId ? [ + { type: 'divider' }, + { + type: 'button', + text: i18n.ts.detach, + icon: 'ti ti-circle-x', + action: () => { + os.apiWithDialog('i/update', { + bannerId: null, + }).then(() => { + $i.bannerId = null; + $i.bannerUrl = null; + globalEvents.emit('requestClearPageCache'); + }); + }, + }, + ] : undefined).then(async (file) => { let originalOrCropped = file; const { canceled } = await os.confirm({ diff --git a/packages/frontend/src/scripts/select-file.ts b/packages/frontend/src/scripts/select-file.ts index 4f4d41456b..7df7efe5b4 100644 --- a/packages/frontend/src/scripts/select-file.ts +++ b/packages/frontend/src/scripts/select-file.ts @@ -5,6 +5,7 @@ import { ref } from 'vue'; import * as Misskey from 'misskey-js'; +import type { MenuItem } from '@/types/menu.js'; import * as os from '@/os.js'; import { misskeyApi } from '@/scripts/misskey-api.js'; import { useStream } from '@/stream.js'; @@ -80,7 +81,7 @@ export function chooseFileFromUrl(): Promise { }); } -function select(src: any, label: string | null, multiple: boolean, excludeSensitive: boolean): Promise { +function select(src: any, label: string | null, multiple: boolean, excludeSensitive: boolean, additionalMenu: MenuItem[] = []): Promise { return new Promise((res, rej) => { const keepOriginal = ref(defaultStore.state.keepOriginalUploading); @@ -116,14 +117,14 @@ function select(src: any, label: string | null, multiple: boolean, excludeSensit text: i18n.ts.fromUrl, icon: 'ti ti-link', action: () => chooseFileFromUrl().then(file => _resolve([file])), - }], src); + }, ...additionalMenu], src); }); } -export function selectFile(src: any, label: string | null = null, excludeSensitive = false): Promise { - return select(src, label, false, excludeSensitive).then(files => files[0]); +export function selectFile(src: any, label: string | null = null, excludeSensitive = false, additionalMenu?: MenuItem[]): Promise { + return select(src, label, false, excludeSensitive, additionalMenu).then(files => files[0]); } -export function selectFiles(src: any, label: string | null = null, excludeSensitive = false): Promise { - return select(src, label, true, excludeSensitive); +export function selectFiles(src: any, label: string | null = null, excludeSensitive = false, additionalMenu?: MenuItem[]): Promise { + return select(src, label, true, excludeSensitive, additionalMenu); }