From 2ea8e811d5f3f27f3d675ae4dab16decc774781f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=93=E3=81=91=E3=81=A3=E3=81=A1?= Date: Sun, 4 Sep 2022 03:47:00 +0900 Subject: [PATCH] fix: emojigen --- package.json | 2 +- packages/client/src/components/post-form.vue | 9 +- .../client/src/components/ui/context-menu.vue | 3 +- .../client/src/components/user-preview.vue | 3 +- packages/client/src/pages/admin/emojigen.vue | 272 +++++++++--------- packages/client/src/router.ts | 4 + .../client/src/scripts/select-file-enc.ts | 140 +-------- 7 files changed, 156 insertions(+), 277 deletions(-) diff --git a/package.json b/package.json index ad5d23cdd..a7e154e17 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "misskey", - "version": "12.118.1-simkey-v2", + "version": "12.118.1-simkey-v3", "codename": "indigo", "repository": { "type": "git", diff --git a/packages/client/src/components/post-form.vue b/packages/client/src/components/post-form.vue index 87bd5821c..010c87b40 100644 --- a/packages/client/src/components/post-form.vue +++ b/packages/client/src/components/post-form.vue @@ -490,9 +490,9 @@ function onDragover(ev) { switch (ev.dataTransfer.effectAllowed) { case 'all': case 'uninitialized': - case 'copy': - case 'copyLink': - case 'copyMove': + case 'copy': + case 'copyLink': + case 'copyMove': ev.dataTransfer.dropEffect = 'copy'; break; case 'linkMove': @@ -769,7 +769,7 @@ onMounted(() => { margin-left: 0 !important; } } - + > .local-only { margin: 0 0 0 12px; opacity: 0.7; @@ -910,6 +910,7 @@ onMounted(() => { max-width: 100%; min-width: 100%; min-height: 90px; + height: 250px; &.withCw { padding-top: 8px; diff --git a/packages/client/src/components/ui/context-menu.vue b/packages/client/src/components/ui/context-menu.vue index d8d40677e..5a25dc282 100644 --- a/packages/client/src/components/ui/context-menu.vue +++ b/packages/client/src/components/ui/context-menu.vue @@ -76,12 +76,13 @@ function onMousedown(evt: Event) { } .fade-enter-active, .fade-leave-active { - transition: opacity 0.5s cubic-bezier(0.16, 1, 0.3, 1), transform 0.5s cubic-bezier(0.16, 1, 0.3, 1); + transition: opacity 0.5s cubic-bezier(0.16, 1, 0.3, 1), height 0.2s ease-out, transform 0.5s cubic-bezier(0.16, 1, 0.3, 1); transform-origin: left top; } .fade-enter-from, .fade-leave-to { opacity: 0; transform: scale(0.9); + height: 1px; } diff --git a/packages/client/src/components/user-preview.vue b/packages/client/src/components/user-preview.vue index f80947f75..a0ead5806 100644 --- a/packages/client/src/components/user-preview.vue +++ b/packages/client/src/components/user-preview.vue @@ -101,11 +101,12 @@ export default defineComponent({ - diff --git a/packages/client/src/router.ts b/packages/client/src/router.ts index 37a8fd3dc..68d36fa57 100644 --- a/packages/client/src/router.ts +++ b/packages/client/src/router.ts @@ -308,6 +308,10 @@ export const routes = [{ path: '/emojis', name: 'emojis', component: page(() => import('./pages/admin/emojis.vue')), + }, { + path: '/emojigen', + name: 'emojigen', + component: page(() => import('./pages/admin/emojigen.vue')), }, { path: '/queue', name: 'queue', diff --git a/packages/client/src/scripts/select-file-enc.ts b/packages/client/src/scripts/select-file-enc.ts index 6da64f03b..d5c8f7efc 100644 --- a/packages/client/src/scripts/select-file-enc.ts +++ b/packages/client/src/scripts/select-file-enc.ts @@ -1,9 +1,7 @@ import { ref } from 'vue'; -import * as os from '@/os'; -import { stream } from '@/stream'; -import { i18n } from '@/i18n'; -import { defaultStore } from '@/store'; import { DriveFile } from 'misskey-js/built/entities'; +import { defaultStore } from '@/store'; +import { uploadFile } from '@/scripts/upload'; function select(src: any, label: string | null, multiple: boolean): Promise { return new Promise((res, rej) => { @@ -12,126 +10,17 @@ function select(src: any, label: string | null, multiple: boolean): Promise { const input = document.createElement('input'); input.type = 'file'; + input.accept = 'video/mp4'; input.multiple = multiple; input.onchange = () => { + const promises = Array.from(input.files).map(file => uploadFile(file, defaultStore.state.uploadFolder, undefined, keepOriginal.value)); - //ここから - // @ts-ignore - function VideoConverter (videoFileData, targetFormat) { - try { - targetFormat = targetFormat.toLowerCase(); - let reader = new FileReader(); - return new Promise(resolve => { - reader.onload = function (event) { - let contentType = 'video/'+targetFormat; - - // @ts-ignore - let fileData: ArrayBuffer = event.target.result.split(','); - let b64Data = fileData[1]; - let blob = getBlobFromBase64Data(b64Data, contentType); - let blobUrl = URL.createObjectURL(blob); - - let convertedVideo: any = { - name: videoFileData.name.substring(0, videoFileData.name.lastIndexOf(".")), - format: targetFormat, - data: blob - } - // console.log("convertedVideo: ", convertedVideo); - resolve(convertedVideo); - } - reader.readAsDataURL(videoFileData); - }); - - } catch (e) { - console.log("Error occurred while converting : ", e); - } - } - - function getBlobFromBase64Data(b64Data, contentType, sliceSize=512) { - const byteCharacters = atob(b64Data); - const byteArrays = []; - - for (let offset = 0; offset < byteCharacters.length; offset += sliceSize) { - const slice = byteCharacters.slice(offset, offset + sliceSize); - - const byteNumbers = new Array(slice.length); - for (let i = 0; i < slice.length; i++) { - byteNumbers[i] = slice.charCodeAt(i); - } - - const byteArray = new Uint8Array(byteNumbers); - // @ts-ignore - byteArrays.push(byteArray); - } - - const blob = new Blob(byteArrays, {type: contentType}); - return blob; - } - - //ここまで - - /* - MIT License - - Copyright (c) 2021 Suvro Debnath - - Permission is hereby granted, free of charge, to any person obtaining a copy - of this software and associated documentation files (the "Software"), to deal - in the Software without restriction, including without limitation the rights - to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - copies of the Software, and to permit persons to whom the Software is - furnished to do so, subject to the following conditions: - - The above copyright notice and this permission notice shall be included in all - copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - SOFTWARE. - */ - - - Array.from(input.files).map(async file => { - if (file.type.indexOf('video/mp4') === 1) { - os.toast('It is mp4 file'); - os.upload(file, defaultStore.state.uploadFolder).then(driveFiles => { - res(driveFiles); - }).catch(e => { - os.alert({ - type: 'error', - text: e - }); - }); - return - } - - console.log('convert video'); - os.toast('Try convert to mp4'); - //convertVideo(file); - let sourceVideoFile = file; - let targetVideoFormat = 'mp4' - console.log('start convert video'); - let convertedVideoDataObj = await VideoConverter(sourceVideoFile, targetVideoFormat); - console.log('end convert video'); - - // @ts-ignore - let convertedVideoFile = await new File([convertedVideoDataObj.data], convertedVideoDataObj.name + "." + convertedVideoDataObj.format); - - os.upload(convertedVideoFile, defaultStore.state.uploadFolder).then(driveFiles => { - res(driveFiles); - }).catch(e => { - os.alert({ - type: 'error', - text: e - }); - }); + Promise.all(promises).then(driveFiles => { + res(multiple ? driveFiles : driveFiles[0]); + }).catch(err => { + // アップロードのエラーは uploadFile 内でハンドリングされているためアラートダイアログを出したりはしてはいけない }); - // 一応廃棄 (window as any).__misskey_input_ref__ = null; }; @@ -143,21 +32,10 @@ function select(src: any, label: string | null, multiple: boolean): Promise { return select(src, label, false) as Promise; } - -export function selectFilesEnc(src: any, label: string | null = null): Promise { - return select(src, label, true) as Promise; -}