forked from mirrors/misskey
enhance(frontend): typed nirax (#16309)
* enhance(frontend): typed nirax * migrate router.replace * fix
This commit is contained in:
@@ -72,12 +72,20 @@ async function save() {
|
||||
roleId: role.value.id,
|
||||
...data.value,
|
||||
});
|
||||
router.push('/admin/roles/' + role.value.id);
|
||||
router.push('/admin/roles/:id', {
|
||||
params: {
|
||||
id: role.value.id,
|
||||
}
|
||||
});
|
||||
} else {
|
||||
const created = await os.apiWithDialog('admin/roles/create', {
|
||||
...data.value,
|
||||
});
|
||||
router.push('/admin/roles/' + created.id);
|
||||
router.push('/admin/roles/:id', {
|
||||
params: {
|
||||
id: created.id,
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -88,7 +88,11 @@ const role = reactive(await misskeyApi('admin/roles/show', {
|
||||
}));
|
||||
|
||||
function edit() {
|
||||
router.push('/admin/roles/' + role.id + '/edit');
|
||||
router.push('/admin/roles/:id/edit', {
|
||||
params: {
|
||||
id: role.id,
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
async function del() {
|
||||
|
||||
@@ -47,7 +47,11 @@ async function timetravel() {
|
||||
}
|
||||
|
||||
function settings() {
|
||||
router.push(`/my/antennas/${props.antennaId}`);
|
||||
router.push('/my/antennas/:antennaId', {
|
||||
params: {
|
||||
antennaId: props.antennaId,
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function focus() {
|
||||
|
||||
@@ -165,7 +165,11 @@ function save() {
|
||||
os.apiWithDialog('channels/update', params);
|
||||
} else {
|
||||
os.apiWithDialog('channels/create', params).then(created => {
|
||||
router.push(`/channels/${created.id}`);
|
||||
router.push('/channels/:channelId', {
|
||||
params: {
|
||||
channelId: created.id,
|
||||
},
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -147,7 +147,11 @@ watch(() => props.channelId, async () => {
|
||||
}, { immediate: true });
|
||||
|
||||
function edit() {
|
||||
router.push(`/channels/${channel.value?.id}/edit`);
|
||||
router.push('/channels/:channelId/edit', {
|
||||
params: {
|
||||
channelId: props.channelId,
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function openPostForm() {
|
||||
|
||||
@@ -86,7 +86,11 @@ function start(ev: MouseEvent) {
|
||||
async function startUser() {
|
||||
// TODO: localOnly は連合に対応したら消す
|
||||
os.selectUser({ localOnly: true }).then(user => {
|
||||
router.push(`/chat/user/${user.id}`);
|
||||
router.push('/chat/user/:userId', {
|
||||
params: {
|
||||
userId: user.id,
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
@@ -101,7 +105,11 @@ async function createRoom() {
|
||||
name: result,
|
||||
});
|
||||
|
||||
router.push(`/chat/room/${room.id}`);
|
||||
router.push('/chat/room/:roomId', {
|
||||
params: {
|
||||
roomId: room.id,
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
async function search() {
|
||||
|
||||
@@ -61,7 +61,11 @@ async function join(invitation: Misskey.entities.ChatRoomInvitation) {
|
||||
roomId: invitation.room.id,
|
||||
});
|
||||
|
||||
router.push(`/chat/room/${invitation.room.id}`);
|
||||
router.push('/chat/room/:roomId', {
|
||||
params: {
|
||||
roomId: invitation.room.id,
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
async function ignore(invitation: Misskey.entities.ChatRoomInvitation) {
|
||||
|
||||
@@ -429,7 +429,11 @@ async function save() {
|
||||
script: script.value,
|
||||
visibility: visibility.value,
|
||||
});
|
||||
router.push('/play/' + created.id + '/edit');
|
||||
router.push('/play/:id/edit', {
|
||||
params: {
|
||||
id: created.id,
|
||||
},
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -85,7 +85,11 @@ async function save() {
|
||||
fileIds: files.value.map(file => file.id),
|
||||
isSensitive: isSensitive.value,
|
||||
});
|
||||
router.push(`/gallery/${props.postId}`);
|
||||
router.push('/gallery/:postId', {
|
||||
params: {
|
||||
postId: props.postId,
|
||||
}
|
||||
});
|
||||
} else {
|
||||
const created = await os.apiWithDialog('gallery/posts/create', {
|
||||
title: title.value,
|
||||
@@ -93,7 +97,11 @@ async function save() {
|
||||
fileIds: files.value.map(file => file.id),
|
||||
isSensitive: isSensitive.value,
|
||||
});
|
||||
router.push(`/gallery/${created.id}`);
|
||||
router.push('/gallery/:postId', {
|
||||
params: {
|
||||
postId: created.id,
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -150,7 +150,11 @@ async function unlike() {
|
||||
}
|
||||
|
||||
function edit() {
|
||||
router.push(`/gallery/${post.value.id}/edit`);
|
||||
router.push('/gallery/:postId/edit', {
|
||||
params: {
|
||||
postId: props.postId,
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
async function reportAbuse() {
|
||||
|
||||
@@ -45,11 +45,20 @@ function fetch() {
|
||||
promise = misskeyApi('ap/show', {
|
||||
uri,
|
||||
});
|
||||
|
||||
promise.then(res => {
|
||||
if (res.type === 'User') {
|
||||
mainRouter.replace(res.object.host ? `/@${res.object.username}@${res.object.host}` : `/@${res.object.username}`);
|
||||
mainRouter.replace('/@:acct/:page?', {
|
||||
params: {
|
||||
acct: res.host != null ? `${res.object.username}@${res.object.host}` : res.object.username,
|
||||
}
|
||||
});
|
||||
} else if (res.type === 'Note') {
|
||||
mainRouter.replace(`/notes/${res.object.id}`);
|
||||
mainRouter.replace('/notes/:noteId/:initialTab?', {
|
||||
params: {
|
||||
noteId: res.object.id,
|
||||
}
|
||||
});
|
||||
} else {
|
||||
os.alert({
|
||||
type: 'error',
|
||||
@@ -63,7 +72,11 @@ function fetch() {
|
||||
}
|
||||
promise = misskeyApi('users/show', Misskey.acct.parse(uri));
|
||||
promise.then(user => {
|
||||
mainRouter.replace(user.host ? `/@${user.username}@${user.host}` : `/@${user.username}`);
|
||||
mainRouter.replace('/@:acct/:page?', {
|
||||
params: {
|
||||
acct: user.host != null ? `${user.username}@${user.host}` : user.username,
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -154,7 +154,11 @@ async function save() {
|
||||
|
||||
pageId.value = created.id;
|
||||
currentName.value = name.value.trim();
|
||||
mainRouter.replace(`/pages/edit/${pageId.value}`);
|
||||
mainRouter.replace('/pages/edit/:initPageId', {
|
||||
params: {
|
||||
initPageId: pageId.value,
|
||||
},
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -189,7 +193,11 @@ async function duplicate() {
|
||||
pageId.value = created.id;
|
||||
currentName.value = name.value.trim();
|
||||
|
||||
mainRouter.push(`/pages/edit/${pageId.value}`);
|
||||
mainRouter.push('/pages/edit/:initPageId', {
|
||||
params: {
|
||||
initPageId: pageId.value,
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
async function add() {
|
||||
|
||||
@@ -267,7 +267,11 @@ function showMenu(ev: MouseEvent) {
|
||||
menuItems.push({
|
||||
icon: 'ti ti-pencil',
|
||||
text: i18n.ts.edit,
|
||||
action: () => router.push(`/pages/edit/${page.value.id}`),
|
||||
action: () => router.push('/pages/edit/:initPageId', {
|
||||
params: {
|
||||
initPageId: page.value!.id,
|
||||
},
|
||||
}),
|
||||
});
|
||||
|
||||
if ($i.pinnedPageId === page.value.id) {
|
||||
|
||||
@@ -168,7 +168,11 @@ function startGame(game: Misskey.entities.ReversiGameDetailed) {
|
||||
playbackRate: 1,
|
||||
});
|
||||
|
||||
router.push(`/reversi/g/${game.id}`);
|
||||
router.push('/reversi/g/:gameId', {
|
||||
params: {
|
||||
gameId: game.id,
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
async function matchHeatbeat() {
|
||||
|
||||
@@ -264,10 +264,18 @@ async function search() {
|
||||
const res = await apLookup(searchParams.value.query);
|
||||
|
||||
if (res.type === 'User') {
|
||||
router.push(`/@${res.object.username}@${res.object.host}`);
|
||||
router.push('/@:acct/:page?', {
|
||||
params: {
|
||||
acct: `${res.object.username}@${res.object.host}`,
|
||||
},
|
||||
});
|
||||
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
|
||||
} else if (res.type === 'Note') {
|
||||
router.push(`/notes/${res.object.id}`);
|
||||
router.push('/notes/:noteId/:initialTab?', {
|
||||
params: {
|
||||
noteId: res.object.id,
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
return;
|
||||
@@ -282,7 +290,7 @@ async function search() {
|
||||
text: i18n.ts.lookupConfirm,
|
||||
});
|
||||
if (!confirm.canceled) {
|
||||
router.push(`/${searchParams.value.query}`);
|
||||
router.pushByPath(`/${searchParams.value.query}`);
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -293,7 +301,11 @@ async function search() {
|
||||
text: i18n.ts.openTagPageConfirm,
|
||||
});
|
||||
if (!confirm.canceled) {
|
||||
router.push(`/tags/${encodeURIComponent(searchParams.value.query.substring(1))}`);
|
||||
router.push('/tags/:tag', {
|
||||
params: {
|
||||
tag: searchParams.value.query.substring(1),
|
||||
},
|
||||
});
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -77,10 +77,18 @@ async function search() {
|
||||
const res = await promise;
|
||||
|
||||
if (res.type === 'User') {
|
||||
router.push(`/@${res.object.username}@${res.object.host}`);
|
||||
router.push('/@:acct/:page?', {
|
||||
params: {
|
||||
acct: `${res.object.username}@${res.object.host}`,
|
||||
},
|
||||
});
|
||||
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
|
||||
} else if (res.type === 'Note') {
|
||||
router.push(`/notes/${res.object.id}`);
|
||||
router.push('/notes/:noteId/:initialTab?', {
|
||||
params: {
|
||||
noteId: res.object.id,
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
return;
|
||||
@@ -95,7 +103,7 @@ async function search() {
|
||||
text: i18n.ts.lookupConfirm,
|
||||
});
|
||||
if (!confirm.canceled) {
|
||||
router.push(`/${query}`);
|
||||
router.pushByPath(`/${query}`);
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -106,7 +114,11 @@ async function search() {
|
||||
text: i18n.ts.openTagPageConfirm,
|
||||
});
|
||||
if (!confirm.canceled) {
|
||||
router.push(`/user-tags/${encodeURIComponent(query.substring(1))}`);
|
||||
router.push('/user-tags/:tag', {
|
||||
params: {
|
||||
tag: query.substring(1),
|
||||
},
|
||||
});
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -135,7 +135,7 @@ async function del(): Promise<void> {
|
||||
webhookId: props.webhookId,
|
||||
});
|
||||
|
||||
router.push('/settings/webhook');
|
||||
router.push('/settings/connect');
|
||||
}
|
||||
|
||||
async function test(type: Misskey.entities.UserWebhook['on'][number]): Promise<void> {
|
||||
|
||||
@@ -42,7 +42,11 @@ watch(() => props.listId, async () => {
|
||||
}, { immediate: true });
|
||||
|
||||
function settings() {
|
||||
router.push(`/my/lists/${props.listId}`);
|
||||
router.push('/my/lists/:listId', {
|
||||
params: {
|
||||
listId: props.listId,
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
const headerActions = computed(() => list.value ? [{
|
||||
|
||||
Reference in New Issue
Block a user