Compare commits
30 Commits
sim-dev/me
...
sim-dev/em
Author | SHA1 | Date | |
---|---|---|---|
2b05de0204 | |||
fbc1ec67cf | |||
c7b6e0cbf9 | |||
677f6bd6e1 | |||
ea6f538109 | |||
3a540dd1f6 | |||
2be42c0e4b | |||
38e8d2cdb5 | |||
3d8c8af0e8 | |||
d06e9e7e0c | |||
8bc3406c3c | |||
f817979d22 | |||
123fedb5c4 | |||
d01fde57ae | |||
657959dd30 | |||
ac50efc5d1 | |||
1e17b7db6b | |||
e0cea2facc | |||
167a7201c2 | |||
581738f264 | |||
cb18ce16a0 | |||
356d28928a | |||
3bd7f3d301 | |||
fa7c8024d6 | |||
5bff0cb41f | |||
6de468573a | |||
6fb825afdc | |||
f15e9b1e4e | |||
f97146be98 | |||
09ff9f76d0 |
@ -896,6 +896,9 @@ shuffle: "シャッフル"
|
||||
account: "アカウント"
|
||||
move: "移動"
|
||||
deckOld: "旧デッキ"
|
||||
pakuruConfirm: "パクりますか?"
|
||||
pakuru: "パクる"
|
||||
duplicateEmoji: "同じ名前の絵文字が存在します。インポートしますか?"
|
||||
|
||||
_sensitiveMediaDetection:
|
||||
description: "機械学習を使って自動でセンシティブなメディアを検出し、モデレーションに役立てることができます。サーバーの負荷が少し増えます。"
|
||||
|
@ -839,6 +839,7 @@ emojiApproval: "絵文字を登録"
|
||||
deckOld: "旧デッキ"
|
||||
pakuruConfirm: "パクりますか?"
|
||||
pakuru: "パクる"
|
||||
duplicateEmoji: "同じ名前の絵文字が存在します。インポートしますか?"
|
||||
|
||||
|
||||
_emailUnavailable:
|
||||
|
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "misskey",
|
||||
"version": "12.119.0-simkey-v5",
|
||||
"version": "12.119.0-simkey-v7",
|
||||
"codename": "indigo",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
|
@ -24,7 +24,6 @@ module.exports = {
|
||||
// window の禁止理由: グローバルスコープと衝突し、予期せぬ結果を招くため
|
||||
// e の禁止理由: error や event など、複数のキーワードの頭文字であり分かりにくいため
|
||||
'id-denylist': ['error', 'window', 'e'],
|
||||
"forceConsistentCasingInFileNames": true,
|
||||
'no-shadow': ['warn'],
|
||||
'vue/attributes-order': ['error', {
|
||||
'alphabetical': false,
|
||||
|
@ -6,6 +6,7 @@
|
||||
class="hkzvhatu _button"
|
||||
:class="{ reacted: note.myReaction == reaction, canToggle }"
|
||||
@click="toggleReaction()"
|
||||
@contextmenu.stop="onContextmenu"
|
||||
>
|
||||
<XReactionIcon class="icon" :reaction="reaction" :custom-emojis="note.emojis"/>
|
||||
<span class="count">{{ count }}</span>
|
||||
@ -13,13 +14,14 @@
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { computed, onMounted, ref, watch } from 'vue';
|
||||
import { computed, defineAsyncComponent, onMounted, ref, watch } from 'vue';
|
||||
import * as misskey from 'misskey-js';
|
||||
import XDetails from '@/components/MkReactionsViewer.details.vue';
|
||||
import XReactionIcon from '@/components/MkReactionIcon.vue';
|
||||
import * as os from '@/os';
|
||||
import { useTooltip } from '@/scripts/use-tooltip';
|
||||
import { $i } from '@/account';
|
||||
import { openReactionImportMenu } from '@/scripts/reactionImportMenu';
|
||||
|
||||
const props = defineProps<{
|
||||
reaction: string;
|
||||
@ -88,6 +90,11 @@ useTooltip(buttonRef, async (showing) => {
|
||||
targetElement: buttonRef.value,
|
||||
}, {}, 'closed');
|
||||
}, 100);
|
||||
|
||||
const onContextmenu = (e: MouseEvent) => {
|
||||
e.preventDefault();
|
||||
openReactionImportMenu(e, props.reaction);
|
||||
};
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
|
@ -10,7 +10,7 @@
|
||||
<transition :name="$store.state.animation ? 'zoom' : ''" mode="out-in">
|
||||
<component :is="self ? 'MkA' : 'a'" v-if="!fetching" class="link" :class="{ compact }" :[attr]="self ? url.substr(local.length) : url" rel="nofollow noopener" :target="target" :title="url">
|
||||
<div v-if="thumbnail" class="thumbnail" :style="`background-image: url('${thumbnail}')`">
|
||||
<button v-if="!playerEnabled && player.url" class="_button" :title="i18n.ts.enablePlayer" @click.prevent="playerEnabled = false" @click="openPlayer()"><i class="fas fa-play-circle"></i></button>
|
||||
<button v-if="!playerEnabled && player.url" class="_button" :title="i18n.ts.enablePlayer" @click.prevent="isMobile? playerEnabled = true : openPlayer()"><i class="fas fa-play-circle"></i></button>
|
||||
</div>
|
||||
<article>
|
||||
<header>
|
||||
@ -37,6 +37,7 @@ import { onMounted, onUnmounted } from 'vue';
|
||||
import { url as local, lang } from '@/config';
|
||||
import { i18n } from '@/i18n';
|
||||
import * as os from '@/os';
|
||||
import { deviceKind } from '@/scripts/device-kind';
|
||||
|
||||
const props = withDefaults(defineProps<{
|
||||
url: string;
|
||||
@ -47,6 +48,9 @@ const props = withDefaults(defineProps<{
|
||||
compact: false,
|
||||
});
|
||||
|
||||
const MOBILE_THRESHOLD = 500;
|
||||
const isMobile = $ref(deviceKind === 'smartphone' || window.innerWidth <= MOBILE_THRESHOLD);
|
||||
|
||||
const self = props.url.startsWith(local);
|
||||
const attr = self ? 'to' : 'href';
|
||||
const target = self ? null : '_blank';
|
||||
|
@ -1,35 +1,28 @@
|
||||
<template>
|
||||
<div class="poamfof fill">
|
||||
<transition :name="$store.state.animation ? 'fade' : ''" mode="out-in">
|
||||
<div v-if="player.url" class="player">
|
||||
<iframe v-if="!fetching" :src="player.url + (player.url.match(/\?/) ? '&autoplay=1&auto_play=1' : '?autoplay=1&auto_play=1')" frameborder="0" allow="autoplay; encrypted-media" allowfullscreen/>
|
||||
</div>
|
||||
</transition>
|
||||
<MkLoading v-if="fetching" />
|
||||
<MkError v-else-if="!player.url" @retry="fetch()" />
|
||||
</div>
|
||||
<div class="poamfof fill">
|
||||
<transition :name="$store.state.animation ? 'fade' : ''" mode="out-in">
|
||||
<div v-if="player.url" class="player">
|
||||
<iframe v-if="!fetching" :src="player.url + (player.url.match(/\?/) ? '&autoplay=1&auto_play=1' : '?autoplay=1&auto_play=1')" frameborder="0" allow="autoplay; encrypted-media" allowfullscreen/>
|
||||
</div>
|
||||
</transition>
|
||||
<MkLoading v-if="fetching" />
|
||||
<MkError v-else-if="!player.url" @retry="ytFetch()" />
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { i18n } from '@/i18n';
|
||||
import { definePageMetadata } from '@/scripts/page-metadata';
|
||||
import { computed } from 'vue';
|
||||
import { url as local, lang } from '@/config';
|
||||
import { lang } from '@/config';
|
||||
|
||||
const props = defineProps<{
|
||||
url: string;
|
||||
}>();
|
||||
|
||||
console.log(props.url);
|
||||
|
||||
const requestUrl = new URL(props.url);
|
||||
|
||||
let fetching = $ref(true);
|
||||
let title = $ref<string | null>(null);
|
||||
let description = $ref<string | null>(null);
|
||||
let thumbnail = $ref<string | null>(null);
|
||||
let icon = $ref<string | null>(null);
|
||||
let sitename = $ref<string | null>(null);
|
||||
let player = $ref({
|
||||
url: null,
|
||||
width: null,
|
||||
@ -38,43 +31,53 @@ let player = $ref({
|
||||
|
||||
const requestLang = (lang || 'ja-JP').replace('ja-KS', 'ja-JP');
|
||||
|
||||
fetch(`/url?url=${encodeURIComponent(requestUrl.href)}&lang=${requestLang}`).then(res => {
|
||||
res.json().then(info => {
|
||||
if (info.url == null) return;
|
||||
title = info.title;
|
||||
description = info.description;
|
||||
thumbnail = info.thumbnail;
|
||||
icon = info.icon;
|
||||
sitename = info.sitename;
|
||||
fetching = false;
|
||||
player = info.player;
|
||||
});
|
||||
});
|
||||
const ytFetch = () => {
|
||||
fetching = true;
|
||||
fetch(`/url?url=${encodeURIComponent(requestUrl.href)}&lang=${requestLang}`).then(res => {
|
||||
res.json().then(info => {
|
||||
if (info.url == null) return;
|
||||
title = info.title;
|
||||
fetching = false;
|
||||
player = info.player;
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
ytFetch();
|
||||
|
||||
definePageMetadata(computed(() => props.url ? {
|
||||
title: title?.toString() || 'ytplayer',
|
||||
title: title?.toString() || 'Youtube Player',
|
||||
path: `/notes/${props.url}`,
|
||||
icon: 'fa-brands fa-youtube'
|
||||
} : null));
|
||||
|
||||
console.log(await player.url);
|
||||
</script>
|
||||
|
||||
<style lang="scss">
|
||||
.poamfof {
|
||||
position: relative;
|
||||
overflow: hidden;
|
||||
min-height: 64px;
|
||||
|
||||
.player {
|
||||
position: absolute;
|
||||
top: 0;
|
||||
left: 0;
|
||||
right: 0;
|
||||
bottom: 0;
|
||||
height: calc(100% - 10px);
|
||||
width: calc(100% - 10px);
|
||||
padding: 5px;
|
||||
|
||||
iframe {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
border-radius: 0 0 var(--radius) var(--radius);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.fill {
|
||||
height: 100%;
|
||||
}
|
||||
.player {
|
||||
height: calc(100% - 10px);
|
||||
width: calc(100% - 10px);
|
||||
padding: 5px;
|
||||
|
||||
>iframe {
|
||||
height: 100%;
|
||||
width: 100%;
|
||||
border-radius: 0 0 var(--radius) var(--radius);
|
||||
left: 0;
|
||||
top: 0;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
114
packages/client/src/scripts/reactionImportMenu.ts
Normal file
114
packages/client/src/scripts/reactionImportMenu.ts
Normal file
@ -0,0 +1,114 @@
|
||||
import { defineAsyncComponent } from 'vue';
|
||||
import { $i } from '@/account';
|
||||
import { i18n } from '@/i18n';
|
||||
import * as os from '@/os';
|
||||
import copyToClipboard from '@/scripts/copy-to-clipboard';
|
||||
import { MenuItem } from '@/types/menu';
|
||||
|
||||
export async function openReactionImportMenu(ev: MouseEvent, reaction: string): Promise<void> {
|
||||
if (!reaction) return;
|
||||
|
||||
const host = reaction.match(/(?<=@).*\.*(?=:)/g)?.[0];
|
||||
const name = reaction.match(/(?<=:).*(?=@.*\.*(?=:))/g)?.[0];
|
||||
const isLocal = (host === null || host === '.');
|
||||
const isCustom = reaction.startsWith(':');
|
||||
|
||||
const getEmojiObject = (emojiId): Promise<Record<string, any> | null> => new Promise<Record<string, any> | null>(async resolve => {
|
||||
const sinceId = await os.api('admin/emoji/list', {
|
||||
limit: 1,
|
||||
untilId: emojiId.id,
|
||||
});
|
||||
|
||||
if (!sinceId || !sinceId[0] || !sinceId[0].id) {
|
||||
resolve(null);
|
||||
return;
|
||||
}
|
||||
|
||||
const id = await os.api('admin/emoji/list', {
|
||||
limit: 1,
|
||||
sinceId: sinceId[0].id,
|
||||
});
|
||||
|
||||
if (!id || !id[0]) {
|
||||
resolve(null);
|
||||
return;
|
||||
}
|
||||
|
||||
resolve(id[0]);
|
||||
});
|
||||
|
||||
const getEmojiId = async (): Promise<string | null> => {
|
||||
if (isLocal) return null;
|
||||
if (!host || !name) return null;
|
||||
|
||||
const resList: Record<string, any>[] = await os.api('admin/emoji/list-remote', {
|
||||
host,
|
||||
query: name,
|
||||
limit: 100,
|
||||
});
|
||||
|
||||
const emojiId = await resList.find(emoji => emoji.name === name && emoji.host === host)?.id;
|
||||
|
||||
return emojiId;
|
||||
};
|
||||
|
||||
const importEmoji = async (): Promise<void> => {
|
||||
const emojiId = await getEmojiId();
|
||||
if (!await emojiId) return;
|
||||
os.api('admin/emoji/copy', {
|
||||
emojiId: emojiId,
|
||||
}).then(async emoji => os.popup(defineAsyncComponent(() => import('@/pages/admin/emoji-edit-dialog.vue')), {
|
||||
emoji: await getEmojiObject(emoji),
|
||||
}));
|
||||
};
|
||||
|
||||
const menuItems: MenuItem[] = [{
|
||||
type: 'label',
|
||||
text: reaction,
|
||||
}, {
|
||||
type: 'button',
|
||||
icon: 'fas fa-copy',
|
||||
text: i18n.ts.copy,
|
||||
action: (): void => {
|
||||
copyToClipboard(isCustom ? `:${name}:` : reaction);
|
||||
},
|
||||
}];
|
||||
|
||||
const emojiId = await getEmojiId() ? await getEmojiId() : reaction;
|
||||
|
||||
if (
|
||||
isCustom &&
|
||||
emojiId &&
|
||||
($i?.isAdmin || $i?.isModerator) &&
|
||||
!isLocal
|
||||
) {
|
||||
menuItems.push({
|
||||
type: 'button',
|
||||
icon: 'fas fa-download',
|
||||
text: i18n.ts.import,
|
||||
action: async () => {
|
||||
const duplication: boolean = await os.api('meta').then(meta => {
|
||||
const emojis = meta.emojis;
|
||||
return emojis.some((emoji) => {
|
||||
return (emoji.name === name);
|
||||
});
|
||||
});
|
||||
|
||||
if (await duplication) {
|
||||
os.confirm({
|
||||
type: 'warning',
|
||||
text: i18n.ts.duplicateEmoji,
|
||||
}).then(res => {
|
||||
if (res.canceled) return;
|
||||
importEmoji();
|
||||
});
|
||||
} else {
|
||||
importEmoji();
|
||||
}
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
os.contextMenu(menuItems, ev);
|
||||
}
|
||||
|
Reference in New Issue
Block a user