chore(frontend): use toast to show message when call copyToClipboard

This commit is contained in:
syuilo 2025-03-16 15:04:38 +09:00
parent 32844e4775
commit 81a0cbd294
21 changed files with 16 additions and 27 deletions

4
locales/index.d.ts vendored
View file

@ -2810,6 +2810,10 @@ export interface Locale extends ILocale {
* *
*/ */
"copy": string; "copy": string;
/**
*
*/
"copiedToClipboard": string;
/** /**
* *
*/ */

View file

@ -698,6 +698,7 @@ userSaysSomethingAbout: "{name}が「{word}」について何かを言いまし
makeActive: "アクティブにする" makeActive: "アクティブにする"
display: "表示" display: "表示"
copy: "コピー" copy: "コピー"
copiedToClipboard: "クリップボードにコピーされました"
metrics: "メトリクス" metrics: "メトリクス"
overview: "概要" overview: "概要"
logs: "ログ" logs: "ログ"

View file

@ -48,7 +48,6 @@ const XCode = defineAsyncComponent(() => import('@/components/MkCode.core.vue'))
function copy() { function copy() {
copyToClipboard(props.code); copyToClipboard(props.code);
os.success();
} }
</script> </script>

View file

@ -194,7 +194,6 @@ function generate() {
function doCopy() { function doCopy() {
copyToClipboard(result.value); copyToClipboard(result.value);
os.success();
} }
//#endregion //#endregion

View file

@ -90,7 +90,6 @@ function deleteCode() {
function copyInviteCode() { function copyInviteCode() {
copyToClipboard(props.invite.code); copyToClipboard(props.invite.code);
os.success();
} }
</script> </script>

View file

@ -31,7 +31,6 @@ const props = withDefaults(defineProps<{
const copy_ = () => { const copy_ = () => {
copyToClipboard(props.copy); copyToClipboard(props.copy);
os.success();
}; };
</script> </script>

View file

@ -100,7 +100,6 @@ function onClick(ev: MouseEvent) {
icon: 'ti ti-copy', icon: 'ti ti-copy',
action: () => { action: () => {
copyToClipboard(`:${props.name}:`); copyToClipboard(`:${props.name}:`);
os.success();
}, },
}); });

View file

@ -50,7 +50,6 @@ function onClick(ev: MouseEvent) {
icon: 'ti ti-copy', icon: 'ti ti-copy',
action: () => { action: () => {
copyToClipboard(props.emoji); copyToClipboard(props.emoji);
os.success();
}, },
}); });

View file

@ -63,7 +63,6 @@ export const apiWithDialog = (<E extends keyof Misskey.Endpoints, P extends Miss
}); });
if (result === 'copy') { if (result === 'copy') {
copyToClipboard(`Endpoint: ${endpoint}\nInfo: ${JSON.stringify(err.info)}\nDate: ${date}`); copyToClipboard(`Endpoint: ${endpoint}\nInfo: ${JSON.stringify(err.info)}\nDate: ${date}`);
success();
} }
return; return;
} else if (err.code === 'RATE_LIMIT_EXCEEDED') { } else if (err.code === 'RATE_LIMIT_EXCEEDED') {

View file

@ -210,7 +210,6 @@ const headerActions = computed(() => {
return; return;
} }
copyToClipboard(`${url}/channels/${channel.value.id}`); copyToClipboard(`${url}/channels/${channel.value.id}`);
os.success();
}, },
}); });

View file

@ -148,7 +148,6 @@ const headerActions = computed(() => clip.value && isOwned.value ? [{
text: i18n.ts.copyUrl, text: i18n.ts.copyUrl,
action: () => { action: () => {
copyToClipboard(`${url}/clips/${clip.value!.id}`); copyToClipboard(`${url}/clips/${clip.value!.id}`);
os.success();
}, },
}, { }, {
icon: 'ti ti-code', icon: 'ti ti-code',

View file

@ -849,7 +849,6 @@ function exportLog() {
l: DropAndFusionGame.serializeLogs(logs), l: DropAndFusionGame.serializeLogs(logs),
}); });
copyToClipboard(data); copyToClipboard(data);
os.success();
} }
function updateSettings< function updateSettings<

View file

@ -25,7 +25,7 @@ import MkCustomEmojiDetailedDialog from '@/components/MkCustomEmojiDetailedDialo
import { $i } from '@/i.js'; import { $i } from '@/i.js';
const props = defineProps<{ const props = defineProps<{
emoji: Misskey.entities.EmojiSimple; emoji: Misskey.entities.EmojiSimple;
}>(); }>();
function menu(ev) { function menu(ev) {
@ -38,7 +38,6 @@ function menu(ev) {
icon: 'ti ti-copy', icon: 'ti ti-copy',
action: () => { action: () => {
copyToClipboard(`:${props.emoji.name}:`); copyToClipboard(`:${props.emoji.name}:`);
os.success();
}, },
}, { }, {
text: i18n.ts.info, text: i18n.ts.info,

View file

@ -129,7 +129,6 @@ function copyLink() {
if (!flash.value) return; if (!flash.value) return;
copyToClipboard(`${url}/play/${flash.value.id}`); copyToClipboard(`${url}/play/${flash.value.id}`);
os.success();
} }
function shareWithNavigator() { function shareWithNavigator() {

View file

@ -111,7 +111,6 @@ function fetchPost() {
function copyLink() { function copyLink() {
copyToClipboard(`${url}/gallery/${post.value.id}`); copyToClipboard(`${url}/gallery/${post.value.id}`);
os.success();
} }
function share() { function share() {

View file

@ -190,7 +190,6 @@ function copyLink() {
if (!page.value) return; if (!page.value) return;
copyToClipboard(`${url}/@${page.value.user.username}/pages/${page.value.name}`); copyToClipboard(`${url}/@${page.value.user.username}/pages/${page.value.name}`);
os.success();
} }
function shareWithNote() { function shareWithNote() {

View file

@ -33,12 +33,12 @@ SPDX-License-Identifier: AGPL-3.0-only
<script lang="ts" setup> <script lang="ts" setup>
import { computed, ref } from 'vue'; import { computed, ref } from 'vue';
import JSON5 from 'json5'; import JSON5 from 'json5';
import type { Theme } from '@/theme.js';
import MkTextarea from '@/components/MkTextarea.vue'; import MkTextarea from '@/components/MkTextarea.vue';
import MkSelect from '@/components/MkSelect.vue'; import MkSelect from '@/components/MkSelect.vue';
import MkInput from '@/components/MkInput.vue'; import MkInput from '@/components/MkInput.vue';
import MkButton from '@/components/MkButton.vue'; import MkButton from '@/components/MkButton.vue';
import { getBuiltinThemesRef } from '@/theme.js'; import { getBuiltinThemesRef } from '@/theme.js';
import type { Theme } from '@/theme.js';
import { copyToClipboard } from '@/utility/copy-to-clipboard.js'; import { copyToClipboard } from '@/utility/copy-to-clipboard.js';
import * as os from '@/os.js'; import * as os from '@/os.js';
import { getThemes, removeTheme } from '@/theme-store.js'; import { getThemes, removeTheme } from '@/theme-store.js';
@ -63,7 +63,6 @@ const selectedThemeCode = computed(() => {
function copyThemeCode() { function copyThemeCode() {
copyToClipboard(selectedThemeCode.value); copyToClipboard(selectedThemeCode.value);
os.success();
} }
function uninstall() { function uninstall() {

View file

@ -3,9 +3,15 @@
* SPDX-License-Identifier: AGPL-3.0-only * SPDX-License-Identifier: AGPL-3.0-only
*/ */
import * as os from '@/os.js';
import { i18n } from '@/i18n.js';
/** /**
* Clipboardに値をコピー(TODO: 文字列以外も対応) * Clipboardに値をコピー(TODO: 文字列以外も対応)
*/ */
export function copyToClipboard(input: string | null) { export function copyToClipboard(input: string | null) {
if (input) navigator.clipboard.writeText(input); if (input) {
navigator.clipboard.writeText(input);
os.toast(i18n.ts.copiedToClipboard);
}
}; };

View file

@ -65,7 +65,6 @@ function toggleSensitive(file: Misskey.entities.DriveFile) {
function copyUrl(file: Misskey.entities.DriveFile) { function copyUrl(file: Misskey.entities.DriveFile) {
copyToClipboard(file.url); copyToClipboard(file.url);
os.success();
} }
/* /*

View file

@ -4,11 +4,11 @@
*/ */
import { defineAsyncComponent } from 'vue'; import { defineAsyncComponent } from 'vue';
import { v4 as uuid } from 'uuid'; import { v4 as uuid } from 'uuid';
import type { EmbedParams, EmbeddableEntity } from '@@/js/embed-page.js';
import { url } from '@@/js/config.js'; import { url } from '@@/js/config.js';
import { defaultEmbedParams, embedRouteWithScrollbar } from '@@/js/embed-page.js';
import type { EmbedParams, EmbeddableEntity } from '@@/js/embed-page.js';
import * as os from '@/os.js'; import * as os from '@/os.js';
import { copyToClipboard } from '@/utility/copy-to-clipboard.js'; import { copyToClipboard } from '@/utility/copy-to-clipboard.js';
import { defaultEmbedParams, embedRouteWithScrollbar } from '@@/js/embed-page.js';
const MOBILE_THRESHOLD = 500; const MOBILE_THRESHOLD = 500;
@ -74,7 +74,6 @@ export function genEmbedCode(entity: EmbeddableEntity, id: string, params?: Embe
// PCじゃない場合はコードカスタマイズ画面を出さずにそのままコピー // PCじゃない場合はコードカスタマイズ画面を出さずにそのままコピー
if (window.innerWidth < MOBILE_THRESHOLD) { if (window.innerWidth < MOBILE_THRESHOLD) {
copyToClipboard(getEmbedCode(`/embed/${entity}/${id}`, _params)); copyToClipboard(getEmbedCode(`/embed/${entity}/${id}`, _params));
os.success();
} else { } else {
const { dispose } = os.popup(defineAsyncComponent(() => import('@/components/MkEmbedCodeGenDialog.vue')), { const { dispose } = os.popup(defineAsyncComponent(() => import('@/components/MkEmbedCodeGenDialog.vue')), {
entity, entity,

View file

@ -157,7 +157,6 @@ export function getCopyNoteLinkMenu(note: Misskey.entities.Note, text: string):
text, text,
action: (): void => { action: (): void => {
copyToClipboard(`${url}/notes/${note.id}`); copyToClipboard(`${url}/notes/${note.id}`);
os.success();
}, },
}; };
} }
@ -237,7 +236,6 @@ export function getNoteMenu(props: {
function copyContent(): void { function copyContent(): void {
copyToClipboard(appearNote.text); copyToClipboard(appearNote.text);
os.success();
} }
function togglePin(pin: boolean): void { function togglePin(pin: boolean): void {
@ -324,7 +322,6 @@ export function getNoteMenu(props: {
text: i18n.ts.copyRemoteLink, text: i18n.ts.copyRemoteLink,
action: () => { action: () => {
copyToClipboard(appearNote.url ?? appearNote.uri); copyToClipboard(appearNote.url ?? appearNote.uri);
os.success();
}, },
}, { }, {
icon: 'ti ti-external-link', icon: 'ti ti-external-link',
@ -483,7 +480,6 @@ export function getNoteMenu(props: {
text: i18n.ts.copyRemoteLink, text: i18n.ts.copyRemoteLink,
action: () => { action: () => {
copyToClipboard(appearNote.url ?? appearNote.uri); copyToClipboard(appearNote.url ?? appearNote.uri);
os.success();
}, },
}, { }, {
icon: 'ti ti-external-link', icon: 'ti ti-external-link',
@ -516,7 +512,6 @@ export function getNoteMenu(props: {
text: i18n.ts.copyNoteId, text: i18n.ts.copyNoteId,
action: () => { action: () => {
copyToClipboard(appearNote.id); copyToClipboard(appearNote.id);
os.success();
}, },
}); });
} }