refactor(frontend): os.tsに引き込んだscripts/api.tsの再exportをやめる (#12694)

* refactor(frontend): os.tsに引き込んだscripts/api.tsの再exportをやめる

* fix

* fix

* renate to "misskeyApi"

* rename file
This commit is contained in:
おさむのひと 2024-01-04 18:32:46 +09:00 committed by GitHub
parent ea41cc6ec0
commit fa9c4a19b9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
191 changed files with 581 additions and 468 deletions

View file

@ -11,7 +11,8 @@ import { miLocalStorage } from '@/local-storage.js';
import { MenuButton } from '@/types/menu.js'; import { MenuButton } from '@/types/menu.js';
import { del, get, set } from '@/scripts/idb-proxy.js'; import { del, get, set } from '@/scripts/idb-proxy.js';
import { apiUrl } from '@/config.js'; import { apiUrl } from '@/config.js';
import { waiting, api, popup, popupMenu, success, alert } from '@/os.js'; import { waiting, popup, popupMenu, success, alert } from '@/os.js';
import { misskeyApi } from '@/scripts/misskey-api.js';
import { unisonReload, reloadChannel } from '@/scripts/unison-reload.js'; import { unisonReload, reloadChannel } from '@/scripts/unison-reload.js';
// TODO: 他のタブと永続化されたstateを同期 // TODO: 他のタブと永続化されたstateを同期
@ -251,7 +252,7 @@ export async function openAccountMenu(opts: {
} }
const storedAccounts = await getAccounts().then(accounts => accounts.filter(x => x.id !== $i.id)); const storedAccounts = await getAccounts().then(accounts => accounts.filter(x => x.id !== $i.id));
const accountsPromise = api('users/show', { userIds: storedAccounts.map(x => x.id) }); const accountsPromise = misskeyApi('users/show', { userIds: storedAccounts.map(x => x.id) });
function createItem(account: Misskey.entities.UserDetailed) { function createItem(account: Misskey.entities.UserDetailed) {
return { return {

View file

@ -5,9 +5,9 @@
import * as Misskey from 'misskey-js'; import * as Misskey from 'misskey-js';
import { Cache } from '@/scripts/cache.js'; import { Cache } from '@/scripts/cache.js';
import { api } from '@/os.js'; import { misskeyApi } from '@/scripts/misskey-api.js';
export const clipsCache = new Cache<Misskey.entities.Clip[]>(1000 * 60 * 30, () => api('clips/list')); export const clipsCache = new Cache<Misskey.entities.Clip[]>(1000 * 60 * 30, () => misskeyApi('clips/list'));
export const rolesCache = new Cache(1000 * 60 * 30, () => api('admin/roles/list')); export const rolesCache = new Cache(1000 * 60 * 30, () => misskeyApi('admin/roles/list'));
export const userListsCache = new Cache<Misskey.entities.UserList[]>(1000 * 60 * 30, () => api('users/lists/list')); export const userListsCache = new Cache<Misskey.entities.UserList[]>(1000 * 60 * 30, () => misskeyApi('users/lists/list'));
export const antennasCache = new Cache<Misskey.entities.Antenna[]>(1000 * 60 * 30, () => api('antennas/list')); export const antennasCache = new Cache<Misskey.entities.Antenna[]>(1000 * 60 * 30, () => misskeyApi('antennas/list'));

View file

@ -17,7 +17,7 @@ import * as Misskey from 'misskey-js';
import MkMention from './MkMention.vue'; import MkMention from './MkMention.vue';
import { i18n } from '@/i18n.js'; import { i18n } from '@/i18n.js';
import { host as localHost } from '@/config.js'; import { host as localHost } from '@/config.js';
import { api } from '@/os.js'; import { misskeyApi } from '@/scripts/misskey-api.js';
const user = ref<Misskey.entities.UserLite>(); const user = ref<Misskey.entities.UserLite>();
@ -25,7 +25,7 @@ const props = defineProps<{
movedTo: string; // user id movedTo: string; // user id
}>(); }>();
api('users/show', { userId: props.movedTo }).then(u => user.value = u); misskeyApi('users/show', { userId: props.movedTo }).then(u => user.value = u);
</script> </script>
<style lang="scss" module> <style lang="scss" module>

View file

@ -55,6 +55,7 @@ SPDX-License-Identifier: AGPL-3.0-only
import * as Misskey from 'misskey-js'; import * as Misskey from 'misskey-js';
import { onMounted, ref, computed } from 'vue'; import { onMounted, ref, computed } from 'vue';
import * as os from '@/os.js'; import * as os from '@/os.js';
import { misskeyApi } from '@/scripts/misskey-api.js';
import { i18n } from '@/i18n.js'; import { i18n } from '@/i18n.js';
import { ACHIEVEMENT_TYPES, ACHIEVEMENT_BADGES, claimAchievement } from '@/scripts/achievements.js'; import { ACHIEVEMENT_TYPES, ACHIEVEMENT_BADGES, claimAchievement } from '@/scripts/achievements.js';
@ -71,7 +72,7 @@ const achievements = ref<Misskey.entities.UsersAchievementsResponse | null>(null
const lockedAchievements = computed(() => ACHIEVEMENT_TYPES.filter(x => !(achievements.value ?? []).some(a => a.name === x))); const lockedAchievements = computed(() => ACHIEVEMENT_TYPES.filter(x => !(achievements.value ?? []).some(a => a.name === x)));
function fetch() { function fetch() {
os.api('users/achievements', { userId: props.user.id }).then(res => { misskeyApi('users/achievements', { userId: props.user.id }).then(res => {
achievements.value = []; achievements.value = [];
for (const t of ACHIEVEMENT_TYPES) { for (const t of ACHIEVEMENT_TYPES) {
const a = res.find(x => x.name === t); const a = res.find(x => x.name === t);

View file

@ -25,6 +25,7 @@ SPDX-License-Identifier: AGPL-3.0-only
import { onMounted, shallowRef } from 'vue'; import { onMounted, shallowRef } from 'vue';
import * as Misskey from 'misskey-js'; import * as Misskey from 'misskey-js';
import * as os from '@/os.js'; import * as os from '@/os.js';
import { misskeyApi } from '@/scripts/misskey-api.js';
import MkModal from '@/components/MkModal.vue'; import MkModal from '@/components/MkModal.vue';
import MkButton from '@/components/MkButton.vue'; import MkButton from '@/components/MkButton.vue';
import { i18n } from '@/i18n.js'; import { i18n } from '@/i18n.js';
@ -49,7 +50,7 @@ async function ok() {
} }
modal.value.close(); modal.value.close();
os.api('i/read-announcement', { announcementId: props.announcement.id }); misskeyApi('i/read-announcement', { announcementId: props.announcement.id });
updateAccount({ updateAccount({
unreadAnnouncements: $i!.unreadAnnouncements.filter(a => a.id !== props.announcement.id), unreadAnnouncements: $i!.unreadAnnouncements.filter(a => a.id !== props.announcement.id),
}); });

View file

@ -45,6 +45,7 @@ import contains from '@/scripts/contains.js';
import { char2twemojiFilePath, char2fluentEmojiFilePath } from '@/scripts/emoji-base.js'; import { char2twemojiFilePath, char2fluentEmojiFilePath } from '@/scripts/emoji-base.js';
import { acct } from '@/filters/user.js'; import { acct } from '@/filters/user.js';
import * as os from '@/os.js'; import * as os from '@/os.js';
import { misskeyApi } from '@/scripts/misskey-api.js';
import { defaultStore } from '@/store.js'; import { defaultStore } from '@/store.js';
import { emojilist, getEmojiName } from '@/scripts/emojilist.js'; import { emojilist, getEmojiName } from '@/scripts/emojilist.js';
import { i18n } from '@/i18n.js'; import { i18n } from '@/i18n.js';
@ -201,7 +202,7 @@ function exec() {
users.value = JSON.parse(cache); users.value = JSON.parse(cache);
fetching.value = false; fetching.value = false;
} else { } else {
os.api('users/search-by-username-and-host', { misskeyApi('users/search-by-username-and-host', {
username: props.q, username: props.q,
limit: 10, limit: 10,
detail: false, detail: false,
@ -224,7 +225,7 @@ function exec() {
hashtags.value = hashtags; hashtags.value = hashtags;
fetching.value = false; fetching.value = false;
} else { } else {
os.api('hashtags/search', { misskeyApi('hashtags/search', {
query: props.q, query: props.q,
limit: 30, limit: 30,
}).then(searchedHashtags => { }).then(searchedHashtags => {

View file

@ -15,7 +15,7 @@ SPDX-License-Identifier: AGPL-3.0-only
<script lang="ts" setup> <script lang="ts" setup>
import { onMounted, ref } from 'vue'; import { onMounted, ref } from 'vue';
import * as Misskey from 'misskey-js'; import * as Misskey from 'misskey-js';
import * as os from '@/os.js'; import { misskeyApi } from '@/scripts/misskey-api.js';
const props = withDefaults(defineProps<{ const props = withDefaults(defineProps<{
userIds: string[]; userIds: string[];
@ -27,7 +27,7 @@ const props = withDefaults(defineProps<{
const users = ref<Misskey.entities.UserLite[]>([]); const users = ref<Misskey.entities.UserLite[]>([]);
onMounted(async () => { onMounted(async () => {
users.value = await os.api('users/show', { users.value = await misskeyApi('users/show', {
userIds: props.userIds, userIds: props.userIds,
}) as unknown as Misskey.entities.UserLite[]; }) as unknown as Misskey.entities.UserLite[];
}); });

View file

@ -26,7 +26,7 @@ SPDX-License-Identifier: AGPL-3.0-only
<script lang="ts" setup> <script lang="ts" setup>
import { ref } from 'vue'; import { ref } from 'vue';
import * as os from '@/os.js'; import { misskeyApi } from '@/scripts/misskey-api.js';
import { i18n } from '@/i18n.js'; import { i18n } from '@/i18n.js';
const props = withDefaults(defineProps<{ const props = withDefaults(defineProps<{
@ -44,12 +44,12 @@ async function onClick() {
try { try {
if (isFollowing.value) { if (isFollowing.value) {
await os.api('channels/unfollow', { await misskeyApi('channels/unfollow', {
channelId: props.channel.id, channelId: props.channel.id,
}); });
isFollowing.value = false; isFollowing.value = false;
} else { } else {
await os.api('channels/follow', { await misskeyApi('channels/follow', {
channelId: props.channel.id, channelId: props.channel.id,
}); });
isFollowing.value = true; isFollowing.value = true;

View file

@ -22,7 +22,7 @@ SPDX-License-Identifier: AGPL-3.0-only
import { onMounted, ref, shallowRef, watch, PropType } from 'vue'; import { onMounted, ref, shallowRef, watch, PropType } from 'vue';
import { Chart } from 'chart.js'; import { Chart } from 'chart.js';
import gradient from 'chartjs-plugin-gradient'; import gradient from 'chartjs-plugin-gradient';
import * as os from '@/os.js'; import { misskeyApiGet } from '@/scripts/misskey-api.js';
import { defaultStore } from '@/store.js'; import { defaultStore } from '@/store.js';
import { useChartTooltip } from '@/scripts/use-chart-tooltip.js'; import { useChartTooltip } from '@/scripts/use-chart-tooltip.js';
import { chartVLine } from '@/scripts/chart-vline.js'; import { chartVLine } from '@/scripts/chart-vline.js';
@ -277,7 +277,7 @@ const exportData = () => {
}; };
const fetchFederationChart = async (): Promise<typeof chartData> => { const fetchFederationChart = async (): Promise<typeof chartData> => {
const raw = await os.apiGet('charts/federation', { limit: props.limit, span: props.span }); const raw = await misskeyApiGet('charts/federation', { limit: props.limit, span: props.span });
return { return {
series: [{ series: [{
name: 'Received', name: 'Received',
@ -327,7 +327,7 @@ const fetchFederationChart = async (): Promise<typeof chartData> => {
}; };
const fetchApRequestChart = async (): Promise<typeof chartData> => { const fetchApRequestChart = async (): Promise<typeof chartData> => {
const raw = await os.apiGet('charts/ap-request', { limit: props.limit, span: props.span }); const raw = await misskeyApiGet('charts/ap-request', { limit: props.limit, span: props.span });
return { return {
series: [{ series: [{
name: 'In', name: 'In',
@ -349,7 +349,7 @@ const fetchApRequestChart = async (): Promise<typeof chartData> => {
}; };
const fetchNotesChart = async (type: string): Promise<typeof chartData> => { const fetchNotesChart = async (type: string): Promise<typeof chartData> => {
const raw = await os.apiGet('charts/notes', { limit: props.limit, span: props.span }); const raw = await misskeyApiGet('charts/notes', { limit: props.limit, span: props.span });
return { return {
series: [{ series: [{
name: 'All', name: 'All',
@ -396,7 +396,7 @@ const fetchNotesChart = async (type: string): Promise<typeof chartData> => {
}; };
const fetchNotesTotalChart = async (): Promise<typeof chartData> => { const fetchNotesTotalChart = async (): Promise<typeof chartData> => {
const raw = await os.apiGet('charts/notes', { limit: props.limit, span: props.span }); const raw = await misskeyApiGet('charts/notes', { limit: props.limit, span: props.span });
return { return {
series: [{ series: [{
name: 'Combined', name: 'Combined',
@ -415,7 +415,7 @@ const fetchNotesTotalChart = async (): Promise<typeof chartData> => {
}; };
const fetchUsersChart = async (total: boolean): Promise<typeof chartData> => { const fetchUsersChart = async (total: boolean): Promise<typeof chartData> => {
const raw = await os.apiGet('charts/users', { limit: props.limit, span: props.span }); const raw = await misskeyApiGet('charts/users', { limit: props.limit, span: props.span });
return { return {
series: [{ series: [{
name: 'Combined', name: 'Combined',
@ -443,7 +443,7 @@ const fetchUsersChart = async (total: boolean): Promise<typeof chartData> => {
}; };
const fetchActiveUsersChart = async (): Promise<typeof chartData> => { const fetchActiveUsersChart = async (): Promise<typeof chartData> => {
const raw = await os.apiGet('charts/active-users', { limit: props.limit, span: props.span }); const raw = await misskeyApiGet('charts/active-users', { limit: props.limit, span: props.span });
return { return {
series: [{ series: [{
name: 'Read & Write', name: 'Read & Write',
@ -495,7 +495,7 @@ const fetchActiveUsersChart = async (): Promise<typeof chartData> => {
}; };
const fetchDriveChart = async (): Promise<typeof chartData> => { const fetchDriveChart = async (): Promise<typeof chartData> => {
const raw = await os.apiGet('charts/drive', { limit: props.limit, span: props.span }); const raw = await misskeyApiGet('charts/drive', { limit: props.limit, span: props.span });
return { return {
bytes: true, bytes: true,
series: [{ series: [{
@ -531,7 +531,7 @@ const fetchDriveChart = async (): Promise<typeof chartData> => {
}; };
const fetchDriveFilesChart = async (): Promise<typeof chartData> => { const fetchDriveFilesChart = async (): Promise<typeof chartData> => {
const raw = await os.apiGet('charts/drive', { limit: props.limit, span: props.span }); const raw = await misskeyApiGet('charts/drive', { limit: props.limit, span: props.span });
return { return {
series: [{ series: [{
name: 'All', name: 'All',
@ -566,7 +566,7 @@ const fetchDriveFilesChart = async (): Promise<typeof chartData> => {
}; };
const fetchInstanceRequestsChart = async (): Promise<typeof chartData> => { const fetchInstanceRequestsChart = async (): Promise<typeof chartData> => {
const raw = await os.apiGet('charts/instance', { host: props.args.host, limit: props.limit, span: props.span }); const raw = await misskeyApiGet('charts/instance', { host: props.args.host, limit: props.limit, span: props.span });
return { return {
series: [{ series: [{
name: 'In', name: 'In',
@ -588,7 +588,7 @@ const fetchInstanceRequestsChart = async (): Promise<typeof chartData> => {
}; };
const fetchInstanceUsersChart = async (total: boolean): Promise<typeof chartData> => { const fetchInstanceUsersChart = async (total: boolean): Promise<typeof chartData> => {
const raw = await os.apiGet('charts/instance', { host: props.args.host, limit: props.limit, span: props.span }); const raw = await misskeyApiGet('charts/instance', { host: props.args.host, limit: props.limit, span: props.span });
return { return {
series: [{ series: [{
name: 'Users', name: 'Users',
@ -603,7 +603,7 @@ const fetchInstanceUsersChart = async (total: boolean): Promise<typeof chartData
}; };
const fetchInstanceNotesChart = async (total: boolean): Promise<typeof chartData> => { const fetchInstanceNotesChart = async (total: boolean): Promise<typeof chartData> => {
const raw = await os.apiGet('charts/instance', { host: props.args.host, limit: props.limit, span: props.span }); const raw = await misskeyApiGet('charts/instance', { host: props.args.host, limit: props.limit, span: props.span });
return { return {
series: [{ series: [{
name: 'Notes', name: 'Notes',
@ -618,7 +618,7 @@ const fetchInstanceNotesChart = async (total: boolean): Promise<typeof chartData
}; };
const fetchInstanceFfChart = async (total: boolean): Promise<typeof chartData> => { const fetchInstanceFfChart = async (total: boolean): Promise<typeof chartData> => {
const raw = await os.apiGet('charts/instance', { host: props.args.host, limit: props.limit, span: props.span }); const raw = await misskeyApiGet('charts/instance', { host: props.args.host, limit: props.limit, span: props.span });
return { return {
series: [{ series: [{
name: 'Following', name: 'Following',
@ -641,7 +641,7 @@ const fetchInstanceFfChart = async (total: boolean): Promise<typeof chartData> =
}; };
const fetchInstanceDriveUsageChart = async (total: boolean): Promise<typeof chartData> => { const fetchInstanceDriveUsageChart = async (total: boolean): Promise<typeof chartData> => {
const raw = await os.apiGet('charts/instance', { host: props.args.host, limit: props.limit, span: props.span }); const raw = await misskeyApiGet('charts/instance', { host: props.args.host, limit: props.limit, span: props.span });
return { return {
bytes: true, bytes: true,
series: [{ series: [{
@ -657,7 +657,7 @@ const fetchInstanceDriveUsageChart = async (total: boolean): Promise<typeof char
}; };
const fetchInstanceDriveFilesChart = async (total: boolean): Promise<typeof chartData> => { const fetchInstanceDriveFilesChart = async (total: boolean): Promise<typeof chartData> => {
const raw = await os.apiGet('charts/instance', { host: props.args.host, limit: props.limit, span: props.span }); const raw = await misskeyApiGet('charts/instance', { host: props.args.host, limit: props.limit, span: props.span });
return { return {
series: [{ series: [{
name: 'Drive files', name: 'Drive files',
@ -672,7 +672,7 @@ const fetchInstanceDriveFilesChart = async (total: boolean): Promise<typeof char
}; };
const fetchPerUserNotesChart = async (): Promise<typeof chartData> => { const fetchPerUserNotesChart = async (): Promise<typeof chartData> => {
const raw = await os.apiGet('charts/user/notes', { userId: props.args.user.id, limit: props.limit, span: props.span }); const raw = await misskeyApiGet('charts/user/notes', { userId: props.args.user.id, limit: props.limit, span: props.span });
return { return {
series: [...(props.args.withoutAll ? [] : [{ series: [...(props.args.withoutAll ? [] : [{
name: 'All', name: 'All',
@ -704,7 +704,7 @@ const fetchPerUserNotesChart = async (): Promise<typeof chartData> => {
}; };
const fetchPerUserPvChart = async (): Promise<typeof chartData> => { const fetchPerUserPvChart = async (): Promise<typeof chartData> => {
const raw = await os.apiGet('charts/user/pv', { userId: props.args.user.id, limit: props.limit, span: props.span }); const raw = await misskeyApiGet('charts/user/pv', { userId: props.args.user.id, limit: props.limit, span: props.span });
return { return {
series: [{ series: [{
name: 'Unique PV (user)', name: 'Unique PV (user)',
@ -731,7 +731,7 @@ const fetchPerUserPvChart = async (): Promise<typeof chartData> => {
}; };
const fetchPerUserFollowingChart = async (): Promise<typeof chartData> => { const fetchPerUserFollowingChart = async (): Promise<typeof chartData> => {
const raw = await os.apiGet('charts/user/following', { userId: props.args.user.id, limit: props.limit, span: props.span }); const raw = await misskeyApiGet('charts/user/following', { userId: props.args.user.id, limit: props.limit, span: props.span });
return { return {
series: [{ series: [{
name: 'Local', name: 'Local',
@ -746,7 +746,7 @@ const fetchPerUserFollowingChart = async (): Promise<typeof chartData> => {
}; };
const fetchPerUserFollowersChart = async (): Promise<typeof chartData> => { const fetchPerUserFollowersChart = async (): Promise<typeof chartData> => {
const raw = await os.apiGet('charts/user/following', { userId: props.args.user.id, limit: props.limit, span: props.span }); const raw = await misskeyApiGet('charts/user/following', { userId: props.args.user.id, limit: props.limit, span: props.span });
return { return {
series: [{ series: [{
name: 'Local', name: 'Local',
@ -761,7 +761,7 @@ const fetchPerUserFollowersChart = async (): Promise<typeof chartData> => {
}; };
const fetchPerUserDriveChart = async (): Promise<typeof chartData> => { const fetchPerUserDriveChart = async (): Promise<typeof chartData> => {
const raw = await os.apiGet('charts/user/drive', { userId: props.args.user.id, limit: props.limit, span: props.span }); const raw = await misskeyApiGet('charts/user/drive', { userId: props.args.user.id, limit: props.limit, span: props.span });
return { return {
series: [{ series: [{
name: 'Inc', name: 'Inc',

View file

@ -35,6 +35,7 @@ SPDX-License-Identifier: AGPL-3.0-only
import { computed, defineAsyncComponent, ref } from 'vue'; import { computed, defineAsyncComponent, ref } from 'vue';
import * as Misskey from 'misskey-js'; import * as Misskey from 'misskey-js';
import * as os from '@/os.js'; import * as os from '@/os.js';
import { misskeyApi } from '@/scripts/misskey-api.js';
import { i18n } from '@/i18n.js'; import { i18n } from '@/i18n.js';
import { defaultStore } from '@/store.js'; import { defaultStore } from '@/store.js';
import { claimAchievement } from '@/scripts/achievements.js'; import { claimAchievement } from '@/scripts/achievements.js';
@ -144,7 +145,7 @@ function onDrop(ev: DragEvent) {
if (driveFile != null && driveFile !== '') { if (driveFile != null && driveFile !== '') {
const file = JSON.parse(driveFile); const file = JSON.parse(driveFile);
emit('removeFile', file.id); emit('removeFile', file.id);
os.api('drive/files/update', { misskeyApi('drive/files/update', {
fileId: file.id, fileId: file.id,
folderId: props.folder.id, folderId: props.folder.id,
}); });
@ -160,7 +161,7 @@ function onDrop(ev: DragEvent) {
if (folder.id === props.folder.id) return; if (folder.id === props.folder.id) return;
emit('removeFolder', folder.id); emit('removeFolder', folder.id);
os.api('drive/folders/update', { misskeyApi('drive/folders/update', {
folderId: folder.id, folderId: folder.id,
parentId: props.folder.id, parentId: props.folder.id,
}).then(() => { }).then(() => {
@ -214,7 +215,7 @@ function rename() {
default: props.folder.name, default: props.folder.name,
}).then(({ canceled, result: name }) => { }).then(({ canceled, result: name }) => {
if (canceled) return; if (canceled) return;
os.api('drive/folders/update', { misskeyApi('drive/folders/update', {
folderId: props.folder.id, folderId: props.folder.id,
name: name, name: name,
}); });
@ -222,7 +223,7 @@ function rename() {
} }
function deleteFolder() { function deleteFolder() {
os.api('drive/folders/delete', { misskeyApi('drive/folders/delete', {
folderId: props.folder.id, folderId: props.folder.id,
}).then(() => { }).then(() => {
if (defaultStore.state.uploadFolder === props.folder.id) { if (defaultStore.state.uploadFolder === props.folder.id) {

View file

@ -20,7 +20,7 @@ SPDX-License-Identifier: AGPL-3.0-only
<script lang="ts" setup> <script lang="ts" setup>
import { ref } from 'vue'; import { ref } from 'vue';
import * as Misskey from 'misskey-js'; import * as Misskey from 'misskey-js';
import * as os from '@/os.js'; import { misskeyApi } from '@/scripts/misskey-api.js';
import { i18n } from '@/i18n.js'; import { i18n } from '@/i18n.js';
const props = defineProps<{ const props = defineProps<{
@ -112,7 +112,7 @@ function onDrop(ev: DragEvent) {
if (driveFile != null && driveFile !== '') { if (driveFile != null && driveFile !== '') {
const file = JSON.parse(driveFile); const file = JSON.parse(driveFile);
emit('removeFile', file.id); emit('removeFile', file.id);
os.api('drive/files/update', { misskeyApi('drive/files/update', {
fileId: file.id, fileId: file.id,
folderId: props.folder ? props.folder.id : null, folderId: props.folder ? props.folder.id : null,
}); });
@ -126,7 +126,7 @@ function onDrop(ev: DragEvent) {
// reject // reject
if (props.folder && folder.id === props.folder.id) return; if (props.folder && folder.id === props.folder.id) return;
emit('removeFolder', folder.id); emit('removeFolder', folder.id);
os.api('drive/folders/update', { misskeyApi('drive/folders/update', {
folderId: folder.id, folderId: folder.id,
parentId: props.folder ? props.folder.id : null, parentId: props.folder ? props.folder.id : null,
}); });

View file

@ -102,6 +102,7 @@ import XNavFolder from '@/components/MkDrive.navFolder.vue';
import XFolder from '@/components/MkDrive.folder.vue'; import XFolder from '@/components/MkDrive.folder.vue';
import XFile from '@/components/MkDrive.file.vue'; import XFile from '@/components/MkDrive.file.vue';
import * as os from '@/os.js'; import * as os from '@/os.js';
import { misskeyApi } from '@/scripts/misskey-api.js';
import { useStream } from '@/stream.js'; import { useStream } from '@/stream.js';
import { defaultStore } from '@/store.js'; import { defaultStore } from '@/store.js';
import { i18n } from '@/i18n.js'; import { i18n } from '@/i18n.js';
@ -254,7 +255,7 @@ function onDrop(ev: DragEvent): any {
const file = JSON.parse(driveFile); const file = JSON.parse(driveFile);
if (files.value.some(f => f.id === file.id)) return; if (files.value.some(f => f.id === file.id)) return;
removeFile(file.id); removeFile(file.id);
os.api('drive/files/update', { misskeyApi('drive/files/update', {
fileId: file.id, fileId: file.id,
folderId: folder.value ? folder.value.id : null, folderId: folder.value ? folder.value.id : null,
}); });
@ -270,7 +271,7 @@ function onDrop(ev: DragEvent): any {
if (folder.value && droppedFolder.id === folder.value.id) return false; if (folder.value && droppedFolder.id === folder.value.id) return false;
if (folders.value.some(f => f.id === droppedFolder.id)) return false; if (folders.value.some(f => f.id === droppedFolder.id)) return false;
removeFolder(droppedFolder.id); removeFolder(droppedFolder.id);
os.api('drive/folders/update', { misskeyApi('drive/folders/update', {
folderId: droppedFolder.id, folderId: droppedFolder.id,
parentId: folder.value ? folder.value.id : null, parentId: folder.value ? folder.value.id : null,
}).then(() => { }).then(() => {
@ -307,7 +308,7 @@ function urlUpload() {
placeholder: i18n.ts.uploadFromUrlDescription, placeholder: i18n.ts.uploadFromUrlDescription,
}).then(({ canceled, result: url }) => { }).then(({ canceled, result: url }) => {
if (canceled || !url) return; if (canceled || !url) return;
os.api('drive/files/upload-from-url', { misskeyApi('drive/files/upload-from-url', {
url: url, url: url,
folderId: folder.value ? folder.value.id : undefined, folderId: folder.value ? folder.value.id : undefined,
}); });
@ -325,7 +326,7 @@ function createFolder() {
placeholder: i18n.ts.folderName, placeholder: i18n.ts.folderName,
}).then(({ canceled, result: name }) => { }).then(({ canceled, result: name }) => {
if (canceled) return; if (canceled) return;
os.api('drive/folders/create', { misskeyApi('drive/folders/create', {
name: name, name: name,
parentId: folder.value ? folder.value.id : undefined, parentId: folder.value ? folder.value.id : undefined,
}).then(createdFolder => { }).then(createdFolder => {
@ -341,7 +342,7 @@ function renameFolder(folderToRename: Misskey.entities.DriveFolder) {
default: folderToRename.name, default: folderToRename.name,
}).then(({ canceled, result: name }) => { }).then(({ canceled, result: name }) => {
if (canceled) return; if (canceled) return;
os.api('drive/folders/update', { misskeyApi('drive/folders/update', {
folderId: folderToRename.id, folderId: folderToRename.id,
name: name, name: name,
}).then(updatedFolder => { }).then(updatedFolder => {
@ -352,7 +353,7 @@ function renameFolder(folderToRename: Misskey.entities.DriveFolder) {
} }
function deleteFolder(folderToDelete: Misskey.entities.DriveFolder) { function deleteFolder(folderToDelete: Misskey.entities.DriveFolder) {
os.api('drive/folders/delete', { misskeyApi('drive/folders/delete', {
folderId: folderToDelete.id, folderId: folderToDelete.id,
}).then(() => { }).then(() => {
// //
@ -436,7 +437,7 @@ function move(target?: Misskey.entities.DriveFolder) {
fetching.value = true; fetching.value = true;
os.api('drive/folders/show', { misskeyApi('drive/folders/show', {
folderId: target, folderId: target,
}).then(folderToMove => { }).then(folderToMove => {
folder.value = folderToMove; folder.value = folderToMove;
@ -535,7 +536,7 @@ async function fetch() {
const foldersMax = 30; const foldersMax = 30;
const filesMax = 30; const filesMax = 30;
const foldersPromise = os.api('drive/folders', { const foldersPromise = misskeyApi('drive/folders', {
folderId: folder.value ? folder.value.id : null, folderId: folder.value ? folder.value.id : null,
limit: foldersMax + 1, limit: foldersMax + 1,
}).then(fetchedFolders => { }).then(fetchedFolders => {
@ -546,7 +547,7 @@ async function fetch() {
return fetchedFolders; return fetchedFolders;
}); });
const filesPromise = os.api('drive/files', { const filesPromise = misskeyApi('drive/files', {
folderId: folder.value ? folder.value.id : null, folderId: folder.value ? folder.value.id : null,
type: props.type, type: props.type,
limit: filesMax + 1, limit: filesMax + 1,
@ -571,7 +572,7 @@ function fetchMoreFolders() {
const max = 30; const max = 30;
os.api('drive/folders', { misskeyApi('drive/folders', {
folderId: folder.value ? folder.value.id : null, folderId: folder.value ? folder.value.id : null,
type: props.type, type: props.type,
untilId: folders.value.at(-1)?.id, untilId: folders.value.at(-1)?.id,
@ -594,7 +595,7 @@ function fetchMoreFiles() {
const max = 30; const max = 30;
// //
os.api('drive/files', { misskeyApi('drive/files', {
folderId: folder.value ? folder.value.id : null, folderId: folder.value ? folder.value.id : null,
type: props.type, type: props.type,
untilId: files.value.at(-1)?.id, untilId: files.value.at(-1)?.id,

View file

@ -10,11 +10,11 @@ SPDX-License-Identifier: AGPL-3.0-only
<script lang="ts" setup> <script lang="ts" setup>
import { ref } from 'vue'; import { ref } from 'vue';
import * as Misskey from 'misskey-js'; import * as Misskey from 'misskey-js';
import * as os from '@/os.js'; import { misskeyApi } from '@/scripts/misskey-api.js';
const meta = ref<Misskey.entities.MetaResponse>(); const meta = ref<Misskey.entities.MetaResponse>();
os.api('meta', { detail: true }).then(gotMeta => { misskeyApi('meta', { detail: true }).then(gotMeta => {
meta.value = gotMeta; meta.value = gotMeta;
}); });
</script> </script>

View file

@ -38,11 +38,12 @@ SPDX-License-Identifier: AGPL-3.0-only
import { onBeforeUnmount, onMounted, ref } from 'vue'; import { onBeforeUnmount, onMounted, ref } from 'vue';
import * as Misskey from 'misskey-js'; import * as Misskey from 'misskey-js';
import * as os from '@/os.js'; import * as os from '@/os.js';
import { misskeyApi } from '@/scripts/misskey-api.js';
import { useStream } from '@/stream.js'; import { useStream } from '@/stream.js';
import { i18n } from '@/i18n.js'; import { i18n } from '@/i18n.js';
import { claimAchievement } from '@/scripts/achievements.js'; import { claimAchievement } from '@/scripts/achievements.js';
import { $i } from '@/account.js'; import { $i } from '@/account.js';
import { defaultStore } from "@/store.js"; import { defaultStore } from '@/store.js';
const props = withDefaults(defineProps<{ const props = withDefaults(defineProps<{
user: Misskey.entities.UserDetailed, user: Misskey.entities.UserDetailed,
@ -63,7 +64,7 @@ const wait = ref(false);
const connection = useStream().useChannel('main'); const connection = useStream().useChannel('main');
if (props.user.isFollowing == null) { if (props.user.isFollowing == null) {
os.api('users/show', { misskeyApi('users/show', {
userId: props.user.id, userId: props.user.id,
}) })
.then(onFollowChange); .then(onFollowChange);
@ -88,17 +89,17 @@ async function onClick() {
if (canceled) return; if (canceled) return;
await os.api('following/delete', { await misskeyApi('following/delete', {
userId: props.user.id, userId: props.user.id,
}); });
} else { } else {
if (hasPendingFollowRequestFromYou.value) { if (hasPendingFollowRequestFromYou.value) {
await os.api('following/requests/cancel', { await misskeyApi('following/requests/cancel', {
userId: props.user.id, userId: props.user.id,
}); });
hasPendingFollowRequestFromYou.value = false; hasPendingFollowRequestFromYou.value = false;
} else { } else {
await os.api('following/create', { await misskeyApi('following/create', {
userId: props.user.id, userId: props.user.id,
withReplies: defaultStore.state.defaultWithReplies, withReplies: defaultStore.state.defaultWithReplies,
}); });

View file

@ -15,7 +15,7 @@ SPDX-License-Identifier: AGPL-3.0-only
<script lang="ts" setup> <script lang="ts" setup>
import { onMounted, nextTick, watch, shallowRef, ref } from 'vue'; import { onMounted, nextTick, watch, shallowRef, ref } from 'vue';
import { Chart } from 'chart.js'; import { Chart } from 'chart.js';
import * as os from '@/os.js'; import { misskeyApi } from '@/scripts/misskey-api.js';
import { defaultStore } from '@/store.js'; import { defaultStore } from '@/store.js';
import { useChartTooltip } from '@/scripts/use-chart-tooltip.js'; import { useChartTooltip } from '@/scripts/use-chart-tooltip.js';
import { alpha } from '@/scripts/color.js'; import { alpha } from '@/scripts/color.js';
@ -72,19 +72,19 @@ async function renderChart() {
let values; let values;
if (props.src === 'active-users') { if (props.src === 'active-users') {
const raw = await os.api('charts/active-users', { limit: chartLimit, span: 'day' }); const raw = await misskeyApi('charts/active-users', { limit: chartLimit, span: 'day' });
values = raw.readWrite; values = raw.readWrite;
} else if (props.src === 'notes') { } else if (props.src === 'notes') {
const raw = await os.api('charts/notes', { limit: chartLimit, span: 'day' }); const raw = await misskeyApi('charts/notes', { limit: chartLimit, span: 'day' });
values = raw.local.inc; values = raw.local.inc;
} else if (props.src === 'ap-requests-inbox-received') { } else if (props.src === 'ap-requests-inbox-received') {
const raw = await os.api('charts/ap-request', { limit: chartLimit, span: 'day' }); const raw = await misskeyApi('charts/ap-request', { limit: chartLimit, span: 'day' });
values = raw.inboxReceived; values = raw.inboxReceived;
} else if (props.src === 'ap-requests-deliver-succeeded') { } else if (props.src === 'ap-requests-deliver-succeeded') {
const raw = await os.api('charts/ap-request', { limit: chartLimit, span: 'day' }); const raw = await misskeyApi('charts/ap-request', { limit: chartLimit, span: 'day' });
values = raw.deliverSucceeded; values = raw.deliverSucceeded;
} else if (props.src === 'ap-requests-deliver-failed') { } else if (props.src === 'ap-requests-deliver-failed') {
const raw = await os.api('charts/ap-request', { limit: chartLimit, span: 'day' }); const raw = await misskeyApi('charts/ap-request', { limit: chartLimit, span: 'day' });
values = raw.deliverFailed; values = raw.deliverFailed;
} }

View file

@ -18,7 +18,7 @@ SPDX-License-Identifier: AGPL-3.0-only
import { ref } from 'vue'; import { ref } from 'vue';
import * as Misskey from 'misskey-js'; import * as Misskey from 'misskey-js';
import MkMiniChart from '@/components/MkMiniChart.vue'; import MkMiniChart from '@/components/MkMiniChart.vue';
import * as os from '@/os.js'; import { misskeyApiGet } from '@/scripts/misskey-api.js';
import { getProxiedImageUrlNullable } from '@/scripts/media-proxy.js'; import { getProxiedImageUrlNullable } from '@/scripts/media-proxy.js';
const props = defineProps<{ const props = defineProps<{
@ -27,7 +27,7 @@ const props = defineProps<{
const chartValues = ref<number[] | null>(null); const chartValues = ref<number[] | null>(null);
os.apiGet('charts/instance', { host: props.instance.host, limit: 16 + 1, span: 'day' }).then(res => { misskeyApiGet('charts/instance', { host: props.instance.host, limit: 16 + 1, span: 'day' }).then(res => {
// //
res['requests.received'].splice(0, 1); res['requests.received'].splice(0, 1);
chartValues.value = res['requests.received']; chartValues.value = res['requests.received'];

View file

@ -90,6 +90,7 @@ import MkSelect from '@/components/MkSelect.vue';
import MkChart from '@/components/MkChart.vue'; import MkChart from '@/components/MkChart.vue';
import { useChartTooltip } from '@/scripts/use-chart-tooltip.js'; import { useChartTooltip } from '@/scripts/use-chart-tooltip.js';
import * as os from '@/os.js'; import * as os from '@/os.js';
import { misskeyApiGet } from '@/scripts/misskey-api.js';
import { i18n } from '@/i18n.js'; import { i18n } from '@/i18n.js';
import MkHeatmap from '@/components/MkHeatmap.vue'; import MkHeatmap from '@/components/MkHeatmap.vue';
import MkFoldableSection from '@/components/MkFoldableSection.vue'; import MkFoldableSection from '@/components/MkFoldableSection.vue';
@ -162,7 +163,7 @@ function createDoughnut(chartEl, tooltip, data) {
} }
onMounted(() => { onMounted(() => {
os.apiGet('federation/stats', { limit: 30 }).then(fedStats => { misskeyApiGet('federation/stats', { limit: 30 }).then(fedStats => {
createDoughnut(subDoughnutEl.value, externalTooltipHandler1, fedStats.topSubInstances.map(x => ({ createDoughnut(subDoughnutEl.value, externalTooltipHandler1, fedStats.topSubInstances.map(x => ({
name: x.host, name: x.host,
color: x.themeColor, color: x.themeColor,

View file

@ -170,6 +170,7 @@ import { checkWordMute } from '@/scripts/check-word-mute.js';
import { userPage } from '@/filters/user.js'; import { userPage } from '@/filters/user.js';
import * as os from '@/os.js'; import * as os from '@/os.js';
import * as sound from '@/scripts/sound.js'; import * as sound from '@/scripts/sound.js';
import { misskeyApi } from '@/scripts/misskey-api.js';
import { defaultStore, noteViewInterruptors } from '@/store.js'; import { defaultStore, noteViewInterruptors } from '@/store.js';
import { reactionPicker } from '@/scripts/reaction-picker.js'; import { reactionPicker } from '@/scripts/reaction-picker.js';
import { extractUrlFromMfm } from '@/scripts/extract-url-from-mfm.js'; import { extractUrlFromMfm } from '@/scripts/extract-url-from-mfm.js';
@ -277,7 +278,7 @@ const keymap = {
}; };
provide('react', (reaction: string) => { provide('react', (reaction: string) => {
os.api('notes/reactions/create', { misskeyApi('notes/reactions/create', {
noteId: appearNote.value.id, noteId: appearNote.value.id,
reaction: reaction, reaction: reaction,
}); });
@ -298,7 +299,7 @@ if (props.mock) {
if (!props.mock) { if (!props.mock) {
useTooltip(renoteButton, async (showing) => { useTooltip(renoteButton, async (showing) => {
const renotes = await os.api('notes/renotes', { const renotes = await misskeyApi('notes/renotes', {
noteId: appearNote.value.id, noteId: appearNote.value.id,
limit: 11, limit: 11,
}); });
@ -350,7 +351,7 @@ function react(viaKeyboard = false): void {
return; return;
} }
os.api('notes/reactions/create', { misskeyApi('notes/reactions/create', {
noteId: appearNote.value.id, noteId: appearNote.value.id,
reaction: '❤️', reaction: '❤️',
}); });
@ -371,7 +372,7 @@ function react(viaKeyboard = false): void {
return; return;
} }
os.api('notes/reactions/create', { misskeyApi('notes/reactions/create', {
noteId: appearNote.value.id, noteId: appearNote.value.id,
reaction: reaction, reaction: reaction,
}); });
@ -393,7 +394,7 @@ function undoReact(note): void {
return; return;
} }
os.api('notes/reactions/delete', { misskeyApi('notes/reactions/delete', {
noteId: note.id, noteId: note.id,
}); });
} }
@ -453,7 +454,7 @@ function showRenoteMenu(viaKeyboard = false): void {
icon: 'ti ti-trash', icon: 'ti ti-trash',
danger: true, danger: true,
action: () => { action: () => {
os.api('notes/delete', { misskeyApi('notes/delete', {
noteId: note.value.id, noteId: note.value.id,
}); });
isDeleted.value = true; isDeleted.value = true;
@ -499,7 +500,7 @@ function focusAfter() {
} }
function readPromo() { function readPromo() {
os.api('promo/read', { misskeyApi('promo/read', {
noteId: appearNote.value.id, noteId: appearNote.value.id,
}); });
isDeleted.value = true; isDeleted.value = true;

View file

@ -210,6 +210,7 @@ import { checkWordMute } from '@/scripts/check-word-mute.js';
import { userPage } from '@/filters/user.js'; import { userPage } from '@/filters/user.js';
import { notePage } from '@/filters/note.js'; import { notePage } from '@/filters/note.js';
import * as os from '@/os.js'; import * as os from '@/os.js';
import { misskeyApi } from '@/scripts/misskey-api.js';
import * as sound from '@/scripts/sound.js'; import * as sound from '@/scripts/sound.js';
import { defaultStore, noteViewInterruptors } from '@/store.js'; import { defaultStore, noteViewInterruptors } from '@/store.js';
import { reactionPicker } from '@/scripts/reaction-picker.js'; import { reactionPicker } from '@/scripts/reaction-picker.js';
@ -292,7 +293,7 @@ const keymap = {
}; };
provide('react', (reaction: string) => { provide('react', (reaction: string) => {
os.api('notes/reactions/create', { misskeyApi('notes/reactions/create', {
noteId: appearNote.value.id, noteId: appearNote.value.id,
reaction: reaction, reaction: reaction,
}); });
@ -326,7 +327,7 @@ useNoteCapture({
}); });
useTooltip(renoteButton, async (showing) => { useTooltip(renoteButton, async (showing) => {
const renotes = await os.api('notes/renotes', { const renotes = await misskeyApi('notes/renotes', {
noteId: appearNote.value.id, noteId: appearNote.value.id,
limit: 11, limit: 11,
}); });
@ -371,7 +372,7 @@ function react(viaKeyboard = false): void {
if (appearNote.value.reactionAcceptance === 'likeOnly') { if (appearNote.value.reactionAcceptance === 'likeOnly') {
sound.play('reaction'); sound.play('reaction');
os.api('notes/reactions/create', { misskeyApi('notes/reactions/create', {
noteId: appearNote.value.id, noteId: appearNote.value.id,
reaction: '❤️', reaction: '❤️',
}); });
@ -387,7 +388,7 @@ function react(viaKeyboard = false): void {
reactionPicker.show(reactButton.value, reaction => { reactionPicker.show(reactButton.value, reaction => {
sound.play('reaction'); sound.play('reaction');
os.api('notes/reactions/create', { misskeyApi('notes/reactions/create', {
noteId: appearNote.value.id, noteId: appearNote.value.id,
reaction: reaction, reaction: reaction,
}); });
@ -403,7 +404,7 @@ function react(viaKeyboard = false): void {
function undoReact(note): void { function undoReact(note): void {
const oldReaction = note.myReaction; const oldReaction = note.myReaction;
if (!oldReaction) return; if (!oldReaction) return;
os.api('notes/reactions/delete', { misskeyApi('notes/reactions/delete', {
noteId: note.id, noteId: note.id,
}); });
} }
@ -446,7 +447,7 @@ function showRenoteMenu(viaKeyboard = false): void {
icon: 'ti ti-trash', icon: 'ti ti-trash',
danger: true, danger: true,
action: () => { action: () => {
os.api('notes/delete', { misskeyApi('notes/delete', {
noteId: note.value.id, noteId: note.value.id,
}); });
isDeleted.value = true; isDeleted.value = true;
@ -468,7 +469,7 @@ const repliesLoaded = ref(false);
function loadReplies() { function loadReplies() {
repliesLoaded.value = true; repliesLoaded.value = true;
os.api('notes/children', { misskeyApi('notes/children', {
noteId: appearNote.value.id, noteId: appearNote.value.id,
limit: 30, limit: 30,
}).then(res => { }).then(res => {
@ -480,7 +481,7 @@ const conversationLoaded = ref(false);
function loadConversation() { function loadConversation() {
conversationLoaded.value = true; conversationLoaded.value = true;
os.api('notes/conversation', { misskeyApi('notes/conversation', {
noteId: appearNote.value.replyId, noteId: appearNote.value.replyId,
}).then(res => { }).then(res => {
conversation.value = res.reverse(); conversation.value = res.reverse();

View file

@ -46,7 +46,7 @@ import MkNoteHeader from '@/components/MkNoteHeader.vue';
import MkSubNoteContent from '@/components/MkSubNoteContent.vue'; import MkSubNoteContent from '@/components/MkSubNoteContent.vue';
import MkCwButton from '@/components/MkCwButton.vue'; import MkCwButton from '@/components/MkCwButton.vue';
import { notePage } from '@/filters/note.js'; import { notePage } from '@/filters/note.js';
import * as os from '@/os.js'; import { misskeyApi } from '@/scripts/misskey-api.js';
import { i18n } from '@/i18n.js'; import { i18n } from '@/i18n.js';
import { $i } from '@/account.js'; import { $i } from '@/account.js';
import { userPage } from '@/filters/user.js'; import { userPage } from '@/filters/user.js';
@ -68,7 +68,7 @@ const showContent = ref(false);
const replies = ref<Misskey.entities.Note[]>([]); const replies = ref<Misskey.entities.Note[]>([]);
if (props.detail) { if (props.detail) {
os.api('notes/children', { misskeyApi('notes/children', {
noteId: props.note.id, noteId: props.note.id,
limit: 5, limit: 5,
}).then(res => { }).then(res => {

View file

@ -145,7 +145,7 @@ import { getNoteSummary } from '@/scripts/get-note-summary.js';
import { notePage } from '@/filters/note.js'; import { notePage } from '@/filters/note.js';
import { userPage } from '@/filters/user.js'; import { userPage } from '@/filters/user.js';
import { i18n } from '@/i18n.js'; import { i18n } from '@/i18n.js';
import * as os from '@/os.js'; import { misskeyApi } from '@/scripts/misskey-api.js';
import { $i } from '@/account.js'; import { $i } from '@/account.js';
import { infoImageUrl } from '@/instance.js'; import { infoImageUrl } from '@/instance.js';
@ -162,12 +162,12 @@ const followRequestDone = ref(false);
const acceptFollowRequest = () => { const acceptFollowRequest = () => {
followRequestDone.value = true; followRequestDone.value = true;
os.api('following/requests/accept', { userId: props.notification.user.id }); misskeyApi('following/requests/accept', { userId: props.notification.user.id });
}; };
const rejectFollowRequest = () => { const rejectFollowRequest = () => {
followRequestDone.value = true; followRequestDone.value = true;
os.api('following/requests/reject', { userId: props.notification.user.id }); misskeyApi('following/requests/reject', { userId: props.notification.user.id });
}; };
</script> </script>

View file

@ -46,6 +46,7 @@ SPDX-License-Identifier: AGPL-3.0-only
import { computed, ComputedRef, isRef, nextTick, onActivated, onBeforeMount, onBeforeUnmount, onDeactivated, ref, shallowRef, watch } from 'vue'; import { computed, ComputedRef, isRef, nextTick, onActivated, onBeforeMount, onBeforeUnmount, onDeactivated, ref, shallowRef, watch } from 'vue';
import * as Misskey from 'misskey-js'; import * as Misskey from 'misskey-js';
import * as os from '@/os.js'; import * as os from '@/os.js';
import { misskeyApi } from '@/scripts/misskey-api.js';
import { onScrollTop, isTopVisible, getBodyScrollHeight, getScrollContainer, onScrollBottom, scrollToBottom, scroll, isBottomVisible } from '@/scripts/scroll.js'; import { onScrollTop, isTopVisible, getBodyScrollHeight, getScrollContainer, onScrollBottom, scrollToBottom, scroll, isBottomVisible } from '@/scripts/scroll.js';
import { useDocumentVisibility } from '@/scripts/use-document-visibility.js'; import { useDocumentVisibility } from '@/scripts/use-document-visibility.js';
import { defaultStore } from '@/store.js'; import { defaultStore } from '@/store.js';
@ -203,7 +204,7 @@ async function init(): Promise<void> {
queue.value = new Map(); queue.value = new Map();
fetching.value = true; fetching.value = true;
const params = props.pagination.params ? isRef(props.pagination.params) ? props.pagination.params.value : props.pagination.params : {}; const params = props.pagination.params ? isRef(props.pagination.params) ? props.pagination.params.value : props.pagination.params : {};
await os.api(props.pagination.endpoint, { await misskeyApi(props.pagination.endpoint, {
...params, ...params,
limit: props.pagination.limit ?? 10, limit: props.pagination.limit ?? 10,
allowPartial: true, allowPartial: true,
@ -239,7 +240,7 @@ const fetchMore = async (): Promise<void> => {
if (!more.value || fetching.value || moreFetching.value || items.value.size === 0) return; if (!more.value || fetching.value || moreFetching.value || items.value.size === 0) return;
moreFetching.value = true; moreFetching.value = true;
const params = props.pagination.params ? isRef(props.pagination.params) ? props.pagination.params.value : props.pagination.params : {}; const params = props.pagination.params ? isRef(props.pagination.params) ? props.pagination.params.value : props.pagination.params : {};
await os.api(props.pagination.endpoint, { await misskeyApi(props.pagination.endpoint, {
...params, ...params,
limit: SECOND_FETCH_LIMIT, limit: SECOND_FETCH_LIMIT,
...(props.pagination.offsetMode ? { ...(props.pagination.offsetMode ? {
@ -303,7 +304,7 @@ const fetchMoreAhead = async (): Promise<void> => {
if (!more.value || fetching.value || moreFetching.value || items.value.size === 0) return; if (!more.value || fetching.value || moreFetching.value || items.value.size === 0) return;
moreFetching.value = true; moreFetching.value = true;
const params = props.pagination.params ? isRef(props.pagination.params) ? props.pagination.params.value : props.pagination.params : {}; const params = props.pagination.params ? isRef(props.pagination.params) ? props.pagination.params.value : props.pagination.params : {};
await os.api(props.pagination.endpoint, { await misskeyApi(props.pagination.endpoint, {
...params, ...params,
limit: SECOND_FETCH_LIMIT, limit: SECOND_FETCH_LIMIT,
...(props.pagination.offsetMode ? { ...(props.pagination.offsetMode ? {

View file

@ -32,6 +32,7 @@ import * as Misskey from 'misskey-js';
import { sum } from '@/scripts/array.js'; import { sum } from '@/scripts/array.js';
import { pleaseLogin } from '@/scripts/please-login.js'; import { pleaseLogin } from '@/scripts/please-login.js';
import * as os from '@/os.js'; import * as os from '@/os.js';
import { misskeyApi } from '@/scripts/misskey-api.js';
import { i18n } from '@/i18n.js'; import { i18n } from '@/i18n.js';
import { useInterval } from '@/scripts/use-interval.js'; import { useInterval } from '@/scripts/use-interval.js';
@ -83,7 +84,7 @@ const vote = async (id) => {
}); });
if (canceled) return; if (canceled) return;
await os.api('notes/polls/vote', { await misskeyApi('notes/polls/vote', {
noteId: props.note.id, noteId: props.note.id,
choice: id, choice: id,
}); });

View file

@ -115,6 +115,7 @@ import { extractMentions } from '@/scripts/extract-mentions.js';
import { formatTimeString } from '@/scripts/format-time-string.js'; import { formatTimeString } from '@/scripts/format-time-string.js';
import { Autocomplete } from '@/scripts/autocomplete.js'; import { Autocomplete } from '@/scripts/autocomplete.js';
import * as os from '@/os.js'; import * as os from '@/os.js';
import { misskeyApi } from '@/scripts/misskey-api.js';
import { selectFiles } from '@/scripts/select-file.js'; import { selectFiles } from '@/scripts/select-file.js';
import { defaultStore, notePostInterruptors, postFormActions } from '@/store.js'; import { defaultStore, notePostInterruptors, postFormActions } from '@/store.js';
import MkInfo from '@/components/MkInfo.vue'; import MkInfo from '@/components/MkInfo.vue';
@ -328,7 +329,7 @@ if (props.reply && ['home', 'followers', 'specified'].includes(props.reply.visib
if (visibility.value === 'specified') { if (visibility.value === 'specified') {
if (props.reply.visibleUserIds) { if (props.reply.visibleUserIds) {
os.api('users/show', { misskeyApi('users/show', {
userIds: props.reply.visibleUserIds.filter(uid => uid !== $i.id && uid !== props.reply.userId), userIds: props.reply.visibleUserIds.filter(uid => uid !== $i.id && uid !== props.reply.userId),
}).then(users => { }).then(users => {
users.forEach(pushVisibleUser); users.forEach(pushVisibleUser);
@ -336,7 +337,7 @@ if (props.reply && ['home', 'followers', 'specified'].includes(props.reply.visib
} }
if (props.reply.userId !== $i.id) { if (props.reply.userId !== $i.id) {
os.api('users/show', { userId: props.reply.userId }).then(user => { misskeyApi('users/show', { userId: props.reply.userId }).then(user => {
pushVisibleUser(user); pushVisibleUser(user);
}); });
} }
@ -383,7 +384,7 @@ function addMissingMention() {
for (const x of extractMentions(ast)) { for (const x of extractMentions(ast)) {
if (!visibleUsers.value.some(u => (u.username === x.username) && (u.host === x.host))) { if (!visibleUsers.value.some(u => (u.username === x.username) && (u.host === x.host))) {
os.api('users/show', { username: x.username, host: x.host }).then(user => { misskeyApi('users/show', { username: x.username, host: x.host }).then(user => {
visibleUsers.value.push(user); visibleUsers.value.push(user);
}); });
} }
@ -784,7 +785,7 @@ async function post(ev?: MouseEvent) {
} }
posting.value = true; posting.value = true;
os.api('notes/create', postData, token).then(() => { misskeyApi('notes/create', postData, token).then(() => {
if (props.freezeAfterPosted) { if (props.freezeAfterPosted) {
posted.value = true; posted.value = true;
} else { } else {

View file

@ -24,6 +24,7 @@ import { defineAsyncComponent, inject } from 'vue';
import * as Misskey from 'misskey-js'; import * as Misskey from 'misskey-js';
import MkDriveFileThumbnail from '@/components/MkDriveFileThumbnail.vue'; import MkDriveFileThumbnail from '@/components/MkDriveFileThumbnail.vue';
import * as os from '@/os.js'; import * as os from '@/os.js';
import { misskeyApi } from '@/scripts/misskey-api.js';
import { i18n } from '@/i18n.js'; import { i18n } from '@/i18n.js';
const Sortable = defineAsyncComponent(() => import('vuedraggable').then(x => x.default)); const Sortable = defineAsyncComponent(() => import('vuedraggable').then(x => x.default));
@ -61,7 +62,7 @@ function toggleSensitive(file) {
return; return;
} }
os.api('drive/files/update', { misskeyApi('drive/files/update', {
fileId: file.id, fileId: file.id,
isSensitive: !file.isSensitive, isSensitive: !file.isSensitive,
}).then(() => { }).then(() => {
@ -78,7 +79,7 @@ async function rename(file) {
allowEmpty: false, allowEmpty: false,
}); });
if (canceled) return; if (canceled) return;
os.api('drive/files/update', { misskeyApi('drive/files/update', {
fileId: file.id, fileId: file.id,
name: result, name: result,
}).then(() => { }).then(() => {
@ -96,7 +97,7 @@ async function describe(file) {
}, { }, {
done: caption => { done: caption => {
let comment = caption.length === 0 ? null : caption; let comment = caption.length === 0 ? null : caption;
os.api('drive/files/update', { misskeyApi('drive/files/update', {
fileId: file.id, fileId: file.id,
comment: comment, comment: comment,
}).then(() => { }).then(() => {

View file

@ -45,7 +45,8 @@ import { ref } from 'vue';
import { $i, getAccounts } from '@/account.js'; import { $i, getAccounts } from '@/account.js';
import MkButton from '@/components/MkButton.vue'; import MkButton from '@/components/MkButton.vue';
import { instance } from '@/instance.js'; import { instance } from '@/instance.js';
import { api, apiWithDialog, promiseDialog } from '@/os.js'; import { apiWithDialog, promiseDialog } from '@/os.js';
import { misskeyApi } from '@/scripts/misskey-api.js';
import { i18n } from '@/i18n.js'; import { i18n } from '@/i18n.js';
defineProps<{ defineProps<{
@ -82,7 +83,7 @@ function subscribe() {
pushSubscription.value = subscription; pushSubscription.value = subscription;
// Register // Register
pushRegistrationInServer.value = await api('sw/register', { pushRegistrationInServer.value = await misskeyApi('sw/register', {
endpoint: subscription.endpoint, endpoint: subscription.endpoint,
auth: encode(subscription.getKey('auth')), auth: encode(subscription.getKey('auth')),
publickey: encode(subscription.getKey('p256dh')), publickey: encode(subscription.getKey('p256dh')),
@ -159,7 +160,7 @@ if (navigator.serviceWorker == null) {
supported.value = true; supported.value = true;
if (pushSubscription.value) { if (pushSubscription.value) {
const res = await api('sw/show-registration', { const res = await misskeyApi('sw/show-registration', {
endpoint: pushSubscription.value.endpoint, endpoint: pushSubscription.value.endpoint,
}); });

View file

@ -22,6 +22,7 @@ import * as Misskey from 'misskey-js';
import XDetails from '@/components/MkReactionsViewer.details.vue'; import XDetails from '@/components/MkReactionsViewer.details.vue';
import MkReactionIcon from '@/components/MkReactionIcon.vue'; import MkReactionIcon from '@/components/MkReactionIcon.vue';
import * as os from '@/os.js'; import * as os from '@/os.js';
import { misskeyApi, misskeyApiGet } from '@/scripts/misskey-api.js';
import { useTooltip } from '@/scripts/use-tooltip.js'; import { useTooltip } from '@/scripts/use-tooltip.js';
import { $i } from '@/account.js'; import { $i } from '@/account.js';
import MkReactionEffect from '@/components/MkReactionEffect.vue'; import MkReactionEffect from '@/components/MkReactionEffect.vue';
@ -69,11 +70,11 @@ async function toggleReaction() {
return; return;
} }
os.api('notes/reactions/delete', { misskeyApi('notes/reactions/delete', {
noteId: props.note.id, noteId: props.note.id,
}).then(() => { }).then(() => {
if (oldReaction !== props.reaction) { if (oldReaction !== props.reaction) {
os.api('notes/reactions/create', { misskeyApi('notes/reactions/create', {
noteId: props.note.id, noteId: props.note.id,
reaction: props.reaction, reaction: props.reaction,
}); });
@ -87,7 +88,7 @@ async function toggleReaction() {
return; return;
} }
os.api('notes/reactions/create', { misskeyApi('notes/reactions/create', {
noteId: props.note.id, noteId: props.note.id,
reaction: props.reaction, reaction: props.reaction,
}); });
@ -117,7 +118,7 @@ onMounted(() => {
if (!mock) { if (!mock) {
useTooltip(buttonEl, async (showing) => { useTooltip(buttonEl, async (showing) => {
const reactions = await os.apiGet('notes/reactions', { const reactions = await misskeyApiGet('notes/reactions', {
noteId: props.note.id, noteId: props.note.id,
type: props.reaction, type: props.reaction,
limit: 10, limit: 10,

View file

@ -15,7 +15,7 @@ SPDX-License-Identifier: AGPL-3.0-only
<script lang="ts" setup> <script lang="ts" setup>
import { onMounted, nextTick, shallowRef, ref } from 'vue'; import { onMounted, nextTick, shallowRef, ref } from 'vue';
import { Chart } from 'chart.js'; import { Chart } from 'chart.js';
import * as os from '@/os.js'; import { misskeyApi } from '@/scripts/misskey-api.js';
import { defaultStore } from '@/store.js'; import { defaultStore } from '@/store.js';
import { useChartTooltip } from '@/scripts/use-chart-tooltip.js'; import { useChartTooltip } from '@/scripts/use-chart-tooltip.js';
import { alpha } from '@/scripts/color.js'; import { alpha } from '@/scripts/color.js';
@ -43,7 +43,7 @@ async function renderChart() {
const maxDays = wide ? 10 : narrow ? 5 : 7; const maxDays = wide ? 10 : narrow ? 5 : 7;
let raw = await os.api('retention', { }); let raw = await misskeyApi('retention', { });
raw = raw.slice(0, maxDays + 1); raw = raw.slice(0, maxDays + 1);

View file

@ -16,7 +16,7 @@ import { useChartTooltip } from '@/scripts/use-chart-tooltip.js';
import { chartVLine } from '@/scripts/chart-vline.js'; import { chartVLine } from '@/scripts/chart-vline.js';
import { alpha } from '@/scripts/color.js'; import { alpha } from '@/scripts/color.js';
import { initChart } from '@/scripts/init-chart.js'; import { initChart } from '@/scripts/init-chart.js';
import * as os from '@/os.js'; import { misskeyApi } from '@/scripts/misskey-api.js';
initChart(); initChart();
@ -40,7 +40,7 @@ const getDate = (ymd: string) => {
}; };
onMounted(async () => { onMounted(async () => {
let raw = await os.api('retention', { }); let raw = await misskeyApi('retention', { });
const vLineColor = defaultStore.state.darkMode ? 'rgba(255, 255, 255, 0.2)' : 'rgba(0, 0, 0, 0.2)'; const vLineColor = defaultStore.state.darkMode ? 'rgba(255, 255, 255, 0.2)' : 'rgba(0, 0, 0, 0.2)';

View file

@ -59,6 +59,7 @@ import MkInput from '@/components/MkInput.vue';
import MkInfo from '@/components/MkInfo.vue'; import MkInfo from '@/components/MkInfo.vue';
import { host as configHost } from '@/config.js'; import { host as configHost } from '@/config.js';
import * as os from '@/os.js'; import * as os from '@/os.js';
import { misskeyApi } from '@/scripts/misskey-api.js';
import { login } from '@/account.js'; import { login } from '@/account.js';
import { i18n } from '@/i18n.js'; import { i18n } from '@/i18n.js';
@ -95,7 +96,7 @@ const props = defineProps({
}); });
function onUsernameChange(): void { function onUsernameChange(): void {
os.api('users/show', { misskeyApi('users/show', {
username: username.value, username: username.value,
}).then(userResponse => { }).then(userResponse => {
user.value = userResponse; user.value = userResponse;
@ -120,7 +121,7 @@ async function queryKey(): Promise<void> {
credentialRequest.value = null; credentialRequest.value = null;
queryingKey.value = false; queryingKey.value = false;
signing.value = true; signing.value = true;
return os.api('signin', { return misskeyApi('signin', {
username: username.value, username: username.value,
password: password.value, password: password.value,
credential: credential.toJSON(), credential: credential.toJSON(),
@ -142,7 +143,7 @@ function onSubmit(): void {
signing.value = true; signing.value = true;
if (!totpLogin.value && user.value && user.value.twoFactorEnabled) { if (!totpLogin.value && user.value && user.value.twoFactorEnabled) {
if (webAuthnSupported() && user.value.securityKeys) { if (webAuthnSupported() && user.value.securityKeys) {
os.api('signin', { misskeyApi('signin', {
username: username.value, username: username.value,
password: password.value, password: password.value,
}).then(res => { }).then(res => {
@ -159,7 +160,7 @@ function onSubmit(): void {
signing.value = false; signing.value = false;
} }
} else { } else {
os.api('signin', { misskeyApi('signin', {
username: username.value, username: username.value,
password: password.value, password: password.value,
token: user.value?.twoFactorEnabled ? token.value : undefined, token: user.value?.twoFactorEnabled ? token.value : undefined,

View file

@ -84,6 +84,7 @@ import MkInput from './MkInput.vue';
import MkCaptcha, { type Captcha } from '@/components/MkCaptcha.vue'; import MkCaptcha, { type Captcha } from '@/components/MkCaptcha.vue';
import * as config from '@/config.js'; import * as config from '@/config.js';
import * as os from '@/os.js'; import * as os from '@/os.js';
import { misskeyApi } from '@/scripts/misskey-api.js';
import { login } from '@/account.js'; import { login } from '@/account.js';
import { instance } from '@/instance.js'; import { instance } from '@/instance.js';
import { i18n } from '@/i18n.js'; import { i18n } from '@/i18n.js';
@ -180,7 +181,7 @@ function onChangeUsername(): void {
usernameState.value = 'wait'; usernameState.value = 'wait';
usernameAbortController.value = new AbortController(); usernameAbortController.value = new AbortController();
os.api('username/available', { misskeyApi('username/available', {
username: username.value, username: username.value,
}, undefined, usernameAbortController.value.signal).then(result => { }, undefined, usernameAbortController.value.signal).then(result => {
usernameState.value = result.available ? 'ok' : 'unavailable'; usernameState.value = result.available ? 'ok' : 'unavailable';
@ -203,7 +204,7 @@ function onChangeEmail(): void {
emailState.value = 'wait'; emailState.value = 'wait';
emailAbortController.value = new AbortController(); emailAbortController.value = new AbortController();
os.api('email-address/available', { misskeyApi('email-address/available', {
emailAddress: email.value, emailAddress: email.value,
}, undefined, emailAbortController.value.signal).then(result => { }, undefined, emailAbortController.value.signal).then(result => {
emailState.value = result.available ? 'ok' : emailState.value = result.available ? 'ok' :
@ -245,7 +246,7 @@ async function onSubmit(): Promise<void> {
submitting.value = true; submitting.value = true;
try { try {
await os.api('signup', { await misskeyApi('signup', {
username: username.value, username: username.value,
password: password.value, password: password.value,
emailAddress: email.value, emailAddress: email.value,
@ -262,7 +263,7 @@ async function onSubmit(): Promise<void> {
}); });
emit('signupEmailPending'); emit('signupEmailPending');
} else { } else {
const res = await os.api('signin', { const res = await misskeyApi('signin', {
username: username.value, username: username.value,
password: password.value, password: password.value,
}); });

View file

@ -56,6 +56,7 @@ import MkModalWindow from '@/components/MkModalWindow.vue';
import MkButton from '@/components/MkButton.vue'; import MkButton from '@/components/MkButton.vue';
import MkInput from '@/components/MkInput.vue'; import MkInput from '@/components/MkInput.vue';
import * as os from '@/os.js'; import * as os from '@/os.js';
import { misskeyApi } from '@/scripts/misskey-api.js';
import { i18n } from '@/i18n.js'; import { i18n } from '@/i18n.js';
import MkTextarea from '@/components/MkTextarea.vue'; import MkTextarea from '@/components/MkTextarea.vue';
import MkSwitch from '@/components/MkSwitch.vue'; import MkSwitch from '@/components/MkSwitch.vue';
@ -121,7 +122,7 @@ async function del() {
}); });
if (canceled) return; if (canceled) return;
os.api('admin/announcements/delete', { misskeyApi('admin/announcements/delete', {
id: props.announcement.id, id: props.announcement.id,
}).then(() => { }).then(() => {
emit('done', { emit('done', {

View file

@ -18,7 +18,7 @@ SPDX-License-Identifier: AGPL-3.0-only
import * as Misskey from 'misskey-js'; import * as Misskey from 'misskey-js';
import { onMounted, ref } from 'vue'; import { onMounted, ref } from 'vue';
import MkMiniChart from '@/components/MkMiniChart.vue'; import MkMiniChart from '@/components/MkMiniChart.vue';
import * as os from '@/os.js'; import { misskeyApiGet } from '@/scripts/misskey-api.js';
import { acct } from '@/filters/user.js'; import { acct } from '@/filters/user.js';
const props = withDefaults(defineProps<{ const props = withDefaults(defineProps<{
@ -32,7 +32,7 @@ const chartValues = ref<number[] | null>(null);
onMounted(() => { onMounted(() => {
if (props.withChart) { if (props.withChart) {
os.apiGet('charts/user/notes', { userId: props.user.id, limit: 16 + 1, span: 'day' }).then(res => { misskeyApiGet('charts/user/notes', { userId: props.user.id, limit: 16 + 1, span: 'day' }).then(res => {
// //
res.inc.splice(0, 1); res.inc.splice(0, 1);
chartValues.value = res.inc; chartValues.value = res.inc;

View file

@ -60,6 +60,7 @@ import * as Misskey from 'misskey-js';
import MkFollowButton from '@/components/MkFollowButton.vue'; import MkFollowButton from '@/components/MkFollowButton.vue';
import { userPage } from '@/filters/user.js'; import { userPage } from '@/filters/user.js';
import * as os from '@/os.js'; import * as os from '@/os.js';
import { misskeyApi } from '@/scripts/misskey-api.js';
import { getUserMenu } from '@/scripts/get-user-menu.js'; import { getUserMenu } from '@/scripts/get-user-menu.js';
import number from '@/filters/number.js'; import number from '@/filters/number.js';
import { i18n } from '@/i18n.js'; import { i18n } from '@/i18n.js';
@ -97,7 +98,7 @@ onMounted(() => {
Misskey.acct.parse(props.q.substring(1)) : Misskey.acct.parse(props.q.substring(1)) :
{ userId: props.q }; { userId: props.q };
os.api('users/show', query).then(res => { misskeyApi('users/show', query).then(res => {
if (!props.showing) return; if (!props.showing) return;
user.value = res; user.value = res;
}); });

View file

@ -62,7 +62,7 @@ import * as Misskey from 'misskey-js';
import MkInput from '@/components/MkInput.vue'; import MkInput from '@/components/MkInput.vue';
import FormSplit from '@/components/form/split.vue'; import FormSplit from '@/components/form/split.vue';
import MkModalWindow from '@/components/MkModalWindow.vue'; import MkModalWindow from '@/components/MkModalWindow.vue';
import * as os from '@/os.js'; import { misskeyApi } from '@/scripts/misskey-api.js';
import { defaultStore } from '@/store.js'; import { defaultStore } from '@/store.js';
import { i18n } from '@/i18n.js'; import { i18n } from '@/i18n.js';
import { $i } from '@/account.js'; import { $i } from '@/account.js';
@ -90,7 +90,7 @@ const search = () => {
users.value = []; users.value = [];
return; return;
} }
os.api('users/search-by-username-and-host', { misskeyApi('users/search-by-username-and-host', {
username: username.value, username: username.value,
host: host.value, host: host.value,
limit: 10, limit: 10,
@ -118,7 +118,7 @@ const cancel = () => {
}; };
onMounted(() => { onMounted(() => {
os.api('users/show', { misskeyApi('users/show', {
userIds: defaultStore.state.recentlyUsedUsers, userIds: defaultStore.state.recentlyUsedUsers,
}).then(users => { }).then(users => {
if (props.includeSelf && users.find(x => $i ? x.id === $i.id : true) == null) { if (props.includeSelf && users.find(x => $i ? x.id === $i.id : true) == null) {

View file

@ -49,7 +49,7 @@ import { i18n } from '@/i18n.js';
import MkSwitch from '@/components/MkSwitch.vue'; import MkSwitch from '@/components/MkSwitch.vue';
import MkInfo from '@/components/MkInfo.vue'; import MkInfo from '@/components/MkInfo.vue';
import MkFolder from '@/components/MkFolder.vue'; import MkFolder from '@/components/MkFolder.vue';
import * as os from '@/os.js'; import { misskeyApi } from '@/scripts/misskey-api.js';
const isLocked = ref(false); const isLocked = ref(false);
const hideOnlineStatus = ref(false); const hideOnlineStatus = ref(false);
@ -57,7 +57,7 @@ const noCrawle = ref(false);
const preventAiLearning = ref(true); const preventAiLearning = ref(true);
watch([isLocked, hideOnlineStatus, noCrawle, preventAiLearning], () => { watch([isLocked, hideOnlineStatus, noCrawle, preventAiLearning], () => {
os.api('i/update', { misskeyApi('i/update', {
isLocked: !!isLocked.value, isLocked: !!isLocked.value,
hideOnlineStatus: !!hideOnlineStatus.value, hideOnlineStatus: !!hideOnlineStatus.value,
noCrawle: !!noCrawle.value, noCrawle: !!noCrawle.value,

View file

@ -29,7 +29,7 @@ import * as Misskey from 'misskey-js';
import { ref } from 'vue'; import { ref } from 'vue';
import MkButton from '@/components/MkButton.vue'; import MkButton from '@/components/MkButton.vue';
import { i18n } from '@/i18n.js'; import { i18n } from '@/i18n.js';
import * as os from '@/os.js'; import { misskeyApi } from '@/scripts/misskey-api.js';
const props = defineProps<{ const props = defineProps<{
user: Misskey.entities.UserDetailed; user: Misskey.entities.UserDetailed;
@ -39,7 +39,7 @@ const isFollowing = ref(false);
async function follow() { async function follow() {
isFollowing.value = true; isFollowing.value = true;
os.api('following/create', { misskeyApi('following/create', {
userId: props.user.id, userId: props.user.id,
}); });
} }

View file

@ -17,7 +17,7 @@ import { onMounted, shallowRef, ref } from 'vue';
import { Chart } from 'chart.js'; import { Chart } from 'chart.js';
import gradient from 'chartjs-plugin-gradient'; import gradient from 'chartjs-plugin-gradient';
import tinycolor from 'tinycolor2'; import tinycolor from 'tinycolor2';
import * as os from '@/os.js'; import { misskeyApi } from '@/scripts/misskey-api.js';
import { defaultStore } from '@/store.js'; import { defaultStore } from '@/store.js';
import { useChartTooltip } from '@/scripts/use-chart-tooltip.js'; import { useChartTooltip } from '@/scripts/use-chart-tooltip.js';
import { chartVLine } from '@/scripts/chart-vline.js'; import { chartVLine } from '@/scripts/chart-vline.js';
@ -53,7 +53,7 @@ async function renderChart() {
})); }));
}; };
const raw = await os.api('charts/active-users', { limit: chartLimit, span: 'day' }); const raw = await misskeyApi('charts/active-users', { limit: chartLimit, span: 'day' });
const vLineColor = defaultStore.state.darkMode ? 'rgba(255, 255, 255, 0.2)' : 'rgba(0, 0, 0, 0.2)'; const vLineColor = defaultStore.state.darkMode ? 'rgba(255, 255, 255, 0.2)' : 'rgba(0, 0, 0, 0.2)';

View file

@ -60,6 +60,7 @@ import MkTimeline from '@/components/MkTimeline.vue';
import MkInfo from '@/components/MkInfo.vue'; import MkInfo from '@/components/MkInfo.vue';
import { instanceName } from '@/config.js'; import { instanceName } from '@/config.js';
import * as os from '@/os.js'; import * as os from '@/os.js';
import { misskeyApi } from '@/scripts/misskey-api.js';
import { i18n } from '@/i18n.js'; import { i18n } from '@/i18n.js';
import { instance } from '@/instance.js'; import { instance } from '@/instance.js';
import MkNumber from '@/components/MkNumber.vue'; import MkNumber from '@/components/MkNumber.vue';
@ -68,11 +69,11 @@ import XActiveUsersChart from '@/components/MkVisitorDashboard.ActiveUsersChart.
const meta = ref<Misskey.entities.MetaResponse | null>(null); const meta = ref<Misskey.entities.MetaResponse | null>(null);
const stats = ref<Misskey.entities.StatsResponse | null>(null); const stats = ref<Misskey.entities.StatsResponse | null>(null);
os.api('meta', { detail: true }).then(_meta => { misskeyApi('meta', { detail: true }).then(_meta => {
meta.value = _meta; meta.value = _meta;
}); });
os.api('stats', {}).then((res) => { misskeyApi('stats', {}).then((res) => {
stats.value = res; stats.value = res;
}); });

View file

@ -16,7 +16,7 @@ import * as Misskey from 'misskey-js';
import { NoteBlock } from './block.type.js'; import { NoteBlock } from './block.type.js';
import MkNote from '@/components/MkNote.vue'; import MkNote from '@/components/MkNote.vue';
import MkNoteDetailed from '@/components/MkNoteDetailed.vue'; import MkNoteDetailed from '@/components/MkNoteDetailed.vue';
import * as os from '@/os.js'; import { misskeyApi } from '@/scripts/misskey-api.js';
const props = defineProps<{ const props = defineProps<{
block: NoteBlock, block: NoteBlock,
@ -26,7 +26,7 @@ const props = defineProps<{
const note = ref<Misskey.entities.Note | null>(null); const note = ref<Misskey.entities.Note | null>(null);
onMounted(() => { onMounted(() => {
os.api('notes/show', { noteId: props.block.note }) misskeyApi('notes/show', { noteId: props.block.note })
.then(result => { .then(result => {
note.value = result; note.value = result;
}); });

View file

@ -5,7 +5,7 @@
import { shallowRef, computed, markRaw, watch } from 'vue'; import { shallowRef, computed, markRaw, watch } from 'vue';
import * as Misskey from 'misskey-js'; import * as Misskey from 'misskey-js';
import { api, apiGet } from '@/os.js'; import { misskeyApi, misskeyApiGet } from '@/scripts/misskey-api.js';
import { useStream } from '@/stream.js'; import { useStream } from '@/stream.js';
import { get, set } from '@/scripts/idb-proxy.js'; import { get, set } from '@/scripts/idb-proxy.js';
@ -52,11 +52,11 @@ export async function fetchCustomEmojis(force = false) {
let res; let res;
if (force) { if (force) {
res = await api('emojis', {}); res = await misskeyApi('emojis', {});
} else { } else {
const lastFetchedAt = await get('lastEmojisFetchedAt'); const lastFetchedAt = await get('lastEmojisFetchedAt');
if (lastFetchedAt && (now - lastFetchedAt) < 1000 * 60 * 60) return; if (lastFetchedAt && (now - lastFetchedAt) < 1000 * 60 * 60) return;
res = await apiGet('emojis', {}); res = await misskeyApiGet('emojis', {});
} }
customEmojis.value = res.emojis; customEmojis.value = res.emojis;

View file

@ -5,7 +5,7 @@
import { computed, reactive } from 'vue'; import { computed, reactive } from 'vue';
import * as Misskey from 'misskey-js'; import * as Misskey from 'misskey-js';
import { api } from '@/os.js'; import { misskeyApi } from '@/scripts/misskey-api.js';
import { miLocalStorage } from '@/local-storage.js'; import { miLocalStorage } from '@/local-storage.js';
import { DEFAULT_INFO_IMAGE_URL, DEFAULT_NOT_FOUND_IMAGE_URL, DEFAULT_SERVER_ERROR_IMAGE_URL } from '@/const.js'; import { DEFAULT_INFO_IMAGE_URL, DEFAULT_NOT_FOUND_IMAGE_URL, DEFAULT_SERVER_ERROR_IMAGE_URL } from '@/const.js';
@ -26,7 +26,7 @@ export const infoImageUrl = computed(() => instance.infoImageUrl ?? DEFAULT_INFO
export const notFoundImageUrl = computed(() => instance.notFoundImageUrl ?? DEFAULT_NOT_FOUND_IMAGE_URL); export const notFoundImageUrl = computed(() => instance.notFoundImageUrl ?? DEFAULT_NOT_FOUND_IMAGE_URL);
export async function fetchInstance() { export async function fetchInstance() {
const meta = await api('meta', { const meta = await misskeyApi('meta', {
detail: false, detail: false,
}); });

View file

@ -5,12 +5,11 @@
// TODO: なんでもかんでもos.tsに突っ込むのやめたいのでよしなに分割する // TODO: なんでもかんでもos.tsに突っ込むのやめたいのでよしなに分割する
import { pendingApiRequestsCount, api, apiGet } from '@/scripts/api.js';
export { pendingApiRequestsCount, api, apiGet };
import { Component, markRaw, Ref, ref, defineAsyncComponent } from 'vue'; import { Component, markRaw, Ref, ref, defineAsyncComponent } from 'vue';
import { EventEmitter } from 'eventemitter3'; import { EventEmitter } from 'eventemitter3';
import insertTextAtCursor from 'insert-text-at-cursor'; import insertTextAtCursor from 'insert-text-at-cursor';
import * as Misskey from 'misskey-js'; import * as Misskey from 'misskey-js';
import { misskeyApi } from '@/scripts/misskey-api.js';
import { i18n } from '@/i18n.js'; import { i18n } from '@/i18n.js';
import MkPostFormDialog from '@/components/MkPostFormDialog.vue'; import MkPostFormDialog from '@/components/MkPostFormDialog.vue';
import MkWaitingDialog from '@/components/MkWaitingDialog.vue'; import MkWaitingDialog from '@/components/MkWaitingDialog.vue';
@ -33,7 +32,7 @@ export const apiWithDialog = ((
data: Record<string, any> = {}, data: Record<string, any> = {},
token?: string | null | undefined, token?: string | null | undefined,
) => { ) => {
const promise = api(endpoint, data, token); const promise = misskeyApi(endpoint, data, token);
promiseDialog(promise, null, async (err) => { promiseDialog(promise, null, async (err) => {
let title = null; let title = null;
let text = err.message + '\n' + (err as any).id; let text = err.message + '\n' + (err as any).id;
@ -83,7 +82,7 @@ export const apiWithDialog = ((
}); });
return promise; return promise;
}) as typeof api; }) as typeof misskeyApi;
export function promiseDialog<T extends Promise<any>>( export function promiseDialog<T extends Promise<any>>(
promise: T, promise: T,
@ -621,7 +620,7 @@ export function checkExistence(fileData: ArrayBuffer): Promise<any> {
const data = new FormData(); const data = new FormData();
data.append('md5', getMD5(fileData)); data.append('md5', getMD5(fileData));
os.api('drive/files/find-by-hash', { api('drive/files/find-by-hash', {
md5: getMD5(fileData) md5: getMD5(fileData)
}).then(resp => { }).then(resp => {
resolve(resp.length > 0 ? resp[0] : null); resolve(resp.length > 0 ? resp[0] : null);

View file

@ -29,7 +29,7 @@ import { ref, computed } from 'vue';
import * as Misskey from 'misskey-js'; import * as Misskey from 'misskey-js';
import MkButton from '@/components/MkButton.vue'; import MkButton from '@/components/MkButton.vue';
import { version } from '@/config.js'; import { version } from '@/config.js';
import * as os from '@/os.js'; import { misskeyApi } from '@/scripts/misskey-api.js';
import { unisonReload } from '@/scripts/unison-reload.js'; import { unisonReload } from '@/scripts/unison-reload.js';
import { i18n } from '@/i18n.js'; import { i18n } from '@/i18n.js';
import { definePageMetadata } from '@/scripts/page-metadata.js'; import { definePageMetadata } from '@/scripts/page-metadata.js';
@ -46,7 +46,7 @@ const loaded = ref(false);
const serverIsDead = ref(false); const serverIsDead = ref(false);
const meta = ref<Misskey.entities.MetaResponse | null>(null); const meta = ref<Misskey.entities.MetaResponse | null>(null);
os.api('meta', { misskeyApi('meta', {
detail: false, detail: false,
}).then(res => { }).then(res => {
loaded.value = true; loaded.value = true;

View file

@ -114,7 +114,7 @@ import FormSplit from '@/components/form/split.vue';
import MkFolder from '@/components/MkFolder.vue'; import MkFolder from '@/components/MkFolder.vue';
import MkKeyValue from '@/components/MkKeyValue.vue'; import MkKeyValue from '@/components/MkKeyValue.vue';
import MkInstanceStats from '@/components/MkInstanceStats.vue'; import MkInstanceStats from '@/components/MkInstanceStats.vue';
import * as os from '@/os.js'; import { misskeyApi } from '@/scripts/misskey-api.js';
import number from '@/filters/number.js'; import number from '@/filters/number.js';
import { i18n } from '@/i18n.js'; import { i18n } from '@/i18n.js';
import { definePageMetadata } from '@/scripts/page-metadata.js'; import { definePageMetadata } from '@/scripts/page-metadata.js';
@ -136,7 +136,7 @@ watch(tab, () => {
} }
}); });
const initStats = () => os.api('stats', { const initStats = () => misskeyApi('stats', {
}).then((res) => { }).then((res) => {
stats.value = res; stats.value = res;
}); });

View file

@ -79,6 +79,7 @@ import MkUserCardMini from '@/components/MkUserCardMini.vue';
import MkInfo from '@/components/MkInfo.vue'; import MkInfo from '@/components/MkInfo.vue';
import bytes from '@/filters/bytes.js'; import bytes from '@/filters/bytes.js';
import * as os from '@/os.js'; import * as os from '@/os.js';
import { misskeyApi } from '@/scripts/misskey-api.js';
import { i18n } from '@/i18n.js'; import { i18n } from '@/i18n.js';
import { definePageMetadata } from '@/scripts/page-metadata.js'; import { definePageMetadata } from '@/scripts/page-metadata.js';
import { iAmAdmin, iAmModerator } from '@/account.js'; import { iAmAdmin, iAmModerator } from '@/account.js';
@ -93,8 +94,8 @@ const props = defineProps<{
}>(); }>();
async function fetch() { async function fetch() {
file.value = await os.api('drive/files/show', { fileId: props.fileId }); file.value = await misskeyApi('drive/files/show', { fileId: props.fileId });
info.value = await os.api('admin/drive/show-file', { fileId: props.fileId }); info.value = await misskeyApi('admin/drive/show-file', { fileId: props.fileId });
isSensitive.value = file.value.isSensitive; isSensitive.value = file.value.isSensitive;
} }
@ -113,7 +114,7 @@ async function del() {
} }
async function toggleIsSensitive(v) { async function toggleIsSensitive(v) {
await os.api('drive/files/update', { fileId: props.fileId, isSensitive: v }); await misskeyApi('drive/files/update', { fileId: props.fileId, isSensitive: v });
isSensitive.value = v; isSensitive.value = v;
} }

View file

@ -219,6 +219,7 @@ import FormSuspense from '@/components/form/suspense.vue';
import MkFileListForAdmin from '@/components/MkFileListForAdmin.vue'; import MkFileListForAdmin from '@/components/MkFileListForAdmin.vue';
import MkInfo from '@/components/MkInfo.vue'; import MkInfo from '@/components/MkInfo.vue';
import * as os from '@/os.js'; import * as os from '@/os.js';
import { misskeyApi } from '@/scripts/misskey-api.js';
import { url } from '@/config.js'; import { url } from '@/config.js';
import { acct } from '@/filters/user.js'; import { acct } from '@/filters/user.js';
import { definePageMetadata } from '@/scripts/page-metadata.js'; import { definePageMetadata } from '@/scripts/page-metadata.js';
@ -262,11 +263,11 @@ const announcementsPagination = {
const expandedRoles = ref([]); const expandedRoles = ref([]);
function createFetcher() { function createFetcher() {
return () => Promise.all([os.api('users/show', { return () => Promise.all([misskeyApi('users/show', {
userId: props.userId, userId: props.userId,
}), os.api('admin/show-user', { }), misskeyApi('admin/show-user', {
userId: props.userId, userId: props.userId,
}), iAmAdmin ? os.api('admin/get-user-ips', { }), iAmAdmin ? misskeyApi('admin/get-user-ips', {
userId: props.userId, userId: props.userId,
}) : Promise.resolve(null)]).then(([_user, _info, _ips]) => { }) : Promise.resolve(null)]).then(([_user, _info, _ips]) => {
user.value = _user; user.value = _user;
@ -278,7 +279,7 @@ function createFetcher() {
moderationNote.value = info.value.moderationNote; moderationNote.value = info.value.moderationNote;
watch(moderationNote, async () => { watch(moderationNote, async () => {
await os.api('admin/update-user-note', { userId: user.value.id, text: moderationNote.value }); await misskeyApi('admin/update-user-note', { userId: user.value.id, text: moderationNote.value });
await refreshUser(); await refreshUser();
}); });
}); });
@ -301,7 +302,7 @@ async function resetPassword() {
if (confirm.canceled) { if (confirm.canceled) {
return; return;
} else { } else {
const { password } = await os.api('admin/reset-password', { const { password } = await misskeyApi('admin/reset-password', {
userId: user.value.id, userId: user.value.id,
}); });
os.alert({ os.alert({
@ -319,7 +320,7 @@ async function toggleSuspend(v) {
if (confirm.canceled) { if (confirm.canceled) {
suspended.value = !v; suspended.value = !v;
} else { } else {
await os.api(v ? 'admin/suspend-user' : 'admin/unsuspend-user', { userId: user.value.id }); await misskeyApi(v ? 'admin/suspend-user' : 'admin/unsuspend-user', { userId: user.value.id });
await refreshUser(); await refreshUser();
} }
} }
@ -331,7 +332,7 @@ async function unsetUserAvatar() {
}); });
if (confirm.canceled) return; if (confirm.canceled) return;
const process = async () => { const process = async () => {
await os.api('admin/unset-user-avatar', { userId: user.value.id }); await misskeyApi('admin/unset-user-avatar', { userId: user.value.id });
os.success(); os.success();
}; };
await process().catch(err => { await process().catch(err => {
@ -350,7 +351,7 @@ async function unsetUserBanner() {
}); });
if (confirm.canceled) return; if (confirm.canceled) return;
const process = async () => { const process = async () => {
await os.api('admin/unset-user-banner', { userId: user.value.id }); await misskeyApi('admin/unset-user-banner', { userId: user.value.id });
os.success(); os.success();
}; };
await process().catch(err => { await process().catch(err => {
@ -369,7 +370,7 @@ async function deleteAllFiles() {
}); });
if (confirm.canceled) return; if (confirm.canceled) return;
const process = async () => { const process = async () => {
await os.api('admin/delete-all-files-of-a-user', { userId: user.value.id }); await misskeyApi('admin/delete-all-files-of-a-user', { userId: user.value.id });
os.success(); os.success();
}; };
await process().catch(err => { await process().catch(err => {
@ -406,7 +407,7 @@ async function deleteAccount() {
} }
async function assignRole() { async function assignRole() {
const roles = await os.api('admin/roles/list'); const roles = await misskeyApi('admin/roles/list');
const { canceled, result: roleId } = await os.select({ const { canceled, result: roleId } = await os.select({
title: i18n.ts._role.chooseRoleToAssign, title: i18n.ts._role.chooseRoleToAssign,
@ -482,7 +483,7 @@ watch(() => props.userId, () => {
}); });
watch(user, () => { watch(user, () => {
os.api('ap/get', { misskeyApi('ap/get', {
uri: user.value.uri ?? `${url}/users/${user.value.id}`, uri: user.value.uri ?? `${url}/users/${user.value.id}`,
}).then(res => { }).then(res => {
ap.value = res; ap.value = res;

View file

@ -96,6 +96,7 @@ import MkFolder from '@/components/MkFolder.vue';
import MkSelect from '@/components/MkSelect.vue'; import MkSelect from '@/components/MkSelect.vue';
import FormSplit from '@/components/form/split.vue'; import FormSplit from '@/components/form/split.vue';
import * as os from '@/os.js'; import * as os from '@/os.js';
import { misskeyApi } from '@/scripts/misskey-api.js';
import { i18n } from '@/i18n.js'; import { i18n } from '@/i18n.js';
import { definePageMetadata } from '@/scripts/page-metadata.js'; import { definePageMetadata } from '@/scripts/page-metadata.js';
@ -108,7 +109,7 @@ const daysOfWeek: string[] = [i18n.ts._weekday.sunday, i18n.ts._weekday.monday,
const filterType = ref('all'); const filterType = ref('all');
let publishing: boolean | null = null; let publishing: boolean | null = null;
os.api('admin/ad/list', { publishing: publishing }).then(adsResponse => { misskeyApi('admin/ad/list', { publishing: publishing }).then(adsResponse => {
if (adsResponse != null) { if (adsResponse != null) {
ads.value = adsResponse.map(r => { ads.value = adsResponse.map(r => {
const exdate = new Date(r.expiresAt); const exdate = new Date(r.expiresAt);
@ -174,7 +175,7 @@ function remove(ad) {
function save(ad) { function save(ad) {
if (ad.id == null) { if (ad.id == null) {
os.api('admin/ad/create', { misskeyApi('admin/ad/create', {
...ad, ...ad,
expiresAt: new Date(ad.expiresAt).getTime(), expiresAt: new Date(ad.expiresAt).getTime(),
startsAt: new Date(ad.startsAt).getTime(), startsAt: new Date(ad.startsAt).getTime(),
@ -191,7 +192,7 @@ function save(ad) {
}); });
}); });
} else { } else {
os.api('admin/ad/update', { misskeyApi('admin/ad/update', {
...ad, ...ad,
expiresAt: new Date(ad.expiresAt).getTime(), expiresAt: new Date(ad.expiresAt).getTime(),
startsAt: new Date(ad.startsAt).getTime(), startsAt: new Date(ad.startsAt).getTime(),
@ -210,7 +211,7 @@ function save(ad) {
} }
function more() { function more() {
os.api('admin/ad/list', { untilId: ads.value.reduce((acc, ad) => ad.id != null ? ad : acc).id, publishing: publishing }).then(adsResponse => { misskeyApi('admin/ad/list', { untilId: ads.value.reduce((acc, ad) => ad.id != null ? ad : acc).id, publishing: publishing }).then(adsResponse => {
if (adsResponse == null) return; if (adsResponse == null) return;
ads.value = ads.value.concat(adsResponse.map(r => { ads.value = ads.value.concat(adsResponse.map(r => {
const exdate = new Date(r.expiresAt); const exdate = new Date(r.expiresAt);
@ -227,7 +228,7 @@ function more() {
} }
function refresh() { function refresh() {
os.api('admin/ad/list', { publishing: publishing }).then(adsResponse => { misskeyApi('admin/ad/list', { publishing: publishing }).then(adsResponse => {
if (adsResponse == null) return; if (adsResponse == null) return;
ads.value = adsResponse.map(r => { ads.value = adsResponse.map(r => {
const exdate = new Date(r.expiresAt); const exdate = new Date(r.expiresAt);

View file

@ -79,6 +79,7 @@ import MkSwitch from '@/components/MkSwitch.vue';
import MkRadios from '@/components/MkRadios.vue'; import MkRadios from '@/components/MkRadios.vue';
import MkInfo from '@/components/MkInfo.vue'; import MkInfo from '@/components/MkInfo.vue';
import * as os from '@/os.js'; import * as os from '@/os.js';
import { misskeyApi } from '@/scripts/misskey-api.js';
import { i18n } from '@/i18n.js'; import { i18n } from '@/i18n.js';
import { definePageMetadata } from '@/scripts/page-metadata.js'; import { definePageMetadata } from '@/scripts/page-metadata.js';
import MkFolder from '@/components/MkFolder.vue'; import MkFolder from '@/components/MkFolder.vue';
@ -86,7 +87,7 @@ import MkTextarea from '@/components/MkTextarea.vue';
const announcements = ref<any[]>([]); const announcements = ref<any[]>([]);
os.api('admin/announcements/list').then(announcementResponse => { misskeyApi('admin/announcements/list').then(announcementResponse => {
announcements.value = announcementResponse; announcements.value = announcementResponse;
}); });
@ -112,7 +113,7 @@ function del(announcement) {
}).then(({ canceled }) => { }).then(({ canceled }) => {
if (canceled) return; if (canceled) return;
announcements.value = announcements.value.filter(x => x !== announcement); announcements.value = announcements.value.filter(x => x !== announcement);
os.api('admin/announcements/delete', announcement); misskeyApi('admin/announcements/delete', announcement);
}); });
} }
@ -134,13 +135,13 @@ async function save(announcement) {
} }
function more() { function more() {
os.api('admin/announcements/list', { untilId: announcements.value.reduce((acc, announcement) => announcement.id != null ? announcement : acc).id }).then(announcementResponse => { misskeyApi('admin/announcements/list', { untilId: announcements.value.reduce((acc, announcement) => announcement.id != null ? announcement : acc).id }).then(announcementResponse => {
announcements.value = announcements.value.concat(announcementResponse); announcements.value = announcements.value.concat(announcementResponse);
}); });
} }
function refresh() { function refresh() {
os.api('admin/announcements/list').then(announcementResponse => { misskeyApi('admin/announcements/list').then(announcementResponse => {
announcements.value = announcementResponse; announcements.value = announcementResponse;
}); });
} }

View file

@ -72,6 +72,7 @@ import MkButton from '@/components/MkButton.vue';
import FormSuspense from '@/components/form/suspense.vue'; import FormSuspense from '@/components/form/suspense.vue';
import FormSlot from '@/components/form/slot.vue'; import FormSlot from '@/components/form/slot.vue';
import * as os from '@/os.js'; import * as os from '@/os.js';
import { misskeyApi } from '@/scripts/misskey-api.js';
import { fetchInstance } from '@/instance.js'; import { fetchInstance } from '@/instance.js';
import { i18n } from '@/i18n.js'; import { i18n } from '@/i18n.js';
@ -86,7 +87,7 @@ const turnstileSiteKey = ref<string | null>(null);
const turnstileSecretKey = ref<string | null>(null); const turnstileSecretKey = ref<string | null>(null);
async function init() { async function init() {
const meta = await os.api('admin/meta'); const meta = await misskeyApi('admin/meta');
hcaptchaSiteKey.value = meta.hcaptchaSiteKey; hcaptchaSiteKey.value = meta.hcaptchaSiteKey;
hcaptchaSecretKey.value = meta.hcaptchaSecretKey; hcaptchaSecretKey.value = meta.hcaptchaSecretKey;
recaptchaSiteKey.value = meta.recaptchaSiteKey; recaptchaSiteKey.value = meta.recaptchaSiteKey;

View file

@ -101,6 +101,7 @@ import MkInput from '@/components/MkInput.vue';
import MkTextarea from '@/components/MkTextarea.vue'; import MkTextarea from '@/components/MkTextarea.vue';
import FormSuspense from '@/components/form/suspense.vue'; import FormSuspense from '@/components/form/suspense.vue';
import * as os from '@/os.js'; import * as os from '@/os.js';
import { misskeyApi } from '@/scripts/misskey-api.js';
import { instance, fetchInstance } from '@/instance.js'; import { instance, fetchInstance } from '@/instance.js';
import { i18n } from '@/i18n.js'; import { i18n } from '@/i18n.js';
import { definePageMetadata } from '@/scripts/page-metadata.js'; import { definePageMetadata } from '@/scripts/page-metadata.js';
@ -122,7 +123,7 @@ const notFoundImageUrl = ref<string | null>(null);
const manifestJsonOverride = ref<string>('{}'); const manifestJsonOverride = ref<string>('{}');
async function init() { async function init() {
const meta = await os.api('admin/meta'); const meta = await misskeyApi('admin/meta');
iconUrl.value = meta.iconUrl; iconUrl.value = meta.iconUrl;
app192IconUrl.value = meta.app192IconUrl; app192IconUrl.value = meta.app192IconUrl;
app512IconUrl.value = meta.app512IconUrl; app512IconUrl.value = meta.app512IconUrl;

View file

@ -21,13 +21,13 @@ SPDX-License-Identifier: AGPL-3.0-only
import { computed } from 'vue'; import { computed } from 'vue';
import FormSuspense from '@/components/form/suspense.vue'; import FormSuspense from '@/components/form/suspense.vue';
import MkKeyValue from '@/components/MkKeyValue.vue'; import MkKeyValue from '@/components/MkKeyValue.vue';
import * as os from '@/os.js'; import { misskeyApi } from '@/scripts/misskey-api.js';
import bytes from '@/filters/bytes.js'; import bytes from '@/filters/bytes.js';
import number from '@/filters/number.js'; import number from '@/filters/number.js';
import { i18n } from '@/i18n.js'; import { i18n } from '@/i18n.js';
import { definePageMetadata } from '@/scripts/page-metadata.js'; import { definePageMetadata } from '@/scripts/page-metadata.js';
const databasePromiseFactory = () => os.api('admin/get-table-stats').then(res => Object.entries(res).sort((a, b) => b[1].size - a[1].size)); const databasePromiseFactory = () => misskeyApi('admin/get-table-stats').then(res => Object.entries(res).sort((a, b) => b[1].size - a[1].size));
const headerActions = computed(() => []); const headerActions = computed(() => []);

View file

@ -73,6 +73,7 @@ import FormSuspense from '@/components/form/suspense.vue';
import FormSplit from '@/components/form/split.vue'; import FormSplit from '@/components/form/split.vue';
import FormSection from '@/components/form/section.vue'; import FormSection from '@/components/form/section.vue';
import * as os from '@/os.js'; import * as os from '@/os.js';
import { misskeyApi } from '@/scripts/misskey-api.js';
import { fetchInstance, instance } from '@/instance.js'; import { fetchInstance, instance } from '@/instance.js';
import { i18n } from '@/i18n.js'; import { i18n } from '@/i18n.js';
import { definePageMetadata } from '@/scripts/page-metadata.js'; import { definePageMetadata } from '@/scripts/page-metadata.js';
@ -87,7 +88,7 @@ const smtpUser = ref<string>('');
const smtpPass = ref<string>(''); const smtpPass = ref<string>('');
async function init() { async function init() {
const meta = await os.api('admin/meta'); const meta = await misskeyApi('admin/meta');
enableEmail.value = meta.enableEmail; enableEmail.value = meta.enableEmail;
email.value = meta.email; email.value = meta.email;
smtpSecure.value = meta.smtpSecure; smtpSecure.value = meta.smtpSecure;

View file

@ -42,6 +42,7 @@ import MkSwitch from '@/components/MkSwitch.vue';
import FormSuspense from '@/components/form/suspense.vue'; import FormSuspense from '@/components/form/suspense.vue';
import FormSection from '@/components/form/section.vue'; import FormSection from '@/components/form/section.vue';
import * as os from '@/os.js'; import * as os from '@/os.js';
import { misskeyApi } from '@/scripts/misskey-api.js';
import { fetchInstance } from '@/instance.js'; import { fetchInstance } from '@/instance.js';
import { i18n } from '@/i18n.js'; import { i18n } from '@/i18n.js';
import { definePageMetadata } from '@/scripts/page-metadata.js'; import { definePageMetadata } from '@/scripts/page-metadata.js';
@ -50,7 +51,7 @@ const deeplAuthKey = ref<string>('');
const deeplIsPro = ref<boolean>(false); const deeplIsPro = ref<boolean>(false);
async function init() { async function init() {
const meta = await os.api('admin/meta'); const meta = await misskeyApi('admin/meta');
deeplAuthKey.value = meta.deeplAuthKey; deeplAuthKey.value = meta.deeplAuthKey;
deeplIsPro.value = meta.deeplIsPro; deeplIsPro.value = meta.deeplIsPro;
} }

View file

@ -42,6 +42,7 @@ import MkInput from '@/components/MkInput.vue';
import MkSelect from '@/components/MkSelect.vue'; import MkSelect from '@/components/MkSelect.vue';
import MkFileListForAdmin from '@/components/MkFileListForAdmin.vue'; import MkFileListForAdmin from '@/components/MkFileListForAdmin.vue';
import * as os from '@/os.js'; import * as os from '@/os.js';
import { misskeyApi } from '@/scripts/misskey-api.js';
import { i18n } from '@/i18n.js'; import { i18n } from '@/i18n.js';
import { definePageMetadata } from '@/scripts/page-metadata.js'; import { definePageMetadata } from '@/scripts/page-metadata.js';
@ -83,7 +84,7 @@ async function find() {
}); });
if (canceled) return; if (canceled) return;
os.api('admin/drive/show-file', q.startsWith('http://') || q.startsWith('https://') ? { url: q.trim() } : { fileId: q.trim() }).then(file => { misskeyApi('admin/drive/show-file', q.startsWith('http://') || q.startsWith('https://') ? { url: q.trim() } : { fileId: q.trim() }).then(file => {
show(file); show(file);
}).catch(err => { }).catch(err => {
if (err.code === 'NO_SUCH_FILE') { if (err.code === 'NO_SUCH_FILE') {

View file

@ -34,6 +34,7 @@ import MkSuperMenu from '@/components/MkSuperMenu.vue';
import MkInfo from '@/components/MkInfo.vue'; import MkInfo from '@/components/MkInfo.vue';
import { instance } from '@/instance.js'; import { instance } from '@/instance.js';
import * as os from '@/os.js'; import * as os from '@/os.js';
import { misskeyApi } from '@/scripts/misskey-api.js';
import { lookupUser, lookupUserByEmail } from '@/scripts/lookup-user.js'; import { lookupUser, lookupUserByEmail } from '@/scripts/lookup-user.js';
import { useRouter } from '@/router.js'; import { useRouter } from '@/router.js';
import { PageMetadata, definePageMetadata, provideMetadataReceiver } from '@/scripts/page-metadata.js'; import { PageMetadata, definePageMetadata, provideMetadataReceiver } from '@/scripts/page-metadata.js';
@ -62,7 +63,7 @@ let noEmailServer = !instance.enableEmail;
const thereIsUnresolvedAbuseReport = ref(false); const thereIsUnresolvedAbuseReport = ref(false);
const currentPage = computed(() => router.currentRef.value.child); const currentPage = computed(() => router.currentRef.value.child);
os.api('admin/abuse-user-reports', { misskeyApi('admin/abuse-user-reports', {
state: 'unresolved', state: 'unresolved',
limit: 1, limit: 1,
}).then(reports => { }).then(reports => {
@ -266,7 +267,7 @@ provideMetadataReceiver((info) => {
}); });
function invite() { function invite() {
os.api('admin/invite/create').then(x => { misskeyApi('admin/invite/create').then(x => {
os.alert({ os.alert({
type: 'info', type: 'info',
text: x[0].code, text: x[0].code,

View file

@ -29,6 +29,7 @@ import MkButton from '@/components/MkButton.vue';
import MkTextarea from '@/components/MkTextarea.vue'; import MkTextarea from '@/components/MkTextarea.vue';
import FormSuspense from '@/components/form/suspense.vue'; import FormSuspense from '@/components/form/suspense.vue';
import * as os from '@/os.js'; import * as os from '@/os.js';
import { misskeyApi } from '@/scripts/misskey-api.js';
import { fetchInstance } from '@/instance.js'; import { fetchInstance } from '@/instance.js';
import { i18n } from '@/i18n.js'; import { i18n } from '@/i18n.js';
import { definePageMetadata } from '@/scripts/page-metadata.js'; import { definePageMetadata } from '@/scripts/page-metadata.js';
@ -38,7 +39,7 @@ const silencedHosts = ref<string>('');
const tab = ref('block'); const tab = ref('block');
async function init() { async function init() {
const meta = await os.api('admin/meta'); const meta = await misskeyApi('admin/meta');
blockedHosts.value = meta.blockedHosts.join('\n'); blockedHosts.value = meta.blockedHosts.join('\n');
silencedHosts.value = meta.silencedHosts.join('\n'); silencedHosts.value = meta.silencedHosts.join('\n');
} }

View file

@ -59,6 +59,7 @@ import { computed, ref, shallowRef } from 'vue';
import XHeader from './_header_.vue'; import XHeader from './_header_.vue';
import { i18n } from '@/i18n.js'; import { i18n } from '@/i18n.js';
import * as os from '@/os.js'; import * as os from '@/os.js';
import { misskeyApi } from '@/scripts/misskey-api.js';
import MkButton from '@/components/MkButton.vue'; import MkButton from '@/components/MkButton.vue';
import MkFolder from '@/components/MkFolder.vue'; import MkFolder from '@/components/MkFolder.vue';
import MkSelect from '@/components/MkSelect.vue'; import MkSelect from '@/components/MkSelect.vue';
@ -93,14 +94,14 @@ async function createWithOptions() {
count: createCount.value, count: createCount.value,
}; };
const tickets = await os.api('admin/invite/create', options); const tickets = await misskeyApi('admin/invite/create', options);
os.alert({ os.alert({
type: 'success', type: 'success',
title: i18n.ts.inviteCodeCreated, title: i18n.ts.inviteCodeCreated,
text: tickets?.map(x => x.code).join('\n'), text: tickets.map(x => x.code).join('\n'),
}); });
tickets?.forEach(ticket => pagingComponent.value?.prepend(ticket)); tickets.forEach(ticket => pagingComponent.value?.prepend(ticket));
} }
function deleted(id: string) { function deleted(id: string) {

View file

@ -66,6 +66,7 @@ import MkInput from '@/components/MkInput.vue';
import MkTextarea from '@/components/MkTextarea.vue'; import MkTextarea from '@/components/MkTextarea.vue';
import FormSuspense from '@/components/form/suspense.vue'; import FormSuspense from '@/components/form/suspense.vue';
import * as os from '@/os.js'; import * as os from '@/os.js';
import { misskeyApi } from '@/scripts/misskey-api.js';
import { fetchInstance } from '@/instance.js'; import { fetchInstance } from '@/instance.js';
import { i18n } from '@/i18n.js'; import { i18n } from '@/i18n.js';
import { definePageMetadata } from '@/scripts/page-metadata.js'; import { definePageMetadata } from '@/scripts/page-metadata.js';
@ -81,7 +82,7 @@ const tosUrl = ref<string | null>(null);
const privacyPolicyUrl = ref<string | null>(null); const privacyPolicyUrl = ref<string | null>(null);
async function init() { async function init() {
const meta = await os.api('admin/meta'); const meta = await misskeyApi('admin/meta');
enableRegistration.value = !meta.disableRegistration; enableRegistration.value = !meta.disableRegistration;
emailRequiredForSignup.value = meta.emailRequiredForSignup; emailRequiredForSignup.value = meta.emailRequiredForSignup;
sensitiveWords.value = meta.sensitiveWords.join('\n'); sensitiveWords.value = meta.sensitiveWords.join('\n');

View file

@ -90,6 +90,7 @@ import MkInput from '@/components/MkInput.vue';
import FormSuspense from '@/components/form/suspense.vue'; import FormSuspense from '@/components/form/suspense.vue';
import FormSplit from '@/components/form/split.vue'; import FormSplit from '@/components/form/split.vue';
import * as os from '@/os.js'; import * as os from '@/os.js';
import { misskeyApi } from '@/scripts/misskey-api.js';
import { fetchInstance } from '@/instance.js'; import { fetchInstance } from '@/instance.js';
import { i18n } from '@/i18n.js'; import { i18n } from '@/i18n.js';
import { definePageMetadata } from '@/scripts/page-metadata.js'; import { definePageMetadata } from '@/scripts/page-metadata.js';
@ -110,7 +111,7 @@ const objectStorageSetPublicRead = ref<boolean>(false);
const objectStorageS3ForcePathStyle = ref<boolean>(true); const objectStorageS3ForcePathStyle = ref<boolean>(true);
async function init() { async function init() {
const meta = await os.api('admin/meta'); const meta = await misskeyApi('admin/meta');
useObjectStorage.value = meta.useObjectStorage; useObjectStorage.value = meta.useObjectStorage;
objectStorageBaseUrl.value = meta.objectStorageBaseUrl; objectStorageBaseUrl.value = meta.objectStorageBaseUrl;
objectStorageBucket.value = meta.objectStorageBucket; objectStorageBucket.value = meta.objectStorageBucket;

View file

@ -47,6 +47,7 @@ import { ref, computed } from 'vue';
import XHeader from './_header_.vue'; import XHeader from './_header_.vue';
import FormSuspense from '@/components/form/suspense.vue'; import FormSuspense from '@/components/form/suspense.vue';
import * as os from '@/os.js'; import * as os from '@/os.js';
import { misskeyApi } from '@/scripts/misskey-api.js';
import { fetchInstance } from '@/instance.js'; import { fetchInstance } from '@/instance.js';
import { i18n } from '@/i18n.js'; import { i18n } from '@/i18n.js';
import { definePageMetadata } from '@/scripts/page-metadata.js'; import { definePageMetadata } from '@/scripts/page-metadata.js';
@ -58,7 +59,7 @@ const enableChartsForRemoteUser = ref<boolean>(false);
const enableChartsForFederatedInstances = ref<boolean>(false); const enableChartsForFederatedInstances = ref<boolean>(false);
async function init() { async function init() {
const meta = await os.api('admin/meta'); const meta = await misskeyApi('admin/meta');
enableServerMachineStats.value = meta.enableServerMachineStats; enableServerMachineStats.value = meta.enableServerMachineStats;
enableIdenticonGeneration.value = meta.enableIdenticonGeneration; enableIdenticonGeneration.value = meta.enableIdenticonGeneration;
enableChartsForRemoteUser.value = meta.enableChartsForRemoteUser; enableChartsForRemoteUser.value = meta.enableChartsForRemoteUser;

View file

@ -16,7 +16,7 @@ SPDX-License-Identifier: AGPL-3.0-only
import { onMounted, shallowRef, ref } from 'vue'; import { onMounted, shallowRef, ref } from 'vue';
import { Chart } from 'chart.js'; import { Chart } from 'chart.js';
import gradient from 'chartjs-plugin-gradient'; import gradient from 'chartjs-plugin-gradient';
import * as os from '@/os.js'; import { misskeyApi } from '@/scripts/misskey-api.js';
import { defaultStore } from '@/store.js'; import { defaultStore } from '@/store.js';
import { useChartTooltip } from '@/scripts/use-chart-tooltip.js'; import { useChartTooltip } from '@/scripts/use-chart-tooltip.js';
import { chartVLine } from '@/scripts/chart-vline.js'; import { chartVLine } from '@/scripts/chart-vline.js';
@ -52,7 +52,7 @@ async function renderChart() {
})); }));
}; };
const raw = await os.api('charts/active-users', { limit: chartLimit, span: 'day' }); const raw = await misskeyApi('charts/active-users', { limit: chartLimit, span: 'day' });
const vLineColor = defaultStore.state.darkMode ? 'rgba(255, 255, 255, 0.2)' : 'rgba(0, 0, 0, 0.2)'; const vLineColor = defaultStore.state.darkMode ? 'rgba(255, 255, 255, 0.2)' : 'rgba(0, 0, 0, 0.2)';

View file

@ -23,7 +23,7 @@ SPDX-License-Identifier: AGPL-3.0-only
import { onMounted, shallowRef, ref } from 'vue'; import { onMounted, shallowRef, ref } from 'vue';
import { Chart } from 'chart.js'; import { Chart } from 'chart.js';
import gradient from 'chartjs-plugin-gradient'; import gradient from 'chartjs-plugin-gradient';
import * as os from '@/os.js'; import { misskeyApi } from '@/scripts/misskey-api.js';
import { useChartTooltip } from '@/scripts/use-chart-tooltip.js'; import { useChartTooltip } from '@/scripts/use-chart-tooltip.js';
import { chartVLine } from '@/scripts/chart-vline.js'; import { chartVLine } from '@/scripts/chart-vline.js';
import { defaultStore } from '@/store.js'; import { defaultStore } from '@/store.js';
@ -65,7 +65,7 @@ onMounted(async () => {
})); }));
}; };
const raw = await os.api('charts/ap-request', { limit: chartLimit, span: 'day' }); const raw = await misskeyApi('charts/ap-request', { limit: chartLimit, span: 'day' });
const vLineColor = defaultStore.state.darkMode ? 'rgba(255, 255, 255, 0.2)' : 'rgba(0, 0, 0, 0.2)'; const vLineColor = defaultStore.state.darkMode ? 'rgba(255, 255, 255, 0.2)' : 'rgba(0, 0, 0, 0.2)';
const succColor = '#87e000'; const succColor = '#87e000';

View file

@ -49,6 +49,7 @@ SPDX-License-Identifier: AGPL-3.0-only
import { onMounted, ref } from 'vue'; import { onMounted, ref } from 'vue';
import XPie, { type InstanceForPie } from './overview.pie.vue'; import XPie, { type InstanceForPie } from './overview.pie.vue';
import * as os from '@/os.js'; import * as os from '@/os.js';
import { misskeyApiGet } from '@/scripts/misskey-api.js';
import number from '@/filters/number.js'; import number from '@/filters/number.js';
import MkNumberDiff from '@/components/MkNumberDiff.vue'; import MkNumberDiff from '@/components/MkNumberDiff.vue';
import { i18n } from '@/i18n.js'; import { i18n } from '@/i18n.js';
@ -65,13 +66,13 @@ const fetching = ref(true);
const { handler: externalTooltipHandler } = useChartTooltip(); const { handler: externalTooltipHandler } = useChartTooltip();
onMounted(async () => { onMounted(async () => {
const chart = await os.apiGet('charts/federation', { limit: 2, span: 'day' }); const chart = await misskeyApiGet('charts/federation', { limit: 2, span: 'day' });
federationPubActive.value = chart.pubActive[0]; federationPubActive.value = chart.pubActive[0];
federationPubActiveDiff.value = chart.pubActive[0] - chart.pubActive[1]; federationPubActiveDiff.value = chart.pubActive[0] - chart.pubActive[1];
federationSubActive.value = chart.subActive[0]; federationSubActive.value = chart.subActive[0];
federationSubActiveDiff.value = chart.subActive[0] - chart.subActive[1]; federationSubActiveDiff.value = chart.subActive[0] - chart.subActive[1];
os.apiGet('federation/stats', { limit: 10 }).then(res => { misskeyApiGet('federation/stats', { limit: 10 }).then(res => {
topSubInstancesForPie.value = [ topSubInstancesForPie.value = [
...res.topSubInstances.map(x => ({ ...res.topSubInstances.map(x => ({
name: x.host, name: x.host,

View file

@ -18,8 +18,8 @@ SPDX-License-Identifier: AGPL-3.0-only
<script lang="ts" setup> <script lang="ts" setup>
import { ref } from 'vue'; import { ref } from 'vue';
import { misskeyApi } from '@/scripts/misskey-api.js';
import * as Misskey from 'misskey-js'; import * as Misskey from 'misskey-js';
import * as os from '@/os.js';
import { useInterval } from '@/scripts/use-interval.js'; import { useInterval } from '@/scripts/use-interval.js';
import MkInstanceCardMini from '@/components/MkInstanceCardMini.vue'; import MkInstanceCardMini from '@/components/MkInstanceCardMini.vue';
import { defaultStore } from '@/store.js'; import { defaultStore } from '@/store.js';
@ -28,7 +28,7 @@ const instances = ref<Misskey.entities.FederationInstance[]>([]);
const fetching = ref(true); const fetching = ref(true);
const fetch = async () => { const fetch = async () => {
const fetchedInstances = await os.api('federation/instances', { const fetchedInstances = await misskeyApi('federation/instances', {
sort: '+latestRequestReceivedAt', sort: '+latestRequestReceivedAt',
limit: 6, limit: 6,
}); });

View file

@ -18,15 +18,15 @@ SPDX-License-Identifier: AGPL-3.0-only
<script lang="ts" setup> <script lang="ts" setup>
import { onMounted, ref } from 'vue'; import { onMounted, ref } from 'vue';
import { misskeyApi } from '@/scripts/misskey-api.js';
import * as Misskey from 'misskey-js'; import * as Misskey from 'misskey-js';
import * as os from '@/os.js';
import { defaultStore } from '@/store.js'; import { defaultStore } from '@/store.js';
const moderators = ref<Misskey.entities.UserDetailed[] | null>(null); const moderators = ref<Misskey.entities.UserDetailed[] | null>(null);
const fetching = ref(true); const fetching = ref(true);
onMounted(async () => { onMounted(async () => {
moderators.value = await os.api('admin/show-users', { moderators.value = await misskeyApi('admin/show-users', {
sort: '+lastActiveDate', sort: '+lastActiveDate',
state: 'adminOrModerator', state: 'adminOrModerator',
limit: 30, limit: 30,

View file

@ -63,7 +63,7 @@ SPDX-License-Identifier: AGPL-3.0-only
<script lang="ts" setup> <script lang="ts" setup>
import { onMounted, ref } from 'vue'; import { onMounted, ref } from 'vue';
import * as Misskey from 'misskey-js'; import * as Misskey from 'misskey-js';
import * as os from '@/os.js'; import { misskeyApi, misskeyApiGet } from '@/scripts/misskey-api.js';
import MkNumberDiff from '@/components/MkNumberDiff.vue'; import MkNumberDiff from '@/components/MkNumberDiff.vue';
import MkNumber from '@/components/MkNumber.vue'; import MkNumber from '@/components/MkNumber.vue';
import { i18n } from '@/i18n.js'; import { i18n } from '@/i18n.js';
@ -78,17 +78,17 @@ const fetching = ref(true);
onMounted(async () => { onMounted(async () => {
const [_stats, _onlineUsersCount] = await Promise.all([ const [_stats, _onlineUsersCount] = await Promise.all([
os.api('stats', {}), misskeyApi('stats', {}),
os.apiGet('get-online-users-count').then(res => res.count), misskeyApiGet('get-online-users-count').then(res => res.count),
]); ]);
stats.value = _stats; stats.value = _stats;
onlineUsersCount.value = _onlineUsersCount; onlineUsersCount.value = _onlineUsersCount;
os.apiGet('charts/users', { limit: 2, span: 'day' }).then(chart => { misskeyApiGet('charts/users', { limit: 2, span: 'day' }).then(chart => {
usersComparedToThePrevDay.value = stats.value.originalUsersCount - chart.local.total[1]; usersComparedToThePrevDay.value = stats.value.originalUsersCount - chart.local.total[1];
}); });
os.apiGet('charts/notes', { limit: 2, span: 'day' }).then(chart => { misskeyApiGet('charts/notes', { limit: 2, span: 'day' }).then(chart => {
notesComparedToThePrevDay.value = stats.value.originalNotesCount - chart.local.total[1]; notesComparedToThePrevDay.value = stats.value.originalNotesCount - chart.local.total[1];
}); });

View file

@ -18,8 +18,8 @@ SPDX-License-Identifier: AGPL-3.0-only
<script lang="ts" setup> <script lang="ts" setup>
import { ref } from 'vue'; import { ref } from 'vue';
import { misskeyApi } from '@/scripts/misskey-api.js';
import * as Misskey from 'misskey-js'; import * as Misskey from 'misskey-js';
import * as os from '@/os.js';
import { useInterval } from '@/scripts/use-interval.js'; import { useInterval } from '@/scripts/use-interval.js';
import MkUserCardMini from '@/components/MkUserCardMini.vue'; import MkUserCardMini from '@/components/MkUserCardMini.vue';
import { defaultStore } from '@/store.js'; import { defaultStore } from '@/store.js';
@ -28,7 +28,7 @@ const newUsers = ref<Misskey.entities.UserDetailed[] | null>(null);
const fetching = ref(true); const fetching = ref(true);
const fetch = async () => { const fetch = async () => {
const _newUsers = await os.api('admin/show-users', { const _newUsers = await misskeyApi('admin/show-users', {
limit: 5, limit: 5,
sort: '+createdAt', sort: '+createdAt',
origin: 'local', origin: 'local',

View file

@ -79,6 +79,7 @@ import XModerators from './overview.moderators.vue';
import XHeatmap from './overview.heatmap.vue'; import XHeatmap from './overview.heatmap.vue';
import type { InstanceForPie } from './overview.pie.vue'; import type { InstanceForPie } from './overview.pie.vue';
import * as os from '@/os.js'; import * as os from '@/os.js';
import { misskeyApi, misskeyApiGet } from '@/scripts/misskey-api.js';
import { useStream } from '@/stream.js'; import { useStream } from '@/stream.js';
import { i18n } from '@/i18n.js'; import { i18n } from '@/i18n.js';
import { definePageMetadata } from '@/scripts/page-metadata.js'; import { definePageMetadata } from '@/scripts/page-metadata.js';
@ -117,14 +118,14 @@ onMounted(async () => {
magicGrid.listen(); magicGrid.listen();
*/ */
os.apiGet('charts/federation', { limit: 2, span: 'day' }).then(chart => { misskeyApiGet('charts/federation', { limit: 2, span: 'day' }).then(chart => {
federationPubActive.value = chart.pubActive[0]; federationPubActive.value = chart.pubActive[0];
federationPubActiveDiff.value = chart.pubActive[0] - chart.pubActive[1]; federationPubActiveDiff.value = chart.pubActive[0] - chart.pubActive[1];
federationSubActive.value = chart.subActive[0]; federationSubActive.value = chart.subActive[0];
federationSubActiveDiff.value = chart.subActive[0] - chart.subActive[1]; federationSubActiveDiff.value = chart.subActive[0] - chart.subActive[1];
}); });
os.apiGet('federation/stats', { limit: 10 }).then(res => { misskeyApiGet('federation/stats', { limit: 10 }).then(res => {
topSubInstancesForPie.value = [ topSubInstancesForPie.value = [
...res.topSubInstances.map(x => ({ ...res.topSubInstances.map(x => ({
name: x.host, name: x.host,
@ -149,18 +150,18 @@ onMounted(async () => {
]; ];
}); });
os.api('admin/server-info').then(serverInfoResponse => { misskeyApi('admin/server-info').then(serverInfoResponse => {
serverInfo.value = serverInfoResponse; serverInfo.value = serverInfoResponse;
}); });
os.api('admin/show-users', { misskeyApi('admin/show-users', {
limit: 5, limit: 5,
sort: '+createdAt', sort: '+createdAt',
}).then(res => { }).then(res => {
newUsers.value = res; newUsers.value = res;
}); });
os.api('federation/instances', { misskeyApi('federation/instances', {
sort: '+latestRequestReceivedAt', sort: '+latestRequestReceivedAt',
limit: 25, limit: 25,
}).then(res => { }).then(res => {

View file

@ -28,6 +28,7 @@ import MkButton from '@/components/MkButton.vue';
import MkInfo from '@/components/MkInfo.vue'; import MkInfo from '@/components/MkInfo.vue';
import FormSuspense from '@/components/form/suspense.vue'; import FormSuspense from '@/components/form/suspense.vue';
import * as os from '@/os.js'; import * as os from '@/os.js';
import { misskeyApi } from '@/scripts/misskey-api.js';
import { fetchInstance } from '@/instance.js'; import { fetchInstance } from '@/instance.js';
import { i18n } from '@/i18n.js'; import { i18n } from '@/i18n.js';
import { definePageMetadata } from '@/scripts/page-metadata.js'; import { definePageMetadata } from '@/scripts/page-metadata.js';
@ -36,10 +37,10 @@ const proxyAccount = ref<Misskey.entities.UserDetailed | null>(null);
const proxyAccountId = ref<string | null>(null); const proxyAccountId = ref<string | null>(null);
async function init() { async function init() {
const meta = await os.api('admin/meta'); const meta = await misskeyApi('admin/meta');
proxyAccountId.value = meta.proxyAccountId; proxyAccountId.value = meta.proxyAccountId;
if (proxyAccountId.value) { if (proxyAccountId.value) {
proxyAccount.value = await os.api('users/show', { userId: proxyAccountId.value }); proxyAccount.value = await misskeyApi('users/show', { userId: proxyAccountId.value });
} }
} }

View file

@ -51,7 +51,7 @@ SPDX-License-Identifier: AGPL-3.0-only
import { markRaw, onMounted, onUnmounted, ref, shallowRef } from 'vue'; import { markRaw, onMounted, onUnmounted, ref, shallowRef } from 'vue';
import XChart from './queue.chart.chart.vue'; import XChart from './queue.chart.chart.vue';
import number from '@/filters/number.js'; import number from '@/filters/number.js';
import * as os from '@/os.js'; import { misskeyApi } from '@/scripts/misskey-api.js';
import { useStream } from '@/stream.js'; import { useStream } from '@/stream.js';
import { i18n } from '@/i18n.js'; import { i18n } from '@/i18n.js';
import MkFolder from '@/components/MkFolder.vue'; import MkFolder from '@/components/MkFolder.vue';
@ -105,7 +105,7 @@ const onStatsLog = (statsLog) => {
onMounted(() => { onMounted(() => {
if (props.domain === 'inbox' || props.domain === 'deliver') { if (props.domain === 'inbox' || props.domain === 'deliver') {
os.api(`admin/queue/${props.domain}-delayed`).then(result => { misskeyApi(`admin/queue/${props.domain}-delayed`).then(result => {
jobs.value = result; jobs.value = result;
}); });
} }

View file

@ -29,6 +29,7 @@ import * as Misskey from 'misskey-js';
import XHeader from './_header_.vue'; import XHeader from './_header_.vue';
import MkButton from '@/components/MkButton.vue'; import MkButton from '@/components/MkButton.vue';
import * as os from '@/os.js'; import * as os from '@/os.js';
import { misskeyApi } from '@/scripts/misskey-api.js';
import { i18n } from '@/i18n.js'; import { i18n } from '@/i18n.js';
import { definePageMetadata } from '@/scripts/page-metadata.js'; import { definePageMetadata } from '@/scripts/page-metadata.js';
@ -41,7 +42,7 @@ async function addRelay() {
placeholder: i18n.ts.inboxUrl, placeholder: i18n.ts.inboxUrl,
}); });
if (canceled) return; if (canceled) return;
os.api('admin/relays/add', { misskeyApi('admin/relays/add', {
inbox, inbox,
}).then((relay: any) => { }).then((relay: any) => {
refresh(); refresh();
@ -54,7 +55,7 @@ async function addRelay() {
} }
function remove(inbox: string) { function remove(inbox: string) {
os.api('admin/relays/remove', { misskeyApi('admin/relays/remove', {
inbox, inbox,
}).then(() => { }).then(() => {
refresh(); refresh();
@ -67,7 +68,7 @@ function remove(inbox: string) {
} }
function refresh() { function refresh() {
os.api('admin/relays/list').then(relayList => { misskeyApi('admin/relays/list').then(relayList => {
relays.value = relayList; relays.value = relayList;
}); });
} }

View file

@ -28,6 +28,7 @@ import { v4 as uuid } from 'uuid';
import XHeader from './_header_.vue'; import XHeader from './_header_.vue';
import XEditor from './roles.editor.vue'; import XEditor from './roles.editor.vue';
import * as os from '@/os.js'; import * as os from '@/os.js';
import { misskeyApi } from '@/scripts/misskey-api.js';
import { i18n } from '@/i18n.js'; import { i18n } from '@/i18n.js';
import { definePageMetadata } from '@/scripts/page-metadata.js'; import { definePageMetadata } from '@/scripts/page-metadata.js';
import { useRouter } from '@/router.js'; import { useRouter } from '@/router.js';
@ -44,7 +45,7 @@ const role = ref<Misskey.entities.Role | null>(null);
const data = ref<any>(null); const data = ref<any>(null);
if (props.id) { if (props.id) {
role.value = await os.api('admin/roles/show', { role.value = await misskeyApi('admin/roles/show', {
roleId: props.id, roleId: props.id,
}); });

View file

@ -67,6 +67,7 @@ import XHeader from './_header_.vue';
import XEditor from './roles.editor.vue'; import XEditor from './roles.editor.vue';
import MkFolder from '@/components/MkFolder.vue'; import MkFolder from '@/components/MkFolder.vue';
import * as os from '@/os.js'; import * as os from '@/os.js';
import { misskeyApi } from '@/scripts/misskey-api.js';
import { i18n } from '@/i18n.js'; import { i18n } from '@/i18n.js';
import { definePageMetadata } from '@/scripts/page-metadata.js'; import { definePageMetadata } from '@/scripts/page-metadata.js';
import { useRouter } from '@/router.js'; import { useRouter } from '@/router.js';
@ -92,7 +93,7 @@ const usersPagination = {
const expandedItems = ref([]); const expandedItems = ref([]);
const role = reactive(await os.api('admin/roles/show', { const role = reactive(await misskeyApi('admin/roles/show', {
roleId: props.id, roleId: props.id,
})); }));

View file

@ -233,6 +233,7 @@ import MkButton from '@/components/MkButton.vue';
import MkRange from '@/components/MkRange.vue'; import MkRange from '@/components/MkRange.vue';
import MkRolePreview from '@/components/MkRolePreview.vue'; import MkRolePreview from '@/components/MkRolePreview.vue';
import * as os from '@/os.js'; import * as os from '@/os.js';
import { misskeyApi } from '@/scripts/misskey-api.js';
import { i18n } from '@/i18n.js'; import { i18n } from '@/i18n.js';
import { definePageMetadata } from '@/scripts/page-metadata.js'; import { definePageMetadata } from '@/scripts/page-metadata.js';
import { instance } from '@/instance.js'; import { instance } from '@/instance.js';
@ -243,7 +244,7 @@ import { ROLE_POLICIES } from '@/const.js';
const router = useRouter(); const router = useRouter();
const baseRoleQ = ref(''); const baseRoleQ = ref('');
const roles = await os.api('admin/roles/list'); const roles = await misskeyApi('admin/roles/list');
const policies = reactive<Record<typeof ROLE_POLICIES[number], any>>({}); const policies = reactive<Record<typeof ROLE_POLICIES[number], any>>({});
for (const ROLE_POLICY of ROLE_POLICIES) { for (const ROLE_POLICY of ROLE_POLICIES) {

View file

@ -148,6 +148,7 @@ import MkInput from '@/components/MkInput.vue';
import MkButton from '@/components/MkButton.vue'; import MkButton from '@/components/MkButton.vue';
import MkTextarea from '@/components/MkTextarea.vue'; import MkTextarea from '@/components/MkTextarea.vue';
import * as os from '@/os.js'; import * as os from '@/os.js';
import { misskeyApi } from '@/scripts/misskey-api.js';
import { fetchInstance } from '@/instance.js'; import { fetchInstance } from '@/instance.js';
import { i18n } from '@/i18n.js'; import { i18n } from '@/i18n.js';
import { definePageMetadata } from '@/scripts/page-metadata.js'; import { definePageMetadata } from '@/scripts/page-metadata.js';
@ -170,7 +171,7 @@ const truemailAuthKey = ref<string | null>(null);
const bannedEmailDomains = ref<string>(''); const bannedEmailDomains = ref<string>('');
async function init() { async function init() {
const meta = await os.api('admin/meta'); const meta = await misskeyApi('admin/meta');
summalyProxy.value = meta.summalyProxy; summalyProxy.value = meta.summalyProxy;
enableHcaptcha.value = meta.enableHcaptcha; enableHcaptcha.value = meta.enableHcaptcha;
enableRecaptcha.value = meta.enableRecaptcha; enableRecaptcha.value = meta.enableRecaptcha;

View file

@ -158,6 +158,7 @@ import FormSection from '@/components/form/section.vue';
import FormSplit from '@/components/form/split.vue'; import FormSplit from '@/components/form/split.vue';
import FormSuspense from '@/components/form/suspense.vue'; import FormSuspense from '@/components/form/suspense.vue';
import * as os from '@/os.js'; import * as os from '@/os.js';
import { misskeyApi } from '@/scripts/misskey-api.js';
import { fetchInstance } from '@/instance.js'; import { fetchInstance } from '@/instance.js';
import { i18n } from '@/i18n.js'; import { i18n } from '@/i18n.js';
import { definePageMetadata } from '@/scripts/page-metadata.js'; import { definePageMetadata } from '@/scripts/page-metadata.js';
@ -184,7 +185,7 @@ const perUserListTimelineCacheMax = ref<number>(0);
const notesPerOneAd = ref<number>(0); const notesPerOneAd = ref<number>(0);
async function init(): Promise<void> { async function init(): Promise<void> {
const meta = await os.api('admin/meta'); const meta = await misskeyApi('admin/meta');
name.value = meta.name; name.value = meta.name;
shortName.value = meta.shortName; shortName.value = meta.shortName;
description.value = meta.description; description.value = meta.description;

View file

@ -45,6 +45,7 @@ import MkPagination from '@/components/MkPagination.vue';
import MkButton from '@/components/MkButton.vue'; import MkButton from '@/components/MkButton.vue';
import MkInfo from '@/components/MkInfo.vue'; import MkInfo from '@/components/MkInfo.vue';
import * as os from '@/os.js'; import * as os from '@/os.js';
import { misskeyApi } from '@/scripts/misskey-api.js';
import { i18n } from '@/i18n.js'; import { i18n } from '@/i18n.js';
import { definePageMetadata } from '@/scripts/page-metadata.js'; import { definePageMetadata } from '@/scripts/page-metadata.js';
import { $i, updateAccount } from '@/account.js'; import { $i, updateAccount } from '@/account.js';
@ -84,7 +85,7 @@ async function read(announcement) {
a.isRead = true; a.isRead = true;
return a; return a;
}); });
os.api('i/read-announcement', { announcementId: announcement.id }); misskeyApi('i/read-announcement', { announcementId: announcement.id });
updateAccount({ updateAccount({
unreadAnnouncements: $i!.unreadAnnouncements.filter(a => a.id !== announcement.id), unreadAnnouncements: $i!.unreadAnnouncements.filter(a => a.id !== announcement.id),
}); });

View file

@ -29,6 +29,7 @@ import * as Misskey from 'misskey-js';
import MkTimeline from '@/components/MkTimeline.vue'; import MkTimeline from '@/components/MkTimeline.vue';
import { scroll } from '@/scripts/scroll.js'; import { scroll } from '@/scripts/scroll.js';
import * as os from '@/os.js'; import * as os from '@/os.js';
import { misskeyApi } from '@/scripts/misskey-api.js';
import { useRouter } from '@/router.js'; import { useRouter } from '@/router.js';
import { definePageMetadata } from '@/scripts/page-metadata.js'; import { definePageMetadata } from '@/scripts/page-metadata.js';
import { i18n } from '@/i18n.js'; import { i18n } from '@/i18n.js';
@ -73,7 +74,7 @@ function focus() {
} }
watch(() => props.antennaId, async () => { watch(() => props.antennaId, async () => {
antenna.value = await os.api('antennas/show', { antenna.value = await misskeyApi('antennas/show', {
antennaId: props.antennaId, antennaId: props.antennaId,
}); });
}, { immediate: true }); }, { immediate: true });

View file

@ -41,7 +41,7 @@ import MkButton from '@/components/MkButton.vue';
import MkInput from '@/components/MkInput.vue'; import MkInput from '@/components/MkInput.vue';
import MkTextarea from '@/components/MkTextarea.vue'; import MkTextarea from '@/components/MkTextarea.vue';
import MkSwitch from '@/components/MkSwitch.vue'; import MkSwitch from '@/components/MkSwitch.vue';
import * as os from '@/os.js'; import { misskeyApi } from '@/scripts/misskey-api.js';
import { definePageMetadata } from '@/scripts/page-metadata.js'; import { definePageMetadata } from '@/scripts/page-metadata.js';
const body = ref('{}'); const body = ref('{}');
@ -51,14 +51,14 @@ const sending = ref(false);
const res = ref(''); const res = ref('');
const withCredential = ref(true); const withCredential = ref(true);
os.api('endpoints').then(endpointResponse => { misskeyApi('endpoints').then(endpointResponse => {
endpoints.value = endpointResponse; endpoints.value = endpointResponse;
}); });
function send() { function send() {
sending.value = true; sending.value = true;
const requestBody = JSON5.parse(body.value); const requestBody = JSON5.parse(body.value);
os.api(endpoint.value as keyof Endpoints, requestBody, requestBody.i || (withCredential.value ? undefined : null)).then(resp => { misskeyApi(endpoint.value as keyof Endpoints, requestBody, requestBody.i || (withCredential.value ? undefined : null)).then(resp => {
sending.value = false; sending.value = false;
res.value = JSON5.stringify(resp, null, 2); res.value = JSON5.stringify(resp, null, 2);
}, err => { }, err => {
@ -68,7 +68,7 @@ function send() {
} }
function onEndpointChange() { function onEndpointChange() {
os.api('endpoint', { endpoint: endpoint.value }, withCredential.value ? undefined : null).then(resp => { misskeyApi('endpoint', { endpoint: endpoint.value }, withCredential.value ? undefined : null).then(resp => {
const endpointBody = {}; const endpointBody = {};
for (const p of resp.params) { for (const p of resp.params) {
endpointBody[p.name] = endpointBody[p.name] =

View file

@ -23,7 +23,7 @@ SPDX-License-Identifier: AGPL-3.0-only
import { computed } from 'vue'; import { computed } from 'vue';
import * as Misskey from 'misskey-js'; import * as Misskey from 'misskey-js';
import MkButton from '@/components/MkButton.vue'; import MkButton from '@/components/MkButton.vue';
import * as os from '@/os.js'; import { misskeyApi } from '@/scripts/misskey-api.js';
import { i18n } from '@/i18n.js'; import { i18n } from '@/i18n.js';
const props = defineProps<{ const props = defineProps<{
@ -44,7 +44,7 @@ const name = computed(() => {
}); });
function cancel() { function cancel() {
os.api('auth/deny', { misskeyApi('auth/deny', {
token: props.session.token, token: props.session.token,
}).then(() => { }).then(() => {
emit('denied'); emit('denied');
@ -52,7 +52,7 @@ function cancel() {
} }
function accept() { function accept() {
os.api('auth/accept', { misskeyApi('auth/accept', {
token: props.session.token, token: props.session.token,
}).then(() => { }).then(() => {
emit('accepted'); emit('accepted');

View file

@ -46,7 +46,7 @@ import { onMounted, ref, computed } from 'vue';
import * as Misskey from 'misskey-js'; import * as Misskey from 'misskey-js';
import XForm from './auth.form.vue'; import XForm from './auth.form.vue';
import MkSignin from '@/components/MkSignin.vue'; import MkSignin from '@/components/MkSignin.vue';
import * as os from '@/os.js'; import { misskeyApi } from '@/scripts/misskey-api.js';
import { $i, login } from '@/account.js'; import { $i, login } from '@/account.js';
import { definePageMetadata } from '@/scripts/page-metadata.js'; import { definePageMetadata } from '@/scripts/page-metadata.js';
import { i18n } from '@/i18n.js'; import { i18n } from '@/i18n.js';
@ -75,13 +75,13 @@ onMounted(async () => {
if (!$i) return; if (!$i) return;
try { try {
session.value = await os.api('auth/session/show', { session.value = await misskeyApi('auth/session/show', {
token: props.token, token: props.token,
}); });
// //
if (session.value.app.isAuthorized) { if (session.value.app.isAuthorized) {
await os.api('auth/accept', { await misskeyApi('auth/accept', {
token: session.value.token, token: session.value.token,
}); });
accepted(); accepted();

View file

@ -40,6 +40,7 @@ import MkButton from '@/components/MkButton.vue';
import MkInput from '@/components/MkInput.vue'; import MkInput from '@/components/MkInput.vue';
import MkTextarea from '@/components/MkTextarea.vue'; import MkTextarea from '@/components/MkTextarea.vue';
import * as os from '@/os.js'; import * as os from '@/os.js';
import { misskeyApi } from '@/scripts/misskey-api.js';
import { i18n } from '@/i18n.js'; import { i18n } from '@/i18n.js';
import { definePageMetadata } from '@/scripts/page-metadata.js'; import { definePageMetadata } from '@/scripts/page-metadata.js';
import MkFolder from '@/components/MkFolder.vue'; import MkFolder from '@/components/MkFolder.vue';
@ -63,7 +64,7 @@ function del(avatarDecoration) {
}).then(({ canceled }) => { }).then(({ canceled }) => {
if (canceled) return; if (canceled) return;
avatarDecorations.value = avatarDecorations.value.filter(x => x !== avatarDecoration); avatarDecorations.value = avatarDecorations.value.filter(x => x !== avatarDecoration);
os.api('admin/avatar-decorations/delete', avatarDecoration); misskeyApi('admin/avatar-decorations/delete', avatarDecoration);
}); });
} }
@ -77,7 +78,7 @@ async function save(avatarDecoration) {
} }
function load() { function load() {
os.api('admin/avatar-decorations/list').then(_avatarDecorations => { misskeyApi('admin/avatar-decorations/list').then(_avatarDecorations => {
avatarDecorations.value = _avatarDecorations; avatarDecorations.value = _avatarDecorations;
}); });
} }

View file

@ -76,6 +76,7 @@ import MkInput from '@/components/MkInput.vue';
import MkColorInput from '@/components/MkColorInput.vue'; import MkColorInput from '@/components/MkColorInput.vue';
import { selectFile } from '@/scripts/select-file.js'; import { selectFile } from '@/scripts/select-file.js';
import * as os from '@/os.js'; import * as os from '@/os.js';
import { misskeyApi } from '@/scripts/misskey-api.js';
import { useRouter } from '@/router.js'; import { useRouter } from '@/router.js';
import { definePageMetadata } from '@/scripts/page-metadata.js'; import { definePageMetadata } from '@/scripts/page-metadata.js';
import { i18n } from '@/i18n.js'; import { i18n } from '@/i18n.js';
@ -105,7 +106,7 @@ watch(() => bannerId.value, async () => {
if (bannerId.value == null) { if (bannerId.value == null) {
bannerUrl.value = null; bannerUrl.value = null;
} else { } else {
bannerUrl.value = (await os.api('drive/files/show', { bannerUrl.value = (await misskeyApi('drive/files/show', {
fileId: bannerId.value, fileId: bannerId.value,
})).url; })).url;
} }
@ -114,7 +115,7 @@ watch(() => bannerId.value, async () => {
async function fetchChannel() { async function fetchChannel() {
if (props.channelId == null) return; if (props.channelId == null) return;
channel.value = await os.api('channels/show', { channel.value = await misskeyApi('channels/show', {
channelId: props.channelId, channelId: props.channelId,
}); });
@ -179,7 +180,7 @@ async function archive() {
if (canceled) return; if (canceled) return;
os.api('channels/update', { misskeyApi('channels/update', {
channelId: props.channelId, channelId: props.channelId,
isArchived: true, isArchived: true,
}).then(() => { }).then(() => {

View file

@ -74,6 +74,7 @@ import MkPostForm from '@/components/MkPostForm.vue';
import MkTimeline from '@/components/MkTimeline.vue'; import MkTimeline from '@/components/MkTimeline.vue';
import XChannelFollowButton from '@/components/MkChannelFollowButton.vue'; import XChannelFollowButton from '@/components/MkChannelFollowButton.vue';
import * as os from '@/os.js'; import * as os from '@/os.js';
import { misskeyApi } from '@/scripts/misskey-api.js';
import { useRouter } from '@/router.js'; import { useRouter } from '@/router.js';
import { $i, iAmModerator } from '@/account.js'; import { $i, iAmModerator } from '@/account.js';
import { i18n } from '@/i18n.js'; import { i18n } from '@/i18n.js';
@ -113,7 +114,7 @@ const featuredPagination = computed(() => ({
})); }));
watch(() => props.channelId, async () => { watch(() => props.channelId, async () => {
channel.value = await os.api('channels/show', { channel.value = await misskeyApi('channels/show', {
channelId: props.channelId, channelId: props.channelId,
}); });
favorited.value = channel.value.isFavorited ?? false; favorited.value = channel.value.isFavorited ?? false;

View file

@ -32,6 +32,7 @@ import MkNotes from '@/components/MkNotes.vue';
import { $i } from '@/account.js'; import { $i } from '@/account.js';
import { i18n } from '@/i18n.js'; import { i18n } from '@/i18n.js';
import * as os from '@/os.js'; import * as os from '@/os.js';
import { misskeyApi } from '@/scripts/misskey-api.js';
import { definePageMetadata } from '@/scripts/page-metadata.js'; import { definePageMetadata } from '@/scripts/page-metadata.js';
import { url } from '@/config.js'; import { url } from '@/config.js';
import MkButton from '@/components/MkButton.vue'; import MkButton from '@/components/MkButton.vue';
@ -56,7 +57,7 @@ const pagination = {
const isOwned = computed<boolean | null>(() => $i && clip.value && ($i.id === clip.value.userId)); const isOwned = computed<boolean | null>(() => $i && clip.value && ($i.id === clip.value.userId));
watch(() => props.clipId, async () => { watch(() => props.clipId, async () => {
clip.value = await os.api('clips/show', { clip.value = await misskeyApi('clips/show', {
clipId: props.clipId, clipId: props.clipId,
}); });
favorited.value = clip.value.isFavorited; favorited.value = clip.value.isFavorited;

View file

@ -82,6 +82,7 @@ import MkSwitch from '@/components/MkSwitch.vue';
import FormSplit from '@/components/form/split.vue'; import FormSplit from '@/components/form/split.vue';
import { selectFile } from '@/scripts/select-file.js'; import { selectFile } from '@/scripts/select-file.js';
import * as os from '@/os.js'; import * as os from '@/os.js';
import { misskeyApi } from '@/scripts/misskey-api.js';
import { i18n } from '@/i18n.js'; import { i18n } from '@/i18n.js';
import { definePageMetadata } from '@/scripts/page-metadata.js'; import { definePageMetadata } from '@/scripts/page-metadata.js';
@ -177,7 +178,7 @@ const menu = (ev: MouseEvent) => {
icon: 'ti ti-download', icon: 'ti ti-download',
text: i18n.ts.export, text: i18n.ts.export,
action: async () => { action: async () => {
os.api('export-custom-emojis', { misskeyApi('export-custom-emojis', {
}) })
.then(() => { .then(() => {
os.alert({ os.alert({
@ -196,7 +197,7 @@ const menu = (ev: MouseEvent) => {
text: i18n.ts.import, text: i18n.ts.import,
action: async () => { action: async () => {
const file = await selectFile(ev.currentTarget ?? ev.target); const file = await selectFile(ev.currentTarget ?? ev.target);
os.api('admin/emoji/import-zip', { misskeyApi('admin/emoji/import-zip', {
fileId: file.id, fileId: file.id,
}) })
.then(() => { .then(() => {

View file

@ -79,6 +79,7 @@ import bytes from '@/filters/bytes.js';
import { infoImageUrl } from '@/instance.js'; import { infoImageUrl } from '@/instance.js';
import { i18n } from '@/i18n.js'; import { i18n } from '@/i18n.js';
import * as os from '@/os.js'; import * as os from '@/os.js';
import { misskeyApi } from '@/scripts/misskey-api.js';
import { useRouter } from '@/router.js'; import { useRouter } from '@/router.js';
const router = useRouter(); const router = useRouter();
@ -94,7 +95,7 @@ const isImage = computed(() => file.value?.type.startsWith('image/'));
async function fetch() { async function fetch() {
fetching.value = true; fetching.value = true;
file.value = await os.api('drive/files/show', { file.value = await misskeyApi('drive/files/show', {
fileId: props.fileId, fileId: props.fileId,
}).catch((err) => { }).catch((err) => {
console.error(err); console.error(err);

View file

@ -85,6 +85,7 @@ import MkInput from '@/components/MkInput.vue';
import MkInfo from '@/components/MkInfo.vue'; import MkInfo from '@/components/MkInfo.vue';
import MkFolder from '@/components/MkFolder.vue'; import MkFolder from '@/components/MkFolder.vue';
import * as os from '@/os.js'; import * as os from '@/os.js';
import { misskeyApi } from '@/scripts/misskey-api.js';
import { i18n } from '@/i18n.js'; import { i18n } from '@/i18n.js';
import { customEmojiCategories } from '@/custom-emojis.js'; import { customEmojiCategories } from '@/custom-emojis.js';
import MkSwitch from '@/components/MkSwitch.vue'; import MkSwitch from '@/components/MkSwitch.vue';
@ -107,7 +108,7 @@ const rolesThatCanBeUsedThisEmojiAsReaction = ref<Misskey.entities.Role[]>([]);
const file = ref<Misskey.entities.DriveFile>(); const file = ref<Misskey.entities.DriveFile>();
watch(roleIdsThatCanBeUsedThisEmojiAsReaction, async () => { watch(roleIdsThatCanBeUsedThisEmojiAsReaction, async () => {
rolesThatCanBeUsedThisEmojiAsReaction.value = (await Promise.all(roleIdsThatCanBeUsedThisEmojiAsReaction.value.map((id) => os.api('admin/roles/show', { roleId: id }).catch(() => null)))).filter(x => x != null); rolesThatCanBeUsedThisEmojiAsReaction.value = (await Promise.all(roleIdsThatCanBeUsedThisEmojiAsReaction.value.map((id) => misskeyApi('admin/roles/show', { roleId: id }).catch(() => null)))).filter(x => x != null);
}, { immediate: true }); }, { immediate: true });
const imgUrl = computed(() => file.value ? file.value.url : props.emoji ? `/emoji/${props.emoji.name}.webp` : null); const imgUrl = computed(() => file.value ? file.value.url : props.emoji ? `/emoji/${props.emoji.name}.webp` : null);
@ -126,7 +127,7 @@ async function changeImage(ev) {
} }
async function addRole() { async function addRole() {
const roles = await os.api('admin/roles/list'); const roles = await misskeyApi('admin/roles/list');
const currentRoleIds = rolesThatCanBeUsedThisEmojiAsReaction.value.map(x => x.id); const currentRoleIds = rolesThatCanBeUsedThisEmojiAsReaction.value.map(x => x.id);
const { canceled, result: role } = await os.select({ const { canceled, result: role } = await os.select({
@ -188,7 +189,7 @@ async function del() {
}); });
if (canceled) return; if (canceled) return;
os.api('admin/emoji/delete', { misskeyApi('admin/emoji/delete', {
id: props.emoji.id, id: props.emoji.id,
}).then(() => { }).then(() => {
emit('done', { emit('done', {

View file

@ -16,6 +16,7 @@ SPDX-License-Identifier: AGPL-3.0-only
<script lang="ts" setup> <script lang="ts" setup>
import { } from 'vue'; import { } from 'vue';
import * as os from '@/os.js'; import * as os from '@/os.js';
import { misskeyApiGet } from '@/scripts/misskey-api.js';
import copyToClipboard from '@/scripts/copy-to-clipboard.js'; import copyToClipboard from '@/scripts/copy-to-clipboard.js';
import { i18n } from '@/i18n.js'; import { i18n } from '@/i18n.js';
@ -43,7 +44,7 @@ function menu(ev) {
text: i18n.ts.info, text: i18n.ts.info,
icon: 'ti ti-info-circle', icon: 'ti ti-info-circle',
action: () => { action: () => {
os.apiGet('emoji', { name: props.emoji.name }).then(res => { misskeyApiGet('emoji', { name: props.emoji.name }).then(res => {
os.alert({ os.alert({
type: 'info', type: 'info',
text: `Name: ${res.name}\nAliases: ${res.aliases.join(' ')}\nCategory: ${res.category}\nisSensitive: ${res.isSensitive}\nlocalOnly: ${res.localOnly}\nLicense: ${res.license}\nURL: ${res.url}`, text: `Name: ${res.name}\nAliases: ${res.aliases.join(' ')}\nCategory: ${res.category}\nisSensitive: ${res.isSensitive}\nlocalOnly: ${res.localOnly}\nLicense: ${res.license}\nURL: ${res.url}`,

View file

@ -15,11 +15,11 @@ SPDX-License-Identifier: AGPL-3.0-only
import { ref } from 'vue'; import { ref } from 'vue';
import * as Misskey from 'misskey-js'; import * as Misskey from 'misskey-js';
import MkRolePreview from '@/components/MkRolePreview.vue'; import MkRolePreview from '@/components/MkRolePreview.vue';
import * as os from '@/os.js'; import { misskeyApi } from '@/scripts/misskey-api.js';
const roles = ref<Misskey.entities.Role[] | null>(null); const roles = ref<Misskey.entities.Role[] | null>(null);
os.api('roles/list').then(res => { misskeyApi('roles/list').then(res => {
roles.value = res.filter(x => x.target === 'manual').sort((a, b) => b.displayOrder - a.displayOrder); roles.value = res.filter(x => x.target === 'manual').sort((a, b) => b.displayOrder - a.displayOrder);
}); });
</script> </script>

View file

@ -68,7 +68,7 @@ import * as Misskey from 'misskey-js';
import MkUserList from '@/components/MkUserList.vue'; import MkUserList from '@/components/MkUserList.vue';
import MkFoldableSection from '@/components/MkFoldableSection.vue'; import MkFoldableSection from '@/components/MkFoldableSection.vue';
import MkTab from '@/components/MkTab.vue'; import MkTab from '@/components/MkTab.vue';
import * as os from '@/os.js'; import { misskeyApi } from '@/scripts/misskey-api.js';
import { i18n } from '@/i18n.js'; import { i18n } from '@/i18n.js';
const props = defineProps<{ const props = defineProps<{
@ -123,14 +123,14 @@ const recentlyRegisteredUsersF = { endpoint: 'users', limit: 10, noPaging: true,
sort: '+createdAt', sort: '+createdAt',
} }; } };
os.api('hashtags/list', { misskeyApi('hashtags/list', {
sort: '+attachedLocalUsers', sort: '+attachedLocalUsers',
attachedToLocalUserOnly: true, attachedToLocalUserOnly: true,
limit: 30, limit: 30,
}).then(tags => { }).then(tags => {
tagsLocal.value = tags; tagsLocal.value = tags;
}); });
os.api('hashtags/list', { misskeyApi('hashtags/list', {
sort: '+attachedRemoteUsers', sort: '+attachedRemoteUsers',
attachedToRemoteUserOnly: true, attachedToRemoteUserOnly: true,
limit: 30, limit: 30,

View file

@ -38,6 +38,7 @@ import { computed, ref } from 'vue';
import * as Misskey from 'misskey-js'; import * as Misskey from 'misskey-js';
import MkButton from '@/components/MkButton.vue'; import MkButton from '@/components/MkButton.vue';
import * as os from '@/os.js'; import * as os from '@/os.js';
import { misskeyApi } from '@/scripts/misskey-api.js';
import { i18n } from '@/i18n.js'; import { i18n } from '@/i18n.js';
import { definePageMetadata } from '@/scripts/page-metadata.js'; import { definePageMetadata } from '@/scripts/page-metadata.js';
import MkTextarea from '@/components/MkTextarea.vue'; import MkTextarea from '@/components/MkTextarea.vue';
@ -369,7 +370,7 @@ const flash = ref<Misskey.entities.Flash | null>(null);
const visibility = ref<Misskey.entities.FlashUpdateRequest['visibility']>('public'); const visibility = ref<Misskey.entities.FlashUpdateRequest['visibility']>('public');
if (props.id) { if (props.id) {
flash.value = await os.api('flash/show', { flash.value = await misskeyApi('flash/show', {
flashId: props.id, flashId: props.id,
}); });
} }

View file

@ -62,6 +62,7 @@ import * as Misskey from 'misskey-js';
import { Interpreter, Parser, values } from '@syuilo/aiscript'; import { Interpreter, Parser, values } from '@syuilo/aiscript';
import MkButton from '@/components/MkButton.vue'; import MkButton from '@/components/MkButton.vue';
import * as os from '@/os.js'; import * as os from '@/os.js';
import { misskeyApi } from '@/scripts/misskey-api.js';
import { url } from '@/config.js'; import { url } from '@/config.js';
import { i18n } from '@/i18n.js'; import { i18n } from '@/i18n.js';
import { definePageMetadata } from '@/scripts/page-metadata.js'; import { definePageMetadata } from '@/scripts/page-metadata.js';
@ -84,7 +85,7 @@ const error = ref<any>(null);
function fetchFlash() { function fetchFlash() {
flash.value = null; flash.value = null;
os.api('flash/show', { misskeyApi('flash/show', {
flashId: props.id, flashId: props.id,
}).then(_flash => { }).then(_flash => {
flash.value = _flash; flash.value = _flash;

View file

@ -41,7 +41,7 @@ import { shallowRef, computed } from 'vue';
import MkPagination from '@/components/MkPagination.vue'; import MkPagination from '@/components/MkPagination.vue';
import MkButton from '@/components/MkButton.vue'; import MkButton from '@/components/MkButton.vue';
import { userPage, acct } from '@/filters/user.js'; import { userPage, acct } from '@/filters/user.js';
import * as os from '@/os.js'; import { misskeyApi } from '@/scripts/misskey-api.js';
import { i18n } from '@/i18n.js'; import { i18n } from '@/i18n.js';
import { definePageMetadata } from '@/scripts/page-metadata.js'; import { definePageMetadata } from '@/scripts/page-metadata.js';
import { infoImageUrl } from '@/instance.js'; import { infoImageUrl } from '@/instance.js';
@ -54,13 +54,13 @@ const pagination = {
}; };
function accept(user) { function accept(user) {
os.api('following/requests/accept', { userId: user.id }).then(() => { misskeyApi('following/requests/accept', { userId: user.id }).then(() => {
paginationComponent.value.reload(); paginationComponent.value.reload();
}); });
} }
function reject(user) { function reject(user) {
os.api('following/requests/reject', { userId: user.id }).then(() => { misskeyApi('following/requests/reject', { userId: user.id }).then(() => {
paginationComponent.value.reload(); paginationComponent.value.reload();
}); });
} }

View file

@ -12,9 +12,10 @@ SPDX-License-Identifier: AGPL-3.0-only
import { } from 'vue'; import { } from 'vue';
import * as Misskey from 'misskey-js'; import * as Misskey from 'misskey-js';
import * as os from '@/os.js'; import * as os from '@/os.js';
import { misskeyApi } from '@/scripts/misskey-api.js';
import { mainRouter } from '@/router.js'; import { mainRouter } from '@/router.js';
import { i18n } from '@/i18n.js'; import { i18n } from '@/i18n.js';
import { defaultStore } from "@/store.js"; import { defaultStore } from '@/store.js';
async function follow(user): Promise<void> { async function follow(user): Promise<void> {
const { canceled } = await os.confirm({ const { canceled } = await os.confirm({
@ -42,7 +43,7 @@ if (acct == null) {
let promise; let promise;
if (acct.startsWith('https://')) { if (acct.startsWith('https://')) {
promise = os.api('ap/show', { promise = misskeyApi('ap/show', {
uri: acct, uri: acct,
}); });
promise.then(res => { promise.then(res => {
@ -60,7 +61,7 @@ if (acct.startsWith('https://')) {
} }
}); });
} else { } else {
promise = os.api('users/show', Misskey.acct.parse(acct)); promise = misskeyApi('users/show', Misskey.acct.parse(acct));
promise.then(user => { promise.then(user => {
follow(user); follow(user);
}); });

View file

@ -47,6 +47,7 @@ import MkSwitch from '@/components/MkSwitch.vue';
import FormSuspense from '@/components/form/suspense.vue'; import FormSuspense from '@/components/form/suspense.vue';
import { selectFiles } from '@/scripts/select-file.js'; import { selectFiles } from '@/scripts/select-file.js';
import * as os from '@/os.js'; import * as os from '@/os.js';
import { misskeyApi } from '@/scripts/misskey-api.js';
import { useRouter } from '@/router.js'; import { useRouter } from '@/router.js';
import { definePageMetadata } from '@/scripts/page-metadata.js'; import { definePageMetadata } from '@/scripts/page-metadata.js';
import { i18n } from '@/i18n.js'; import { i18n } from '@/i18n.js';
@ -107,7 +108,7 @@ async function del() {
} }
watch(() => props.postId, () => { watch(() => props.postId, () => {
init.value = () => props.postId ? os.api('gallery/posts/show', { init.value = () => props.postId ? misskeyApi('gallery/posts/show', {
postId: props.postId, postId: props.postId,
}).then(post => { }).then(post => {
files.value = post.files ?? []; files.value = post.files ?? [];

View file

@ -66,6 +66,7 @@ import { computed, watch, ref } from 'vue';
import * as Misskey from 'misskey-js'; import * as Misskey from 'misskey-js';
import MkButton from '@/components/MkButton.vue'; import MkButton from '@/components/MkButton.vue';
import * as os from '@/os.js'; import * as os from '@/os.js';
import { misskeyApi } from '@/scripts/misskey-api.js';
import MkContainer from '@/components/MkContainer.vue'; import MkContainer from '@/components/MkContainer.vue';
import MkPagination from '@/components/MkPagination.vue'; import MkPagination from '@/components/MkPagination.vue';
import MkGalleryPostPreview from '@/components/MkGalleryPostPreview.vue'; import MkGalleryPostPreview from '@/components/MkGalleryPostPreview.vue';
@ -97,7 +98,7 @@ const otherPostsPagination = {
function fetchPost() { function fetchPost() {
post.value = null; post.value = null;
os.api('gallery/posts/show', { misskeyApi('gallery/posts/show', {
postId: props.postId, postId: props.postId,
}).then(_post => { }).then(_post => {
post.value = _post; post.value = _post;

View file

@ -105,6 +105,7 @@ import MkInfo from '@/components/MkInfo.vue';
import MkFolder from '@/components/MkFolder.vue'; import MkFolder from '@/components/MkFolder.vue';
import MkKeyValue from '@/components/MkKeyValue.vue'; import MkKeyValue from '@/components/MkKeyValue.vue';
import * as os from '@/os.js'; import * as os from '@/os.js';
import { misskeyApi } from '@/scripts/misskey-api.js';
import { AiScriptPluginMeta, parsePluginMeta, installPlugin } from '@/scripts/install-plugin.js'; import { AiScriptPluginMeta, parsePluginMeta, installPlugin } from '@/scripts/install-plugin.js';
import { parseThemeCode, installTheme } from '@/scripts/install-theme.js'; import { parseThemeCode, installTheme } from '@/scripts/install-theme.js';
import { unisonReload } from '@/scripts/unison-reload.js'; import { unisonReload } from '@/scripts/unison-reload.js';
@ -159,7 +160,7 @@ async function fetch() {
uiPhase.value = 'error'; uiPhase.value = 'error';
return; return;
} }
const res = await os.api('fetch-external-resources', { const res = await misskeyApi('fetch-external-resources', {
url: url.value, url: url.value,
hash: hash.value, hash: hash.value,
}).catch((err) => { }).catch((err) => {

View file

@ -129,6 +129,7 @@ import MkKeyValue from '@/components/MkKeyValue.vue';
import MkSelect from '@/components/MkSelect.vue'; import MkSelect from '@/components/MkSelect.vue';
import MkSwitch from '@/components/MkSwitch.vue'; import MkSwitch from '@/components/MkSwitch.vue';
import * as os from '@/os.js'; import * as os from '@/os.js';
import { misskeyApi } from '@/scripts/misskey-api.js';
import number from '@/filters/number.js'; import number from '@/filters/number.js';
import { iAmModerator, iAmAdmin } from '@/account.js'; import { iAmModerator, iAmAdmin } from '@/account.js';
import { definePageMetadata } from '@/scripts/page-metadata.js'; import { definePageMetadata } from '@/scripts/page-metadata.js';
@ -164,9 +165,9 @@ const usersPagination = {
async function fetch(): Promise<void> { async function fetch(): Promise<void> {
if (iAmAdmin) { if (iAmAdmin) {
meta.value = await os.api('admin/meta'); meta.value = await misskeyApi('admin/meta');
} }
instance.value = await os.api('federation/show-instance', { instance.value = await misskeyApi('federation/show-instance', {
host: props.host, host: props.host,
}); });
suspended.value = instance.value?.isSuspended ?? false; suspended.value = instance.value?.isSuspended ?? false;
@ -179,7 +180,7 @@ async function toggleBlock(): Promise<void> {
if (!meta.value) throw new Error('No meta?'); if (!meta.value) throw new Error('No meta?');
if (!instance.value) throw new Error('No instance?'); if (!instance.value) throw new Error('No instance?');
const { host } = instance.value; const { host } = instance.value;
await os.api('admin/update-meta', { await misskeyApi('admin/update-meta', {
blockedHosts: isBlocked.value ? meta.value.blockedHosts.concat([host]) : meta.value.blockedHosts.filter(x => x !== host), blockedHosts: isBlocked.value ? meta.value.blockedHosts.concat([host]) : meta.value.blockedHosts.filter(x => x !== host),
}); });
} }
@ -189,14 +190,14 @@ async function toggleSilenced(): Promise<void> {
if (!instance.value) throw new Error('No instance?'); if (!instance.value) throw new Error('No instance?');
const { host } = instance.value; const { host } = instance.value;
const silencedHosts = meta.value.silencedHosts ?? []; const silencedHosts = meta.value.silencedHosts ?? [];
await os.api('admin/update-meta', { await misskeyApi('admin/update-meta', {
silencedHosts: isSilenced.value ? silencedHosts.concat([host]) : silencedHosts.filter(x => x !== host), silencedHosts: isSilenced.value ? silencedHosts.concat([host]) : silencedHosts.filter(x => x !== host),
}); });
} }
async function toggleSuspend(): Promise<void> { async function toggleSuspend(): Promise<void> {
if (!instance.value) throw new Error('No instance?'); if (!instance.value) throw new Error('No instance?');
await os.api('admin/federation/update-instance', { await misskeyApi('admin/federation/update-instance', {
host: instance.value.host, host: instance.value.host,
isSuspended: suspended.value, isSuspended: suspended.value,
}); });
@ -204,7 +205,7 @@ async function toggleSuspend(): Promise<void> {
function refreshMetadata(): void { function refreshMetadata(): void {
if (!instance.value) throw new Error('No instance?'); if (!instance.value) throw new Error('No instance?');
os.api('admin/federation/refresh-remote-instance-metadata', { misskeyApi('admin/federation/refresh-remote-instance-metadata', {
host: instance.value.host, host: instance.value.host,
}); });
os.alert({ os.alert({

Some files were not shown because too many files have changed in this diff Show more