fix code quality issues
This commit is contained in:
parent
50caa3fd5c
commit
1dce84dfe3
|
@ -14,7 +14,6 @@ import FFmpeg from 'fluent-ffmpeg';
|
||||||
import isSvg from 'is-svg';
|
import isSvg from 'is-svg';
|
||||||
import probeImageSize from 'probe-image-size';
|
import probeImageSize from 'probe-image-size';
|
||||||
import { type predictionType } from 'nsfwjs';
|
import { type predictionType } from 'nsfwjs';
|
||||||
import sharp from 'sharp';
|
|
||||||
import { sharpBmp } from '@misskey-dev/sharp-read-bmp';
|
import { sharpBmp } from '@misskey-dev/sharp-read-bmp';
|
||||||
import { encode } from 'blurhash';
|
import { encode } from 'blurhash';
|
||||||
import { createTempDir } from '@/misc/create-temp.js';
|
import { createTempDir } from '@/misc/create-temp.js';
|
||||||
|
@ -408,25 +407,14 @@ export class FileInfoService {
|
||||||
* Calculate average color of image
|
* Calculate average color of image
|
||||||
*/
|
*/
|
||||||
@bindThis
|
@bindThis
|
||||||
private getBlurhash(path: string, type: string): Promise<string> {
|
private async getBlurhash(path: string, type: string): Promise<string> {
|
||||||
return new Promise(async (resolve, reject) => {
|
const sharp = await sharpBmp(path, type);
|
||||||
(await sharpBmp(path, type))
|
const { data, info } = await sharp
|
||||||
.raw()
|
.raw()
|
||||||
.ensureAlpha()
|
.ensureAlpha()
|
||||||
.resize(64, 64, { fit: 'inside' })
|
.resize(64, 64, { fit: 'inside' })
|
||||||
.toBuffer((err, buffer, info) => {
|
.toBuffer({ resolveWithObject: true });
|
||||||
if (err) return reject(err);
|
|
||||||
|
|
||||||
let hash;
|
return encode(new Uint8ClampedArray(data), info.width, info.height, 5, 5);
|
||||||
|
|
||||||
try {
|
|
||||||
hash = encode(new Uint8ClampedArray(buffer), info.width, info.height, 5, 5);
|
|
||||||
} catch (e) {
|
|
||||||
return reject(e);
|
|
||||||
}
|
|
||||||
|
|
||||||
resolve(hash);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -47,9 +47,7 @@ import { instance } from '@/instance.js';
|
||||||
import { miLocalStorage } from '@/local-storage.js';
|
import { miLocalStorage } from '@/local-storage.js';
|
||||||
import * as os from '@/os.js';
|
import * as os from '@/os.js';
|
||||||
|
|
||||||
const emit = defineEmits<{
|
const emit = defineEmits<(ev: 'closed') => void>();
|
||||||
(ev: 'closed'): void;
|
|
||||||
}>();
|
|
||||||
|
|
||||||
const zIndex = os.claimZIndex('low');
|
const zIndex = os.claimZIndex('low');
|
||||||
|
|
||||||
|
|
|
@ -10,7 +10,7 @@ SPDX-License-Identifier: AGPL-3.0-only
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import { computed, watch, onMounted, ref, shallowRef, onUnmounted } from 'vue';
|
import { watch, onMounted, ref, shallowRef, onUnmounted } from 'vue';
|
||||||
import * as Misskey from 'misskey-js';
|
import * as Misskey from 'misskey-js';
|
||||||
import GameSetting from './game.setting.vue';
|
import GameSetting from './game.setting.vue';
|
||||||
import GameBoard from './game.board.vue';
|
import GameBoard from './game.board.vue';
|
||||||
|
|
Loading…
Reference in New Issue