Migrate to Vue3 (#6587)

* Update reaction.vue

* fix  bug

* wip

* wip

* wjio

* wip

* Revert "wip"

This reverts commit e427f2160adf4e8a4147006e25a89854edab0033.

* wip

* wip

* wip

* Update init.ts

* Update drive-window.vue

* wip

* wip

* Use PascalCase for components

* Use PascalCase for components

* update dep

* wip

* wip

* wip

* Update init.ts

* wip

* Update paging.ts

* Update test.vue

* watch deep

* wip

* lint

* wip

* wip

* wip

* wip

* wiop

* wip

* Update webpack.config.ts

* alllow null poll

* wip

* wip

* wip

* wiop

* UI redesign & refactor (#6714)

* wip

* wip

* wip

* wip

* wip

* Update drive.vue

* Update word-mute.vue

* wip

* wip

* wip

* clean up

* wip

* Update default.vue

* wip

* Update notes.vue

* Update mfm.ts

* Update index.home.vue

* Update post-form.vue

* Update post-form-attaches.vue

* wip

* Update post-form.vue

* Update sidebar.vue

* wip

* wip

* Update index.vue

* wip

* Update default.vue

* Update index.vue

* Update index.vue

* wip

* Update post-form-attaches.vue

* Update note.vue

* wip

* clean up

* Update notes.vue

* wip

* wip

* Update ja-JP.yml

* wip

* wip

* Update index.vue

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* Update default.vue

* wip

* Update _dark.json5

* wip

* wip

* wip

* clean up

* wip

* wip

* Update index.vue

* Update test.vue

* wip

* wip

* fix

* wip

* wip

* wip

* wip

* clena yop

* wip

* wip

* Update store.ts

* Update messaging-room.vue

* Update default.widgets.vue

* fix

* wip

* wip

* Update modal.vue

* wip

* Update os.ts

* Update os.ts

* Update deck.vue

* Update init.ts

* wip

* Update ja-JP.yml

* v-sizeは単にwindowのresizeを監視するだけで良いかもしれない

* Update modal.vue

* wip

* Update tooltip.ts

* wip

* wip

* wip

* wip

* wip

* Update image-viewer.vue

* wip

* wip

* Update style.scss

* Update style.scss

* Update visitor.vue

* wip

* Update init.ts

* Update init.ts

* wip

* wip

* Update visitor.vue

* Update visitor.vue

* Update visitor.vue

* Update visitor.vue

* wip

* wip

* Update modal.vue

* Update header.vue

* Update menu.vue

* Update about.vue

* Update about-misskey.vue

* wip

* wip

* Update visitor.vue

* Update tooltip.ts

* wip

* Update drive.vue

* wip

* Update style.scss

* Update header.vue

* wip

* wip

* Update users.user.vue

* Update announcements.vue

* wip

* wip

* wip

* Update emojis.vue

* wip

* Update emojis.vue

* Update style.scss

* Update users.vue

* wip

* Update style.scss

* wip

* Update welcome.entrance.vue

* Update radio.vue

* Update size.ts

* Update emoji-edit-dialog.vue

* wip

* Update emojis.vue

* wip

* Update emojis.vue

* Update emojis.vue

* Update emojis.vue

* wip

* wip

* wip

* wip

* Update file-dialog.vue

* wip

* wip

* Update token-generate-window.vue

* Update notification-setting-window.vue

* wip

* wip

* Update _error_.vue

* Update ja-JP.yml

* wip

* wip

* Update store.ts

* Update emojis.vue

* Update emojis.vue

* Update emojis.vue

* Update announcements.vue

* Update store.ts

* wip

* Update page-editor.vue

* wip

* wip

* Update modal.vue

* wip

* Update select-file.ts

* Update timeline.vue

* Update emojis.vue

* Update os.ts

* wip

* Update user-select.vue

* Update mfm.ts

* Update get-file-info.ts

* Update drive.vue

* Update init.ts

* Update mfm.ts

* wip

* wip

* Update window.vue

* Update note.vue

* wip

* wip

* Update user-info.vue

* wip

* wip

* wip

* wip

* wip

* Update header.vue

* Update header.vue

* wip

* Update explore.vue

* wip

* wip

* wip

* Update webpack.config.ts

* wip

* wip

* wip

* wip

* wip

* wip

* Update autocomplete.ts

* wip

* wip

* wip

* Update toast.vue

* wip

* Update post-form-dialog.vue

* wip

* wip

* wip

* wip

* wip

* Update users.vue

* wip

* Update explore.vue

* wip

* wip

* wip

* Update package.json

* wip

* Update icon-dialog.vue

* wip

* wip

* Update user-preview.ts

* wip

* wip

* wip

* wip

* wip

* Update instance.vue

* Update user-name.vue

* Update federation.vue

* Update instance.vue

* wip

* wip

* Update tag.vue

* wip

* wip

* wip

* wip

* wip

* Update instance.vue

* wip

* Update os.ts

* Update os.ts

* wip

* wip

* wip

* Update router.ts

* wip

* Update init.ts

* Update note.vue

* Update messages.vue

* wip

* wip

* wip

* wip

* wip

* google

* wip

* wip

* wip

* wip

* Update theme-editor.vue

* wip

* wip

* Update room.vue

* Update channel-editor.vue

* wip

* Update window.vue

* Update window.vue

* wip

* Update window.vue

* Update window.vue

* wip

* Update menu.vue

* wip

* wip

* wip

* wip

* Update messaging-room.vue

* wip

* Update post-form.vue

* Update default.widgets.vue

* Update window.vue

* wip
This commit is contained in:
syuilo
2020-10-17 20:12:00 +09:00
committed by GitHub
parent a40f38b2b5
commit 7199e6f4e0
357 changed files with 15053 additions and 12496 deletions

View File

@ -2,34 +2,35 @@
<div class="yfudmmck">
<nav>
<div class="path" @contextmenu.prevent.stop="() => {}">
<x-nav-folder :class="{ current: folder == null }"/>
<XNavFolder :class="{ current: folder == null }"/>
<template v-for="f in hierarchyFolders">
<span class="separator" :key="f.id + ':separator'"><fa :icon="faAngleRight"/></span>
<x-nav-folder :folder="f" :key="f.id"/>
<span class="separator"><Fa :icon="faAngleRight"/></span>
<XNavFolder :folder="f"/>
</template>
<span class="separator" v-if="folder != null"><fa :icon="faAngleRight"/></span>
<span class="separator" v-if="folder != null"><Fa :icon="faAngleRight"/></span>
<span class="folder current" v-if="folder != null">{{ folder.name }}</span>
</div>
</nav>
<div class="main" :class="{ uploading: uploadings.length > 0, fetching }"
<div class="main _section" :class="{ uploading: uploadings.length > 0, fetching }"
ref="main"
@dragover.prevent.stop="onDragover"
@dragenter="onDragenter"
@dragleave="onDragleave"
@drop.prevent.stop="onDrop"
@contextmenu="onContextmenu"
>
<div class="contents" ref="contents">
<div class="folders" ref="foldersContainer" v-show="folders.length > 0">
<x-folder v-for="f in folders" :key="f.id" class="folder" :folder="f" :select-mode="select === 'folder'" :is-selected="selectedFolders.some(x => x.id === f.id)" @chosen="chooseFolder"/>
<XFolder v-for="f in folders" :key="f.id" class="folder" :folder="f" :select-mode="select === 'folder'" :is-selected="selectedFolders.some(x => x.id === f.id)" @chosen="chooseFolder"/>
<!-- SEE: https://stackoverflow.com/questions/18744164/flex-box-align-last-row-to-grid -->
<div class="padding" v-for="(n, i) in 16" :key="i"></div>
<mk-button ref="moreFolders" v-if="moreFolders">{{ $t('loadMore') }}</mk-button>
<MkButton ref="moreFolders" v-if="moreFolders">{{ $t('loadMore') }}</MkButton>
</div>
<div class="files" ref="filesContainer" v-show="files.length > 0">
<x-file v-for="file in files" :key="file.id" class="file" :file="file" :select-mode="select === 'file'" :is-selected="selectedFiles.some(x => x.id === file.id)" @chosen="chooseFile"/>
<XFile v-for="file in files" :key="file.id" class="file" :file="file" :select-mode="select === 'file'" :is-selected="selectedFiles.some(x => x.id === file.id)" @chosen="chooseFile"/>
<!-- SEE: https://stackoverflow.com/questions/18744164/flex-box-align-last-row-to-grid -->
<div class="padding" v-for="(n, i) in 16" :key="i"></div>
<mk-button ref="loadMoreFiles" @click="fetchMoreFiles" v-show="moreFiles">{{ $t('loadMore') }}</mk-button>
<MkButton ref="loadMoreFiles" @click="fetchMoreFiles" v-show="moreFiles">{{ $t('loadMore') }}</MkButton>
</div>
<div class="empty" v-if="files.length == 0 && folders.length == 0 && !fetching">
<p v-if="draghover">{{ $t('empty-draghover') }}</p>
@ -37,29 +38,28 @@
<p v-if="!draghover && folder != null">{{ $t('emptyFolder') }}</p>
</div>
</div>
<mk-loading v-if="fetching"/>
<MkLoading v-if="fetching"/>
</div>
<div class="dropzone" v-if="draghover"></div>
<x-uploader ref="uploader" @change="onChangeUploaderUploads" @uploaded="onUploaderUploaded"/>
<input ref="fileInput" type="file" accept="*/*" multiple="multiple" tabindex="-1" @change="onChangeFileInput"/>
</div>
</template>
<script lang="ts">
import Vue from 'vue';
import { faAngleRight } from '@fortawesome/free-solid-svg-icons';
import { defineComponent } from 'vue';
import { faAngleRight, faFolderPlus, faICursor, faLink, faUpload } from '@fortawesome/free-solid-svg-icons';
import XNavFolder from './drive.nav-folder.vue';
import XFolder from './drive.folder.vue';
import XFile from './drive.file.vue';
import XUploader from './uploader.vue';
import MkButton from './ui/button.vue';
import * as os from '@/os';
import { faTrashAlt } from '@fortawesome/free-regular-svg-icons';
export default Vue.extend({
export default defineComponent({
components: {
XNavFolder,
XFolder,
XFile,
XUploader,
MkButton,
},
@ -85,6 +85,8 @@ export default Vue.extend({
}
},
emits: ['selected', 'change-selection', 'move-root', 'cd', 'open-folder'],
data() {
return {
/**
@ -100,7 +102,7 @@ export default Vue.extend({
hierarchyFolders: [],
selectedFiles: [],
selectedFolders: [],
uploadings: [],
uploadings: os.uploads,
connection: null,
/**
@ -140,7 +142,7 @@ export default Vue.extend({
});
}
this.connection = this.$root.stream.useSharedConnection('drive');
this.connection = os.stream.useSharedConnection('drive');
this.connection.on('fileCreated', this.onStreamDriveFileCreated);
this.connection.on('fileUpdated', this.onStreamDriveFileUpdated);
@ -164,7 +166,7 @@ export default Vue.extend({
}
},
beforeDestroy() {
beforeUnmount() {
this.connection.dispose();
this.ilFilesObserver.disconnect();
},
@ -204,14 +206,6 @@ export default Vue.extend({
this.removeFolder(folderId);
},
onChangeUploaderUploads(uploads) {
this.uploadings = uploads;
},
onUploaderUploaded(file) {
this.addFile(file, true);
},
onDragover(e): any {
// ドラッグ元が自分自身の所有するアイテムだったら
if (this.isDragSource) {
@ -221,8 +215,8 @@ export default Vue.extend({
}
const isFile = e.dataTransfer.items[0].kind == 'file';
const isDriveFile = e.dataTransfer.types[0] == 'mk_drive_file';
const isDriveFolder = e.dataTransfer.types[0] == 'mk_drive_folder';
const isDriveFile = e.dataTransfer.types[0] == _DATA_TRANSFER_DRIVE_FILE_;
const isDriveFolder = e.dataTransfer.types[0] == _DATA_TRANSFER_DRIVE_FOLDER_;
if (isFile || isDriveFile || isDriveFolder) {
e.dataTransfer.dropEffect = e.dataTransfer.effectAllowed == 'all' ? 'copy' : 'move';
@ -253,12 +247,12 @@ export default Vue.extend({
}
//#region ドライブのファイル
const driveFile = e.dataTransfer.getData('mk_drive_file');
const driveFile = e.dataTransfer.getData(_DATA_TRANSFER_DRIVE_FILE_);
if (driveFile != null && driveFile != '') {
const file = JSON.parse(driveFile);
if (this.files.some(f => f.id == file.id)) return;
this.removeFile(file.id);
this.$root.api('drive/files/update', {
os.api('drive/files/update', {
fileId: file.id,
folderId: this.folder ? this.folder.id : null
});
@ -266,7 +260,7 @@ export default Vue.extend({
//#endregion
//#region ドライブのフォルダ
const driveFolder = e.dataTransfer.getData('mk_drive_folder');
const driveFolder = e.dataTransfer.getData(_DATA_TRANSFER_DRIVE_FOLDER_);
if (driveFolder != null && driveFolder != '') {
const folder = JSON.parse(driveFolder);
@ -274,7 +268,7 @@ export default Vue.extend({
if (this.folder && folder.id == this.folder.id) return false;
if (this.folders.some(f => f.id == folder.id)) return false;
this.removeFolder(folder.id);
this.$root.api('drive/folders/update', {
os.api('drive/folders/update', {
folderId: folder.id,
parentId: this.folder ? this.folder.id : null
}).then(() => {
@ -282,15 +276,15 @@ export default Vue.extend({
}).catch(err => {
switch (err) {
case 'detected-circular-definition':
this.$root.dialog({
os.dialog({
title: this.$t('unableToProcess'),
text: this.$t('circularReferenceFolder')
});
break;
default:
this.$root.dialog({
os.dialog({
type: 'error',
text: this.$t('error')
text: this.$t('somethingHappened')
});
}
});
@ -303,19 +297,19 @@ export default Vue.extend({
},
urlUpload() {
this.$root.dialog({
os.dialog({
title: this.$t('uploadFromUrl'),
input: {
placeholder: this.$t('uploadFromUrlDescription')
}
}).then(({ canceled, result: url }) => {
if (canceled) return;
this.$root.api('drive/files/upload_from_url', {
os.api('drive/files/upload_from_url', {
url: url,
folderId: this.folder ? this.folder.id : undefined
});
this.$root.dialog({
os.dialog({
title: this.$t('uploadFromUrlRequested'),
text: this.$t('uploadFromUrlMayTakeTime')
});
@ -323,14 +317,14 @@ export default Vue.extend({
},
createFolder() {
this.$root.dialog({
os.dialog({
title: this.$t('createFolder'),
input: {
placeholder: this.$t('folderName')
}
}).then(({ canceled, result: name }) => {
if (canceled) return;
this.$root.api('drive/folders/create', {
os.api('drive/folders/create', {
name: name,
parentId: this.folder ? this.folder.id : undefined
}).then(folder => {
@ -340,7 +334,7 @@ export default Vue.extend({
},
renameFolder(folder) {
this.$root.dialog({
os.dialog({
title: this.$t('renameFolder'),
input: {
placeholder: this.$t('inputNewFolderName'),
@ -348,7 +342,7 @@ export default Vue.extend({
}
}).then(({ canceled, result: name }) => {
if (canceled) return;
this.$root.api('drive/folders/update', {
os.api('drive/folders/update', {
folderId: folder.id,
name: name
}).then(folder => {
@ -359,7 +353,7 @@ export default Vue.extend({
},
deleteFolder(folder) {
this.$root.api('drive/folders/delete', {
os.api('drive/folders/delete', {
folderId: folder.id
}).then(() => {
// 削除時に親フォルダに移動
@ -367,14 +361,14 @@ export default Vue.extend({
}).catch(err => {
switch(err.id) {
case 'b0fc8a17-963c-405d-bfbc-859a487295e1':
this.$root.dialog({
os.dialog({
type: 'error',
title: this.$t('unableToDelete'),
text: this.$t('hasChildFilesOrFolders')
});
break;
default:
this.$root.dialog({
os.dialog({
type: 'error',
text: this.$t('unableToDelete')
});
@ -390,7 +384,9 @@ export default Vue.extend({
upload(file, folder) {
if (folder && typeof folder == 'object') folder = folder.id;
(this.$refs.uploader as any).upload(file, folder);
os.upload(file, folder).then(res => {
this.addFile(res, true);
});
},
chooseFile(file) {
@ -441,7 +437,7 @@ export default Vue.extend({
this.fetching = true;
this.$root.api('drive/folders/show', {
os.api('drive/folders/show', {
folderId: target
}).then(folder => {
this.folder = folder;
@ -465,7 +461,7 @@ export default Vue.extend({
if (this.folders.some(f => f.id == folder.id)) {
const exist = this.folders.map(f => f.id).indexOf(folder.id);
Vue.set(this.folders, exist, folder);
this.folders[exist] = folder;
return;
}
@ -482,7 +478,7 @@ export default Vue.extend({
if (this.files.some(f => f.id == file.id)) {
const exist = this.files.map(f => f.id).indexOf(file.id);
Vue.set(this.files, exist, file);
this.files[exist] = file;
return;
}
@ -543,7 +539,7 @@ export default Vue.extend({
const filesMax = 30;
// フォルダ一覧取得
this.$root.api('drive/folders', {
os.api('drive/folders', {
folderId: this.folder ? this.folder.id : null,
limit: foldersMax + 1
}).then(folders => {
@ -556,7 +552,7 @@ export default Vue.extend({
});
// ファイル一覧取得
this.$root.api('drive/files', {
os.api('drive/files', {
folderId: this.folder ? this.folder.id : null,
type: this.type,
limit: filesMax + 1
@ -587,7 +583,7 @@ export default Vue.extend({
const max = 30;
// ファイル一覧取得
this.$root.api('drive/files', {
os.api('drive/files', {
folderId: this.folder ? this.folder.id : null,
type: this.type,
untilId: this.files[this.files.length - 1].id,
@ -602,7 +598,41 @@ export default Vue.extend({
for (const x of files) this.appendFile(x);
this.fetching = false;
});
}
},
getMenu() {
return [{
text: this.$t('addFile'),
type: 'label'
}, {
text: this.$t('upload'),
icon: faUpload,
action: () => { this.selectLocalFile(); }
}, {
text: this.$t('fromUrl'),
icon: faLink,
action: () => { this.urlUpload(); }
}, null, {
text: this.folder ? this.folder.name : this.$t('drive'),
type: 'label'
}, this.folder ? {
text: this.$t('renameFolder'),
icon: faICursor,
action: () => { this.renameFolder(this.folder); }
} : undefined, this.folder ? {
text: this.$t('deleteFolder'),
icon: faTrashAlt,
action: () => { this.deleteFolder(this.folder); }
} : undefined, {
text: this.$t('createFolder'),
icon: faFolderPlus,
action: () => { this.createFolder(); }
}];
},
onContextmenu(e) {
os.contextMenu(this.getMenu(), e);
},
}
});
</script>
@ -613,6 +643,8 @@ export default Vue.extend({
display: block;
z-index: 2;
width: 100%;
padding: 0 8px;
box-sizing: border-box;
overflow: auto;
font-size: 0.9em;
box-shadow: 0 1px 0 var(--divider);
@ -666,7 +698,6 @@ export default Vue.extend({
}
> .main {
padding: 8px 0;
overflow: auto;
&, * {
@ -734,11 +765,6 @@ export default Vue.extend({
pointer-events: none;
}
> .mk-uploader {
height: 100px;
padding: 16px;
}
> input {
display: none;
}