* wip * wip * wip * test * wip rollup pluginでsearchIndexの情報生成 * wip * SPDX * wip: markerIdを自動付与 * rollupでビルド時・devモード時に毎回uuidを生成するように * 開発サーバーでだけ必要な挙動は開発サーバーのみで * 条件が逆 * wip: childrenの生成 * update comment * update comment * rename auto generated file * hashをパスと行数から決定 * Update privacy.vue * Update privacy.vue * wip * Update general.vue * Update general.vue * wip * wip * Update SearchMarker.vue * wip * Update profile.vue * Update mute-block.vue * Update mute-block.vue * Update general.vue * Update general.vue * childrenがduplicate key errorを吐く問題をいったん解決 * マーカーの形を成形 * loggerを置きかえ * とりあえず省略記法に対応 * Refactor and Format codes * wip * Update settings-search-index.ts * wip * wip * とりあえず不確定要因の仮置きidを削除 * hashの生成を正規化(絶対パスになっていたのを緩和) * pathの入力を省略可能に * adminでもパス生成できるように * Update settings-search-index.ts * Update privacy.vue * wip * build searchIndex * wip * build * Update general.vue * build * Update sounds.vue * build * build * Update sounds.vue * 🎨 * 🎨 * Update privacy.vue * Update privacy.vue * Update security.vue * create-search-indexを多少改善 * build * Update 2fa.vue * wip * 必ずtransformCodeCacheを利用するように, キャッシュの明確な受け渡しを定義 * キャッシュはdevServerでなくても更新 * Revert "wip" This reverts commit 41bffd3a13f55618bf939dc1c9acb2a77ead4054. * inlining * wip * Update theme.vue * 🎨 * wip normalize * Update theme.vue * キャッシュのパス変換 * build * wip * wip * Update SearchMarker.vue * i18n.ts['key'] の形式が取り出せない問題のFix * build * 仮でpath入れ * 必ず絶対パスが使われるように * wip * 🎨 * storybookビルド時はcreateSearchIndexをしない * inliningの構造化 * format code * Update index.vue * wip * wip * 🎨 * wip * wip * wip * wip * wip * wip * wip * wip * clean up * wip * wip * wip * Update rollup-plugin-unwind-css-module-class-name.test.ts * Update navbar.vue * clean up * wip * wip * wip * wip * wip * Update preferences-backups.vue * Update common.ts * Update preferences.ts * wip * wip * wip * wip * Update MkPreferenceContainer.vue * Update MkPreferenceContainer.vue * Update MkPreferenceContainer.vue * enhance: 検索で上下矢印を使用することで検索結果を移動できるように * Update main-boot.ts * refactor * wip * Update sounds.vue * fix(frontend): PageWindowでSearchMarkerが動作するように * enhance(frontend): SearchMarkerの点滅を一定時間で止める * wip * lint fix * fix: 子要素監視が抜けていたのを修正 * アニメーションの回数はCSSで制御するように * refactor * enhance(frontend): 検索インデックス作成時のログを削減 * revert * fix * fix * Update preferences.ts * Update preferences.ts * wip * Update preferences.ts * wip * 🎨 * wip * Update MkPreferenceContainer.vue * wip * Update preferences.ts * wip * Update preferences.ts * Update preferences.ts * wip * wip * Update preferences.ts * wip * wip * Update preferences.ts * Update CHANGELOG.md * Update preferences.ts * Update deck-store.ts * deckStoreをdefaultStoreに統合 * wip * defaultStore -> store * Update profile.ts * wip * refactor * wip: plugin * plugin * plugin * plugin * Update plugin.ts * wip * Update plugin.vue * Update preferences.ts * Update main-boot.ts * wip * fix test * Update plugin.vue * Update plugin.vue * Update utility.ts * wip * wip * Update utility.ts * wip * wip * clean up * Update utility.ts --------- Co-authored-by: tai-cha <dev@taichan.site> Co-authored-by: taichan <40626578+tai-cha@users.noreply.github.com> Co-authored-by: kakkokari-gtyih <67428053+kakkokari-gtyih@users.noreply.github.com>
391 lines
8.7 KiB
Vue
391 lines
8.7 KiB
Vue
<!--
|
|
SPDX-FileCopyrightText: syuilo and misskey-project
|
|
SPDX-License-Identifier: AGPL-3.0-only
|
|
-->
|
|
|
|
<template>
|
|
<div
|
|
:class="[$style.root, { [$style.draghover]: draghover }]"
|
|
draggable="true"
|
|
:title="title"
|
|
@click="onClick"
|
|
@contextmenu.stop="onContextmenu"
|
|
@mouseover="onMouseover"
|
|
@mouseout="onMouseout"
|
|
@dragover.prevent.stop="onDragover"
|
|
@dragenter.prevent="onDragenter"
|
|
@dragleave="onDragleave"
|
|
@drop.prevent.stop="onDrop"
|
|
@dragstart="onDragstart"
|
|
@dragend="onDragend"
|
|
>
|
|
<p :class="$style.name">
|
|
<template v-if="hover"><i :class="$style.icon" class="ti ti-folder ti-fw"></i></template>
|
|
<template v-if="!hover"><i :class="$style.icon" class="ti ti-folder ti-fw"></i></template>
|
|
{{ folder.name }}
|
|
</p>
|
|
<p v-if="prefer.s.uploadFolder == folder.id" :class="$style.upload">
|
|
{{ i18n.ts.uploadFolder }}
|
|
</p>
|
|
<button v-if="selectMode" class="_button" :class="$style.checkboxWrapper" @click.prevent.stop="checkboxClicked">
|
|
<div :class="[$style.checkbox, { [$style.checked]: isSelected }]"></div>
|
|
</button>
|
|
</div>
|
|
</template>
|
|
|
|
<script lang="ts" setup>
|
|
import { computed, defineAsyncComponent, 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 { i18n } from '@/i18n.js';
|
|
import { claimAchievement } from '@/scripts/achievements.js';
|
|
import { copyToClipboard } from '@/scripts/copy-to-clipboard.js';
|
|
import { prefer } from '@/preferences.js';
|
|
|
|
const props = withDefaults(defineProps<{
|
|
folder: Misskey.entities.DriveFolder;
|
|
isSelected?: boolean;
|
|
selectMode?: boolean;
|
|
}>(), {
|
|
isSelected: false,
|
|
selectMode: false,
|
|
});
|
|
|
|
const emit = defineEmits<{
|
|
(ev: 'chosen', v: Misskey.entities.DriveFolder): void;
|
|
(ev: 'unchose', v: Misskey.entities.DriveFolder): void;
|
|
(ev: 'move', v: Misskey.entities.DriveFolder): void;
|
|
(ev: 'upload', file: File, folder: Misskey.entities.DriveFolder);
|
|
(ev: 'removeFile', v: Misskey.entities.DriveFile['id']): void;
|
|
(ev: 'removeFolder', v: Misskey.entities.DriveFolder['id']): void;
|
|
(ev: 'dragstart'): void;
|
|
(ev: 'dragend'): void;
|
|
}>();
|
|
|
|
const hover = ref(false);
|
|
const draghover = ref(false);
|
|
const isDragging = ref(false);
|
|
|
|
const title = computed(() => props.folder.name);
|
|
|
|
function checkboxClicked() {
|
|
if (props.isSelected) {
|
|
emit('unchose', props.folder);
|
|
} else {
|
|
emit('chosen', props.folder);
|
|
}
|
|
}
|
|
|
|
function onClick() {
|
|
emit('move', props.folder);
|
|
}
|
|
|
|
function onMouseover() {
|
|
hover.value = true;
|
|
}
|
|
|
|
function onMouseout() {
|
|
hover.value = false;
|
|
}
|
|
|
|
function onDragover(ev: DragEvent) {
|
|
if (!ev.dataTransfer) return;
|
|
|
|
// 自分自身がドラッグされている場合
|
|
if (isDragging.value) {
|
|
// 自分自身にはドロップさせない
|
|
ev.dataTransfer.dropEffect = 'none';
|
|
return;
|
|
}
|
|
|
|
const isFile = ev.dataTransfer.items[0].kind === 'file';
|
|
const isDriveFile = ev.dataTransfer.types[0] === _DATA_TRANSFER_DRIVE_FILE_;
|
|
const isDriveFolder = ev.dataTransfer.types[0] === _DATA_TRANSFER_DRIVE_FOLDER_;
|
|
|
|
if (isFile || isDriveFile || isDriveFolder) {
|
|
switch (ev.dataTransfer.effectAllowed) {
|
|
case 'all':
|
|
case 'uninitialized':
|
|
case 'copy':
|
|
case 'copyLink':
|
|
case 'copyMove':
|
|
ev.dataTransfer.dropEffect = 'copy';
|
|
break;
|
|
case 'linkMove':
|
|
case 'move':
|
|
ev.dataTransfer.dropEffect = 'move';
|
|
break;
|
|
default:
|
|
ev.dataTransfer.dropEffect = 'none';
|
|
break;
|
|
}
|
|
} else {
|
|
ev.dataTransfer.dropEffect = 'none';
|
|
}
|
|
}
|
|
|
|
function onDragenter() {
|
|
if (!isDragging.value) draghover.value = true;
|
|
}
|
|
|
|
function onDragleave() {
|
|
draghover.value = false;
|
|
}
|
|
|
|
function onDrop(ev: DragEvent) {
|
|
draghover.value = false;
|
|
|
|
if (!ev.dataTransfer) return;
|
|
|
|
// ファイルだったら
|
|
if (ev.dataTransfer.files.length > 0) {
|
|
for (const file of Array.from(ev.dataTransfer.files)) {
|
|
emit('upload', file, props.folder);
|
|
}
|
|
return;
|
|
}
|
|
|
|
//#region ドライブのファイル
|
|
const driveFile = ev.dataTransfer.getData(_DATA_TRANSFER_DRIVE_FILE_);
|
|
if (driveFile != null && driveFile !== '') {
|
|
const file = JSON.parse(driveFile);
|
|
emit('removeFile', file.id);
|
|
misskeyApi('drive/files/update', {
|
|
fileId: file.id,
|
|
folderId: props.folder.id,
|
|
});
|
|
}
|
|
//#endregion
|
|
|
|
//#region ドライブのフォルダ
|
|
const driveFolder = ev.dataTransfer.getData(_DATA_TRANSFER_DRIVE_FOLDER_);
|
|
if (driveFolder != null && driveFolder !== '') {
|
|
const folder = JSON.parse(driveFolder);
|
|
|
|
// 移動先が自分自身ならreject
|
|
if (folder.id === props.folder.id) return;
|
|
|
|
emit('removeFolder', folder.id);
|
|
misskeyApi('drive/folders/update', {
|
|
folderId: folder.id,
|
|
parentId: props.folder.id,
|
|
}).then(() => {
|
|
// noop
|
|
}).catch(err => {
|
|
switch (err.code) {
|
|
case 'RECURSIVE_NESTING':
|
|
claimAchievement('driveFolderCircularReference');
|
|
os.alert({
|
|
type: 'error',
|
|
title: i18n.ts.unableToProcess,
|
|
text: i18n.ts.circularReferenceFolder,
|
|
});
|
|
break;
|
|
default:
|
|
os.alert({
|
|
type: 'error',
|
|
text: i18n.ts.somethingHappened,
|
|
});
|
|
}
|
|
});
|
|
}
|
|
//#endregion
|
|
}
|
|
|
|
function onDragstart(ev: DragEvent) {
|
|
if (!ev.dataTransfer) return;
|
|
|
|
ev.dataTransfer.effectAllowed = 'move';
|
|
ev.dataTransfer.setData(_DATA_TRANSFER_DRIVE_FOLDER_, JSON.stringify(props.folder));
|
|
isDragging.value = true;
|
|
|
|
// 親ブラウザに対して、ドラッグが開始されたフラグを立てる
|
|
// (=あなたの子供が、ドラッグを開始しましたよ)
|
|
emit('dragstart');
|
|
}
|
|
|
|
function onDragend() {
|
|
isDragging.value = false;
|
|
emit('dragend');
|
|
}
|
|
|
|
function go() {
|
|
emit('move', props.folder);
|
|
}
|
|
|
|
function rename() {
|
|
os.inputText({
|
|
title: i18n.ts.renameFolder,
|
|
placeholder: i18n.ts.inputNewFolderName,
|
|
default: props.folder.name,
|
|
}).then(({ canceled, result: name }) => {
|
|
if (canceled) return;
|
|
misskeyApi('drive/folders/update', {
|
|
folderId: props.folder.id,
|
|
name: name,
|
|
});
|
|
});
|
|
}
|
|
|
|
function move() {
|
|
os.selectDriveFolder(false).then(folder => {
|
|
if (folder[0] && folder[0].id === props.folder.id) return;
|
|
|
|
misskeyApi('drive/folders/update', {
|
|
folderId: props.folder.id,
|
|
parentId: folder[0] ? folder[0].id : null,
|
|
});
|
|
});
|
|
}
|
|
|
|
function deleteFolder() {
|
|
misskeyApi('drive/folders/delete', {
|
|
folderId: props.folder.id,
|
|
}).then(() => {
|
|
if (prefer.s.uploadFolder === props.folder.id) {
|
|
prefer.set('uploadFolder', null);
|
|
}
|
|
}).catch(err => {
|
|
switch (err.id) {
|
|
case 'b0fc8a17-963c-405d-bfbc-859a487295e1':
|
|
os.alert({
|
|
type: 'error',
|
|
title: i18n.ts.unableToDelete,
|
|
text: i18n.ts.hasChildFilesOrFolders,
|
|
});
|
|
break;
|
|
default:
|
|
os.alert({
|
|
type: 'error',
|
|
text: i18n.ts.unableToDelete,
|
|
});
|
|
}
|
|
});
|
|
}
|
|
|
|
function setAsUploadFolder() {
|
|
prefer.set('uploadFolder', props.folder.id);
|
|
}
|
|
|
|
function onContextmenu(ev: MouseEvent) {
|
|
let menu: MenuItem[];
|
|
menu = [{
|
|
text: i18n.ts.openInWindow,
|
|
icon: 'ti ti-app-window',
|
|
action: () => {
|
|
const { dispose } = os.popup(defineAsyncComponent(() => import('@/components/MkDriveWindow.vue')), {
|
|
initialFolder: props.folder,
|
|
}, {
|
|
closed: () => dispose(),
|
|
});
|
|
},
|
|
}, { type: 'divider' }, {
|
|
text: i18n.ts.rename,
|
|
icon: 'ti ti-forms',
|
|
action: rename,
|
|
}, {
|
|
text: i18n.ts.move,
|
|
icon: 'ti ti ti-folder-symlink',
|
|
action: move,
|
|
}, { type: 'divider' }, {
|
|
text: i18n.ts.delete,
|
|
icon: 'ti ti-trash',
|
|
danger: true,
|
|
action: deleteFolder,
|
|
}];
|
|
if (prefer.s.devMode) {
|
|
menu = menu.concat([{ type: 'divider' }, {
|
|
icon: 'ti ti-id',
|
|
text: i18n.ts.copyFolderId,
|
|
action: () => {
|
|
copyToClipboard(props.folder.id);
|
|
},
|
|
}]);
|
|
}
|
|
os.contextMenu(menu, ev);
|
|
}
|
|
</script>
|
|
|
|
<style lang="scss" module>
|
|
.root {
|
|
position: relative;
|
|
padding: 8px;
|
|
height: 64px;
|
|
background: var(--MI_THEME-driveFolderBg);
|
|
border-radius: 4px;
|
|
cursor: pointer;
|
|
|
|
&.draghover {
|
|
&::after {
|
|
content: "";
|
|
pointer-events: none;
|
|
position: absolute;
|
|
top: -4px;
|
|
right: -4px;
|
|
bottom: -4px;
|
|
left: -4px;
|
|
border: 2px dashed var(--MI_THEME-focus);
|
|
border-radius: 4px;
|
|
}
|
|
}
|
|
}
|
|
|
|
.checkboxWrapper {
|
|
position: absolute;
|
|
border-radius: 50%;
|
|
bottom: 2px;
|
|
right: 2px;
|
|
padding: 8px;
|
|
box-sizing: border-box;
|
|
|
|
> .checkbox {
|
|
position: relative;
|
|
width: 18px;
|
|
height: 18px;
|
|
background: #fff;
|
|
border: solid 2px var(--MI_THEME-divider);
|
|
border-radius: 4px;
|
|
box-sizing: border-box;
|
|
|
|
&.checked {
|
|
border-color: var(--MI_THEME-accent);
|
|
background: var(--MI_THEME-accent);
|
|
|
|
&::after {
|
|
content: "\ea5e";
|
|
font-family: 'tabler-icons';
|
|
position: absolute;
|
|
top: 50%;
|
|
left: 50%;
|
|
transform: translate(-50%, -50%);
|
|
color: #fff;
|
|
font-size: 12px;
|
|
line-height: 22px;
|
|
}
|
|
}
|
|
}
|
|
|
|
&:hover {
|
|
background: var(--MI_THEME-accentedBg);
|
|
}
|
|
}
|
|
|
|
.name {
|
|
margin: 0;
|
|
font-size: 0.9em;
|
|
}
|
|
|
|
.icon {
|
|
margin-right: 4px;
|
|
margin-left: 2px;
|
|
text-align: left;
|
|
}
|
|
|
|
.upload {
|
|
margin: 4px 4px;
|
|
font-size: 0.8em;
|
|
text-align: right;
|
|
}
|
|
</style>
|