1
0
mirror of https://github.com/misskey-dev/misskey.git synced 2026-05-21 21:35:28 +02:00

refactor(frontend): ID生成処理を統一

This commit is contained in:
syuilo
2025-06-03 07:37:08 +09:00
parent 3bc81522c6
commit 93d17aff6c
16 changed files with 35 additions and 20 deletions

View File

@@ -97,6 +97,7 @@ import { i18n } from '@/i18n.js';
import { definePage } from '@/page.js';
import MkFolder from '@/components/MkFolder.vue';
import MkTextarea from '@/components/MkTextarea.vue';
import { genId } from '@/utility/id.js';
const announcementsStatus = ref<'active' | 'archived'>('active');
@@ -117,7 +118,7 @@ watch(announcementsStatus, (to) => {
function add() {
announcements.value.unshift({
_id: Math.random().toString(36),
_id: genId(),
id: null,
title: 'New announcement',
text: '',

View File

@@ -57,6 +57,7 @@ import { misskeyApi } from '@/utility/misskey-api.js';
import { useStream } from '@/stream.js';
import { i18n } from '@/i18n.js';
import MkFolder from '@/components/MkFolder.vue';
import { genId } from '@/utility/id.js';
const connection = markRaw(useStream().useChannel('queueStats'));
@@ -113,7 +114,7 @@ onMounted(() => {
connection.on('stats', onStats);
connection.on('statsLog', onStatsLog);
connection.send('requestLog', {
id: Math.random().toString().substring(2, 10),
id: genId(),
length: 200,
});
});

View File

@@ -41,6 +41,7 @@ import XChart from './overview.queue.chart.vue';
import type { ApQueueDomain } from '@/pages/admin/queue.vue';
import number from '@/filters/number.js';
import { useStream } from '@/stream.js';
import { genId } from '@/utility/id.js';
const connection = markRaw(useStream().useChannel('queueStats'));
@@ -92,7 +93,7 @@ onMounted(() => {
connection.on('stats', onStats);
connection.on('statsLog', onStatsLog);
connection.send('requestLog', {
id: Math.random().toString().substring(2, 10),
id: genId(),
length: 100,
});
});

View File

@@ -84,6 +84,7 @@ import { useStream } from '@/stream.js';
import { i18n } from '@/i18n.js';
import { definePage } from '@/page.js';
import MkFoldableSection from '@/components/MkFoldableSection.vue';
import { genId } from '@/utility/id.js';
const rootEl = useTemplateRef('rootEl');
const serverInfo = ref<Misskey.entities.ServerInfoResponse | null>(null);
@@ -170,7 +171,7 @@ onMounted(async () => {
nextTick(() => {
queueStatsConnection.send('requestLog', {
id: Math.random().toString().substring(2, 10),
id: genId(),
length: 100,
});
});

View File

@@ -158,6 +158,7 @@ import { userPage } from '@/filters/user.js';
import * as sound from '@/utility/sound.js';
import * as os from '@/os.js';
import { confetti } from '@/utility/confetti.js';
import { genId } from '@/utility/id.js';
const $i = ensureSignin();
@@ -273,7 +274,7 @@ function putStone(pos: number) {
playbackRate: 1,
});
const id = Math.random().toString(36).slice(2);
const id = genId();
props.connection!.send('putStone', {
pos: pos,
id,

View File

@@ -70,11 +70,12 @@ import { definePage } from '@/page.js';
import { prefer } from '@/preferences.js';
import { PREF_DEF } from '@/preferences/def.js';
import { getInitialPrefValue } from '@/preferences/manager.js';
import { genId } from '@/utility/id.js';
const Sortable = defineAsyncComponent(() => import('vuedraggable').then(x => x.default));
const items = ref(prefer.s.menu.map(x => ({
id: Math.random().toString(),
id: genId(),
type: x,
})));
@@ -93,7 +94,7 @@ async function addItem() {
});
if (canceled) return;
items.value = [...items.value, {
id: Math.random().toString(),
id: genId(),
type: item,
}];
}
@@ -108,7 +109,7 @@ async function save() {
function reset() {
items.value = getInitialPrefValue('menu').map(x => ({
id: Math.random().toString(),
id: genId(),
type: x,
}));
}

View File

@@ -796,6 +796,7 @@ import { globalEvents } from '@/events.js';
import { claimAchievement } from '@/utility/achievements.js';
import { instance } from '@/instance.js';
import { ensureSignin } from '@/i.js';
import { genId } from '@/utility/id.js';
const $i = ensureSignin();
@@ -1009,7 +1010,7 @@ let smashTimer: number | null = null;
function testNotification(): void {
const notification: Misskey.entities.Notification = {
id: Math.random().toString(),
id: genId(),
createdAt: new Date().toUTCString(),
isRead: false,
type: 'test',

View File

@@ -171,6 +171,7 @@ import { claimAchievement } from '@/utility/achievements.js';
import { store } from '@/store.js';
import MkInfo from '@/components/MkInfo.vue';
import MkTextarea from '@/components/MkTextarea.vue';
import { genId } from '@/utility/id.js';
const $i = ensureSignin();
@@ -199,12 +200,12 @@ watch(() => profile, () => {
deep: true,
});
const fields = ref($i.fields.map(field => ({ id: Math.random().toString(), name: field.name, value: field.value })) ?? []);
const fields = ref($i.fields.map(field => ({ id: genId(), name: field.name, value: field.value })) ?? []);
const fieldEditMode = ref(false);
function addField() {
fields.value.push({
id: Math.random().toString(),
id: genId(),
name: '',
value: '',
});