From 1d6f43aa30a932b1b7539f417f19d0b239cde511 Mon Sep 17 00:00:00 2001 From: CyberRex Date: Mon, 20 Mar 2023 12:58:06 +0900 Subject: [PATCH] feat: drive cleaner (#10366) * feat: drive-cleaner * Update CHANGELOG.md --- CHANGELOG.md | 1 + locales/ja-JP.yml | 5 + .../src/server/api/endpoints/drive/files.ts | 10 + .../src/pages/settings/drive-cleaner.vue | 193 ++++++++++++++++++ .../frontend/src/pages/settings/drive.vue | 3 + packages/frontend/src/router.ts | 4 + 6 files changed, 216 insertions(+) create mode 100644 packages/frontend/src/pages/settings/drive-cleaner.vue diff --git a/CHANGELOG.md b/CHANGELOG.md index 6fb090f267..30b0ac018c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -43,6 +43,7 @@ - Bookwyrmのユーザーのプロフィールページで「リモートで表示」をタップしても反応がない問題を修正 - 非ログイン時の「Misskeyについて」の表示を修正 - PC版にて「設定」「コントロールパネル」のリンクを2度以上続けてクリックした際に空白のページが表示される問題を修正 +- ドライブクリーナーを追加 ### Server - OpenAPIエンドポイントを復旧 diff --git a/locales/ja-JP.yml b/locales/ja-JP.yml index c4e86fc64a..54742cef96 100644 --- a/locales/ja-JP.yml +++ b/locales/ja-JP.yml @@ -977,6 +977,7 @@ notesSearchNotAvailable: "ノート検索は利用できません。" license: "ライセンス" unfavoriteConfirm: "お気に入り解除しますか?" myClips: "自分のクリップ" +drivecleaner: "ドライブクリーナー" _achievements: earnedAt: "獲得日時" @@ -1922,3 +1923,7 @@ _dialog: _disabledTimeline: title: "無効化されたタイムライン" description: "現在のロールでは、このタイムラインを使用することはできません。" + +_drivecleaner: + orderBySizeDesc: "サイズが大きい順" + orderByCreatedAtAsc: "追加日が古い順" \ No newline at end of file diff --git a/packages/backend/src/server/api/endpoints/drive/files.ts b/packages/backend/src/server/api/endpoints/drive/files.ts index f6fad50fd9..4609307774 100644 --- a/packages/backend/src/server/api/endpoints/drive/files.ts +++ b/packages/backend/src/server/api/endpoints/drive/files.ts @@ -31,6 +31,7 @@ export const paramDef = { untilId: { type: 'string', format: 'misskey:id' }, folderId: { type: 'string', format: 'misskey:id', nullable: true, default: null }, type: { type: 'string', nullable: true, pattern: /^[a-zA-Z\/\-*]+$/.toString().slice(1, -1) }, + sort: { type: 'string', nullable: true, enum: ['+createdAt', '-createdAt', '+name', '-name', '+size', '-size'] }, }, required: [], } as const; @@ -63,6 +64,15 @@ export default class extends Endpoint { } } + switch (ps.sort) { + case '+createdAt': query.orderBy('file.createdAt', 'DESC'); break; + case '-createdAt': query.orderBy('file.createdAt', 'ASC'); break; + case '+name': query.orderBy('file.name', 'DESC'); break; + case '-name': query.orderBy('file.name', 'ASC'); break; + case '+size': query.orderBy('file.size', 'DESC'); break; + case '-size': query.orderBy('file.size', 'ASC'); break; + } + const files = await query.take(ps.limit).getMany(); return await this.driveFileEntityService.packMany(files, { detail: false, self: true }); diff --git a/packages/frontend/src/pages/settings/drive-cleaner.vue b/packages/frontend/src/pages/settings/drive-cleaner.vue new file mode 100644 index 0000000000..ce8ab214e4 --- /dev/null +++ b/packages/frontend/src/pages/settings/drive-cleaner.vue @@ -0,0 +1,193 @@ + + + + + diff --git a/packages/frontend/src/pages/settings/drive.vue b/packages/frontend/src/pages/settings/drive.vue index a23bdfe69e..d3fb422e01 100644 --- a/packages/frontend/src/pages/settings/drive.vue +++ b/packages/frontend/src/pages/settings/drive.vue @@ -32,6 +32,9 @@ + + {{ i18n.ts.drivecleaner }} + diff --git a/packages/frontend/src/router.ts b/packages/frontend/src/router.ts index 590c5765fd..c8077edd28 100644 --- a/packages/frontend/src/router.ts +++ b/packages/frontend/src/router.ts @@ -65,6 +65,10 @@ export const routes = [{ path: '/drive', name: 'drive', component: page(() => import('./pages/settings/drive.vue')), + }, { + path: '/drive/cleaner', + name: 'drive', + component: page(() => import('./pages/settings/drive-cleaner.vue')), }, { path: '/notifications', name: 'notifications',