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

fix(frontend): ドライブへの画像アップロード時にファイル名の変更が無視される不具合を修正 (#17302)

* ドライブの実ファイル名ではなくsuffixを保持するように

* MkUploaderItemsでファイル名が圧縮後の拡張子も含めて表示されるように

* Apply suggestion from @kakkokari-gtyih

Co-authored-by: かっこかり <67428053+kakkokari-gtyih@users.noreply.github.com>

* changelog

---------

Co-authored-by: かっこかり <67428053+kakkokari-gtyih@users.noreply.github.com>
Co-authored-by: syuilo <4439005+syuilo@users.noreply.github.com>
This commit is contained in:
FINEARCHS
2026-04-11 14:23:42 +09:00
committed by GitHub
parent 3cb003366f
commit 68e3476a16
3 changed files with 17 additions and 7 deletions

View File

@@ -6,6 +6,7 @@
### Client ### Client
- Enhance: チャンネル指定リノートでリノート先のチャンネルに移動できるように - Enhance: チャンネル指定リノートでリノート先のチャンネルに移動できるように
- Fix: 一部のページ内リンクが正しく動作しない問題を修正 - Fix: 一部のページ内リンクが正しく動作しない問題を修正
- Fix: ドライブへの画像アップロード時にファイル名の変更が無視される不具合を修正
- Fix: 連合が無効化されたサーバーで一部の設定項目が空欄で表示される問題を修正 - Fix: 連合が無効化されたサーバーで一部の設定項目が空欄で表示される問題を修正
### Server ### Server

View File

@@ -24,7 +24,10 @@ SPDX-License-Identifier: AGPL-3.0-only
<div :class="$style.itemBody"> <div :class="$style.itemBody">
<div> <div>
<i v-if="item.isSensitive" style="color: var(--MI_THEME-warn); margin-right: 0.5em;" class="ti ti-eye-exclamation"></i> <i v-if="item.isSensitive" style="color: var(--MI_THEME-warn); margin-right: 0.5em;" class="ti ti-eye-exclamation"></i>
<MkCondensedLine :minScale="2 / 3">{{ item.name }}</MkCondensedLine> <MkCondensedLine :minScale="2 / 3">
<span>{{ getUploadName(item).lastIndexOf('.') != -1 ? getUploadName(item).substring(0, getUploadName(item).lastIndexOf('.')) : getUploadName(item) }}</span>
<span v-if="getUploadName(item).lastIndexOf('.') != -1" style="opacity: 0.5;">{{ getUploadName(item).substring(getUploadName(item).lastIndexOf('.')) }}</span>
</MkCondensedLine>
</div> </div>
<div :class="$style.itemInfo"> <div :class="$style.itemInfo">
<span>{{ item.file.type }}</span> <span>{{ item.file.type }}</span>
@@ -47,6 +50,7 @@ SPDX-License-Identifier: AGPL-3.0-only
<script lang="ts" setup> <script lang="ts" setup>
import { isLink } from '@@/js/is-link.js'; import { isLink } from '@@/js/is-link.js';
import { getUploadName } from '@/composables/use-uploader.js';
import type { UploaderItem } from '@/composables/use-uploader.js'; import type { UploaderItem } from '@/composables/use-uploader.js';
import { i18n } from '@/i18n.js'; import { i18n } from '@/i18n.js';
import MkButton from '@/components/MkButton.vue'; import MkButton from '@/components/MkButton.vue';

View File

@@ -61,7 +61,7 @@ const mimeTypeMap = {
export type UploaderItem = { export type UploaderItem = {
id: string; id: string;
name: string; name: string;
uploadName?: string; suffix: string;
progress: { max: number; value: number } | null; progress: { max: number; value: number } | null;
thumbnail: string | null; thumbnail: string | null;
preprocessing: boolean; preprocessing: boolean;
@@ -83,6 +83,10 @@ export type UploaderItem = {
abortPreprocess?: (() => void) | null; abortPreprocess?: (() => void) | null;
}; };
export function getUploadName(item: UploaderItem): string {
return item.name + (item.name.endsWith(item.suffix) ? '' : item.suffix);
}
function getCompressionSettings(level: 0 | 1 | 2 | 3) { function getCompressionSettings(level: 0 | 1 | 2 | 3) {
if (level === 1) { if (level === 1) {
return { return {
@@ -132,6 +136,7 @@ export function useUploader(options: {
items.value.push({ items.value.push({
id, id,
name: prefer.s.keepOriginalFilename ? filename : id + extension, name: prefer.s.keepOriginalFilename ? filename : id + extension,
suffix: '',
progress: null, progress: null,
thumbnail: THUMBNAIL_SUPPORTED_TYPES.includes(file.type) ? window.URL.createObjectURL(file) : null, thumbnail: THUMBNAIL_SUPPORTED_TYPES.includes(file.type) ? window.URL.createObjectURL(file) : null,
preprocessing: false, preprocessing: false,
@@ -503,7 +508,7 @@ export function useUploader(options: {
item.uploading = true; item.uploading = true;
const { filePromise, abort } = uploadFile(item.preprocessedFile ?? item.file, { const { filePromise, abort } = uploadFile(item.preprocessedFile ?? item.file, {
name: item.uploadName ?? item.name, name: getUploadName(item),
folderId: options.folderId === undefined ? prefer.s.uploadFolder : options.folderId, folderId: options.folderId === undefined ? prefer.s.uploadFolder : options.folderId,
isSensitive: item.isSensitive ?? false, isSensitive: item.isSensitive ?? false,
caption: item.caption ?? null, caption: item.caption ?? null,
@@ -677,14 +682,14 @@ export function useUploader(options: {
// (and WebP is not browser safe yet) // (and WebP is not browser safe yet)
preprocessedFile = result; preprocessedFile = result;
item.compressedSize = result.size; item.compressedSize = result.size;
item.uploadName = preprocessedFile.type !== config.mimeType ? `${item.name}.${mimeTypeMap[config.mimeType]}` : item.name; item.suffix = '.' + mimeTypeMap[config.mimeType];
} }
} catch (err) { } catch (err) {
console.error('Failed to resize image', err); console.error('Failed to resize image', err);
} }
} else { } else {
item.compressedSize = null; item.compressedSize = null;
item.uploadName = item.name; item.suffix = '';
} }
imageBitmap.close(); imageBitmap.close();
@@ -743,10 +748,10 @@ export function useUploader(options: {
preprocessedFile = new Blob([output.target.buffer!], { type: output.format.mimeType }); preprocessedFile = new Blob([output.target.buffer!], { type: output.format.mimeType });
item.compressedSize = output.target.buffer!.byteLength; item.compressedSize = output.target.buffer!.byteLength;
item.uploadName = `${item.name}.mp4`; item.suffix = '.mp4';
} else { } else {
item.compressedSize = null; item.compressedSize = null;
item.uploadName = item.name; item.suffix = '';
} }
if (item.thumbnail != null) URL.revokeObjectURL(item.thumbnail); if (item.thumbnail != null) URL.revokeObjectURL(item.thumbnail);