wip
This commit is contained in:
parent
0397a5046d
commit
df2971e437
|
@ -22,7 +22,7 @@ SPDX-License-Identifier: AGPL-3.0-only
|
||||||
:key="ctx.id"
|
:key="ctx.id"
|
||||||
v-panel
|
v-panel
|
||||||
:class="[$style.item, ctx.waiting ? $style.itemWaiting : null, ctx.uploaded ? $style.itemCompleted : null, ctx.uploadFailed ? $style.itemFailed : null]"
|
:class="[$style.item, ctx.waiting ? $style.itemWaiting : null, ctx.uploaded ? $style.itemCompleted : null, ctx.uploadFailed ? $style.itemFailed : null]"
|
||||||
:style="{ '--p': ctx.progressValue !== null ? `${ctx.progressValue / ctx.progressMax * 100}%` : '0%' }"
|
:style="{ '--p': ctx.progress != null ? `${ctx.progress.value / ctx.progress.max * 100}%` : '0%' }"
|
||||||
>
|
>
|
||||||
<div :class="$style.itemInner">
|
<div :class="$style.itemInner">
|
||||||
<div>
|
<div>
|
||||||
|
@ -127,8 +127,7 @@ const emit = defineEmits<{
|
||||||
const items = ref([] as {
|
const items = ref([] as {
|
||||||
id: string;
|
id: string;
|
||||||
name: string;
|
name: string;
|
||||||
progressMax: number | null;
|
progress: { max: number; value: number } | null;
|
||||||
progressValue: number | null;
|
|
||||||
thumbnail: string;
|
thumbnail: string;
|
||||||
waiting: boolean;
|
waiting: boolean;
|
||||||
uploading: boolean;
|
uploading: boolean;
|
||||||
|
@ -263,13 +262,16 @@ async function upload() { // エラーハンドリングなどを考慮してシ
|
||||||
folderId: props.folderId,
|
folderId: props.folderId,
|
||||||
onProgress: (progress) => {
|
onProgress: (progress) => {
|
||||||
item.waiting = false;
|
item.waiting = false;
|
||||||
item.progressMax = progress.total;
|
if (item.progress == null) {
|
||||||
item.progressValue = progress.loaded;
|
item.progress = { max: progress.total, value: progress.loaded };
|
||||||
|
} else {
|
||||||
|
item.progress.value = progress.loaded;
|
||||||
|
item.progress.max = progress.total;
|
||||||
|
}
|
||||||
},
|
},
|
||||||
}).catch(err => {
|
}).catch(err => {
|
||||||
item.uploadFailed = true;
|
item.uploadFailed = true;
|
||||||
item.progressMax = null;
|
item.progress = null;
|
||||||
item.progressValue = null;
|
|
||||||
throw err;
|
throw err;
|
||||||
}).finally(() => {
|
}).finally(() => {
|
||||||
item.uploading = false;
|
item.uploading = false;
|
||||||
|
@ -287,8 +289,7 @@ onMounted(() => {
|
||||||
items.value.push({
|
items.value.push({
|
||||||
id,
|
id,
|
||||||
name: prefer.s.keepOriginalFilename ? filename : id + extension,
|
name: prefer.s.keepOriginalFilename ? filename : id + extension,
|
||||||
progressMax: null,
|
progress: null,
|
||||||
progressValue: null,
|
|
||||||
thumbnail: window.URL.createObjectURL(file),
|
thumbnail: window.URL.createObjectURL(file),
|
||||||
waiting: false,
|
waiting: false,
|
||||||
uploading: false,
|
uploading: false,
|
||||||
|
|
|
@ -48,6 +48,7 @@ export function chooseFileFromUrl(): Promise<Misskey.entities.DriveFile> {
|
||||||
|
|
||||||
const marker = Math.random().toString(); // TODO: UUIDとか使う
|
const marker = Math.random().toString(); // TODO: UUIDとか使う
|
||||||
|
|
||||||
|
// TODO: no websocketモード対応
|
||||||
const connection = useStream().useChannel('main');
|
const connection = useStream().useChannel('main');
|
||||||
connection.on('urlUploadFinished', urlResponse => {
|
connection.on('urlUploadFinished', urlResponse => {
|
||||||
if (urlResponse.marker === marker) {
|
if (urlResponse.marker === marker) {
|
||||||
|
|
Loading…
Reference in New Issue