From 24734d408700a72d45c3ff4a679606cab3ec544f Mon Sep 17 00:00:00 2001 From: Freya Murphy Date: Mon, 2 Mar 2026 16:05:12 -0500 Subject: split url into webUrl and localUrl (like mastodon) --- packages/frontend/src/accounts.ts | 20 ++++++++++---------- packages/frontend/src/aiscript/api.ts | 4 ++-- packages/frontend/src/components/MkAccountMoved.vue | 2 +- packages/frontend/src/components/MkDonation.vue | 6 +++--- .../frontend/src/components/MkEmbedCodeGenDialog.vue | 4 ++-- packages/frontend/src/components/MkFollowButton.vue | 4 ++-- packages/frontend/src/components/MkLink.vue | 4 ++-- packages/frontend/src/components/MkMention.vue | 2 +- packages/frontend/src/components/MkNote.vue | 2 +- packages/frontend/src/components/MkNoteDetailed.vue | 2 +- packages/frontend/src/components/MkNoteSub.vue | 2 +- packages/frontend/src/components/MkPageWindow.vue | 6 +++--- packages/frontend/src/components/MkPoll.vue | 2 +- packages/frontend/src/components/MkPostForm.vue | 8 ++++---- packages/frontend/src/components/MkPreview.vue | 2 +- packages/frontend/src/components/MkSignin.input.vue | 2 +- .../frontend/src/components/MkSignupDialog.form.vue | 2 +- .../src/components/MkSourceCodeAvailablePopup.vue | 6 +++--- .../frontend/src/components/MkTutorialDialog.vue | 4 ++-- packages/frontend/src/components/MkUrlPreview.vue | 4 ++-- .../frontend/src/components/MkUserSelectDialog.vue | 4 ++-- .../frontend/src/components/MkUserSetupDialog.vue | 6 +++--- packages/frontend/src/components/SkNote.vue | 2 +- packages/frontend/src/components/SkNoteDetailed.vue | 2 +- packages/frontend/src/components/SkNoteSub.vue | 2 +- packages/frontend/src/components/global/MkA.vue | 4 ++-- packages/frontend/src/components/global/MkAcct.vue | 2 +- packages/frontend/src/components/global/MkAd.vue | 4 ++-- packages/frontend/src/components/global/MkMfm.ts | 4 ++-- packages/frontend/src/components/global/MkUrl.vue | 4 ++-- packages/frontend/src/filters/user.ts | 4 ++-- packages/frontend/src/pages/about.overview.vue | 6 +++--- packages/frontend/src/pages/admin-user.vue | 1 - packages/frontend/src/pages/admin/branding.vue | 6 +++--- packages/frontend/src/pages/channel.vue | 6 +++--- packages/frontend/src/pages/chat/XMessage.vue | 4 ++-- packages/frontend/src/pages/clip.vue | 6 +++--- packages/frontend/src/pages/explore.featured.vue | 4 ++-- packages/frontend/src/pages/explore.users.vue | 4 ++-- packages/frontend/src/pages/flash/flash.vue | 12 ++++++------ packages/frontend/src/pages/gallery/post.vue | 10 +++++----- packages/frontend/src/pages/note.vue | 2 +- .../frontend/src/pages/page-editor/page-editor.vue | 1 - packages/frontend/src/pages/page.vue | 10 +++++----- packages/frontend/src/pages/reversi/game.board.vue | 4 ++-- packages/frontend/src/pages/reversi/game.vue | 4 ++-- packages/frontend/src/pages/search.note.vue | 4 ++-- .../frontend/src/pages/settings/2fa.qrdialog.vue | 4 ++-- .../settings/profile.attribution-domains-setting.vue | 4 ++-- packages/frontend/src/pages/theme-editor.vue | 4 ++-- packages/frontend/src/pages/welcome.setup.vue | 4 ++-- packages/frontend/src/preferences/manager.ts | 16 ++++++++-------- packages/frontend/src/ui/_common_/common.ts | 4 ++-- packages/frontend/src/ui/_common_/titlebar.vue | 4 ++-- packages/frontend/src/utility/get-embed-code.ts | 6 +++--- packages/frontend/src/utility/get-note-menu.ts | 8 ++++---- packages/frontend/src/utility/get-user-menu.ts | 8 ++++---- packages/frontend/src/utility/getNoteUrls.ts | 8 ++++---- packages/frontend/src/utility/media-proxy.ts | 8 ++++---- .../frontend/src/utility/player-url-transform.ts | 4 ++-- packages/frontend/src/utility/popout.ts | 2 +- packages/frontend/src/widgets/WidgetInstanceInfo.vue | 4 ++-- packages/frontend/src/widgets/WidgetRss.vue | 2 +- packages/frontend/src/widgets/WidgetRssTicker.vue | 2 +- 64 files changed, 150 insertions(+), 152 deletions(-) (limited to 'packages/frontend') diff --git a/packages/frontend/src/accounts.ts b/packages/frontend/src/accounts.ts index 4ee951bbd7..9ce21b9543 100644 --- a/packages/frontend/src/accounts.ts +++ b/packages/frontend/src/accounts.ts @@ -5,7 +5,7 @@ import { defineAsyncComponent, ref } from 'vue'; import * as Misskey from 'misskey-js'; -import { apiUrl, host } from '@@/js/config.js'; +import { apiUrl, localHost } from '@@/js/config.js'; import type { MenuItem } from '@/types/menu.js'; import { showSuspendedDialog } from '@/utility/show-suspended-dialog.js'; import { i18n } from '@/i18n.js'; @@ -137,7 +137,7 @@ export function updateCurrentAccount(accountData: Misskey.entities.MeDetailed) { for (const [key, value] of Object.entries(accountData)) { $i[key] = value; } - store.set('accountInfos', { ...store.s.accountInfos, [host + '/' + $i.id]: $i }); + store.set('accountInfos', { ...store.s.accountInfos, [localHost + '/' + $i.id]: $i }); $i.token = token; miLocalStorage.setItem('account', JSON.stringify($i)); } @@ -148,7 +148,7 @@ export function updateCurrentAccountPartial(accountData: Partial { if (reason === isAccountDeleted) { - removeAccount(host, $i.id); + removeAccount(localHost, $i.id); if (Object.keys(store.s.accountTokens).length > 0) { login(Object.values(store.s.accountTokens)[0]); } else { @@ -186,7 +186,7 @@ export async function login(token: AccountWithToken['token'], redirect?: string) token, })); - await addAccount(host, me, token); + await addAccount(localHost, me, token); if (redirect) { // 他のタブは再読み込みするだけ @@ -272,7 +272,7 @@ export async function openAccountMenu(opts: { }); if (opts.includeCurrentAccount) { - menuItems.push(createItem(host, $i.id, $i.username, $i, $i.token)); + menuItems.push(createItem(localHost, $i.id, $i.username, $i, $i.token)); } menuItems.push(...accountItems); @@ -295,7 +295,7 @@ export async function openAccountMenu(opts: { action: () => { getAccountWithSignupDialog().then(res => { if (res != null) { - switchAccount(host, res.id); + switchAccount(localHost, res.id); } }); }, @@ -313,7 +313,7 @@ export async function openAccountMenu(opts: { }); } else { if (opts.includeCurrentAccount) { - menuItems.push(createItem(host, $i.id, $i.username, $i, $i.token)); + menuItems.push(createItem(localHost, $i.id, $i.username, $i, $i.token)); } menuItems.push(...accountItems); @@ -329,7 +329,7 @@ export function getAccountWithSigninDialog(): Promise<{ id: string, token: strin const { dispose } = popup(defineAsyncComponent(() => import('@/components/MkSigninDialog.vue')), {}, { done: async (res: Misskey.entities.SigninFlowResponse & { finished: true }) => { const user = await fetchAccount(res.i, res.id, true); - await addAccount(host, user, res.i); + await addAccount(localHost, user, res.i); resolve({ id: res.id, token: res.i }); }, cancelled: () => { @@ -348,7 +348,7 @@ export function getAccountWithSignupDialog(): Promise<{ id: string, token: strin done: async (res: Misskey.entities.SignupResponse) => { const user = JSON.parse(JSON.stringify(res)); delete user.token; - await addAccount(host, user, res.token); + await addAccount(localHost, user, res.token); resolve({ id: res.id, token: res.token }); }, cancelled: () => { diff --git a/packages/frontend/src/aiscript/api.ts b/packages/frontend/src/aiscript/api.ts index 08ba89dd9d..444a770ba5 100644 --- a/packages/frontend/src/aiscript/api.ts +++ b/packages/frontend/src/aiscript/api.ts @@ -5,7 +5,7 @@ import { errors, utils, values } from '@syuilo/aiscript'; import * as Misskey from 'misskey-js'; -import { url, lang } from '@@/js/config.js'; +import { webUrl, lang } from '@@/js/config.js'; import { assertStringAndIsIn } from './common.js'; import * as os from '@/os.js'; import { misskeyApi } from '@/utility/misskey-api.js'; @@ -39,7 +39,7 @@ export function createAiScriptEnv(opts: { storageKey: string, token?: string }) USER_USERNAME: $i ? values.STR($i.username) : values.NULL, CUSTOM_EMOJIS: utils.jsToVal(customEmojis.value), LOCALE: values.STR(lang), - SERVER_URL: values.STR(url), + SERVER_URL: values.STR(webUrl), 'Mk:dialog': values.FN_NATIVE(async ([title, text, type]) => { utils.assertString(title); utils.assertString(text); diff --git a/packages/frontend/src/components/MkAccountMoved.vue b/packages/frontend/src/components/MkAccountMoved.vue index cb8032c019..e101c04793 100644 --- a/packages/frontend/src/components/MkAccountMoved.vue +++ b/packages/frontend/src/components/MkAccountMoved.vue @@ -16,7 +16,7 @@ import { ref } from 'vue'; import * as Misskey from 'misskey-js'; import MkMention from './MkMention.vue'; import { i18n } from '@/i18n.js'; -import { host as localHost } from '@@/js/config.js'; +import { localHost } from '@@/js/config.js'; import { misskeyApi } from '@/utility/misskey-api.js'; const user = ref(); diff --git a/packages/frontend/src/components/MkDonation.vue b/packages/frontend/src/components/MkDonation.vue index dfdfc0a871..be0a737b60 100644 --- a/packages/frontend/src/components/MkDonation.vue +++ b/packages/frontend/src/components/MkDonation.vue @@ -19,7 +19,7 @@ SPDX-License-Identifier: AGPL-3.0-only
@@ -29,7 +29,7 @@ SPDX-License-Identifier: AGPL-3.0-only
@@ -48,7 +48,7 @@ SPDX-License-Identifier: AGPL-3.0-only `, + ``, + ``, ]; return iframeCode.join('\n'); } diff --git a/packages/frontend/src/utility/get-note-menu.ts b/packages/frontend/src/utility/get-note-menu.ts index 056480a7ef..0096ed68da 100644 --- a/packages/frontend/src/utility/get-note-menu.ts +++ b/packages/frontend/src/utility/get-note-menu.ts @@ -5,7 +5,7 @@ import { defineAsyncComponent } from 'vue'; import * as Misskey from 'misskey-js'; -import { url } from '@@/js/config.js'; +import { webUrl } from '@@/js/config.js'; import { claimAchievement } from './achievements.js'; import type { Ref, ShallowRef } from 'vue'; import type { MenuItem } from '@/types/menu.js'; @@ -137,7 +137,7 @@ export function getAbuseNoteMenu(note: Misskey.entities.Note, text: string): Men icon: 'ti ti-exclamation-circle', text, action: (): void => { - const localUrl = `${url}/notes/${note.id}`; + const localUrl = `${webUrl}/notes/${note.id}`; let noteInfo = ''; if (note.url ?? note.uri != null) noteInfo = `Note: ${note.url ?? note.uri}\n`; noteInfo += `Local Note: ${localUrl}\n`; @@ -156,7 +156,7 @@ export function getCopyNoteLinkMenu(note: Misskey.entities.Note, text: string): icon: 'ti ti-link', text, action: (): void => { - copyToClipboard(`${url}/notes/${note.id}`); + copyToClipboard(`${webUrl}/notes/${note.id}`); }, }; } @@ -282,7 +282,7 @@ export function getNoteMenu(props: { navigator.share({ title: i18n.tsx.noteOf({ user: appearNote.user.name ?? appearNote.user.username }), text: appearNote.text ?? '', - url: `${url}/notes/${appearNote.id}`, + url: `${webUrl}/notes/${appearNote.id}`, }); } diff --git a/packages/frontend/src/utility/get-user-menu.ts b/packages/frontend/src/utility/get-user-menu.ts index fde390cece..e1a746b579 100644 --- a/packages/frontend/src/utility/get-user-menu.ts +++ b/packages/frontend/src/utility/get-user-menu.ts @@ -6,7 +6,7 @@ import { toUnicode } from 'punycode.js'; import { defineAsyncComponent, ref, watch } from 'vue'; import * as Misskey from 'misskey-js'; -import { host, url } from '@@/js/config.js'; +import { localHost, webUrl } from '@@/js/config.js'; import type { Router } from '@/router.js'; import type { MenuItem } from '@/types/menu.js'; import { i18n } from '@/i18n.js'; @@ -164,7 +164,7 @@ export function getUserMenu(user: Misskey.entities.UserDetailed, router: Router icon: 'ti ti-at', text: i18n.ts.copyUsername, action: () => { - copyToClipboard(`@${user.username}@${user.host ?? host}`); + copyToClipboard(`@${user.username}@${user.host ?? localHost}`); }, }); @@ -173,7 +173,7 @@ export function getUserMenu(user: Misskey.entities.UserDetailed, router: Router text: i18n.ts.copyProfileUrl, action: () => { const canonical = user.host === null ? `@${user.username}` : `@${user.username}@${toUnicode(user.host)}`; - copyToClipboard(`${url}/${canonical}`); + copyToClipboard(`${webUrl}/${canonical}`); }, }); @@ -181,7 +181,7 @@ export function getUserMenu(user: Misskey.entities.UserDetailed, router: Router icon: 'ti ti-rss', text: i18n.ts.copyRSS, action: () => { - copyToClipboard(`${user.host ?? host}/@${user.username}.atom`); + copyToClipboard(`${user.host ?? localHost}/@${user.username}.atom`); }, }); diff --git a/packages/frontend/src/utility/getNoteUrls.ts b/packages/frontend/src/utility/getNoteUrls.ts index efd014cbf0..c92e3a868b 100644 --- a/packages/frontend/src/utility/getNoteUrls.ts +++ b/packages/frontend/src/utility/getNoteUrls.ts @@ -9,7 +9,7 @@ import type * as Misskey from 'misskey-js'; export function getNoteUrls(note: Misskey.entities.Note): string[] { const urls: string[] = [ // Any note - `${config.url}/notes/${note.id}`, + `${config.webUrl}/notes/${note.id}`, ]; // Remote note @@ -18,7 +18,7 @@ export function getNoteUrls(note: Misskey.entities.Note): string[] { if (note.reply) { // Any Reply - urls.push(`${config.url}/notes/${note.reply.id}`); + urls.push(`${config.webUrl}/notes/${note.reply.id}`); // Remote Reply if (note.reply.url) urls.push(note.reply.url); if (note.reply.uri) urls.push(note.reply.uri); @@ -26,7 +26,7 @@ export function getNoteUrls(note: Misskey.entities.Note): string[] { if (note.renote) { // Any Renote - urls.push(`${config.url}/notes/${note.renote.id}`); + urls.push(`${config.webUrl}/notes/${note.renote.id}`); // Remote Renote if (note.renote.url) urls.push(note.renote.url); if (note.renote.uri) urls.push(note.renote.uri); @@ -34,7 +34,7 @@ export function getNoteUrls(note: Misskey.entities.Note): string[] { if (note.renote?.renote) { // Any Quote - urls.push(`${config.url}/notes/${note.renote.renote.id}`); + urls.push(`${config.webUrl}/notes/${note.renote.renote.id}`); // Remote Quote if (note.renote.renote.url) urls.push(note.renote.renote.url); if (note.renote.renote.uri) urls.push(note.renote.renote.uri); diff --git a/packages/frontend/src/utility/media-proxy.ts b/packages/frontend/src/utility/media-proxy.ts index 78eba35ead..d93c0448d1 100644 --- a/packages/frontend/src/utility/media-proxy.ts +++ b/packages/frontend/src/utility/media-proxy.ts @@ -4,14 +4,14 @@ */ import { MediaProxy } from '@@/js/media-proxy.js'; -import { url } from '@@/js/config.js'; +import { webUrl } from '@@/js/config.js'; import { instance } from '@/instance.js'; let _mediaProxy: MediaProxy | null = null; export function getProxiedImageUrl(...args: Parameters): string { if (_mediaProxy == null) { - _mediaProxy = new MediaProxy(instance, url); + _mediaProxy = new MediaProxy(instance, webUrl); } return _mediaProxy.getProxiedImageUrl(...args); @@ -19,7 +19,7 @@ export function getProxiedImageUrl(...args: Parameters): string | null { if (_mediaProxy == null) { - _mediaProxy = new MediaProxy(instance, url); + _mediaProxy = new MediaProxy(instance, webUrl); } return _mediaProxy.getProxiedImageUrlNullable(...args); @@ -27,7 +27,7 @@ export function getProxiedImageUrlNullable(...args: Parameters): string { if (_mediaProxy == null) { - _mediaProxy = new MediaProxy(instance, url); + _mediaProxy = new MediaProxy(instance, webUrl); } return _mediaProxy.getStaticImageUrl(...args); diff --git a/packages/frontend/src/utility/player-url-transform.ts b/packages/frontend/src/utility/player-url-transform.ts index 39c6df6500..068a11874e 100644 --- a/packages/frontend/src/utility/player-url-transform.ts +++ b/packages/frontend/src/utility/player-url-transform.ts @@ -2,7 +2,7 @@ * SPDX-FileCopyrightText: syuilo and misskey-project * SPDX-License-Identifier: AGPL-3.0-only */ -import { hostname } from '@@/js/config.js'; +import { webHost } from '@@/js/config.js'; export function transformPlayerUrl(url: string): string { const urlObj = new URL(url); @@ -13,7 +13,7 @@ export function transformPlayerUrl(url: string): string { if (urlObj.hostname === 'player.twitch.tv') { // TwitchはCSPの制約あり // https://dev.twitch.tv/docs/embed/video-and-clips/ - urlParams.set('parent', hostname); + urlParams.set('parent', webHost); urlParams.set('allowfullscreen', ''); urlParams.set('autoplay', 'true'); } else { diff --git a/packages/frontend/src/utility/popout.ts b/packages/frontend/src/utility/popout.ts index 5b141222e8..6cde3d8a33 100644 --- a/packages/frontend/src/utility/popout.ts +++ b/packages/frontend/src/utility/popout.ts @@ -7,7 +7,7 @@ import { appendQuery } from '@@/js/url.js'; import * as config from '@@/js/config.js'; export function popout(path: string, w?: HTMLElement) { - let url = path.startsWith('http://') || path.startsWith('https://') ? path : config.url + path; + let url = path.startsWith('http://') || path.startsWith('https://') ? path : config.webUrl + path; url = appendQuery(url, 'zen'); if (w) { const position = w.getBoundingClientRect(); diff --git a/packages/frontend/src/widgets/WidgetInstanceInfo.vue b/packages/frontend/src/widgets/WidgetInstanceInfo.vue index 9708b63a8d..4ace9c25b4 100644 --- a/packages/frontend/src/widgets/WidgetInstanceInfo.vue +++ b/packages/frontend/src/widgets/WidgetInstanceInfo.vue @@ -12,7 +12,7 @@ SPDX-License-Identifier: AGPL-3.0-only
{{ instance.name }} -
{{ host }}
+
{{ webHost }}
@@ -23,7 +23,7 @@ SPDX-License-Identifier: AGPL-3.0-only import { useWidgetPropsManager } from './widget.js'; import type { WidgetComponentEmits, WidgetComponentExpose, WidgetComponentProps } from './widget.js'; import type { GetFormResultType } from '@/utility/form.js'; -import { host } from '@@/js/config.js'; +import { webHost } from '@@/js/config.js'; import { instance } from '@/instance.js'; const name = 'instanceInfo'; diff --git a/packages/frontend/src/widgets/WidgetRss.vue b/packages/frontend/src/widgets/WidgetRss.vue index 132eb0a629..8583d56c89 100644 --- a/packages/frontend/src/widgets/WidgetRss.vue +++ b/packages/frontend/src/widgets/WidgetRss.vue @@ -25,7 +25,7 @@ SPDX-License-Identifier: AGPL-3.0-only